documentation.d.ts 3.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890
  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. */
  1123. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1124. /**
  1125. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1126. * @param data contains the texture data
  1127. * @param texture defines the BabylonJS internal texture
  1128. * @param callback defines the method to call once ready to upload
  1129. */
  1130. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1131. }
  1132. }
  1133. declare module BABYLON {
  1134. /**
  1135. * Class used to store and describe the pipeline context associated with an effect
  1136. */
  1137. export interface IPipelineContext {
  1138. /**
  1139. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1140. */
  1141. isAsync: boolean;
  1142. /**
  1143. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1144. */
  1145. isReady: boolean;
  1146. /** @hidden */
  1147. _getVertexShaderCode(): string | null;
  1148. /** @hidden */
  1149. _getFragmentShaderCode(): string | null;
  1150. /** @hidden */
  1151. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1152. }
  1153. }
  1154. declare module BABYLON {
  1155. /**
  1156. * Class used to store gfx data (like WebGLBuffer)
  1157. */
  1158. export class DataBuffer {
  1159. /**
  1160. * Gets or sets the number of objects referencing this buffer
  1161. */
  1162. references: number;
  1163. /** Gets or sets the size of the underlying buffer */
  1164. capacity: number;
  1165. /**
  1166. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1167. */
  1168. is32Bits: boolean;
  1169. /**
  1170. * Gets the underlying buffer
  1171. */
  1172. get underlyingResource(): any;
  1173. }
  1174. }
  1175. declare module BABYLON {
  1176. /** @hidden */
  1177. export interface IShaderProcessor {
  1178. attributeProcessor?: (attribute: string) => string;
  1179. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1180. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1181. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1182. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1183. lineProcessor?: (line: string, isFragment: boolean) => string;
  1184. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1185. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export interface ProcessingOptions {
  1191. defines: string[];
  1192. indexParameters: any;
  1193. isFragment: boolean;
  1194. shouldUseHighPrecisionShader: boolean;
  1195. supportsUniformBuffers: boolean;
  1196. shadersRepository: string;
  1197. includesShadersStore: {
  1198. [key: string]: string;
  1199. };
  1200. processor?: IShaderProcessor;
  1201. version: string;
  1202. platformName: string;
  1203. lookForClosingBracketForUniformBuffer?: boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderCodeNode {
  1209. line: string;
  1210. children: ShaderCodeNode[];
  1211. additionalDefineKey?: string;
  1212. additionalDefineValue?: string;
  1213. isValid(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. process(preprocessors: {
  1217. [key: string]: string;
  1218. }, options: ProcessingOptions): string;
  1219. }
  1220. }
  1221. declare module BABYLON {
  1222. /** @hidden */
  1223. export class ShaderCodeCursor {
  1224. private _lines;
  1225. lineIndex: number;
  1226. get currentLine(): string;
  1227. get canRead(): boolean;
  1228. set lines(value: string[]);
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1234. process(preprocessors: {
  1235. [key: string]: string;
  1236. }, options: ProcessingOptions): string;
  1237. }
  1238. }
  1239. declare module BABYLON {
  1240. /** @hidden */
  1241. export class ShaderDefineExpression {
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. private static _OperatorPriority;
  1246. private static _Stack;
  1247. static postfixToInfix(postfix: string[]): string;
  1248. static infixToPostfix(infix: string): string[];
  1249. }
  1250. }
  1251. declare module BABYLON {
  1252. /** @hidden */
  1253. export class ShaderCodeTestNode extends ShaderCodeNode {
  1254. testExpression: ShaderDefineExpression;
  1255. isValid(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. }
  1259. }
  1260. declare module BABYLON {
  1261. /** @hidden */
  1262. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1263. define: string;
  1264. not: boolean;
  1265. constructor(define: string, not?: boolean);
  1266. isTrue(preprocessors: {
  1267. [key: string]: string;
  1268. }): boolean;
  1269. }
  1270. }
  1271. declare module BABYLON {
  1272. /** @hidden */
  1273. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1274. leftOperand: ShaderDefineExpression;
  1275. rightOperand: ShaderDefineExpression;
  1276. isTrue(preprocessors: {
  1277. [key: string]: string;
  1278. }): boolean;
  1279. }
  1280. }
  1281. declare module BABYLON {
  1282. /** @hidden */
  1283. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1284. leftOperand: ShaderDefineExpression;
  1285. rightOperand: ShaderDefineExpression;
  1286. isTrue(preprocessors: {
  1287. [key: string]: string;
  1288. }): boolean;
  1289. }
  1290. }
  1291. declare module BABYLON {
  1292. /** @hidden */
  1293. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1294. define: string;
  1295. operand: string;
  1296. testValue: string;
  1297. constructor(define: string, operand: string, testValue: string);
  1298. isTrue(preprocessors: {
  1299. [key: string]: string;
  1300. }): boolean;
  1301. }
  1302. }
  1303. declare module BABYLON {
  1304. /**
  1305. * Class used to enable access to offline support
  1306. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1307. */
  1308. export interface IOfflineProvider {
  1309. /**
  1310. * Gets a boolean indicating if scene must be saved in the database
  1311. */
  1312. enableSceneOffline: boolean;
  1313. /**
  1314. * Gets a boolean indicating if textures must be saved in the database
  1315. */
  1316. enableTexturesOffline: boolean;
  1317. /**
  1318. * Open the offline support and make it available
  1319. * @param successCallback defines the callback to call on success
  1320. * @param errorCallback defines the callback to call on error
  1321. */
  1322. open(successCallback: () => void, errorCallback: () => void): void;
  1323. /**
  1324. * Loads an image from the offline support
  1325. * @param url defines the url to load from
  1326. * @param image defines the target DOM image
  1327. */
  1328. loadImage(url: string, image: HTMLImageElement): void;
  1329. /**
  1330. * Loads a file from offline support
  1331. * @param url defines the URL to load from
  1332. * @param sceneLoaded defines a callback to call on success
  1333. * @param progressCallBack defines a callback to call when progress changed
  1334. * @param errorCallback defines a callback to call on error
  1335. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1336. */
  1337. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1338. }
  1339. }
  1340. declare module BABYLON {
  1341. /**
  1342. * Class used to help managing file picking and drag'n'drop
  1343. * File Storage
  1344. */
  1345. export class FilesInputStore {
  1346. /**
  1347. * List of files ready to be loaded
  1348. */
  1349. static FilesToLoad: {
  1350. [key: string]: File;
  1351. };
  1352. }
  1353. }
  1354. declare module BABYLON {
  1355. /**
  1356. * Class used to define a retry strategy when error happens while loading assets
  1357. */
  1358. export class RetryStrategy {
  1359. /**
  1360. * Function used to defines an exponential back off strategy
  1361. * @param maxRetries defines the maximum number of retries (3 by default)
  1362. * @param baseInterval defines the interval between retries
  1363. * @returns the strategy function to use
  1364. */
  1365. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1366. }
  1367. }
  1368. declare module BABYLON {
  1369. /**
  1370. * @ignore
  1371. * Application error to support additional information when loading a file
  1372. */
  1373. export abstract class BaseError extends Error {
  1374. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1375. }
  1376. }
  1377. declare module BABYLON {
  1378. /** @ignore */
  1379. export class LoadFileError extends BaseError {
  1380. request?: WebRequest;
  1381. file?: File;
  1382. /**
  1383. * Creates a new LoadFileError
  1384. * @param message defines the message of the error
  1385. * @param request defines the optional web request
  1386. * @param file defines the optional file
  1387. */
  1388. constructor(message: string, object?: WebRequest | File);
  1389. }
  1390. /** @ignore */
  1391. export class RequestFileError extends BaseError {
  1392. request: WebRequest;
  1393. /**
  1394. * Creates a new LoadFileError
  1395. * @param message defines the message of the error
  1396. * @param request defines the optional web request
  1397. */
  1398. constructor(message: string, request: WebRequest);
  1399. }
  1400. /** @ignore */
  1401. export class ReadFileError extends BaseError {
  1402. file: File;
  1403. /**
  1404. * Creates a new ReadFileError
  1405. * @param message defines the message of the error
  1406. * @param file defines the optional file
  1407. */
  1408. constructor(message: string, file: File);
  1409. }
  1410. /**
  1411. * @hidden
  1412. */
  1413. export class FileTools {
  1414. /**
  1415. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1416. */
  1417. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1418. /**
  1419. * Gets or sets the base URL to use to load assets
  1420. */
  1421. static BaseUrl: string;
  1422. /**
  1423. * Default behaviour for cors in the application.
  1424. * It can be a string if the expected behavior is identical in the entire app.
  1425. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1426. */
  1427. static CorsBehavior: string | ((url: string | string[]) => string);
  1428. /**
  1429. * Gets or sets a function used to pre-process url before using them to load assets
  1430. */
  1431. static PreprocessUrl: (url: string) => string;
  1432. /**
  1433. * Removes unwanted characters from an url
  1434. * @param url defines the url to clean
  1435. * @returns the cleaned url
  1436. */
  1437. private static _CleanUrl;
  1438. /**
  1439. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1440. * @param url define the url we are trying
  1441. * @param element define the dom element where to configure the cors policy
  1442. */
  1443. static SetCorsBehavior(url: string | string[], element: {
  1444. crossOrigin: string | null;
  1445. }): void;
  1446. /**
  1447. * Loads an image as an HTMLImageElement.
  1448. * @param input url string, ArrayBuffer, or Blob to load
  1449. * @param onLoad callback called when the image successfully loads
  1450. * @param onError callback called when the image fails to load
  1451. * @param offlineProvider offline provider for caching
  1452. * @param mimeType optional mime type
  1453. * @returns the HTMLImageElement of the loaded image
  1454. */
  1455. 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>;
  1456. /**
  1457. * Reads a file from a File object
  1458. * @param file defines the file to load
  1459. * @param onSuccess defines the callback to call when data is loaded
  1460. * @param onProgress defines the callback to call during loading process
  1461. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1462. * @param onError defines the callback to call when an error occurs
  1463. * @returns a file request object
  1464. */
  1465. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1466. /**
  1467. * Loads a file from a url
  1468. * @param url url to load
  1469. * @param onSuccess callback called when the file successfully loads
  1470. * @param onProgress callback called while file is loading (if the server supports this mode)
  1471. * @param offlineProvider defines the offline provider for caching
  1472. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1473. * @param onError callback called when the file fails to load
  1474. * @returns a file request object
  1475. */
  1476. 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;
  1477. /**
  1478. * Loads a file
  1479. * @param url url to load
  1480. * @param onSuccess callback called when the file successfully loads
  1481. * @param onProgress callback called while file is loading (if the server supports this mode)
  1482. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1483. * @param onError callback called when the file fails to load
  1484. * @param onOpened callback called when the web request is opened
  1485. * @returns a file request object
  1486. */
  1487. 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;
  1488. /**
  1489. * Checks if the loaded document was accessed via `file:`-Protocol.
  1490. * @returns boolean
  1491. */
  1492. static IsFileURL(): boolean;
  1493. }
  1494. }
  1495. declare module BABYLON {
  1496. /** @hidden */
  1497. export class ShaderProcessor {
  1498. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1499. private static _ProcessPrecision;
  1500. private static _ExtractOperation;
  1501. private static _BuildSubExpression;
  1502. private static _BuildExpression;
  1503. private static _MoveCursorWithinIf;
  1504. private static _MoveCursor;
  1505. private static _EvaluatePreProcessors;
  1506. private static _PreparePreProcessors;
  1507. private static _ProcessShaderConversion;
  1508. private static _ProcessIncludes;
  1509. /**
  1510. * Loads a file from a url
  1511. * @param url url to load
  1512. * @param onSuccess callback called when the file successfully loads
  1513. * @param onProgress callback called while file is loading (if the server supports this mode)
  1514. * @param offlineProvider defines the offline provider for caching
  1515. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1516. * @param onError callback called when the file fails to load
  1517. * @returns a file request object
  1518. * @hidden
  1519. */
  1520. 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;
  1521. }
  1522. }
  1523. declare module BABYLON {
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IColor4Like {
  1528. r: float;
  1529. g: float;
  1530. b: float;
  1531. a: float;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IColor3Like {
  1537. r: float;
  1538. g: float;
  1539. b: float;
  1540. }
  1541. /**
  1542. * @hidden
  1543. */
  1544. export interface IVector4Like {
  1545. x: float;
  1546. y: float;
  1547. z: float;
  1548. w: float;
  1549. }
  1550. /**
  1551. * @hidden
  1552. */
  1553. export interface IVector3Like {
  1554. x: float;
  1555. y: float;
  1556. z: float;
  1557. }
  1558. /**
  1559. * @hidden
  1560. */
  1561. export interface IVector2Like {
  1562. x: float;
  1563. y: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IMatrixLike {
  1569. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1570. updateFlag: int;
  1571. }
  1572. /**
  1573. * @hidden
  1574. */
  1575. export interface IViewportLike {
  1576. x: float;
  1577. y: float;
  1578. width: float;
  1579. height: float;
  1580. }
  1581. /**
  1582. * @hidden
  1583. */
  1584. export interface IPlaneLike {
  1585. normal: IVector3Like;
  1586. d: float;
  1587. normalize(): void;
  1588. }
  1589. }
  1590. declare module BABYLON {
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module BABYLON {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module BABYLON {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module BABYLON {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module BABYLON {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. }
  1895. declare module BABYLON {
  1896. /**
  1897. * Class used to represent a viewport on screen
  1898. */
  1899. export class Viewport {
  1900. /** viewport left coordinate */
  1901. x: number;
  1902. /** viewport top coordinate */
  1903. y: number;
  1904. /**viewport width */
  1905. width: number;
  1906. /** viewport height */
  1907. height: number;
  1908. /**
  1909. * Creates a Viewport object located at (x, y) and sized (width, height)
  1910. * @param x defines viewport left coordinate
  1911. * @param y defines viewport top coordinate
  1912. * @param width defines the viewport width
  1913. * @param height defines the viewport height
  1914. */
  1915. constructor(
  1916. /** viewport left coordinate */
  1917. x: number,
  1918. /** viewport top coordinate */
  1919. y: number,
  1920. /**viewport width */
  1921. width: number,
  1922. /** viewport height */
  1923. height: number);
  1924. /**
  1925. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1926. * @param renderWidth defines the rendering width
  1927. * @param renderHeight defines the rendering height
  1928. * @returns a new Viewport
  1929. */
  1930. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1931. /**
  1932. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1933. * @param renderWidth defines the rendering width
  1934. * @param renderHeight defines the rendering height
  1935. * @param ref defines the target viewport
  1936. * @returns the current viewport
  1937. */
  1938. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1939. /**
  1940. * Returns a new Viewport copied from the current one
  1941. * @returns a new Viewport
  1942. */
  1943. clone(): Viewport;
  1944. }
  1945. }
  1946. declare module BABYLON {
  1947. /**
  1948. * Class containing a set of static utilities functions for arrays.
  1949. */
  1950. export class ArrayTools {
  1951. /**
  1952. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1953. * @param size the number of element to construct and put in the array
  1954. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1955. * @returns a new array filled with new objects
  1956. */
  1957. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1958. }
  1959. }
  1960. declare module BABYLON {
  1961. /**
  1962. * Represents a plane by the equation ax + by + cz + d = 0
  1963. */
  1964. export class Plane {
  1965. private static _TmpMatrix;
  1966. /**
  1967. * Normal of the plane (a,b,c)
  1968. */
  1969. normal: Vector3;
  1970. /**
  1971. * d component of the plane
  1972. */
  1973. d: number;
  1974. /**
  1975. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1976. * @param a a component of the plane
  1977. * @param b b component of the plane
  1978. * @param c c component of the plane
  1979. * @param d d component of the plane
  1980. */
  1981. constructor(a: number, b: number, c: number, d: number);
  1982. /**
  1983. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1984. */
  1985. asArray(): number[];
  1986. /**
  1987. * @returns a new plane copied from the current Plane.
  1988. */
  1989. clone(): Plane;
  1990. /**
  1991. * @returns the string "Plane".
  1992. */
  1993. getClassName(): string;
  1994. /**
  1995. * @returns the Plane hash code.
  1996. */
  1997. getHashCode(): number;
  1998. /**
  1999. * Normalize the current Plane in place.
  2000. * @returns the updated Plane.
  2001. */
  2002. normalize(): Plane;
  2003. /**
  2004. * Applies a transformation the plane and returns the result
  2005. * @param transformation the transformation matrix to be applied to the plane
  2006. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2007. */
  2008. transform(transformation: DeepImmutable<Matrix>): Plane;
  2009. /**
  2010. * Compute the dot product between the point and the plane normal
  2011. * @param point point to calculate the dot product with
  2012. * @returns the dot product (float) of the point coordinates and the plane normal.
  2013. */
  2014. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2015. /**
  2016. * Updates the current Plane from the plane defined by the three given points.
  2017. * @param point1 one of the points used to contruct the plane
  2018. * @param point2 one of the points used to contruct the plane
  2019. * @param point3 one of the points used to contruct the plane
  2020. * @returns the updated Plane.
  2021. */
  2022. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2023. /**
  2024. * Checks if the plane is facing a given direction
  2025. * @param direction the direction to check if the plane is facing
  2026. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2027. * @returns True is the vector "direction" is the same side than the plane normal.
  2028. */
  2029. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2030. /**
  2031. * Calculates the distance to a point
  2032. * @param point point to calculate distance to
  2033. * @returns the signed distance (float) from the given point to the Plane.
  2034. */
  2035. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2036. /**
  2037. * Creates a plane from an array
  2038. * @param array the array to create a plane from
  2039. * @returns a new Plane from the given array.
  2040. */
  2041. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2042. /**
  2043. * Creates a plane from three points
  2044. * @param point1 point used to create the plane
  2045. * @param point2 point used to create the plane
  2046. * @param point3 point used to create the plane
  2047. * @returns a new Plane defined by the three given points.
  2048. */
  2049. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2050. /**
  2051. * Creates a plane from an origin point and a normal
  2052. * @param origin origin of the plane to be constructed
  2053. * @param normal normal of the plane to be constructed
  2054. * @returns a new Plane the normal vector to this plane at the given origin point.
  2055. * Note : the vector "normal" is updated because normalized.
  2056. */
  2057. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2058. /**
  2059. * Calculates the distance from a plane and a point
  2060. * @param origin origin of the plane to be constructed
  2061. * @param normal normal of the plane to be constructed
  2062. * @param point point to calculate distance to
  2063. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2064. */
  2065. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2066. }
  2067. }
  2068. declare module BABYLON {
  2069. /** @hidden */
  2070. export class PerformanceConfigurator {
  2071. /** @hidden */
  2072. static MatrixUse64Bits: boolean;
  2073. /** @hidden */
  2074. static MatrixTrackPrecisionChange: boolean;
  2075. /** @hidden */
  2076. static MatrixCurrentType: any;
  2077. /** @hidden */
  2078. static MatrixTrackedMatrices: Array<any> | null;
  2079. /** @hidden */
  2080. static SetMatrixPrecision(use64bits: boolean): void;
  2081. }
  2082. }
  2083. declare module BABYLON {
  2084. /**
  2085. * Class representing a vector containing 2 coordinates
  2086. */
  2087. export class Vector2 {
  2088. /** defines the first coordinate */
  2089. x: number;
  2090. /** defines the second coordinate */
  2091. y: number;
  2092. /**
  2093. * Creates a new Vector2 from the given x and y coordinates
  2094. * @param x defines the first coordinate
  2095. * @param y defines the second coordinate
  2096. */
  2097. constructor(
  2098. /** defines the first coordinate */
  2099. x?: number,
  2100. /** defines the second coordinate */
  2101. y?: number);
  2102. /**
  2103. * Gets a string with the Vector2 coordinates
  2104. * @returns a string with the Vector2 coordinates
  2105. */
  2106. toString(): string;
  2107. /**
  2108. * Gets class name
  2109. * @returns the string "Vector2"
  2110. */
  2111. getClassName(): string;
  2112. /**
  2113. * Gets current vector hash code
  2114. * @returns the Vector2 hash code as a number
  2115. */
  2116. getHashCode(): number;
  2117. /**
  2118. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2119. * @param array defines the source array
  2120. * @param index defines the offset in source array
  2121. * @returns the current Vector2
  2122. */
  2123. toArray(array: FloatArray, index?: number): Vector2;
  2124. /**
  2125. * Update the current vector from an array
  2126. * @param array defines the destination array
  2127. * @param index defines the offset in the destination array
  2128. * @returns the current Vector3
  2129. */
  2130. fromArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Copy the current vector to an array
  2133. * @returns a new array with 2 elements: the Vector2 coordinates.
  2134. */
  2135. asArray(): number[];
  2136. /**
  2137. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2138. * @param source defines the source Vector2
  2139. * @returns the current updated Vector2
  2140. */
  2141. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2142. /**
  2143. * Sets the Vector2 coordinates with the given floats
  2144. * @param x defines the first coordinate
  2145. * @param y defines the second coordinate
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFromFloats(x: number, y: number): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. set(x: number, y: number): Vector2;
  2156. /**
  2157. * Add another vector with the current one
  2158. * @param otherVector defines the other vector
  2159. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2160. */
  2161. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2162. /**
  2163. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2164. * @param otherVector defines the other vector
  2165. * @param result defines the target vector
  2166. * @returns the unmodified current Vector2
  2167. */
  2168. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2169. /**
  2170. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2171. * @param otherVector defines the other vector
  2172. * @returns the current updated Vector2
  2173. */
  2174. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2175. /**
  2176. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2177. * @param otherVector defines the other vector
  2178. * @returns a new Vector2
  2179. */
  2180. addVector3(otherVector: Vector3): Vector2;
  2181. /**
  2182. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2183. * @param otherVector defines the other vector
  2184. * @returns a new Vector2
  2185. */
  2186. subtract(otherVector: Vector2): Vector2;
  2187. /**
  2188. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2189. * @param otherVector defines the other vector
  2190. * @param result defines the target vector
  2191. * @returns the unmodified current Vector2
  2192. */
  2193. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2194. /**
  2195. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2196. * @param otherVector defines the other vector
  2197. * @returns the current updated Vector2
  2198. */
  2199. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Multiplies in place the current Vector2 coordinates by the given ones
  2202. * @param otherVector defines the other vector
  2203. * @returns the current updated Vector2
  2204. */
  2205. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2206. /**
  2207. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2208. * @param otherVector defines the other vector
  2209. * @returns a new Vector2
  2210. */
  2211. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2214. * @param otherVector defines the other vector
  2215. * @param result defines the target vector
  2216. * @returns the unmodified current Vector2
  2217. */
  2218. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2221. * @param x defines the first coordinate
  2222. * @param y defines the second coordinate
  2223. * @returns a new Vector2
  2224. */
  2225. multiplyByFloats(x: number, y: number): Vector2;
  2226. /**
  2227. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2228. * @param otherVector defines the other vector
  2229. * @returns a new Vector2
  2230. */
  2231. divide(otherVector: Vector2): Vector2;
  2232. /**
  2233. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2234. * @param otherVector defines the other vector
  2235. * @param result defines the target vector
  2236. * @returns the unmodified current Vector2
  2237. */
  2238. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2239. /**
  2240. * Divides the current Vector2 coordinates by the given ones
  2241. * @param otherVector defines the other vector
  2242. * @returns the current updated Vector2
  2243. */
  2244. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2245. /**
  2246. * Gets a new Vector2 with current Vector2 negated coordinates
  2247. * @returns a new Vector2
  2248. */
  2249. negate(): Vector2;
  2250. /**
  2251. * Negate this vector in place
  2252. * @returns this
  2253. */
  2254. negateInPlace(): Vector2;
  2255. /**
  2256. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2257. * @param result defines the Vector3 object where to store the result
  2258. * @returns the current Vector2
  2259. */
  2260. negateToRef(result: Vector2): Vector2;
  2261. /**
  2262. * Multiply the Vector2 coordinates by scale
  2263. * @param scale defines the scaling factor
  2264. * @returns the current updated Vector2
  2265. */
  2266. scaleInPlace(scale: number): Vector2;
  2267. /**
  2268. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2269. * @param scale defines the scaling factor
  2270. * @returns a new Vector2
  2271. */
  2272. scale(scale: number): Vector2;
  2273. /**
  2274. * Scale the current Vector2 values by a factor to a given Vector2
  2275. * @param scale defines the scale factor
  2276. * @param result defines the Vector2 object where to store the result
  2277. * @returns the unmodified current Vector2
  2278. */
  2279. scaleToRef(scale: number, result: Vector2): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Gets a boolean if two vectors are equals
  2289. * @param otherVector defines the other vector
  2290. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2291. */
  2292. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2293. /**
  2294. * Gets a boolean if two vectors are equals (using an epsilon value)
  2295. * @param otherVector defines the other vector
  2296. * @param epsilon defines the minimal distance to consider equality
  2297. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2298. */
  2299. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2300. /**
  2301. * Gets a new Vector2 from current Vector2 floored values
  2302. * @returns a new Vector2
  2303. */
  2304. floor(): Vector2;
  2305. /**
  2306. * Gets a new Vector2 from current Vector2 floored values
  2307. * @returns a new Vector2
  2308. */
  2309. fract(): Vector2;
  2310. /**
  2311. * Gets the length of the vector
  2312. * @returns the vector length (float)
  2313. */
  2314. length(): number;
  2315. /**
  2316. * Gets the vector squared length
  2317. * @returns the vector squared length (float)
  2318. */
  2319. lengthSquared(): number;
  2320. /**
  2321. * Normalize the vector
  2322. * @returns the current updated Vector2
  2323. */
  2324. normalize(): Vector2;
  2325. /**
  2326. * Gets a new Vector2 copied from the Vector2
  2327. * @returns a new Vector2
  2328. */
  2329. clone(): Vector2;
  2330. /**
  2331. * Gets a new Vector2(0, 0)
  2332. * @returns a new Vector2
  2333. */
  2334. static Zero(): Vector2;
  2335. /**
  2336. * Gets a new Vector2(1, 1)
  2337. * @returns a new Vector2
  2338. */
  2339. static One(): Vector2;
  2340. /**
  2341. * Gets a new Vector2 set from the given index element of the given array
  2342. * @param array defines the data source
  2343. * @param offset defines the offset in the data source
  2344. * @returns a new Vector2
  2345. */
  2346. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2347. /**
  2348. * Sets "result" from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @param result defines the target vector
  2352. */
  2353. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2354. /**
  2355. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2356. * @param value1 defines 1st point of control
  2357. * @param value2 defines 2nd point of control
  2358. * @param value3 defines 3rd point of control
  2359. * @param value4 defines 4th point of control
  2360. * @param amount defines the interpolation factor
  2361. * @returns a new Vector2
  2362. */
  2363. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2364. /**
  2365. * 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".
  2366. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2367. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2368. * @param value defines the value to clamp
  2369. * @param min defines the lower limit
  2370. * @param max defines the upper limit
  2371. * @returns a new Vector2
  2372. */
  2373. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2374. /**
  2375. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2376. * @param value1 defines the 1st control point
  2377. * @param tangent1 defines the outgoing tangent
  2378. * @param value2 defines the 2nd control point
  2379. * @param tangent2 defines the incoming tangent
  2380. * @param amount defines the interpolation factor
  2381. * @returns a new Vector2
  2382. */
  2383. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2384. /**
  2385. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2386. * @param start defines the start vector
  2387. * @param end defines the end vector
  2388. * @param amount defines the interpolation factor
  2389. * @returns a new Vector2
  2390. */
  2391. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2392. /**
  2393. * Gets the dot product of the vector "left" and the vector "right"
  2394. * @param left defines first vector
  2395. * @param right defines second vector
  2396. * @returns the dot product (float)
  2397. */
  2398. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2399. /**
  2400. * Returns a new Vector2 equal to the normalized given vector
  2401. * @param vector defines the vector to normalize
  2402. * @returns a new Vector2
  2403. */
  2404. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2405. /**
  2406. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2407. * @param left defines 1st vector
  2408. * @param right defines 2nd vector
  2409. * @returns a new Vector2
  2410. */
  2411. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2421. * @param vector defines the vector to transform
  2422. * @param transformation defines the matrix to apply
  2423. * @returns a new Vector2
  2424. */
  2425. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2426. /**
  2427. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @param result defines the target vector
  2431. */
  2432. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2433. /**
  2434. * Determines if a given vector is included in a triangle
  2435. * @param p defines the vector to test
  2436. * @param p0 defines 1st triangle point
  2437. * @param p1 defines 2nd triangle point
  2438. * @param p2 defines 3rd triangle point
  2439. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2440. */
  2441. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2442. /**
  2443. * Gets the distance between the vectors "value1" and "value2"
  2444. * @param value1 defines first vector
  2445. * @param value2 defines second vector
  2446. * @returns the distance between vectors
  2447. */
  2448. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2449. /**
  2450. * Returns the squared distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the squared distance between vectors
  2454. */
  2455. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns a new Vector2
  2461. */
  2462. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2463. /**
  2464. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2465. * @param p defines the middle point
  2466. * @param segA defines one point of the segment
  2467. * @param segB defines the other point of the segment
  2468. * @returns the shortest distance
  2469. */
  2470. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2471. }
  2472. /**
  2473. * Class used to store (x,y,z) vector representation
  2474. * A Vector3 is the main object used in 3D geometry
  2475. * It can represent etiher the coordinates of a point the space, either a direction
  2476. * Reminder: js uses a left handed forward facing system
  2477. */
  2478. export class Vector3 {
  2479. private static _UpReadOnly;
  2480. private static _ZeroReadOnly;
  2481. /** @hidden */
  2482. _x: number;
  2483. /** @hidden */
  2484. _y: number;
  2485. /** @hidden */
  2486. _z: number;
  2487. /** @hidden */
  2488. _isDirty: boolean;
  2489. /** Gets or sets the x coordinate */
  2490. get x(): number;
  2491. set x(value: number);
  2492. /** Gets or sets the y coordinate */
  2493. get y(): number;
  2494. set y(value: number);
  2495. /** Gets or sets the z coordinate */
  2496. get z(): number;
  2497. set z(value: number);
  2498. /**
  2499. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2500. * @param x defines the first coordinates (on X axis)
  2501. * @param y defines the second coordinates (on Y axis)
  2502. * @param z defines the third coordinates (on Z axis)
  2503. */
  2504. constructor(x?: number, y?: number, z?: number);
  2505. /**
  2506. * Creates a string representation of the Vector3
  2507. * @returns a string with the Vector3 coordinates.
  2508. */
  2509. toString(): string;
  2510. /**
  2511. * Gets the class name
  2512. * @returns the string "Vector3"
  2513. */
  2514. getClassName(): string;
  2515. /**
  2516. * Creates the Vector3 hash code
  2517. * @returns a number which tends to be unique between Vector3 instances
  2518. */
  2519. getHashCode(): number;
  2520. /**
  2521. * Creates an array containing three elements : the coordinates of the Vector3
  2522. * @returns a new array of numbers
  2523. */
  2524. asArray(): number[];
  2525. /**
  2526. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2527. * @param array defines the destination array
  2528. * @param index defines the offset in the destination array
  2529. * @returns the current Vector3
  2530. */
  2531. toArray(array: FloatArray, index?: number): Vector3;
  2532. /**
  2533. * Update the current vector from an array
  2534. * @param array defines the destination array
  2535. * @param index defines the offset in the destination array
  2536. * @returns the current Vector3
  2537. */
  2538. fromArray(array: FloatArray, index?: number): Vector3;
  2539. /**
  2540. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2541. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2542. */
  2543. toQuaternion(): Quaternion;
  2544. /**
  2545. * Adds the given vector to the current Vector3
  2546. * @param otherVector defines the second operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2550. /**
  2551. * Adds the given coordinates to the current Vector3
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2560. * @param otherVector defines the second operand
  2561. * @returns the resulting Vector3
  2562. */
  2563. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2564. /**
  2565. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2566. * @param otherVector defines the second operand
  2567. * @param result defines the Vector3 object where to store the result
  2568. * @returns the current Vector3
  2569. */
  2570. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2571. /**
  2572. * Subtract the given vector from the current Vector3
  2573. * @param otherVector defines the second operand
  2574. * @returns the current updated Vector3
  2575. */
  2576. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2577. /**
  2578. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2579. * @param otherVector defines the second operand
  2580. * @returns the resulting Vector3
  2581. */
  2582. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2583. /**
  2584. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2585. * @param otherVector defines the second operand
  2586. * @param result defines the Vector3 object where to store the result
  2587. * @returns the current Vector3
  2588. */
  2589. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2590. /**
  2591. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2592. * @param x defines the x coordinate of the operand
  2593. * @param y defines the y coordinate of the operand
  2594. * @param z defines the z coordinate of the operand
  2595. * @returns the resulting Vector3
  2596. */
  2597. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2598. /**
  2599. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2600. * @param x defines the x coordinate of the operand
  2601. * @param y defines the y coordinate of the operand
  2602. * @param z defines the z coordinate of the operand
  2603. * @param result defines the Vector3 object where to store the result
  2604. * @returns the current Vector3
  2605. */
  2606. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2607. /**
  2608. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2609. * @returns a new Vector3
  2610. */
  2611. negate(): Vector3;
  2612. /**
  2613. * Negate this vector in place
  2614. * @returns this
  2615. */
  2616. negateInPlace(): Vector3;
  2617. /**
  2618. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2619. * @param result defines the Vector3 object where to store the result
  2620. * @returns the current Vector3
  2621. */
  2622. negateToRef(result: Vector3): Vector3;
  2623. /**
  2624. * Multiplies the Vector3 coordinates by the float "scale"
  2625. * @param scale defines the multiplier factor
  2626. * @returns the current updated Vector3
  2627. */
  2628. scaleInPlace(scale: number): Vector3;
  2629. /**
  2630. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2631. * @param scale defines the multiplier factor
  2632. * @returns a new Vector3
  2633. */
  2634. scale(scale: number): Vector3;
  2635. /**
  2636. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2637. * @param scale defines the multiplier factor
  2638. * @param result defines the Vector3 object where to store the result
  2639. * @returns the current Vector3
  2640. */
  2641. scaleToRef(scale: number, result: Vector3): Vector3;
  2642. /**
  2643. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2644. * @param scale defines the scale factor
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the unmodified current Vector3
  2647. */
  2648. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2649. /**
  2650. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2651. * @param origin defines the origin of the projection ray
  2652. * @param plane defines the plane to project to
  2653. * @returns the projected vector3
  2654. */
  2655. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2656. /**
  2657. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2658. * @param origin defines the origin of the projection ray
  2659. * @param plane defines the plane to project to
  2660. * @param result defines the Vector3 where to store the result
  2661. */
  2662. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2663. /**
  2664. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2665. * @param otherVector defines the second operand
  2666. * @returns true if both vectors are equals
  2667. */
  2668. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2669. /**
  2670. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2671. * @param otherVector defines the second operand
  2672. * @param epsilon defines the minimal distance to define values as equals
  2673. * @returns true if both vectors are distant less than epsilon
  2674. */
  2675. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2676. /**
  2677. * Returns true if the current Vector3 coordinates equals the given floats
  2678. * @param x defines the x coordinate of the operand
  2679. * @param y defines the y coordinate of the operand
  2680. * @param z defines the z coordinate of the operand
  2681. * @returns true if both vectors are equals
  2682. */
  2683. equalsToFloats(x: number, y: number, z: number): boolean;
  2684. /**
  2685. * Multiplies the current Vector3 coordinates by the given ones
  2686. * @param otherVector defines the second operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2690. /**
  2691. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2692. * @param otherVector defines the second operand
  2693. * @returns the new Vector3
  2694. */
  2695. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2696. /**
  2697. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2698. * @param otherVector defines the second operand
  2699. * @param result defines the Vector3 object where to store the result
  2700. * @returns the current Vector3
  2701. */
  2702. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2703. /**
  2704. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2705. * @param x defines the x coordinate of the operand
  2706. * @param y defines the y coordinate of the operand
  2707. * @param z defines the z coordinate of the operand
  2708. * @returns the new Vector3
  2709. */
  2710. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2711. /**
  2712. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2713. * @param otherVector defines the second operand
  2714. * @returns the new Vector3
  2715. */
  2716. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2717. /**
  2718. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2719. * @param otherVector defines the second operand
  2720. * @param result defines the Vector3 object where to store the result
  2721. * @returns the current Vector3
  2722. */
  2723. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2724. /**
  2725. * Divides the current Vector3 coordinates by the given ones.
  2726. * @param otherVector defines the second operand
  2727. * @returns the current updated Vector3
  2728. */
  2729. divideInPlace(otherVector: Vector3): Vector3;
  2730. /**
  2731. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2732. * @param other defines the second operand
  2733. * @returns the current updated Vector3
  2734. */
  2735. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2736. /**
  2737. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2738. * @param other defines the second operand
  2739. * @returns the current updated Vector3
  2740. */
  2741. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2742. /**
  2743. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2744. * @param x defines the x coordinate of the operand
  2745. * @param y defines the y coordinate of the operand
  2746. * @param z defines the z coordinate of the operand
  2747. * @returns the current updated Vector3
  2748. */
  2749. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2750. /**
  2751. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2752. * @param x defines the x coordinate of the operand
  2753. * @param y defines the y coordinate of the operand
  2754. * @param z defines the z coordinate of the operand
  2755. * @returns the current updated Vector3
  2756. */
  2757. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2758. /**
  2759. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2760. * Check if is non uniform within a certain amount of decimal places to account for this
  2761. * @param epsilon the amount the values can differ
  2762. * @returns if the the vector is non uniform to a certain number of decimal places
  2763. */
  2764. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2765. /**
  2766. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2767. */
  2768. get isNonUniform(): boolean;
  2769. /**
  2770. * Gets a new Vector3 from current Vector3 floored values
  2771. * @returns a new Vector3
  2772. */
  2773. floor(): Vector3;
  2774. /**
  2775. * Gets a new Vector3 from current Vector3 floored values
  2776. * @returns a new Vector3
  2777. */
  2778. fract(): Vector3;
  2779. /**
  2780. * Gets the length of the Vector3
  2781. * @returns the length of the Vector3
  2782. */
  2783. length(): number;
  2784. /**
  2785. * Gets the squared length of the Vector3
  2786. * @returns squared length of the Vector3
  2787. */
  2788. lengthSquared(): number;
  2789. /**
  2790. * Normalize the current Vector3.
  2791. * Please note that this is an in place operation.
  2792. * @returns the current updated Vector3
  2793. */
  2794. normalize(): Vector3;
  2795. /**
  2796. * Reorders the x y z properties of the vector in place
  2797. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2798. * @returns the current updated vector
  2799. */
  2800. reorderInPlace(order: string): this;
  2801. /**
  2802. * Rotates the vector around 0,0,0 by a quaternion
  2803. * @param quaternion the rotation quaternion
  2804. * @param result vector to store the result
  2805. * @returns the resulting vector
  2806. */
  2807. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2808. /**
  2809. * Rotates a vector around a given point
  2810. * @param quaternion the rotation quaternion
  2811. * @param point the point to rotate around
  2812. * @param result vector to store the result
  2813. * @returns the resulting vector
  2814. */
  2815. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2816. /**
  2817. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2818. * The cross product is then orthogonal to both current and "other"
  2819. * @param other defines the right operand
  2820. * @returns the cross product
  2821. */
  2822. cross(other: Vector3): Vector3;
  2823. /**
  2824. * Normalize the current Vector3 with the given input length.
  2825. * Please note that this is an in place operation.
  2826. * @param len the length of the vector
  2827. * @returns the current updated Vector3
  2828. */
  2829. normalizeFromLength(len: number): Vector3;
  2830. /**
  2831. * Normalize the current Vector3 to a new vector
  2832. * @returns the new Vector3
  2833. */
  2834. normalizeToNew(): Vector3;
  2835. /**
  2836. * Normalize the current Vector3 to the reference
  2837. * @param reference define the Vector3 to update
  2838. * @returns the updated Vector3
  2839. */
  2840. normalizeToRef(reference: Vector3): Vector3;
  2841. /**
  2842. * Creates a new Vector3 copied from the current Vector3
  2843. * @returns the new Vector3
  2844. */
  2845. clone(): Vector3;
  2846. /**
  2847. * Copies the given vector coordinates to the current Vector3 ones
  2848. * @param source defines the source Vector3
  2849. * @returns the current updated Vector3
  2850. */
  2851. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2852. /**
  2853. * Copies the given floats to the current Vector3 coordinates
  2854. * @param x defines the x coordinate of the operand
  2855. * @param y defines the y coordinate of the operand
  2856. * @param z defines the z coordinate of the operand
  2857. * @returns the current updated Vector3
  2858. */
  2859. copyFromFloats(x: number, y: number, z: number): Vector3;
  2860. /**
  2861. * Copies the given floats to the current Vector3 coordinates
  2862. * @param x defines the x coordinate of the operand
  2863. * @param y defines the y coordinate of the operand
  2864. * @param z defines the z coordinate of the operand
  2865. * @returns the current updated Vector3
  2866. */
  2867. set(x: number, y: number, z: number): Vector3;
  2868. /**
  2869. * Copies the given float to the current Vector3 coordinates
  2870. * @param v defines the x, y and z coordinates of the operand
  2871. * @returns the current updated Vector3
  2872. */
  2873. setAll(v: number): Vector3;
  2874. /**
  2875. * Get the clip factor between two vectors
  2876. * @param vector0 defines the first operand
  2877. * @param vector1 defines the second operand
  2878. * @param axis defines the axis to use
  2879. * @param size defines the size along the axis
  2880. * @returns the clip factor
  2881. */
  2882. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2883. /**
  2884. * Get angle between two vectors
  2885. * @param vector0 angle between vector0 and vector1
  2886. * @param vector1 angle between vector0 and vector1
  2887. * @param normal direction of the normal
  2888. * @return the angle between vector0 and vector1
  2889. */
  2890. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2891. /**
  2892. * Returns a new Vector3 set from the index "offset" of the given array
  2893. * @param array defines the source array
  2894. * @param offset defines the offset in the source array
  2895. * @returns the new Vector3
  2896. */
  2897. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2898. /**
  2899. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2900. * @param array defines the source array
  2901. * @param offset defines the offset in the source array
  2902. * @returns the new Vector3
  2903. * @deprecated Please use FromArray instead.
  2904. */
  2905. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2906. /**
  2907. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2908. * @param array defines the source array
  2909. * @param offset defines the offset in the source array
  2910. * @param result defines the Vector3 where to store the result
  2911. */
  2912. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2913. /**
  2914. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2915. * @param array defines the source array
  2916. * @param offset defines the offset in the source array
  2917. * @param result defines the Vector3 where to store the result
  2918. * @deprecated Please use FromArrayToRef instead.
  2919. */
  2920. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2921. /**
  2922. * Sets the given vector "result" with the given floats.
  2923. * @param x defines the x coordinate of the source
  2924. * @param y defines the y coordinate of the source
  2925. * @param z defines the z coordinate of the source
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2929. /**
  2930. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2931. * @returns a new empty Vector3
  2932. */
  2933. static Zero(): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2936. * @returns a new unit Vector3
  2937. */
  2938. static One(): Vector3;
  2939. /**
  2940. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2941. * @returns a new up Vector3
  2942. */
  2943. static Up(): Vector3;
  2944. /**
  2945. * Gets a up Vector3 that must not be updated
  2946. */
  2947. static get UpReadOnly(): DeepImmutable<Vector3>;
  2948. /**
  2949. * Gets a zero Vector3 that must not be updated
  2950. */
  2951. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2952. /**
  2953. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2954. * @returns a new down Vector3
  2955. */
  2956. static Down(): Vector3;
  2957. /**
  2958. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2959. * @param rightHandedSystem is the scene right-handed (negative z)
  2960. * @returns a new forward Vector3
  2961. */
  2962. static Forward(rightHandedSystem?: boolean): Vector3;
  2963. /**
  2964. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2965. * @param rightHandedSystem is the scene right-handed (negative-z)
  2966. * @returns a new forward Vector3
  2967. */
  2968. static Backward(rightHandedSystem?: boolean): Vector3;
  2969. /**
  2970. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2971. * @returns a new right Vector3
  2972. */
  2973. static Right(): Vector3;
  2974. /**
  2975. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2976. * @returns a new left Vector3
  2977. */
  2978. static Left(): Vector3;
  2979. /**
  2980. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2981. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2982. * @param vector defines the Vector3 to transform
  2983. * @param transformation defines the transformation matrix
  2984. * @returns the transformed Vector3
  2985. */
  2986. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2987. /**
  2988. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2989. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2990. * @param vector defines the Vector3 to transform
  2991. * @param transformation defines the transformation matrix
  2992. * @param result defines the Vector3 where to store the result
  2993. */
  2994. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2995. /**
  2996. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2997. * This method computes tranformed coordinates only, not transformed direction vectors
  2998. * @param x define the x coordinate of the source vector
  2999. * @param y define the y coordinate of the source vector
  3000. * @param z define the z coordinate of the source vector
  3001. * @param transformation defines the transformation matrix
  3002. * @param result defines the Vector3 where to store the result
  3003. */
  3004. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3005. /**
  3006. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3007. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3008. * @param vector defines the Vector3 to transform
  3009. * @param transformation defines the transformation matrix
  3010. * @returns the new Vector3
  3011. */
  3012. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3013. /**
  3014. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3015. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3016. * @param vector defines the Vector3 to transform
  3017. * @param transformation defines the transformation matrix
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3021. /**
  3022. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3023. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3024. * @param x define the x coordinate of the source vector
  3025. * @param y define the y coordinate of the source vector
  3026. * @param z define the z coordinate of the source vector
  3027. * @param transformation defines the transformation matrix
  3028. * @param result defines the Vector3 where to store the result
  3029. */
  3030. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3031. /**
  3032. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3033. * @param value1 defines the first control point
  3034. * @param value2 defines the second control point
  3035. * @param value3 defines the third control point
  3036. * @param value4 defines the fourth control point
  3037. * @param amount defines the amount on the spline to use
  3038. * @returns the new Vector3
  3039. */
  3040. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3041. /**
  3042. * 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"
  3043. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3044. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3045. * @param value defines the current value
  3046. * @param min defines the lower range value
  3047. * @param max defines the upper range value
  3048. * @returns the new Vector3
  3049. */
  3050. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3051. /**
  3052. * 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"
  3053. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3054. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3055. * @param value defines the current value
  3056. * @param min defines the lower range value
  3057. * @param max defines the upper range value
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3061. /**
  3062. * Checks if a given vector is inside a specific range
  3063. * @param v defines the vector to test
  3064. * @param min defines the minimum range
  3065. * @param max defines the maximum range
  3066. */
  3067. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3068. /**
  3069. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3070. * @param value1 defines the first control point
  3071. * @param tangent1 defines the first tangent vector
  3072. * @param value2 defines the second control point
  3073. * @param tangent2 defines the second tangent vector
  3074. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3075. * @returns the new Vector3
  3076. */
  3077. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3078. /**
  3079. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3080. * @param start defines the start value
  3081. * @param end defines the end value
  3082. * @param amount max defines amount between both (between 0 and 1)
  3083. * @returns the new Vector3
  3084. */
  3085. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3086. /**
  3087. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3088. * @param start defines the start value
  3089. * @param end defines the end value
  3090. * @param amount max defines amount between both (between 0 and 1)
  3091. * @param result defines the Vector3 where to store the result
  3092. */
  3093. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3094. /**
  3095. * Returns the dot product (float) between the vectors "left" and "right"
  3096. * @param left defines the left operand
  3097. * @param right defines the right operand
  3098. * @returns the dot product
  3099. */
  3100. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3101. /**
  3102. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3103. * The cross product is then orthogonal to both "left" and "right"
  3104. * @param left defines the left operand
  3105. * @param right defines the right operand
  3106. * @returns the cross product
  3107. */
  3108. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3109. /**
  3110. * Sets the given vector "result" with the cross product of "left" and "right"
  3111. * The cross product is then orthogonal to both "left" and "right"
  3112. * @param left defines the left operand
  3113. * @param right defines the right operand
  3114. * @param result defines the Vector3 where to store the result
  3115. */
  3116. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3117. /**
  3118. * Returns a new Vector3 as the normalization of the given vector
  3119. * @param vector defines the Vector3 to normalize
  3120. * @returns the new Vector3
  3121. */
  3122. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3123. /**
  3124. * Sets the given vector "result" with the normalization of the given first vector
  3125. * @param vector defines the Vector3 to normalize
  3126. * @param result defines the Vector3 where to store the result
  3127. */
  3128. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3129. /**
  3130. * Project a Vector3 onto screen space
  3131. * @param vector defines the Vector3 to project
  3132. * @param world defines the world matrix to use
  3133. * @param transform defines the transform (view x projection) matrix to use
  3134. * @param viewport defines the screen viewport to use
  3135. * @returns the new Vector3
  3136. */
  3137. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3138. /** @hidden */
  3139. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3140. /**
  3141. * Unproject from screen space to object space
  3142. * @param source defines the screen space Vector3 to use
  3143. * @param viewportWidth defines the current width of the viewport
  3144. * @param viewportHeight defines the current height of the viewport
  3145. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3146. * @param transform defines the transform (view x projection) matrix to use
  3147. * @returns the new Vector3
  3148. */
  3149. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3150. /**
  3151. * Unproject from screen space to object space
  3152. * @param source defines the screen space Vector3 to use
  3153. * @param viewportWidth defines the current width of the viewport
  3154. * @param viewportHeight defines the current height of the viewport
  3155. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3156. * @param view defines the view matrix to use
  3157. * @param projection defines the projection matrix to use
  3158. * @returns the new Vector3
  3159. */
  3160. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3161. /**
  3162. * Unproject from screen space to object space
  3163. * @param source defines the screen space Vector3 to use
  3164. * @param viewportWidth defines the current width of the viewport
  3165. * @param viewportHeight defines the current height of the viewport
  3166. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3167. * @param view defines the view matrix to use
  3168. * @param projection defines the projection matrix to use
  3169. * @param result defines the Vector3 where to store the result
  3170. */
  3171. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3172. /**
  3173. * Unproject from screen space to object space
  3174. * @param sourceX defines the screen space x coordinate to use
  3175. * @param sourceY defines the screen space y coordinate to use
  3176. * @param sourceZ defines the screen space z coordinate to use
  3177. * @param viewportWidth defines the current width of the viewport
  3178. * @param viewportHeight defines the current height of the viewport
  3179. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3180. * @param view defines the view matrix to use
  3181. * @param projection defines the projection matrix to use
  3182. * @param result defines the Vector3 where to store the result
  3183. */
  3184. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3185. /**
  3186. * Gets the minimal coordinate values between two Vector3
  3187. * @param left defines the first operand
  3188. * @param right defines the second operand
  3189. * @returns the new Vector3
  3190. */
  3191. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3192. /**
  3193. * Gets the maximal coordinate values between two Vector3
  3194. * @param left defines the first operand
  3195. * @param right defines the second operand
  3196. * @returns the new Vector3
  3197. */
  3198. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * Returns the distance between the vectors "value1" and "value2"
  3201. * @param value1 defines the first operand
  3202. * @param value2 defines the second operand
  3203. * @returns the distance
  3204. */
  3205. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3206. /**
  3207. * Returns the squared distance between the vectors "value1" and "value2"
  3208. * @param value1 defines the first operand
  3209. * @param value2 defines the second operand
  3210. * @returns the squared distance
  3211. */
  3212. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3213. /**
  3214. * Returns a new Vector3 located at the center between "value1" and "value2"
  3215. * @param value1 defines the first operand
  3216. * @param value2 defines the second operand
  3217. * @returns the new Vector3
  3218. */
  3219. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3220. /**
  3221. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3222. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3223. * to something in order to rotate it from its local system to the given target system
  3224. * Note: axis1, axis2 and axis3 are normalized during this operation
  3225. * @param axis1 defines the first axis
  3226. * @param axis2 defines the second axis
  3227. * @param axis3 defines the third axis
  3228. * @returns a new Vector3
  3229. */
  3230. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3231. /**
  3232. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3233. * @param axis1 defines the first axis
  3234. * @param axis2 defines the second axis
  3235. * @param axis3 defines the third axis
  3236. * @param ref defines the Vector3 where to store the result
  3237. */
  3238. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3239. }
  3240. /**
  3241. * Vector4 class created for EulerAngle class conversion to Quaternion
  3242. */
  3243. export class Vector4 {
  3244. /** x value of the vector */
  3245. x: number;
  3246. /** y value of the vector */
  3247. y: number;
  3248. /** z value of the vector */
  3249. z: number;
  3250. /** w value of the vector */
  3251. w: number;
  3252. /**
  3253. * Creates a Vector4 object from the given floats.
  3254. * @param x x value of the vector
  3255. * @param y y value of the vector
  3256. * @param z z value of the vector
  3257. * @param w w value of the vector
  3258. */
  3259. constructor(
  3260. /** x value of the vector */
  3261. x: number,
  3262. /** y value of the vector */
  3263. y: number,
  3264. /** z value of the vector */
  3265. z: number,
  3266. /** w value of the vector */
  3267. w: number);
  3268. /**
  3269. * Returns the string with the Vector4 coordinates.
  3270. * @returns a string containing all the vector values
  3271. */
  3272. toString(): string;
  3273. /**
  3274. * Returns the string "Vector4".
  3275. * @returns "Vector4"
  3276. */
  3277. getClassName(): string;
  3278. /**
  3279. * Returns the Vector4 hash code.
  3280. * @returns a unique hash code
  3281. */
  3282. getHashCode(): number;
  3283. /**
  3284. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3285. * @returns the resulting array
  3286. */
  3287. asArray(): number[];
  3288. /**
  3289. * Populates the given array from the given index with the Vector4 coordinates.
  3290. * @param array array to populate
  3291. * @param index index of the array to start at (default: 0)
  3292. * @returns the Vector4.
  3293. */
  3294. toArray(array: FloatArray, index?: number): Vector4;
  3295. /**
  3296. * Update the current vector from an array
  3297. * @param array defines the destination array
  3298. * @param index defines the offset in the destination array
  3299. * @returns the current Vector3
  3300. */
  3301. fromArray(array: FloatArray, index?: number): Vector4;
  3302. /**
  3303. * Adds the given vector to the current Vector4.
  3304. * @param otherVector the vector to add
  3305. * @returns the updated Vector4.
  3306. */
  3307. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3308. /**
  3309. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3310. * @param otherVector the vector to add
  3311. * @returns the resulting vector
  3312. */
  3313. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3314. /**
  3315. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3316. * @param otherVector the vector to add
  3317. * @param result the vector to store the result
  3318. * @returns the current Vector4.
  3319. */
  3320. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3321. /**
  3322. * Subtract in place the given vector from the current Vector4.
  3323. * @param otherVector the vector to subtract
  3324. * @returns the updated Vector4.
  3325. */
  3326. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3327. /**
  3328. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3329. * @param otherVector the vector to add
  3330. * @returns the new vector with the result
  3331. */
  3332. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3333. /**
  3334. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3335. * @param otherVector the vector to subtract
  3336. * @param result the vector to store the result
  3337. * @returns the current Vector4.
  3338. */
  3339. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3340. /**
  3341. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3342. */
  3343. /**
  3344. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3345. * @param x value to subtract
  3346. * @param y value to subtract
  3347. * @param z value to subtract
  3348. * @param w value to subtract
  3349. * @returns new vector containing the result
  3350. */
  3351. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3352. /**
  3353. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3354. * @param x value to subtract
  3355. * @param y value to subtract
  3356. * @param z value to subtract
  3357. * @param w value to subtract
  3358. * @param result the vector to store the result in
  3359. * @returns the current Vector4.
  3360. */
  3361. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3362. /**
  3363. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3364. * @returns a new vector with the negated values
  3365. */
  3366. negate(): Vector4;
  3367. /**
  3368. * Negate this vector in place
  3369. * @returns this
  3370. */
  3371. negateInPlace(): Vector4;
  3372. /**
  3373. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3374. * @param result defines the Vector3 object where to store the result
  3375. * @returns the current Vector4
  3376. */
  3377. negateToRef(result: Vector4): Vector4;
  3378. /**
  3379. * Multiplies the current Vector4 coordinates by scale (float).
  3380. * @param scale the number to scale with
  3381. * @returns the updated Vector4.
  3382. */
  3383. scaleInPlace(scale: number): Vector4;
  3384. /**
  3385. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3386. * @param scale the number to scale with
  3387. * @returns a new vector with the result
  3388. */
  3389. scale(scale: number): Vector4;
  3390. /**
  3391. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3392. * @param scale the number to scale with
  3393. * @param result a vector to store the result in
  3394. * @returns the current Vector4.
  3395. */
  3396. scaleToRef(scale: number, result: Vector4): Vector4;
  3397. /**
  3398. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3399. * @param scale defines the scale factor
  3400. * @param result defines the Vector4 object where to store the result
  3401. * @returns the unmodified current Vector4
  3402. */
  3403. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3404. /**
  3405. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3406. * @param otherVector the vector to compare against
  3407. * @returns true if they are equal
  3408. */
  3409. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3410. /**
  3411. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3412. * @param otherVector vector to compare against
  3413. * @param epsilon (Default: very small number)
  3414. * @returns true if they are equal
  3415. */
  3416. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3417. /**
  3418. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3419. * @param x x value to compare against
  3420. * @param y y value to compare against
  3421. * @param z z value to compare against
  3422. * @param w w value to compare against
  3423. * @returns true if equal
  3424. */
  3425. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3426. /**
  3427. * Multiplies in place the current Vector4 by the given one.
  3428. * @param otherVector vector to multiple with
  3429. * @returns the updated Vector4.
  3430. */
  3431. multiplyInPlace(otherVector: Vector4): Vector4;
  3432. /**
  3433. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3434. * @param otherVector vector to multiple with
  3435. * @returns resulting new vector
  3436. */
  3437. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3438. /**
  3439. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3440. * @param otherVector vector to multiple with
  3441. * @param result vector to store the result
  3442. * @returns the current Vector4.
  3443. */
  3444. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3445. /**
  3446. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3447. * @param x x value multiply with
  3448. * @param y y value multiply with
  3449. * @param z z value multiply with
  3450. * @param w w value multiply with
  3451. * @returns resulting new vector
  3452. */
  3453. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3454. /**
  3455. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3456. * @param otherVector vector to devide with
  3457. * @returns resulting new vector
  3458. */
  3459. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3460. /**
  3461. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3462. * @param otherVector vector to devide with
  3463. * @param result vector to store the result
  3464. * @returns the current Vector4.
  3465. */
  3466. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3467. /**
  3468. * Divides the current Vector3 coordinates by the given ones.
  3469. * @param otherVector vector to devide with
  3470. * @returns the updated Vector3.
  3471. */
  3472. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3473. /**
  3474. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3475. * @param other defines the second operand
  3476. * @returns the current updated Vector4
  3477. */
  3478. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3479. /**
  3480. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3481. * @param other defines the second operand
  3482. * @returns the current updated Vector4
  3483. */
  3484. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3485. /**
  3486. * Gets a new Vector4 from current Vector4 floored values
  3487. * @returns a new Vector4
  3488. */
  3489. floor(): Vector4;
  3490. /**
  3491. * Gets a new Vector4 from current Vector3 floored values
  3492. * @returns a new Vector4
  3493. */
  3494. fract(): Vector4;
  3495. /**
  3496. * Returns the Vector4 length (float).
  3497. * @returns the length
  3498. */
  3499. length(): number;
  3500. /**
  3501. * Returns the Vector4 squared length (float).
  3502. * @returns the length squared
  3503. */
  3504. lengthSquared(): number;
  3505. /**
  3506. * Normalizes in place the Vector4.
  3507. * @returns the updated Vector4.
  3508. */
  3509. normalize(): Vector4;
  3510. /**
  3511. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3512. * @returns this converted to a new vector3
  3513. */
  3514. toVector3(): Vector3;
  3515. /**
  3516. * Returns a new Vector4 copied from the current one.
  3517. * @returns the new cloned vector
  3518. */
  3519. clone(): Vector4;
  3520. /**
  3521. * Updates the current Vector4 with the given one coordinates.
  3522. * @param source the source vector to copy from
  3523. * @returns the updated Vector4.
  3524. */
  3525. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3526. /**
  3527. * Updates the current Vector4 coordinates with the given floats.
  3528. * @param x float to copy from
  3529. * @param y float to copy from
  3530. * @param z float to copy from
  3531. * @param w float to copy from
  3532. * @returns the updated Vector4.
  3533. */
  3534. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3535. /**
  3536. * Updates the current Vector4 coordinates with the given floats.
  3537. * @param x float to set from
  3538. * @param y float to set from
  3539. * @param z float to set from
  3540. * @param w float to set from
  3541. * @returns the updated Vector4.
  3542. */
  3543. set(x: number, y: number, z: number, w: number): Vector4;
  3544. /**
  3545. * Copies the given float to the current Vector3 coordinates
  3546. * @param v defines the x, y, z and w coordinates of the operand
  3547. * @returns the current updated Vector3
  3548. */
  3549. setAll(v: number): Vector4;
  3550. /**
  3551. * Returns a new Vector4 set from the starting index of the given array.
  3552. * @param array the array to pull values from
  3553. * @param offset the offset into the array to start at
  3554. * @returns the new vector
  3555. */
  3556. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3557. /**
  3558. * Updates the given vector "result" from the starting index of the given array.
  3559. * @param array the array to pull values from
  3560. * @param offset the offset into the array to start at
  3561. * @param result the vector to store the result in
  3562. */
  3563. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3564. /**
  3565. * Updates the given vector "result" from the starting index of the given Float32Array.
  3566. * @param array the array to pull values from
  3567. * @param offset the offset into the array to start at
  3568. * @param result the vector to store the result in
  3569. */
  3570. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3571. /**
  3572. * Updates the given vector "result" coordinates from the given floats.
  3573. * @param x float to set from
  3574. * @param y float to set from
  3575. * @param z float to set from
  3576. * @param w float to set from
  3577. * @param result the vector to the floats in
  3578. */
  3579. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3580. /**
  3581. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3582. * @returns the new vector
  3583. */
  3584. static Zero(): Vector4;
  3585. /**
  3586. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3587. * @returns the new vector
  3588. */
  3589. static One(): Vector4;
  3590. /**
  3591. * Returns a new normalized Vector4 from the given one.
  3592. * @param vector the vector to normalize
  3593. * @returns the vector
  3594. */
  3595. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3596. /**
  3597. * Updates the given vector "result" from the normalization of the given one.
  3598. * @param vector the vector to normalize
  3599. * @param result the vector to store the result in
  3600. */
  3601. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3602. /**
  3603. * Returns a vector with the minimum values from the left and right vectors
  3604. * @param left left vector to minimize
  3605. * @param right right vector to minimize
  3606. * @returns a new vector with the minimum of the left and right vector values
  3607. */
  3608. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3609. /**
  3610. * Returns a vector with the maximum values from the left and right vectors
  3611. * @param left left vector to maximize
  3612. * @param right right vector to maximize
  3613. * @returns a new vector with the maximum of the left and right vector values
  3614. */
  3615. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3616. /**
  3617. * Returns the distance (float) between the vectors "value1" and "value2".
  3618. * @param value1 value to calulate the distance between
  3619. * @param value2 value to calulate the distance between
  3620. * @return the distance between the two vectors
  3621. */
  3622. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3623. /**
  3624. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3625. * @param value1 value to calulate the distance between
  3626. * @param value2 value to calulate the distance between
  3627. * @return the distance between the two vectors squared
  3628. */
  3629. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3630. /**
  3631. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3632. * @param value1 value to calulate the center between
  3633. * @param value2 value to calulate the center between
  3634. * @return the center between the two vectors
  3635. */
  3636. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3637. /**
  3638. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3639. * This methods computes transformed normalized direction vectors only.
  3640. * @param vector the vector to transform
  3641. * @param transformation the transformation matrix to apply
  3642. * @returns the new vector
  3643. */
  3644. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3645. /**
  3646. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3647. * This methods computes transformed normalized direction vectors only.
  3648. * @param vector the vector to transform
  3649. * @param transformation the transformation matrix to apply
  3650. * @param result the vector to store the result in
  3651. */
  3652. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3653. /**
  3654. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3655. * This methods computes transformed normalized direction vectors only.
  3656. * @param x value to transform
  3657. * @param y value to transform
  3658. * @param z value to transform
  3659. * @param w value to transform
  3660. * @param transformation the transformation matrix to apply
  3661. * @param result the vector to store the results in
  3662. */
  3663. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3664. /**
  3665. * Creates a new Vector4 from a Vector3
  3666. * @param source defines the source data
  3667. * @param w defines the 4th component (default is 0)
  3668. * @returns a new Vector4
  3669. */
  3670. static FromVector3(source: Vector3, w?: number): Vector4;
  3671. }
  3672. /**
  3673. * Class used to store quaternion data
  3674. * @see https://en.wikipedia.org/wiki/Quaternion
  3675. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3676. */
  3677. export class Quaternion {
  3678. /** @hidden */
  3679. _x: number;
  3680. /** @hidden */
  3681. _y: number;
  3682. /** @hidden */
  3683. _z: number;
  3684. /** @hidden */
  3685. _w: number;
  3686. /** @hidden */
  3687. _isDirty: boolean;
  3688. /** Gets or sets the x coordinate */
  3689. get x(): number;
  3690. set x(value: number);
  3691. /** Gets or sets the y coordinate */
  3692. get y(): number;
  3693. set y(value: number);
  3694. /** Gets or sets the z coordinate */
  3695. get z(): number;
  3696. set z(value: number);
  3697. /** Gets or sets the w coordinate */
  3698. get w(): number;
  3699. set w(value: number);
  3700. /**
  3701. * Creates a new Quaternion from the given floats
  3702. * @param x defines the first component (0 by default)
  3703. * @param y defines the second component (0 by default)
  3704. * @param z defines the third component (0 by default)
  3705. * @param w defines the fourth component (1.0 by default)
  3706. */
  3707. constructor(x?: number, y?: number, z?: number, w?: number);
  3708. /**
  3709. * Gets a string representation for the current quaternion
  3710. * @returns a string with the Quaternion coordinates
  3711. */
  3712. toString(): string;
  3713. /**
  3714. * Gets the class name of the quaternion
  3715. * @returns the string "Quaternion"
  3716. */
  3717. getClassName(): string;
  3718. /**
  3719. * Gets a hash code for this quaternion
  3720. * @returns the quaternion hash code
  3721. */
  3722. getHashCode(): number;
  3723. /**
  3724. * Copy the quaternion to an array
  3725. * @returns a new array populated with 4 elements from the quaternion coordinates
  3726. */
  3727. asArray(): number[];
  3728. /**
  3729. * Check if two quaternions are equals
  3730. * @param otherQuaternion defines the second operand
  3731. * @return true if the current quaternion and the given one coordinates are strictly equals
  3732. */
  3733. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3734. /**
  3735. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3736. * @param otherQuaternion defines the other quaternion
  3737. * @param epsilon defines the minimal distance to consider equality
  3738. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3739. */
  3740. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3741. /**
  3742. * Clone the current quaternion
  3743. * @returns a new quaternion copied from the current one
  3744. */
  3745. clone(): Quaternion;
  3746. /**
  3747. * Copy a quaternion to the current one
  3748. * @param other defines the other quaternion
  3749. * @returns the updated current quaternion
  3750. */
  3751. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3752. /**
  3753. * Updates the current quaternion with the given float coordinates
  3754. * @param x defines the x coordinate
  3755. * @param y defines the y coordinate
  3756. * @param z defines the z coordinate
  3757. * @param w defines the w coordinate
  3758. * @returns the updated current quaternion
  3759. */
  3760. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3761. /**
  3762. * Updates the current quaternion from the given float coordinates
  3763. * @param x defines the x coordinate
  3764. * @param y defines the y coordinate
  3765. * @param z defines the z coordinate
  3766. * @param w defines the w coordinate
  3767. * @returns the updated current quaternion
  3768. */
  3769. set(x: number, y: number, z: number, w: number): Quaternion;
  3770. /**
  3771. * Adds two quaternions
  3772. * @param other defines the second operand
  3773. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3774. */
  3775. add(other: DeepImmutable<Quaternion>): Quaternion;
  3776. /**
  3777. * Add a quaternion to the current one
  3778. * @param other defines the quaternion to add
  3779. * @returns the current quaternion
  3780. */
  3781. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3782. /**
  3783. * Subtract two quaternions
  3784. * @param other defines the second operand
  3785. * @returns a new quaternion as the subtraction result of the given one from the current one
  3786. */
  3787. subtract(other: Quaternion): Quaternion;
  3788. /**
  3789. * Multiplies the current quaternion by a scale factor
  3790. * @param value defines the scale factor
  3791. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3792. */
  3793. scale(value: number): Quaternion;
  3794. /**
  3795. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3796. * @param scale defines the scale factor
  3797. * @param result defines the Quaternion object where to store the result
  3798. * @returns the unmodified current quaternion
  3799. */
  3800. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3801. /**
  3802. * Multiplies in place the current quaternion by a scale factor
  3803. * @param value defines the scale factor
  3804. * @returns the current modified quaternion
  3805. */
  3806. scaleInPlace(value: number): Quaternion;
  3807. /**
  3808. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3809. * @param scale defines the scale factor
  3810. * @param result defines the Quaternion object where to store the result
  3811. * @returns the unmodified current quaternion
  3812. */
  3813. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3814. /**
  3815. * Multiplies two quaternions
  3816. * @param q1 defines the second operand
  3817. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3818. */
  3819. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3820. /**
  3821. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3822. * @param q1 defines the second operand
  3823. * @param result defines the target quaternion
  3824. * @returns the current quaternion
  3825. */
  3826. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3827. /**
  3828. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3829. * @param q1 defines the second operand
  3830. * @returns the currentupdated quaternion
  3831. */
  3832. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3833. /**
  3834. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3835. * @param ref defines the target quaternion
  3836. * @returns the current quaternion
  3837. */
  3838. conjugateToRef(ref: Quaternion): Quaternion;
  3839. /**
  3840. * Conjugates in place (1-q) the current quaternion
  3841. * @returns the current updated quaternion
  3842. */
  3843. conjugateInPlace(): Quaternion;
  3844. /**
  3845. * Conjugates in place (1-q) the current quaternion
  3846. * @returns a new quaternion
  3847. */
  3848. conjugate(): Quaternion;
  3849. /**
  3850. * Gets length of current quaternion
  3851. * @returns the quaternion length (float)
  3852. */
  3853. length(): number;
  3854. /**
  3855. * Normalize in place the current quaternion
  3856. * @returns the current updated quaternion
  3857. */
  3858. normalize(): Quaternion;
  3859. /**
  3860. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3861. * @param order is a reserved parameter and is ignored for now
  3862. * @returns a new Vector3 containing the Euler angles
  3863. */
  3864. toEulerAngles(order?: string): Vector3;
  3865. /**
  3866. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3867. * @param result defines the vector which will be filled with the Euler angles
  3868. * @returns the current unchanged quaternion
  3869. */
  3870. toEulerAnglesToRef(result: Vector3): Quaternion;
  3871. /**
  3872. * Updates the given rotation matrix with the current quaternion values
  3873. * @param result defines the target matrix
  3874. * @returns the current unchanged quaternion
  3875. */
  3876. toRotationMatrix(result: Matrix): Quaternion;
  3877. /**
  3878. * Updates the current quaternion from the given rotation matrix values
  3879. * @param matrix defines the source matrix
  3880. * @returns the current updated quaternion
  3881. */
  3882. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3883. /**
  3884. * Creates a new quaternion from a rotation matrix
  3885. * @param matrix defines the source matrix
  3886. * @returns a new quaternion created from the given rotation matrix values
  3887. */
  3888. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3889. /**
  3890. * Updates the given quaternion with the given rotation matrix values
  3891. * @param matrix defines the source matrix
  3892. * @param result defines the target quaternion
  3893. */
  3894. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3895. /**
  3896. * Returns the dot product (float) between the quaternions "left" and "right"
  3897. * @param left defines the left operand
  3898. * @param right defines the right operand
  3899. * @returns the dot product
  3900. */
  3901. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3902. /**
  3903. * Checks if the two quaternions are close to each other
  3904. * @param quat0 defines the first quaternion to check
  3905. * @param quat1 defines the second quaternion to check
  3906. * @returns true if the two quaternions are close to each other
  3907. */
  3908. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3909. /**
  3910. * Creates an empty quaternion
  3911. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3912. */
  3913. static Zero(): Quaternion;
  3914. /**
  3915. * Inverse a given quaternion
  3916. * @param q defines the source quaternion
  3917. * @returns a new quaternion as the inverted current quaternion
  3918. */
  3919. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3920. /**
  3921. * Inverse a given quaternion
  3922. * @param q defines the source quaternion
  3923. * @param result the quaternion the result will be stored in
  3924. * @returns the result quaternion
  3925. */
  3926. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3927. /**
  3928. * Creates an identity quaternion
  3929. * @returns the identity quaternion
  3930. */
  3931. static Identity(): Quaternion;
  3932. /**
  3933. * Gets a boolean indicating if the given quaternion is identity
  3934. * @param quaternion defines the quaternion to check
  3935. * @returns true if the quaternion is identity
  3936. */
  3937. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3938. /**
  3939. * Creates a quaternion from a rotation around an axis
  3940. * @param axis defines the axis to use
  3941. * @param angle defines the angle to use
  3942. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3943. */
  3944. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3945. /**
  3946. * Creates a rotation around an axis and stores it into the given quaternion
  3947. * @param axis defines the axis to use
  3948. * @param angle defines the angle to use
  3949. * @param result defines the target quaternion
  3950. * @returns the target quaternion
  3951. */
  3952. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates a new quaternion from data stored into an array
  3955. * @param array defines the data source
  3956. * @param offset defines the offset in the source array where the data starts
  3957. * @returns a new quaternion
  3958. */
  3959. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3960. /**
  3961. * Updates the given quaternion "result" from the starting index of the given array.
  3962. * @param array the array to pull values from
  3963. * @param offset the offset into the array to start at
  3964. * @param result the quaternion to store the result in
  3965. */
  3966. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3967. /**
  3968. * Create a quaternion from Euler rotation angles
  3969. * @param x Pitch
  3970. * @param y Yaw
  3971. * @param z Roll
  3972. * @returns the new Quaternion
  3973. */
  3974. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3975. /**
  3976. * Updates a quaternion from Euler rotation angles
  3977. * @param x Pitch
  3978. * @param y Yaw
  3979. * @param z Roll
  3980. * @param result the quaternion to store the result
  3981. * @returns the updated quaternion
  3982. */
  3983. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3984. /**
  3985. * Create a quaternion from Euler rotation vector
  3986. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3987. * @returns the new Quaternion
  3988. */
  3989. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3990. /**
  3991. * Updates a quaternion from Euler rotation vector
  3992. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3993. * @param result the quaternion to store the result
  3994. * @returns the updated quaternion
  3995. */
  3996. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3997. /**
  3998. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3999. * @param yaw defines the rotation around Y axis
  4000. * @param pitch defines the rotation around X axis
  4001. * @param roll defines the rotation around Z axis
  4002. * @returns the new quaternion
  4003. */
  4004. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4005. /**
  4006. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4007. * @param yaw defines the rotation around Y axis
  4008. * @param pitch defines the rotation around X axis
  4009. * @param roll defines the rotation around Z axis
  4010. * @param result defines the target quaternion
  4011. */
  4012. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4013. /**
  4014. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4015. * @param alpha defines the rotation around first axis
  4016. * @param beta defines the rotation around second axis
  4017. * @param gamma defines the rotation around third axis
  4018. * @returns the new quaternion
  4019. */
  4020. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4021. /**
  4022. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4023. * @param alpha defines the rotation around first axis
  4024. * @param beta defines the rotation around second axis
  4025. * @param gamma defines the rotation around third axis
  4026. * @param result defines the target quaternion
  4027. */
  4028. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4029. /**
  4030. * 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)
  4031. * @param axis1 defines the first axis
  4032. * @param axis2 defines the second axis
  4033. * @param axis3 defines the third axis
  4034. * @returns the new quaternion
  4035. */
  4036. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4037. /**
  4038. * 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
  4039. * @param axis1 defines the first axis
  4040. * @param axis2 defines the second axis
  4041. * @param axis3 defines the third axis
  4042. * @param ref defines the target quaternion
  4043. */
  4044. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4045. /**
  4046. * Interpolates between two quaternions
  4047. * @param left defines first quaternion
  4048. * @param right defines second quaternion
  4049. * @param amount defines the gradient to use
  4050. * @returns the new interpolated quaternion
  4051. */
  4052. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4053. /**
  4054. * Interpolates between two quaternions and stores it into a target quaternion
  4055. * @param left defines first quaternion
  4056. * @param right defines second quaternion
  4057. * @param amount defines the gradient to use
  4058. * @param result defines the target quaternion
  4059. */
  4060. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4061. /**
  4062. * Interpolate between two quaternions using Hermite interpolation
  4063. * @param value1 defines first quaternion
  4064. * @param tangent1 defines the incoming tangent
  4065. * @param value2 defines second quaternion
  4066. * @param tangent2 defines the outgoing tangent
  4067. * @param amount defines the target quaternion
  4068. * @returns the new interpolated quaternion
  4069. */
  4070. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4071. }
  4072. /**
  4073. * Class used to store matrix data (4x4)
  4074. */
  4075. export class Matrix {
  4076. /**
  4077. * Gets the precision of matrix computations
  4078. */
  4079. static get Use64Bits(): boolean;
  4080. private static _updateFlagSeed;
  4081. private static _identityReadOnly;
  4082. private _isIdentity;
  4083. private _isIdentityDirty;
  4084. private _isIdentity3x2;
  4085. private _isIdentity3x2Dirty;
  4086. /**
  4087. * Gets the update flag of the matrix which is an unique number for the matrix.
  4088. * It will be incremented every time the matrix data change.
  4089. * You can use it to speed the comparison between two versions of the same matrix.
  4090. */
  4091. updateFlag: number;
  4092. private readonly _m;
  4093. /**
  4094. * Gets the internal data of the matrix
  4095. */
  4096. get m(): DeepImmutable<Float32Array | Array<number>>;
  4097. /** @hidden */
  4098. _markAsUpdated(): void;
  4099. /** @hidden */
  4100. private _updateIdentityStatus;
  4101. /**
  4102. * Creates an empty matrix (filled with zeros)
  4103. */
  4104. constructor();
  4105. /**
  4106. * Check if the current matrix is identity
  4107. * @returns true is the matrix is the identity matrix
  4108. */
  4109. isIdentity(): boolean;
  4110. /**
  4111. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4112. * @returns true is the matrix is the identity matrix
  4113. */
  4114. isIdentityAs3x2(): boolean;
  4115. /**
  4116. * Gets the determinant of the matrix
  4117. * @returns the matrix determinant
  4118. */
  4119. determinant(): number;
  4120. /**
  4121. * Returns the matrix as a Float32Array or Array<number>
  4122. * @returns the matrix underlying array
  4123. */
  4124. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4125. /**
  4126. * Returns the matrix as a Float32Array or Array<number>
  4127. * @returns the matrix underlying array.
  4128. */
  4129. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4130. /**
  4131. * Inverts the current matrix in place
  4132. * @returns the current inverted matrix
  4133. */
  4134. invert(): Matrix;
  4135. /**
  4136. * Sets all the matrix elements to zero
  4137. * @returns the current matrix
  4138. */
  4139. reset(): Matrix;
  4140. /**
  4141. * Adds the current matrix with a second one
  4142. * @param other defines the matrix to add
  4143. * @returns a new matrix as the addition of the current matrix and the given one
  4144. */
  4145. add(other: DeepImmutable<Matrix>): Matrix;
  4146. /**
  4147. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4148. * @param other defines the matrix to add
  4149. * @param result defines the target matrix
  4150. * @returns the current matrix
  4151. */
  4152. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4153. /**
  4154. * Adds in place the given matrix to the current matrix
  4155. * @param other defines the second operand
  4156. * @returns the current updated matrix
  4157. */
  4158. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4159. /**
  4160. * Sets the given matrix to the current inverted Matrix
  4161. * @param other defines the target matrix
  4162. * @returns the unmodified current matrix
  4163. */
  4164. invertToRef(other: Matrix): Matrix;
  4165. /**
  4166. * add a value at the specified position in the current Matrix
  4167. * @param index the index of the value within the matrix. between 0 and 15.
  4168. * @param value the value to be added
  4169. * @returns the current updated matrix
  4170. */
  4171. addAtIndex(index: number, value: number): Matrix;
  4172. /**
  4173. * mutiply the specified position in the current Matrix by a value
  4174. * @param index the index of the value within the matrix. between 0 and 15.
  4175. * @param value the value to be added
  4176. * @returns the current updated matrix
  4177. */
  4178. multiplyAtIndex(index: number, value: number): Matrix;
  4179. /**
  4180. * Inserts the translation vector (using 3 floats) in the current matrix
  4181. * @param x defines the 1st component of the translation
  4182. * @param y defines the 2nd component of the translation
  4183. * @param z defines the 3rd component of the translation
  4184. * @returns the current updated matrix
  4185. */
  4186. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4187. /**
  4188. * Adds the translation vector (using 3 floats) in the current matrix
  4189. * @param x defines the 1st component of the translation
  4190. * @param y defines the 2nd component of the translation
  4191. * @param z defines the 3rd component of the translation
  4192. * @returns the current updated matrix
  4193. */
  4194. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4195. /**
  4196. * Inserts the translation vector in the current matrix
  4197. * @param vector3 defines the translation to insert
  4198. * @returns the current updated matrix
  4199. */
  4200. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4201. /**
  4202. * Gets the translation value of the current matrix
  4203. * @returns a new Vector3 as the extracted translation from the matrix
  4204. */
  4205. getTranslation(): Vector3;
  4206. /**
  4207. * Fill a Vector3 with the extracted translation from the matrix
  4208. * @param result defines the Vector3 where to store the translation
  4209. * @returns the current matrix
  4210. */
  4211. getTranslationToRef(result: Vector3): Matrix;
  4212. /**
  4213. * Remove rotation and scaling part from the matrix
  4214. * @returns the updated matrix
  4215. */
  4216. removeRotationAndScaling(): Matrix;
  4217. /**
  4218. * Multiply two matrices
  4219. * @param other defines the second operand
  4220. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4221. */
  4222. multiply(other: DeepImmutable<Matrix>): Matrix;
  4223. /**
  4224. * Copy the current matrix from the given one
  4225. * @param other defines the source matrix
  4226. * @returns the current updated matrix
  4227. */
  4228. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4229. /**
  4230. * Populates the given array from the starting index with the current matrix values
  4231. * @param array defines the target array
  4232. * @param offset defines the offset in the target array where to start storing values
  4233. * @returns the current matrix
  4234. */
  4235. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4236. /**
  4237. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4238. * @param other defines the second operand
  4239. * @param result defines the matrix where to store the multiplication
  4240. * @returns the current matrix
  4241. */
  4242. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4243. /**
  4244. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4245. * @param other defines the second operand
  4246. * @param result defines the array where to store the multiplication
  4247. * @param offset defines the offset in the target array where to start storing values
  4248. * @returns the current matrix
  4249. */
  4250. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4251. /**
  4252. * Check equality between this matrix and a second one
  4253. * @param value defines the second matrix to compare
  4254. * @returns true is the current matrix and the given one values are strictly equal
  4255. */
  4256. equals(value: DeepImmutable<Matrix>): boolean;
  4257. /**
  4258. * Clone the current matrix
  4259. * @returns a new matrix from the current matrix
  4260. */
  4261. clone(): Matrix;
  4262. /**
  4263. * Returns the name of the current matrix class
  4264. * @returns the string "Matrix"
  4265. */
  4266. getClassName(): string;
  4267. /**
  4268. * Gets the hash code of the current matrix
  4269. * @returns the hash code
  4270. */
  4271. getHashCode(): number;
  4272. /**
  4273. * Decomposes the current Matrix into a translation, rotation and scaling components
  4274. * @param scale defines the scale vector3 given as a reference to update
  4275. * @param rotation defines the rotation quaternion given as a reference to update
  4276. * @param translation defines the translation vector3 given as a reference to update
  4277. * @returns true if operation was successful
  4278. */
  4279. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4280. /**
  4281. * Gets specific row of the matrix
  4282. * @param index defines the number of the row to get
  4283. * @returns the index-th row of the current matrix as a new Vector4
  4284. */
  4285. getRow(index: number): Nullable<Vector4>;
  4286. /**
  4287. * Sets the index-th row of the current matrix to the vector4 values
  4288. * @param index defines the number of the row to set
  4289. * @param row defines the target vector4
  4290. * @returns the updated current matrix
  4291. */
  4292. setRow(index: number, row: Vector4): Matrix;
  4293. /**
  4294. * Compute the transpose of the matrix
  4295. * @returns the new transposed matrix
  4296. */
  4297. transpose(): Matrix;
  4298. /**
  4299. * Compute the transpose of the matrix and store it in a given matrix
  4300. * @param result defines the target matrix
  4301. * @returns the current matrix
  4302. */
  4303. transposeToRef(result: Matrix): Matrix;
  4304. /**
  4305. * Sets the index-th row of the current matrix with the given 4 x float values
  4306. * @param index defines the row index
  4307. * @param x defines the x component to set
  4308. * @param y defines the y component to set
  4309. * @param z defines the z component to set
  4310. * @param w defines the w component to set
  4311. * @returns the updated current matrix
  4312. */
  4313. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4314. /**
  4315. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4316. * @param scale defines the scale factor
  4317. * @returns a new matrix
  4318. */
  4319. scale(scale: number): Matrix;
  4320. /**
  4321. * Scale the current matrix values by a factor to a given result matrix
  4322. * @param scale defines the scale factor
  4323. * @param result defines the matrix to store the result
  4324. * @returns the current matrix
  4325. */
  4326. scaleToRef(scale: number, result: Matrix): Matrix;
  4327. /**
  4328. * Scale the current matrix values by a factor and add the result to a given matrix
  4329. * @param scale defines the scale factor
  4330. * @param result defines the Matrix to store the result
  4331. * @returns the current matrix
  4332. */
  4333. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4334. /**
  4335. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4336. * @param ref matrix to store the result
  4337. */
  4338. toNormalMatrix(ref: Matrix): void;
  4339. /**
  4340. * Gets only rotation part of the current matrix
  4341. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4342. */
  4343. getRotationMatrix(): Matrix;
  4344. /**
  4345. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4346. * @param result defines the target matrix to store data to
  4347. * @returns the current matrix
  4348. */
  4349. getRotationMatrixToRef(result: Matrix): Matrix;
  4350. /**
  4351. * Toggles model matrix from being right handed to left handed in place and vice versa
  4352. */
  4353. toggleModelMatrixHandInPlace(): void;
  4354. /**
  4355. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4356. */
  4357. toggleProjectionMatrixHandInPlace(): void;
  4358. /**
  4359. * Creates a matrix from an array
  4360. * @param array defines the source array
  4361. * @param offset defines an offset in the source array
  4362. * @returns a new Matrix set from the starting index of the given array
  4363. */
  4364. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4365. /**
  4366. * Copy the content of an array into a given matrix
  4367. * @param array defines the source array
  4368. * @param offset defines an offset in the source array
  4369. * @param result defines the target matrix
  4370. */
  4371. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4372. /**
  4373. * Stores an array into a matrix after having multiplied each component by a given factor
  4374. * @param array defines the source array
  4375. * @param offset defines the offset in the source array
  4376. * @param scale defines the scaling factor
  4377. * @param result defines the target matrix
  4378. */
  4379. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4380. /**
  4381. * Gets an identity matrix that must not be updated
  4382. */
  4383. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4384. /**
  4385. * Stores a list of values (16) inside a given matrix
  4386. * @param initialM11 defines 1st value of 1st row
  4387. * @param initialM12 defines 2nd value of 1st row
  4388. * @param initialM13 defines 3rd value of 1st row
  4389. * @param initialM14 defines 4th value of 1st row
  4390. * @param initialM21 defines 1st value of 2nd row
  4391. * @param initialM22 defines 2nd value of 2nd row
  4392. * @param initialM23 defines 3rd value of 2nd row
  4393. * @param initialM24 defines 4th value of 2nd row
  4394. * @param initialM31 defines 1st value of 3rd row
  4395. * @param initialM32 defines 2nd value of 3rd row
  4396. * @param initialM33 defines 3rd value of 3rd row
  4397. * @param initialM34 defines 4th value of 3rd row
  4398. * @param initialM41 defines 1st value of 4th row
  4399. * @param initialM42 defines 2nd value of 4th row
  4400. * @param initialM43 defines 3rd value of 4th row
  4401. * @param initialM44 defines 4th value of 4th row
  4402. * @param result defines the target matrix
  4403. */
  4404. 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;
  4405. /**
  4406. * Creates new matrix from a list of values (16)
  4407. * @param initialM11 defines 1st value of 1st row
  4408. * @param initialM12 defines 2nd value of 1st row
  4409. * @param initialM13 defines 3rd value of 1st row
  4410. * @param initialM14 defines 4th value of 1st row
  4411. * @param initialM21 defines 1st value of 2nd row
  4412. * @param initialM22 defines 2nd value of 2nd row
  4413. * @param initialM23 defines 3rd value of 2nd row
  4414. * @param initialM24 defines 4th value of 2nd row
  4415. * @param initialM31 defines 1st value of 3rd row
  4416. * @param initialM32 defines 2nd value of 3rd row
  4417. * @param initialM33 defines 3rd value of 3rd row
  4418. * @param initialM34 defines 4th value of 3rd row
  4419. * @param initialM41 defines 1st value of 4th row
  4420. * @param initialM42 defines 2nd value of 4th row
  4421. * @param initialM43 defines 3rd value of 4th row
  4422. * @param initialM44 defines 4th value of 4th row
  4423. * @returns the new matrix
  4424. */
  4425. 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;
  4426. /**
  4427. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4428. * @param scale defines the scale vector3
  4429. * @param rotation defines the rotation quaternion
  4430. * @param translation defines the translation vector3
  4431. * @returns a new matrix
  4432. */
  4433. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4434. /**
  4435. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4436. * @param scale defines the scale vector3
  4437. * @param rotation defines the rotation quaternion
  4438. * @param translation defines the translation vector3
  4439. * @param result defines the target matrix
  4440. */
  4441. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4442. /**
  4443. * Creates a new identity matrix
  4444. * @returns a new identity matrix
  4445. */
  4446. static Identity(): Matrix;
  4447. /**
  4448. * Creates a new identity matrix and stores the result in a given matrix
  4449. * @param result defines the target matrix
  4450. */
  4451. static IdentityToRef(result: Matrix): void;
  4452. /**
  4453. * Creates a new zero matrix
  4454. * @returns a new zero matrix
  4455. */
  4456. static Zero(): Matrix;
  4457. /**
  4458. * Creates a new rotation matrix for "angle" radians around the X axis
  4459. * @param angle defines the angle (in radians) to use
  4460. * @return the new matrix
  4461. */
  4462. static RotationX(angle: number): Matrix;
  4463. /**
  4464. * Creates a new matrix as the invert of a given matrix
  4465. * @param source defines the source matrix
  4466. * @returns the new matrix
  4467. */
  4468. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4469. /**
  4470. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4471. * @param angle defines the angle (in radians) to use
  4472. * @param result defines the target matrix
  4473. */
  4474. static RotationXToRef(angle: number, result: Matrix): void;
  4475. /**
  4476. * Creates a new rotation matrix for "angle" radians around the Y axis
  4477. * @param angle defines the angle (in radians) to use
  4478. * @return the new matrix
  4479. */
  4480. static RotationY(angle: number): Matrix;
  4481. /**
  4482. * Creates a new rotation matrix for "angle" radians around the Y 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 RotationYToRef(angle: number, result: Matrix): void;
  4487. /**
  4488. * Creates a new rotation matrix for "angle" radians around the Z axis
  4489. * @param angle defines the angle (in radians) to use
  4490. * @return the new matrix
  4491. */
  4492. static RotationZ(angle: number): Matrix;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the Z 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 RotationZToRef(angle: number, result: Matrix): void;
  4499. /**
  4500. * Creates a new rotation matrix for "angle" radians around the given axis
  4501. * @param axis defines the axis to use
  4502. * @param angle defines the angle (in radians) to use
  4503. * @return the new matrix
  4504. */
  4505. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4506. /**
  4507. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4508. * @param axis defines the axis to use
  4509. * @param angle defines the angle (in radians) to use
  4510. * @param result defines the target matrix
  4511. */
  4512. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4513. /**
  4514. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4515. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4516. * @param from defines the vector to align
  4517. * @param to defines the vector to align to
  4518. * @param result defines the target matrix
  4519. */
  4520. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4521. /**
  4522. * Creates a rotation matrix
  4523. * @param yaw defines the yaw angle in radians (Y axis)
  4524. * @param pitch defines the pitch angle in radians (X axis)
  4525. * @param roll defines the roll angle in radians (Z axis)
  4526. * @returns the new rotation matrix
  4527. */
  4528. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4529. /**
  4530. * Creates a rotation matrix and stores it in a given matrix
  4531. * @param yaw defines the yaw angle in radians (Y axis)
  4532. * @param pitch defines the pitch angle in radians (X axis)
  4533. * @param roll defines the roll angle in radians (Z axis)
  4534. * @param result defines the target matrix
  4535. */
  4536. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4537. /**
  4538. * Creates a scaling matrix
  4539. * @param x defines the scale factor on X axis
  4540. * @param y defines the scale factor on Y axis
  4541. * @param z defines the scale factor on Z axis
  4542. * @returns the new matrix
  4543. */
  4544. static Scaling(x: number, y: number, z: number): Matrix;
  4545. /**
  4546. * Creates a scaling matrix and stores it in a given matrix
  4547. * @param x defines the scale factor on X axis
  4548. * @param y defines the scale factor on Y axis
  4549. * @param z defines the scale factor on Z axis
  4550. * @param result defines the target matrix
  4551. */
  4552. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4553. /**
  4554. * Creates a translation matrix
  4555. * @param x defines the translation on X axis
  4556. * @param y defines the translation on Y axis
  4557. * @param z defines the translationon Z axis
  4558. * @returns the new matrix
  4559. */
  4560. static Translation(x: number, y: number, z: number): Matrix;
  4561. /**
  4562. * Creates a translation matrix and stores it in a given matrix
  4563. * @param x defines the translation on X axis
  4564. * @param y defines the translation on Y axis
  4565. * @param z defines the translationon Z axis
  4566. * @param result defines the target matrix
  4567. */
  4568. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4569. /**
  4570. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4571. * @param startValue defines the start value
  4572. * @param endValue defines the end value
  4573. * @param gradient defines the gradient factor
  4574. * @returns the new matrix
  4575. */
  4576. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4577. /**
  4578. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4579. * @param startValue defines the start value
  4580. * @param endValue defines the end value
  4581. * @param gradient defines the gradient factor
  4582. * @param result defines the Matrix object where to store data
  4583. */
  4584. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4585. /**
  4586. * Builds a new matrix whose values are computed by:
  4587. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4588. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4589. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4590. * @param startValue defines the first matrix
  4591. * @param endValue defines the second matrix
  4592. * @param gradient defines the gradient between the two matrices
  4593. * @returns the new matrix
  4594. */
  4595. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4596. /**
  4597. * Update a matrix to values which are computed by:
  4598. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4599. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4600. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4601. * @param startValue defines the first matrix
  4602. * @param endValue defines the second matrix
  4603. * @param gradient defines the gradient between the two matrices
  4604. * @param result defines the target matrix
  4605. */
  4606. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4607. /**
  4608. * 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"
  4609. * This function works in left handed mode
  4610. * @param eye defines the final position of the entity
  4611. * @param target defines where the entity should look at
  4612. * @param up defines the up vector for the entity
  4613. * @returns the new matrix
  4614. */
  4615. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4616. /**
  4617. * 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".
  4618. * This function works in left handed mode
  4619. * @param eye defines the final position of the entity
  4620. * @param target defines where the entity should look at
  4621. * @param up defines the up vector for the entity
  4622. * @param result defines the target matrix
  4623. */
  4624. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4625. /**
  4626. * 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"
  4627. * This function works in right handed mode
  4628. * @param eye defines the final position of the entity
  4629. * @param target defines where the entity should look at
  4630. * @param up defines the up vector for the entity
  4631. * @returns the new matrix
  4632. */
  4633. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4634. /**
  4635. * 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".
  4636. * This function works in right handed mode
  4637. * @param eye defines the final position of the entity
  4638. * @param target defines where the entity should look at
  4639. * @param up defines the up vector for the entity
  4640. * @param result defines the target matrix
  4641. */
  4642. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4643. /**
  4644. * Create a left-handed orthographic projection matrix
  4645. * @param width defines the viewport width
  4646. * @param height defines the viewport height
  4647. * @param znear defines the near clip plane
  4648. * @param zfar defines the far clip plane
  4649. * @returns a new matrix as a left-handed orthographic projection matrix
  4650. */
  4651. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4652. /**
  4653. * Store a left-handed orthographic projection to a given matrix
  4654. * @param width defines the viewport width
  4655. * @param height defines the viewport height
  4656. * @param znear defines the near clip plane
  4657. * @param zfar defines the far clip plane
  4658. * @param result defines the target matrix
  4659. */
  4660. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4661. /**
  4662. * Create a left-handed orthographic projection matrix
  4663. * @param left defines the viewport left coordinate
  4664. * @param right defines the viewport right coordinate
  4665. * @param bottom defines the viewport bottom coordinate
  4666. * @param top defines the viewport top coordinate
  4667. * @param znear defines the near clip plane
  4668. * @param zfar defines the far clip plane
  4669. * @returns a new matrix as a left-handed orthographic projection matrix
  4670. */
  4671. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4672. /**
  4673. * Stores a left-handed orthographic projection into a given matrix
  4674. * @param left defines the viewport left coordinate
  4675. * @param right defines the viewport right coordinate
  4676. * @param bottom defines the viewport bottom coordinate
  4677. * @param top defines the viewport top coordinate
  4678. * @param znear defines the near clip plane
  4679. * @param zfar defines the far clip plane
  4680. * @param result defines the target matrix
  4681. */
  4682. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4683. /**
  4684. * Creates a right-handed orthographic projection matrix
  4685. * @param left defines the viewport left coordinate
  4686. * @param right defines the viewport right coordinate
  4687. * @param bottom defines the viewport bottom coordinate
  4688. * @param top defines the viewport top coordinate
  4689. * @param znear defines the near clip plane
  4690. * @param zfar defines the far clip plane
  4691. * @returns a new matrix as a right-handed orthographic projection matrix
  4692. */
  4693. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4694. /**
  4695. * Stores a right-handed orthographic projection into a given matrix
  4696. * @param left defines the viewport left coordinate
  4697. * @param right defines the viewport right coordinate
  4698. * @param bottom defines the viewport bottom coordinate
  4699. * @param top defines the viewport top coordinate
  4700. * @param znear defines the near clip plane
  4701. * @param zfar defines the far clip plane
  4702. * @param result defines the target matrix
  4703. */
  4704. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4705. /**
  4706. * Creates a left-handed perspective projection matrix
  4707. * @param width defines the viewport width
  4708. * @param height defines the viewport height
  4709. * @param znear defines the near clip plane
  4710. * @param zfar defines the far clip plane
  4711. * @returns a new matrix as a left-handed perspective projection matrix
  4712. */
  4713. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4714. /**
  4715. * Creates a left-handed perspective projection matrix
  4716. * @param fov defines the horizontal field of view
  4717. * @param aspect defines the aspect ratio
  4718. * @param znear defines the near clip plane
  4719. * @param zfar defines the far clip plane
  4720. * @returns a new matrix as a left-handed perspective projection matrix
  4721. */
  4722. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4723. /**
  4724. * Stores a left-handed perspective projection into a given matrix
  4725. * @param fov defines the horizontal field of view
  4726. * @param aspect defines the aspect ratio
  4727. * @param znear defines the near clip plane
  4728. * @param zfar defines the far clip plane
  4729. * @param result defines the target matrix
  4730. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4731. */
  4732. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4733. /**
  4734. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4735. * @param fov defines the horizontal field of view
  4736. * @param aspect defines the aspect ratio
  4737. * @param znear defines the near clip plane
  4738. * @param zfar not used as infinity is used as far clip
  4739. * @param result defines the target matrix
  4740. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4741. */
  4742. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4743. /**
  4744. * Creates a right-handed perspective projection matrix
  4745. * @param fov defines the horizontal field of view
  4746. * @param aspect defines the aspect ratio
  4747. * @param znear defines the near clip plane
  4748. * @param zfar defines the far clip plane
  4749. * @returns a new matrix as a right-handed perspective projection matrix
  4750. */
  4751. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4752. /**
  4753. * Stores a right-handed perspective projection into a given matrix
  4754. * @param fov defines the horizontal field of view
  4755. * @param aspect defines the aspect ratio
  4756. * @param znear defines the near clip plane
  4757. * @param zfar defines the far clip plane
  4758. * @param result defines the target matrix
  4759. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4760. */
  4761. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4762. /**
  4763. * Stores a right-handed perspective projection into a given matrix
  4764. * @param fov defines the horizontal field of view
  4765. * @param aspect defines the aspect ratio
  4766. * @param znear defines the near clip plane
  4767. * @param zfar not used as infinity is used as far clip
  4768. * @param result defines the target matrix
  4769. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4770. */
  4771. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4772. /**
  4773. * Stores a perspective projection for WebVR info a given matrix
  4774. * @param fov defines the field of view
  4775. * @param znear defines the near clip plane
  4776. * @param zfar defines the far clip plane
  4777. * @param result defines the target matrix
  4778. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4779. */
  4780. static PerspectiveFovWebVRToRef(fov: {
  4781. upDegrees: number;
  4782. downDegrees: number;
  4783. leftDegrees: number;
  4784. rightDegrees: number;
  4785. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4786. /**
  4787. * Computes a complete transformation matrix
  4788. * @param viewport defines the viewport to use
  4789. * @param world defines the world matrix
  4790. * @param view defines the view matrix
  4791. * @param projection defines the projection matrix
  4792. * @param zmin defines the near clip plane
  4793. * @param zmax defines the far clip plane
  4794. * @returns the transformation matrix
  4795. */
  4796. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4797. /**
  4798. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4799. * @param matrix defines the matrix to use
  4800. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4801. */
  4802. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4803. /**
  4804. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4805. * @param matrix defines the matrix to use
  4806. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4807. */
  4808. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4809. /**
  4810. * Compute the transpose of a given matrix
  4811. * @param matrix defines the matrix to transpose
  4812. * @returns the new matrix
  4813. */
  4814. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4815. /**
  4816. * Compute the transpose of a matrix and store it in a target matrix
  4817. * @param matrix defines the matrix to transpose
  4818. * @param result defines the target matrix
  4819. */
  4820. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4821. /**
  4822. * Computes a reflection matrix from a plane
  4823. * @param plane defines the reflection plane
  4824. * @returns a new matrix
  4825. */
  4826. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4827. /**
  4828. * Computes a reflection matrix from a plane
  4829. * @param plane defines the reflection plane
  4830. * @param result defines the target matrix
  4831. */
  4832. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4833. /**
  4834. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4835. * @param xaxis defines the value of the 1st axis
  4836. * @param yaxis defines the value of the 2nd axis
  4837. * @param zaxis defines the value of the 3rd axis
  4838. * @param result defines the target matrix
  4839. */
  4840. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4841. /**
  4842. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4843. * @param quat defines the quaternion to use
  4844. * @param result defines the target matrix
  4845. */
  4846. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4847. }
  4848. /**
  4849. * @hidden
  4850. */
  4851. export class TmpVectors {
  4852. static Vector2: Vector2[];
  4853. static Vector3: Vector3[];
  4854. static Vector4: Vector4[];
  4855. static Quaternion: Quaternion[];
  4856. static Matrix: Matrix[];
  4857. }
  4858. }
  4859. declare module BABYLON {
  4860. /**
  4861. * Defines potential orientation for back face culling
  4862. */
  4863. export enum Orientation {
  4864. /**
  4865. * Clockwise
  4866. */
  4867. CW = 0,
  4868. /** Counter clockwise */
  4869. CCW = 1
  4870. }
  4871. /** Class used to represent a Bezier curve */
  4872. export class BezierCurve {
  4873. /**
  4874. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4875. * @param t defines the time
  4876. * @param x1 defines the left coordinate on X axis
  4877. * @param y1 defines the left coordinate on Y axis
  4878. * @param x2 defines the right coordinate on X axis
  4879. * @param y2 defines the right coordinate on Y axis
  4880. * @returns the interpolated value
  4881. */
  4882. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4883. }
  4884. /**
  4885. * Defines angle representation
  4886. */
  4887. export class Angle {
  4888. private _radians;
  4889. /**
  4890. * Creates an Angle object of "radians" radians (float).
  4891. * @param radians the angle in radians
  4892. */
  4893. constructor(radians: number);
  4894. /**
  4895. * Get value in degrees
  4896. * @returns the Angle value in degrees (float)
  4897. */
  4898. degrees(): number;
  4899. /**
  4900. * Get value in radians
  4901. * @returns the Angle value in radians (float)
  4902. */
  4903. radians(): number;
  4904. /**
  4905. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4906. * @param a defines first point as the origin
  4907. * @param b defines point
  4908. * @returns a new Angle
  4909. */
  4910. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4911. /**
  4912. * Gets a new Angle object from the given float in radians
  4913. * @param radians defines the angle value in radians
  4914. * @returns a new Angle
  4915. */
  4916. static FromRadians(radians: number): Angle;
  4917. /**
  4918. * Gets a new Angle object from the given float in degrees
  4919. * @param degrees defines the angle value in degrees
  4920. * @returns a new Angle
  4921. */
  4922. static FromDegrees(degrees: number): Angle;
  4923. }
  4924. /**
  4925. * This represents an arc in a 2d space.
  4926. */
  4927. export class Arc2 {
  4928. /** Defines the start point of the arc */
  4929. startPoint: Vector2;
  4930. /** Defines the mid point of the arc */
  4931. midPoint: Vector2;
  4932. /** Defines the end point of the arc */
  4933. endPoint: Vector2;
  4934. /**
  4935. * Defines the center point of the arc.
  4936. */
  4937. centerPoint: Vector2;
  4938. /**
  4939. * Defines the radius of the arc.
  4940. */
  4941. radius: number;
  4942. /**
  4943. * Defines the angle of the arc (from mid point to end point).
  4944. */
  4945. angle: Angle;
  4946. /**
  4947. * Defines the start angle of the arc (from start point to middle point).
  4948. */
  4949. startAngle: Angle;
  4950. /**
  4951. * Defines the orientation of the arc (clock wise/counter clock wise).
  4952. */
  4953. orientation: Orientation;
  4954. /**
  4955. * Creates an Arc object from the three given points : start, middle and end.
  4956. * @param startPoint Defines the start point of the arc
  4957. * @param midPoint Defines the midlle point of the arc
  4958. * @param endPoint Defines the end point of the arc
  4959. */
  4960. constructor(
  4961. /** Defines the start point of the arc */
  4962. startPoint: Vector2,
  4963. /** Defines the mid point of the arc */
  4964. midPoint: Vector2,
  4965. /** Defines the end point of the arc */
  4966. endPoint: Vector2);
  4967. }
  4968. /**
  4969. * Represents a 2D path made up of multiple 2D points
  4970. */
  4971. export class Path2 {
  4972. private _points;
  4973. private _length;
  4974. /**
  4975. * If the path start and end point are the same
  4976. */
  4977. closed: boolean;
  4978. /**
  4979. * Creates a Path2 object from the starting 2D coordinates x and y.
  4980. * @param x the starting points x value
  4981. * @param y the starting points y value
  4982. */
  4983. constructor(x: number, y: number);
  4984. /**
  4985. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4986. * @param x the added points x value
  4987. * @param y the added points y value
  4988. * @returns the updated Path2.
  4989. */
  4990. addLineTo(x: number, y: number): Path2;
  4991. /**
  4992. * 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.
  4993. * @param midX middle point x value
  4994. * @param midY middle point y value
  4995. * @param endX end point x value
  4996. * @param endY end point y value
  4997. * @param numberOfSegments (default: 36)
  4998. * @returns the updated Path2.
  4999. */
  5000. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5001. /**
  5002. * Closes the Path2.
  5003. * @returns the Path2.
  5004. */
  5005. close(): Path2;
  5006. /**
  5007. * Gets the sum of the distance between each sequential point in the path
  5008. * @returns the Path2 total length (float).
  5009. */
  5010. length(): number;
  5011. /**
  5012. * Gets the points which construct the path
  5013. * @returns the Path2 internal array of points.
  5014. */
  5015. getPoints(): Vector2[];
  5016. /**
  5017. * Retreives the point at the distance aways from the starting point
  5018. * @param normalizedLengthPosition the length along the path to retreive the point from
  5019. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5020. */
  5021. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5022. /**
  5023. * Creates a new path starting from an x and y position
  5024. * @param x starting x value
  5025. * @param y starting y value
  5026. * @returns a new Path2 starting at the coordinates (x, y).
  5027. */
  5028. static StartingAt(x: number, y: number): Path2;
  5029. }
  5030. /**
  5031. * Represents a 3D path made up of multiple 3D points
  5032. */
  5033. export class Path3D {
  5034. /**
  5035. * an array of Vector3, the curve axis of the Path3D
  5036. */
  5037. path: Vector3[];
  5038. private _curve;
  5039. private _distances;
  5040. private _tangents;
  5041. private _normals;
  5042. private _binormals;
  5043. private _raw;
  5044. private _alignTangentsWithPath;
  5045. private readonly _pointAtData;
  5046. /**
  5047. * new Path3D(path, normal, raw)
  5048. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5049. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5050. * @param path an array of Vector3, the curve axis of the Path3D
  5051. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5052. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5053. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5054. */
  5055. constructor(
  5056. /**
  5057. * an array of Vector3, the curve axis of the Path3D
  5058. */
  5059. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5060. /**
  5061. * Returns the Path3D array of successive Vector3 designing its curve.
  5062. * @returns the Path3D array of successive Vector3 designing its curve.
  5063. */
  5064. getCurve(): Vector3[];
  5065. /**
  5066. * Returns the Path3D array of successive Vector3 designing its curve.
  5067. * @returns the Path3D array of successive Vector3 designing its curve.
  5068. */
  5069. getPoints(): Vector3[];
  5070. /**
  5071. * @returns the computed length (float) of the path.
  5072. */
  5073. length(): number;
  5074. /**
  5075. * Returns an array populated with tangent vectors on each Path3D curve point.
  5076. * @returns an array populated with tangent vectors on each Path3D curve point.
  5077. */
  5078. getTangents(): Vector3[];
  5079. /**
  5080. * Returns an array populated with normal vectors on each Path3D curve point.
  5081. * @returns an array populated with normal vectors on each Path3D curve point.
  5082. */
  5083. getNormals(): Vector3[];
  5084. /**
  5085. * Returns an array populated with binormal vectors on each Path3D curve point.
  5086. * @returns an array populated with binormal vectors on each Path3D curve point.
  5087. */
  5088. getBinormals(): Vector3[];
  5089. /**
  5090. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5091. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5092. */
  5093. getDistances(): number[];
  5094. /**
  5095. * Returns an interpolated point along this path
  5096. * @param position the position of the point along this path, from 0.0 to 1.0
  5097. * @returns a new Vector3 as the point
  5098. */
  5099. getPointAt(position: number): Vector3;
  5100. /**
  5101. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5102. * @param position the position of the point along this path, from 0.0 to 1.0
  5103. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5104. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5105. */
  5106. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5107. /**
  5108. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5109. * @param position the position of the point along this path, from 0.0 to 1.0
  5110. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5111. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5112. */
  5113. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5114. /**
  5115. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5116. * @param position the position of the point along this path, from 0.0 to 1.0
  5117. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5118. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5119. */
  5120. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5121. /**
  5122. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5123. * @param position the position of the point along this path, from 0.0 to 1.0
  5124. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5125. */
  5126. getDistanceAt(position: number): number;
  5127. /**
  5128. * Returns the array index of the previous point of an interpolated point along this path
  5129. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5130. * @returns the array index
  5131. */
  5132. getPreviousPointIndexAt(position: number): number;
  5133. /**
  5134. * 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)
  5135. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5136. * @returns the sub position
  5137. */
  5138. getSubPositionAt(position: number): number;
  5139. /**
  5140. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5141. * @param target the vector of which to get the closest position to
  5142. * @returns the position of the closest virtual point on this path to the target vector
  5143. */
  5144. getClosestPositionTo(target: Vector3): number;
  5145. /**
  5146. * Returns a sub path (slice) of this path
  5147. * @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
  5148. * @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
  5149. * @returns a sub path (slice) of this path
  5150. */
  5151. slice(start?: number, end?: number): Path3D;
  5152. /**
  5153. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5154. * @param path path which all values are copied into the curves points
  5155. * @param firstNormal which should be projected onto the curve
  5156. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5157. * @returns the same object updated.
  5158. */
  5159. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5160. private _compute;
  5161. private _getFirstNonNullVector;
  5162. private _getLastNonNullVector;
  5163. private _normalVector;
  5164. /**
  5165. * Updates the point at data for an interpolated point along this curve
  5166. * @param position the position of the point along this curve, from 0.0 to 1.0
  5167. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5168. * @returns the (updated) point at data
  5169. */
  5170. private _updatePointAtData;
  5171. /**
  5172. * Updates the point at data from the specified parameters
  5173. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5174. * @param point the interpolated point
  5175. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5176. */
  5177. private _setPointAtData;
  5178. /**
  5179. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5180. */
  5181. private _updateInterpolationMatrix;
  5182. }
  5183. /**
  5184. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5185. * A Curve3 is designed from a series of successive Vector3.
  5186. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5187. */
  5188. export class Curve3 {
  5189. private _points;
  5190. private _length;
  5191. /**
  5192. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5193. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5194. * @param v1 (Vector3) the control point
  5195. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5196. * @param nbPoints (integer) the wanted number of points in the curve
  5197. * @returns the created Curve3
  5198. */
  5199. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5200. /**
  5201. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5202. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5203. * @param v1 (Vector3) the first control point
  5204. * @param v2 (Vector3) the second control point
  5205. * @param v3 (Vector3) the end point of the Cubic Bezier
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5212. * @param p1 (Vector3) the origin point of the Hermite Spline
  5213. * @param t1 (Vector3) the tangent vector at the origin point
  5214. * @param p2 (Vector3) the end point of the Hermite Spline
  5215. * @param t2 (Vector3) the tangent vector at the end point
  5216. * @param nbPoints (integer) the wanted number of points in the curve
  5217. * @returns the created Curve3
  5218. */
  5219. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5220. /**
  5221. * Returns a Curve3 object along a CatmullRom Spline curve :
  5222. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5223. * @param nbPoints (integer) the wanted number of points between each curve control points
  5224. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5225. * @returns the created Curve3
  5226. */
  5227. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5228. /**
  5229. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5230. * A Curve3 is designed from a series of successive Vector3.
  5231. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5232. * @param points points which make up the curve
  5233. */
  5234. constructor(points: Vector3[]);
  5235. /**
  5236. * @returns the Curve3 stored array of successive Vector3
  5237. */
  5238. getPoints(): Vector3[];
  5239. /**
  5240. * @returns the computed length (float) of the curve.
  5241. */
  5242. length(): number;
  5243. /**
  5244. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5245. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5246. * curveA and curveB keep unchanged.
  5247. * @param curve the curve to continue from this curve
  5248. * @returns the newly constructed curve
  5249. */
  5250. continue(curve: DeepImmutable<Curve3>): Curve3;
  5251. private _computeLength;
  5252. }
  5253. }
  5254. declare module BABYLON {
  5255. /**
  5256. * This represents the main contract an easing function should follow.
  5257. * Easing functions are used throughout the animation system.
  5258. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export interface IEasingFunction {
  5261. /**
  5262. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5263. * of the easing function.
  5264. * The link below provides some of the most common examples of easing functions.
  5265. * @see https://easings.net/
  5266. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5267. * @returns the corresponding value on the curve defined by the easing function
  5268. */
  5269. ease(gradient: number): number;
  5270. }
  5271. /**
  5272. * Base class used for every default easing function.
  5273. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5274. */
  5275. export class EasingFunction implements IEasingFunction {
  5276. /**
  5277. * Interpolation follows the mathematical formula associated with the easing function.
  5278. */
  5279. static readonly EASINGMODE_EASEIN: number;
  5280. /**
  5281. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5282. */
  5283. static readonly EASINGMODE_EASEOUT: number;
  5284. /**
  5285. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5286. */
  5287. static readonly EASINGMODE_EASEINOUT: number;
  5288. private _easingMode;
  5289. /**
  5290. * Sets the easing mode of the current function.
  5291. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5292. */
  5293. setEasingMode(easingMode: number): void;
  5294. /**
  5295. * Gets the current easing mode.
  5296. * @returns the easing mode
  5297. */
  5298. getEasingMode(): number;
  5299. /**
  5300. * @hidden
  5301. */
  5302. easeInCore(gradient: number): number;
  5303. /**
  5304. * Given an input gradient between 0 and 1, this returns the corresponding value
  5305. * of the easing function.
  5306. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5307. * @returns the corresponding value on the curve defined by the easing function
  5308. */
  5309. ease(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with a circle shape (see link below).
  5313. * @see https://easings.net/#easeInCirc
  5314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class CircleEase extends EasingFunction implements IEasingFunction {
  5317. /** @hidden */
  5318. easeInCore(gradient: number): number;
  5319. }
  5320. /**
  5321. * Easing function with a ease back shape (see link below).
  5322. * @see https://easings.net/#easeInBack
  5323. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5324. */
  5325. export class BackEase extends EasingFunction implements IEasingFunction {
  5326. /** Defines the amplitude of the function */
  5327. amplitude: number;
  5328. /**
  5329. * Instantiates a back ease easing
  5330. * @see https://easings.net/#easeInBack
  5331. * @param amplitude Defines the amplitude of the function
  5332. */
  5333. constructor(
  5334. /** Defines the amplitude of the function */
  5335. amplitude?: number);
  5336. /** @hidden */
  5337. easeInCore(gradient: number): number;
  5338. }
  5339. /**
  5340. * Easing function with a bouncing shape (see link below).
  5341. * @see https://easings.net/#easeInBounce
  5342. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5343. */
  5344. export class BounceEase extends EasingFunction implements IEasingFunction {
  5345. /** Defines the number of bounces */
  5346. bounces: number;
  5347. /** Defines the amplitude of the bounce */
  5348. bounciness: number;
  5349. /**
  5350. * Instantiates a bounce easing
  5351. * @see https://easings.net/#easeInBounce
  5352. * @param bounces Defines the number of bounces
  5353. * @param bounciness Defines the amplitude of the bounce
  5354. */
  5355. constructor(
  5356. /** Defines the number of bounces */
  5357. bounces?: number,
  5358. /** Defines the amplitude of the bounce */
  5359. bounciness?: number);
  5360. /** @hidden */
  5361. easeInCore(gradient: number): number;
  5362. }
  5363. /**
  5364. * Easing function with a power of 3 shape (see link below).
  5365. * @see https://easings.net/#easeInCubic
  5366. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5367. */
  5368. export class CubicEase extends EasingFunction implements IEasingFunction {
  5369. /** @hidden */
  5370. easeInCore(gradient: number): number;
  5371. }
  5372. /**
  5373. * Easing function with an elastic shape (see link below).
  5374. * @see https://easings.net/#easeInElastic
  5375. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5376. */
  5377. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5378. /** Defines the number of oscillations*/
  5379. oscillations: number;
  5380. /** Defines the amplitude of the oscillations*/
  5381. springiness: number;
  5382. /**
  5383. * Instantiates an elastic easing function
  5384. * @see https://easings.net/#easeInElastic
  5385. * @param oscillations Defines the number of oscillations
  5386. * @param springiness Defines the amplitude of the oscillations
  5387. */
  5388. constructor(
  5389. /** Defines the number of oscillations*/
  5390. oscillations?: number,
  5391. /** Defines the amplitude of the oscillations*/
  5392. springiness?: number);
  5393. /** @hidden */
  5394. easeInCore(gradient: number): number;
  5395. }
  5396. /**
  5397. * Easing function with an exponential shape (see link below).
  5398. * @see https://easings.net/#easeInExpo
  5399. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5400. */
  5401. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5402. /** Defines the exponent of the function */
  5403. exponent: number;
  5404. /**
  5405. * Instantiates an exponential easing function
  5406. * @see https://easings.net/#easeInExpo
  5407. * @param exponent Defines the exponent of the function
  5408. */
  5409. constructor(
  5410. /** Defines the exponent of the function */
  5411. exponent?: number);
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power shape (see link below).
  5417. * @see https://easings.net/#easeInQuad
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class PowerEase extends EasingFunction implements IEasingFunction {
  5421. /** Defines the power of the function */
  5422. power: number;
  5423. /**
  5424. * Instantiates an power base easing function
  5425. * @see https://easings.net/#easeInQuad
  5426. * @param power Defines the power of the function
  5427. */
  5428. constructor(
  5429. /** Defines the power of the function */
  5430. power?: number);
  5431. /** @hidden */
  5432. easeInCore(gradient: number): number;
  5433. }
  5434. /**
  5435. * Easing function with a power of 2 shape (see link below).
  5436. * @see https://easings.net/#easeInQuad
  5437. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5438. */
  5439. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5440. /** @hidden */
  5441. easeInCore(gradient: number): number;
  5442. }
  5443. /**
  5444. * Easing function with a power of 4 shape (see link below).
  5445. * @see https://easings.net/#easeInQuart
  5446. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5447. */
  5448. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5449. /** @hidden */
  5450. easeInCore(gradient: number): number;
  5451. }
  5452. /**
  5453. * Easing function with a power of 5 shape (see link below).
  5454. * @see https://easings.net/#easeInQuint
  5455. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5456. */
  5457. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5458. /** @hidden */
  5459. easeInCore(gradient: number): number;
  5460. }
  5461. /**
  5462. * Easing function with a sin shape (see link below).
  5463. * @see https://easings.net/#easeInSine
  5464. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5465. */
  5466. export class SineEase extends EasingFunction implements IEasingFunction {
  5467. /** @hidden */
  5468. easeInCore(gradient: number): number;
  5469. }
  5470. /**
  5471. * Easing function with a bezier shape (see link below).
  5472. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5473. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5474. */
  5475. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5476. /** Defines the x component of the start tangent in the bezier curve */
  5477. x1: number;
  5478. /** Defines the y component of the start tangent in the bezier curve */
  5479. y1: number;
  5480. /** Defines the x component of the end tangent in the bezier curve */
  5481. x2: number;
  5482. /** Defines the y component of the end tangent in the bezier curve */
  5483. y2: number;
  5484. /**
  5485. * Instantiates a bezier function
  5486. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5487. * @param x1 Defines the x component of the start tangent in the bezier curve
  5488. * @param y1 Defines the y component of the start tangent in the bezier curve
  5489. * @param x2 Defines the x component of the end tangent in the bezier curve
  5490. * @param y2 Defines the y component of the end tangent in the bezier curve
  5491. */
  5492. constructor(
  5493. /** Defines the x component of the start tangent in the bezier curve */
  5494. x1?: number,
  5495. /** Defines the y component of the start tangent in the bezier curve */
  5496. y1?: number,
  5497. /** Defines the x component of the end tangent in the bezier curve */
  5498. x2?: number,
  5499. /** Defines the y component of the end tangent in the bezier curve */
  5500. y2?: number);
  5501. /** @hidden */
  5502. easeInCore(gradient: number): number;
  5503. }
  5504. }
  5505. declare module BABYLON {
  5506. /**
  5507. * Class used to hold a RBG color
  5508. */
  5509. export class Color3 {
  5510. /**
  5511. * Defines the red component (between 0 and 1, default is 0)
  5512. */
  5513. r: number;
  5514. /**
  5515. * Defines the green component (between 0 and 1, default is 0)
  5516. */
  5517. g: number;
  5518. /**
  5519. * Defines the blue component (between 0 and 1, default is 0)
  5520. */
  5521. b: number;
  5522. /**
  5523. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5524. * @param r defines the red component (between 0 and 1, default is 0)
  5525. * @param g defines the green component (between 0 and 1, default is 0)
  5526. * @param b defines the blue component (between 0 and 1, default is 0)
  5527. */
  5528. constructor(
  5529. /**
  5530. * Defines the red component (between 0 and 1, default is 0)
  5531. */
  5532. r?: number,
  5533. /**
  5534. * Defines the green component (between 0 and 1, default is 0)
  5535. */
  5536. g?: number,
  5537. /**
  5538. * Defines the blue component (between 0 and 1, default is 0)
  5539. */
  5540. b?: number);
  5541. /**
  5542. * Creates a string with the Color3 current values
  5543. * @returns the string representation of the Color3 object
  5544. */
  5545. toString(): string;
  5546. /**
  5547. * Returns the string "Color3"
  5548. * @returns "Color3"
  5549. */
  5550. getClassName(): string;
  5551. /**
  5552. * Compute the Color3 hash code
  5553. * @returns an unique number that can be used to hash Color3 objects
  5554. */
  5555. getHashCode(): number;
  5556. /**
  5557. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5558. * @param array defines the array where to store the r,g,b components
  5559. * @param index defines an optional index in the target array to define where to start storing values
  5560. * @returns the current Color3 object
  5561. */
  5562. toArray(array: FloatArray, index?: number): Color3;
  5563. /**
  5564. * Update the current color with values stored in an array from the starting index of the given array
  5565. * @param array defines the source array
  5566. * @param offset defines an offset in the source array
  5567. * @returns the current Color3 object
  5568. */
  5569. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5570. /**
  5571. * Returns a new Color4 object from the current Color3 and the given alpha
  5572. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5573. * @returns a new Color4 object
  5574. */
  5575. toColor4(alpha?: number): Color4;
  5576. /**
  5577. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5578. * @returns the new array
  5579. */
  5580. asArray(): number[];
  5581. /**
  5582. * Returns the luminance value
  5583. * @returns a float value
  5584. */
  5585. toLuminance(): number;
  5586. /**
  5587. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5588. * @param otherColor defines the second operand
  5589. * @returns the new Color3 object
  5590. */
  5591. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5592. /**
  5593. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5594. * @param otherColor defines the second operand
  5595. * @param result defines the Color3 object where to store the result
  5596. * @returns the current Color3
  5597. */
  5598. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5599. /**
  5600. * Determines equality between Color3 objects
  5601. * @param otherColor defines the second operand
  5602. * @returns true if the rgb values are equal to the given ones
  5603. */
  5604. equals(otherColor: DeepImmutable<Color3>): boolean;
  5605. /**
  5606. * Determines equality between the current Color3 object and a set of r,b,g values
  5607. * @param r defines the red component to check
  5608. * @param g defines the green component to check
  5609. * @param b defines the blue component to check
  5610. * @returns true if the rgb values are equal to the given ones
  5611. */
  5612. equalsFloats(r: number, g: number, b: number): boolean;
  5613. /**
  5614. * Multiplies in place each rgb value by scale
  5615. * @param scale defines the scaling factor
  5616. * @returns the updated Color3
  5617. */
  5618. scale(scale: number): Color3;
  5619. /**
  5620. * Multiplies the rgb values by scale and stores the result into "result"
  5621. * @param scale defines the scaling factor
  5622. * @param result defines the Color3 object where to store the result
  5623. * @returns the unmodified current Color3
  5624. */
  5625. scaleToRef(scale: number, result: Color3): Color3;
  5626. /**
  5627. * Scale the current Color3 values by a factor and add the result to a given Color3
  5628. * @param scale defines the scale factor
  5629. * @param result defines color to store the result into
  5630. * @returns the unmodified current Color3
  5631. */
  5632. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5633. /**
  5634. * Clamps the rgb values by the min and max values and stores the result into "result"
  5635. * @param min defines minimum clamping value (default is 0)
  5636. * @param max defines maximum clamping value (default is 1)
  5637. * @param result defines color to store the result into
  5638. * @returns the original Color3
  5639. */
  5640. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5641. /**
  5642. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5643. * @param otherColor defines the second operand
  5644. * @returns the new Color3
  5645. */
  5646. add(otherColor: DeepImmutable<Color3>): Color3;
  5647. /**
  5648. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5649. * @param otherColor defines the second operand
  5650. * @param result defines Color3 object to store the result into
  5651. * @returns the unmodified current Color3
  5652. */
  5653. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5654. /**
  5655. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5656. * @param otherColor defines the second operand
  5657. * @returns the new Color3
  5658. */
  5659. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5660. /**
  5661. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5662. * @param otherColor defines the second operand
  5663. * @param result defines Color3 object to store the result into
  5664. * @returns the unmodified current Color3
  5665. */
  5666. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5667. /**
  5668. * Copy the current object
  5669. * @returns a new Color3 copied the current one
  5670. */
  5671. clone(): Color3;
  5672. /**
  5673. * Copies the rgb values from the source in the current Color3
  5674. * @param source defines the source Color3 object
  5675. * @returns the updated Color3 object
  5676. */
  5677. copyFrom(source: DeepImmutable<Color3>): Color3;
  5678. /**
  5679. * Updates the Color3 rgb values from the given floats
  5680. * @param r defines the red component to read from
  5681. * @param g defines the green component to read from
  5682. * @param b defines the blue component to read from
  5683. * @returns the current Color3 object
  5684. */
  5685. copyFromFloats(r: number, g: number, b: number): Color3;
  5686. /**
  5687. * Updates the Color3 rgb values from the given floats
  5688. * @param r defines the red component to read from
  5689. * @param g defines the green component to read from
  5690. * @param b defines the blue component to read from
  5691. * @returns the current Color3 object
  5692. */
  5693. set(r: number, g: number, b: number): Color3;
  5694. /**
  5695. * Compute the Color3 hexadecimal code as a string
  5696. * @returns a string containing the hexadecimal representation of the Color3 object
  5697. */
  5698. toHexString(): string;
  5699. /**
  5700. * Computes a new Color3 converted from the current one to linear space
  5701. * @returns a new Color3 object
  5702. */
  5703. toLinearSpace(): Color3;
  5704. /**
  5705. * Converts current color in rgb space to HSV values
  5706. * @returns a new color3 representing the HSV values
  5707. */
  5708. toHSV(): Color3;
  5709. /**
  5710. * Converts current color in rgb space to HSV values
  5711. * @param result defines the Color3 where to store the HSV values
  5712. */
  5713. toHSVToRef(result: Color3): void;
  5714. /**
  5715. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5716. * @param convertedColor defines the Color3 object where to store the linear space version
  5717. * @returns the unmodified Color3
  5718. */
  5719. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5720. /**
  5721. * Computes a new Color3 converted from the current one to gamma space
  5722. * @returns a new Color3 object
  5723. */
  5724. toGammaSpace(): Color3;
  5725. /**
  5726. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5727. * @param convertedColor defines the Color3 object where to store the gamma space version
  5728. * @returns the unmodified Color3
  5729. */
  5730. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5731. private static _BlackReadOnly;
  5732. /**
  5733. * Convert Hue, saturation and value to a Color3 (RGB)
  5734. * @param hue defines the hue
  5735. * @param saturation defines the saturation
  5736. * @param value defines the value
  5737. * @param result defines the Color3 where to store the RGB values
  5738. */
  5739. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5740. /**
  5741. * Creates a new Color3 from the string containing valid hexadecimal values
  5742. * @param hex defines a string containing valid hexadecimal values
  5743. * @returns a new Color3 object
  5744. */
  5745. static FromHexString(hex: string): Color3;
  5746. /**
  5747. * Creates a new Color3 from the starting index of the given array
  5748. * @param array defines the source array
  5749. * @param offset defines an offset in the source array
  5750. * @returns a new Color3 object
  5751. */
  5752. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5753. /**
  5754. * Creates a new Color3 from the starting index element of the given array
  5755. * @param array defines the source array to read from
  5756. * @param offset defines the offset in the source array
  5757. * @param result defines the target Color3 object
  5758. */
  5759. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5760. /**
  5761. * Creates a new Color3 from integer values (< 256)
  5762. * @param r defines the red component to read from (value between 0 and 255)
  5763. * @param g defines the green component to read from (value between 0 and 255)
  5764. * @param b defines the blue component to read from (value between 0 and 255)
  5765. * @returns a new Color3 object
  5766. */
  5767. static FromInts(r: number, g: number, b: number): Color3;
  5768. /**
  5769. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5770. * @param start defines the start Color3 value
  5771. * @param end defines the end Color3 value
  5772. * @param amount defines the gradient value between start and end
  5773. * @returns a new Color3 object
  5774. */
  5775. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5776. /**
  5777. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5778. * @param left defines the start value
  5779. * @param right defines the end value
  5780. * @param amount defines the gradient factor
  5781. * @param result defines the Color3 object where to store the result
  5782. */
  5783. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5784. /**
  5785. * Returns a Color3 value containing a red color
  5786. * @returns a new Color3 object
  5787. */
  5788. static Red(): Color3;
  5789. /**
  5790. * Returns a Color3 value containing a green color
  5791. * @returns a new Color3 object
  5792. */
  5793. static Green(): Color3;
  5794. /**
  5795. * Returns a Color3 value containing a blue color
  5796. * @returns a new Color3 object
  5797. */
  5798. static Blue(): Color3;
  5799. /**
  5800. * Returns a Color3 value containing a black color
  5801. * @returns a new Color3 object
  5802. */
  5803. static Black(): Color3;
  5804. /**
  5805. * Gets a Color3 value containing a black color that must not be updated
  5806. */
  5807. static get BlackReadOnly(): DeepImmutable<Color3>;
  5808. /**
  5809. * Returns a Color3 value containing a white color
  5810. * @returns a new Color3 object
  5811. */
  5812. static White(): Color3;
  5813. /**
  5814. * Returns a Color3 value containing a purple color
  5815. * @returns a new Color3 object
  5816. */
  5817. static Purple(): Color3;
  5818. /**
  5819. * Returns a Color3 value containing a magenta color
  5820. * @returns a new Color3 object
  5821. */
  5822. static Magenta(): Color3;
  5823. /**
  5824. * Returns a Color3 value containing a yellow color
  5825. * @returns a new Color3 object
  5826. */
  5827. static Yellow(): Color3;
  5828. /**
  5829. * Returns a Color3 value containing a gray color
  5830. * @returns a new Color3 object
  5831. */
  5832. static Gray(): Color3;
  5833. /**
  5834. * Returns a Color3 value containing a teal color
  5835. * @returns a new Color3 object
  5836. */
  5837. static Teal(): Color3;
  5838. /**
  5839. * Returns a Color3 value containing a random color
  5840. * @returns a new Color3 object
  5841. */
  5842. static Random(): Color3;
  5843. }
  5844. /**
  5845. * Class used to hold a RBGA color
  5846. */
  5847. export class Color4 {
  5848. /**
  5849. * Defines the red component (between 0 and 1, default is 0)
  5850. */
  5851. r: number;
  5852. /**
  5853. * Defines the green component (between 0 and 1, default is 0)
  5854. */
  5855. g: number;
  5856. /**
  5857. * Defines the blue component (between 0 and 1, default is 0)
  5858. */
  5859. b: number;
  5860. /**
  5861. * Defines the alpha component (between 0 and 1, default is 1)
  5862. */
  5863. a: number;
  5864. /**
  5865. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5866. * @param r defines the red component (between 0 and 1, default is 0)
  5867. * @param g defines the green component (between 0 and 1, default is 0)
  5868. * @param b defines the blue component (between 0 and 1, default is 0)
  5869. * @param a defines the alpha component (between 0 and 1, default is 1)
  5870. */
  5871. constructor(
  5872. /**
  5873. * Defines the red component (between 0 and 1, default is 0)
  5874. */
  5875. r?: number,
  5876. /**
  5877. * Defines the green component (between 0 and 1, default is 0)
  5878. */
  5879. g?: number,
  5880. /**
  5881. * Defines the blue component (between 0 and 1, default is 0)
  5882. */
  5883. b?: number,
  5884. /**
  5885. * Defines the alpha component (between 0 and 1, default is 1)
  5886. */
  5887. a?: number);
  5888. /**
  5889. * Adds in place the given Color4 values to the current Color4 object
  5890. * @param right defines the second operand
  5891. * @returns the current updated Color4 object
  5892. */
  5893. addInPlace(right: DeepImmutable<Color4>): Color4;
  5894. /**
  5895. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5896. * @returns the new array
  5897. */
  5898. asArray(): number[];
  5899. /**
  5900. * Stores from the starting index in the given array the Color4 successive values
  5901. * @param array defines the array where to store the r,g,b components
  5902. * @param index defines an optional index in the target array to define where to start storing values
  5903. * @returns the current Color4 object
  5904. */
  5905. toArray(array: number[], index?: number): Color4;
  5906. /**
  5907. * Update the current color with values stored in an array from the starting index of the given array
  5908. * @param array defines the source array
  5909. * @param offset defines an offset in the source array
  5910. * @returns the current Color4 object
  5911. */
  5912. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5913. /**
  5914. * Determines equality between Color4 objects
  5915. * @param otherColor defines the second operand
  5916. * @returns true if the rgba values are equal to the given ones
  5917. */
  5918. equals(otherColor: DeepImmutable<Color4>): boolean;
  5919. /**
  5920. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5921. * @param right defines the second operand
  5922. * @returns a new Color4 object
  5923. */
  5924. add(right: DeepImmutable<Color4>): Color4;
  5925. /**
  5926. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5927. * @param right defines the second operand
  5928. * @returns a new Color4 object
  5929. */
  5930. subtract(right: DeepImmutable<Color4>): Color4;
  5931. /**
  5932. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5933. * @param right defines the second operand
  5934. * @param result defines the Color4 object where to store the result
  5935. * @returns the current Color4 object
  5936. */
  5937. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5938. /**
  5939. * Creates a new Color4 with the current Color4 values multiplied by scale
  5940. * @param scale defines the scaling factor to apply
  5941. * @returns a new Color4 object
  5942. */
  5943. scale(scale: number): Color4;
  5944. /**
  5945. * Multiplies the current Color4 values by scale and stores the result in "result"
  5946. * @param scale defines the scaling factor to apply
  5947. * @param result defines the Color4 object where to store the result
  5948. * @returns the current unmodified Color4
  5949. */
  5950. scaleToRef(scale: number, result: Color4): Color4;
  5951. /**
  5952. * Scale the current Color4 values by a factor and add the result to a given Color4
  5953. * @param scale defines the scale factor
  5954. * @param result defines the Color4 object where to store the result
  5955. * @returns the unmodified current Color4
  5956. */
  5957. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5958. /**
  5959. * Clamps the rgb values by the min and max values and stores the result into "result"
  5960. * @param min defines minimum clamping value (default is 0)
  5961. * @param max defines maximum clamping value (default is 1)
  5962. * @param result defines color to store the result into.
  5963. * @returns the cuurent Color4
  5964. */
  5965. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5966. /**
  5967. * Multipy an Color4 value by another and return a new Color4 object
  5968. * @param color defines the Color4 value to multiply by
  5969. * @returns a new Color4 object
  5970. */
  5971. multiply(color: Color4): Color4;
  5972. /**
  5973. * Multipy a Color4 value by another and push the result in a reference value
  5974. * @param color defines the Color4 value to multiply by
  5975. * @param result defines the Color4 to fill the result in
  5976. * @returns the result Color4
  5977. */
  5978. multiplyToRef(color: Color4, result: Color4): Color4;
  5979. /**
  5980. * Creates a string with the Color4 current values
  5981. * @returns the string representation of the Color4 object
  5982. */
  5983. toString(): string;
  5984. /**
  5985. * Returns the string "Color4"
  5986. * @returns "Color4"
  5987. */
  5988. getClassName(): string;
  5989. /**
  5990. * Compute the Color4 hash code
  5991. * @returns an unique number that can be used to hash Color4 objects
  5992. */
  5993. getHashCode(): number;
  5994. /**
  5995. * Creates a new Color4 copied from the current one
  5996. * @returns a new Color4 object
  5997. */
  5998. clone(): Color4;
  5999. /**
  6000. * Copies the given Color4 values into the current one
  6001. * @param source defines the source Color4 object
  6002. * @returns the current updated Color4 object
  6003. */
  6004. copyFrom(source: Color4): Color4;
  6005. /**
  6006. * Copies the given float values into the current one
  6007. * @param r defines the red component to read from
  6008. * @param g defines the green component to read from
  6009. * @param b defines the blue component to read from
  6010. * @param a defines the alpha component to read from
  6011. * @returns the current updated Color4 object
  6012. */
  6013. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6014. /**
  6015. * Copies the given float values into the current one
  6016. * @param r defines the red component to read from
  6017. * @param g defines the green component to read from
  6018. * @param b defines the blue component to read from
  6019. * @param a defines the alpha component to read from
  6020. * @returns the current updated Color4 object
  6021. */
  6022. set(r: number, g: number, b: number, a: number): Color4;
  6023. /**
  6024. * Compute the Color4 hexadecimal code as a string
  6025. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6026. * @returns a string containing the hexadecimal representation of the Color4 object
  6027. */
  6028. toHexString(returnAsColor3?: boolean): string;
  6029. /**
  6030. * Computes a new Color4 converted from the current one to linear space
  6031. * @returns a new Color4 object
  6032. */
  6033. toLinearSpace(): Color4;
  6034. /**
  6035. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6036. * @param convertedColor defines the Color4 object where to store the linear space version
  6037. * @returns the unmodified Color4
  6038. */
  6039. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6040. /**
  6041. * Computes a new Color4 converted from the current one to gamma space
  6042. * @returns a new Color4 object
  6043. */
  6044. toGammaSpace(): Color4;
  6045. /**
  6046. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6047. * @param convertedColor defines the Color4 object where to store the gamma space version
  6048. * @returns the unmodified Color4
  6049. */
  6050. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6051. /**
  6052. * Creates a new Color4 from the string containing valid hexadecimal values
  6053. * @param hex defines a string containing valid hexadecimal values
  6054. * @returns a new Color4 object
  6055. */
  6056. static FromHexString(hex: string): Color4;
  6057. /**
  6058. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6059. * @param left defines the start value
  6060. * @param right defines the end value
  6061. * @param amount defines the gradient factor
  6062. * @returns a new Color4 object
  6063. */
  6064. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6065. /**
  6066. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6067. * @param left defines the start value
  6068. * @param right defines the end value
  6069. * @param amount defines the gradient factor
  6070. * @param result defines the Color4 object where to store data
  6071. */
  6072. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6073. /**
  6074. * Creates a new Color4 from a Color3 and an alpha value
  6075. * @param color3 defines the source Color3 to read from
  6076. * @param alpha defines the alpha component (1.0 by default)
  6077. * @returns a new Color4 object
  6078. */
  6079. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6080. /**
  6081. * Creates a new Color4 from the starting index element of the given array
  6082. * @param array defines the source array to read from
  6083. * @param offset defines the offset in the source array
  6084. * @returns a new Color4 object
  6085. */
  6086. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6087. /**
  6088. * Creates a new Color4 from the starting index element of the given array
  6089. * @param array defines the source array to read from
  6090. * @param offset defines the offset in the source array
  6091. * @param result defines the target Color4 object
  6092. */
  6093. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6094. /**
  6095. * Creates a new Color3 from integer values (< 256)
  6096. * @param r defines the red component to read from (value between 0 and 255)
  6097. * @param g defines the green component to read from (value between 0 and 255)
  6098. * @param b defines the blue component to read from (value between 0 and 255)
  6099. * @param a defines the alpha component to read from (value between 0 and 255)
  6100. * @returns a new Color3 object
  6101. */
  6102. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6103. /**
  6104. * Check the content of a given array and convert it to an array containing RGBA data
  6105. * If the original array was already containing count * 4 values then it is returned directly
  6106. * @param colors defines the array to check
  6107. * @param count defines the number of RGBA data to expect
  6108. * @returns an array containing count * 4 values (RGBA)
  6109. */
  6110. static CheckColors4(colors: number[], count: number): number[];
  6111. }
  6112. /**
  6113. * @hidden
  6114. */
  6115. export class TmpColors {
  6116. static Color3: Color3[];
  6117. static Color4: Color4[];
  6118. }
  6119. }
  6120. declare module BABYLON {
  6121. /**
  6122. * Defines an interface which represents an animation key frame
  6123. */
  6124. export interface IAnimationKey {
  6125. /**
  6126. * Frame of the key frame
  6127. */
  6128. frame: number;
  6129. /**
  6130. * Value at the specifies key frame
  6131. */
  6132. value: any;
  6133. /**
  6134. * The input tangent for the cubic hermite spline
  6135. */
  6136. inTangent?: any;
  6137. /**
  6138. * The output tangent for the cubic hermite spline
  6139. */
  6140. outTangent?: any;
  6141. /**
  6142. * The animation interpolation type
  6143. */
  6144. interpolation?: AnimationKeyInterpolation;
  6145. }
  6146. /**
  6147. * Enum for the animation key frame interpolation type
  6148. */
  6149. export enum AnimationKeyInterpolation {
  6150. /**
  6151. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6152. */
  6153. STEP = 1
  6154. }
  6155. }
  6156. declare module BABYLON {
  6157. /**
  6158. * Represents the range of an animation
  6159. */
  6160. export class AnimationRange {
  6161. /**The name of the animation range**/
  6162. name: string;
  6163. /**The starting frame of the animation */
  6164. from: number;
  6165. /**The ending frame of the animation*/
  6166. to: number;
  6167. /**
  6168. * Initializes the range of an animation
  6169. * @param name The name of the animation range
  6170. * @param from The starting frame of the animation
  6171. * @param to The ending frame of the animation
  6172. */
  6173. constructor(
  6174. /**The name of the animation range**/
  6175. name: string,
  6176. /**The starting frame of the animation */
  6177. from: number,
  6178. /**The ending frame of the animation*/
  6179. to: number);
  6180. /**
  6181. * Makes a copy of the animation range
  6182. * @returns A copy of the animation range
  6183. */
  6184. clone(): AnimationRange;
  6185. }
  6186. }
  6187. declare module BABYLON {
  6188. /**
  6189. * Composed of a frame, and an action function
  6190. */
  6191. export class AnimationEvent {
  6192. /** The frame for which the event is triggered **/
  6193. frame: number;
  6194. /** The event to perform when triggered **/
  6195. action: (currentFrame: number) => void;
  6196. /** Specifies if the event should be triggered only once**/
  6197. onlyOnce?: boolean | undefined;
  6198. /**
  6199. * Specifies if the animation event is done
  6200. */
  6201. isDone: boolean;
  6202. /**
  6203. * Initializes the animation event
  6204. * @param frame The frame for which the event is triggered
  6205. * @param action The event to perform when triggered
  6206. * @param onlyOnce Specifies if the event should be triggered only once
  6207. */
  6208. constructor(
  6209. /** The frame for which the event is triggered **/
  6210. frame: number,
  6211. /** The event to perform when triggered **/
  6212. action: (currentFrame: number) => void,
  6213. /** Specifies if the event should be triggered only once**/
  6214. onlyOnce?: boolean | undefined);
  6215. /** @hidden */
  6216. _clone(): AnimationEvent;
  6217. }
  6218. }
  6219. declare module BABYLON {
  6220. /**
  6221. * Interface used to define a behavior
  6222. */
  6223. export interface Behavior<T> {
  6224. /** gets or sets behavior's name */
  6225. name: string;
  6226. /**
  6227. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6228. */
  6229. init(): void;
  6230. /**
  6231. * Called when the behavior is attached to a target
  6232. * @param target defines the target where the behavior is attached to
  6233. */
  6234. attach(target: T): void;
  6235. /**
  6236. * Called when the behavior is detached from its target
  6237. */
  6238. detach(): void;
  6239. }
  6240. /**
  6241. * Interface implemented by classes supporting behaviors
  6242. */
  6243. export interface IBehaviorAware<T> {
  6244. /**
  6245. * Attach a behavior
  6246. * @param behavior defines the behavior to attach
  6247. * @returns the current host
  6248. */
  6249. addBehavior(behavior: Behavior<T>): T;
  6250. /**
  6251. * Remove a behavior from the current object
  6252. * @param behavior defines the behavior to detach
  6253. * @returns the current host
  6254. */
  6255. removeBehavior(behavior: Behavior<T>): T;
  6256. /**
  6257. * Gets a behavior using its name to search
  6258. * @param name defines the name to search
  6259. * @returns the behavior or null if not found
  6260. */
  6261. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6262. }
  6263. }
  6264. declare module BABYLON {
  6265. /**
  6266. * Defines an array and its length.
  6267. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6268. */
  6269. export interface ISmartArrayLike<T> {
  6270. /**
  6271. * The data of the array.
  6272. */
  6273. data: Array<T>;
  6274. /**
  6275. * The active length of the array.
  6276. */
  6277. length: number;
  6278. }
  6279. /**
  6280. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6281. */
  6282. export class SmartArray<T> implements ISmartArrayLike<T> {
  6283. /**
  6284. * The full set of data from the array.
  6285. */
  6286. data: Array<T>;
  6287. /**
  6288. * The active length of the array.
  6289. */
  6290. length: number;
  6291. protected _id: number;
  6292. /**
  6293. * Instantiates a Smart Array.
  6294. * @param capacity defines the default capacity of the array.
  6295. */
  6296. constructor(capacity: number);
  6297. /**
  6298. * Pushes a value at the end of the active data.
  6299. * @param value defines the object to push in the array.
  6300. */
  6301. push(value: T): void;
  6302. /**
  6303. * Iterates over the active data and apply the lambda to them.
  6304. * @param func defines the action to apply on each value.
  6305. */
  6306. forEach(func: (content: T) => void): void;
  6307. /**
  6308. * Sorts the full sets of data.
  6309. * @param compareFn defines the comparison function to apply.
  6310. */
  6311. sort(compareFn: (a: T, b: T) => number): void;
  6312. /**
  6313. * Resets the active data to an empty array.
  6314. */
  6315. reset(): void;
  6316. /**
  6317. * Releases all the data from the array as well as the array.
  6318. */
  6319. dispose(): void;
  6320. /**
  6321. * Concats the active data with a given array.
  6322. * @param array defines the data to concatenate with.
  6323. */
  6324. concat(array: any): void;
  6325. /**
  6326. * Returns the position of a value in the active data.
  6327. * @param value defines the value to find the index for
  6328. * @returns the index if found in the active data otherwise -1
  6329. */
  6330. indexOf(value: T): number;
  6331. /**
  6332. * Returns whether an element is part of the active data.
  6333. * @param value defines the value to look for
  6334. * @returns true if found in the active data otherwise false
  6335. */
  6336. contains(value: T): boolean;
  6337. private static _GlobalId;
  6338. }
  6339. /**
  6340. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6341. * The data in this array can only be present once
  6342. */
  6343. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6344. private _duplicateId;
  6345. /**
  6346. * Pushes a value at the end of the active data.
  6347. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6348. * @param value defines the object to push in the array.
  6349. */
  6350. push(value: T): void;
  6351. /**
  6352. * Pushes a value at the end of the active data.
  6353. * If the data is already present, it won t be added again
  6354. * @param value defines the object to push in the array.
  6355. * @returns true if added false if it was already present
  6356. */
  6357. pushNoDuplicate(value: T): boolean;
  6358. /**
  6359. * Resets the active data to an empty array.
  6360. */
  6361. reset(): void;
  6362. /**
  6363. * Concats the active data with a given array.
  6364. * This ensures no dupplicate will be present in the result.
  6365. * @param array defines the data to concatenate with.
  6366. */
  6367. concatWithNoDuplicate(array: any): void;
  6368. }
  6369. }
  6370. declare module BABYLON {
  6371. /**
  6372. * @ignore
  6373. * This is a list of all the different input types that are available in the application.
  6374. * Fo instance: ArcRotateCameraGamepadInput...
  6375. */
  6376. export var CameraInputTypes: {};
  6377. /**
  6378. * This is the contract to implement in order to create a new input class.
  6379. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6380. */
  6381. export interface ICameraInput<TCamera extends Camera> {
  6382. /**
  6383. * Defines the camera the input is attached to.
  6384. */
  6385. camera: Nullable<TCamera>;
  6386. /**
  6387. * Gets the class name of the current intput.
  6388. * @returns the class name
  6389. */
  6390. getClassName(): string;
  6391. /**
  6392. * Get the friendly name associated with the input class.
  6393. * @returns the input friendly name
  6394. */
  6395. getSimpleName(): string;
  6396. /**
  6397. * Attach the input controls to a specific dom element to get the input from.
  6398. * @param element Defines the element the controls should be listened from
  6399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6400. */
  6401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6402. /**
  6403. * Detach the current controls from the specified dom element.
  6404. * @param element Defines the element to stop listening the inputs from
  6405. */
  6406. detachControl(element: Nullable<HTMLElement>): void;
  6407. /**
  6408. * Update the current camera state depending on the inputs that have been used this frame.
  6409. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6410. */
  6411. checkInputs?: () => void;
  6412. }
  6413. /**
  6414. * Represents a map of input types to input instance or input index to input instance.
  6415. */
  6416. export interface CameraInputsMap<TCamera extends Camera> {
  6417. /**
  6418. * Accessor to the input by input type.
  6419. */
  6420. [name: string]: ICameraInput<TCamera>;
  6421. /**
  6422. * Accessor to the input by input index.
  6423. */
  6424. [idx: number]: ICameraInput<TCamera>;
  6425. }
  6426. /**
  6427. * This represents the input manager used within a camera.
  6428. * It helps dealing with all the different kind of input attached to a camera.
  6429. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6430. */
  6431. export class CameraInputsManager<TCamera extends Camera> {
  6432. /**
  6433. * Defines the list of inputs attahed to the camera.
  6434. */
  6435. attached: CameraInputsMap<TCamera>;
  6436. /**
  6437. * Defines the dom element the camera is collecting inputs from.
  6438. * This is null if the controls have not been attached.
  6439. */
  6440. attachedElement: Nullable<HTMLElement>;
  6441. /**
  6442. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6443. */
  6444. noPreventDefault: boolean;
  6445. /**
  6446. * Defined the camera the input manager belongs to.
  6447. */
  6448. camera: TCamera;
  6449. /**
  6450. * Update the current camera state depending on the inputs that have been used this frame.
  6451. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6452. */
  6453. checkInputs: () => void;
  6454. /**
  6455. * Instantiate a new Camera Input Manager.
  6456. * @param camera Defines the camera the input manager blongs to
  6457. */
  6458. constructor(camera: TCamera);
  6459. /**
  6460. * Add an input method to a camera
  6461. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6462. * @param input camera input method
  6463. */
  6464. add(input: ICameraInput<TCamera>): void;
  6465. /**
  6466. * Remove a specific input method from a camera
  6467. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6468. * @param inputToRemove camera input method
  6469. */
  6470. remove(inputToRemove: ICameraInput<TCamera>): void;
  6471. /**
  6472. * Remove a specific input type from a camera
  6473. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6474. * @param inputType the type of the input to remove
  6475. */
  6476. removeByType(inputType: string): void;
  6477. private _addCheckInputs;
  6478. /**
  6479. * Attach the input controls to the currently attached dom element to listen the events from.
  6480. * @param input Defines the input to attach
  6481. */
  6482. attachInput(input: ICameraInput<TCamera>): void;
  6483. /**
  6484. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6485. * @param element Defines the dom element to collect the events from
  6486. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6487. */
  6488. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6489. /**
  6490. * Detach the current manager inputs controls from a specific dom element.
  6491. * @param element Defines the dom element to collect the events from
  6492. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6493. */
  6494. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6495. /**
  6496. * Rebuild the dynamic inputCheck function from the current list of
  6497. * defined inputs in the manager.
  6498. */
  6499. rebuildInputCheck(): void;
  6500. /**
  6501. * Remove all attached input methods from a camera
  6502. */
  6503. clear(): void;
  6504. /**
  6505. * Serialize the current input manager attached to a camera.
  6506. * This ensures than once parsed,
  6507. * the input associated to the camera will be identical to the current ones
  6508. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6509. */
  6510. serialize(serializedCamera: any): void;
  6511. /**
  6512. * Parses an input manager serialized JSON to restore the previous list of inputs
  6513. * and states associated to a camera.
  6514. * @param parsedCamera Defines the JSON to parse
  6515. */
  6516. parse(parsedCamera: any): void;
  6517. }
  6518. }
  6519. declare module BABYLON {
  6520. /**
  6521. * Class used to store data that will be store in GPU memory
  6522. */
  6523. export class Buffer {
  6524. private _engine;
  6525. private _buffer;
  6526. /** @hidden */
  6527. _data: Nullable<DataArray>;
  6528. private _updatable;
  6529. private _instanced;
  6530. private _divisor;
  6531. /**
  6532. * Gets the byte stride.
  6533. */
  6534. readonly byteStride: number;
  6535. /**
  6536. * Constructor
  6537. * @param engine the engine
  6538. * @param data the data to use for this buffer
  6539. * @param updatable whether the data is updatable
  6540. * @param stride the stride (optional)
  6541. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6542. * @param instanced whether the buffer is instanced (optional)
  6543. * @param useBytes set to true if the stride in in bytes (optional)
  6544. * @param divisor sets an optional divisor for instances (1 by default)
  6545. */
  6546. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6547. /**
  6548. * Create a new VertexBuffer based on the current buffer
  6549. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6550. * @param offset defines offset in the buffer (0 by default)
  6551. * @param size defines the size in floats of attributes (position is 3 for instance)
  6552. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6553. * @param instanced defines if the vertex buffer contains indexed data
  6554. * @param useBytes defines if the offset and stride are in bytes *
  6555. * @param divisor sets an optional divisor for instances (1 by default)
  6556. * @returns the new vertex buffer
  6557. */
  6558. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6559. /**
  6560. * Gets a boolean indicating if the Buffer is updatable?
  6561. * @returns true if the buffer is updatable
  6562. */
  6563. isUpdatable(): boolean;
  6564. /**
  6565. * Gets current buffer's data
  6566. * @returns a DataArray or null
  6567. */
  6568. getData(): Nullable<DataArray>;
  6569. /**
  6570. * Gets underlying native buffer
  6571. * @returns underlying native buffer
  6572. */
  6573. getBuffer(): Nullable<DataBuffer>;
  6574. /**
  6575. * Gets the stride in float32 units (i.e. byte stride / 4).
  6576. * May not be an integer if the byte stride is not divisible by 4.
  6577. * @returns the stride in float32 units
  6578. * @deprecated Please use byteStride instead.
  6579. */
  6580. getStrideSize(): number;
  6581. /**
  6582. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6583. * @param data defines the data to store
  6584. */
  6585. create(data?: Nullable<DataArray>): void;
  6586. /** @hidden */
  6587. _rebuild(): void;
  6588. /**
  6589. * Update current buffer data
  6590. * @param data defines the data to store
  6591. */
  6592. update(data: DataArray): void;
  6593. /**
  6594. * Updates the data directly.
  6595. * @param data the new data
  6596. * @param offset the new offset
  6597. * @param vertexCount the vertex count (optional)
  6598. * @param useBytes set to true if the offset is in bytes
  6599. */
  6600. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6601. /**
  6602. * Release all resources
  6603. */
  6604. dispose(): void;
  6605. }
  6606. /**
  6607. * Specialized buffer used to store vertex data
  6608. */
  6609. export class VertexBuffer {
  6610. /** @hidden */
  6611. _buffer: Buffer;
  6612. private _kind;
  6613. private _size;
  6614. private _ownsBuffer;
  6615. private _instanced;
  6616. private _instanceDivisor;
  6617. /**
  6618. * The byte type.
  6619. */
  6620. static readonly BYTE: number;
  6621. /**
  6622. * The unsigned byte type.
  6623. */
  6624. static readonly UNSIGNED_BYTE: number;
  6625. /**
  6626. * The short type.
  6627. */
  6628. static readonly SHORT: number;
  6629. /**
  6630. * The unsigned short type.
  6631. */
  6632. static readonly UNSIGNED_SHORT: number;
  6633. /**
  6634. * The integer type.
  6635. */
  6636. static readonly INT: number;
  6637. /**
  6638. * The unsigned integer type.
  6639. */
  6640. static readonly UNSIGNED_INT: number;
  6641. /**
  6642. * The float type.
  6643. */
  6644. static readonly FLOAT: number;
  6645. /**
  6646. * Gets or sets the instance divisor when in instanced mode
  6647. */
  6648. get instanceDivisor(): number;
  6649. set instanceDivisor(value: number);
  6650. /**
  6651. * Gets the byte stride.
  6652. */
  6653. readonly byteStride: number;
  6654. /**
  6655. * Gets the byte offset.
  6656. */
  6657. readonly byteOffset: number;
  6658. /**
  6659. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6660. */
  6661. readonly normalized: boolean;
  6662. /**
  6663. * Gets the data type of each component in the array.
  6664. */
  6665. readonly type: number;
  6666. /**
  6667. * Constructor
  6668. * @param engine the engine
  6669. * @param data the data to use for this vertex buffer
  6670. * @param kind the vertex buffer kind
  6671. * @param updatable whether the data is updatable
  6672. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6673. * @param stride the stride (optional)
  6674. * @param instanced whether the buffer is instanced (optional)
  6675. * @param offset the offset of the data (optional)
  6676. * @param size the number of components (optional)
  6677. * @param type the type of the component (optional)
  6678. * @param normalized whether the data contains normalized data (optional)
  6679. * @param useBytes set to true if stride and offset are in bytes (optional)
  6680. * @param divisor defines the instance divisor to use (1 by default)
  6681. */
  6682. 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);
  6683. /** @hidden */
  6684. _rebuild(): void;
  6685. /**
  6686. * Returns the kind of the VertexBuffer (string)
  6687. * @returns a string
  6688. */
  6689. getKind(): string;
  6690. /**
  6691. * Gets a boolean indicating if the VertexBuffer is updatable?
  6692. * @returns true if the buffer is updatable
  6693. */
  6694. isUpdatable(): boolean;
  6695. /**
  6696. * Gets current buffer's data
  6697. * @returns a DataArray or null
  6698. */
  6699. getData(): Nullable<DataArray>;
  6700. /**
  6701. * Gets underlying native buffer
  6702. * @returns underlying native buffer
  6703. */
  6704. getBuffer(): Nullable<DataBuffer>;
  6705. /**
  6706. * Gets the stride in float32 units (i.e. byte stride / 4).
  6707. * May not be an integer if the byte stride is not divisible by 4.
  6708. * @returns the stride in float32 units
  6709. * @deprecated Please use byteStride instead.
  6710. */
  6711. getStrideSize(): number;
  6712. /**
  6713. * Returns the offset as a multiple of the type byte length.
  6714. * @returns the offset in bytes
  6715. * @deprecated Please use byteOffset instead.
  6716. */
  6717. getOffset(): number;
  6718. /**
  6719. * Returns the number of components per vertex attribute (integer)
  6720. * @returns the size in float
  6721. */
  6722. getSize(): number;
  6723. /**
  6724. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6725. * @returns true if this buffer is instanced
  6726. */
  6727. getIsInstanced(): boolean;
  6728. /**
  6729. * Returns the instancing divisor, zero for non-instanced (integer).
  6730. * @returns a number
  6731. */
  6732. getInstanceDivisor(): number;
  6733. /**
  6734. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6735. * @param data defines the data to store
  6736. */
  6737. create(data?: DataArray): void;
  6738. /**
  6739. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6740. * This function will create a new buffer if the current one is not updatable
  6741. * @param data defines the data to store
  6742. */
  6743. update(data: DataArray): void;
  6744. /**
  6745. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6746. * Returns the directly updated WebGLBuffer.
  6747. * @param data the new data
  6748. * @param offset the new offset
  6749. * @param useBytes set to true if the offset is in bytes
  6750. */
  6751. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6752. /**
  6753. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6754. */
  6755. dispose(): void;
  6756. /**
  6757. * Enumerates each value of this vertex buffer as numbers.
  6758. * @param count the number of values to enumerate
  6759. * @param callback the callback function called for each value
  6760. */
  6761. forEach(count: number, callback: (value: number, index: number) => void): void;
  6762. /**
  6763. * Positions
  6764. */
  6765. static readonly PositionKind: string;
  6766. /**
  6767. * Normals
  6768. */
  6769. static readonly NormalKind: string;
  6770. /**
  6771. * Tangents
  6772. */
  6773. static readonly TangentKind: string;
  6774. /**
  6775. * Texture coordinates
  6776. */
  6777. static readonly UVKind: string;
  6778. /**
  6779. * Texture coordinates 2
  6780. */
  6781. static readonly UV2Kind: string;
  6782. /**
  6783. * Texture coordinates 3
  6784. */
  6785. static readonly UV3Kind: string;
  6786. /**
  6787. * Texture coordinates 4
  6788. */
  6789. static readonly UV4Kind: string;
  6790. /**
  6791. * Texture coordinates 5
  6792. */
  6793. static readonly UV5Kind: string;
  6794. /**
  6795. * Texture coordinates 6
  6796. */
  6797. static readonly UV6Kind: string;
  6798. /**
  6799. * Colors
  6800. */
  6801. static readonly ColorKind: string;
  6802. /**
  6803. * Matrix indices (for bones)
  6804. */
  6805. static readonly MatricesIndicesKind: string;
  6806. /**
  6807. * Matrix weights (for bones)
  6808. */
  6809. static readonly MatricesWeightsKind: string;
  6810. /**
  6811. * Additional matrix indices (for bones)
  6812. */
  6813. static readonly MatricesIndicesExtraKind: string;
  6814. /**
  6815. * Additional matrix weights (for bones)
  6816. */
  6817. static readonly MatricesWeightsExtraKind: string;
  6818. /**
  6819. * Deduces the stride given a kind.
  6820. * @param kind The kind string to deduce
  6821. * @returns The deduced stride
  6822. */
  6823. static DeduceStride(kind: string): number;
  6824. /**
  6825. * Gets the byte length of the given type.
  6826. * @param type the type
  6827. * @returns the number of bytes
  6828. */
  6829. static GetTypeByteLength(type: number): number;
  6830. /**
  6831. * Enumerates each value of the given parameters as numbers.
  6832. * @param data the data to enumerate
  6833. * @param byteOffset the byte offset of the data
  6834. * @param byteStride the byte stride of the data
  6835. * @param componentCount the number of components per element
  6836. * @param componentType the type of the component
  6837. * @param count the number of values to enumerate
  6838. * @param normalized whether the data is normalized
  6839. * @param callback the callback function called for each value
  6840. */
  6841. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6842. private static _GetFloatValue;
  6843. }
  6844. }
  6845. declare module BABYLON {
  6846. /**
  6847. * The options Interface for creating a Capsule Mesh
  6848. */
  6849. export interface ICreateCapsuleOptions {
  6850. /** The Orientation of the capsule. Default : Vector3.Up() */
  6851. orientation?: Vector3;
  6852. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6853. subdivisions: number;
  6854. /** Number of cylindrical segments on the capsule. */
  6855. tessellation: number;
  6856. /** Height or Length of the capsule. */
  6857. height: number;
  6858. /** Radius of the capsule. */
  6859. radius: number;
  6860. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6861. capSubdivisions: number;
  6862. /** Overwrite for the top radius. */
  6863. radiusTop?: number;
  6864. /** Overwrite for the bottom radius. */
  6865. radiusBottom?: number;
  6866. /** Overwrite for the top capSubdivisions. */
  6867. topCapSubdivisions?: number;
  6868. /** Overwrite for the bottom capSubdivisions. */
  6869. bottomCapSubdivisions?: number;
  6870. }
  6871. /**
  6872. * Class containing static functions to help procedurally build meshes
  6873. */
  6874. export class CapsuleBuilder {
  6875. /**
  6876. * Creates a capsule or a pill mesh
  6877. * @param name defines the name of the mesh
  6878. * @param options The constructors options.
  6879. * @param scene The scene the mesh is scoped to.
  6880. * @returns Capsule Mesh
  6881. */
  6882. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6883. }
  6884. }
  6885. declare module BABYLON {
  6886. /**
  6887. * @hidden
  6888. */
  6889. export class IntersectionInfo {
  6890. bu: Nullable<number>;
  6891. bv: Nullable<number>;
  6892. distance: number;
  6893. faceId: number;
  6894. subMeshId: number;
  6895. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6896. }
  6897. }
  6898. declare module BABYLON {
  6899. /**
  6900. * Class used to store bounding sphere information
  6901. */
  6902. export class BoundingSphere {
  6903. /**
  6904. * Gets the center of the bounding sphere in local space
  6905. */
  6906. readonly center: Vector3;
  6907. /**
  6908. * Radius of the bounding sphere in local space
  6909. */
  6910. radius: number;
  6911. /**
  6912. * Gets the center of the bounding sphere in world space
  6913. */
  6914. readonly centerWorld: Vector3;
  6915. /**
  6916. * Radius of the bounding sphere in world space
  6917. */
  6918. radiusWorld: number;
  6919. /**
  6920. * Gets the minimum vector in local space
  6921. */
  6922. readonly minimum: Vector3;
  6923. /**
  6924. * Gets the maximum vector in local space
  6925. */
  6926. readonly maximum: Vector3;
  6927. private _worldMatrix;
  6928. private static readonly TmpVector3;
  6929. /**
  6930. * Creates a new bounding sphere
  6931. * @param min defines the minimum vector (in local space)
  6932. * @param max defines the maximum vector (in local space)
  6933. * @param worldMatrix defines the new world matrix
  6934. */
  6935. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6936. /**
  6937. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6938. * @param min defines the new minimum vector (in local space)
  6939. * @param max defines the new maximum vector (in local space)
  6940. * @param worldMatrix defines the new world matrix
  6941. */
  6942. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6943. /**
  6944. * Scale the current bounding sphere by applying a scale factor
  6945. * @param factor defines the scale factor to apply
  6946. * @returns the current bounding box
  6947. */
  6948. scale(factor: number): BoundingSphere;
  6949. /**
  6950. * Gets the world matrix of the bounding box
  6951. * @returns a matrix
  6952. */
  6953. getWorldMatrix(): DeepImmutable<Matrix>;
  6954. /** @hidden */
  6955. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6956. /**
  6957. * Tests if the bounding sphere is intersecting the frustum planes
  6958. * @param frustumPlanes defines the frustum planes to test
  6959. * @returns true if there is an intersection
  6960. */
  6961. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6962. /**
  6963. * Tests if the bounding sphere center is in between the frustum planes.
  6964. * Used for optimistic fast inclusion.
  6965. * @param frustumPlanes defines the frustum planes to test
  6966. * @returns true if the sphere center is in between the frustum planes
  6967. */
  6968. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6969. /**
  6970. * Tests if a point is inside the bounding sphere
  6971. * @param point defines the point to test
  6972. * @returns true if the point is inside the bounding sphere
  6973. */
  6974. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6975. /**
  6976. * Checks if two sphere intersct
  6977. * @param sphere0 sphere 0
  6978. * @param sphere1 sphere 1
  6979. * @returns true if the speres intersect
  6980. */
  6981. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6982. }
  6983. }
  6984. declare module BABYLON {
  6985. /**
  6986. * Class used to store bounding box information
  6987. */
  6988. export class BoundingBox implements ICullable {
  6989. /**
  6990. * Gets the 8 vectors representing the bounding box in local space
  6991. */
  6992. readonly vectors: Vector3[];
  6993. /**
  6994. * Gets the center of the bounding box in local space
  6995. */
  6996. readonly center: Vector3;
  6997. /**
  6998. * Gets the center of the bounding box in world space
  6999. */
  7000. readonly centerWorld: Vector3;
  7001. /**
  7002. * Gets the extend size in local space
  7003. */
  7004. readonly extendSize: Vector3;
  7005. /**
  7006. * Gets the extend size in world space
  7007. */
  7008. readonly extendSizeWorld: Vector3;
  7009. /**
  7010. * Gets the OBB (object bounding box) directions
  7011. */
  7012. readonly directions: Vector3[];
  7013. /**
  7014. * Gets the 8 vectors representing the bounding box in world space
  7015. */
  7016. readonly vectorsWorld: Vector3[];
  7017. /**
  7018. * Gets the minimum vector in world space
  7019. */
  7020. readonly minimumWorld: Vector3;
  7021. /**
  7022. * Gets the maximum vector in world space
  7023. */
  7024. readonly maximumWorld: Vector3;
  7025. /**
  7026. * Gets the minimum vector in local space
  7027. */
  7028. readonly minimum: Vector3;
  7029. /**
  7030. * Gets the maximum vector in local space
  7031. */
  7032. readonly maximum: Vector3;
  7033. private _worldMatrix;
  7034. private static readonly TmpVector3;
  7035. /**
  7036. * @hidden
  7037. */
  7038. _tag: number;
  7039. /**
  7040. * Creates a new bounding box
  7041. * @param min defines the minimum vector (in local space)
  7042. * @param max defines the maximum vector (in local space)
  7043. * @param worldMatrix defines the new world matrix
  7044. */
  7045. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7046. /**
  7047. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7048. * @param min defines the new minimum vector (in local space)
  7049. * @param max defines the new maximum vector (in local space)
  7050. * @param worldMatrix defines the new world matrix
  7051. */
  7052. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7053. /**
  7054. * Scale the current bounding box by applying a scale factor
  7055. * @param factor defines the scale factor to apply
  7056. * @returns the current bounding box
  7057. */
  7058. scale(factor: number): BoundingBox;
  7059. /**
  7060. * Gets the world matrix of the bounding box
  7061. * @returns a matrix
  7062. */
  7063. getWorldMatrix(): DeepImmutable<Matrix>;
  7064. /** @hidden */
  7065. _update(world: DeepImmutable<Matrix>): void;
  7066. /**
  7067. * Tests if the bounding box is intersecting the frustum planes
  7068. * @param frustumPlanes defines the frustum planes to test
  7069. * @returns true if there is an intersection
  7070. */
  7071. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7072. /**
  7073. * Tests if the bounding box is entirely inside the frustum planes
  7074. * @param frustumPlanes defines the frustum planes to test
  7075. * @returns true if there is an inclusion
  7076. */
  7077. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7078. /**
  7079. * Tests if a point is inside the bounding box
  7080. * @param point defines the point to test
  7081. * @returns true if the point is inside the bounding box
  7082. */
  7083. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7084. /**
  7085. * Tests if the bounding box intersects with a bounding sphere
  7086. * @param sphere defines the sphere to test
  7087. * @returns true if there is an intersection
  7088. */
  7089. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7090. /**
  7091. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7092. * @param min defines the min vector to use
  7093. * @param max defines the max vector to use
  7094. * @returns true if there is an intersection
  7095. */
  7096. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7097. /**
  7098. * Tests if two bounding boxes are intersections
  7099. * @param box0 defines the first box to test
  7100. * @param box1 defines the second box to test
  7101. * @returns true if there is an intersection
  7102. */
  7103. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7104. /**
  7105. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7106. * @param minPoint defines the minimum vector of the bounding box
  7107. * @param maxPoint defines the maximum vector of the bounding box
  7108. * @param sphereCenter defines the sphere center
  7109. * @param sphereRadius defines the sphere radius
  7110. * @returns true if there is an intersection
  7111. */
  7112. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7113. /**
  7114. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7115. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7116. * @param frustumPlanes defines the frustum planes to test
  7117. * @return true if there is an inclusion
  7118. */
  7119. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7120. /**
  7121. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7122. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7123. * @param frustumPlanes defines the frustum planes to test
  7124. * @return true if there is an intersection
  7125. */
  7126. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7127. }
  7128. }
  7129. declare module BABYLON {
  7130. /** @hidden */
  7131. export class Collider {
  7132. /** Define if a collision was found */
  7133. collisionFound: boolean;
  7134. /**
  7135. * Define last intersection point in local space
  7136. */
  7137. intersectionPoint: Vector3;
  7138. /**
  7139. * Define last collided mesh
  7140. */
  7141. collidedMesh: Nullable<AbstractMesh>;
  7142. private _collisionPoint;
  7143. private _planeIntersectionPoint;
  7144. private _tempVector;
  7145. private _tempVector2;
  7146. private _tempVector3;
  7147. private _tempVector4;
  7148. private _edge;
  7149. private _baseToVertex;
  7150. private _destinationPoint;
  7151. private _slidePlaneNormal;
  7152. private _displacementVector;
  7153. /** @hidden */
  7154. _radius: Vector3;
  7155. /** @hidden */
  7156. _retry: number;
  7157. private _velocity;
  7158. private _basePoint;
  7159. private _epsilon;
  7160. /** @hidden */
  7161. _velocityWorldLength: number;
  7162. /** @hidden */
  7163. _basePointWorld: Vector3;
  7164. private _velocityWorld;
  7165. private _normalizedVelocity;
  7166. /** @hidden */
  7167. _initialVelocity: Vector3;
  7168. /** @hidden */
  7169. _initialPosition: Vector3;
  7170. private _nearestDistance;
  7171. private _collisionMask;
  7172. get collisionMask(): number;
  7173. set collisionMask(mask: number);
  7174. /**
  7175. * Gets the plane normal used to compute the sliding response (in local space)
  7176. */
  7177. get slidePlaneNormal(): Vector3;
  7178. /** @hidden */
  7179. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7180. /** @hidden */
  7181. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7182. /** @hidden */
  7183. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7184. /** @hidden */
  7185. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7186. /** @hidden */
  7187. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7188. /** @hidden */
  7189. _getResponse(pos: Vector3, vel: Vector3): void;
  7190. }
  7191. }
  7192. declare module BABYLON {
  7193. /**
  7194. * Interface for cullable objects
  7195. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7196. */
  7197. export interface ICullable {
  7198. /**
  7199. * Checks if the object or part of the object is in the frustum
  7200. * @param frustumPlanes Camera near/planes
  7201. * @returns true if the object is in frustum otherwise false
  7202. */
  7203. isInFrustum(frustumPlanes: Plane[]): boolean;
  7204. /**
  7205. * Checks if a cullable object (mesh...) is in the camera frustum
  7206. * Unlike isInFrustum this cheks the full bounding box
  7207. * @param frustumPlanes Camera near/planes
  7208. * @returns true if the object is in frustum otherwise false
  7209. */
  7210. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7211. }
  7212. /**
  7213. * Info for a bounding data of a mesh
  7214. */
  7215. export class BoundingInfo implements ICullable {
  7216. /**
  7217. * Bounding box for the mesh
  7218. */
  7219. readonly boundingBox: BoundingBox;
  7220. /**
  7221. * Bounding sphere for the mesh
  7222. */
  7223. readonly boundingSphere: BoundingSphere;
  7224. private _isLocked;
  7225. private static readonly TmpVector3;
  7226. /**
  7227. * Constructs bounding info
  7228. * @param minimum min vector of the bounding box/sphere
  7229. * @param maximum max vector of the bounding box/sphere
  7230. * @param worldMatrix defines the new world matrix
  7231. */
  7232. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7233. /**
  7234. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7235. * @param min defines the new minimum vector (in local space)
  7236. * @param max defines the new maximum vector (in local space)
  7237. * @param worldMatrix defines the new world matrix
  7238. */
  7239. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7240. /**
  7241. * min vector of the bounding box/sphere
  7242. */
  7243. get minimum(): Vector3;
  7244. /**
  7245. * max vector of the bounding box/sphere
  7246. */
  7247. get maximum(): Vector3;
  7248. /**
  7249. * If the info is locked and won't be updated to avoid perf overhead
  7250. */
  7251. get isLocked(): boolean;
  7252. set isLocked(value: boolean);
  7253. /**
  7254. * Updates the bounding sphere and box
  7255. * @param world world matrix to be used to update
  7256. */
  7257. update(world: DeepImmutable<Matrix>): void;
  7258. /**
  7259. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7260. * @param center New center of the bounding info
  7261. * @param extend New extend of the bounding info
  7262. * @returns the current bounding info
  7263. */
  7264. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7265. /**
  7266. * Scale the current bounding info by applying a scale factor
  7267. * @param factor defines the scale factor to apply
  7268. * @returns the current bounding info
  7269. */
  7270. scale(factor: number): BoundingInfo;
  7271. /**
  7272. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7273. * @param frustumPlanes defines the frustum to test
  7274. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7275. * @returns true if the bounding info is in the frustum planes
  7276. */
  7277. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7278. /**
  7279. * Gets the world distance between the min and max points of the bounding box
  7280. */
  7281. get diagonalLength(): number;
  7282. /**
  7283. * Checks if a cullable object (mesh...) is in the camera frustum
  7284. * Unlike isInFrustum this cheks the full bounding box
  7285. * @param frustumPlanes Camera near/planes
  7286. * @returns true if the object is in frustum otherwise false
  7287. */
  7288. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7289. /** @hidden */
  7290. _checkCollision(collider: Collider): boolean;
  7291. /**
  7292. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7293. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7294. * @param point the point to check intersection with
  7295. * @returns if the point intersects
  7296. */
  7297. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7298. /**
  7299. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7300. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7301. * @param boundingInfo the bounding info to check intersection with
  7302. * @param precise if the intersection should be done using OBB
  7303. * @returns if the bounding info intersects
  7304. */
  7305. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7306. }
  7307. }
  7308. declare module BABYLON {
  7309. /**
  7310. * Extracts minimum and maximum values from a list of indexed positions
  7311. * @param positions defines the positions to use
  7312. * @param indices defines the indices to the positions
  7313. * @param indexStart defines the start index
  7314. * @param indexCount defines the end index
  7315. * @param bias defines bias value to add to the result
  7316. * @return minimum and maximum values
  7317. */
  7318. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7319. minimum: Vector3;
  7320. maximum: Vector3;
  7321. };
  7322. /**
  7323. * Extracts minimum and maximum values from a list of positions
  7324. * @param positions defines the positions to use
  7325. * @param start defines the start index in the positions array
  7326. * @param count defines the number of positions to handle
  7327. * @param bias defines bias value to add to the result
  7328. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7329. * @return minimum and maximum values
  7330. */
  7331. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7332. minimum: Vector3;
  7333. maximum: Vector3;
  7334. };
  7335. }
  7336. declare module BABYLON {
  7337. /** @hidden */
  7338. export class WebGLDataBuffer extends DataBuffer {
  7339. private _buffer;
  7340. constructor(resource: WebGLBuffer);
  7341. get underlyingResource(): any;
  7342. }
  7343. }
  7344. declare module BABYLON {
  7345. /** @hidden */
  7346. export class WebGLPipelineContext implements IPipelineContext {
  7347. engine: ThinEngine;
  7348. program: Nullable<WebGLProgram>;
  7349. context?: WebGLRenderingContext;
  7350. vertexShader?: WebGLShader;
  7351. fragmentShader?: WebGLShader;
  7352. isParallelCompiled: boolean;
  7353. onCompiled?: () => void;
  7354. transformFeedback?: WebGLTransformFeedback | null;
  7355. vertexCompilationError: Nullable<string>;
  7356. fragmentCompilationError: Nullable<string>;
  7357. programLinkError: Nullable<string>;
  7358. programValidationError: Nullable<string>;
  7359. get isAsync(): boolean;
  7360. get isReady(): boolean;
  7361. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7362. _getVertexShaderCode(): string | null;
  7363. _getFragmentShaderCode(): string | null;
  7364. }
  7365. }
  7366. declare module BABYLON {
  7367. interface ThinEngine {
  7368. /**
  7369. * Create an uniform buffer
  7370. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7371. * @param elements defines the content of the uniform buffer
  7372. * @returns the webGL uniform buffer
  7373. */
  7374. createUniformBuffer(elements: FloatArray): DataBuffer;
  7375. /**
  7376. * Create a dynamic uniform buffer
  7377. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7378. * @param elements defines the content of the uniform buffer
  7379. * @returns the webGL uniform buffer
  7380. */
  7381. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7382. /**
  7383. * Update an existing uniform buffer
  7384. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7385. * @param uniformBuffer defines the target uniform buffer
  7386. * @param elements defines the content to update
  7387. * @param offset defines the offset in the uniform buffer where update should start
  7388. * @param count defines the size of the data to update
  7389. */
  7390. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7391. /**
  7392. * Bind an uniform buffer to the current webGL context
  7393. * @param buffer defines the buffer to bind
  7394. */
  7395. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7396. /**
  7397. * Bind a buffer to the current webGL context at a given location
  7398. * @param buffer defines the buffer to bind
  7399. * @param location defines the index where to bind the buffer
  7400. */
  7401. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7402. /**
  7403. * Bind a specific block at a given index in a specific shader program
  7404. * @param pipelineContext defines the pipeline context to use
  7405. * @param blockName defines the block name
  7406. * @param index defines the index where to bind the block
  7407. */
  7408. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7409. }
  7410. }
  7411. declare module BABYLON {
  7412. /**
  7413. * Uniform buffer objects.
  7414. *
  7415. * Handles blocks of uniform on the GPU.
  7416. *
  7417. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7418. *
  7419. * For more information, please refer to :
  7420. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7421. */
  7422. export class UniformBuffer {
  7423. private _engine;
  7424. private _buffer;
  7425. private _data;
  7426. private _bufferData;
  7427. private _dynamic?;
  7428. private _uniformLocations;
  7429. private _uniformSizes;
  7430. private _uniformLocationPointer;
  7431. private _needSync;
  7432. private _noUBO;
  7433. private _currentEffect;
  7434. /** @hidden */
  7435. _alreadyBound: boolean;
  7436. private static _MAX_UNIFORM_SIZE;
  7437. private static _tempBuffer;
  7438. /**
  7439. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7440. * This is dynamic to allow compat with webgl 1 and 2.
  7441. * You will need to pass the name of the uniform as well as the value.
  7442. */
  7443. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7444. /**
  7445. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7446. * This is dynamic to allow compat with webgl 1 and 2.
  7447. * You will need to pass the name of the uniform as well as the value.
  7448. */
  7449. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7450. /**
  7451. * Lambda to Update a single float in a uniform buffer.
  7452. * This is dynamic to allow compat with webgl 1 and 2.
  7453. * You will need to pass the name of the uniform as well as the value.
  7454. */
  7455. updateFloat: (name: string, x: number) => void;
  7456. /**
  7457. * Lambda to Update a vec2 of float in a uniform buffer.
  7458. * This is dynamic to allow compat with webgl 1 and 2.
  7459. * You will need to pass the name of the uniform as well as the value.
  7460. */
  7461. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7462. /**
  7463. * Lambda to Update a vec3 of float in a uniform buffer.
  7464. * This is dynamic to allow compat with webgl 1 and 2.
  7465. * You will need to pass the name of the uniform as well as the value.
  7466. */
  7467. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7468. /**
  7469. * Lambda to Update a vec4 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. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7474. /**
  7475. * Lambda to Update a 4x4 Matrix 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. updateMatrix: (name: string, mat: Matrix) => void;
  7480. /**
  7481. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7482. * This is dynamic to allow compat with webgl 1 and 2.
  7483. * You will need to pass the name of the uniform as well as the value.
  7484. */
  7485. updateVector3: (name: string, vector: Vector3) => void;
  7486. /**
  7487. * Lambda to Update vec4 of float from a Vector 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. updateVector4: (name: string, vector: Vector4) => void;
  7492. /**
  7493. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7494. * This is dynamic to allow compat with webgl 1 and 2.
  7495. * You will need to pass the name of the uniform as well as the value.
  7496. */
  7497. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7498. /**
  7499. * Lambda to Update vec4 of float from a Color 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. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7504. /**
  7505. * Instantiates a new Uniform buffer objects.
  7506. *
  7507. * Handles blocks of uniform on the GPU.
  7508. *
  7509. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7510. *
  7511. * For more information, please refer to :
  7512. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7513. * @param engine Define the engine the buffer is associated with
  7514. * @param data Define the data contained in the buffer
  7515. * @param dynamic Define if the buffer is updatable
  7516. */
  7517. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7518. /**
  7519. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7520. * or just falling back on setUniformXXX calls.
  7521. */
  7522. get useUbo(): boolean;
  7523. /**
  7524. * Indicates if the WebGL underlying uniform buffer is in sync
  7525. * with the javascript cache data.
  7526. */
  7527. get isSync(): boolean;
  7528. /**
  7529. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7530. * Also, a dynamic UniformBuffer will disable cache verification and always
  7531. * update the underlying WebGL uniform buffer to the GPU.
  7532. * @returns if Dynamic, otherwise false
  7533. */
  7534. isDynamic(): boolean;
  7535. /**
  7536. * The data cache on JS side.
  7537. * @returns the underlying data as a float array
  7538. */
  7539. getData(): Float32Array;
  7540. /**
  7541. * The underlying WebGL Uniform buffer.
  7542. * @returns the webgl buffer
  7543. */
  7544. getBuffer(): Nullable<DataBuffer>;
  7545. /**
  7546. * std140 layout specifies how to align data within an UBO structure.
  7547. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7548. * for specs.
  7549. */
  7550. private _fillAlignment;
  7551. /**
  7552. * Adds an uniform in the buffer.
  7553. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7554. * for the layout to be correct !
  7555. * @param name Name of the uniform, as used in the uniform block in the shader.
  7556. * @param size Data size, or data directly.
  7557. */
  7558. addUniform(name: string, size: number | number[]): void;
  7559. /**
  7560. * Adds a Matrix 4x4 to the uniform buffer.
  7561. * @param name Name of the uniform, as used in the uniform block in the shader.
  7562. * @param mat A 4x4 matrix.
  7563. */
  7564. addMatrix(name: string, mat: Matrix): void;
  7565. /**
  7566. * Adds a vec2 to the uniform buffer.
  7567. * @param name Name of the uniform, as used in the uniform block in the shader.
  7568. * @param x Define the x component value of the vec2
  7569. * @param y Define the y component value of the vec2
  7570. */
  7571. addFloat2(name: string, x: number, y: number): void;
  7572. /**
  7573. * Adds a vec3 to the uniform buffer.
  7574. * @param name Name of the uniform, as used in the uniform block in the shader.
  7575. * @param x Define the x component value of the vec3
  7576. * @param y Define the y component value of the vec3
  7577. * @param z Define the z component value of the vec3
  7578. */
  7579. addFloat3(name: string, x: number, y: number, z: number): void;
  7580. /**
  7581. * Adds a vec3 to the uniform buffer.
  7582. * @param name Name of the uniform, as used in the uniform block in the shader.
  7583. * @param color Define the vec3 from a Color
  7584. */
  7585. addColor3(name: string, color: Color3): void;
  7586. /**
  7587. * Adds a vec4 to the uniform buffer.
  7588. * @param name Name of the uniform, as used in the uniform block in the shader.
  7589. * @param color Define the rgb components from a Color
  7590. * @param alpha Define the a component of the vec4
  7591. */
  7592. addColor4(name: string, color: Color3, alpha: number): void;
  7593. /**
  7594. * Adds a vec3 to the uniform buffer.
  7595. * @param name Name of the uniform, as used in the uniform block in the shader.
  7596. * @param vector Define the vec3 components from a Vector
  7597. */
  7598. addVector3(name: string, vector: Vector3): void;
  7599. /**
  7600. * Adds a Matrix 3x3 to the uniform buffer.
  7601. * @param name Name of the uniform, as used in the uniform block in the shader.
  7602. */
  7603. addMatrix3x3(name: string): void;
  7604. /**
  7605. * Adds a Matrix 2x2 to the uniform buffer.
  7606. * @param name Name of the uniform, as used in the uniform block in the shader.
  7607. */
  7608. addMatrix2x2(name: string): void;
  7609. /**
  7610. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7611. */
  7612. create(): void;
  7613. /** @hidden */
  7614. _rebuild(): void;
  7615. /**
  7616. * Updates the WebGL Uniform Buffer on the GPU.
  7617. * If the `dynamic` flag is set to true, no cache comparison is done.
  7618. * Otherwise, the buffer will be updated only if the cache differs.
  7619. */
  7620. update(): void;
  7621. /**
  7622. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7623. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7624. * @param data Define the flattened data
  7625. * @param size Define the size of the data.
  7626. */
  7627. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7628. private _valueCache;
  7629. private _cacheMatrix;
  7630. private _updateMatrix3x3ForUniform;
  7631. private _updateMatrix3x3ForEffect;
  7632. private _updateMatrix2x2ForEffect;
  7633. private _updateMatrix2x2ForUniform;
  7634. private _updateFloatForEffect;
  7635. private _updateFloatForUniform;
  7636. private _updateFloat2ForEffect;
  7637. private _updateFloat2ForUniform;
  7638. private _updateFloat3ForEffect;
  7639. private _updateFloat3ForUniform;
  7640. private _updateFloat4ForEffect;
  7641. private _updateFloat4ForUniform;
  7642. private _updateMatrixForEffect;
  7643. private _updateMatrixForUniform;
  7644. private _updateVector3ForEffect;
  7645. private _updateVector3ForUniform;
  7646. private _updateVector4ForEffect;
  7647. private _updateVector4ForUniform;
  7648. private _updateColor3ForEffect;
  7649. private _updateColor3ForUniform;
  7650. private _updateColor4ForEffect;
  7651. private _updateColor4ForUniform;
  7652. /**
  7653. * Sets a sampler uniform on the effect.
  7654. * @param name Define the name of the sampler.
  7655. * @param texture Define the texture to set in the sampler
  7656. */
  7657. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7658. /**
  7659. * Directly updates the value of the uniform in the cache AND on the GPU.
  7660. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7661. * @param data Define the flattened data
  7662. */
  7663. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7664. /**
  7665. * Binds this uniform buffer to an effect.
  7666. * @param effect Define the effect to bind the buffer to
  7667. * @param name Name of the uniform block in the shader.
  7668. */
  7669. bindToEffect(effect: Effect, name: string): void;
  7670. /**
  7671. * Disposes the uniform buffer.
  7672. */
  7673. dispose(): void;
  7674. }
  7675. }
  7676. declare module BABYLON {
  7677. /**
  7678. * Enum that determines the text-wrapping mode to use.
  7679. */
  7680. export enum InspectableType {
  7681. /**
  7682. * Checkbox for booleans
  7683. */
  7684. Checkbox = 0,
  7685. /**
  7686. * Sliders for numbers
  7687. */
  7688. Slider = 1,
  7689. /**
  7690. * Vector3
  7691. */
  7692. Vector3 = 2,
  7693. /**
  7694. * Quaternions
  7695. */
  7696. Quaternion = 3,
  7697. /**
  7698. * Color3
  7699. */
  7700. Color3 = 4,
  7701. /**
  7702. * String
  7703. */
  7704. String = 5
  7705. }
  7706. /**
  7707. * Interface used to define custom inspectable properties.
  7708. * This interface is used by the inspector to display custom property grids
  7709. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7710. */
  7711. export interface IInspectable {
  7712. /**
  7713. * Gets the label to display
  7714. */
  7715. label: string;
  7716. /**
  7717. * Gets the name of the property to edit
  7718. */
  7719. propertyName: string;
  7720. /**
  7721. * Gets the type of the editor to use
  7722. */
  7723. type: InspectableType;
  7724. /**
  7725. * Gets the minimum value of the property when using in "slider" mode
  7726. */
  7727. min?: number;
  7728. /**
  7729. * Gets the maximum value of the property when using in "slider" mode
  7730. */
  7731. max?: number;
  7732. /**
  7733. * Gets the setp to use when using in "slider" mode
  7734. */
  7735. step?: number;
  7736. }
  7737. }
  7738. declare module BABYLON {
  7739. /**
  7740. * Class used to provide helper for timing
  7741. */
  7742. export class TimingTools {
  7743. /**
  7744. * Polyfill for setImmediate
  7745. * @param action defines the action to execute after the current execution block
  7746. */
  7747. static SetImmediate(action: () => void): void;
  7748. }
  7749. }
  7750. declare module BABYLON {
  7751. /**
  7752. * Class used to enable instatition of objects by class name
  7753. */
  7754. export class InstantiationTools {
  7755. /**
  7756. * Use this object to register external classes like custom textures or material
  7757. * to allow the laoders to instantiate them
  7758. */
  7759. static RegisteredExternalClasses: {
  7760. [key: string]: Object;
  7761. };
  7762. /**
  7763. * Tries to instantiate a new object from a given class name
  7764. * @param className defines the class name to instantiate
  7765. * @returns the new object or null if the system was not able to do the instantiation
  7766. */
  7767. static Instantiate(className: string): any;
  7768. }
  7769. }
  7770. declare module BABYLON {
  7771. /**
  7772. * Define options used to create a depth texture
  7773. */
  7774. export class DepthTextureCreationOptions {
  7775. /** Specifies whether or not a stencil should be allocated in the texture */
  7776. generateStencil?: boolean;
  7777. /** Specifies whether or not bilinear filtering is enable on the texture */
  7778. bilinearFiltering?: boolean;
  7779. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7780. comparisonFunction?: number;
  7781. /** Specifies if the created texture is a cube texture */
  7782. isCube?: boolean;
  7783. }
  7784. }
  7785. declare module BABYLON {
  7786. interface ThinEngine {
  7787. /**
  7788. * Creates a depth stencil cube texture.
  7789. * This is only available in WebGL 2.
  7790. * @param size The size of face edge in the cube texture.
  7791. * @param options The options defining the cube texture.
  7792. * @returns The cube texture
  7793. */
  7794. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7795. /**
  7796. * Creates a cube texture
  7797. * @param rootUrl defines the url where the files to load is located
  7798. * @param scene defines the current scene
  7799. * @param files defines the list of files to load (1 per face)
  7800. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7801. * @param onLoad defines an optional callback raised when the texture is loaded
  7802. * @param onError defines an optional callback raised if there is an issue to load the texture
  7803. * @param format defines the format of the data
  7804. * @param forcedExtension defines the extension to use to pick the right loader
  7805. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7806. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7807. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7808. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7809. * @returns the cube texture as an InternalTexture
  7810. */
  7811. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7812. /**
  7813. * Creates a cube texture
  7814. * @param rootUrl defines the url where the files to load is located
  7815. * @param scene defines the current scene
  7816. * @param files defines the list of files to load (1 per face)
  7817. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7818. * @param onLoad defines an optional callback raised when the texture is loaded
  7819. * @param onError defines an optional callback raised if there is an issue to load the texture
  7820. * @param format defines the format of the data
  7821. * @param forcedExtension defines the extension to use to pick the right loader
  7822. * @returns the cube texture as an InternalTexture
  7823. */
  7824. 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;
  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. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7836. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7837. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7838. * @returns the cube texture as an InternalTexture
  7839. */
  7840. 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;
  7841. /** @hidden */
  7842. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7843. /** @hidden */
  7844. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7845. /** @hidden */
  7846. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7847. /** @hidden */
  7848. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7849. /**
  7850. * @hidden
  7851. */
  7852. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7853. }
  7854. }
  7855. declare module BABYLON {
  7856. /**
  7857. * Class for creating a cube texture
  7858. */
  7859. export class CubeTexture extends BaseTexture {
  7860. private _delayedOnLoad;
  7861. /**
  7862. * Observable triggered once the texture has been loaded.
  7863. */
  7864. onLoadObservable: Observable<CubeTexture>;
  7865. /**
  7866. * The url of the texture
  7867. */
  7868. url: string;
  7869. /**
  7870. * Gets or sets the center of the bounding box associated with the cube texture.
  7871. * It must define where the camera used to render the texture was set
  7872. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7873. */
  7874. boundingBoxPosition: Vector3;
  7875. private _boundingBoxSize;
  7876. /**
  7877. * Gets or sets the size of the bounding box associated with the cube texture
  7878. * When defined, the cubemap will switch to local mode
  7879. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7880. * @example https://www.babylonjs-playground.com/#RNASML
  7881. */
  7882. set boundingBoxSize(value: Vector3);
  7883. /**
  7884. * Returns the bounding box size
  7885. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7886. */
  7887. get boundingBoxSize(): Vector3;
  7888. protected _rotationY: number;
  7889. /**
  7890. * Sets texture matrix rotation angle around Y axis in radians.
  7891. */
  7892. set rotationY(value: number);
  7893. /**
  7894. * Gets texture matrix rotation angle around Y axis radians.
  7895. */
  7896. get rotationY(): number;
  7897. /**
  7898. * Are mip maps generated for this texture or not.
  7899. */
  7900. get noMipmap(): boolean;
  7901. private _noMipmap;
  7902. private _files;
  7903. protected _forcedExtension: Nullable<string>;
  7904. private _extensions;
  7905. private _textureMatrix;
  7906. private _format;
  7907. private _createPolynomials;
  7908. /**
  7909. * Creates a cube texture from an array of image urls
  7910. * @param files defines an array of image urls
  7911. * @param scene defines the hosting scene
  7912. * @param noMipmap specifies if mip maps are not used
  7913. * @returns a cube texture
  7914. */
  7915. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7916. /**
  7917. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7918. * @param url defines the url of the prefiltered texture
  7919. * @param scene defines the scene the texture is attached to
  7920. * @param forcedExtension defines the extension of the file if different from the url
  7921. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7922. * @return the prefiltered texture
  7923. */
  7924. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7925. /**
  7926. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7927. * as prefiltered data.
  7928. * @param rootUrl defines the url of the texture or the root name of the six images
  7929. * @param null defines the scene or engine the texture is attached to
  7930. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7931. * @param noMipmap defines if mipmaps should be created or not
  7932. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7933. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7934. * @param onError defines a callback triggered in case of error during load
  7935. * @param format defines the internal format to use for the texture once loaded
  7936. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7937. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7938. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7939. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7940. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7941. * @return the cube texture
  7942. */
  7943. 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);
  7944. /**
  7945. * Get the current class name of the texture useful for serialization or dynamic coding.
  7946. * @returns "CubeTexture"
  7947. */
  7948. getClassName(): string;
  7949. /**
  7950. * Update the url (and optional buffer) of this texture if url was null during construction.
  7951. * @param url the url of the texture
  7952. * @param forcedExtension defines the extension to use
  7953. * @param onLoad callback called when the texture is loaded (defaults to null)
  7954. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7955. */
  7956. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7957. /**
  7958. * Delays loading of the cube texture
  7959. * @param forcedExtension defines the extension to use
  7960. */
  7961. delayLoad(forcedExtension?: string): void;
  7962. /**
  7963. * Returns the reflection texture matrix
  7964. * @returns the reflection texture matrix
  7965. */
  7966. getReflectionTextureMatrix(): Matrix;
  7967. /**
  7968. * Sets the reflection texture matrix
  7969. * @param value Reflection texture matrix
  7970. */
  7971. setReflectionTextureMatrix(value: Matrix): void;
  7972. /**
  7973. * Parses text to create a cube texture
  7974. * @param parsedTexture define the serialized text to read from
  7975. * @param scene defines the hosting scene
  7976. * @param rootUrl defines the root url of the cube texture
  7977. * @returns a cube texture
  7978. */
  7979. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7980. /**
  7981. * Makes a clone, or deep copy, of the cube texture
  7982. * @returns a new cube texture
  7983. */
  7984. clone(): CubeTexture;
  7985. }
  7986. }
  7987. declare module BABYLON {
  7988. /**
  7989. * Manages the defines for the Material
  7990. */
  7991. export class MaterialDefines {
  7992. /** @hidden */
  7993. protected _keys: string[];
  7994. private _isDirty;
  7995. /** @hidden */
  7996. _renderId: number;
  7997. /** @hidden */
  7998. _areLightsDirty: boolean;
  7999. /** @hidden */
  8000. _areLightsDisposed: boolean;
  8001. /** @hidden */
  8002. _areAttributesDirty: boolean;
  8003. /** @hidden */
  8004. _areTexturesDirty: boolean;
  8005. /** @hidden */
  8006. _areFresnelDirty: boolean;
  8007. /** @hidden */
  8008. _areMiscDirty: boolean;
  8009. /** @hidden */
  8010. _arePrePassDirty: boolean;
  8011. /** @hidden */
  8012. _areImageProcessingDirty: boolean;
  8013. /** @hidden */
  8014. _normals: boolean;
  8015. /** @hidden */
  8016. _uvs: boolean;
  8017. /** @hidden */
  8018. _needNormals: boolean;
  8019. /** @hidden */
  8020. _needUVs: boolean;
  8021. [id: string]: any;
  8022. /**
  8023. * Specifies if the material needs to be re-calculated
  8024. */
  8025. get isDirty(): boolean;
  8026. /**
  8027. * Marks the material to indicate that it has been re-calculated
  8028. */
  8029. markAsProcessed(): void;
  8030. /**
  8031. * Marks the material to indicate that it needs to be re-calculated
  8032. */
  8033. markAsUnprocessed(): void;
  8034. /**
  8035. * Marks the material to indicate all of its defines need to be re-calculated
  8036. */
  8037. markAllAsDirty(): void;
  8038. /**
  8039. * Marks the material to indicate that image processing needs to be re-calculated
  8040. */
  8041. markAsImageProcessingDirty(): void;
  8042. /**
  8043. * Marks the material to indicate the lights need to be re-calculated
  8044. * @param disposed Defines whether the light is dirty due to dispose or not
  8045. */
  8046. markAsLightDirty(disposed?: boolean): void;
  8047. /**
  8048. * Marks the attribute state as changed
  8049. */
  8050. markAsAttributesDirty(): void;
  8051. /**
  8052. * Marks the texture state as changed
  8053. */
  8054. markAsTexturesDirty(): void;
  8055. /**
  8056. * Marks the fresnel state as changed
  8057. */
  8058. markAsFresnelDirty(): void;
  8059. /**
  8060. * Marks the misc state as changed
  8061. */
  8062. markAsMiscDirty(): void;
  8063. /**
  8064. * Marks the prepass state as changed
  8065. */
  8066. markAsPrePassDirty(): void;
  8067. /**
  8068. * Rebuilds the material defines
  8069. */
  8070. rebuild(): void;
  8071. /**
  8072. * Specifies if two material defines are equal
  8073. * @param other - A material define instance to compare to
  8074. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8075. */
  8076. isEqual(other: MaterialDefines): boolean;
  8077. /**
  8078. * Clones this instance's defines to another instance
  8079. * @param other - material defines to clone values to
  8080. */
  8081. cloneTo(other: MaterialDefines): void;
  8082. /**
  8083. * Resets the material define values
  8084. */
  8085. reset(): void;
  8086. /**
  8087. * Converts the material define values to a string
  8088. * @returns - String of material define information
  8089. */
  8090. toString(): string;
  8091. }
  8092. }
  8093. declare module BABYLON {
  8094. /**
  8095. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8096. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8097. * 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;
  8098. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8099. */
  8100. export class ColorCurves {
  8101. private _dirty;
  8102. private _tempColor;
  8103. private _globalCurve;
  8104. private _highlightsCurve;
  8105. private _midtonesCurve;
  8106. private _shadowsCurve;
  8107. private _positiveCurve;
  8108. private _negativeCurve;
  8109. private _globalHue;
  8110. private _globalDensity;
  8111. private _globalSaturation;
  8112. private _globalExposure;
  8113. /**
  8114. * Gets the global Hue value.
  8115. * 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).
  8116. */
  8117. get globalHue(): number;
  8118. /**
  8119. * Sets the global Hue value.
  8120. * 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).
  8121. */
  8122. set globalHue(value: number);
  8123. /**
  8124. * Gets the global Density value.
  8125. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8126. * Values less than zero provide a filter of opposite hue.
  8127. */
  8128. get globalDensity(): number;
  8129. /**
  8130. * Sets the global Density value.
  8131. * 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.
  8132. * Values less than zero provide a filter of opposite hue.
  8133. */
  8134. set globalDensity(value: number);
  8135. /**
  8136. * Gets the global Saturation value.
  8137. * 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.
  8138. */
  8139. get globalSaturation(): number;
  8140. /**
  8141. * Sets the global Saturation value.
  8142. * 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.
  8143. */
  8144. set globalSaturation(value: number);
  8145. /**
  8146. * Gets the global Exposure value.
  8147. * 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.
  8148. */
  8149. get globalExposure(): number;
  8150. /**
  8151. * Sets the global Exposure 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 exposure and negative values decrease exposure.
  8153. */
  8154. set globalExposure(value: number);
  8155. private _highlightsHue;
  8156. private _highlightsDensity;
  8157. private _highlightsSaturation;
  8158. private _highlightsExposure;
  8159. /**
  8160. * Gets the highlights Hue value.
  8161. * 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).
  8162. */
  8163. get highlightsHue(): number;
  8164. /**
  8165. * Sets the highlights Hue value.
  8166. * 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).
  8167. */
  8168. set highlightsHue(value: number);
  8169. /**
  8170. * Gets the highlights Density value.
  8171. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8172. * Values less than zero provide a filter of opposite hue.
  8173. */
  8174. get highlightsDensity(): number;
  8175. /**
  8176. * Sets the highlights Density value.
  8177. * 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.
  8178. * Values less than zero provide a filter of opposite hue.
  8179. */
  8180. set highlightsDensity(value: number);
  8181. /**
  8182. * Gets the highlights Saturation value.
  8183. * 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.
  8184. */
  8185. get highlightsSaturation(): number;
  8186. /**
  8187. * Sets the highlights Saturation value.
  8188. * 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.
  8189. */
  8190. set highlightsSaturation(value: number);
  8191. /**
  8192. * Gets the highlights Exposure value.
  8193. * 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.
  8194. */
  8195. get highlightsExposure(): number;
  8196. /**
  8197. * Sets the highlights Exposure 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 exposure and negative values decrease exposure.
  8199. */
  8200. set highlightsExposure(value: number);
  8201. private _midtonesHue;
  8202. private _midtonesDensity;
  8203. private _midtonesSaturation;
  8204. private _midtonesExposure;
  8205. /**
  8206. * Gets the midtones Hue value.
  8207. * 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).
  8208. */
  8209. get midtonesHue(): number;
  8210. /**
  8211. * Sets the midtones Hue value.
  8212. * 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).
  8213. */
  8214. set midtonesHue(value: number);
  8215. /**
  8216. * Gets the midtones Density value.
  8217. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8218. * Values less than zero provide a filter of opposite hue.
  8219. */
  8220. get midtonesDensity(): number;
  8221. /**
  8222. * Sets the midtones Density value.
  8223. * 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.
  8224. * Values less than zero provide a filter of opposite hue.
  8225. */
  8226. set midtonesDensity(value: number);
  8227. /**
  8228. * Gets the midtones Saturation value.
  8229. * 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.
  8230. */
  8231. get midtonesSaturation(): number;
  8232. /**
  8233. * Sets the midtones Saturation value.
  8234. * 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.
  8235. */
  8236. set midtonesSaturation(value: number);
  8237. /**
  8238. * Gets the midtones Exposure value.
  8239. * 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.
  8240. */
  8241. get midtonesExposure(): number;
  8242. /**
  8243. * Sets the midtones Exposure 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 exposure and negative values decrease exposure.
  8245. */
  8246. set midtonesExposure(value: number);
  8247. private _shadowsHue;
  8248. private _shadowsDensity;
  8249. private _shadowsSaturation;
  8250. private _shadowsExposure;
  8251. /**
  8252. * Gets the shadows Hue value.
  8253. * 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).
  8254. */
  8255. get shadowsHue(): number;
  8256. /**
  8257. * Sets the shadows Hue value.
  8258. * 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).
  8259. */
  8260. set shadowsHue(value: number);
  8261. /**
  8262. * Gets the shadows Density value.
  8263. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8264. * Values less than zero provide a filter of opposite hue.
  8265. */
  8266. get shadowsDensity(): number;
  8267. /**
  8268. * Sets the shadows Density value.
  8269. * 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.
  8270. * Values less than zero provide a filter of opposite hue.
  8271. */
  8272. set shadowsDensity(value: number);
  8273. /**
  8274. * Gets the shadows Saturation value.
  8275. * 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.
  8276. */
  8277. get shadowsSaturation(): number;
  8278. /**
  8279. * Sets the shadows Saturation value.
  8280. * 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.
  8281. */
  8282. set shadowsSaturation(value: number);
  8283. /**
  8284. * Gets the shadows Exposure value.
  8285. * 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.
  8286. */
  8287. get shadowsExposure(): number;
  8288. /**
  8289. * Sets the shadows Exposure 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 exposure and negative values decrease exposure.
  8291. */
  8292. set shadowsExposure(value: number);
  8293. /**
  8294. * Returns the class name
  8295. * @returns The class name
  8296. */
  8297. getClassName(): string;
  8298. /**
  8299. * Binds the color curves to the shader.
  8300. * @param colorCurves The color curve to bind
  8301. * @param effect The effect to bind to
  8302. * @param positiveUniform The positive uniform shader parameter
  8303. * @param neutralUniform The neutral uniform shader parameter
  8304. * @param negativeUniform The negative uniform shader parameter
  8305. */
  8306. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8307. /**
  8308. * Prepare the list of uniforms associated with the ColorCurves effects.
  8309. * @param uniformsList The list of uniforms used in the effect
  8310. */
  8311. static PrepareUniforms(uniformsList: string[]): void;
  8312. /**
  8313. * Returns color grading data based on a hue, density, saturation and exposure value.
  8314. * @param filterHue The hue of the color filter.
  8315. * @param filterDensity The density of the color filter.
  8316. * @param saturation The saturation.
  8317. * @param exposure The exposure.
  8318. * @param result The result data container.
  8319. */
  8320. private getColorGradingDataToRef;
  8321. /**
  8322. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8323. * @param value The input slider value in range [-100,100].
  8324. * @returns Adjusted value.
  8325. */
  8326. private static applyColorGradingSliderNonlinear;
  8327. /**
  8328. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8329. * @param hue The hue (H) input.
  8330. * @param saturation The saturation (S) input.
  8331. * @param brightness The brightness (B) input.
  8332. * @result An RGBA color represented as Vector4.
  8333. */
  8334. private static fromHSBToRef;
  8335. /**
  8336. * Returns a value clamped between min and max
  8337. * @param value The value to clamp
  8338. * @param min The minimum of value
  8339. * @param max The maximum of value
  8340. * @returns The clamped value.
  8341. */
  8342. private static clamp;
  8343. /**
  8344. * Clones the current color curve instance.
  8345. * @return The cloned curves
  8346. */
  8347. clone(): ColorCurves;
  8348. /**
  8349. * Serializes the current color curve instance to a json representation.
  8350. * @return a JSON representation
  8351. */
  8352. serialize(): any;
  8353. /**
  8354. * Parses the color curve from a json representation.
  8355. * @param source the JSON source to parse
  8356. * @return The parsed curves
  8357. */
  8358. static Parse(source: any): ColorCurves;
  8359. }
  8360. }
  8361. declare module BABYLON {
  8362. /**
  8363. * Interface to follow in your material defines to integrate easily the
  8364. * Image proccessing functions.
  8365. * @hidden
  8366. */
  8367. export interface IImageProcessingConfigurationDefines {
  8368. IMAGEPROCESSING: boolean;
  8369. VIGNETTE: boolean;
  8370. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8371. VIGNETTEBLENDMODEOPAQUE: boolean;
  8372. TONEMAPPING: boolean;
  8373. TONEMAPPING_ACES: boolean;
  8374. CONTRAST: boolean;
  8375. EXPOSURE: boolean;
  8376. COLORCURVES: boolean;
  8377. COLORGRADING: boolean;
  8378. COLORGRADING3D: boolean;
  8379. SAMPLER3DGREENDEPTH: boolean;
  8380. SAMPLER3DBGRMAP: boolean;
  8381. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8382. }
  8383. /**
  8384. * @hidden
  8385. */
  8386. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8387. IMAGEPROCESSING: boolean;
  8388. VIGNETTE: boolean;
  8389. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8390. VIGNETTEBLENDMODEOPAQUE: boolean;
  8391. TONEMAPPING: boolean;
  8392. TONEMAPPING_ACES: boolean;
  8393. CONTRAST: boolean;
  8394. COLORCURVES: boolean;
  8395. COLORGRADING: boolean;
  8396. COLORGRADING3D: boolean;
  8397. SAMPLER3DGREENDEPTH: boolean;
  8398. SAMPLER3DBGRMAP: boolean;
  8399. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8400. EXPOSURE: boolean;
  8401. constructor();
  8402. }
  8403. /**
  8404. * This groups together the common properties used for image processing either in direct forward pass
  8405. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8406. * or not.
  8407. */
  8408. export class ImageProcessingConfiguration {
  8409. /**
  8410. * Default tone mapping applied in BabylonJS.
  8411. */
  8412. static readonly TONEMAPPING_STANDARD: number;
  8413. /**
  8414. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8415. * to other engines rendering to increase portability.
  8416. */
  8417. static readonly TONEMAPPING_ACES: number;
  8418. /**
  8419. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8420. */
  8421. colorCurves: Nullable<ColorCurves>;
  8422. private _colorCurvesEnabled;
  8423. /**
  8424. * Gets wether the color curves effect is enabled.
  8425. */
  8426. get colorCurvesEnabled(): boolean;
  8427. /**
  8428. * Sets wether the color curves effect is enabled.
  8429. */
  8430. set colorCurvesEnabled(value: boolean);
  8431. private _colorGradingTexture;
  8432. /**
  8433. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8434. */
  8435. get colorGradingTexture(): Nullable<BaseTexture>;
  8436. /**
  8437. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8438. */
  8439. set colorGradingTexture(value: Nullable<BaseTexture>);
  8440. private _colorGradingEnabled;
  8441. /**
  8442. * Gets wether the color grading effect is enabled.
  8443. */
  8444. get colorGradingEnabled(): boolean;
  8445. /**
  8446. * Sets wether the color grading effect is enabled.
  8447. */
  8448. set colorGradingEnabled(value: boolean);
  8449. private _colorGradingWithGreenDepth;
  8450. /**
  8451. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8452. */
  8453. get colorGradingWithGreenDepth(): boolean;
  8454. /**
  8455. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8456. */
  8457. set colorGradingWithGreenDepth(value: boolean);
  8458. private _colorGradingBGR;
  8459. /**
  8460. * Gets wether the color grading texture contains BGR values.
  8461. */
  8462. get colorGradingBGR(): boolean;
  8463. /**
  8464. * Sets wether the color grading texture contains BGR values.
  8465. */
  8466. set colorGradingBGR(value: boolean);
  8467. /** @hidden */
  8468. _exposure: number;
  8469. /**
  8470. * Gets the Exposure used in the effect.
  8471. */
  8472. get exposure(): number;
  8473. /**
  8474. * Sets the Exposure used in the effect.
  8475. */
  8476. set exposure(value: number);
  8477. private _toneMappingEnabled;
  8478. /**
  8479. * Gets wether the tone mapping effect is enabled.
  8480. */
  8481. get toneMappingEnabled(): boolean;
  8482. /**
  8483. * Sets wether the tone mapping effect is enabled.
  8484. */
  8485. set toneMappingEnabled(value: boolean);
  8486. private _toneMappingType;
  8487. /**
  8488. * Gets the type of tone mapping effect.
  8489. */
  8490. get toneMappingType(): number;
  8491. /**
  8492. * Sets the type of tone mapping effect used in BabylonJS.
  8493. */
  8494. set toneMappingType(value: number);
  8495. protected _contrast: number;
  8496. /**
  8497. * Gets the contrast used in the effect.
  8498. */
  8499. get contrast(): number;
  8500. /**
  8501. * Sets the contrast used in the effect.
  8502. */
  8503. set contrast(value: number);
  8504. /**
  8505. * Vignette stretch size.
  8506. */
  8507. vignetteStretch: number;
  8508. /**
  8509. * Vignette centre X Offset.
  8510. */
  8511. vignetteCentreX: number;
  8512. /**
  8513. * Vignette centre Y Offset.
  8514. */
  8515. vignetteCentreY: number;
  8516. /**
  8517. * Vignette weight or intensity of the vignette effect.
  8518. */
  8519. vignetteWeight: number;
  8520. /**
  8521. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8522. * if vignetteEnabled is set to true.
  8523. */
  8524. vignetteColor: Color4;
  8525. /**
  8526. * Camera field of view used by the Vignette effect.
  8527. */
  8528. vignetteCameraFov: number;
  8529. private _vignetteBlendMode;
  8530. /**
  8531. * Gets the vignette blend mode allowing different kind of effect.
  8532. */
  8533. get vignetteBlendMode(): number;
  8534. /**
  8535. * Sets the vignette blend mode allowing different kind of effect.
  8536. */
  8537. set vignetteBlendMode(value: number);
  8538. private _vignetteEnabled;
  8539. /**
  8540. * Gets wether the vignette effect is enabled.
  8541. */
  8542. get vignetteEnabled(): boolean;
  8543. /**
  8544. * Sets wether the vignette effect is enabled.
  8545. */
  8546. set vignetteEnabled(value: boolean);
  8547. private _applyByPostProcess;
  8548. /**
  8549. * Gets wether the image processing is applied through a post process or not.
  8550. */
  8551. get applyByPostProcess(): boolean;
  8552. /**
  8553. * Sets wether the image processing is applied through a post process or not.
  8554. */
  8555. set applyByPostProcess(value: boolean);
  8556. private _isEnabled;
  8557. /**
  8558. * Gets wether the image processing is enabled or not.
  8559. */
  8560. get isEnabled(): boolean;
  8561. /**
  8562. * Sets wether the image processing is enabled or not.
  8563. */
  8564. set isEnabled(value: boolean);
  8565. /**
  8566. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8567. */
  8568. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8569. /**
  8570. * Method called each time the image processing information changes requires to recompile the effect.
  8571. */
  8572. protected _updateParameters(): void;
  8573. /**
  8574. * Gets the current class name.
  8575. * @return "ImageProcessingConfiguration"
  8576. */
  8577. getClassName(): string;
  8578. /**
  8579. * Prepare the list of uniforms associated with the Image Processing effects.
  8580. * @param uniforms The list of uniforms used in the effect
  8581. * @param defines the list of defines currently in use
  8582. */
  8583. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8584. /**
  8585. * Prepare the list of samplers associated with the Image Processing effects.
  8586. * @param samplersList The list of uniforms used in the effect
  8587. * @param defines the list of defines currently in use
  8588. */
  8589. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8590. /**
  8591. * Prepare the list of defines associated to the shader.
  8592. * @param defines the list of defines to complete
  8593. * @param forPostProcess Define if we are currently in post process mode or not
  8594. */
  8595. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8596. /**
  8597. * Returns true if all the image processing information are ready.
  8598. * @returns True if ready, otherwise, false
  8599. */
  8600. isReady(): boolean;
  8601. /**
  8602. * Binds the image processing to the shader.
  8603. * @param effect The effect to bind to
  8604. * @param overrideAspectRatio Override the aspect ratio of the effect
  8605. */
  8606. bind(effect: Effect, overrideAspectRatio?: number): void;
  8607. /**
  8608. * Clones the current image processing instance.
  8609. * @return The cloned image processing
  8610. */
  8611. clone(): ImageProcessingConfiguration;
  8612. /**
  8613. * Serializes the current image processing instance to a json representation.
  8614. * @return a JSON representation
  8615. */
  8616. serialize(): any;
  8617. /**
  8618. * Parses the image processing from a json representation.
  8619. * @param source the JSON source to parse
  8620. * @return The parsed image processing
  8621. */
  8622. static Parse(source: any): ImageProcessingConfiguration;
  8623. private static _VIGNETTEMODE_MULTIPLY;
  8624. private static _VIGNETTEMODE_OPAQUE;
  8625. /**
  8626. * Used to apply the vignette as a mix with the pixel color.
  8627. */
  8628. static get VIGNETTEMODE_MULTIPLY(): number;
  8629. /**
  8630. * Used to apply the vignette as a replacement of the pixel color.
  8631. */
  8632. static get VIGNETTEMODE_OPAQUE(): number;
  8633. }
  8634. }
  8635. declare module BABYLON {
  8636. /** @hidden */
  8637. export var postprocessVertexShader: {
  8638. name: string;
  8639. shader: string;
  8640. };
  8641. }
  8642. declare module BABYLON {
  8643. /**
  8644. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8645. */
  8646. export type RenderTargetTextureSize = number | {
  8647. width: number;
  8648. height: number;
  8649. layers?: number;
  8650. };
  8651. interface ThinEngine {
  8652. /**
  8653. * Creates a new render target texture
  8654. * @param size defines the size of the texture
  8655. * @param options defines the options used to create the texture
  8656. * @returns a new render target texture stored in an InternalTexture
  8657. */
  8658. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8659. /**
  8660. * Creates a depth stencil texture.
  8661. * This is only available in WebGL 2 or with the depth texture extension available.
  8662. * @param size The size of face edge in the texture.
  8663. * @param options The options defining the texture.
  8664. * @returns The texture
  8665. */
  8666. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8667. /** @hidden */
  8668. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8669. }
  8670. }
  8671. declare module BABYLON {
  8672. /**
  8673. * Defines the kind of connection point for node based material
  8674. */
  8675. export enum NodeMaterialBlockConnectionPointTypes {
  8676. /** Float */
  8677. Float = 1,
  8678. /** Int */
  8679. Int = 2,
  8680. /** Vector2 */
  8681. Vector2 = 4,
  8682. /** Vector3 */
  8683. Vector3 = 8,
  8684. /** Vector4 */
  8685. Vector4 = 16,
  8686. /** Color3 */
  8687. Color3 = 32,
  8688. /** Color4 */
  8689. Color4 = 64,
  8690. /** Matrix */
  8691. Matrix = 128,
  8692. /** Custom object */
  8693. Object = 256,
  8694. /** Detect type based on connection */
  8695. AutoDetect = 1024,
  8696. /** Output type that will be defined by input type */
  8697. BasedOnInput = 2048
  8698. }
  8699. }
  8700. declare module BABYLON {
  8701. /**
  8702. * Enum used to define the target of a block
  8703. */
  8704. export enum NodeMaterialBlockTargets {
  8705. /** Vertex shader */
  8706. Vertex = 1,
  8707. /** Fragment shader */
  8708. Fragment = 2,
  8709. /** Neutral */
  8710. Neutral = 4,
  8711. /** Vertex and Fragment */
  8712. VertexAndFragment = 3
  8713. }
  8714. }
  8715. declare module BABYLON {
  8716. /**
  8717. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8718. */
  8719. export enum NodeMaterialBlockConnectionPointMode {
  8720. /** Value is an uniform */
  8721. Uniform = 0,
  8722. /** Value is a mesh attribute */
  8723. Attribute = 1,
  8724. /** Value is a varying between vertex and fragment shaders */
  8725. Varying = 2,
  8726. /** Mode is undefined */
  8727. Undefined = 3
  8728. }
  8729. }
  8730. declare module BABYLON {
  8731. /**
  8732. * Enum used to define system values e.g. values automatically provided by the system
  8733. */
  8734. export enum NodeMaterialSystemValues {
  8735. /** World */
  8736. World = 1,
  8737. /** View */
  8738. View = 2,
  8739. /** Projection */
  8740. Projection = 3,
  8741. /** ViewProjection */
  8742. ViewProjection = 4,
  8743. /** WorldView */
  8744. WorldView = 5,
  8745. /** WorldViewProjection */
  8746. WorldViewProjection = 6,
  8747. /** CameraPosition */
  8748. CameraPosition = 7,
  8749. /** Fog Color */
  8750. FogColor = 8,
  8751. /** Delta time */
  8752. DeltaTime = 9
  8753. }
  8754. }
  8755. declare module BABYLON {
  8756. /** Defines supported spaces */
  8757. export enum Space {
  8758. /** Local (object) space */
  8759. LOCAL = 0,
  8760. /** World space */
  8761. WORLD = 1,
  8762. /** Bone space */
  8763. BONE = 2
  8764. }
  8765. /** Defines the 3 main axes */
  8766. export class Axis {
  8767. /** X axis */
  8768. static X: Vector3;
  8769. /** Y axis */
  8770. static Y: Vector3;
  8771. /** Z axis */
  8772. static Z: Vector3;
  8773. }
  8774. }
  8775. declare module BABYLON {
  8776. /**
  8777. * Represents a camera frustum
  8778. */
  8779. export class Frustum {
  8780. /**
  8781. * Gets the planes representing the frustum
  8782. * @param transform matrix to be applied to the returned planes
  8783. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8784. */
  8785. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8786. /**
  8787. * Gets the near frustum plane transformed by the transform matrix
  8788. * @param transform transformation matrix to be applied to the resulting frustum plane
  8789. * @param frustumPlane the resuling frustum plane
  8790. */
  8791. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8792. /**
  8793. * Gets the far frustum plane transformed by the transform matrix
  8794. * @param transform transformation matrix to be applied to the resulting frustum plane
  8795. * @param frustumPlane the resuling frustum plane
  8796. */
  8797. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8798. /**
  8799. * Gets the left frustum plane transformed by the transform matrix
  8800. * @param transform transformation matrix to be applied to the resulting frustum plane
  8801. * @param frustumPlane the resuling frustum plane
  8802. */
  8803. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8804. /**
  8805. * Gets the right frustum plane transformed by the transform matrix
  8806. * @param transform transformation matrix to be applied to the resulting frustum plane
  8807. * @param frustumPlane the resuling frustum plane
  8808. */
  8809. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8810. /**
  8811. * Gets the top frustum plane transformed by the transform matrix
  8812. * @param transform transformation matrix to be applied to the resulting frustum plane
  8813. * @param frustumPlane the resuling frustum plane
  8814. */
  8815. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8816. /**
  8817. * Gets the bottom frustum plane transformed by the transform matrix
  8818. * @param transform transformation matrix to be applied to the resulting frustum plane
  8819. * @param frustumPlane the resuling frustum plane
  8820. */
  8821. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8822. /**
  8823. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8824. * @param transform transformation matrix to be applied to the resulting frustum planes
  8825. * @param frustumPlanes the resuling frustum planes
  8826. */
  8827. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8828. }
  8829. }
  8830. declare module BABYLON {
  8831. /**
  8832. * Interface for the size containing width and height
  8833. */
  8834. export interface ISize {
  8835. /**
  8836. * Width
  8837. */
  8838. width: number;
  8839. /**
  8840. * Heighht
  8841. */
  8842. height: number;
  8843. }
  8844. /**
  8845. * Size containing widht and height
  8846. */
  8847. export class Size implements ISize {
  8848. /**
  8849. * Width
  8850. */
  8851. width: number;
  8852. /**
  8853. * Height
  8854. */
  8855. height: number;
  8856. /**
  8857. * Creates a Size object from the given width and height (floats).
  8858. * @param width width of the new size
  8859. * @param height height of the new size
  8860. */
  8861. constructor(width: number, height: number);
  8862. /**
  8863. * Returns a string with the Size width and height
  8864. * @returns a string with the Size width and height
  8865. */
  8866. toString(): string;
  8867. /**
  8868. * "Size"
  8869. * @returns the string "Size"
  8870. */
  8871. getClassName(): string;
  8872. /**
  8873. * Returns the Size hash code.
  8874. * @returns a hash code for a unique width and height
  8875. */
  8876. getHashCode(): number;
  8877. /**
  8878. * Updates the current size from the given one.
  8879. * @param src the given size
  8880. */
  8881. copyFrom(src: Size): void;
  8882. /**
  8883. * Updates in place the current Size from the given floats.
  8884. * @param width width of the new size
  8885. * @param height height of the new size
  8886. * @returns the updated Size.
  8887. */
  8888. copyFromFloats(width: number, height: number): Size;
  8889. /**
  8890. * Updates in place the current Size from the given floats.
  8891. * @param width width to set
  8892. * @param height height to set
  8893. * @returns the updated Size.
  8894. */
  8895. set(width: number, height: number): Size;
  8896. /**
  8897. * Multiplies the width and height by numbers
  8898. * @param w factor to multiple the width by
  8899. * @param h factor to multiple the height by
  8900. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8901. */
  8902. multiplyByFloats(w: number, h: number): Size;
  8903. /**
  8904. * Clones the size
  8905. * @returns a new Size copied from the given one.
  8906. */
  8907. clone(): Size;
  8908. /**
  8909. * True if the current Size and the given one width and height are strictly equal.
  8910. * @param other the other size to compare against
  8911. * @returns True if the current Size and the given one width and height are strictly equal.
  8912. */
  8913. equals(other: Size): boolean;
  8914. /**
  8915. * The surface of the Size : width * height (float).
  8916. */
  8917. get surface(): number;
  8918. /**
  8919. * Create a new size of zero
  8920. * @returns a new Size set to (0.0, 0.0)
  8921. */
  8922. static Zero(): Size;
  8923. /**
  8924. * Sums the width and height of two sizes
  8925. * @param otherSize size to add to this size
  8926. * @returns a new Size set as the addition result of the current Size and the given one.
  8927. */
  8928. add(otherSize: Size): Size;
  8929. /**
  8930. * Subtracts the width and height of two
  8931. * @param otherSize size to subtract to this size
  8932. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8933. */
  8934. subtract(otherSize: Size): Size;
  8935. /**
  8936. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8937. * @param start starting size to lerp between
  8938. * @param end end size to lerp between
  8939. * @param amount amount to lerp between the start and end values
  8940. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8941. */
  8942. static Lerp(start: Size, end: Size, amount: number): Size;
  8943. }
  8944. }
  8945. declare module BABYLON {
  8946. /**
  8947. * Contains position and normal vectors for a vertex
  8948. */
  8949. export class PositionNormalVertex {
  8950. /** the position of the vertex (defaut: 0,0,0) */
  8951. position: Vector3;
  8952. /** the normal of the vertex (defaut: 0,1,0) */
  8953. normal: Vector3;
  8954. /**
  8955. * Creates a PositionNormalVertex
  8956. * @param position the position of the vertex (defaut: 0,0,0)
  8957. * @param normal the normal of the vertex (defaut: 0,1,0)
  8958. */
  8959. constructor(
  8960. /** the position of the vertex (defaut: 0,0,0) */
  8961. position?: Vector3,
  8962. /** the normal of the vertex (defaut: 0,1,0) */
  8963. normal?: Vector3);
  8964. /**
  8965. * Clones the PositionNormalVertex
  8966. * @returns the cloned PositionNormalVertex
  8967. */
  8968. clone(): PositionNormalVertex;
  8969. }
  8970. /**
  8971. * Contains position, normal and uv vectors for a vertex
  8972. */
  8973. export class PositionNormalTextureVertex {
  8974. /** the position of the vertex (defaut: 0,0,0) */
  8975. position: Vector3;
  8976. /** the normal of the vertex (defaut: 0,1,0) */
  8977. normal: Vector3;
  8978. /** the uv of the vertex (default: 0,0) */
  8979. uv: Vector2;
  8980. /**
  8981. * Creates a PositionNormalTextureVertex
  8982. * @param position the position of the vertex (defaut: 0,0,0)
  8983. * @param normal the normal of the vertex (defaut: 0,1,0)
  8984. * @param uv the uv of the vertex (default: 0,0)
  8985. */
  8986. constructor(
  8987. /** the position of the vertex (defaut: 0,0,0) */
  8988. position?: Vector3,
  8989. /** the normal of the vertex (defaut: 0,1,0) */
  8990. normal?: Vector3,
  8991. /** the uv of the vertex (default: 0,0) */
  8992. uv?: Vector2);
  8993. /**
  8994. * Clones the PositionNormalTextureVertex
  8995. * @returns the cloned PositionNormalTextureVertex
  8996. */
  8997. clone(): PositionNormalTextureVertex;
  8998. }
  8999. }
  9000. declare module BABYLON {
  9001. /**
  9002. * Enum defining the type of animations supported by InputBlock
  9003. */
  9004. export enum AnimatedInputBlockTypes {
  9005. /** No animation */
  9006. None = 0,
  9007. /** Time based animation. Will only work for floats */
  9008. Time = 1
  9009. }
  9010. }
  9011. declare module BABYLON {
  9012. /**
  9013. * Interface describing all the common properties and methods a shadow light needs to implement.
  9014. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9015. * as well as binding the different shadow properties to the effects.
  9016. */
  9017. export interface IShadowLight extends Light {
  9018. /**
  9019. * The light id in the scene (used in scene.findLighById for instance)
  9020. */
  9021. id: string;
  9022. /**
  9023. * The position the shdow will be casted from.
  9024. */
  9025. position: Vector3;
  9026. /**
  9027. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9028. */
  9029. direction: Vector3;
  9030. /**
  9031. * The transformed position. Position of the light in world space taking parenting in account.
  9032. */
  9033. transformedPosition: Vector3;
  9034. /**
  9035. * The transformed direction. Direction of the light in world space taking parenting in account.
  9036. */
  9037. transformedDirection: Vector3;
  9038. /**
  9039. * The friendly name of the light in the scene.
  9040. */
  9041. name: string;
  9042. /**
  9043. * Defines the shadow projection clipping minimum z value.
  9044. */
  9045. shadowMinZ: number;
  9046. /**
  9047. * Defines the shadow projection clipping maximum z value.
  9048. */
  9049. shadowMaxZ: number;
  9050. /**
  9051. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9052. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9053. */
  9054. computeTransformedInformation(): boolean;
  9055. /**
  9056. * Gets the scene the light belongs to.
  9057. * @returns The scene
  9058. */
  9059. getScene(): Scene;
  9060. /**
  9061. * Callback defining a custom Projection Matrix Builder.
  9062. * This can be used to override the default projection matrix computation.
  9063. */
  9064. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9065. /**
  9066. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9067. * @param matrix The materix to updated with the projection information
  9068. * @param viewMatrix The transform matrix of the light
  9069. * @param renderList The list of mesh to render in the map
  9070. * @returns The current light
  9071. */
  9072. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9073. /**
  9074. * Gets the current depth scale used in ESM.
  9075. * @returns The scale
  9076. */
  9077. getDepthScale(): number;
  9078. /**
  9079. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9080. * @returns true if a cube texture needs to be use
  9081. */
  9082. needCube(): boolean;
  9083. /**
  9084. * Detects if the projection matrix requires to be recomputed this frame.
  9085. * @returns true if it requires to be recomputed otherwise, false.
  9086. */
  9087. needProjectionMatrixCompute(): boolean;
  9088. /**
  9089. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9090. */
  9091. forceProjectionMatrixCompute(): void;
  9092. /**
  9093. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9094. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9095. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9096. */
  9097. getShadowDirection(faceIndex?: number): Vector3;
  9098. /**
  9099. * Gets the minZ used for shadow according to both the scene and the light.
  9100. * @param activeCamera The camera we are returning the min for
  9101. * @returns the depth min z
  9102. */
  9103. getDepthMinZ(activeCamera: Camera): number;
  9104. /**
  9105. * Gets the maxZ used for shadow according to both the scene and the light.
  9106. * @param activeCamera The camera we are returning the max for
  9107. * @returns the depth max z
  9108. */
  9109. getDepthMaxZ(activeCamera: Camera): number;
  9110. }
  9111. /**
  9112. * Base implementation IShadowLight
  9113. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9114. */
  9115. export abstract class ShadowLight extends Light implements IShadowLight {
  9116. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9117. protected _position: Vector3;
  9118. protected _setPosition(value: Vector3): void;
  9119. /**
  9120. * Sets the position the shadow will be casted from. Also use as the light position for both
  9121. * point and spot lights.
  9122. */
  9123. get position(): Vector3;
  9124. /**
  9125. * Sets the position the shadow will be casted from. Also use as the light position for both
  9126. * point and spot lights.
  9127. */
  9128. set position(value: Vector3);
  9129. protected _direction: Vector3;
  9130. protected _setDirection(value: Vector3): void;
  9131. /**
  9132. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9133. * Also use as the light direction on spot and directional lights.
  9134. */
  9135. get direction(): Vector3;
  9136. /**
  9137. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9138. * Also use as the light direction on spot and directional lights.
  9139. */
  9140. set direction(value: Vector3);
  9141. protected _shadowMinZ: number;
  9142. /**
  9143. * Gets the shadow projection clipping minimum z value.
  9144. */
  9145. get shadowMinZ(): number;
  9146. /**
  9147. * Sets the shadow projection clipping minimum z value.
  9148. */
  9149. set shadowMinZ(value: number);
  9150. protected _shadowMaxZ: number;
  9151. /**
  9152. * Sets the shadow projection clipping maximum z value.
  9153. */
  9154. get shadowMaxZ(): number;
  9155. /**
  9156. * Gets the shadow projection clipping maximum z value.
  9157. */
  9158. set shadowMaxZ(value: number);
  9159. /**
  9160. * Callback defining a custom Projection Matrix Builder.
  9161. * This can be used to override the default projection matrix computation.
  9162. */
  9163. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9164. /**
  9165. * The transformed position. Position of the light in world space taking parenting in account.
  9166. */
  9167. transformedPosition: Vector3;
  9168. /**
  9169. * The transformed direction. Direction of the light in world space taking parenting in account.
  9170. */
  9171. transformedDirection: Vector3;
  9172. private _needProjectionMatrixCompute;
  9173. /**
  9174. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9175. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9176. */
  9177. computeTransformedInformation(): boolean;
  9178. /**
  9179. * Return the depth scale used for the shadow map.
  9180. * @returns the depth scale.
  9181. */
  9182. getDepthScale(): number;
  9183. /**
  9184. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9185. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9186. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9187. */
  9188. getShadowDirection(faceIndex?: number): Vector3;
  9189. /**
  9190. * Returns the ShadowLight absolute position in the World.
  9191. * @returns the position vector in world space
  9192. */
  9193. getAbsolutePosition(): Vector3;
  9194. /**
  9195. * Sets the ShadowLight direction toward the passed target.
  9196. * @param target The point to target in local space
  9197. * @returns the updated ShadowLight direction
  9198. */
  9199. setDirectionToTarget(target: Vector3): Vector3;
  9200. /**
  9201. * Returns the light rotation in euler definition.
  9202. * @returns the x y z rotation in local space.
  9203. */
  9204. getRotation(): Vector3;
  9205. /**
  9206. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9207. * @returns true if a cube texture needs to be use
  9208. */
  9209. needCube(): boolean;
  9210. /**
  9211. * Detects if the projection matrix requires to be recomputed this frame.
  9212. * @returns true if it requires to be recomputed otherwise, false.
  9213. */
  9214. needProjectionMatrixCompute(): boolean;
  9215. /**
  9216. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9217. */
  9218. forceProjectionMatrixCompute(): void;
  9219. /** @hidden */
  9220. _initCache(): void;
  9221. /** @hidden */
  9222. _isSynchronized(): boolean;
  9223. /**
  9224. * Computes the world matrix of the node
  9225. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9226. * @returns the world matrix
  9227. */
  9228. computeWorldMatrix(force?: boolean): Matrix;
  9229. /**
  9230. * Gets the minZ used for shadow according to both the scene and the light.
  9231. * @param activeCamera The camera we are returning the min for
  9232. * @returns the depth min z
  9233. */
  9234. getDepthMinZ(activeCamera: Camera): number;
  9235. /**
  9236. * Gets the maxZ used for shadow according to both the scene and the light.
  9237. * @param activeCamera The camera we are returning the max for
  9238. * @returns the depth max z
  9239. */
  9240. getDepthMaxZ(activeCamera: Camera): number;
  9241. /**
  9242. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9243. * @param matrix The materix to updated with the projection information
  9244. * @param viewMatrix The transform matrix of the light
  9245. * @param renderList The list of mesh to render in the map
  9246. * @returns The current light
  9247. */
  9248. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9249. }
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var packingFunctions: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /** @hidden */
  9260. export var bayerDitherFunctions: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var shadowMapFragmentDeclaration: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var clipPlaneFragmentDeclaration: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var clipPlaneFragment: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var shadowMapFragment: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var shadowMapPixelShader: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var bonesDeclaration: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var morphTargetsVertexGlobalDeclaration: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var morphTargetsVertexDeclaration: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var instancesDeclaration: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var helperFunctions: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var shadowMapVertexDeclaration: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /** @hidden */
  9344. export var clipPlaneVertexDeclaration: {
  9345. name: string;
  9346. shader: string;
  9347. };
  9348. }
  9349. declare module BABYLON {
  9350. /** @hidden */
  9351. export var morphTargetsVertex: {
  9352. name: string;
  9353. shader: string;
  9354. };
  9355. }
  9356. declare module BABYLON {
  9357. /** @hidden */
  9358. export var instancesVertex: {
  9359. name: string;
  9360. shader: string;
  9361. };
  9362. }
  9363. declare module BABYLON {
  9364. /** @hidden */
  9365. export var bonesVertex: {
  9366. name: string;
  9367. shader: string;
  9368. };
  9369. }
  9370. declare module BABYLON {
  9371. /** @hidden */
  9372. export var shadowMapVertexNormalBias: {
  9373. name: string;
  9374. shader: string;
  9375. };
  9376. }
  9377. declare module BABYLON {
  9378. /** @hidden */
  9379. export var shadowMapVertexMetric: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module BABYLON {
  9385. /** @hidden */
  9386. export var clipPlaneVertex: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module BABYLON {
  9392. /** @hidden */
  9393. export var shadowMapVertexShader: {
  9394. name: string;
  9395. shader: string;
  9396. };
  9397. }
  9398. declare module BABYLON {
  9399. /** @hidden */
  9400. export var depthBoxBlurPixelShader: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module BABYLON {
  9406. /** @hidden */
  9407. export var shadowMapFragmentSoftTransparentShadow: {
  9408. name: string;
  9409. shader: string;
  9410. };
  9411. }
  9412. declare module BABYLON {
  9413. /**
  9414. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9415. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9416. */
  9417. export class EffectFallbacks implements IEffectFallbacks {
  9418. private _defines;
  9419. private _currentRank;
  9420. private _maxRank;
  9421. private _mesh;
  9422. /**
  9423. * Removes the fallback from the bound mesh.
  9424. */
  9425. unBindMesh(): void;
  9426. /**
  9427. * Adds a fallback on the specified property.
  9428. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9429. * @param define The name of the define in the shader
  9430. */
  9431. addFallback(rank: number, define: string): void;
  9432. /**
  9433. * Sets the mesh to use CPU skinning when needing to fallback.
  9434. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9435. * @param mesh The mesh to use the fallbacks.
  9436. */
  9437. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9438. /**
  9439. * Checks to see if more fallbacks are still availible.
  9440. */
  9441. get hasMoreFallbacks(): boolean;
  9442. /**
  9443. * Removes the defines that should be removed when falling back.
  9444. * @param currentDefines defines the current define statements for the shader.
  9445. * @param effect defines the current effect we try to compile
  9446. * @returns The resulting defines with defines of the current rank removed.
  9447. */
  9448. reduce(currentDefines: string, effect: Effect): string;
  9449. }
  9450. }
  9451. declare module BABYLON {
  9452. /**
  9453. * Interface used to define Action
  9454. */
  9455. export interface IAction {
  9456. /**
  9457. * Trigger for the action
  9458. */
  9459. trigger: number;
  9460. /** Options of the trigger */
  9461. triggerOptions: any;
  9462. /**
  9463. * Gets the trigger parameters
  9464. * @returns the trigger parameters
  9465. */
  9466. getTriggerParameter(): any;
  9467. /**
  9468. * Internal only - executes current action event
  9469. * @hidden
  9470. */
  9471. _executeCurrent(evt?: ActionEvent): void;
  9472. /**
  9473. * Serialize placeholder for child classes
  9474. * @param parent of child
  9475. * @returns the serialized object
  9476. */
  9477. serialize(parent: any): any;
  9478. /**
  9479. * Internal only
  9480. * @hidden
  9481. */
  9482. _prepare(): void;
  9483. /**
  9484. * Internal only - manager for action
  9485. * @hidden
  9486. */
  9487. _actionManager: Nullable<AbstractActionManager>;
  9488. /**
  9489. * Adds action to chain of actions, may be a DoNothingAction
  9490. * @param action defines the next action to execute
  9491. * @returns The action passed in
  9492. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9493. */
  9494. then(action: IAction): IAction;
  9495. }
  9496. /**
  9497. * The action to be carried out following a trigger
  9498. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9499. */
  9500. export class Action implements IAction {
  9501. /** the trigger, with or without parameters, for the action */
  9502. triggerOptions: any;
  9503. /**
  9504. * Trigger for the action
  9505. */
  9506. trigger: number;
  9507. /**
  9508. * Internal only - manager for action
  9509. * @hidden
  9510. */
  9511. _actionManager: ActionManager;
  9512. private _nextActiveAction;
  9513. private _child;
  9514. private _condition?;
  9515. private _triggerParameter;
  9516. /**
  9517. * An event triggered prior to action being executed.
  9518. */
  9519. onBeforeExecuteObservable: Observable<Action>;
  9520. /**
  9521. * Creates a new Action
  9522. * @param triggerOptions the trigger, with or without parameters, for the action
  9523. * @param condition an optional determinant of action
  9524. */
  9525. constructor(
  9526. /** the trigger, with or without parameters, for the action */
  9527. triggerOptions: any, condition?: Condition);
  9528. /**
  9529. * Internal only
  9530. * @hidden
  9531. */
  9532. _prepare(): void;
  9533. /**
  9534. * Gets the trigger parameters
  9535. * @returns the trigger parameters
  9536. */
  9537. getTriggerParameter(): any;
  9538. /**
  9539. * Internal only - executes current action event
  9540. * @hidden
  9541. */
  9542. _executeCurrent(evt?: ActionEvent): void;
  9543. /**
  9544. * Execute placeholder for child classes
  9545. * @param evt optional action event
  9546. */
  9547. execute(evt?: ActionEvent): void;
  9548. /**
  9549. * Skips to next active action
  9550. */
  9551. skipToNextActiveAction(): void;
  9552. /**
  9553. * Adds action to chain of actions, may be a DoNothingAction
  9554. * @param action defines the next action to execute
  9555. * @returns The action passed in
  9556. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9557. */
  9558. then(action: Action): Action;
  9559. /**
  9560. * Internal only
  9561. * @hidden
  9562. */
  9563. _getProperty(propertyPath: string): string;
  9564. /**
  9565. * Internal only
  9566. * @hidden
  9567. */
  9568. _getEffectiveTarget(target: any, propertyPath: string): any;
  9569. /**
  9570. * Serialize placeholder for child classes
  9571. * @param parent of child
  9572. * @returns the serialized object
  9573. */
  9574. serialize(parent: any): any;
  9575. /**
  9576. * Internal only called by serialize
  9577. * @hidden
  9578. */
  9579. protected _serialize(serializedAction: any, parent?: any): any;
  9580. /**
  9581. * Internal only
  9582. * @hidden
  9583. */
  9584. static _SerializeValueAsString: (value: any) => string;
  9585. /**
  9586. * Internal only
  9587. * @hidden
  9588. */
  9589. static _GetTargetProperty: (target: Scene | Node) => {
  9590. name: string;
  9591. targetType: string;
  9592. value: string;
  9593. };
  9594. }
  9595. }
  9596. declare module BABYLON {
  9597. /**
  9598. * A Condition applied to an Action
  9599. */
  9600. export class Condition {
  9601. /**
  9602. * Internal only - manager for action
  9603. * @hidden
  9604. */
  9605. _actionManager: ActionManager;
  9606. /**
  9607. * Internal only
  9608. * @hidden
  9609. */
  9610. _evaluationId: number;
  9611. /**
  9612. * Internal only
  9613. * @hidden
  9614. */
  9615. _currentResult: boolean;
  9616. /**
  9617. * Creates a new Condition
  9618. * @param actionManager the manager of the action the condition is applied to
  9619. */
  9620. constructor(actionManager: ActionManager);
  9621. /**
  9622. * Check if the current condition is valid
  9623. * @returns a boolean
  9624. */
  9625. isValid(): boolean;
  9626. /**
  9627. * Internal only
  9628. * @hidden
  9629. */
  9630. _getProperty(propertyPath: string): string;
  9631. /**
  9632. * Internal only
  9633. * @hidden
  9634. */
  9635. _getEffectiveTarget(target: any, propertyPath: string): any;
  9636. /**
  9637. * Serialize placeholder for child classes
  9638. * @returns the serialized object
  9639. */
  9640. serialize(): any;
  9641. /**
  9642. * Internal only
  9643. * @hidden
  9644. */
  9645. protected _serialize(serializedCondition: any): any;
  9646. }
  9647. /**
  9648. * Defines specific conditional operators as extensions of Condition
  9649. */
  9650. export class ValueCondition extends Condition {
  9651. /** path to specify the property of the target the conditional operator uses */
  9652. propertyPath: string;
  9653. /** the value compared by the conditional operator against the current value of the property */
  9654. value: any;
  9655. /** the conditional operator, default ValueCondition.IsEqual */
  9656. operator: number;
  9657. /**
  9658. * Internal only
  9659. * @hidden
  9660. */
  9661. private static _IsEqual;
  9662. /**
  9663. * Internal only
  9664. * @hidden
  9665. */
  9666. private static _IsDifferent;
  9667. /**
  9668. * Internal only
  9669. * @hidden
  9670. */
  9671. private static _IsGreater;
  9672. /**
  9673. * Internal only
  9674. * @hidden
  9675. */
  9676. private static _IsLesser;
  9677. /**
  9678. * returns the number for IsEqual
  9679. */
  9680. static get IsEqual(): number;
  9681. /**
  9682. * Returns the number for IsDifferent
  9683. */
  9684. static get IsDifferent(): number;
  9685. /**
  9686. * Returns the number for IsGreater
  9687. */
  9688. static get IsGreater(): number;
  9689. /**
  9690. * Returns the number for IsLesser
  9691. */
  9692. static get IsLesser(): number;
  9693. /**
  9694. * Internal only The action manager for the condition
  9695. * @hidden
  9696. */
  9697. _actionManager: ActionManager;
  9698. /**
  9699. * Internal only
  9700. * @hidden
  9701. */
  9702. private _target;
  9703. /**
  9704. * Internal only
  9705. * @hidden
  9706. */
  9707. private _effectiveTarget;
  9708. /**
  9709. * Internal only
  9710. * @hidden
  9711. */
  9712. private _property;
  9713. /**
  9714. * Creates a new ValueCondition
  9715. * @param actionManager manager for the action the condition applies to
  9716. * @param target for the action
  9717. * @param propertyPath path to specify the property of the target the conditional operator uses
  9718. * @param value the value compared by the conditional operator against the current value of the property
  9719. * @param operator the conditional operator, default ValueCondition.IsEqual
  9720. */
  9721. constructor(actionManager: ActionManager, target: any,
  9722. /** path to specify the property of the target the conditional operator uses */
  9723. propertyPath: string,
  9724. /** the value compared by the conditional operator against the current value of the property */
  9725. value: any,
  9726. /** the conditional operator, default ValueCondition.IsEqual */
  9727. operator?: number);
  9728. /**
  9729. * Compares the given value with the property value for the specified conditional operator
  9730. * @returns the result of the comparison
  9731. */
  9732. isValid(): boolean;
  9733. /**
  9734. * Serialize the ValueCondition into a JSON compatible object
  9735. * @returns serialization object
  9736. */
  9737. serialize(): any;
  9738. /**
  9739. * Gets the name of the conditional operator for the ValueCondition
  9740. * @param operator the conditional operator
  9741. * @returns the name
  9742. */
  9743. static GetOperatorName(operator: number): string;
  9744. }
  9745. /**
  9746. * Defines a predicate condition as an extension of Condition
  9747. */
  9748. export class PredicateCondition extends Condition {
  9749. /** defines the predicate function used to validate the condition */
  9750. predicate: () => boolean;
  9751. /**
  9752. * Internal only - manager for action
  9753. * @hidden
  9754. */
  9755. _actionManager: ActionManager;
  9756. /**
  9757. * Creates a new PredicateCondition
  9758. * @param actionManager manager for the action the condition applies to
  9759. * @param predicate defines the predicate function used to validate the condition
  9760. */
  9761. constructor(actionManager: ActionManager,
  9762. /** defines the predicate function used to validate the condition */
  9763. predicate: () => boolean);
  9764. /**
  9765. * @returns the validity of the predicate condition
  9766. */
  9767. isValid(): boolean;
  9768. }
  9769. /**
  9770. * Defines a state condition as an extension of Condition
  9771. */
  9772. export class StateCondition extends Condition {
  9773. /** Value to compare with target state */
  9774. value: string;
  9775. /**
  9776. * Internal only - manager for action
  9777. * @hidden
  9778. */
  9779. _actionManager: ActionManager;
  9780. /**
  9781. * Internal only
  9782. * @hidden
  9783. */
  9784. private _target;
  9785. /**
  9786. * Creates a new StateCondition
  9787. * @param actionManager manager for the action the condition applies to
  9788. * @param target of the condition
  9789. * @param value to compare with target state
  9790. */
  9791. constructor(actionManager: ActionManager, target: any,
  9792. /** Value to compare with target state */
  9793. value: string);
  9794. /**
  9795. * Gets a boolean indicating if the current condition is met
  9796. * @returns the validity of the state
  9797. */
  9798. isValid(): boolean;
  9799. /**
  9800. * Serialize the StateCondition into a JSON compatible object
  9801. * @returns serialization object
  9802. */
  9803. serialize(): any;
  9804. }
  9805. }
  9806. declare module BABYLON {
  9807. /**
  9808. * This defines an action responsible to toggle a boolean once triggered.
  9809. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9810. */
  9811. export class SwitchBooleanAction extends Action {
  9812. /**
  9813. * The path to the boolean property in the target object
  9814. */
  9815. propertyPath: string;
  9816. private _target;
  9817. private _effectiveTarget;
  9818. private _property;
  9819. /**
  9820. * Instantiate the action
  9821. * @param triggerOptions defines the trigger options
  9822. * @param target defines the object containing the boolean
  9823. * @param propertyPath defines the path to the boolean property in the target object
  9824. * @param condition defines the trigger related conditions
  9825. */
  9826. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9827. /** @hidden */
  9828. _prepare(): void;
  9829. /**
  9830. * Execute the action toggle the boolean value.
  9831. */
  9832. execute(): void;
  9833. /**
  9834. * Serializes the actions and its related information.
  9835. * @param parent defines the object to serialize in
  9836. * @returns the serialized object
  9837. */
  9838. serialize(parent: any): any;
  9839. }
  9840. /**
  9841. * This defines an action responsible to set a the state field of the target
  9842. * to a desired value once triggered.
  9843. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9844. */
  9845. export class SetStateAction extends Action {
  9846. /**
  9847. * The value to store in the state field.
  9848. */
  9849. value: string;
  9850. private _target;
  9851. /**
  9852. * Instantiate the action
  9853. * @param triggerOptions defines the trigger options
  9854. * @param target defines the object containing the state property
  9855. * @param value defines the value to store in the state field
  9856. * @param condition defines the trigger related conditions
  9857. */
  9858. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9859. /**
  9860. * Execute the action and store the value on the target state property.
  9861. */
  9862. execute(): void;
  9863. /**
  9864. * Serializes the actions and its related information.
  9865. * @param parent defines the object to serialize in
  9866. * @returns the serialized object
  9867. */
  9868. serialize(parent: any): any;
  9869. }
  9870. /**
  9871. * This defines an action responsible to set a property of the target
  9872. * to a desired value once triggered.
  9873. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9874. */
  9875. export class SetValueAction extends Action {
  9876. /**
  9877. * The path of the property to set in the target.
  9878. */
  9879. propertyPath: string;
  9880. /**
  9881. * The value to set in the property
  9882. */
  9883. value: any;
  9884. private _target;
  9885. private _effectiveTarget;
  9886. private _property;
  9887. /**
  9888. * Instantiate the action
  9889. * @param triggerOptions defines the trigger options
  9890. * @param target defines the object containing the property
  9891. * @param propertyPath defines the path of the property to set in the target
  9892. * @param value defines the value to set in the property
  9893. * @param condition defines the trigger related conditions
  9894. */
  9895. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9896. /** @hidden */
  9897. _prepare(): void;
  9898. /**
  9899. * Execute the action and set the targetted property to the desired value.
  9900. */
  9901. execute(): void;
  9902. /**
  9903. * Serializes the actions and its related information.
  9904. * @param parent defines the object to serialize in
  9905. * @returns the serialized object
  9906. */
  9907. serialize(parent: any): any;
  9908. }
  9909. /**
  9910. * This defines an action responsible to increment the target value
  9911. * to a desired value once triggered.
  9912. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9913. */
  9914. export class IncrementValueAction extends Action {
  9915. /**
  9916. * The path of the property to increment in the target.
  9917. */
  9918. propertyPath: string;
  9919. /**
  9920. * The value we should increment the property by.
  9921. */
  9922. value: any;
  9923. private _target;
  9924. private _effectiveTarget;
  9925. private _property;
  9926. /**
  9927. * Instantiate the action
  9928. * @param triggerOptions defines the trigger options
  9929. * @param target defines the object containing the property
  9930. * @param propertyPath defines the path of the property to increment in the target
  9931. * @param value defines the value value we should increment the property by
  9932. * @param condition defines the trigger related conditions
  9933. */
  9934. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9935. /** @hidden */
  9936. _prepare(): void;
  9937. /**
  9938. * Execute the action and increment the target of the value amount.
  9939. */
  9940. execute(): void;
  9941. /**
  9942. * Serializes the actions and its related information.
  9943. * @param parent defines the object to serialize in
  9944. * @returns the serialized object
  9945. */
  9946. serialize(parent: any): any;
  9947. }
  9948. /**
  9949. * This defines an action responsible to start an animation once triggered.
  9950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9951. */
  9952. export class PlayAnimationAction extends Action {
  9953. /**
  9954. * Where the animation should start (animation frame)
  9955. */
  9956. from: number;
  9957. /**
  9958. * Where the animation should stop (animation frame)
  9959. */
  9960. to: number;
  9961. /**
  9962. * Define if the animation should loop or stop after the first play.
  9963. */
  9964. loop?: boolean;
  9965. private _target;
  9966. /**
  9967. * Instantiate the action
  9968. * @param triggerOptions defines the trigger options
  9969. * @param target defines the target animation or animation name
  9970. * @param from defines from where the animation should start (animation frame)
  9971. * @param end defines where the animation should stop (animation frame)
  9972. * @param loop defines if the animation should loop or stop after the first play
  9973. * @param condition defines the trigger related conditions
  9974. */
  9975. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9976. /** @hidden */
  9977. _prepare(): void;
  9978. /**
  9979. * Execute the action and play the animation.
  9980. */
  9981. execute(): void;
  9982. /**
  9983. * Serializes the actions and its related information.
  9984. * @param parent defines the object to serialize in
  9985. * @returns the serialized object
  9986. */
  9987. serialize(parent: any): any;
  9988. }
  9989. /**
  9990. * This defines an action responsible to stop an animation once triggered.
  9991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9992. */
  9993. export class StopAnimationAction extends Action {
  9994. private _target;
  9995. /**
  9996. * Instantiate the action
  9997. * @param triggerOptions defines the trigger options
  9998. * @param target defines the target animation or animation name
  9999. * @param condition defines the trigger related conditions
  10000. */
  10001. constructor(triggerOptions: any, target: any, condition?: Condition);
  10002. /** @hidden */
  10003. _prepare(): void;
  10004. /**
  10005. * Execute the action and stop the animation.
  10006. */
  10007. execute(): void;
  10008. /**
  10009. * Serializes the actions and its related information.
  10010. * @param parent defines the object to serialize in
  10011. * @returns the serialized object
  10012. */
  10013. serialize(parent: any): any;
  10014. }
  10015. /**
  10016. * This defines an action responsible that does nothing once triggered.
  10017. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10018. */
  10019. export class DoNothingAction extends Action {
  10020. /**
  10021. * Instantiate the action
  10022. * @param triggerOptions defines the trigger options
  10023. * @param condition defines the trigger related conditions
  10024. */
  10025. constructor(triggerOptions?: any, condition?: Condition);
  10026. /**
  10027. * Execute the action and do nothing.
  10028. */
  10029. execute(): void;
  10030. /**
  10031. * Serializes the actions and its related information.
  10032. * @param parent defines the object to serialize in
  10033. * @returns the serialized object
  10034. */
  10035. serialize(parent: any): any;
  10036. }
  10037. /**
  10038. * This defines an action responsible to trigger several actions once triggered.
  10039. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10040. */
  10041. export class CombineAction extends Action {
  10042. /**
  10043. * The list of aggregated animations to run.
  10044. */
  10045. children: Action[];
  10046. /**
  10047. * Instantiate the action
  10048. * @param triggerOptions defines the trigger options
  10049. * @param children defines the list of aggregated animations to run
  10050. * @param condition defines the trigger related conditions
  10051. */
  10052. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10053. /** @hidden */
  10054. _prepare(): void;
  10055. /**
  10056. * Execute the action and executes all the aggregated actions.
  10057. */
  10058. execute(evt: ActionEvent): void;
  10059. /**
  10060. * Serializes the actions and its related information.
  10061. * @param parent defines the object to serialize in
  10062. * @returns the serialized object
  10063. */
  10064. serialize(parent: any): any;
  10065. }
  10066. /**
  10067. * This defines an action responsible to run code (external event) once triggered.
  10068. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10069. */
  10070. export class ExecuteCodeAction extends Action {
  10071. /**
  10072. * The callback function to run.
  10073. */
  10074. func: (evt: ActionEvent) => void;
  10075. /**
  10076. * Instantiate the action
  10077. * @param triggerOptions defines the trigger options
  10078. * @param func defines the callback function to run
  10079. * @param condition defines the trigger related conditions
  10080. */
  10081. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10082. /**
  10083. * Execute the action and run the attached code.
  10084. */
  10085. execute(evt: ActionEvent): void;
  10086. }
  10087. /**
  10088. * This defines an action responsible to set the parent property of the target once triggered.
  10089. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10090. */
  10091. export class SetParentAction extends Action {
  10092. private _parent;
  10093. private _target;
  10094. /**
  10095. * Instantiate the action
  10096. * @param triggerOptions defines the trigger options
  10097. * @param target defines the target containing the parent property
  10098. * @param parent defines from where the animation should start (animation frame)
  10099. * @param condition defines the trigger related conditions
  10100. */
  10101. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10102. /** @hidden */
  10103. _prepare(): void;
  10104. /**
  10105. * Execute the action and set the parent property.
  10106. */
  10107. execute(): void;
  10108. /**
  10109. * Serializes the actions and its related information.
  10110. * @param parent defines the object to serialize in
  10111. * @returns the serialized object
  10112. */
  10113. serialize(parent: any): any;
  10114. }
  10115. }
  10116. declare module BABYLON {
  10117. /**
  10118. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10119. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10120. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10121. */
  10122. export class ActionManager extends AbstractActionManager {
  10123. /**
  10124. * Nothing
  10125. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10126. */
  10127. static readonly NothingTrigger: number;
  10128. /**
  10129. * On pick
  10130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10131. */
  10132. static readonly OnPickTrigger: number;
  10133. /**
  10134. * On left pick
  10135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10136. */
  10137. static readonly OnLeftPickTrigger: number;
  10138. /**
  10139. * On right pick
  10140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10141. */
  10142. static readonly OnRightPickTrigger: number;
  10143. /**
  10144. * On center pick
  10145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10146. */
  10147. static readonly OnCenterPickTrigger: number;
  10148. /**
  10149. * On pick down
  10150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10151. */
  10152. static readonly OnPickDownTrigger: number;
  10153. /**
  10154. * On double pick
  10155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10156. */
  10157. static readonly OnDoublePickTrigger: number;
  10158. /**
  10159. * On pick up
  10160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10161. */
  10162. static readonly OnPickUpTrigger: number;
  10163. /**
  10164. * On pick out.
  10165. * This trigger will only be raised if you also declared a OnPickDown
  10166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10167. */
  10168. static readonly OnPickOutTrigger: number;
  10169. /**
  10170. * On long press
  10171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10172. */
  10173. static readonly OnLongPressTrigger: number;
  10174. /**
  10175. * On pointer over
  10176. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10177. */
  10178. static readonly OnPointerOverTrigger: number;
  10179. /**
  10180. * On pointer out
  10181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10182. */
  10183. static readonly OnPointerOutTrigger: number;
  10184. /**
  10185. * On every frame
  10186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10187. */
  10188. static readonly OnEveryFrameTrigger: number;
  10189. /**
  10190. * On intersection enter
  10191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10192. */
  10193. static readonly OnIntersectionEnterTrigger: number;
  10194. /**
  10195. * On intersection exit
  10196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10197. */
  10198. static readonly OnIntersectionExitTrigger: number;
  10199. /**
  10200. * On key down
  10201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10202. */
  10203. static readonly OnKeyDownTrigger: number;
  10204. /**
  10205. * On key up
  10206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10207. */
  10208. static readonly OnKeyUpTrigger: number;
  10209. private _scene;
  10210. /**
  10211. * Creates a new action manager
  10212. * @param scene defines the hosting scene
  10213. */
  10214. constructor(scene: Scene);
  10215. /**
  10216. * Releases all associated resources
  10217. */
  10218. dispose(): void;
  10219. /**
  10220. * Gets hosting scene
  10221. * @returns the hosting scene
  10222. */
  10223. getScene(): Scene;
  10224. /**
  10225. * Does this action manager handles actions of any of the given triggers
  10226. * @param triggers defines the triggers to be tested
  10227. * @return a boolean indicating whether one (or more) of the triggers is handled
  10228. */
  10229. hasSpecificTriggers(triggers: number[]): boolean;
  10230. /**
  10231. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10232. * speed.
  10233. * @param triggerA defines the trigger to be tested
  10234. * @param triggerB defines the trigger to be tested
  10235. * @return a boolean indicating whether one (or more) of the triggers is handled
  10236. */
  10237. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10238. /**
  10239. * Does this action manager handles actions of a given trigger
  10240. * @param trigger defines the trigger to be tested
  10241. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10242. * @return whether the trigger is handled
  10243. */
  10244. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10245. /**
  10246. * Does this action manager has pointer triggers
  10247. */
  10248. get hasPointerTriggers(): boolean;
  10249. /**
  10250. * Does this action manager has pick triggers
  10251. */
  10252. get hasPickTriggers(): boolean;
  10253. /**
  10254. * Registers an action to this action manager
  10255. * @param action defines the action to be registered
  10256. * @return the action amended (prepared) after registration
  10257. */
  10258. registerAction(action: IAction): Nullable<IAction>;
  10259. /**
  10260. * Unregisters an action to this action manager
  10261. * @param action defines the action to be unregistered
  10262. * @return a boolean indicating whether the action has been unregistered
  10263. */
  10264. unregisterAction(action: IAction): Boolean;
  10265. /**
  10266. * Process a specific trigger
  10267. * @param trigger defines the trigger to process
  10268. * @param evt defines the event details to be processed
  10269. */
  10270. processTrigger(trigger: number, evt?: IActionEvent): void;
  10271. /** @hidden */
  10272. _getEffectiveTarget(target: any, propertyPath: string): any;
  10273. /** @hidden */
  10274. _getProperty(propertyPath: string): string;
  10275. /**
  10276. * Serialize this manager to a JSON object
  10277. * @param name defines the property name to store this manager
  10278. * @returns a JSON representation of this manager
  10279. */
  10280. serialize(name: string): any;
  10281. /**
  10282. * Creates a new ActionManager from a JSON data
  10283. * @param parsedActions defines the JSON data to read from
  10284. * @param object defines the hosting mesh
  10285. * @param scene defines the hosting scene
  10286. */
  10287. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10288. /**
  10289. * Get a trigger name by index
  10290. * @param trigger defines the trigger index
  10291. * @returns a trigger name
  10292. */
  10293. static GetTriggerName(trigger: number): string;
  10294. }
  10295. }
  10296. declare module BABYLON {
  10297. /**
  10298. * Class used to represent a sprite
  10299. * @see https://doc.babylonjs.com/babylon101/sprites
  10300. */
  10301. export class Sprite implements IAnimatable {
  10302. /** defines the name */
  10303. name: string;
  10304. /** Gets or sets the current world position */
  10305. position: Vector3;
  10306. /** Gets or sets the main color */
  10307. color: Color4;
  10308. /** Gets or sets the width */
  10309. width: number;
  10310. /** Gets or sets the height */
  10311. height: number;
  10312. /** Gets or sets rotation angle */
  10313. angle: number;
  10314. /** Gets or sets the cell index in the sprite sheet */
  10315. cellIndex: number;
  10316. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10317. cellRef: string;
  10318. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10319. invertU: boolean;
  10320. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10321. invertV: boolean;
  10322. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10323. disposeWhenFinishedAnimating: boolean;
  10324. /** Gets the list of attached animations */
  10325. animations: Nullable<Array<Animation>>;
  10326. /** Gets or sets a boolean indicating if the sprite can be picked */
  10327. isPickable: boolean;
  10328. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10329. useAlphaForPicking: boolean;
  10330. /** @hidden */
  10331. _xOffset: number;
  10332. /** @hidden */
  10333. _yOffset: number;
  10334. /** @hidden */
  10335. _xSize: number;
  10336. /** @hidden */
  10337. _ySize: number;
  10338. /**
  10339. * Gets or sets the associated action manager
  10340. */
  10341. actionManager: Nullable<ActionManager>;
  10342. /**
  10343. * An event triggered when the control has been disposed
  10344. */
  10345. onDisposeObservable: Observable<Sprite>;
  10346. private _animationStarted;
  10347. private _loopAnimation;
  10348. private _fromIndex;
  10349. private _toIndex;
  10350. private _delay;
  10351. private _direction;
  10352. private _manager;
  10353. private _time;
  10354. private _onAnimationEnd;
  10355. /**
  10356. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10357. */
  10358. isVisible: boolean;
  10359. /**
  10360. * Gets or sets the sprite size
  10361. */
  10362. get size(): number;
  10363. set size(value: number);
  10364. /**
  10365. * Returns a boolean indicating if the animation is started
  10366. */
  10367. get animationStarted(): boolean;
  10368. /**
  10369. * Gets or sets the unique id of the sprite
  10370. */
  10371. uniqueId: number;
  10372. /**
  10373. * Gets the manager of this sprite
  10374. */
  10375. get manager(): ISpriteManager;
  10376. /**
  10377. * Creates a new Sprite
  10378. * @param name defines the name
  10379. * @param manager defines the manager
  10380. */
  10381. constructor(
  10382. /** defines the name */
  10383. name: string, manager: ISpriteManager);
  10384. /**
  10385. * Returns the string "Sprite"
  10386. * @returns "Sprite"
  10387. */
  10388. getClassName(): string;
  10389. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10390. get fromIndex(): number;
  10391. set fromIndex(value: number);
  10392. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10393. get toIndex(): number;
  10394. set toIndex(value: number);
  10395. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10396. get loopAnimation(): boolean;
  10397. set loopAnimation(value: boolean);
  10398. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10399. get delay(): number;
  10400. set delay(value: number);
  10401. /**
  10402. * Starts an animation
  10403. * @param from defines the initial key
  10404. * @param to defines the end key
  10405. * @param loop defines if the animation must loop
  10406. * @param delay defines the start delay (in ms)
  10407. * @param onAnimationEnd defines a callback to call when animation ends
  10408. */
  10409. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10410. /** Stops current animation (if any) */
  10411. stopAnimation(): void;
  10412. /** @hidden */
  10413. _animate(deltaTime: number): void;
  10414. /** Release associated resources */
  10415. dispose(): void;
  10416. /**
  10417. * Serializes the sprite to a JSON object
  10418. * @returns the JSON object
  10419. */
  10420. serialize(): any;
  10421. /**
  10422. * Parses a JSON object to create a new sprite
  10423. * @param parsedSprite The JSON object to parse
  10424. * @param manager defines the hosting manager
  10425. * @returns the new sprite
  10426. */
  10427. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10428. }
  10429. }
  10430. declare module BABYLON {
  10431. /**
  10432. * Information about the result of picking within a scene
  10433. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10434. */
  10435. export class PickingInfo {
  10436. /** @hidden */
  10437. _pickingUnavailable: boolean;
  10438. /**
  10439. * If the pick collided with an object
  10440. */
  10441. hit: boolean;
  10442. /**
  10443. * Distance away where the pick collided
  10444. */
  10445. distance: number;
  10446. /**
  10447. * The location of pick collision
  10448. */
  10449. pickedPoint: Nullable<Vector3>;
  10450. /**
  10451. * The mesh corresponding the the pick collision
  10452. */
  10453. pickedMesh: Nullable<AbstractMesh>;
  10454. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10455. bu: number;
  10456. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10457. bv: number;
  10458. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10459. faceId: number;
  10460. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10461. subMeshFaceId: number;
  10462. /** Id of the the submesh that was picked */
  10463. subMeshId: number;
  10464. /** If a sprite was picked, this will be the sprite the pick collided with */
  10465. pickedSprite: Nullable<Sprite>;
  10466. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10467. thinInstanceIndex: number;
  10468. /**
  10469. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10470. */
  10471. originMesh: Nullable<AbstractMesh>;
  10472. /**
  10473. * The ray that was used to perform the picking.
  10474. */
  10475. ray: Nullable<Ray>;
  10476. /**
  10477. * Gets the normal correspodning to the face the pick collided with
  10478. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10479. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10480. * @returns The normal correspodning to the face the pick collided with
  10481. */
  10482. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10483. /**
  10484. * Gets the texture coordinates of where the pick occured
  10485. * @returns the vector containing the coordnates of the texture
  10486. */
  10487. getTextureCoordinates(): Nullable<Vector2>;
  10488. }
  10489. }
  10490. declare module BABYLON {
  10491. /**
  10492. * Class representing a ray with position and direction
  10493. */
  10494. export class Ray {
  10495. /** origin point */
  10496. origin: Vector3;
  10497. /** direction */
  10498. direction: Vector3;
  10499. /** length of the ray */
  10500. length: number;
  10501. private static readonly _TmpVector3;
  10502. private _tmpRay;
  10503. /**
  10504. * Creates a new ray
  10505. * @param origin origin point
  10506. * @param direction direction
  10507. * @param length length of the ray
  10508. */
  10509. constructor(
  10510. /** origin point */
  10511. origin: Vector3,
  10512. /** direction */
  10513. direction: Vector3,
  10514. /** length of the ray */
  10515. length?: number);
  10516. /**
  10517. * Checks if the ray intersects a box
  10518. * This does not account for the ray lenght by design to improve perfs.
  10519. * @param minimum bound of the box
  10520. * @param maximum bound of the box
  10521. * @param intersectionTreshold extra extend to be added to the box in all direction
  10522. * @returns if the box was hit
  10523. */
  10524. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10525. /**
  10526. * Checks if the ray intersects a box
  10527. * This does not account for the ray lenght by design to improve perfs.
  10528. * @param box the bounding box to check
  10529. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10530. * @returns if the box was hit
  10531. */
  10532. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10533. /**
  10534. * If the ray hits a sphere
  10535. * @param sphere the bounding sphere to check
  10536. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10537. * @returns true if it hits the sphere
  10538. */
  10539. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10540. /**
  10541. * If the ray hits a triange
  10542. * @param vertex0 triangle vertex
  10543. * @param vertex1 triangle vertex
  10544. * @param vertex2 triangle vertex
  10545. * @returns intersection information if hit
  10546. */
  10547. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10548. /**
  10549. * Checks if ray intersects a plane
  10550. * @param plane the plane to check
  10551. * @returns the distance away it was hit
  10552. */
  10553. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10554. /**
  10555. * Calculate the intercept of a ray on a given axis
  10556. * @param axis to check 'x' | 'y' | 'z'
  10557. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10558. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10559. */
  10560. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10561. /**
  10562. * Checks if ray intersects a mesh
  10563. * @param mesh the mesh to check
  10564. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10565. * @returns picking info of the intersecton
  10566. */
  10567. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10568. /**
  10569. * Checks if ray intersects a mesh
  10570. * @param meshes the meshes to check
  10571. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10572. * @param results array to store result in
  10573. * @returns Array of picking infos
  10574. */
  10575. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10576. private _comparePickingInfo;
  10577. private static smallnum;
  10578. private static rayl;
  10579. /**
  10580. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10581. * @param sega the first point of the segment to test the intersection against
  10582. * @param segb the second point of the segment to test the intersection against
  10583. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10584. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10585. */
  10586. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10587. /**
  10588. * Update the ray from viewport position
  10589. * @param x position
  10590. * @param y y position
  10591. * @param viewportWidth viewport width
  10592. * @param viewportHeight viewport height
  10593. * @param world world matrix
  10594. * @param view view matrix
  10595. * @param projection projection matrix
  10596. * @returns this ray updated
  10597. */
  10598. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10599. /**
  10600. * Creates a ray with origin and direction of 0,0,0
  10601. * @returns the new ray
  10602. */
  10603. static Zero(): Ray;
  10604. /**
  10605. * Creates a new ray from screen space and viewport
  10606. * @param x position
  10607. * @param y y position
  10608. * @param viewportWidth viewport width
  10609. * @param viewportHeight viewport height
  10610. * @param world world matrix
  10611. * @param view view matrix
  10612. * @param projection projection matrix
  10613. * @returns new ray
  10614. */
  10615. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10616. /**
  10617. * 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
  10618. * transformed to the given world matrix.
  10619. * @param origin The origin point
  10620. * @param end The end point
  10621. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10622. * @returns the new ray
  10623. */
  10624. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10625. /**
  10626. * Transforms a ray by a matrix
  10627. * @param ray ray to transform
  10628. * @param matrix matrix to apply
  10629. * @returns the resulting new ray
  10630. */
  10631. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10632. /**
  10633. * Transforms a ray by a matrix
  10634. * @param ray ray to transform
  10635. * @param matrix matrix to apply
  10636. * @param result ray to store result in
  10637. */
  10638. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10639. /**
  10640. * Unproject a ray from screen space to object space
  10641. * @param sourceX defines the screen space x coordinate to use
  10642. * @param sourceY defines the screen space y coordinate to use
  10643. * @param viewportWidth defines the current width of the viewport
  10644. * @param viewportHeight defines the current height of the viewport
  10645. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10646. * @param view defines the view matrix to use
  10647. * @param projection defines the projection matrix to use
  10648. */
  10649. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10650. }
  10651. /**
  10652. * Type used to define predicate used to select faces when a mesh intersection is detected
  10653. */
  10654. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10655. interface Scene {
  10656. /** @hidden */
  10657. _tempPickingRay: Nullable<Ray>;
  10658. /** @hidden */
  10659. _cachedRayForTransform: Ray;
  10660. /** @hidden */
  10661. _pickWithRayInverseMatrix: Matrix;
  10662. /** @hidden */
  10663. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10664. /** @hidden */
  10665. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10666. /** @hidden */
  10667. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10668. }
  10669. }
  10670. declare module BABYLON {
  10671. /**
  10672. * Groups all the scene component constants in one place to ease maintenance.
  10673. * @hidden
  10674. */
  10675. export class SceneComponentConstants {
  10676. static readonly NAME_EFFECTLAYER: string;
  10677. static readonly NAME_LAYER: string;
  10678. static readonly NAME_LENSFLARESYSTEM: string;
  10679. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10680. static readonly NAME_PARTICLESYSTEM: string;
  10681. static readonly NAME_GAMEPAD: string;
  10682. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10683. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10684. static readonly NAME_PREPASSRENDERER: string;
  10685. static readonly NAME_DEPTHRENDERER: string;
  10686. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10687. static readonly NAME_SPRITE: string;
  10688. static readonly NAME_SUBSURFACE: string;
  10689. static readonly NAME_OUTLINERENDERER: string;
  10690. static readonly NAME_PROCEDURALTEXTURE: string;
  10691. static readonly NAME_SHADOWGENERATOR: string;
  10692. static readonly NAME_OCTREE: string;
  10693. static readonly NAME_PHYSICSENGINE: string;
  10694. static readonly NAME_AUDIO: string;
  10695. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10696. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10697. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10698. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10699. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10700. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10701. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10702. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10703. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10704. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10705. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10706. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10707. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10708. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10709. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10710. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10711. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10712. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10713. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10714. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10715. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10716. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10717. static readonly STEP_AFTERRENDER_AUDIO: number;
  10718. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10719. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10720. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10721. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10722. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10723. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10724. static readonly STEP_POINTERMOVE_SPRITE: number;
  10725. static readonly STEP_POINTERDOWN_SPRITE: number;
  10726. static readonly STEP_POINTERUP_SPRITE: number;
  10727. }
  10728. /**
  10729. * This represents a scene component.
  10730. *
  10731. * This is used to decouple the dependency the scene is having on the different workloads like
  10732. * layers, post processes...
  10733. */
  10734. export interface ISceneComponent {
  10735. /**
  10736. * The name of the component. Each component must have a unique name.
  10737. */
  10738. name: string;
  10739. /**
  10740. * The scene the component belongs to.
  10741. */
  10742. scene: Scene;
  10743. /**
  10744. * Register the component to one instance of a scene.
  10745. */
  10746. register(): void;
  10747. /**
  10748. * Rebuilds the elements related to this component in case of
  10749. * context lost for instance.
  10750. */
  10751. rebuild(): void;
  10752. /**
  10753. * Disposes the component and the associated ressources.
  10754. */
  10755. dispose(): void;
  10756. }
  10757. /**
  10758. * This represents a SERIALIZABLE scene component.
  10759. *
  10760. * This extends Scene Component to add Serialization methods on top.
  10761. */
  10762. export interface ISceneSerializableComponent extends ISceneComponent {
  10763. /**
  10764. * Adds all the elements from the container to the scene
  10765. * @param container the container holding the elements
  10766. */
  10767. addFromContainer(container: AbstractScene): void;
  10768. /**
  10769. * Removes all the elements in the container from the scene
  10770. * @param container contains the elements to remove
  10771. * @param dispose if the removed element should be disposed (default: false)
  10772. */
  10773. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10774. /**
  10775. * Serializes the component data to the specified json object
  10776. * @param serializationObject The object to serialize to
  10777. */
  10778. serialize(serializationObject: any): void;
  10779. }
  10780. /**
  10781. * Strong typing of a Mesh related stage step action
  10782. */
  10783. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10784. /**
  10785. * Strong typing of a Evaluate Sub Mesh related stage step action
  10786. */
  10787. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10788. /**
  10789. * Strong typing of a Active Mesh related stage step action
  10790. */
  10791. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10792. /**
  10793. * Strong typing of a Camera related stage step action
  10794. */
  10795. export type CameraStageAction = (camera: Camera) => void;
  10796. /**
  10797. * Strong typing of a Camera Frame buffer related stage step action
  10798. */
  10799. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10800. /**
  10801. * Strong typing of a Render Target related stage step action
  10802. */
  10803. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10804. /**
  10805. * Strong typing of a RenderingGroup related stage step action
  10806. */
  10807. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10808. /**
  10809. * Strong typing of a Mesh Render related stage step action
  10810. */
  10811. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10812. /**
  10813. * Strong typing of a simple stage step action
  10814. */
  10815. export type SimpleStageAction = () => void;
  10816. /**
  10817. * Strong typing of a render target action.
  10818. */
  10819. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10820. /**
  10821. * Strong typing of a pointer move action.
  10822. */
  10823. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10824. /**
  10825. * Strong typing of a pointer up/down action.
  10826. */
  10827. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10828. /**
  10829. * Representation of a stage in the scene (Basically a list of ordered steps)
  10830. * @hidden
  10831. */
  10832. export class Stage<T extends Function> extends Array<{
  10833. index: number;
  10834. component: ISceneComponent;
  10835. action: T;
  10836. }> {
  10837. /**
  10838. * Hide ctor from the rest of the world.
  10839. * @param items The items to add.
  10840. */
  10841. private constructor();
  10842. /**
  10843. * Creates a new Stage.
  10844. * @returns A new instance of a Stage
  10845. */
  10846. static Create<T extends Function>(): Stage<T>;
  10847. /**
  10848. * Registers a step in an ordered way in the targeted stage.
  10849. * @param index Defines the position to register the step in
  10850. * @param component Defines the component attached to the step
  10851. * @param action Defines the action to launch during the step
  10852. */
  10853. registerStep(index: number, component: ISceneComponent, action: T): void;
  10854. /**
  10855. * Clears all the steps from the stage.
  10856. */
  10857. clear(): void;
  10858. }
  10859. }
  10860. declare module BABYLON {
  10861. interface Scene {
  10862. /** @hidden */
  10863. _pointerOverSprite: Nullable<Sprite>;
  10864. /** @hidden */
  10865. _pickedDownSprite: Nullable<Sprite>;
  10866. /** @hidden */
  10867. _tempSpritePickingRay: Nullable<Ray>;
  10868. /**
  10869. * All of the sprite managers added to this scene
  10870. * @see https://doc.babylonjs.com/babylon101/sprites
  10871. */
  10872. spriteManagers: Array<ISpriteManager>;
  10873. /**
  10874. * An event triggered when sprites rendering is about to start
  10875. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10876. */
  10877. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10878. /**
  10879. * An event triggered when sprites rendering is done
  10880. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10881. */
  10882. onAfterSpritesRenderingObservable: Observable<Scene>;
  10883. /** @hidden */
  10884. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10885. /** Launch a ray to try to pick a sprite in the scene
  10886. * @param x position on screen
  10887. * @param y position on screen
  10888. * @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
  10889. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10890. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10891. * @returns a PickingInfo
  10892. */
  10893. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10894. /** Use the given ray to pick a sprite in the scene
  10895. * @param ray The ray (in world space) to use to pick meshes
  10896. * @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
  10897. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10898. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10899. * @returns a PickingInfo
  10900. */
  10901. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10902. /** @hidden */
  10903. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10904. /** Launch a ray to try to pick sprites in the scene
  10905. * @param x position on screen
  10906. * @param y position on screen
  10907. * @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
  10908. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10909. * @returns a PickingInfo array
  10910. */
  10911. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10912. /** Use the given ray to pick sprites in the scene
  10913. * @param ray The ray (in world space) to use to pick meshes
  10914. * @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
  10915. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10916. * @returns a PickingInfo array
  10917. */
  10918. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10919. /**
  10920. * Force the sprite under the pointer
  10921. * @param sprite defines the sprite to use
  10922. */
  10923. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10924. /**
  10925. * Gets the sprite under the pointer
  10926. * @returns a Sprite or null if no sprite is under the pointer
  10927. */
  10928. getPointerOverSprite(): Nullable<Sprite>;
  10929. }
  10930. /**
  10931. * Defines the sprite scene component responsible to manage sprites
  10932. * in a given scene.
  10933. */
  10934. export class SpriteSceneComponent implements ISceneComponent {
  10935. /**
  10936. * The component name helpfull to identify the component in the list of scene components.
  10937. */
  10938. readonly name: string;
  10939. /**
  10940. * The scene the component belongs to.
  10941. */
  10942. scene: Scene;
  10943. /** @hidden */
  10944. private _spritePredicate;
  10945. /**
  10946. * Creates a new instance of the component for the given scene
  10947. * @param scene Defines the scene to register the component in
  10948. */
  10949. constructor(scene: Scene);
  10950. /**
  10951. * Registers the component in a given scene
  10952. */
  10953. register(): void;
  10954. /**
  10955. * Rebuilds the elements related to this component in case of
  10956. * context lost for instance.
  10957. */
  10958. rebuild(): void;
  10959. /**
  10960. * Disposes the component and the associated ressources.
  10961. */
  10962. dispose(): void;
  10963. private _pickSpriteButKeepRay;
  10964. private _pointerMove;
  10965. private _pointerDown;
  10966. private _pointerUp;
  10967. }
  10968. }
  10969. declare module BABYLON {
  10970. /** @hidden */
  10971. export var fogFragmentDeclaration: {
  10972. name: string;
  10973. shader: string;
  10974. };
  10975. }
  10976. declare module BABYLON {
  10977. /** @hidden */
  10978. export var fogFragment: {
  10979. name: string;
  10980. shader: string;
  10981. };
  10982. }
  10983. declare module BABYLON {
  10984. /** @hidden */
  10985. export var imageProcessingCompatibility: {
  10986. name: string;
  10987. shader: string;
  10988. };
  10989. }
  10990. declare module BABYLON {
  10991. /** @hidden */
  10992. export var spritesPixelShader: {
  10993. name: string;
  10994. shader: string;
  10995. };
  10996. }
  10997. declare module BABYLON {
  10998. /** @hidden */
  10999. export var fogVertexDeclaration: {
  11000. name: string;
  11001. shader: string;
  11002. };
  11003. }
  11004. declare module BABYLON {
  11005. /** @hidden */
  11006. export var spritesVertexShader: {
  11007. name: string;
  11008. shader: string;
  11009. };
  11010. }
  11011. declare module BABYLON {
  11012. /**
  11013. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11014. */
  11015. export interface ISpriteManager extends IDisposable {
  11016. /**
  11017. * Gets manager's name
  11018. */
  11019. name: string;
  11020. /**
  11021. * Restricts the camera to viewing objects with the same layerMask.
  11022. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11023. */
  11024. layerMask: number;
  11025. /**
  11026. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11027. */
  11028. isPickable: boolean;
  11029. /**
  11030. * Gets the hosting scene
  11031. */
  11032. scene: Scene;
  11033. /**
  11034. * Specifies the rendering group id for this mesh (0 by default)
  11035. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11036. */
  11037. renderingGroupId: number;
  11038. /**
  11039. * Defines the list of sprites managed by the manager.
  11040. */
  11041. sprites: Array<Sprite>;
  11042. /**
  11043. * Gets or sets the spritesheet texture
  11044. */
  11045. texture: Texture;
  11046. /** Defines the default width of a cell in the spritesheet */
  11047. cellWidth: number;
  11048. /** Defines the default height of a cell in the spritesheet */
  11049. cellHeight: number;
  11050. /**
  11051. * Tests the intersection of a sprite with a specific ray.
  11052. * @param ray The ray we are sending to test the collision
  11053. * @param camera The camera space we are sending rays in
  11054. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11055. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11056. * @returns picking info or null.
  11057. */
  11058. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11059. /**
  11060. * Intersects the sprites with a ray
  11061. * @param ray defines the ray to intersect with
  11062. * @param camera defines the current active camera
  11063. * @param predicate defines a predicate used to select candidate sprites
  11064. * @returns null if no hit or a PickingInfo array
  11065. */
  11066. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11067. /**
  11068. * Renders the list of sprites on screen.
  11069. */
  11070. render(): void;
  11071. }
  11072. /**
  11073. * Class used to manage multiple sprites on the same spritesheet
  11074. * @see https://doc.babylonjs.com/babylon101/sprites
  11075. */
  11076. export class SpriteManager implements ISpriteManager {
  11077. /** defines the manager's name */
  11078. name: string;
  11079. /** Define the Url to load snippets */
  11080. static SnippetUrl: string;
  11081. /** Snippet ID if the manager was created from the snippet server */
  11082. snippetId: string;
  11083. /** Gets the list of sprites */
  11084. sprites: Sprite[];
  11085. /** Gets or sets the rendering group id (0 by default) */
  11086. renderingGroupId: number;
  11087. /** Gets or sets camera layer mask */
  11088. layerMask: number;
  11089. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11090. fogEnabled: boolean;
  11091. /** Gets or sets a boolean indicating if the sprites are pickable */
  11092. isPickable: boolean;
  11093. /** Defines the default width of a cell in the spritesheet */
  11094. cellWidth: number;
  11095. /** Defines the default height of a cell in the spritesheet */
  11096. cellHeight: number;
  11097. /** Associative array from JSON sprite data file */
  11098. private _cellData;
  11099. /** Array of sprite names from JSON sprite data file */
  11100. private _spriteMap;
  11101. /** True when packed cell data from JSON file is ready*/
  11102. private _packedAndReady;
  11103. private _textureContent;
  11104. private _useInstancing;
  11105. /**
  11106. * An event triggered when the manager is disposed.
  11107. */
  11108. onDisposeObservable: Observable<SpriteManager>;
  11109. private _onDisposeObserver;
  11110. /**
  11111. * Callback called when the manager is disposed
  11112. */
  11113. set onDispose(callback: () => void);
  11114. private _capacity;
  11115. private _fromPacked;
  11116. private _spriteTexture;
  11117. private _epsilon;
  11118. private _scene;
  11119. private _vertexData;
  11120. private _buffer;
  11121. private _vertexBuffers;
  11122. private _spriteBuffer;
  11123. private _indexBuffer;
  11124. private _effectBase;
  11125. private _effectFog;
  11126. private _vertexBufferSize;
  11127. /**
  11128. * Gets or sets the unique id of the sprite
  11129. */
  11130. uniqueId: number;
  11131. /**
  11132. * Gets the array of sprites
  11133. */
  11134. get children(): Sprite[];
  11135. /**
  11136. * Gets the hosting scene
  11137. */
  11138. get scene(): Scene;
  11139. /**
  11140. * Gets the capacity of the manager
  11141. */
  11142. get capacity(): number;
  11143. /**
  11144. * Gets or sets the spritesheet texture
  11145. */
  11146. get texture(): Texture;
  11147. set texture(value: Texture);
  11148. private _blendMode;
  11149. /**
  11150. * Blend mode use to render the particle, it can be any of
  11151. * the static Constants.ALPHA_x properties provided in this class.
  11152. * Default value is Constants.ALPHA_COMBINE
  11153. */
  11154. get blendMode(): number;
  11155. set blendMode(blendMode: number);
  11156. /** Disables writing to the depth buffer when rendering the sprites.
  11157. * It can be handy to disable depth writing when using textures without alpha channel
  11158. * and setting some specific blend modes.
  11159. */
  11160. disableDepthWrite: boolean;
  11161. /**
  11162. * Creates a new sprite manager
  11163. * @param name defines the manager's name
  11164. * @param imgUrl defines the sprite sheet url
  11165. * @param capacity defines the maximum allowed number of sprites
  11166. * @param cellSize defines the size of a sprite cell
  11167. * @param scene defines the hosting scene
  11168. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11169. * @param samplingMode defines the smapling mode to use with spritesheet
  11170. * @param fromPacked set to false; do not alter
  11171. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11172. */
  11173. constructor(
  11174. /** defines the manager's name */
  11175. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11176. /**
  11177. * Returns the string "SpriteManager"
  11178. * @returns "SpriteManager"
  11179. */
  11180. getClassName(): string;
  11181. private _makePacked;
  11182. private _appendSpriteVertex;
  11183. private _checkTextureAlpha;
  11184. /**
  11185. * Intersects the sprites with a ray
  11186. * @param ray defines the ray to intersect with
  11187. * @param camera defines the current active camera
  11188. * @param predicate defines a predicate used to select candidate sprites
  11189. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11190. * @returns null if no hit or a PickingInfo
  11191. */
  11192. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11193. /**
  11194. * Intersects the sprites with a ray
  11195. * @param ray defines the ray to intersect with
  11196. * @param camera defines the current active camera
  11197. * @param predicate defines a predicate used to select candidate sprites
  11198. * @returns null if no hit or a PickingInfo array
  11199. */
  11200. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11201. /**
  11202. * Render all child sprites
  11203. */
  11204. render(): void;
  11205. /**
  11206. * Release associated resources
  11207. */
  11208. dispose(): void;
  11209. /**
  11210. * Serializes the sprite manager to a JSON object
  11211. * @param serializeTexture defines if the texture must be serialized as well
  11212. * @returns the JSON object
  11213. */
  11214. serialize(serializeTexture?: boolean): any;
  11215. /**
  11216. * Parses a JSON object to create a new sprite manager.
  11217. * @param parsedManager The JSON object to parse
  11218. * @param scene The scene to create the sprite managerin
  11219. * @param rootUrl The root url to use to load external dependencies like texture
  11220. * @returns the new sprite manager
  11221. */
  11222. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11223. /**
  11224. * Creates a sprite manager from a snippet saved in a remote file
  11225. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11226. * @param url defines the url to load from
  11227. * @param scene defines the hosting scene
  11228. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11229. * @returns a promise that will resolve to the new sprite manager
  11230. */
  11231. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11232. /**
  11233. * Creates a sprite manager from a snippet saved by the sprite editor
  11234. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11235. * @param scene defines the hosting scene
  11236. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11237. * @returns a promise that will resolve to the new sprite manager
  11238. */
  11239. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11240. }
  11241. }
  11242. declare module BABYLON {
  11243. /** Interface used by value gradients (color, factor, ...) */
  11244. export interface IValueGradient {
  11245. /**
  11246. * Gets or sets the gradient value (between 0 and 1)
  11247. */
  11248. gradient: number;
  11249. }
  11250. /** Class used to store color4 gradient */
  11251. export class ColorGradient implements IValueGradient {
  11252. /**
  11253. * Gets or sets the gradient value (between 0 and 1)
  11254. */
  11255. gradient: number;
  11256. /**
  11257. * Gets or sets first associated color
  11258. */
  11259. color1: Color4;
  11260. /**
  11261. * Gets or sets second associated color
  11262. */
  11263. color2?: Color4 | undefined;
  11264. /**
  11265. * Creates a new color4 gradient
  11266. * @param gradient gets or sets the gradient value (between 0 and 1)
  11267. * @param color1 gets or sets first associated color
  11268. * @param color2 gets or sets first second color
  11269. */
  11270. constructor(
  11271. /**
  11272. * Gets or sets the gradient value (between 0 and 1)
  11273. */
  11274. gradient: number,
  11275. /**
  11276. * Gets or sets first associated color
  11277. */
  11278. color1: Color4,
  11279. /**
  11280. * Gets or sets second associated color
  11281. */
  11282. color2?: Color4 | undefined);
  11283. /**
  11284. * Will get a color picked randomly between color1 and color2.
  11285. * If color2 is undefined then color1 will be used
  11286. * @param result defines the target Color4 to store the result in
  11287. */
  11288. getColorToRef(result: Color4): void;
  11289. }
  11290. /** Class used to store color 3 gradient */
  11291. export class Color3Gradient implements IValueGradient {
  11292. /**
  11293. * Gets or sets the gradient value (between 0 and 1)
  11294. */
  11295. gradient: number;
  11296. /**
  11297. * Gets or sets the associated color
  11298. */
  11299. color: Color3;
  11300. /**
  11301. * Creates a new color3 gradient
  11302. * @param gradient gets or sets the gradient value (between 0 and 1)
  11303. * @param color gets or sets associated color
  11304. */
  11305. constructor(
  11306. /**
  11307. * Gets or sets the gradient value (between 0 and 1)
  11308. */
  11309. gradient: number,
  11310. /**
  11311. * Gets or sets the associated color
  11312. */
  11313. color: Color3);
  11314. }
  11315. /** Class used to store factor gradient */
  11316. export class FactorGradient implements IValueGradient {
  11317. /**
  11318. * Gets or sets the gradient value (between 0 and 1)
  11319. */
  11320. gradient: number;
  11321. /**
  11322. * Gets or sets first associated factor
  11323. */
  11324. factor1: number;
  11325. /**
  11326. * Gets or sets second associated factor
  11327. */
  11328. factor2?: number | undefined;
  11329. /**
  11330. * Creates a new factor gradient
  11331. * @param gradient gets or sets the gradient value (between 0 and 1)
  11332. * @param factor1 gets or sets first associated factor
  11333. * @param factor2 gets or sets second associated factor
  11334. */
  11335. constructor(
  11336. /**
  11337. * Gets or sets the gradient value (between 0 and 1)
  11338. */
  11339. gradient: number,
  11340. /**
  11341. * Gets or sets first associated factor
  11342. */
  11343. factor1: number,
  11344. /**
  11345. * Gets or sets second associated factor
  11346. */
  11347. factor2?: number | undefined);
  11348. /**
  11349. * Will get a number picked randomly between factor1 and factor2.
  11350. * If factor2 is undefined then factor1 will be used
  11351. * @returns the picked number
  11352. */
  11353. getFactor(): number;
  11354. }
  11355. /**
  11356. * Helper used to simplify some generic gradient tasks
  11357. */
  11358. export class GradientHelper {
  11359. /**
  11360. * Gets the current gradient from an array of IValueGradient
  11361. * @param ratio defines the current ratio to get
  11362. * @param gradients defines the array of IValueGradient
  11363. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11364. */
  11365. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11366. }
  11367. }
  11368. declare module BABYLON {
  11369. interface ThinEngine {
  11370. /**
  11371. * Creates a raw texture
  11372. * @param data defines the data to store in the texture
  11373. * @param width defines the width of the texture
  11374. * @param height defines the height of the texture
  11375. * @param format defines the format of the data
  11376. * @param generateMipMaps defines if the engine should generate the mip levels
  11377. * @param invertY defines if data must be stored with Y axis inverted
  11378. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11379. * @param compression defines the compression used (null by default)
  11380. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11381. * @returns the raw texture inside an InternalTexture
  11382. */
  11383. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11384. /**
  11385. * Update a raw texture
  11386. * @param texture defines the texture to update
  11387. * @param data defines the data to store in the texture
  11388. * @param format defines the format of the data
  11389. * @param invertY defines if data must be stored with Y axis inverted
  11390. */
  11391. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11392. /**
  11393. * Update a raw texture
  11394. * @param texture defines the texture to update
  11395. * @param data defines the data to store in the texture
  11396. * @param format defines the format of the data
  11397. * @param invertY defines if data must be stored with Y axis inverted
  11398. * @param compression defines the compression used (null by default)
  11399. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11400. */
  11401. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11402. /**
  11403. * Creates a new raw cube texture
  11404. * @param data defines the array of data to use to create each face
  11405. * @param size defines the size of the textures
  11406. * @param format defines the format of the data
  11407. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11408. * @param generateMipMaps defines if the engine should generate the mip levels
  11409. * @param invertY defines if data must be stored with Y axis inverted
  11410. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11411. * @param compression defines the compression used (null by default)
  11412. * @returns the cube texture as an InternalTexture
  11413. */
  11414. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11415. /**
  11416. * Update a raw cube texture
  11417. * @param texture defines the texture to udpdate
  11418. * @param data defines the data to store
  11419. * @param format defines the data format
  11420. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11421. * @param invertY defines if data must be stored with Y axis inverted
  11422. */
  11423. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11424. /**
  11425. * Update a raw cube texture
  11426. * @param texture defines the texture to udpdate
  11427. * @param data defines the data to store
  11428. * @param format defines the data format
  11429. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11430. * @param invertY defines if data must be stored with Y axis inverted
  11431. * @param compression defines the compression used (null by default)
  11432. */
  11433. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11434. /**
  11435. * Update a raw cube texture
  11436. * @param texture defines the texture to udpdate
  11437. * @param data defines the data to store
  11438. * @param format defines the data format
  11439. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. * @param compression defines the compression used (null by default)
  11442. * @param level defines which level of the texture to update
  11443. */
  11444. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11445. /**
  11446. * Creates a new raw cube texture from a specified url
  11447. * @param url defines the url where the data is located
  11448. * @param scene defines the current scene
  11449. * @param size defines the size of the textures
  11450. * @param format defines the format of the data
  11451. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11452. * @param noMipmap defines if the engine should avoid generating the mip levels
  11453. * @param callback defines a callback used to extract texture data from loaded data
  11454. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11455. * @param onLoad defines a callback called when texture is loaded
  11456. * @param onError defines a callback called if there is an error
  11457. * @returns the cube texture as an InternalTexture
  11458. */
  11459. 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;
  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. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11473. * @param invertY defines if data must be stored with Y axis inverted
  11474. * @returns the cube texture as an InternalTexture
  11475. */
  11476. 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;
  11477. /**
  11478. * Creates a new raw 3D texture
  11479. * @param data defines the data used to create the texture
  11480. * @param width defines the width of the texture
  11481. * @param height defines the height of the texture
  11482. * @param depth defines the depth of the texture
  11483. * @param format defines the format of the texture
  11484. * @param generateMipMaps defines if the engine must generate mip levels
  11485. * @param invertY defines if data must be stored with Y axis inverted
  11486. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11487. * @param compression defines the compressed used (can be null)
  11488. * @param textureType defines the compressed used (can be null)
  11489. * @returns a new raw 3D texture (stored in an InternalTexture)
  11490. */
  11491. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11492. /**
  11493. * Update a raw 3D texture
  11494. * @param texture defines the texture to update
  11495. * @param data defines the data to store
  11496. * @param format defines the data format
  11497. * @param invertY defines if data must be stored with Y axis inverted
  11498. */
  11499. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11500. /**
  11501. * Update a raw 3D texture
  11502. * @param texture defines the texture to update
  11503. * @param data defines the data to store
  11504. * @param format defines the data format
  11505. * @param invertY defines if data must be stored with Y axis inverted
  11506. * @param compression defines the used compression (can be null)
  11507. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11508. */
  11509. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11510. /**
  11511. * Creates a new raw 2D array texture
  11512. * @param data defines the data used to create the texture
  11513. * @param width defines the width of the texture
  11514. * @param height defines the height of the texture
  11515. * @param depth defines the number of layers of the texture
  11516. * @param format defines the format of the texture
  11517. * @param generateMipMaps defines if the engine must generate mip levels
  11518. * @param invertY defines if data must be stored with Y axis inverted
  11519. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11520. * @param compression defines the compressed used (can be null)
  11521. * @param textureType defines the compressed used (can be null)
  11522. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11523. */
  11524. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11525. /**
  11526. * Update a raw 2D array texture
  11527. * @param texture defines the texture to update
  11528. * @param data defines the data to store
  11529. * @param format defines the data format
  11530. * @param invertY defines if data must be stored with Y axis inverted
  11531. */
  11532. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11533. /**
  11534. * Update a raw 2D array texture
  11535. * @param texture defines the texture to update
  11536. * @param data defines the data to store
  11537. * @param format defines the data format
  11538. * @param invertY defines if data must be stored with Y axis inverted
  11539. * @param compression defines the used compression (can be null)
  11540. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11541. */
  11542. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11543. }
  11544. }
  11545. declare module BABYLON {
  11546. /**
  11547. * Raw texture can help creating a texture directly from an array of data.
  11548. * This can be super useful if you either get the data from an uncompressed source or
  11549. * if you wish to create your texture pixel by pixel.
  11550. */
  11551. export class RawTexture extends Texture {
  11552. /**
  11553. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11554. */
  11555. format: number;
  11556. /**
  11557. * Instantiates a new RawTexture.
  11558. * Raw texture can help creating a texture directly from an array of data.
  11559. * This can be super useful if you either get the data from an uncompressed source or
  11560. * if you wish to create your texture pixel by pixel.
  11561. * @param data define the array of data to use to create the texture
  11562. * @param width define the width of the texture
  11563. * @param height define the height of the texture
  11564. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11565. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11566. * @param generateMipMaps define whether mip maps should be generated or not
  11567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11569. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11570. */
  11571. constructor(data: ArrayBufferView, width: number, height: number,
  11572. /**
  11573. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11574. */
  11575. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11576. /**
  11577. * Updates the texture underlying data.
  11578. * @param data Define the new data of the texture
  11579. */
  11580. update(data: ArrayBufferView): void;
  11581. /**
  11582. * Creates a luminance texture from some data.
  11583. * @param data Define the texture data
  11584. * @param width Define the width of the texture
  11585. * @param height Define the height of the texture
  11586. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11587. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11588. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11589. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11590. * @returns the luminance texture
  11591. */
  11592. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11593. /**
  11594. * Creates a luminance alpha texture from some data.
  11595. * @param data Define the texture data
  11596. * @param width Define the width of the texture
  11597. * @param height Define the height of the texture
  11598. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11599. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11600. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11601. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11602. * @returns the luminance alpha texture
  11603. */
  11604. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11605. /**
  11606. * Creates an alpha texture from some data.
  11607. * @param data Define the texture data
  11608. * @param width Define the width of the texture
  11609. * @param height Define the height of the texture
  11610. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11611. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11612. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11613. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11614. * @returns the alpha texture
  11615. */
  11616. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11617. /**
  11618. * Creates a RGB texture from some data.
  11619. * @param data Define the texture data
  11620. * @param width Define the width of the texture
  11621. * @param height Define the height of the texture
  11622. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11623. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11624. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11625. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11626. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11627. * @returns the RGB alpha texture
  11628. */
  11629. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11630. /**
  11631. * Creates a RGBA texture from some data.
  11632. * @param data Define the texture data
  11633. * @param width Define the width of the texture
  11634. * @param height Define the height of the texture
  11635. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11636. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11637. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11638. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11639. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11640. * @returns the RGBA texture
  11641. */
  11642. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11643. /**
  11644. * Creates a R texture from some data.
  11645. * @param data Define the texture data
  11646. * @param width Define the width of the texture
  11647. * @param height Define the height of the texture
  11648. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11649. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11650. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11651. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11652. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11653. * @returns the R texture
  11654. */
  11655. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11656. }
  11657. }
  11658. declare module BABYLON {
  11659. interface ThinEngine {
  11660. /**
  11661. * Update a dynamic index buffer
  11662. * @param indexBuffer defines the target index buffer
  11663. * @param indices defines the data to update
  11664. * @param offset defines the offset in the target index buffer where update should start
  11665. */
  11666. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11667. /**
  11668. * Updates a dynamic vertex buffer.
  11669. * @param vertexBuffer the vertex buffer to update
  11670. * @param data the data used to update the vertex buffer
  11671. * @param byteOffset the byte offset of the data
  11672. * @param byteLength the byte length of the data
  11673. */
  11674. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11675. }
  11676. }
  11677. declare module BABYLON {
  11678. interface AbstractScene {
  11679. /**
  11680. * The list of procedural textures added to the scene
  11681. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11682. */
  11683. proceduralTextures: Array<ProceduralTexture>;
  11684. }
  11685. /**
  11686. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11687. * in a given scene.
  11688. */
  11689. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11690. /**
  11691. * The component name helpfull to identify the component in the list of scene components.
  11692. */
  11693. readonly name: string;
  11694. /**
  11695. * The scene the component belongs to.
  11696. */
  11697. scene: Scene;
  11698. /**
  11699. * Creates a new instance of the component for the given scene
  11700. * @param scene Defines the scene to register the component in
  11701. */
  11702. constructor(scene: Scene);
  11703. /**
  11704. * Registers the component in a given scene
  11705. */
  11706. register(): void;
  11707. /**
  11708. * Rebuilds the elements related to this component in case of
  11709. * context lost for instance.
  11710. */
  11711. rebuild(): void;
  11712. /**
  11713. * Disposes the component and the associated ressources.
  11714. */
  11715. dispose(): void;
  11716. private _beforeClear;
  11717. }
  11718. }
  11719. declare module BABYLON {
  11720. interface ThinEngine {
  11721. /**
  11722. * Creates a new render target cube texture
  11723. * @param size defines the size of the texture
  11724. * @param options defines the options used to create the texture
  11725. * @returns a new render target cube texture stored in an InternalTexture
  11726. */
  11727. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11728. }
  11729. }
  11730. declare module BABYLON {
  11731. /** @hidden */
  11732. export var proceduralVertexShader: {
  11733. name: string;
  11734. shader: string;
  11735. };
  11736. }
  11737. declare module BABYLON {
  11738. /**
  11739. * 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.
  11740. * This is the base class of any Procedural texture and contains most of the shareable code.
  11741. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11742. */
  11743. export class ProceduralTexture extends Texture {
  11744. /**
  11745. * Define if the texture is enabled or not (disabled texture will not render)
  11746. */
  11747. isEnabled: boolean;
  11748. /**
  11749. * Define if the texture must be cleared before rendering (default is true)
  11750. */
  11751. autoClear: boolean;
  11752. /**
  11753. * Callback called when the texture is generated
  11754. */
  11755. onGenerated: () => void;
  11756. /**
  11757. * Event raised when the texture is generated
  11758. */
  11759. onGeneratedObservable: Observable<ProceduralTexture>;
  11760. /**
  11761. * Event raised before the texture is generated
  11762. */
  11763. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11764. /**
  11765. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11766. */
  11767. nodeMaterialSource: Nullable<NodeMaterial>;
  11768. /** @hidden */
  11769. _generateMipMaps: boolean;
  11770. /** @hidden **/
  11771. _effect: Effect;
  11772. /** @hidden */
  11773. _textures: {
  11774. [key: string]: Texture;
  11775. };
  11776. /** @hidden */
  11777. protected _fallbackTexture: Nullable<Texture>;
  11778. private _size;
  11779. private _currentRefreshId;
  11780. private _frameId;
  11781. private _refreshRate;
  11782. private _vertexBuffers;
  11783. private _indexBuffer;
  11784. private _uniforms;
  11785. private _samplers;
  11786. private _fragment;
  11787. private _floats;
  11788. private _ints;
  11789. private _floatsArrays;
  11790. private _colors3;
  11791. private _colors4;
  11792. private _vectors2;
  11793. private _vectors3;
  11794. private _matrices;
  11795. private _fallbackTextureUsed;
  11796. private _fullEngine;
  11797. private _cachedDefines;
  11798. private _contentUpdateId;
  11799. private _contentData;
  11800. /**
  11801. * Instantiates a new procedural texture.
  11802. * 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.
  11803. * This is the base class of any Procedural texture and contains most of the shareable code.
  11804. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11805. * @param name Define the name of the texture
  11806. * @param size Define the size of the texture to create
  11807. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11808. * @param scene Define the scene the texture belongs to
  11809. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11810. * @param generateMipMaps Define if the texture should creates mip maps or not
  11811. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11812. * @param textureType The FBO internal texture type
  11813. */
  11814. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  11815. /**
  11816. * The effect that is created when initializing the post process.
  11817. * @returns The created effect corresponding the the postprocess.
  11818. */
  11819. getEffect(): Effect;
  11820. /**
  11821. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11822. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11823. */
  11824. getContent(): Nullable<ArrayBufferView>;
  11825. private _createIndexBuffer;
  11826. /** @hidden */
  11827. _rebuild(): void;
  11828. /**
  11829. * Resets the texture in order to recreate its associated resources.
  11830. * This can be called in case of context loss
  11831. */
  11832. reset(): void;
  11833. protected _getDefines(): string;
  11834. /**
  11835. * Is the texture ready to be used ? (rendered at least once)
  11836. * @returns true if ready, otherwise, false.
  11837. */
  11838. isReady(): boolean;
  11839. /**
  11840. * Resets the refresh counter of the texture and start bak from scratch.
  11841. * Could be useful to regenerate the texture if it is setup to render only once.
  11842. */
  11843. resetRefreshCounter(): void;
  11844. /**
  11845. * Set the fragment shader to use in order to render the texture.
  11846. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11847. */
  11848. setFragment(fragment: any): void;
  11849. /**
  11850. * Define the refresh rate of the texture or the rendering frequency.
  11851. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11852. */
  11853. get refreshRate(): number;
  11854. set refreshRate(value: number);
  11855. /** @hidden */
  11856. _shouldRender(): boolean;
  11857. /**
  11858. * Get the size the texture is rendering at.
  11859. * @returns the size (on cube texture it is always squared)
  11860. */
  11861. getRenderSize(): RenderTargetTextureSize;
  11862. /**
  11863. * Resize the texture to new value.
  11864. * @param size Define the new size the texture should have
  11865. * @param generateMipMaps Define whether the new texture should create mip maps
  11866. */
  11867. resize(size: number, generateMipMaps: boolean): void;
  11868. private _checkUniform;
  11869. /**
  11870. * Set a texture in the shader program used to render.
  11871. * @param name Define the name of the uniform samplers as defined in the shader
  11872. * @param texture Define the texture to bind to this sampler
  11873. * @return the texture itself allowing "fluent" like uniform updates
  11874. */
  11875. setTexture(name: string, texture: Texture): ProceduralTexture;
  11876. /**
  11877. * Set a float in the shader.
  11878. * @param name Define the name of the uniform as defined in the shader
  11879. * @param value Define the value to give to the uniform
  11880. * @return the texture itself allowing "fluent" like uniform updates
  11881. */
  11882. setFloat(name: string, value: number): ProceduralTexture;
  11883. /**
  11884. * Set a int in the shader.
  11885. * @param name Define the name of the uniform as defined in the shader
  11886. * @param value Define the value to give to the uniform
  11887. * @return the texture itself allowing "fluent" like uniform updates
  11888. */
  11889. setInt(name: string, value: number): ProceduralTexture;
  11890. /**
  11891. * Set an array of floats in the shader.
  11892. * @param name Define the name of the uniform as defined in the shader
  11893. * @param value Define the value to give to the uniform
  11894. * @return the texture itself allowing "fluent" like uniform updates
  11895. */
  11896. setFloats(name: string, value: number[]): ProceduralTexture;
  11897. /**
  11898. * Set a vec3 in the shader from a Color3.
  11899. * @param name Define the name of the uniform as defined in the shader
  11900. * @param value Define the value to give to the uniform
  11901. * @return the texture itself allowing "fluent" like uniform updates
  11902. */
  11903. setColor3(name: string, value: Color3): ProceduralTexture;
  11904. /**
  11905. * Set a vec4 in the shader from a Color4.
  11906. * @param name Define the name of the uniform as defined in the shader
  11907. * @param value Define the value to give to the uniform
  11908. * @return the texture itself allowing "fluent" like uniform updates
  11909. */
  11910. setColor4(name: string, value: Color4): ProceduralTexture;
  11911. /**
  11912. * Set a vec2 in the shader from a Vector2.
  11913. * @param name Define the name of the uniform as defined in the shader
  11914. * @param value Define the value to give to the uniform
  11915. * @return the texture itself allowing "fluent" like uniform updates
  11916. */
  11917. setVector2(name: string, value: Vector2): ProceduralTexture;
  11918. /**
  11919. * Set a vec3 in the shader from a Vector3.
  11920. * @param name Define the name of the uniform as defined in the shader
  11921. * @param value Define the value to give to the uniform
  11922. * @return the texture itself allowing "fluent" like uniform updates
  11923. */
  11924. setVector3(name: string, value: Vector3): ProceduralTexture;
  11925. /**
  11926. * Set a mat4 in the shader from a MAtrix.
  11927. * @param name Define the name of the uniform as defined in the shader
  11928. * @param value Define the value to give to the uniform
  11929. * @return the texture itself allowing "fluent" like uniform updates
  11930. */
  11931. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11932. /**
  11933. * Render the texture to its associated render target.
  11934. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11935. */
  11936. render(useCameraPostProcess?: boolean): void;
  11937. /**
  11938. * Clone the texture.
  11939. * @returns the cloned texture
  11940. */
  11941. clone(): ProceduralTexture;
  11942. /**
  11943. * Dispose the texture and release its asoociated resources.
  11944. */
  11945. dispose(): void;
  11946. }
  11947. }
  11948. declare module BABYLON {
  11949. /**
  11950. * This represents the base class for particle system in Babylon.
  11951. * 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.
  11952. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11953. * @example https://doc.babylonjs.com/babylon101/particles
  11954. */
  11955. export class BaseParticleSystem {
  11956. /**
  11957. * Source color is added to the destination color without alpha affecting the result
  11958. */
  11959. static BLENDMODE_ONEONE: number;
  11960. /**
  11961. * Blend current color and particle color using particle’s alpha
  11962. */
  11963. static BLENDMODE_STANDARD: number;
  11964. /**
  11965. * Add current color and particle color multiplied by particle’s alpha
  11966. */
  11967. static BLENDMODE_ADD: number;
  11968. /**
  11969. * Multiply current color with particle color
  11970. */
  11971. static BLENDMODE_MULTIPLY: number;
  11972. /**
  11973. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11974. */
  11975. static BLENDMODE_MULTIPLYADD: number;
  11976. /**
  11977. * List of animations used by the particle system.
  11978. */
  11979. animations: Animation[];
  11980. /**
  11981. * Gets or sets the unique id of the particle system
  11982. */
  11983. uniqueId: number;
  11984. /**
  11985. * The id of the Particle system.
  11986. */
  11987. id: string;
  11988. /**
  11989. * The friendly name of the Particle system.
  11990. */
  11991. name: string;
  11992. /**
  11993. * Snippet ID if the particle system was created from the snippet server
  11994. */
  11995. snippetId: string;
  11996. /**
  11997. * The rendering group used by the Particle system to chose when to render.
  11998. */
  11999. renderingGroupId: number;
  12000. /**
  12001. * The emitter represents the Mesh or position we are attaching the particle system to.
  12002. */
  12003. emitter: Nullable<AbstractMesh | Vector3>;
  12004. /**
  12005. * The maximum number of particles to emit per frame
  12006. */
  12007. emitRate: number;
  12008. /**
  12009. * If you want to launch only a few particles at once, that can be done, as well.
  12010. */
  12011. manualEmitCount: number;
  12012. /**
  12013. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12014. */
  12015. updateSpeed: number;
  12016. /**
  12017. * The amount of time the particle system is running (depends of the overall update speed).
  12018. */
  12019. targetStopDuration: number;
  12020. /**
  12021. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12022. */
  12023. disposeOnStop: boolean;
  12024. /**
  12025. * Minimum power of emitting particles.
  12026. */
  12027. minEmitPower: number;
  12028. /**
  12029. * Maximum power of emitting particles.
  12030. */
  12031. maxEmitPower: number;
  12032. /**
  12033. * Minimum life time of emitting particles.
  12034. */
  12035. minLifeTime: number;
  12036. /**
  12037. * Maximum life time of emitting particles.
  12038. */
  12039. maxLifeTime: number;
  12040. /**
  12041. * Minimum Size of emitting particles.
  12042. */
  12043. minSize: number;
  12044. /**
  12045. * Maximum Size of emitting particles.
  12046. */
  12047. maxSize: number;
  12048. /**
  12049. * Minimum scale of emitting particles on X axis.
  12050. */
  12051. minScaleX: number;
  12052. /**
  12053. * Maximum scale of emitting particles on X axis.
  12054. */
  12055. maxScaleX: number;
  12056. /**
  12057. * Minimum scale of emitting particles on Y axis.
  12058. */
  12059. minScaleY: number;
  12060. /**
  12061. * Maximum scale of emitting particles on Y axis.
  12062. */
  12063. maxScaleY: number;
  12064. /**
  12065. * Gets or sets the minimal initial rotation in radians.
  12066. */
  12067. minInitialRotation: number;
  12068. /**
  12069. * Gets or sets the maximal initial rotation in radians.
  12070. */
  12071. maxInitialRotation: number;
  12072. /**
  12073. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12074. */
  12075. minAngularSpeed: number;
  12076. /**
  12077. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12078. */
  12079. maxAngularSpeed: number;
  12080. /**
  12081. * The texture used to render each particle. (this can be a spritesheet)
  12082. */
  12083. particleTexture: Nullable<BaseTexture>;
  12084. /**
  12085. * The layer mask we are rendering the particles through.
  12086. */
  12087. layerMask: number;
  12088. /**
  12089. * This can help using your own shader to render the particle system.
  12090. * The according effect will be created
  12091. */
  12092. customShader: any;
  12093. /**
  12094. * By default particle system starts as soon as they are created. This prevents the
  12095. * automatic start to happen and let you decide when to start emitting particles.
  12096. */
  12097. preventAutoStart: boolean;
  12098. private _noiseTexture;
  12099. /**
  12100. * Gets or sets a texture used to add random noise to particle positions
  12101. */
  12102. get noiseTexture(): Nullable<ProceduralTexture>;
  12103. set noiseTexture(value: Nullable<ProceduralTexture>);
  12104. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12105. noiseStrength: Vector3;
  12106. /**
  12107. * Callback triggered when the particle animation is ending.
  12108. */
  12109. onAnimationEnd: Nullable<() => void>;
  12110. /**
  12111. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12112. */
  12113. blendMode: number;
  12114. /**
  12115. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12116. * to override the particles.
  12117. */
  12118. forceDepthWrite: boolean;
  12119. /** 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 */
  12120. preWarmCycles: number;
  12121. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12122. preWarmStepOffset: number;
  12123. /**
  12124. * 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)
  12125. */
  12126. spriteCellChangeSpeed: number;
  12127. /**
  12128. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12129. */
  12130. startSpriteCellID: number;
  12131. /**
  12132. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12133. */
  12134. endSpriteCellID: number;
  12135. /**
  12136. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12137. */
  12138. spriteCellWidth: number;
  12139. /**
  12140. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12141. */
  12142. spriteCellHeight: number;
  12143. /**
  12144. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12145. */
  12146. spriteRandomStartCell: boolean;
  12147. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12148. translationPivot: Vector2;
  12149. /** @hidden */
  12150. protected _isAnimationSheetEnabled: boolean;
  12151. /**
  12152. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12153. */
  12154. beginAnimationOnStart: boolean;
  12155. /**
  12156. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12157. */
  12158. beginAnimationFrom: number;
  12159. /**
  12160. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12161. */
  12162. beginAnimationTo: number;
  12163. /**
  12164. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12165. */
  12166. beginAnimationLoop: boolean;
  12167. /**
  12168. * Gets or sets a world offset applied to all particles
  12169. */
  12170. worldOffset: Vector3;
  12171. /**
  12172. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12173. */
  12174. get isAnimationSheetEnabled(): boolean;
  12175. set isAnimationSheetEnabled(value: boolean);
  12176. /**
  12177. * Get hosting scene
  12178. * @returns the scene
  12179. */
  12180. getScene(): Nullable<Scene>;
  12181. /**
  12182. * You can use gravity if you want to give an orientation to your particles.
  12183. */
  12184. gravity: Vector3;
  12185. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12186. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12187. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12188. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12189. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12190. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12191. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12192. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12193. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12194. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12195. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12196. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12197. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12198. /**
  12199. * Defines the delay in milliseconds before starting the system (0 by default)
  12200. */
  12201. startDelay: number;
  12202. /**
  12203. * Gets the current list of drag gradients.
  12204. * You must use addDragGradient and removeDragGradient to udpate this list
  12205. * @returns the list of drag gradients
  12206. */
  12207. getDragGradients(): Nullable<Array<FactorGradient>>;
  12208. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12209. limitVelocityDamping: number;
  12210. /**
  12211. * Gets the current list of limit velocity gradients.
  12212. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12213. * @returns the list of limit velocity gradients
  12214. */
  12215. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12216. /**
  12217. * Gets the current list of color gradients.
  12218. * You must use addColorGradient and removeColorGradient to udpate this list
  12219. * @returns the list of color gradients
  12220. */
  12221. getColorGradients(): Nullable<Array<ColorGradient>>;
  12222. /**
  12223. * Gets the current list of size gradients.
  12224. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12225. * @returns the list of size gradients
  12226. */
  12227. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12228. /**
  12229. * Gets the current list of color remap gradients.
  12230. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12231. * @returns the list of color remap gradients
  12232. */
  12233. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12234. /**
  12235. * Gets the current list of alpha remap gradients.
  12236. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12237. * @returns the list of alpha remap gradients
  12238. */
  12239. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12240. /**
  12241. * Gets the current list of life time gradients.
  12242. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12243. * @returns the list of life time gradients
  12244. */
  12245. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12246. /**
  12247. * Gets the current list of angular speed gradients.
  12248. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12249. * @returns the list of angular speed gradients
  12250. */
  12251. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12252. /**
  12253. * Gets the current list of velocity gradients.
  12254. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12255. * @returns the list of velocity gradients
  12256. */
  12257. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12258. /**
  12259. * Gets the current list of start size gradients.
  12260. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12261. * @returns the list of start size gradients
  12262. */
  12263. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12264. /**
  12265. * Gets the current list of emit rate gradients.
  12266. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12267. * @returns the list of emit rate gradients
  12268. */
  12269. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12270. /**
  12271. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12272. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12273. */
  12274. get direction1(): Vector3;
  12275. set direction1(value: Vector3);
  12276. /**
  12277. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12278. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12279. */
  12280. get direction2(): Vector3;
  12281. set direction2(value: Vector3);
  12282. /**
  12283. * 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.
  12284. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12285. */
  12286. get minEmitBox(): Vector3;
  12287. set minEmitBox(value: Vector3);
  12288. /**
  12289. * 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.
  12290. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12291. */
  12292. get maxEmitBox(): Vector3;
  12293. set maxEmitBox(value: Vector3);
  12294. /**
  12295. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12296. */
  12297. color1: Color4;
  12298. /**
  12299. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12300. */
  12301. color2: Color4;
  12302. /**
  12303. * Color the particle will have at the end of its lifetime
  12304. */
  12305. colorDead: Color4;
  12306. /**
  12307. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12308. */
  12309. textureMask: Color4;
  12310. /**
  12311. * The particle emitter type defines the emitter used by the particle system.
  12312. * It can be for example box, sphere, or cone...
  12313. */
  12314. particleEmitterType: IParticleEmitterType;
  12315. /** @hidden */
  12316. _isSubEmitter: boolean;
  12317. /**
  12318. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12319. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12320. */
  12321. billboardMode: number;
  12322. protected _isBillboardBased: boolean;
  12323. /**
  12324. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12325. */
  12326. get isBillboardBased(): boolean;
  12327. set isBillboardBased(value: boolean);
  12328. /**
  12329. * The scene the particle system belongs to.
  12330. */
  12331. protected _scene: Nullable<Scene>;
  12332. /**
  12333. * The engine the particle system belongs to.
  12334. */
  12335. protected _engine: ThinEngine;
  12336. /**
  12337. * Local cache of defines for image processing.
  12338. */
  12339. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12340. /**
  12341. * Default configuration related to image processing available in the standard Material.
  12342. */
  12343. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12344. /**
  12345. * Gets the image processing configuration used either in this material.
  12346. */
  12347. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12348. /**
  12349. * Sets the Default image processing configuration used either in the this material.
  12350. *
  12351. * If sets to null, the scene one is in use.
  12352. */
  12353. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12354. /**
  12355. * Attaches a new image processing configuration to the Standard Material.
  12356. * @param configuration
  12357. */
  12358. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12359. /** @hidden */
  12360. protected _reset(): void;
  12361. /** @hidden */
  12362. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12363. /**
  12364. * Instantiates a particle system.
  12365. * 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.
  12366. * @param name The name of the particle system
  12367. */
  12368. constructor(name: string);
  12369. /**
  12370. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12371. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12372. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12373. * @returns the emitter
  12374. */
  12375. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12376. /**
  12377. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12378. * @param radius The radius of the hemisphere to emit from
  12379. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12380. * @returns the emitter
  12381. */
  12382. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12383. /**
  12384. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12385. * @param radius The radius of the sphere to emit from
  12386. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12387. * @returns the emitter
  12388. */
  12389. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12390. /**
  12391. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12392. * @param radius The radius of the sphere to emit from
  12393. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12394. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12395. * @returns the emitter
  12396. */
  12397. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12398. /**
  12399. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12400. * @param radius The radius of the emission cylinder
  12401. * @param height The height of the emission cylinder
  12402. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12403. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12404. * @returns the emitter
  12405. */
  12406. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12407. /**
  12408. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12409. * @param radius The radius of the cylinder to emit from
  12410. * @param height The height of the emission cylinder
  12411. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12412. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12413. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12414. * @returns the emitter
  12415. */
  12416. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12417. /**
  12418. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12419. * @param radius The radius of the cone to emit from
  12420. * @param angle The base angle of the cone
  12421. * @returns the emitter
  12422. */
  12423. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12424. /**
  12425. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12426. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12427. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12428. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12429. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12430. * @returns the emitter
  12431. */
  12432. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12433. }
  12434. }
  12435. declare module BABYLON {
  12436. /**
  12437. * Type of sub emitter
  12438. */
  12439. export enum SubEmitterType {
  12440. /**
  12441. * Attached to the particle over it's lifetime
  12442. */
  12443. ATTACHED = 0,
  12444. /**
  12445. * Created when the particle dies
  12446. */
  12447. END = 1
  12448. }
  12449. /**
  12450. * Sub emitter class used to emit particles from an existing particle
  12451. */
  12452. export class SubEmitter {
  12453. /**
  12454. * the particle system to be used by the sub emitter
  12455. */
  12456. particleSystem: ParticleSystem;
  12457. /**
  12458. * Type of the submitter (Default: END)
  12459. */
  12460. type: SubEmitterType;
  12461. /**
  12462. * 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)
  12463. * Note: This only is supported when using an emitter of type Mesh
  12464. */
  12465. inheritDirection: boolean;
  12466. /**
  12467. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12468. */
  12469. inheritedVelocityAmount: number;
  12470. /**
  12471. * Creates a sub emitter
  12472. * @param particleSystem the particle system to be used by the sub emitter
  12473. */
  12474. constructor(
  12475. /**
  12476. * the particle system to be used by the sub emitter
  12477. */
  12478. particleSystem: ParticleSystem);
  12479. /**
  12480. * Clones the sub emitter
  12481. * @returns the cloned sub emitter
  12482. */
  12483. clone(): SubEmitter;
  12484. /**
  12485. * Serialize current object to a JSON object
  12486. * @returns the serialized object
  12487. */
  12488. serialize(): any;
  12489. /** @hidden */
  12490. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12491. /**
  12492. * Creates a new SubEmitter from a serialized JSON version
  12493. * @param serializationObject defines the JSON object to read from
  12494. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12495. * @param rootUrl defines the rootUrl for data loading
  12496. * @returns a new SubEmitter
  12497. */
  12498. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12499. /** Release associated resources */
  12500. dispose(): void;
  12501. }
  12502. }
  12503. declare module BABYLON {
  12504. /** @hidden */
  12505. export var imageProcessingDeclaration: {
  12506. name: string;
  12507. shader: string;
  12508. };
  12509. }
  12510. declare module BABYLON {
  12511. /** @hidden */
  12512. export var imageProcessingFunctions: {
  12513. name: string;
  12514. shader: string;
  12515. };
  12516. }
  12517. declare module BABYLON {
  12518. /** @hidden */
  12519. export var particlesPixelShader: {
  12520. name: string;
  12521. shader: string;
  12522. };
  12523. }
  12524. declare module BABYLON {
  12525. /** @hidden */
  12526. export var particlesVertexShader: {
  12527. name: string;
  12528. shader: string;
  12529. };
  12530. }
  12531. declare module BABYLON {
  12532. /**
  12533. * Interface used to define entities containing multiple clip planes
  12534. */
  12535. export interface IClipPlanesHolder {
  12536. /**
  12537. * Gets or sets the active clipplane 1
  12538. */
  12539. clipPlane: Nullable<Plane>;
  12540. /**
  12541. * Gets or sets the active clipplane 2
  12542. */
  12543. clipPlane2: Nullable<Plane>;
  12544. /**
  12545. * Gets or sets the active clipplane 3
  12546. */
  12547. clipPlane3: Nullable<Plane>;
  12548. /**
  12549. * Gets or sets the active clipplane 4
  12550. */
  12551. clipPlane4: Nullable<Plane>;
  12552. /**
  12553. * Gets or sets the active clipplane 5
  12554. */
  12555. clipPlane5: Nullable<Plane>;
  12556. /**
  12557. * Gets or sets the active clipplane 6
  12558. */
  12559. clipPlane6: Nullable<Plane>;
  12560. }
  12561. }
  12562. declare module BABYLON {
  12563. /**
  12564. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12565. *
  12566. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12567. *
  12568. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12569. */
  12570. export class ThinMaterialHelper {
  12571. /**
  12572. * Binds the clip plane information from the holder to the effect.
  12573. * @param effect The effect we are binding the data to
  12574. * @param holder The entity containing the clip plane information
  12575. */
  12576. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12577. }
  12578. }
  12579. declare module BABYLON {
  12580. interface ThinEngine {
  12581. /**
  12582. * Sets alpha constants used by some alpha blending modes
  12583. * @param r defines the red component
  12584. * @param g defines the green component
  12585. * @param b defines the blue component
  12586. * @param a defines the alpha component
  12587. */
  12588. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12589. /**
  12590. * Sets the current alpha mode
  12591. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12592. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12593. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12594. */
  12595. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12596. /**
  12597. * Gets the current alpha mode
  12598. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12599. * @returns the current alpha mode
  12600. */
  12601. getAlphaMode(): number;
  12602. /**
  12603. * Sets the current alpha equation
  12604. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12605. */
  12606. setAlphaEquation(equation: number): void;
  12607. /**
  12608. * Gets the current alpha equation.
  12609. * @returns the current alpha equation
  12610. */
  12611. getAlphaEquation(): number;
  12612. }
  12613. }
  12614. declare module BABYLON {
  12615. /**
  12616. * This represents a particle system in Babylon.
  12617. * 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.
  12618. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12619. * @example https://doc.babylonjs.com/babylon101/particles
  12620. */
  12621. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12622. /**
  12623. * Billboard mode will only apply to Y axis
  12624. */
  12625. static readonly BILLBOARDMODE_Y: number;
  12626. /**
  12627. * Billboard mode will apply to all axes
  12628. */
  12629. static readonly BILLBOARDMODE_ALL: number;
  12630. /**
  12631. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12632. */
  12633. static readonly BILLBOARDMODE_STRETCHED: number;
  12634. /**
  12635. * This function can be defined to provide custom update for active particles.
  12636. * This function will be called instead of regular update (age, position, color, etc.).
  12637. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12638. */
  12639. updateFunction: (particles: Particle[]) => void;
  12640. private _emitterWorldMatrix;
  12641. /**
  12642. * This function can be defined to specify initial direction for every new particle.
  12643. * It by default use the emitterType defined function
  12644. */
  12645. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12646. /**
  12647. * This function can be defined to specify initial position for every new particle.
  12648. * It by default use the emitterType defined function
  12649. */
  12650. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12651. /**
  12652. * @hidden
  12653. */
  12654. _inheritedVelocityOffset: Vector3;
  12655. /**
  12656. * An event triggered when the system is disposed
  12657. */
  12658. onDisposeObservable: Observable<IParticleSystem>;
  12659. /**
  12660. * An event triggered when the system is stopped
  12661. */
  12662. onStoppedObservable: Observable<IParticleSystem>;
  12663. private _onDisposeObserver;
  12664. /**
  12665. * Sets a callback that will be triggered when the system is disposed
  12666. */
  12667. set onDispose(callback: () => void);
  12668. private _particles;
  12669. private _epsilon;
  12670. private _capacity;
  12671. private _stockParticles;
  12672. private _newPartsExcess;
  12673. private _vertexData;
  12674. private _vertexBuffer;
  12675. private _vertexBuffers;
  12676. private _spriteBuffer;
  12677. private _indexBuffer;
  12678. private _effect;
  12679. private _customEffect;
  12680. private _cachedDefines;
  12681. private _scaledColorStep;
  12682. private _colorDiff;
  12683. private _scaledDirection;
  12684. private _scaledGravity;
  12685. private _currentRenderId;
  12686. private _alive;
  12687. private _useInstancing;
  12688. private _started;
  12689. private _stopped;
  12690. private _actualFrame;
  12691. private _scaledUpdateSpeed;
  12692. private _vertexBufferSize;
  12693. /** @hidden */
  12694. _currentEmitRateGradient: Nullable<FactorGradient>;
  12695. /** @hidden */
  12696. _currentEmitRate1: number;
  12697. /** @hidden */
  12698. _currentEmitRate2: number;
  12699. /** @hidden */
  12700. _currentStartSizeGradient: Nullable<FactorGradient>;
  12701. /** @hidden */
  12702. _currentStartSize1: number;
  12703. /** @hidden */
  12704. _currentStartSize2: number;
  12705. private readonly _rawTextureWidth;
  12706. private _rampGradientsTexture;
  12707. private _useRampGradients;
  12708. /** Gets or sets a matrix to use to compute projection */
  12709. defaultProjectionMatrix: Matrix;
  12710. /** Gets or sets a matrix to use to compute view */
  12711. defaultViewMatrix: Matrix;
  12712. /** Gets or sets a boolean indicating that ramp gradients must be used
  12713. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12714. */
  12715. get useRampGradients(): boolean;
  12716. set useRampGradients(value: boolean);
  12717. /**
  12718. * 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.
  12719. * 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: [])
  12720. */
  12721. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12722. private _subEmitters;
  12723. /**
  12724. * @hidden
  12725. * If the particle systems emitter should be disposed when the particle system is disposed
  12726. */
  12727. _disposeEmitterOnDispose: boolean;
  12728. /**
  12729. * The current active Sub-systems, this property is used by the root particle system only.
  12730. */
  12731. activeSubSystems: Array<ParticleSystem>;
  12732. /**
  12733. * Specifies if the particles are updated in emitter local space or world space
  12734. */
  12735. isLocal: boolean;
  12736. private _rootParticleSystem;
  12737. /**
  12738. * Gets the current list of active particles
  12739. */
  12740. get particles(): Particle[];
  12741. /**
  12742. * Gets the number of particles active at the same time.
  12743. * @returns The number of active particles.
  12744. */
  12745. getActiveCount(): number;
  12746. /**
  12747. * Returns the string "ParticleSystem"
  12748. * @returns a string containing the class name
  12749. */
  12750. getClassName(): string;
  12751. /**
  12752. * Gets a boolean indicating that the system is stopping
  12753. * @returns true if the system is currently stopping
  12754. */
  12755. isStopping(): boolean;
  12756. /**
  12757. * Gets the custom effect used to render the particles
  12758. * @param blendMode Blend mode for which the effect should be retrieved
  12759. * @returns The effect
  12760. */
  12761. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12762. /**
  12763. * Sets the custom effect used to render the particles
  12764. * @param effect The effect to set
  12765. * @param blendMode Blend mode for which the effect should be set
  12766. */
  12767. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12768. /** @hidden */
  12769. private _onBeforeDrawParticlesObservable;
  12770. /**
  12771. * Observable that will be called just before the particles are drawn
  12772. */
  12773. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12774. /**
  12775. * Gets the name of the particle vertex shader
  12776. */
  12777. get vertexShaderName(): string;
  12778. /**
  12779. * Instantiates a particle system.
  12780. * 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.
  12781. * @param name The name of the particle system
  12782. * @param capacity The max number of particles alive at the same time
  12783. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12784. * @param customEffect a custom effect used to change the way particles are rendered by default
  12785. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12786. * @param epsilon Offset used to render the particles
  12787. */
  12788. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12789. private _addFactorGradient;
  12790. private _removeFactorGradient;
  12791. /**
  12792. * Adds a new life time gradient
  12793. * @param gradient defines the gradient to use (between 0 and 1)
  12794. * @param factor defines the life time factor to affect to the specified gradient
  12795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12796. * @returns the current particle system
  12797. */
  12798. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12799. /**
  12800. * Remove a specific life time gradient
  12801. * @param gradient defines the gradient to remove
  12802. * @returns the current particle system
  12803. */
  12804. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12805. /**
  12806. * Adds a new size gradient
  12807. * @param gradient defines the gradient to use (between 0 and 1)
  12808. * @param factor defines the size factor to affect to the specified gradient
  12809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12810. * @returns the current particle system
  12811. */
  12812. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12813. /**
  12814. * Remove a specific size gradient
  12815. * @param gradient defines the gradient to remove
  12816. * @returns the current particle system
  12817. */
  12818. removeSizeGradient(gradient: number): IParticleSystem;
  12819. /**
  12820. * Adds a new color remap gradient
  12821. * @param gradient defines the gradient to use (between 0 and 1)
  12822. * @param min defines the color remap minimal range
  12823. * @param max defines the color remap maximal range
  12824. * @returns the current particle system
  12825. */
  12826. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12827. /**
  12828. * Remove a specific color remap gradient
  12829. * @param gradient defines the gradient to remove
  12830. * @returns the current particle system
  12831. */
  12832. removeColorRemapGradient(gradient: number): IParticleSystem;
  12833. /**
  12834. * Adds a new alpha remap gradient
  12835. * @param gradient defines the gradient to use (between 0 and 1)
  12836. * @param min defines the alpha remap minimal range
  12837. * @param max defines the alpha remap maximal range
  12838. * @returns the current particle system
  12839. */
  12840. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12841. /**
  12842. * Remove a specific alpha remap gradient
  12843. * @param gradient defines the gradient to remove
  12844. * @returns the current particle system
  12845. */
  12846. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12847. /**
  12848. * Adds a new angular speed gradient
  12849. * @param gradient defines the gradient to use (between 0 and 1)
  12850. * @param factor defines the angular speed to affect to the specified gradient
  12851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12852. * @returns the current particle system
  12853. */
  12854. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12855. /**
  12856. * Remove a specific angular speed gradient
  12857. * @param gradient defines the gradient to remove
  12858. * @returns the current particle system
  12859. */
  12860. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12861. /**
  12862. * Adds a new velocity gradient
  12863. * @param gradient defines the gradient to use (between 0 and 1)
  12864. * @param factor defines the velocity to affect to the specified gradient
  12865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12866. * @returns the current particle system
  12867. */
  12868. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12869. /**
  12870. * Remove a specific velocity gradient
  12871. * @param gradient defines the gradient to remove
  12872. * @returns the current particle system
  12873. */
  12874. removeVelocityGradient(gradient: number): IParticleSystem;
  12875. /**
  12876. * Adds a new limit velocity gradient
  12877. * @param gradient defines the gradient to use (between 0 and 1)
  12878. * @param factor defines the limit velocity value to affect to the specified gradient
  12879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12880. * @returns the current particle system
  12881. */
  12882. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12883. /**
  12884. * Remove a specific limit velocity gradient
  12885. * @param gradient defines the gradient to remove
  12886. * @returns the current particle system
  12887. */
  12888. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12889. /**
  12890. * Adds a new drag gradient
  12891. * @param gradient defines the gradient to use (between 0 and 1)
  12892. * @param factor defines the drag value to affect to the specified gradient
  12893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12894. * @returns the current particle system
  12895. */
  12896. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12897. /**
  12898. * Remove a specific drag gradient
  12899. * @param gradient defines the gradient to remove
  12900. * @returns the current particle system
  12901. */
  12902. removeDragGradient(gradient: number): IParticleSystem;
  12903. /**
  12904. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12905. * @param gradient defines the gradient to use (between 0 and 1)
  12906. * @param factor defines the emit rate value to affect to the specified gradient
  12907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12908. * @returns the current particle system
  12909. */
  12910. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12911. /**
  12912. * Remove a specific emit rate gradient
  12913. * @param gradient defines the gradient to remove
  12914. * @returns the current particle system
  12915. */
  12916. removeEmitRateGradient(gradient: number): IParticleSystem;
  12917. /**
  12918. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12919. * @param gradient defines the gradient to use (between 0 and 1)
  12920. * @param factor defines the start size value to affect to the specified gradient
  12921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12922. * @returns the current particle system
  12923. */
  12924. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12925. /**
  12926. * Remove a specific start size gradient
  12927. * @param gradient defines the gradient to remove
  12928. * @returns the current particle system
  12929. */
  12930. removeStartSizeGradient(gradient: number): IParticleSystem;
  12931. private _createRampGradientTexture;
  12932. /**
  12933. * Gets the current list of ramp gradients.
  12934. * You must use addRampGradient and removeRampGradient to udpate this list
  12935. * @returns the list of ramp gradients
  12936. */
  12937. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12938. /** Force the system to rebuild all gradients that need to be resync */
  12939. forceRefreshGradients(): void;
  12940. private _syncRampGradientTexture;
  12941. /**
  12942. * Adds a new ramp gradient used to remap particle colors
  12943. * @param gradient defines the gradient to use (between 0 and 1)
  12944. * @param color defines the color to affect to the specified gradient
  12945. * @returns the current particle system
  12946. */
  12947. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12948. /**
  12949. * Remove a specific ramp gradient
  12950. * @param gradient defines the gradient to remove
  12951. * @returns the current particle system
  12952. */
  12953. removeRampGradient(gradient: number): ParticleSystem;
  12954. /**
  12955. * Adds a new color gradient
  12956. * @param gradient defines the gradient to use (between 0 and 1)
  12957. * @param color1 defines the color to affect to the specified gradient
  12958. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12959. * @returns this particle system
  12960. */
  12961. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12962. /**
  12963. * Remove a specific color gradient
  12964. * @param gradient defines the gradient to remove
  12965. * @returns this particle system
  12966. */
  12967. removeColorGradient(gradient: number): IParticleSystem;
  12968. private _fetchR;
  12969. protected _reset(): void;
  12970. private _resetEffect;
  12971. private _createVertexBuffers;
  12972. private _createIndexBuffer;
  12973. /**
  12974. * Gets the maximum number of particles active at the same time.
  12975. * @returns The max number of active particles.
  12976. */
  12977. getCapacity(): number;
  12978. /**
  12979. * Gets whether there are still active particles in the system.
  12980. * @returns True if it is alive, otherwise false.
  12981. */
  12982. isAlive(): boolean;
  12983. /**
  12984. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12985. * @returns True if it has been started, otherwise false.
  12986. */
  12987. isStarted(): boolean;
  12988. private _prepareSubEmitterInternalArray;
  12989. /**
  12990. * Starts the particle system and begins to emit
  12991. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12992. */
  12993. start(delay?: number): void;
  12994. /**
  12995. * Stops the particle system.
  12996. * @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.
  12997. */
  12998. stop(stopSubEmitters?: boolean): void;
  12999. /**
  13000. * Remove all active particles
  13001. */
  13002. reset(): void;
  13003. /**
  13004. * @hidden (for internal use only)
  13005. */
  13006. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13007. /**
  13008. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13009. * Its lifetime will start back at 0.
  13010. */
  13011. recycleParticle: (particle: Particle) => void;
  13012. private _stopSubEmitters;
  13013. private _createParticle;
  13014. private _removeFromRoot;
  13015. private _emitFromParticle;
  13016. private _update;
  13017. /** @hidden */
  13018. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13019. /** @hidden */
  13020. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13021. /**
  13022. * Fill the defines array according to the current settings of the particle system
  13023. * @param defines Array to be updated
  13024. * @param blendMode blend mode to take into account when updating the array
  13025. */
  13026. fillDefines(defines: Array<string>, blendMode: number): void;
  13027. /**
  13028. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13029. * @param uniforms Uniforms array to fill
  13030. * @param attributes Attributes array to fill
  13031. * @param samplers Samplers array to fill
  13032. */
  13033. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13034. /** @hidden */
  13035. private _getEffect;
  13036. /**
  13037. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13038. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13039. */
  13040. animate(preWarmOnly?: boolean): void;
  13041. private _appendParticleVertices;
  13042. /**
  13043. * Rebuilds the particle system.
  13044. */
  13045. rebuild(): void;
  13046. /**
  13047. * Is this system ready to be used/rendered
  13048. * @return true if the system is ready
  13049. */
  13050. isReady(): boolean;
  13051. private _render;
  13052. /**
  13053. * Renders the particle system in its current state.
  13054. * @returns the current number of particles
  13055. */
  13056. render(): number;
  13057. /**
  13058. * Disposes the particle system and free the associated resources
  13059. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13060. */
  13061. dispose(disposeTexture?: boolean): void;
  13062. /**
  13063. * Clones the particle system.
  13064. * @param name The name of the cloned object
  13065. * @param newEmitter The new emitter to use
  13066. * @returns the cloned particle system
  13067. */
  13068. clone(name: string, newEmitter: any): ParticleSystem;
  13069. /**
  13070. * Serializes the particle system to a JSON object
  13071. * @param serializeTexture defines if the texture must be serialized as well
  13072. * @returns the JSON object
  13073. */
  13074. serialize(serializeTexture?: boolean): any;
  13075. /** @hidden */
  13076. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13077. /** @hidden */
  13078. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13079. /**
  13080. * Parses a JSON object to create a particle system.
  13081. * @param parsedParticleSystem The JSON object to parse
  13082. * @param sceneOrEngine The scene or the engine to create the particle system in
  13083. * @param rootUrl The root url to use to load external dependencies like texture
  13084. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13085. * @returns the Parsed particle system
  13086. */
  13087. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13088. }
  13089. }
  13090. declare module BABYLON {
  13091. /**
  13092. * A particle represents one of the element emitted by a particle system.
  13093. * This is mainly define by its coordinates, direction, velocity and age.
  13094. */
  13095. export class Particle {
  13096. /**
  13097. * The particle system the particle belongs to.
  13098. */
  13099. particleSystem: ParticleSystem;
  13100. private static _Count;
  13101. /**
  13102. * Unique ID of the particle
  13103. */
  13104. id: number;
  13105. /**
  13106. * The world position of the particle in the scene.
  13107. */
  13108. position: Vector3;
  13109. /**
  13110. * The world direction of the particle in the scene.
  13111. */
  13112. direction: Vector3;
  13113. /**
  13114. * The color of the particle.
  13115. */
  13116. color: Color4;
  13117. /**
  13118. * The color change of the particle per step.
  13119. */
  13120. colorStep: Color4;
  13121. /**
  13122. * Defines how long will the life of the particle be.
  13123. */
  13124. lifeTime: number;
  13125. /**
  13126. * The current age of the particle.
  13127. */
  13128. age: number;
  13129. /**
  13130. * The current size of the particle.
  13131. */
  13132. size: number;
  13133. /**
  13134. * The current scale of the particle.
  13135. */
  13136. scale: Vector2;
  13137. /**
  13138. * The current angle of the particle.
  13139. */
  13140. angle: number;
  13141. /**
  13142. * Defines how fast is the angle changing.
  13143. */
  13144. angularSpeed: number;
  13145. /**
  13146. * Defines the cell index used by the particle to be rendered from a sprite.
  13147. */
  13148. cellIndex: number;
  13149. /**
  13150. * The information required to support color remapping
  13151. */
  13152. remapData: Vector4;
  13153. /** @hidden */
  13154. _randomCellOffset?: number;
  13155. /** @hidden */
  13156. _initialDirection: Nullable<Vector3>;
  13157. /** @hidden */
  13158. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13159. /** @hidden */
  13160. _initialStartSpriteCellID: number;
  13161. /** @hidden */
  13162. _initialEndSpriteCellID: number;
  13163. /** @hidden */
  13164. _currentColorGradient: Nullable<ColorGradient>;
  13165. /** @hidden */
  13166. _currentColor1: Color4;
  13167. /** @hidden */
  13168. _currentColor2: Color4;
  13169. /** @hidden */
  13170. _currentSizeGradient: Nullable<FactorGradient>;
  13171. /** @hidden */
  13172. _currentSize1: number;
  13173. /** @hidden */
  13174. _currentSize2: number;
  13175. /** @hidden */
  13176. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13177. /** @hidden */
  13178. _currentAngularSpeed1: number;
  13179. /** @hidden */
  13180. _currentAngularSpeed2: number;
  13181. /** @hidden */
  13182. _currentVelocityGradient: Nullable<FactorGradient>;
  13183. /** @hidden */
  13184. _currentVelocity1: number;
  13185. /** @hidden */
  13186. _currentVelocity2: number;
  13187. /** @hidden */
  13188. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13189. /** @hidden */
  13190. _currentLimitVelocity1: number;
  13191. /** @hidden */
  13192. _currentLimitVelocity2: number;
  13193. /** @hidden */
  13194. _currentDragGradient: Nullable<FactorGradient>;
  13195. /** @hidden */
  13196. _currentDrag1: number;
  13197. /** @hidden */
  13198. _currentDrag2: number;
  13199. /** @hidden */
  13200. _randomNoiseCoordinates1: Vector3;
  13201. /** @hidden */
  13202. _randomNoiseCoordinates2: Vector3;
  13203. /** @hidden */
  13204. _localPosition?: Vector3;
  13205. /**
  13206. * Creates a new instance Particle
  13207. * @param particleSystem the particle system the particle belongs to
  13208. */
  13209. constructor(
  13210. /**
  13211. * The particle system the particle belongs to.
  13212. */
  13213. particleSystem: ParticleSystem);
  13214. private updateCellInfoFromSystem;
  13215. /**
  13216. * Defines how the sprite cell index is updated for the particle
  13217. */
  13218. updateCellIndex(): void;
  13219. /** @hidden */
  13220. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13221. /** @hidden */
  13222. _inheritParticleInfoToSubEmitters(): void;
  13223. /** @hidden */
  13224. _reset(): void;
  13225. /**
  13226. * Copy the properties of particle to another one.
  13227. * @param other the particle to copy the information to.
  13228. */
  13229. copyTo(other: Particle): void;
  13230. }
  13231. }
  13232. declare module BABYLON {
  13233. /**
  13234. * Particle emitter represents a volume emitting particles.
  13235. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13236. */
  13237. export interface IParticleEmitterType {
  13238. /**
  13239. * Called by the particle System when the direction is computed for the created particle.
  13240. * @param worldMatrix is the world matrix of the particle system
  13241. * @param directionToUpdate is the direction vector to update with the result
  13242. * @param particle is the particle we are computed the direction for
  13243. * @param isLocal defines if the direction should be set in local space
  13244. */
  13245. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13246. /**
  13247. * Called by the particle System when the position is computed for the created particle.
  13248. * @param worldMatrix is the world matrix of the particle system
  13249. * @param positionToUpdate is the position vector to update with the result
  13250. * @param particle is the particle we are computed the position for
  13251. * @param isLocal defines if the position should be set in local space
  13252. */
  13253. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13254. /**
  13255. * Clones the current emitter and returns a copy of it
  13256. * @returns the new emitter
  13257. */
  13258. clone(): IParticleEmitterType;
  13259. /**
  13260. * Called by the GPUParticleSystem to setup the update shader
  13261. * @param effect defines the update shader
  13262. */
  13263. applyToShader(effect: Effect): void;
  13264. /**
  13265. * Returns a string to use to update the GPU particles update shader
  13266. * @returns the effect defines string
  13267. */
  13268. getEffectDefines(): string;
  13269. /**
  13270. * Returns a string representing the class name
  13271. * @returns a string containing the class name
  13272. */
  13273. getClassName(): string;
  13274. /**
  13275. * Serializes the particle system to a JSON object.
  13276. * @returns the JSON object
  13277. */
  13278. serialize(): any;
  13279. /**
  13280. * Parse properties from a JSON object
  13281. * @param serializationObject defines the JSON object
  13282. * @param scene defines the hosting scene
  13283. */
  13284. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13285. }
  13286. }
  13287. declare module BABYLON {
  13288. /**
  13289. * Particle emitter emitting particles from the inside of a box.
  13290. * It emits the particles randomly between 2 given directions.
  13291. */
  13292. export class BoxParticleEmitter implements IParticleEmitterType {
  13293. /**
  13294. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13295. */
  13296. direction1: Vector3;
  13297. /**
  13298. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13299. */
  13300. direction2: Vector3;
  13301. /**
  13302. * 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.
  13303. */
  13304. minEmitBox: Vector3;
  13305. /**
  13306. * 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.
  13307. */
  13308. maxEmitBox: Vector3;
  13309. /**
  13310. * Creates a new instance BoxParticleEmitter
  13311. */
  13312. constructor();
  13313. /**
  13314. * Called by the particle System when the direction is computed for the created particle.
  13315. * @param worldMatrix is the world matrix of the particle system
  13316. * @param directionToUpdate is the direction vector to update with the result
  13317. * @param particle is the particle we are computed the direction for
  13318. * @param isLocal defines if the direction should be set in local space
  13319. */
  13320. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13321. /**
  13322. * Called by the particle System when the position is computed for the created particle.
  13323. * @param worldMatrix is the world matrix of the particle system
  13324. * @param positionToUpdate is the position vector to update with the result
  13325. * @param particle is the particle we are computed the position for
  13326. * @param isLocal defines if the position should be set in local space
  13327. */
  13328. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13329. /**
  13330. * Clones the current emitter and returns a copy of it
  13331. * @returns the new emitter
  13332. */
  13333. clone(): BoxParticleEmitter;
  13334. /**
  13335. * Called by the GPUParticleSystem to setup the update shader
  13336. * @param effect defines the update shader
  13337. */
  13338. applyToShader(effect: Effect): void;
  13339. /**
  13340. * Returns a string to use to update the GPU particles update shader
  13341. * @returns a string containng the defines string
  13342. */
  13343. getEffectDefines(): string;
  13344. /**
  13345. * Returns the string "BoxParticleEmitter"
  13346. * @returns a string containing the class name
  13347. */
  13348. getClassName(): string;
  13349. /**
  13350. * Serializes the particle system to a JSON object.
  13351. * @returns the JSON object
  13352. */
  13353. serialize(): any;
  13354. /**
  13355. * Parse properties from a JSON object
  13356. * @param serializationObject defines the JSON object
  13357. */
  13358. parse(serializationObject: any): void;
  13359. }
  13360. }
  13361. declare module BABYLON {
  13362. /**
  13363. * Particle emitter emitting particles from the inside of a cone.
  13364. * It emits the particles alongside the cone volume from the base to the particle.
  13365. * The emission direction might be randomized.
  13366. */
  13367. export class ConeParticleEmitter implements IParticleEmitterType {
  13368. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13369. directionRandomizer: number;
  13370. private _radius;
  13371. private _angle;
  13372. private _height;
  13373. /**
  13374. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13375. */
  13376. radiusRange: number;
  13377. /**
  13378. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13379. */
  13380. heightRange: number;
  13381. /**
  13382. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13383. */
  13384. emitFromSpawnPointOnly: boolean;
  13385. /**
  13386. * Gets or sets the radius of the emission cone
  13387. */
  13388. get radius(): number;
  13389. set radius(value: number);
  13390. /**
  13391. * Gets or sets the angle of the emission cone
  13392. */
  13393. get angle(): number;
  13394. set angle(value: number);
  13395. private _buildHeight;
  13396. /**
  13397. * Creates a new instance ConeParticleEmitter
  13398. * @param radius the radius of the emission cone (1 by default)
  13399. * @param angle the cone base angle (PI by default)
  13400. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13401. */
  13402. constructor(radius?: number, angle?: number,
  13403. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13404. directionRandomizer?: number);
  13405. /**
  13406. * Called by the particle System when the direction is computed for the created particle.
  13407. * @param worldMatrix is the world matrix of the particle system
  13408. * @param directionToUpdate is the direction vector to update with the result
  13409. * @param particle is the particle we are computed the direction for
  13410. * @param isLocal defines if the direction should be set in local space
  13411. */
  13412. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13413. /**
  13414. * Called by the particle System when the position is computed for the created particle.
  13415. * @param worldMatrix is the world matrix of the particle system
  13416. * @param positionToUpdate is the position vector to update with the result
  13417. * @param particle is the particle we are computed the position for
  13418. * @param isLocal defines if the position should be set in local space
  13419. */
  13420. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13421. /**
  13422. * Clones the current emitter and returns a copy of it
  13423. * @returns the new emitter
  13424. */
  13425. clone(): ConeParticleEmitter;
  13426. /**
  13427. * Called by the GPUParticleSystem to setup the update shader
  13428. * @param effect defines the update shader
  13429. */
  13430. applyToShader(effect: Effect): void;
  13431. /**
  13432. * Returns a string to use to update the GPU particles update shader
  13433. * @returns a string containng the defines string
  13434. */
  13435. getEffectDefines(): string;
  13436. /**
  13437. * Returns the string "ConeParticleEmitter"
  13438. * @returns a string containing the class name
  13439. */
  13440. getClassName(): string;
  13441. /**
  13442. * Serializes the particle system to a JSON object.
  13443. * @returns the JSON object
  13444. */
  13445. serialize(): any;
  13446. /**
  13447. * Parse properties from a JSON object
  13448. * @param serializationObject defines the JSON object
  13449. */
  13450. parse(serializationObject: any): void;
  13451. }
  13452. }
  13453. declare module BABYLON {
  13454. /**
  13455. * Particle emitter emitting particles from the inside of a cylinder.
  13456. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13457. */
  13458. export class CylinderParticleEmitter implements IParticleEmitterType {
  13459. /**
  13460. * The radius of the emission cylinder.
  13461. */
  13462. radius: number;
  13463. /**
  13464. * The height of the emission cylinder.
  13465. */
  13466. height: number;
  13467. /**
  13468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13469. */
  13470. radiusRange: number;
  13471. /**
  13472. * How much to randomize the particle direction [0-1].
  13473. */
  13474. directionRandomizer: number;
  13475. /**
  13476. * Creates a new instance CylinderParticleEmitter
  13477. * @param radius the radius of the emission cylinder (1 by default)
  13478. * @param height the height of the emission cylinder (1 by default)
  13479. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13480. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13481. */
  13482. constructor(
  13483. /**
  13484. * The radius of the emission cylinder.
  13485. */
  13486. radius?: number,
  13487. /**
  13488. * The height of the emission cylinder.
  13489. */
  13490. height?: number,
  13491. /**
  13492. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13493. */
  13494. radiusRange?: number,
  13495. /**
  13496. * How much to randomize the particle direction [0-1].
  13497. */
  13498. directionRandomizer?: number);
  13499. /**
  13500. * Called by the particle System when the direction is computed for the created particle.
  13501. * @param worldMatrix is the world matrix of the particle system
  13502. * @param directionToUpdate is the direction vector to update with the result
  13503. * @param particle is the particle we are computed the direction for
  13504. * @param isLocal defines if the direction should be set in local space
  13505. */
  13506. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13507. /**
  13508. * Called by the particle System when the position is computed for the created particle.
  13509. * @param worldMatrix is the world matrix of the particle system
  13510. * @param positionToUpdate is the position vector to update with the result
  13511. * @param particle is the particle we are computed the position for
  13512. * @param isLocal defines if the position should be set in local space
  13513. */
  13514. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13515. /**
  13516. * Clones the current emitter and returns a copy of it
  13517. * @returns the new emitter
  13518. */
  13519. clone(): CylinderParticleEmitter;
  13520. /**
  13521. * Called by the GPUParticleSystem to setup the update shader
  13522. * @param effect defines the update shader
  13523. */
  13524. applyToShader(effect: Effect): void;
  13525. /**
  13526. * Returns a string to use to update the GPU particles update shader
  13527. * @returns a string containng the defines string
  13528. */
  13529. getEffectDefines(): string;
  13530. /**
  13531. * Returns the string "CylinderParticleEmitter"
  13532. * @returns a string containing the class name
  13533. */
  13534. getClassName(): string;
  13535. /**
  13536. * Serializes the particle system to a JSON object.
  13537. * @returns the JSON object
  13538. */
  13539. serialize(): any;
  13540. /**
  13541. * Parse properties from a JSON object
  13542. * @param serializationObject defines the JSON object
  13543. */
  13544. parse(serializationObject: any): void;
  13545. }
  13546. /**
  13547. * Particle emitter emitting particles from the inside of a cylinder.
  13548. * It emits the particles randomly between two vectors.
  13549. */
  13550. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13551. /**
  13552. * The min limit of the emission direction.
  13553. */
  13554. direction1: Vector3;
  13555. /**
  13556. * The max limit of the emission direction.
  13557. */
  13558. direction2: Vector3;
  13559. /**
  13560. * Creates a new instance CylinderDirectedParticleEmitter
  13561. * @param radius the radius of the emission cylinder (1 by default)
  13562. * @param height the height of the emission cylinder (1 by default)
  13563. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13564. * @param direction1 the min limit of the emission direction (up vector by default)
  13565. * @param direction2 the max limit of the emission direction (up vector by default)
  13566. */
  13567. constructor(radius?: number, height?: number, radiusRange?: number,
  13568. /**
  13569. * The min limit of the emission direction.
  13570. */
  13571. direction1?: Vector3,
  13572. /**
  13573. * The max limit of the emission direction.
  13574. */
  13575. direction2?: Vector3);
  13576. /**
  13577. * Called by the particle System when the direction is computed for the created particle.
  13578. * @param worldMatrix is the world matrix of the particle system
  13579. * @param directionToUpdate is the direction vector to update with the result
  13580. * @param particle is the particle we are computed the direction for
  13581. */
  13582. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13583. /**
  13584. * Clones the current emitter and returns a copy of it
  13585. * @returns the new emitter
  13586. */
  13587. clone(): CylinderDirectedParticleEmitter;
  13588. /**
  13589. * Called by the GPUParticleSystem to setup the update shader
  13590. * @param effect defines the update shader
  13591. */
  13592. applyToShader(effect: Effect): void;
  13593. /**
  13594. * Returns a string to use to update the GPU particles update shader
  13595. * @returns a string containng the defines string
  13596. */
  13597. getEffectDefines(): string;
  13598. /**
  13599. * Returns the string "CylinderDirectedParticleEmitter"
  13600. * @returns a string containing the class name
  13601. */
  13602. getClassName(): string;
  13603. /**
  13604. * Serializes the particle system to a JSON object.
  13605. * @returns the JSON object
  13606. */
  13607. serialize(): any;
  13608. /**
  13609. * Parse properties from a JSON object
  13610. * @param serializationObject defines the JSON object
  13611. */
  13612. parse(serializationObject: any): void;
  13613. }
  13614. }
  13615. declare module BABYLON {
  13616. /**
  13617. * Particle emitter emitting particles from the inside of a hemisphere.
  13618. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13619. */
  13620. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13621. /**
  13622. * The radius of the emission hemisphere.
  13623. */
  13624. radius: number;
  13625. /**
  13626. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13627. */
  13628. radiusRange: number;
  13629. /**
  13630. * How much to randomize the particle direction [0-1].
  13631. */
  13632. directionRandomizer: number;
  13633. /**
  13634. * Creates a new instance HemisphericParticleEmitter
  13635. * @param radius the radius of the emission hemisphere (1 by default)
  13636. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13637. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13638. */
  13639. constructor(
  13640. /**
  13641. * The radius of the emission hemisphere.
  13642. */
  13643. radius?: number,
  13644. /**
  13645. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13646. */
  13647. radiusRange?: number,
  13648. /**
  13649. * How much to randomize the particle direction [0-1].
  13650. */
  13651. directionRandomizer?: number);
  13652. /**
  13653. * Called by the particle System when the direction is computed for the created particle.
  13654. * @param worldMatrix is the world matrix of the particle system
  13655. * @param directionToUpdate is the direction vector to update with the result
  13656. * @param particle is the particle we are computed the direction for
  13657. * @param isLocal defines if the direction should be set in local space
  13658. */
  13659. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13660. /**
  13661. * Called by the particle System when the position is computed for the created particle.
  13662. * @param worldMatrix is the world matrix of the particle system
  13663. * @param positionToUpdate is the position vector to update with the result
  13664. * @param particle is the particle we are computed the position for
  13665. * @param isLocal defines if the position should be set in local space
  13666. */
  13667. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13668. /**
  13669. * Clones the current emitter and returns a copy of it
  13670. * @returns the new emitter
  13671. */
  13672. clone(): HemisphericParticleEmitter;
  13673. /**
  13674. * Called by the GPUParticleSystem to setup the update shader
  13675. * @param effect defines the update shader
  13676. */
  13677. applyToShader(effect: Effect): void;
  13678. /**
  13679. * Returns a string to use to update the GPU particles update shader
  13680. * @returns a string containng the defines string
  13681. */
  13682. getEffectDefines(): string;
  13683. /**
  13684. * Returns the string "HemisphericParticleEmitter"
  13685. * @returns a string containing the class name
  13686. */
  13687. getClassName(): string;
  13688. /**
  13689. * Serializes the particle system to a JSON object.
  13690. * @returns the JSON object
  13691. */
  13692. serialize(): any;
  13693. /**
  13694. * Parse properties from a JSON object
  13695. * @param serializationObject defines the JSON object
  13696. */
  13697. parse(serializationObject: any): void;
  13698. }
  13699. }
  13700. declare module BABYLON {
  13701. /**
  13702. * Particle emitter emitting particles from a point.
  13703. * It emits the particles randomly between 2 given directions.
  13704. */
  13705. export class PointParticleEmitter implements IParticleEmitterType {
  13706. /**
  13707. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13708. */
  13709. direction1: Vector3;
  13710. /**
  13711. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13712. */
  13713. direction2: Vector3;
  13714. /**
  13715. * Creates a new instance PointParticleEmitter
  13716. */
  13717. constructor();
  13718. /**
  13719. * Called by the particle System when the direction is computed for the created particle.
  13720. * @param worldMatrix is the world matrix of the particle system
  13721. * @param directionToUpdate is the direction vector to update with the result
  13722. * @param particle is the particle we are computed the direction for
  13723. * @param isLocal defines if the direction should be set in local space
  13724. */
  13725. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13726. /**
  13727. * Called by the particle System when the position is computed for the created particle.
  13728. * @param worldMatrix is the world matrix of the particle system
  13729. * @param positionToUpdate is the position vector to update with the result
  13730. * @param particle is the particle we are computed the position for
  13731. * @param isLocal defines if the position should be set in local space
  13732. */
  13733. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13734. /**
  13735. * Clones the current emitter and returns a copy of it
  13736. * @returns the new emitter
  13737. */
  13738. clone(): PointParticleEmitter;
  13739. /**
  13740. * Called by the GPUParticleSystem to setup the update shader
  13741. * @param effect defines the update shader
  13742. */
  13743. applyToShader(effect: Effect): void;
  13744. /**
  13745. * Returns a string to use to update the GPU particles update shader
  13746. * @returns a string containng the defines string
  13747. */
  13748. getEffectDefines(): string;
  13749. /**
  13750. * Returns the string "PointParticleEmitter"
  13751. * @returns a string containing the class name
  13752. */
  13753. getClassName(): string;
  13754. /**
  13755. * Serializes the particle system to a JSON object.
  13756. * @returns the JSON object
  13757. */
  13758. serialize(): any;
  13759. /**
  13760. * Parse properties from a JSON object
  13761. * @param serializationObject defines the JSON object
  13762. */
  13763. parse(serializationObject: any): void;
  13764. }
  13765. }
  13766. declare module BABYLON {
  13767. /**
  13768. * Particle emitter emitting particles from the inside of a sphere.
  13769. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13770. */
  13771. export class SphereParticleEmitter implements IParticleEmitterType {
  13772. /**
  13773. * The radius of the emission sphere.
  13774. */
  13775. radius: number;
  13776. /**
  13777. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13778. */
  13779. radiusRange: number;
  13780. /**
  13781. * How much to randomize the particle direction [0-1].
  13782. */
  13783. directionRandomizer: number;
  13784. /**
  13785. * Creates a new instance SphereParticleEmitter
  13786. * @param radius the radius of the emission sphere (1 by default)
  13787. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13788. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13789. */
  13790. constructor(
  13791. /**
  13792. * The radius of the emission sphere.
  13793. */
  13794. radius?: number,
  13795. /**
  13796. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13797. */
  13798. radiusRange?: number,
  13799. /**
  13800. * How much to randomize the particle direction [0-1].
  13801. */
  13802. directionRandomizer?: number);
  13803. /**
  13804. * Called by the particle System when the direction is computed for the created particle.
  13805. * @param worldMatrix is the world matrix of the particle system
  13806. * @param directionToUpdate is the direction vector to update with the result
  13807. * @param particle is the particle we are computed the direction for
  13808. * @param isLocal defines if the direction should be set in local space
  13809. */
  13810. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13811. /**
  13812. * Called by the particle System when the position is computed for the created particle.
  13813. * @param worldMatrix is the world matrix of the particle system
  13814. * @param positionToUpdate is the position vector to update with the result
  13815. * @param particle is the particle we are computed the position for
  13816. * @param isLocal defines if the position should be set in local space
  13817. */
  13818. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13819. /**
  13820. * Clones the current emitter and returns a copy of it
  13821. * @returns the new emitter
  13822. */
  13823. clone(): SphereParticleEmitter;
  13824. /**
  13825. * Called by the GPUParticleSystem to setup the update shader
  13826. * @param effect defines the update shader
  13827. */
  13828. applyToShader(effect: Effect): void;
  13829. /**
  13830. * Returns a string to use to update the GPU particles update shader
  13831. * @returns a string containng the defines string
  13832. */
  13833. getEffectDefines(): string;
  13834. /**
  13835. * Returns the string "SphereParticleEmitter"
  13836. * @returns a string containing the class name
  13837. */
  13838. getClassName(): string;
  13839. /**
  13840. * Serializes the particle system to a JSON object.
  13841. * @returns the JSON object
  13842. */
  13843. serialize(): any;
  13844. /**
  13845. * Parse properties from a JSON object
  13846. * @param serializationObject defines the JSON object
  13847. */
  13848. parse(serializationObject: any): void;
  13849. }
  13850. /**
  13851. * Particle emitter emitting particles from the inside of a sphere.
  13852. * It emits the particles randomly between two vectors.
  13853. */
  13854. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13855. /**
  13856. * The min limit of the emission direction.
  13857. */
  13858. direction1: Vector3;
  13859. /**
  13860. * The max limit of the emission direction.
  13861. */
  13862. direction2: Vector3;
  13863. /**
  13864. * Creates a new instance SphereDirectedParticleEmitter
  13865. * @param radius the radius of the emission sphere (1 by default)
  13866. * @param direction1 the min limit of the emission direction (up vector by default)
  13867. * @param direction2 the max limit of the emission direction (up vector by default)
  13868. */
  13869. constructor(radius?: number,
  13870. /**
  13871. * The min limit of the emission direction.
  13872. */
  13873. direction1?: Vector3,
  13874. /**
  13875. * The max limit of the emission direction.
  13876. */
  13877. direction2?: Vector3);
  13878. /**
  13879. * Called by the particle System when the direction is computed for the created particle.
  13880. * @param worldMatrix is the world matrix of the particle system
  13881. * @param directionToUpdate is the direction vector to update with the result
  13882. * @param particle is the particle we are computed the direction for
  13883. */
  13884. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13885. /**
  13886. * Clones the current emitter and returns a copy of it
  13887. * @returns the new emitter
  13888. */
  13889. clone(): SphereDirectedParticleEmitter;
  13890. /**
  13891. * Called by the GPUParticleSystem to setup the update shader
  13892. * @param effect defines the update shader
  13893. */
  13894. applyToShader(effect: Effect): void;
  13895. /**
  13896. * Returns a string to use to update the GPU particles update shader
  13897. * @returns a string containng the defines string
  13898. */
  13899. getEffectDefines(): string;
  13900. /**
  13901. * Returns the string "SphereDirectedParticleEmitter"
  13902. * @returns a string containing the class name
  13903. */
  13904. getClassName(): string;
  13905. /**
  13906. * Serializes the particle system to a JSON object.
  13907. * @returns the JSON object
  13908. */
  13909. serialize(): any;
  13910. /**
  13911. * Parse properties from a JSON object
  13912. * @param serializationObject defines the JSON object
  13913. */
  13914. parse(serializationObject: any): void;
  13915. }
  13916. }
  13917. declare module BABYLON {
  13918. /**
  13919. * Particle emitter emitting particles from a custom list of positions.
  13920. */
  13921. export class CustomParticleEmitter implements IParticleEmitterType {
  13922. /**
  13923. * Gets or sets the position generator that will create the inital position of each particle.
  13924. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13925. */
  13926. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13927. /**
  13928. * Gets or sets the destination generator that will create the final destination of each particle.
  13929. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13930. */
  13931. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13932. /**
  13933. * Creates a new instance CustomParticleEmitter
  13934. */
  13935. constructor();
  13936. /**
  13937. * Called by the particle System when the direction is computed for the created particle.
  13938. * @param worldMatrix is the world matrix of the particle system
  13939. * @param directionToUpdate is the direction vector to update with the result
  13940. * @param particle is the particle we are computed the direction for
  13941. * @param isLocal defines if the direction should be set in local space
  13942. */
  13943. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13944. /**
  13945. * Called by the particle System when the position is computed for the created particle.
  13946. * @param worldMatrix is the world matrix of the particle system
  13947. * @param positionToUpdate is the position vector to update with the result
  13948. * @param particle is the particle we are computed the position for
  13949. * @param isLocal defines if the position should be set in local space
  13950. */
  13951. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13952. /**
  13953. * Clones the current emitter and returns a copy of it
  13954. * @returns the new emitter
  13955. */
  13956. clone(): CustomParticleEmitter;
  13957. /**
  13958. * Called by the GPUParticleSystem to setup the update shader
  13959. * @param effect defines the update shader
  13960. */
  13961. applyToShader(effect: Effect): void;
  13962. /**
  13963. * Returns a string to use to update the GPU particles update shader
  13964. * @returns a string containng the defines string
  13965. */
  13966. getEffectDefines(): string;
  13967. /**
  13968. * Returns the string "PointParticleEmitter"
  13969. * @returns a string containing the class name
  13970. */
  13971. getClassName(): string;
  13972. /**
  13973. * Serializes the particle system to a JSON object.
  13974. * @returns the JSON object
  13975. */
  13976. serialize(): any;
  13977. /**
  13978. * Parse properties from a JSON object
  13979. * @param serializationObject defines the JSON object
  13980. */
  13981. parse(serializationObject: any): void;
  13982. }
  13983. }
  13984. declare module BABYLON {
  13985. /**
  13986. * Particle emitter emitting particles from the inside of a box.
  13987. * It emits the particles randomly between 2 given directions.
  13988. */
  13989. export class MeshParticleEmitter implements IParticleEmitterType {
  13990. private _indices;
  13991. private _positions;
  13992. private _normals;
  13993. private _storedNormal;
  13994. private _mesh;
  13995. /**
  13996. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13997. */
  13998. direction1: Vector3;
  13999. /**
  14000. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14001. */
  14002. direction2: Vector3;
  14003. /**
  14004. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14005. */
  14006. useMeshNormalsForDirection: boolean;
  14007. /** Defines the mesh to use as source */
  14008. get mesh(): Nullable<AbstractMesh>;
  14009. set mesh(value: Nullable<AbstractMesh>);
  14010. /**
  14011. * Creates a new instance MeshParticleEmitter
  14012. * @param mesh defines the mesh to use as source
  14013. */
  14014. constructor(mesh?: Nullable<AbstractMesh>);
  14015. /**
  14016. * Called by the particle System when the direction is computed for the created particle.
  14017. * @param worldMatrix is the world matrix of the particle system
  14018. * @param directionToUpdate is the direction vector to update with the result
  14019. * @param particle is the particle we are computed the direction for
  14020. * @param isLocal defines if the direction should be set in local space
  14021. */
  14022. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14023. /**
  14024. * Called by the particle System when the position is computed for the created particle.
  14025. * @param worldMatrix is the world matrix of the particle system
  14026. * @param positionToUpdate is the position vector to update with the result
  14027. * @param particle is the particle we are computed the position for
  14028. * @param isLocal defines if the position should be set in local space
  14029. */
  14030. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14031. /**
  14032. * Clones the current emitter and returns a copy of it
  14033. * @returns the new emitter
  14034. */
  14035. clone(): MeshParticleEmitter;
  14036. /**
  14037. * Called by the GPUParticleSystem to setup the update shader
  14038. * @param effect defines the update shader
  14039. */
  14040. applyToShader(effect: Effect): void;
  14041. /**
  14042. * Returns a string to use to update the GPU particles update shader
  14043. * @returns a string containng the defines string
  14044. */
  14045. getEffectDefines(): string;
  14046. /**
  14047. * Returns the string "BoxParticleEmitter"
  14048. * @returns a string containing the class name
  14049. */
  14050. getClassName(): string;
  14051. /**
  14052. * Serializes the particle system to a JSON object.
  14053. * @returns the JSON object
  14054. */
  14055. serialize(): any;
  14056. /**
  14057. * Parse properties from a JSON object
  14058. * @param serializationObject defines the JSON object
  14059. * @param scene defines the hosting scene
  14060. */
  14061. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14062. }
  14063. }
  14064. declare module BABYLON {
  14065. /**
  14066. * Interface representing a particle system in Babylon.js.
  14067. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14068. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14069. */
  14070. export interface IParticleSystem {
  14071. /**
  14072. * List of animations used by the particle system.
  14073. */
  14074. animations: Animation[];
  14075. /**
  14076. * The id of the Particle system.
  14077. */
  14078. id: string;
  14079. /**
  14080. * The name of the Particle system.
  14081. */
  14082. name: string;
  14083. /**
  14084. * The emitter represents the Mesh or position we are attaching the particle system to.
  14085. */
  14086. emitter: Nullable<AbstractMesh | Vector3>;
  14087. /**
  14088. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14089. */
  14090. isBillboardBased: boolean;
  14091. /**
  14092. * The rendering group used by the Particle system to chose when to render.
  14093. */
  14094. renderingGroupId: number;
  14095. /**
  14096. * The layer mask we are rendering the particles through.
  14097. */
  14098. layerMask: number;
  14099. /**
  14100. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14101. */
  14102. updateSpeed: number;
  14103. /**
  14104. * The amount of time the particle system is running (depends of the overall update speed).
  14105. */
  14106. targetStopDuration: number;
  14107. /**
  14108. * The texture used to render each particle. (this can be a spritesheet)
  14109. */
  14110. particleTexture: Nullable<BaseTexture>;
  14111. /**
  14112. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14113. */
  14114. blendMode: number;
  14115. /**
  14116. * Minimum life time of emitting particles.
  14117. */
  14118. minLifeTime: number;
  14119. /**
  14120. * Maximum life time of emitting particles.
  14121. */
  14122. maxLifeTime: number;
  14123. /**
  14124. * Minimum Size of emitting particles.
  14125. */
  14126. minSize: number;
  14127. /**
  14128. * Maximum Size of emitting particles.
  14129. */
  14130. maxSize: number;
  14131. /**
  14132. * Minimum scale of emitting particles on X axis.
  14133. */
  14134. minScaleX: number;
  14135. /**
  14136. * Maximum scale of emitting particles on X axis.
  14137. */
  14138. maxScaleX: number;
  14139. /**
  14140. * Minimum scale of emitting particles on Y axis.
  14141. */
  14142. minScaleY: number;
  14143. /**
  14144. * Maximum scale of emitting particles on Y axis.
  14145. */
  14146. maxScaleY: number;
  14147. /**
  14148. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14149. */
  14150. color1: Color4;
  14151. /**
  14152. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14153. */
  14154. color2: Color4;
  14155. /**
  14156. * Color the particle will have at the end of its lifetime.
  14157. */
  14158. colorDead: Color4;
  14159. /**
  14160. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14161. */
  14162. emitRate: number;
  14163. /**
  14164. * You can use gravity if you want to give an orientation to your particles.
  14165. */
  14166. gravity: Vector3;
  14167. /**
  14168. * Minimum power of emitting particles.
  14169. */
  14170. minEmitPower: number;
  14171. /**
  14172. * Maximum power of emitting particles.
  14173. */
  14174. maxEmitPower: number;
  14175. /**
  14176. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14177. */
  14178. minAngularSpeed: number;
  14179. /**
  14180. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14181. */
  14182. maxAngularSpeed: number;
  14183. /**
  14184. * Gets or sets the minimal initial rotation in radians.
  14185. */
  14186. minInitialRotation: number;
  14187. /**
  14188. * Gets or sets the maximal initial rotation in radians.
  14189. */
  14190. maxInitialRotation: number;
  14191. /**
  14192. * The particle emitter type defines the emitter used by the particle system.
  14193. * It can be for example box, sphere, or cone...
  14194. */
  14195. particleEmitterType: Nullable<IParticleEmitterType>;
  14196. /**
  14197. * Defines the delay in milliseconds before starting the system (0 by default)
  14198. */
  14199. startDelay: number;
  14200. /**
  14201. * 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
  14202. */
  14203. preWarmCycles: number;
  14204. /**
  14205. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14206. */
  14207. preWarmStepOffset: number;
  14208. /**
  14209. * 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)
  14210. */
  14211. spriteCellChangeSpeed: number;
  14212. /**
  14213. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14214. */
  14215. startSpriteCellID: number;
  14216. /**
  14217. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14218. */
  14219. endSpriteCellID: number;
  14220. /**
  14221. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14222. */
  14223. spriteCellWidth: number;
  14224. /**
  14225. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14226. */
  14227. spriteCellHeight: number;
  14228. /**
  14229. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14230. */
  14231. spriteRandomStartCell: boolean;
  14232. /**
  14233. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14234. */
  14235. isAnimationSheetEnabled: boolean;
  14236. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14237. translationPivot: Vector2;
  14238. /**
  14239. * Gets or sets a texture used to add random noise to particle positions
  14240. */
  14241. noiseTexture: Nullable<BaseTexture>;
  14242. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14243. noiseStrength: Vector3;
  14244. /**
  14245. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14246. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14247. */
  14248. billboardMode: number;
  14249. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14250. limitVelocityDamping: number;
  14251. /**
  14252. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14253. */
  14254. beginAnimationOnStart: boolean;
  14255. /**
  14256. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14257. */
  14258. beginAnimationFrom: number;
  14259. /**
  14260. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14261. */
  14262. beginAnimationTo: number;
  14263. /**
  14264. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14265. */
  14266. beginAnimationLoop: boolean;
  14267. /**
  14268. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14269. */
  14270. disposeOnStop: boolean;
  14271. /**
  14272. * Specifies if the particles are updated in emitter local space or world space
  14273. */
  14274. isLocal: boolean;
  14275. /** Snippet ID if the particle system was created from the snippet server */
  14276. snippetId: string;
  14277. /** Gets or sets a matrix to use to compute projection */
  14278. defaultProjectionMatrix: Matrix;
  14279. /**
  14280. * Gets the maximum number of particles active at the same time.
  14281. * @returns The max number of active particles.
  14282. */
  14283. getCapacity(): number;
  14284. /**
  14285. * Gets the number of particles active at the same time.
  14286. * @returns The number of active particles.
  14287. */
  14288. getActiveCount(): number;
  14289. /**
  14290. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14291. * @returns True if it has been started, otherwise false.
  14292. */
  14293. isStarted(): boolean;
  14294. /**
  14295. * Animates the particle system for this frame.
  14296. */
  14297. animate(): void;
  14298. /**
  14299. * Renders the particle system in its current state.
  14300. * @returns the current number of particles
  14301. */
  14302. render(): number;
  14303. /**
  14304. * Dispose the particle system and frees its associated resources.
  14305. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14306. */
  14307. dispose(disposeTexture?: boolean): void;
  14308. /**
  14309. * An event triggered when the system is disposed
  14310. */
  14311. onDisposeObservable: Observable<IParticleSystem>;
  14312. /**
  14313. * An event triggered when the system is stopped
  14314. */
  14315. onStoppedObservable: Observable<IParticleSystem>;
  14316. /**
  14317. * Clones the particle system.
  14318. * @param name The name of the cloned object
  14319. * @param newEmitter The new emitter to use
  14320. * @returns the cloned particle system
  14321. */
  14322. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14323. /**
  14324. * Serializes the particle system to a JSON object
  14325. * @param serializeTexture defines if the texture must be serialized as well
  14326. * @returns the JSON object
  14327. */
  14328. serialize(serializeTexture: boolean): any;
  14329. /**
  14330. * Rebuild the particle system
  14331. */
  14332. rebuild(): void;
  14333. /** Force the system to rebuild all gradients that need to be resync */
  14334. forceRefreshGradients(): void;
  14335. /**
  14336. * Starts the particle system and begins to emit
  14337. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14338. */
  14339. start(delay?: number): void;
  14340. /**
  14341. * Stops the particle system.
  14342. */
  14343. stop(): void;
  14344. /**
  14345. * Remove all active particles
  14346. */
  14347. reset(): void;
  14348. /**
  14349. * Gets a boolean indicating that the system is stopping
  14350. * @returns true if the system is currently stopping
  14351. */
  14352. isStopping(): boolean;
  14353. /**
  14354. * Is this system ready to be used/rendered
  14355. * @return true if the system is ready
  14356. */
  14357. isReady(): boolean;
  14358. /**
  14359. * Returns the string "ParticleSystem"
  14360. * @returns a string containing the class name
  14361. */
  14362. getClassName(): string;
  14363. /**
  14364. * Gets the custom effect used to render the particles
  14365. * @param blendMode Blend mode for which the effect should be retrieved
  14366. * @returns The effect
  14367. */
  14368. getCustomEffect(blendMode: number): Nullable<Effect>;
  14369. /**
  14370. * Sets the custom effect used to render the particles
  14371. * @param effect The effect to set
  14372. * @param blendMode Blend mode for which the effect should be set
  14373. */
  14374. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14375. /**
  14376. * Fill the defines array according to the current settings of the particle system
  14377. * @param defines Array to be updated
  14378. * @param blendMode blend mode to take into account when updating the array
  14379. */
  14380. fillDefines(defines: Array<string>, blendMode: number): void;
  14381. /**
  14382. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14383. * @param uniforms Uniforms array to fill
  14384. * @param attributes Attributes array to fill
  14385. * @param samplers Samplers array to fill
  14386. */
  14387. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14388. /**
  14389. * Observable that will be called just before the particles are drawn
  14390. */
  14391. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14392. /**
  14393. * Gets the name of the particle vertex shader
  14394. */
  14395. vertexShaderName: string;
  14396. /**
  14397. * Adds a new color gradient
  14398. * @param gradient defines the gradient to use (between 0 and 1)
  14399. * @param color1 defines the color to affect to the specified gradient
  14400. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14401. * @returns the current particle system
  14402. */
  14403. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14404. /**
  14405. * Remove a specific color gradient
  14406. * @param gradient defines the gradient to remove
  14407. * @returns the current particle system
  14408. */
  14409. removeColorGradient(gradient: number): IParticleSystem;
  14410. /**
  14411. * Adds a new size gradient
  14412. * @param gradient defines the gradient to use (between 0 and 1)
  14413. * @param factor defines the size factor to affect to the specified gradient
  14414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14415. * @returns the current particle system
  14416. */
  14417. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14418. /**
  14419. * Remove a specific size gradient
  14420. * @param gradient defines the gradient to remove
  14421. * @returns the current particle system
  14422. */
  14423. removeSizeGradient(gradient: number): IParticleSystem;
  14424. /**
  14425. * Gets the current list of color gradients.
  14426. * You must use addColorGradient and removeColorGradient to udpate this list
  14427. * @returns the list of color gradients
  14428. */
  14429. getColorGradients(): Nullable<Array<ColorGradient>>;
  14430. /**
  14431. * Gets the current list of size gradients.
  14432. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14433. * @returns the list of size gradients
  14434. */
  14435. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14436. /**
  14437. * Gets the current list of angular speed gradients.
  14438. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14439. * @returns the list of angular speed gradients
  14440. */
  14441. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14442. /**
  14443. * Adds a new angular speed gradient
  14444. * @param gradient defines the gradient to use (between 0 and 1)
  14445. * @param factor defines the angular speed to affect to the specified gradient
  14446. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14447. * @returns the current particle system
  14448. */
  14449. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14450. /**
  14451. * Remove a specific angular speed gradient
  14452. * @param gradient defines the gradient to remove
  14453. * @returns the current particle system
  14454. */
  14455. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14456. /**
  14457. * Gets the current list of velocity gradients.
  14458. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14459. * @returns the list of velocity gradients
  14460. */
  14461. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14462. /**
  14463. * Adds a new velocity gradient
  14464. * @param gradient defines the gradient to use (between 0 and 1)
  14465. * @param factor defines the velocity to affect to the specified gradient
  14466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14467. * @returns the current particle system
  14468. */
  14469. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14470. /**
  14471. * Remove a specific velocity gradient
  14472. * @param gradient defines the gradient to remove
  14473. * @returns the current particle system
  14474. */
  14475. removeVelocityGradient(gradient: number): IParticleSystem;
  14476. /**
  14477. * Gets the current list of limit velocity gradients.
  14478. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14479. * @returns the list of limit velocity gradients
  14480. */
  14481. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14482. /**
  14483. * Adds a new limit velocity gradient
  14484. * @param gradient defines the gradient to use (between 0 and 1)
  14485. * @param factor defines the limit velocity to affect to the specified gradient
  14486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14487. * @returns the current particle system
  14488. */
  14489. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14490. /**
  14491. * Remove a specific limit velocity gradient
  14492. * @param gradient defines the gradient to remove
  14493. * @returns the current particle system
  14494. */
  14495. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14496. /**
  14497. * Adds a new drag gradient
  14498. * @param gradient defines the gradient to use (between 0 and 1)
  14499. * @param factor defines the drag to affect to the specified gradient
  14500. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14501. * @returns the current particle system
  14502. */
  14503. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14504. /**
  14505. * Remove a specific drag gradient
  14506. * @param gradient defines the gradient to remove
  14507. * @returns the current particle system
  14508. */
  14509. removeDragGradient(gradient: number): IParticleSystem;
  14510. /**
  14511. * Gets the current list of drag gradients.
  14512. * You must use addDragGradient and removeDragGradient to udpate this list
  14513. * @returns the list of drag gradients
  14514. */
  14515. getDragGradients(): Nullable<Array<FactorGradient>>;
  14516. /**
  14517. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14518. * @param gradient defines the gradient to use (between 0 and 1)
  14519. * @param factor defines the emit rate to affect to the specified gradient
  14520. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14521. * @returns the current particle system
  14522. */
  14523. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14524. /**
  14525. * Remove a specific emit rate gradient
  14526. * @param gradient defines the gradient to remove
  14527. * @returns the current particle system
  14528. */
  14529. removeEmitRateGradient(gradient: number): IParticleSystem;
  14530. /**
  14531. * Gets the current list of emit rate gradients.
  14532. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14533. * @returns the list of emit rate gradients
  14534. */
  14535. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14536. /**
  14537. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14538. * @param gradient defines the gradient to use (between 0 and 1)
  14539. * @param factor defines the start size to affect to the specified gradient
  14540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14541. * @returns the current particle system
  14542. */
  14543. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14544. /**
  14545. * Remove a specific start size gradient
  14546. * @param gradient defines the gradient to remove
  14547. * @returns the current particle system
  14548. */
  14549. removeStartSizeGradient(gradient: number): IParticleSystem;
  14550. /**
  14551. * Gets the current list of start size gradients.
  14552. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14553. * @returns the list of start size gradients
  14554. */
  14555. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14556. /**
  14557. * Adds a new life time gradient
  14558. * @param gradient defines the gradient to use (between 0 and 1)
  14559. * @param factor defines the life time factor to affect to the specified gradient
  14560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14561. * @returns the current particle system
  14562. */
  14563. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14564. /**
  14565. * Remove a specific life time gradient
  14566. * @param gradient defines the gradient to remove
  14567. * @returns the current particle system
  14568. */
  14569. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14570. /**
  14571. * Gets the current list of life time gradients.
  14572. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14573. * @returns the list of life time gradients
  14574. */
  14575. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14576. /**
  14577. * Gets the current list of color gradients.
  14578. * You must use addColorGradient and removeColorGradient to udpate this list
  14579. * @returns the list of color gradients
  14580. */
  14581. getColorGradients(): Nullable<Array<ColorGradient>>;
  14582. /**
  14583. * Adds a new ramp gradient used to remap particle colors
  14584. * @param gradient defines the gradient to use (between 0 and 1)
  14585. * @param color defines the color to affect to the specified gradient
  14586. * @returns the current particle system
  14587. */
  14588. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14589. /**
  14590. * Gets the current list of ramp gradients.
  14591. * You must use addRampGradient and removeRampGradient to udpate this list
  14592. * @returns the list of ramp gradients
  14593. */
  14594. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14595. /** Gets or sets a boolean indicating that ramp gradients must be used
  14596. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14597. */
  14598. useRampGradients: boolean;
  14599. /**
  14600. * Adds a new color remap gradient
  14601. * @param gradient defines the gradient to use (between 0 and 1)
  14602. * @param min defines the color remap minimal range
  14603. * @param max defines the color remap maximal range
  14604. * @returns the current particle system
  14605. */
  14606. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14607. /**
  14608. * Gets the current list of color remap gradients.
  14609. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14610. * @returns the list of color remap gradients
  14611. */
  14612. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14613. /**
  14614. * Adds a new alpha remap gradient
  14615. * @param gradient defines the gradient to use (between 0 and 1)
  14616. * @param min defines the alpha remap minimal range
  14617. * @param max defines the alpha remap maximal range
  14618. * @returns the current particle system
  14619. */
  14620. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14621. /**
  14622. * Gets the current list of alpha remap gradients.
  14623. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14624. * @returns the list of alpha remap gradients
  14625. */
  14626. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14627. /**
  14628. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14629. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14630. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14631. * @returns the emitter
  14632. */
  14633. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14634. /**
  14635. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14636. * @param radius The radius of the hemisphere to emit from
  14637. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14638. * @returns the emitter
  14639. */
  14640. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14641. /**
  14642. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14643. * @param radius The radius of the sphere to emit from
  14644. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14645. * @returns the emitter
  14646. */
  14647. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14648. /**
  14649. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14650. * @param radius The radius of the sphere to emit from
  14651. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14652. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14653. * @returns the emitter
  14654. */
  14655. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14656. /**
  14657. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14658. * @param radius The radius of the emission cylinder
  14659. * @param height The height of the emission cylinder
  14660. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14661. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14662. * @returns the emitter
  14663. */
  14664. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14665. /**
  14666. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14667. * @param radius The radius of the cylinder to emit from
  14668. * @param height The height of the emission cylinder
  14669. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14670. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14671. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14672. * @returns the emitter
  14673. */
  14674. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14675. /**
  14676. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14677. * @param radius The radius of the cone to emit from
  14678. * @param angle The base angle of the cone
  14679. * @returns the emitter
  14680. */
  14681. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14682. /**
  14683. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14684. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14685. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14686. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14687. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14688. * @returns the emitter
  14689. */
  14690. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14691. /**
  14692. * Get hosting scene
  14693. * @returns the scene
  14694. */
  14695. getScene(): Nullable<Scene>;
  14696. }
  14697. }
  14698. declare module BABYLON {
  14699. /**
  14700. * 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.
  14701. * @see https://doc.babylonjs.com/how_to/transformnode
  14702. */
  14703. export class TransformNode extends Node {
  14704. /**
  14705. * Object will not rotate to face the camera
  14706. */
  14707. static BILLBOARDMODE_NONE: number;
  14708. /**
  14709. * Object will rotate to face the camera but only on the x axis
  14710. */
  14711. static BILLBOARDMODE_X: number;
  14712. /**
  14713. * Object will rotate to face the camera but only on the y axis
  14714. */
  14715. static BILLBOARDMODE_Y: number;
  14716. /**
  14717. * Object will rotate to face the camera but only on the z axis
  14718. */
  14719. static BILLBOARDMODE_Z: number;
  14720. /**
  14721. * Object will rotate to face the camera
  14722. */
  14723. static BILLBOARDMODE_ALL: number;
  14724. /**
  14725. * Object will rotate to face the camera's position instead of orientation
  14726. */
  14727. static BILLBOARDMODE_USE_POSITION: number;
  14728. private static _TmpRotation;
  14729. private static _TmpScaling;
  14730. private static _TmpTranslation;
  14731. private _forward;
  14732. private _forwardInverted;
  14733. private _up;
  14734. private _right;
  14735. private _rightInverted;
  14736. private _position;
  14737. private _rotation;
  14738. private _rotationQuaternion;
  14739. protected _scaling: Vector3;
  14740. protected _isDirty: boolean;
  14741. private _transformToBoneReferal;
  14742. private _isAbsoluteSynced;
  14743. private _billboardMode;
  14744. /**
  14745. * Gets or sets the billboard mode. Default is 0.
  14746. *
  14747. * | Value | Type | Description |
  14748. * | --- | --- | --- |
  14749. * | 0 | BILLBOARDMODE_NONE | |
  14750. * | 1 | BILLBOARDMODE_X | |
  14751. * | 2 | BILLBOARDMODE_Y | |
  14752. * | 4 | BILLBOARDMODE_Z | |
  14753. * | 7 | BILLBOARDMODE_ALL | |
  14754. *
  14755. */
  14756. get billboardMode(): number;
  14757. set billboardMode(value: number);
  14758. private _preserveParentRotationForBillboard;
  14759. /**
  14760. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14761. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14762. */
  14763. get preserveParentRotationForBillboard(): boolean;
  14764. set preserveParentRotationForBillboard(value: boolean);
  14765. /**
  14766. * 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
  14767. */
  14768. scalingDeterminant: number;
  14769. private _infiniteDistance;
  14770. /**
  14771. * Gets or sets the distance of the object to max, often used by skybox
  14772. */
  14773. get infiniteDistance(): boolean;
  14774. set infiniteDistance(value: boolean);
  14775. /**
  14776. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14777. * By default the system will update normals to compensate
  14778. */
  14779. ignoreNonUniformScaling: boolean;
  14780. /**
  14781. * 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
  14782. */
  14783. reIntegrateRotationIntoRotationQuaternion: boolean;
  14784. /** @hidden */
  14785. _poseMatrix: Nullable<Matrix>;
  14786. /** @hidden */
  14787. _localMatrix: Matrix;
  14788. private _usePivotMatrix;
  14789. private _absolutePosition;
  14790. private _absoluteScaling;
  14791. private _absoluteRotationQuaternion;
  14792. private _pivotMatrix;
  14793. private _pivotMatrixInverse;
  14794. /** @hidden */
  14795. _postMultiplyPivotMatrix: boolean;
  14796. protected _isWorldMatrixFrozen: boolean;
  14797. /** @hidden */
  14798. _indexInSceneTransformNodesArray: number;
  14799. /**
  14800. * An event triggered after the world matrix is updated
  14801. */
  14802. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14803. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14804. /**
  14805. * Gets a string identifying the name of the class
  14806. * @returns "TransformNode" string
  14807. */
  14808. getClassName(): string;
  14809. /**
  14810. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14811. */
  14812. get position(): Vector3;
  14813. set position(newPosition: Vector3);
  14814. /**
  14815. * 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)).
  14816. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14817. */
  14818. get rotation(): Vector3;
  14819. set rotation(newRotation: Vector3);
  14820. /**
  14821. * 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)).
  14822. */
  14823. get scaling(): Vector3;
  14824. set scaling(newScaling: Vector3);
  14825. /**
  14826. * 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).
  14827. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14828. */
  14829. get rotationQuaternion(): Nullable<Quaternion>;
  14830. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14831. /**
  14832. * The forward direction of that transform in world space.
  14833. */
  14834. get forward(): Vector3;
  14835. /**
  14836. * The up direction of that transform in world space.
  14837. */
  14838. get up(): Vector3;
  14839. /**
  14840. * The right direction of that transform in world space.
  14841. */
  14842. get right(): Vector3;
  14843. /**
  14844. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14845. * @param matrix the matrix to copy the pose from
  14846. * @returns this TransformNode.
  14847. */
  14848. updatePoseMatrix(matrix: Matrix): TransformNode;
  14849. /**
  14850. * Returns the mesh Pose matrix.
  14851. * @returns the pose matrix
  14852. */
  14853. getPoseMatrix(): Matrix;
  14854. /** @hidden */
  14855. _isSynchronized(): boolean;
  14856. /** @hidden */
  14857. _initCache(): void;
  14858. /**
  14859. * Flag the transform node as dirty (Forcing it to update everything)
  14860. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14861. * @returns this transform node
  14862. */
  14863. markAsDirty(property: string): TransformNode;
  14864. /**
  14865. * Returns the current mesh absolute position.
  14866. * Returns a Vector3.
  14867. */
  14868. get absolutePosition(): Vector3;
  14869. /**
  14870. * Returns the current mesh absolute scaling.
  14871. * Returns a Vector3.
  14872. */
  14873. get absoluteScaling(): Vector3;
  14874. /**
  14875. * Returns the current mesh absolute rotation.
  14876. * Returns a Quaternion.
  14877. */
  14878. get absoluteRotationQuaternion(): Quaternion;
  14879. /**
  14880. * Sets a new matrix to apply before all other transformation
  14881. * @param matrix defines the transform matrix
  14882. * @returns the current TransformNode
  14883. */
  14884. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14885. /**
  14886. * Sets a new pivot matrix to the current node
  14887. * @param matrix defines the new pivot matrix to use
  14888. * @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
  14889. * @returns the current TransformNode
  14890. */
  14891. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14892. /**
  14893. * Returns the mesh pivot matrix.
  14894. * Default : Identity.
  14895. * @returns the matrix
  14896. */
  14897. getPivotMatrix(): Matrix;
  14898. /**
  14899. * Instantiate (when possible) or clone that node with its hierarchy
  14900. * @param newParent defines the new parent to use for the instance (or clone)
  14901. * @param options defines options to configure how copy is done
  14902. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14903. * @returns an instance (or a clone) of the current node with its hiearchy
  14904. */
  14905. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14906. doNotInstantiate: boolean;
  14907. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14908. /**
  14909. * Prevents the World matrix to be computed any longer
  14910. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14911. * @returns the TransformNode.
  14912. */
  14913. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14914. /**
  14915. * Allows back the World matrix computation.
  14916. * @returns the TransformNode.
  14917. */
  14918. unfreezeWorldMatrix(): this;
  14919. /**
  14920. * True if the World matrix has been frozen.
  14921. */
  14922. get isWorldMatrixFrozen(): boolean;
  14923. /**
  14924. * Retuns the mesh absolute position in the World.
  14925. * @returns a Vector3.
  14926. */
  14927. getAbsolutePosition(): Vector3;
  14928. /**
  14929. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14930. * @param absolutePosition the absolute position to set
  14931. * @returns the TransformNode.
  14932. */
  14933. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14934. /**
  14935. * Sets the mesh position in its local space.
  14936. * @param vector3 the position to set in localspace
  14937. * @returns the TransformNode.
  14938. */
  14939. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14940. /**
  14941. * Returns the mesh position in the local space from the current World matrix values.
  14942. * @returns a new Vector3.
  14943. */
  14944. getPositionExpressedInLocalSpace(): Vector3;
  14945. /**
  14946. * Translates the mesh along the passed Vector3 in its local space.
  14947. * @param vector3 the distance to translate in localspace
  14948. * @returns the TransformNode.
  14949. */
  14950. locallyTranslate(vector3: Vector3): TransformNode;
  14951. private static _lookAtVectorCache;
  14952. /**
  14953. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14954. * @param targetPoint the position (must be in same space as current mesh) to look at
  14955. * @param yawCor optional yaw (y-axis) correction in radians
  14956. * @param pitchCor optional pitch (x-axis) correction in radians
  14957. * @param rollCor optional roll (z-axis) correction in radians
  14958. * @param space the choosen space of the target
  14959. * @returns the TransformNode.
  14960. */
  14961. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14962. /**
  14963. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14964. * This Vector3 is expressed in the World space.
  14965. * @param localAxis axis to rotate
  14966. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14967. */
  14968. getDirection(localAxis: Vector3): Vector3;
  14969. /**
  14970. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14971. * localAxis is expressed in the mesh local space.
  14972. * result is computed in the Wordl space from the mesh World matrix.
  14973. * @param localAxis axis to rotate
  14974. * @param result the resulting transformnode
  14975. * @returns this TransformNode.
  14976. */
  14977. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14978. /**
  14979. * Sets this transform node rotation to the given local axis.
  14980. * @param localAxis the axis in local space
  14981. * @param yawCor optional yaw (y-axis) correction in radians
  14982. * @param pitchCor optional pitch (x-axis) correction in radians
  14983. * @param rollCor optional roll (z-axis) correction in radians
  14984. * @returns this TransformNode
  14985. */
  14986. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14987. /**
  14988. * Sets a new pivot point to the current node
  14989. * @param point defines the new pivot point to use
  14990. * @param space defines if the point is in world or local space (local by default)
  14991. * @returns the current TransformNode
  14992. */
  14993. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14994. /**
  14995. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14996. * @returns the pivot point
  14997. */
  14998. getPivotPoint(): Vector3;
  14999. /**
  15000. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15001. * @param result the vector3 to store the result
  15002. * @returns this TransformNode.
  15003. */
  15004. getPivotPointToRef(result: Vector3): TransformNode;
  15005. /**
  15006. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15007. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15008. */
  15009. getAbsolutePivotPoint(): Vector3;
  15010. /**
  15011. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15012. * @param result vector3 to store the result
  15013. * @returns this TransformNode.
  15014. */
  15015. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15016. /**
  15017. * Defines the passed node as the parent of the current node.
  15018. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15019. * @see https://doc.babylonjs.com/how_to/parenting
  15020. * @param node the node ot set as the parent
  15021. * @returns this TransformNode.
  15022. */
  15023. setParent(node: Nullable<Node>): TransformNode;
  15024. private _nonUniformScaling;
  15025. /**
  15026. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15027. */
  15028. get nonUniformScaling(): boolean;
  15029. /** @hidden */
  15030. _updateNonUniformScalingState(value: boolean): boolean;
  15031. /**
  15032. * Attach the current TransformNode to another TransformNode associated with a bone
  15033. * @param bone Bone affecting the TransformNode
  15034. * @param affectedTransformNode TransformNode associated with the bone
  15035. * @returns this object
  15036. */
  15037. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15038. /**
  15039. * Detach the transform node if its associated with a bone
  15040. * @returns this object
  15041. */
  15042. detachFromBone(): TransformNode;
  15043. private static _rotationAxisCache;
  15044. /**
  15045. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15046. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15047. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15048. * The passed axis is also normalized.
  15049. * @param axis the axis to rotate around
  15050. * @param amount the amount to rotate in radians
  15051. * @param space Space to rotate in (Default: local)
  15052. * @returns the TransformNode.
  15053. */
  15054. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15055. /**
  15056. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15057. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15058. * The passed axis is also normalized. .
  15059. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15060. * @param point the point to rotate around
  15061. * @param axis the axis to rotate around
  15062. * @param amount the amount to rotate in radians
  15063. * @returns the TransformNode
  15064. */
  15065. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15066. /**
  15067. * Translates the mesh along the axis vector for the passed distance in the given space.
  15068. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15069. * @param axis the axis to translate in
  15070. * @param distance the distance to translate
  15071. * @param space Space to rotate in (Default: local)
  15072. * @returns the TransformNode.
  15073. */
  15074. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15075. /**
  15076. * Adds a rotation step to the mesh current rotation.
  15077. * x, y, z are Euler angles expressed in radians.
  15078. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15079. * This means this rotation is made in the mesh local space only.
  15080. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15081. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15082. * ```javascript
  15083. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15084. * ```
  15085. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15086. * 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.
  15087. * @param x Rotation to add
  15088. * @param y Rotation to add
  15089. * @param z Rotation to add
  15090. * @returns the TransformNode.
  15091. */
  15092. addRotation(x: number, y: number, z: number): TransformNode;
  15093. /**
  15094. * @hidden
  15095. */
  15096. protected _getEffectiveParent(): Nullable<Node>;
  15097. /**
  15098. * Computes the world matrix of the node
  15099. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15100. * @returns the world matrix
  15101. */
  15102. computeWorldMatrix(force?: boolean): Matrix;
  15103. /**
  15104. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15105. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15106. */
  15107. resetLocalMatrix(independentOfChildren?: boolean): void;
  15108. protected _afterComputeWorldMatrix(): void;
  15109. /**
  15110. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15111. * @param func callback function to add
  15112. *
  15113. * @returns the TransformNode.
  15114. */
  15115. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15116. /**
  15117. * Removes a registered callback function.
  15118. * @param func callback function to remove
  15119. * @returns the TransformNode.
  15120. */
  15121. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15122. /**
  15123. * Gets the position of the current mesh in camera space
  15124. * @param camera defines the camera to use
  15125. * @returns a position
  15126. */
  15127. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15128. /**
  15129. * Returns the distance from the mesh to the active camera
  15130. * @param camera defines the camera to use
  15131. * @returns the distance
  15132. */
  15133. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15134. /**
  15135. * Clone the current transform node
  15136. * @param name Name of the new clone
  15137. * @param newParent New parent for the clone
  15138. * @param doNotCloneChildren Do not clone children hierarchy
  15139. * @returns the new transform node
  15140. */
  15141. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15142. /**
  15143. * Serializes the objects information.
  15144. * @param currentSerializationObject defines the object to serialize in
  15145. * @returns the serialized object
  15146. */
  15147. serialize(currentSerializationObject?: any): any;
  15148. /**
  15149. * Returns a new TransformNode object parsed from the source provided.
  15150. * @param parsedTransformNode is the source.
  15151. * @param scene the scne the object belongs to
  15152. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15153. * @returns a new TransformNode object parsed from the source provided.
  15154. */
  15155. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15156. /**
  15157. * Get all child-transformNodes of this node
  15158. * @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
  15159. * @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
  15160. * @returns an array of TransformNode
  15161. */
  15162. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15163. /**
  15164. * Releases resources associated with this transform node.
  15165. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15166. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15167. */
  15168. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15169. /**
  15170. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15171. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15172. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15173. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15174. * @returns the current mesh
  15175. */
  15176. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15177. private _syncAbsoluteScalingAndRotation;
  15178. }
  15179. }
  15180. declare module BABYLON {
  15181. /**
  15182. * Class used to override all child animations of a given target
  15183. */
  15184. export class AnimationPropertiesOverride {
  15185. /**
  15186. * Gets or sets a value indicating if animation blending must be used
  15187. */
  15188. enableBlending: boolean;
  15189. /**
  15190. * Gets or sets the blending speed to use when enableBlending is true
  15191. */
  15192. blendingSpeed: number;
  15193. /**
  15194. * Gets or sets the default loop mode to use
  15195. */
  15196. loopMode: number;
  15197. }
  15198. }
  15199. declare module BABYLON {
  15200. /**
  15201. * Class used to store bone information
  15202. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15203. */
  15204. export class Bone extends Node {
  15205. /**
  15206. * defines the bone name
  15207. */
  15208. name: string;
  15209. private static _tmpVecs;
  15210. private static _tmpQuat;
  15211. private static _tmpMats;
  15212. /**
  15213. * Gets the list of child bones
  15214. */
  15215. children: Bone[];
  15216. /** Gets the animations associated with this bone */
  15217. animations: Animation[];
  15218. /**
  15219. * Gets or sets bone length
  15220. */
  15221. length: number;
  15222. /**
  15223. * @hidden Internal only
  15224. * Set this value to map this bone to a different index in the transform matrices
  15225. * Set this value to -1 to exclude the bone from the transform matrices
  15226. */
  15227. _index: Nullable<number>;
  15228. private _skeleton;
  15229. private _localMatrix;
  15230. private _restPose;
  15231. private _bindPose;
  15232. private _baseMatrix;
  15233. private _absoluteTransform;
  15234. private _invertedAbsoluteTransform;
  15235. private _parent;
  15236. private _scalingDeterminant;
  15237. private _worldTransform;
  15238. private _localScaling;
  15239. private _localRotation;
  15240. private _localPosition;
  15241. private _needToDecompose;
  15242. private _needToCompose;
  15243. /** @hidden */
  15244. _linkedTransformNode: Nullable<TransformNode>;
  15245. /** @hidden */
  15246. _waitingTransformNodeId: Nullable<string>;
  15247. /** @hidden */
  15248. get _matrix(): Matrix;
  15249. /** @hidden */
  15250. set _matrix(value: Matrix);
  15251. /**
  15252. * Create a new bone
  15253. * @param name defines the bone name
  15254. * @param skeleton defines the parent skeleton
  15255. * @param parentBone defines the parent (can be null if the bone is the root)
  15256. * @param localMatrix defines the local matrix
  15257. * @param restPose defines the rest pose matrix
  15258. * @param baseMatrix defines the base matrix
  15259. * @param index defines index of the bone in the hiearchy
  15260. */
  15261. constructor(
  15262. /**
  15263. * defines the bone name
  15264. */
  15265. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15266. /**
  15267. * Gets the current object class name.
  15268. * @return the class name
  15269. */
  15270. getClassName(): string;
  15271. /**
  15272. * Gets the parent skeleton
  15273. * @returns a skeleton
  15274. */
  15275. getSkeleton(): Skeleton;
  15276. /**
  15277. * Gets parent bone
  15278. * @returns a bone or null if the bone is the root of the bone hierarchy
  15279. */
  15280. getParent(): Nullable<Bone>;
  15281. /**
  15282. * Returns an array containing the root bones
  15283. * @returns an array containing the root bones
  15284. */
  15285. getChildren(): Array<Bone>;
  15286. /**
  15287. * Gets the node index in matrix array generated for rendering
  15288. * @returns the node index
  15289. */
  15290. getIndex(): number;
  15291. /**
  15292. * Sets the parent bone
  15293. * @param parent defines the parent (can be null if the bone is the root)
  15294. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15295. */
  15296. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15297. /**
  15298. * Gets the local matrix
  15299. * @returns a matrix
  15300. */
  15301. getLocalMatrix(): Matrix;
  15302. /**
  15303. * Gets the base matrix (initial matrix which remains unchanged)
  15304. * @returns a matrix
  15305. */
  15306. getBaseMatrix(): Matrix;
  15307. /**
  15308. * Gets the rest pose matrix
  15309. * @returns a matrix
  15310. */
  15311. getRestPose(): Matrix;
  15312. /**
  15313. * Sets the rest pose matrix
  15314. * @param matrix the local-space rest pose to set for this bone
  15315. */
  15316. setRestPose(matrix: Matrix): void;
  15317. /**
  15318. * Gets the bind pose matrix
  15319. * @returns the bind pose matrix
  15320. */
  15321. getBindPose(): Matrix;
  15322. /**
  15323. * Sets the bind pose matrix
  15324. * @param matrix the local-space bind pose to set for this bone
  15325. */
  15326. setBindPose(matrix: Matrix): void;
  15327. /**
  15328. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15329. */
  15330. getWorldMatrix(): Matrix;
  15331. /**
  15332. * Sets the local matrix to rest pose matrix
  15333. */
  15334. returnToRest(): void;
  15335. /**
  15336. * Gets the inverse of the absolute transform matrix.
  15337. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15338. * @returns a matrix
  15339. */
  15340. getInvertedAbsoluteTransform(): Matrix;
  15341. /**
  15342. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15343. * @returns a matrix
  15344. */
  15345. getAbsoluteTransform(): Matrix;
  15346. /**
  15347. * Links with the given transform node.
  15348. * The local matrix of this bone is copied from the transform node every frame.
  15349. * @param transformNode defines the transform node to link to
  15350. */
  15351. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15352. /**
  15353. * Gets the node used to drive the bone's transformation
  15354. * @returns a transform node or null
  15355. */
  15356. getTransformNode(): Nullable<TransformNode>;
  15357. /** Gets or sets current position (in local space) */
  15358. get position(): Vector3;
  15359. set position(newPosition: Vector3);
  15360. /** Gets or sets current rotation (in local space) */
  15361. get rotation(): Vector3;
  15362. set rotation(newRotation: Vector3);
  15363. /** Gets or sets current rotation quaternion (in local space) */
  15364. get rotationQuaternion(): Quaternion;
  15365. set rotationQuaternion(newRotation: Quaternion);
  15366. /** Gets or sets current scaling (in local space) */
  15367. get scaling(): Vector3;
  15368. set scaling(newScaling: Vector3);
  15369. /**
  15370. * Gets the animation properties override
  15371. */
  15372. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15373. private _decompose;
  15374. private _compose;
  15375. /**
  15376. * Update the base and local matrices
  15377. * @param matrix defines the new base or local matrix
  15378. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15379. * @param updateLocalMatrix defines if the local matrix should be updated
  15380. */
  15381. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15382. /** @hidden */
  15383. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15384. /**
  15385. * Flag the bone as dirty (Forcing it to update everything)
  15386. */
  15387. markAsDirty(): void;
  15388. /** @hidden */
  15389. _markAsDirtyAndCompose(): void;
  15390. private _markAsDirtyAndDecompose;
  15391. /**
  15392. * Translate the bone in local or world space
  15393. * @param vec The amount to translate the bone
  15394. * @param space The space that the translation is in
  15395. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15396. */
  15397. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15398. /**
  15399. * Set the postion of the bone in local or world space
  15400. * @param position The position to set the bone
  15401. * @param space The space that the position is in
  15402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15403. */
  15404. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15405. /**
  15406. * Set the absolute position of the bone (world space)
  15407. * @param position The position to set the bone
  15408. * @param mesh The mesh that this bone is attached to
  15409. */
  15410. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15411. /**
  15412. * Scale the bone on the x, y and z axes (in local space)
  15413. * @param x The amount to scale the bone on the x axis
  15414. * @param y The amount to scale the bone on the y axis
  15415. * @param z The amount to scale the bone on the z axis
  15416. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15417. */
  15418. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15419. /**
  15420. * Set the bone scaling in local space
  15421. * @param scale defines the scaling vector
  15422. */
  15423. setScale(scale: Vector3): void;
  15424. /**
  15425. * Gets the current scaling in local space
  15426. * @returns the current scaling vector
  15427. */
  15428. getScale(): Vector3;
  15429. /**
  15430. * Gets the current scaling in local space and stores it in a target vector
  15431. * @param result defines the target vector
  15432. */
  15433. getScaleToRef(result: Vector3): void;
  15434. /**
  15435. * Set the yaw, pitch, and roll of the bone in local or world space
  15436. * @param yaw The rotation of the bone on the y axis
  15437. * @param pitch The rotation of the bone on the x axis
  15438. * @param roll The rotation of the bone on the z axis
  15439. * @param space The space that the axes of rotation are in
  15440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15441. */
  15442. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15443. /**
  15444. * Add a rotation to the bone on an axis in local or world space
  15445. * @param axis The axis to rotate the bone on
  15446. * @param amount The amount to rotate the bone
  15447. * @param space The space that the axis is in
  15448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15449. */
  15450. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15451. /**
  15452. * Set the rotation of the bone to a particular axis angle in local or world space
  15453. * @param axis The axis to rotate the bone on
  15454. * @param angle The angle that the bone should be rotated to
  15455. * @param space The space that the axis is in
  15456. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15457. */
  15458. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15459. /**
  15460. * Set the euler rotation of the bone in local or world space
  15461. * @param rotation The euler rotation that the bone should be set to
  15462. * @param space The space that the rotation is in
  15463. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15464. */
  15465. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15466. /**
  15467. * Set the quaternion rotation of the bone in local or world space
  15468. * @param quat The quaternion rotation that the bone should be set to
  15469. * @param space The space that the rotation is in
  15470. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15471. */
  15472. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15473. /**
  15474. * Set the rotation matrix of the bone in local or world space
  15475. * @param rotMat The rotation matrix that the bone should be set to
  15476. * @param space The space that the rotation is in
  15477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15478. */
  15479. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15480. private _rotateWithMatrix;
  15481. private _getNegativeRotationToRef;
  15482. /**
  15483. * Get the position of the bone in local or world space
  15484. * @param space The space that the returned position is in
  15485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15486. * @returns The position of the bone
  15487. */
  15488. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15489. /**
  15490. * Copy the position of the bone to a vector3 in local or world space
  15491. * @param space The space that the returned position is in
  15492. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15493. * @param result The vector3 to copy the position to
  15494. */
  15495. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15496. /**
  15497. * Get the absolute position of the bone (world space)
  15498. * @param mesh The mesh that this bone is attached to
  15499. * @returns The absolute position of the bone
  15500. */
  15501. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15502. /**
  15503. * Copy the absolute position of the bone (world space) to the result param
  15504. * @param mesh The mesh that this bone is attached to
  15505. * @param result The vector3 to copy the absolute position to
  15506. */
  15507. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15508. /**
  15509. * Compute the absolute transforms of this bone and its children
  15510. */
  15511. computeAbsoluteTransforms(): void;
  15512. /**
  15513. * Get the world direction from an axis that is in the local space of the bone
  15514. * @param localAxis The local direction that is used to compute the world direction
  15515. * @param mesh The mesh that this bone is attached to
  15516. * @returns The world direction
  15517. */
  15518. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15519. /**
  15520. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15521. * @param localAxis The local direction that is used to compute the world direction
  15522. * @param mesh The mesh that this bone is attached to
  15523. * @param result The vector3 that the world direction will be copied to
  15524. */
  15525. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15526. /**
  15527. * Get the euler rotation of the bone in local or world space
  15528. * @param space The space that the rotation should be in
  15529. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15530. * @returns The euler rotation
  15531. */
  15532. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15533. /**
  15534. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15535. * @param space The space that the rotation should be in
  15536. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15537. * @param result The vector3 that the rotation should be copied to
  15538. */
  15539. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15540. /**
  15541. * Get the quaternion rotation of the bone in either local or world space
  15542. * @param space The space that the rotation should be in
  15543. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15544. * @returns The quaternion rotation
  15545. */
  15546. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15547. /**
  15548. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15549. * @param space The space that the rotation should be in
  15550. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15551. * @param result The quaternion that the rotation should be copied to
  15552. */
  15553. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15554. /**
  15555. * Get the rotation matrix of the bone in local or world space
  15556. * @param space The space that the rotation should be in
  15557. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15558. * @returns The rotation matrix
  15559. */
  15560. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15561. /**
  15562. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15563. * @param space The space that the rotation should be in
  15564. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15565. * @param result The quaternion that the rotation should be copied to
  15566. */
  15567. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15568. /**
  15569. * Get the world position of a point that is in the local space of the bone
  15570. * @param position The local position
  15571. * @param mesh The mesh that this bone is attached to
  15572. * @returns The world position
  15573. */
  15574. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15575. /**
  15576. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15577. * @param position The local position
  15578. * @param mesh The mesh that this bone is attached to
  15579. * @param result The vector3 that the world position should be copied to
  15580. */
  15581. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15582. /**
  15583. * Get the local position of a point that is in world space
  15584. * @param position The world position
  15585. * @param mesh The mesh that this bone is attached to
  15586. * @returns The local position
  15587. */
  15588. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15589. /**
  15590. * Get the local position of a point that is in world space and copy it to the result param
  15591. * @param position The world position
  15592. * @param mesh The mesh that this bone is attached to
  15593. * @param result The vector3 that the local position should be copied to
  15594. */
  15595. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15596. /**
  15597. * Set the current local matrix as the restPose for this bone.
  15598. */
  15599. setCurrentPoseAsRest(): void;
  15600. }
  15601. }
  15602. declare module BABYLON {
  15603. /**
  15604. * Defines a runtime animation
  15605. */
  15606. export class RuntimeAnimation {
  15607. private _events;
  15608. /**
  15609. * The current frame of the runtime animation
  15610. */
  15611. private _currentFrame;
  15612. /**
  15613. * The animation used by the runtime animation
  15614. */
  15615. private _animation;
  15616. /**
  15617. * The target of the runtime animation
  15618. */
  15619. private _target;
  15620. /**
  15621. * The initiating animatable
  15622. */
  15623. private _host;
  15624. /**
  15625. * The original value of the runtime animation
  15626. */
  15627. private _originalValue;
  15628. /**
  15629. * The original blend value of the runtime animation
  15630. */
  15631. private _originalBlendValue;
  15632. /**
  15633. * The offsets cache of the runtime animation
  15634. */
  15635. private _offsetsCache;
  15636. /**
  15637. * The high limits cache of the runtime animation
  15638. */
  15639. private _highLimitsCache;
  15640. /**
  15641. * Specifies if the runtime animation has been stopped
  15642. */
  15643. private _stopped;
  15644. /**
  15645. * The blending factor of the runtime animation
  15646. */
  15647. private _blendingFactor;
  15648. /**
  15649. * The BabylonJS scene
  15650. */
  15651. private _scene;
  15652. /**
  15653. * The current value of the runtime animation
  15654. */
  15655. private _currentValue;
  15656. /** @hidden */
  15657. _animationState: _IAnimationState;
  15658. /**
  15659. * The active target of the runtime animation
  15660. */
  15661. private _activeTargets;
  15662. private _currentActiveTarget;
  15663. private _directTarget;
  15664. /**
  15665. * The target path of the runtime animation
  15666. */
  15667. private _targetPath;
  15668. /**
  15669. * The weight of the runtime animation
  15670. */
  15671. private _weight;
  15672. /**
  15673. * The ratio offset of the runtime animation
  15674. */
  15675. private _ratioOffset;
  15676. /**
  15677. * The previous delay of the runtime animation
  15678. */
  15679. private _previousDelay;
  15680. /**
  15681. * The previous ratio of the runtime animation
  15682. */
  15683. private _previousRatio;
  15684. private _enableBlending;
  15685. private _keys;
  15686. private _minFrame;
  15687. private _maxFrame;
  15688. private _minValue;
  15689. private _maxValue;
  15690. private _targetIsArray;
  15691. /**
  15692. * Gets the current frame of the runtime animation
  15693. */
  15694. get currentFrame(): number;
  15695. /**
  15696. * Gets the weight of the runtime animation
  15697. */
  15698. get weight(): number;
  15699. /**
  15700. * Gets the current value of the runtime animation
  15701. */
  15702. get currentValue(): any;
  15703. /**
  15704. * Gets the target path of the runtime animation
  15705. */
  15706. get targetPath(): string;
  15707. /**
  15708. * Gets the actual target of the runtime animation
  15709. */
  15710. get target(): any;
  15711. /**
  15712. * Gets the additive state of the runtime animation
  15713. */
  15714. get isAdditive(): boolean;
  15715. /** @hidden */
  15716. _onLoop: () => void;
  15717. /**
  15718. * Create a new RuntimeAnimation object
  15719. * @param target defines the target of the animation
  15720. * @param animation defines the source animation object
  15721. * @param scene defines the hosting scene
  15722. * @param host defines the initiating Animatable
  15723. */
  15724. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15725. private _preparePath;
  15726. /**
  15727. * Gets the animation from the runtime animation
  15728. */
  15729. get animation(): Animation;
  15730. /**
  15731. * Resets the runtime animation to the beginning
  15732. * @param restoreOriginal defines whether to restore the target property to the original value
  15733. */
  15734. reset(restoreOriginal?: boolean): void;
  15735. /**
  15736. * Specifies if the runtime animation is stopped
  15737. * @returns Boolean specifying if the runtime animation is stopped
  15738. */
  15739. isStopped(): boolean;
  15740. /**
  15741. * Disposes of the runtime animation
  15742. */
  15743. dispose(): void;
  15744. /**
  15745. * Apply the interpolated value to the target
  15746. * @param currentValue defines the value computed by the animation
  15747. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15748. */
  15749. setValue(currentValue: any, weight: number): void;
  15750. private _getOriginalValues;
  15751. private _setValue;
  15752. /**
  15753. * Gets the loop pmode of the runtime animation
  15754. * @returns Loop Mode
  15755. */
  15756. private _getCorrectLoopMode;
  15757. /**
  15758. * Move the current animation to a given frame
  15759. * @param frame defines the frame to move to
  15760. */
  15761. goToFrame(frame: number): void;
  15762. /**
  15763. * @hidden Internal use only
  15764. */
  15765. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15766. /**
  15767. * Execute the current animation
  15768. * @param delay defines the delay to add to the current frame
  15769. * @param from defines the lower bound of the animation range
  15770. * @param to defines the upper bound of the animation range
  15771. * @param loop defines if the current animation must loop
  15772. * @param speedRatio defines the current speed ratio
  15773. * @param weight defines the weight of the animation (default is -1 so no weight)
  15774. * @param onLoop optional callback called when animation loops
  15775. * @returns a boolean indicating if the animation is running
  15776. */
  15777. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15778. }
  15779. }
  15780. declare module BABYLON {
  15781. /**
  15782. * Class used to store an actual running animation
  15783. */
  15784. export class Animatable {
  15785. /** defines the target object */
  15786. target: any;
  15787. /** defines the starting frame number (default is 0) */
  15788. fromFrame: number;
  15789. /** defines the ending frame number (default is 100) */
  15790. toFrame: number;
  15791. /** defines if the animation must loop (default is false) */
  15792. loopAnimation: boolean;
  15793. /** defines a callback to call when animation ends if it is not looping */
  15794. onAnimationEnd?: (() => void) | null | undefined;
  15795. /** defines a callback to call when animation loops */
  15796. onAnimationLoop?: (() => void) | null | undefined;
  15797. /** defines whether the animation should be evaluated additively */
  15798. isAdditive: boolean;
  15799. private _localDelayOffset;
  15800. private _pausedDelay;
  15801. private _runtimeAnimations;
  15802. private _paused;
  15803. private _scene;
  15804. private _speedRatio;
  15805. private _weight;
  15806. private _syncRoot;
  15807. /**
  15808. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15809. * This will only apply for non looping animation (default is true)
  15810. */
  15811. disposeOnEnd: boolean;
  15812. /**
  15813. * Gets a boolean indicating if the animation has started
  15814. */
  15815. animationStarted: boolean;
  15816. /**
  15817. * Observer raised when the animation ends
  15818. */
  15819. onAnimationEndObservable: Observable<Animatable>;
  15820. /**
  15821. * Observer raised when the animation loops
  15822. */
  15823. onAnimationLoopObservable: Observable<Animatable>;
  15824. /**
  15825. * Gets the root Animatable used to synchronize and normalize animations
  15826. */
  15827. get syncRoot(): Nullable<Animatable>;
  15828. /**
  15829. * Gets the current frame of the first RuntimeAnimation
  15830. * Used to synchronize Animatables
  15831. */
  15832. get masterFrame(): number;
  15833. /**
  15834. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15835. */
  15836. get weight(): number;
  15837. set weight(value: number);
  15838. /**
  15839. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15840. */
  15841. get speedRatio(): number;
  15842. set speedRatio(value: number);
  15843. /**
  15844. * Creates a new Animatable
  15845. * @param scene defines the hosting scene
  15846. * @param target defines the target object
  15847. * @param fromFrame defines the starting frame number (default is 0)
  15848. * @param toFrame defines the ending frame number (default is 100)
  15849. * @param loopAnimation defines if the animation must loop (default is false)
  15850. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15851. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15852. * @param animations defines a group of animation to add to the new Animatable
  15853. * @param onAnimationLoop defines a callback to call when animation loops
  15854. * @param isAdditive defines whether the animation should be evaluated additively
  15855. */
  15856. constructor(scene: Scene,
  15857. /** defines the target object */
  15858. target: any,
  15859. /** defines the starting frame number (default is 0) */
  15860. fromFrame?: number,
  15861. /** defines the ending frame number (default is 100) */
  15862. toFrame?: number,
  15863. /** defines if the animation must loop (default is false) */
  15864. loopAnimation?: boolean, speedRatio?: number,
  15865. /** defines a callback to call when animation ends if it is not looping */
  15866. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15867. /** defines a callback to call when animation loops */
  15868. onAnimationLoop?: (() => void) | null | undefined,
  15869. /** defines whether the animation should be evaluated additively */
  15870. isAdditive?: boolean);
  15871. /**
  15872. * Synchronize and normalize current Animatable with a source Animatable
  15873. * This is useful when using animation weights and when animations are not of the same length
  15874. * @param root defines the root Animatable to synchronize with
  15875. * @returns the current Animatable
  15876. */
  15877. syncWith(root: Animatable): Animatable;
  15878. /**
  15879. * Gets the list of runtime animations
  15880. * @returns an array of RuntimeAnimation
  15881. */
  15882. getAnimations(): RuntimeAnimation[];
  15883. /**
  15884. * Adds more animations to the current animatable
  15885. * @param target defines the target of the animations
  15886. * @param animations defines the new animations to add
  15887. */
  15888. appendAnimations(target: any, animations: Animation[]): void;
  15889. /**
  15890. * Gets the source animation for a specific property
  15891. * @param property defines the propertyu to look for
  15892. * @returns null or the source animation for the given property
  15893. */
  15894. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15895. /**
  15896. * Gets the runtime animation for a specific property
  15897. * @param property defines the propertyu to look for
  15898. * @returns null or the runtime animation for the given property
  15899. */
  15900. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15901. /**
  15902. * Resets the animatable to its original state
  15903. */
  15904. reset(): void;
  15905. /**
  15906. * Allows the animatable to blend with current running animations
  15907. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15908. * @param blendingSpeed defines the blending speed to use
  15909. */
  15910. enableBlending(blendingSpeed: number): void;
  15911. /**
  15912. * Disable animation blending
  15913. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15914. */
  15915. disableBlending(): void;
  15916. /**
  15917. * Jump directly to a given frame
  15918. * @param frame defines the frame to jump to
  15919. */
  15920. goToFrame(frame: number): void;
  15921. /**
  15922. * Pause the animation
  15923. */
  15924. pause(): void;
  15925. /**
  15926. * Restart the animation
  15927. */
  15928. restart(): void;
  15929. private _raiseOnAnimationEnd;
  15930. /**
  15931. * Stop and delete the current animation
  15932. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15933. * @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)
  15934. */
  15935. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15936. /**
  15937. * Wait asynchronously for the animation to end
  15938. * @returns a promise which will be fullfilled when the animation ends
  15939. */
  15940. waitAsync(): Promise<Animatable>;
  15941. /** @hidden */
  15942. _animate(delay: number): boolean;
  15943. }
  15944. interface Scene {
  15945. /** @hidden */
  15946. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15947. /** @hidden */
  15948. _processLateAnimationBindingsForMatrices(holder: {
  15949. totalWeight: number;
  15950. totalAdditiveWeight: number;
  15951. animations: RuntimeAnimation[];
  15952. additiveAnimations: RuntimeAnimation[];
  15953. originalValue: Matrix;
  15954. }): any;
  15955. /** @hidden */
  15956. _processLateAnimationBindingsForQuaternions(holder: {
  15957. totalWeight: number;
  15958. totalAdditiveWeight: number;
  15959. animations: RuntimeAnimation[];
  15960. additiveAnimations: RuntimeAnimation[];
  15961. originalValue: Quaternion;
  15962. }, refQuaternion: Quaternion): Quaternion;
  15963. /** @hidden */
  15964. _processLateAnimationBindings(): void;
  15965. /**
  15966. * Will start the animation sequence of a given target
  15967. * @param target defines the target
  15968. * @param from defines from which frame should animation start
  15969. * @param to defines until which frame should animation run.
  15970. * @param weight defines the weight to apply to the animation (1.0 by default)
  15971. * @param loop defines if the animation loops
  15972. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15973. * @param onAnimationEnd defines the function to be executed when the animation ends
  15974. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15975. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15976. * @param onAnimationLoop defines the callback to call when an animation loops
  15977. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15978. * @returns the animatable object created for this animation
  15979. */
  15980. 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;
  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 loop defines if the animation loops
  15987. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15988. * @param onAnimationEnd defines the function to be executed when the animation ends
  15989. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15990. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15991. * @param targetMask defines if the target should be animate 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. 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;
  15997. /**
  15998. * Will start the animation sequence of a given target and its hierarchy
  15999. * @param target defines the target
  16000. * @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.
  16001. * @param from defines from which frame should animation start
  16002. * @param to defines until which frame should animation run.
  16003. * @param loop defines if the animation loops
  16004. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16005. * @param onAnimationEnd defines the function to be executed when the animation ends
  16006. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16007. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16008. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16009. * @param onAnimationLoop defines the callback to call when an animation loops
  16010. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16011. * @returns the list of created animatables
  16012. */
  16013. 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[];
  16014. /**
  16015. * Begin a new animation on a given node
  16016. * @param target defines the target where the animation will take place
  16017. * @param animations defines the list of animations to start
  16018. * @param from defines the initial value
  16019. * @param to defines the final value
  16020. * @param loop defines if you want animation to loop (off by default)
  16021. * @param speedRatio defines the speed ratio to apply to all animations
  16022. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16023. * @param onAnimationLoop defines the callback to call when an animation loops
  16024. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16025. * @returns the list of created animatables
  16026. */
  16027. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16028. /**
  16029. * Begin a new animation on a given node and its hierarchy
  16030. * @param target defines the root node where the animation will take place
  16031. * @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.
  16032. * @param animations defines the list of animations to start
  16033. * @param from defines the initial value
  16034. * @param to defines the final value
  16035. * @param loop defines if you want animation to loop (off by default)
  16036. * @param speedRatio defines the speed ratio to apply to all animations
  16037. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16038. * @param onAnimationLoop defines the callback to call when an animation loops
  16039. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16040. * @returns the list of animatables created for all nodes
  16041. */
  16042. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16043. /**
  16044. * Gets the animatable associated with a specific target
  16045. * @param target defines the target of the animatable
  16046. * @returns the required animatable if found
  16047. */
  16048. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16049. /**
  16050. * Gets all animatables associated with a given target
  16051. * @param target defines the target to look animatables for
  16052. * @returns an array of Animatables
  16053. */
  16054. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16055. /**
  16056. * Stops and removes all animations that have been applied to the scene
  16057. */
  16058. stopAllAnimations(): void;
  16059. /**
  16060. * Gets the current delta time used by animation engine
  16061. */
  16062. deltaTime: number;
  16063. }
  16064. interface Bone {
  16065. /**
  16066. * Copy an animation range from another bone
  16067. * @param source defines the source bone
  16068. * @param rangeName defines the range name to copy
  16069. * @param frameOffset defines the frame offset
  16070. * @param rescaleAsRequired defines if rescaling must be applied if required
  16071. * @param skelDimensionsRatio defines the scaling ratio
  16072. * @returns true if operation was successful
  16073. */
  16074. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16075. }
  16076. }
  16077. declare module BABYLON {
  16078. /**
  16079. * Class used to handle skinning animations
  16080. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16081. */
  16082. export class Skeleton implements IAnimatable {
  16083. /** defines the skeleton name */
  16084. name: string;
  16085. /** defines the skeleton Id */
  16086. id: string;
  16087. /**
  16088. * Defines the list of child bones
  16089. */
  16090. bones: Bone[];
  16091. /**
  16092. * Defines an estimate of the dimension of the skeleton at rest
  16093. */
  16094. dimensionsAtRest: Vector3;
  16095. /**
  16096. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16097. */
  16098. needInitialSkinMatrix: boolean;
  16099. /**
  16100. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16101. */
  16102. overrideMesh: Nullable<AbstractMesh>;
  16103. /**
  16104. * Gets the list of animations attached to this skeleton
  16105. */
  16106. animations: Array<Animation>;
  16107. private _scene;
  16108. private _isDirty;
  16109. private _transformMatrices;
  16110. private _transformMatrixTexture;
  16111. private _meshesWithPoseMatrix;
  16112. private _animatables;
  16113. private _identity;
  16114. private _synchronizedWithMesh;
  16115. private _ranges;
  16116. private _lastAbsoluteTransformsUpdateId;
  16117. private _canUseTextureForBones;
  16118. private _uniqueId;
  16119. /** @hidden */
  16120. _numBonesWithLinkedTransformNode: number;
  16121. /** @hidden */
  16122. _hasWaitingData: Nullable<boolean>;
  16123. /** @hidden */
  16124. _waitingOverrideMeshId: Nullable<string>;
  16125. /**
  16126. * Specifies if the skeleton should be serialized
  16127. */
  16128. doNotSerialize: boolean;
  16129. private _useTextureToStoreBoneMatrices;
  16130. /**
  16131. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16132. * Please note that this option is not available if the hardware does not support it
  16133. */
  16134. get useTextureToStoreBoneMatrices(): boolean;
  16135. set useTextureToStoreBoneMatrices(value: boolean);
  16136. private _animationPropertiesOverride;
  16137. /**
  16138. * Gets or sets the animation properties override
  16139. */
  16140. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16141. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16142. /**
  16143. * List of inspectable custom properties (used by the Inspector)
  16144. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16145. */
  16146. inspectableCustomProperties: IInspectable[];
  16147. /**
  16148. * An observable triggered before computing the skeleton's matrices
  16149. */
  16150. onBeforeComputeObservable: Observable<Skeleton>;
  16151. /**
  16152. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16153. */
  16154. get isUsingTextureForMatrices(): boolean;
  16155. /**
  16156. * Gets the unique ID of this skeleton
  16157. */
  16158. get uniqueId(): number;
  16159. /**
  16160. * Creates a new skeleton
  16161. * @param name defines the skeleton name
  16162. * @param id defines the skeleton Id
  16163. * @param scene defines the hosting scene
  16164. */
  16165. constructor(
  16166. /** defines the skeleton name */
  16167. name: string,
  16168. /** defines the skeleton Id */
  16169. id: string, scene: Scene);
  16170. /**
  16171. * Gets the current object class name.
  16172. * @return the class name
  16173. */
  16174. getClassName(): string;
  16175. /**
  16176. * Returns an array containing the root bones
  16177. * @returns an array containing the root bones
  16178. */
  16179. getChildren(): Array<Bone>;
  16180. /**
  16181. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16182. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16183. * @returns a Float32Array containing matrices data
  16184. */
  16185. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16186. /**
  16187. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16188. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16189. * @returns a raw texture containing the data
  16190. */
  16191. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16192. /**
  16193. * Gets the current hosting scene
  16194. * @returns a scene object
  16195. */
  16196. getScene(): Scene;
  16197. /**
  16198. * Gets a string representing the current skeleton data
  16199. * @param fullDetails defines a boolean indicating if we want a verbose version
  16200. * @returns a string representing the current skeleton data
  16201. */
  16202. toString(fullDetails?: boolean): string;
  16203. /**
  16204. * Get bone's index searching by name
  16205. * @param name defines bone's name to search for
  16206. * @return the indice of the bone. Returns -1 if not found
  16207. */
  16208. getBoneIndexByName(name: string): number;
  16209. /**
  16210. * Creater a new animation range
  16211. * @param name defines the name of the range
  16212. * @param from defines the start key
  16213. * @param to defines the end key
  16214. */
  16215. createAnimationRange(name: string, from: number, to: number): void;
  16216. /**
  16217. * Delete a specific animation range
  16218. * @param name defines the name of the range
  16219. * @param deleteFrames defines if frames must be removed as well
  16220. */
  16221. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16222. /**
  16223. * Gets a specific animation range
  16224. * @param name defines the name of the range to look for
  16225. * @returns the requested animation range or null if not found
  16226. */
  16227. getAnimationRange(name: string): Nullable<AnimationRange>;
  16228. /**
  16229. * Gets the list of all animation ranges defined on this skeleton
  16230. * @returns an array
  16231. */
  16232. getAnimationRanges(): Nullable<AnimationRange>[];
  16233. /**
  16234. * Copy animation range from a source skeleton.
  16235. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16236. * @param source defines the source skeleton
  16237. * @param name defines the name of the range to copy
  16238. * @param rescaleAsRequired defines if rescaling must be applied if required
  16239. * @returns true if operation was successful
  16240. */
  16241. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16242. /**
  16243. * Forces the skeleton to go to rest pose
  16244. */
  16245. returnToRest(): void;
  16246. private _getHighestAnimationFrame;
  16247. /**
  16248. * Begin a specific animation range
  16249. * @param name defines the name of the range to start
  16250. * @param loop defines if looping must be turned on (false by default)
  16251. * @param speedRatio defines the speed ratio to apply (1 by default)
  16252. * @param onAnimationEnd defines a callback which will be called when animation will end
  16253. * @returns a new animatable
  16254. */
  16255. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16256. /**
  16257. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16258. * @param skeleton defines the Skeleton containing the animation range to convert
  16259. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16260. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16261. * @returns the original skeleton
  16262. */
  16263. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16264. /** @hidden */
  16265. _markAsDirty(): void;
  16266. /** @hidden */
  16267. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16268. /** @hidden */
  16269. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16270. private _computeTransformMatrices;
  16271. /**
  16272. * Build all resources required to render a skeleton
  16273. */
  16274. prepare(): void;
  16275. /**
  16276. * Gets the list of animatables currently running for this skeleton
  16277. * @returns an array of animatables
  16278. */
  16279. getAnimatables(): IAnimatable[];
  16280. /**
  16281. * Clone the current skeleton
  16282. * @param name defines the name of the new skeleton
  16283. * @param id defines the id of the new skeleton
  16284. * @returns the new skeleton
  16285. */
  16286. clone(name: string, id?: string): Skeleton;
  16287. /**
  16288. * Enable animation blending for this skeleton
  16289. * @param blendingSpeed defines the blending speed to apply
  16290. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16291. */
  16292. enableBlending(blendingSpeed?: number): void;
  16293. /**
  16294. * Releases all resources associated with the current skeleton
  16295. */
  16296. dispose(): void;
  16297. /**
  16298. * Serialize the skeleton in a JSON object
  16299. * @returns a JSON object
  16300. */
  16301. serialize(): any;
  16302. /**
  16303. * Creates a new skeleton from serialized data
  16304. * @param parsedSkeleton defines the serialized data
  16305. * @param scene defines the hosting scene
  16306. * @returns a new skeleton
  16307. */
  16308. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16309. /**
  16310. * Compute all node absolute transforms
  16311. * @param forceUpdate defines if computation must be done even if cache is up to date
  16312. */
  16313. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16314. /**
  16315. * Gets the root pose matrix
  16316. * @returns a matrix
  16317. */
  16318. getPoseMatrix(): Nullable<Matrix>;
  16319. /**
  16320. * Sorts bones per internal index
  16321. */
  16322. sortBones(): void;
  16323. private _sortBones;
  16324. /**
  16325. * Set the current local matrix as the restPose for all bones in the skeleton.
  16326. */
  16327. setCurrentPoseAsRest(): void;
  16328. }
  16329. }
  16330. declare module BABYLON {
  16331. /**
  16332. * Creates an instance based on a source mesh.
  16333. */
  16334. export class InstancedMesh extends AbstractMesh {
  16335. private _sourceMesh;
  16336. private _currentLOD;
  16337. /** @hidden */
  16338. _indexInSourceMeshInstanceArray: number;
  16339. constructor(name: string, source: Mesh);
  16340. /**
  16341. * Returns the string "InstancedMesh".
  16342. */
  16343. getClassName(): string;
  16344. /** Gets the list of lights affecting that mesh */
  16345. get lightSources(): Light[];
  16346. _resyncLightSources(): void;
  16347. _resyncLightSource(light: Light): void;
  16348. _removeLightSource(light: Light, dispose: boolean): void;
  16349. /**
  16350. * If the source mesh receives shadows
  16351. */
  16352. get receiveShadows(): boolean;
  16353. /**
  16354. * The material of the source mesh
  16355. */
  16356. get material(): Nullable<Material>;
  16357. /**
  16358. * Visibility of the source mesh
  16359. */
  16360. get visibility(): number;
  16361. /**
  16362. * Skeleton of the source mesh
  16363. */
  16364. get skeleton(): Nullable<Skeleton>;
  16365. /**
  16366. * Rendering ground id of the source mesh
  16367. */
  16368. get renderingGroupId(): number;
  16369. set renderingGroupId(value: number);
  16370. /**
  16371. * Returns the total number of vertices (integer).
  16372. */
  16373. getTotalVertices(): number;
  16374. /**
  16375. * Returns a positive integer : the total number of indices in this mesh geometry.
  16376. * @returns the numner of indices or zero if the mesh has no geometry.
  16377. */
  16378. getTotalIndices(): number;
  16379. /**
  16380. * The source mesh of the instance
  16381. */
  16382. get sourceMesh(): Mesh;
  16383. /**
  16384. * Creates a new InstancedMesh object from the mesh model.
  16385. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16386. * @param name defines the name of the new instance
  16387. * @returns a new InstancedMesh
  16388. */
  16389. createInstance(name: string): InstancedMesh;
  16390. /**
  16391. * Is this node ready to be used/rendered
  16392. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16393. * @return {boolean} is it ready
  16394. */
  16395. isReady(completeCheck?: boolean): boolean;
  16396. /**
  16397. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16398. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16399. * @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.
  16400. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16401. */
  16402. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16403. /**
  16404. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16405. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16406. * The `data` are either a numeric array either a Float32Array.
  16407. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16408. * 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).
  16409. * Note that a new underlying VertexBuffer object is created each call.
  16410. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16411. *
  16412. * Possible `kind` values :
  16413. * - VertexBuffer.PositionKind
  16414. * - VertexBuffer.UVKind
  16415. * - VertexBuffer.UV2Kind
  16416. * - VertexBuffer.UV3Kind
  16417. * - VertexBuffer.UV4Kind
  16418. * - VertexBuffer.UV5Kind
  16419. * - VertexBuffer.UV6Kind
  16420. * - VertexBuffer.ColorKind
  16421. * - VertexBuffer.MatricesIndicesKind
  16422. * - VertexBuffer.MatricesIndicesExtraKind
  16423. * - VertexBuffer.MatricesWeightsKind
  16424. * - VertexBuffer.MatricesWeightsExtraKind
  16425. *
  16426. * Returns the Mesh.
  16427. */
  16428. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16429. /**
  16430. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16431. * If the mesh has no geometry, it is simply returned as it is.
  16432. * The `data` are either a numeric array either a Float32Array.
  16433. * No new underlying VertexBuffer object is created.
  16434. * 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.
  16435. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16436. *
  16437. * Possible `kind` values :
  16438. * - VertexBuffer.PositionKind
  16439. * - VertexBuffer.UVKind
  16440. * - VertexBuffer.UV2Kind
  16441. * - VertexBuffer.UV3Kind
  16442. * - VertexBuffer.UV4Kind
  16443. * - VertexBuffer.UV5Kind
  16444. * - VertexBuffer.UV6Kind
  16445. * - VertexBuffer.ColorKind
  16446. * - VertexBuffer.MatricesIndicesKind
  16447. * - VertexBuffer.MatricesIndicesExtraKind
  16448. * - VertexBuffer.MatricesWeightsKind
  16449. * - VertexBuffer.MatricesWeightsExtraKind
  16450. *
  16451. * Returns the Mesh.
  16452. */
  16453. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16454. /**
  16455. * Sets the mesh indices.
  16456. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16457. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16458. * This method creates a new index buffer each call.
  16459. * Returns the Mesh.
  16460. */
  16461. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16462. /**
  16463. * Boolean : True if the mesh owns the requested kind of data.
  16464. */
  16465. isVerticesDataPresent(kind: string): boolean;
  16466. /**
  16467. * Returns an array of indices (IndicesArray).
  16468. */
  16469. getIndices(): Nullable<IndicesArray>;
  16470. get _positions(): Nullable<Vector3[]>;
  16471. /**
  16472. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16473. * This means the mesh underlying bounding box and sphere are recomputed.
  16474. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16475. * @returns the current mesh
  16476. */
  16477. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16478. /** @hidden */
  16479. _preActivate(): InstancedMesh;
  16480. /** @hidden */
  16481. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16482. /** @hidden */
  16483. _postActivate(): void;
  16484. getWorldMatrix(): Matrix;
  16485. get isAnInstance(): boolean;
  16486. /**
  16487. * Returns the current associated LOD AbstractMesh.
  16488. */
  16489. getLOD(camera: Camera): AbstractMesh;
  16490. /** @hidden */
  16491. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16492. /** @hidden */
  16493. _syncSubMeshes(): InstancedMesh;
  16494. /** @hidden */
  16495. _generatePointsArray(): boolean;
  16496. /** @hidden */
  16497. _updateBoundingInfo(): AbstractMesh;
  16498. /**
  16499. * Creates a new InstancedMesh from the current mesh.
  16500. * - name (string) : the cloned mesh name
  16501. * - newParent (optional Node) : the optional Node to parent the clone to.
  16502. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16503. *
  16504. * Returns the clone.
  16505. */
  16506. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16507. /**
  16508. * Disposes the InstancedMesh.
  16509. * Returns nothing.
  16510. */
  16511. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16512. }
  16513. interface Mesh {
  16514. /**
  16515. * Register a custom buffer that will be instanced
  16516. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16517. * @param kind defines the buffer kind
  16518. * @param stride defines the stride in floats
  16519. */
  16520. registerInstancedBuffer(kind: string, stride: number): void;
  16521. /**
  16522. * true to use the edge renderer for all instances of this mesh
  16523. */
  16524. edgesShareWithInstances: boolean;
  16525. /** @hidden */
  16526. _userInstancedBuffersStorage: {
  16527. data: {
  16528. [key: string]: Float32Array;
  16529. };
  16530. sizes: {
  16531. [key: string]: number;
  16532. };
  16533. vertexBuffers: {
  16534. [key: string]: Nullable<VertexBuffer>;
  16535. };
  16536. strides: {
  16537. [key: string]: number;
  16538. };
  16539. };
  16540. }
  16541. interface AbstractMesh {
  16542. /**
  16543. * Object used to store instanced buffers defined by user
  16544. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16545. */
  16546. instancedBuffers: {
  16547. [key: string]: any;
  16548. };
  16549. }
  16550. }
  16551. declare module BABYLON {
  16552. /**
  16553. * Defines the options associated with the creation of a shader material.
  16554. */
  16555. export interface IShaderMaterialOptions {
  16556. /**
  16557. * Does the material work in alpha blend mode
  16558. */
  16559. needAlphaBlending: boolean;
  16560. /**
  16561. * Does the material work in alpha test mode
  16562. */
  16563. needAlphaTesting: boolean;
  16564. /**
  16565. * The list of attribute names used in the shader
  16566. */
  16567. attributes: string[];
  16568. /**
  16569. * The list of unifrom names used in the shader
  16570. */
  16571. uniforms: string[];
  16572. /**
  16573. * The list of UBO names used in the shader
  16574. */
  16575. uniformBuffers: string[];
  16576. /**
  16577. * The list of sampler names used in the shader
  16578. */
  16579. samplers: string[];
  16580. /**
  16581. * The list of defines used in the shader
  16582. */
  16583. defines: string[];
  16584. }
  16585. /**
  16586. * 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.
  16587. *
  16588. * This returned material effects how the mesh will look based on the code in the shaders.
  16589. *
  16590. * @see https://doc.babylonjs.com/how_to/shader_material
  16591. */
  16592. export class ShaderMaterial extends Material {
  16593. private _shaderPath;
  16594. private _options;
  16595. private _textures;
  16596. private _textureArrays;
  16597. private _floats;
  16598. private _ints;
  16599. private _floatsArrays;
  16600. private _colors3;
  16601. private _colors3Arrays;
  16602. private _colors4;
  16603. private _colors4Arrays;
  16604. private _vectors2;
  16605. private _vectors3;
  16606. private _vectors4;
  16607. private _matrices;
  16608. private _matrixArrays;
  16609. private _matrices3x3;
  16610. private _matrices2x2;
  16611. private _vectors2Arrays;
  16612. private _vectors3Arrays;
  16613. private _vectors4Arrays;
  16614. private _cachedWorldViewMatrix;
  16615. private _cachedWorldViewProjectionMatrix;
  16616. private _renderId;
  16617. private _multiview;
  16618. private _cachedDefines;
  16619. /** Define the Url to load snippets */
  16620. static SnippetUrl: string;
  16621. /** Snippet ID if the material was created from the snippet server */
  16622. snippetId: string;
  16623. /**
  16624. * Instantiate a new shader material.
  16625. * 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.
  16626. * This returned material effects how the mesh will look based on the code in the shaders.
  16627. * @see https://doc.babylonjs.com/how_to/shader_material
  16628. * @param name Define the name of the material in the scene
  16629. * @param scene Define the scene the material belongs to
  16630. * @param shaderPath Defines the route to the shader code in one of three ways:
  16631. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16632. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16633. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16634. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16635. * @param options Define the options used to create the shader
  16636. */
  16637. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16638. /**
  16639. * Gets the shader path used to define the shader code
  16640. * It can be modified to trigger a new compilation
  16641. */
  16642. get shaderPath(): any;
  16643. /**
  16644. * Sets the shader path used to define the shader code
  16645. * It can be modified to trigger a new compilation
  16646. */
  16647. set shaderPath(shaderPath: any);
  16648. /**
  16649. * Gets the options used to compile the shader.
  16650. * They can be modified to trigger a new compilation
  16651. */
  16652. get options(): IShaderMaterialOptions;
  16653. /**
  16654. * Gets the current class name of the material e.g. "ShaderMaterial"
  16655. * Mainly use in serialization.
  16656. * @returns the class name
  16657. */
  16658. getClassName(): string;
  16659. /**
  16660. * Specifies if the material will require alpha blending
  16661. * @returns a boolean specifying if alpha blending is needed
  16662. */
  16663. needAlphaBlending(): boolean;
  16664. /**
  16665. * Specifies if this material should be rendered in alpha test mode
  16666. * @returns a boolean specifying if an alpha test is needed.
  16667. */
  16668. needAlphaTesting(): boolean;
  16669. private _checkUniform;
  16670. /**
  16671. * Set a texture in the shader.
  16672. * @param name Define the name of the uniform samplers as defined in the shader
  16673. * @param texture Define the texture to bind to this sampler
  16674. * @return the material itself allowing "fluent" like uniform updates
  16675. */
  16676. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16677. /**
  16678. * Set a texture array in the shader.
  16679. * @param name Define the name of the uniform sampler array as defined in the shader
  16680. * @param textures Define the list of textures to bind to this sampler
  16681. * @return the material itself allowing "fluent" like uniform updates
  16682. */
  16683. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16684. /**
  16685. * Set a float in the shader.
  16686. * @param name Define the name of the uniform as defined in the shader
  16687. * @param value Define the value to give to the uniform
  16688. * @return the material itself allowing "fluent" like uniform updates
  16689. */
  16690. setFloat(name: string, value: number): ShaderMaterial;
  16691. /**
  16692. * Set a int in the shader.
  16693. * @param name Define the name of the uniform as defined in the shader
  16694. * @param value Define the value to give to the uniform
  16695. * @return the material itself allowing "fluent" like uniform updates
  16696. */
  16697. setInt(name: string, value: number): ShaderMaterial;
  16698. /**
  16699. * Set an array of floats in the shader.
  16700. * @param name Define the name of the uniform as defined in the shader
  16701. * @param value Define the value to give to the uniform
  16702. * @return the material itself allowing "fluent" like uniform updates
  16703. */
  16704. setFloats(name: string, value: number[]): ShaderMaterial;
  16705. /**
  16706. * Set a vec3 in the shader from a Color3.
  16707. * @param name Define the name of the uniform as defined in the shader
  16708. * @param value Define the value to give to the uniform
  16709. * @return the material itself allowing "fluent" like uniform updates
  16710. */
  16711. setColor3(name: string, value: Color3): ShaderMaterial;
  16712. /**
  16713. * Set a vec3 array in the shader from a Color3 array.
  16714. * @param name Define the name of the uniform as defined in the shader
  16715. * @param value Define the value to give to the uniform
  16716. * @return the material itself allowing "fluent" like uniform updates
  16717. */
  16718. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16719. /**
  16720. * Set a vec4 in the shader from a Color4.
  16721. * @param name Define the name of the uniform as defined in the shader
  16722. * @param value Define the value to give to the uniform
  16723. * @return the material itself allowing "fluent" like uniform updates
  16724. */
  16725. setColor4(name: string, value: Color4): ShaderMaterial;
  16726. /**
  16727. * Set a vec4 array in the shader from a Color4 array.
  16728. * @param name Define the name of the uniform as defined in the shader
  16729. * @param value Define the value to give to the uniform
  16730. * @return the material itself allowing "fluent" like uniform updates
  16731. */
  16732. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16733. /**
  16734. * Set a vec2 in the shader from a Vector2.
  16735. * @param name Define the name of the uniform as defined in the shader
  16736. * @param value Define the value to give to the uniform
  16737. * @return the material itself allowing "fluent" like uniform updates
  16738. */
  16739. setVector2(name: string, value: Vector2): ShaderMaterial;
  16740. /**
  16741. * Set a vec3 in the shader from a Vector3.
  16742. * @param name Define the name of the uniform as defined in the shader
  16743. * @param value Define the value to give to the uniform
  16744. * @return the material itself allowing "fluent" like uniform updates
  16745. */
  16746. setVector3(name: string, value: Vector3): ShaderMaterial;
  16747. /**
  16748. * Set a vec4 in the shader from a Vector4.
  16749. * @param name Define the name of the uniform as defined in the shader
  16750. * @param value Define the value to give to the uniform
  16751. * @return the material itself allowing "fluent" like uniform updates
  16752. */
  16753. setVector4(name: string, value: Vector4): ShaderMaterial;
  16754. /**
  16755. * Set a mat4 in the shader from a Matrix.
  16756. * @param name Define the name of the uniform as defined in the shader
  16757. * @param value Define the value to give to the uniform
  16758. * @return the material itself allowing "fluent" like uniform updates
  16759. */
  16760. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16761. /**
  16762. * Set a float32Array in the shader from a matrix array.
  16763. * @param name Define the name of the uniform as defined in the shader
  16764. * @param value Define the value to give to the uniform
  16765. * @return the material itself allowing "fluent" like uniform updates
  16766. */
  16767. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16768. /**
  16769. * Set a mat3 in the shader from a Float32Array.
  16770. * @param name Define the name of the uniform as defined in the shader
  16771. * @param value Define the value to give to the uniform
  16772. * @return the material itself allowing "fluent" like uniform updates
  16773. */
  16774. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16775. /**
  16776. * Set a mat2 in the shader from a Float32Array.
  16777. * @param name Define the name of the uniform as defined in the shader
  16778. * @param value Define the value to give to the uniform
  16779. * @return the material itself allowing "fluent" like uniform updates
  16780. */
  16781. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16782. /**
  16783. * Set a vec2 array in the shader from a number array.
  16784. * @param name Define the name of the uniform as defined in the shader
  16785. * @param value Define the value to give to the uniform
  16786. * @return the material itself allowing "fluent" like uniform updates
  16787. */
  16788. setArray2(name: string, value: number[]): ShaderMaterial;
  16789. /**
  16790. * Set a vec3 array in the shader from a number array.
  16791. * @param name Define the name of the uniform as defined in the shader
  16792. * @param value Define the value to give to the uniform
  16793. * @return the material itself allowing "fluent" like uniform updates
  16794. */
  16795. setArray3(name: string, value: number[]): ShaderMaterial;
  16796. /**
  16797. * Set a vec4 array in the shader from a number array.
  16798. * @param name Define the name of the uniform as defined in the shader
  16799. * @param value Define the value to give to the uniform
  16800. * @return the material itself allowing "fluent" like uniform updates
  16801. */
  16802. setArray4(name: string, value: number[]): ShaderMaterial;
  16803. private _checkCache;
  16804. /**
  16805. * Specifies that the submesh is ready to be used
  16806. * @param mesh defines the mesh to check
  16807. * @param subMesh defines which submesh to check
  16808. * @param useInstances specifies that instances should be used
  16809. * @returns a boolean indicating that the submesh is ready or not
  16810. */
  16811. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16812. /**
  16813. * Checks if the material is ready to render the requested mesh
  16814. * @param mesh Define the mesh to render
  16815. * @param useInstances Define whether or not the material is used with instances
  16816. * @returns true if ready, otherwise false
  16817. */
  16818. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16819. /**
  16820. * Binds the world matrix to the material
  16821. * @param world defines the world transformation matrix
  16822. * @param effectOverride - If provided, use this effect instead of internal effect
  16823. */
  16824. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16825. /**
  16826. * Binds the submesh to this material by preparing the effect and shader to draw
  16827. * @param world defines the world transformation matrix
  16828. * @param mesh defines the mesh containing the submesh
  16829. * @param subMesh defines the submesh to bind the material to
  16830. */
  16831. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16832. /**
  16833. * Binds the material to the mesh
  16834. * @param world defines the world transformation matrix
  16835. * @param mesh defines the mesh to bind the material to
  16836. * @param effectOverride - If provided, use this effect instead of internal effect
  16837. */
  16838. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16839. protected _afterBind(mesh?: Mesh): void;
  16840. /**
  16841. * Gets the active textures from the material
  16842. * @returns an array of textures
  16843. */
  16844. getActiveTextures(): BaseTexture[];
  16845. /**
  16846. * Specifies if the material uses a texture
  16847. * @param texture defines the texture to check against the material
  16848. * @returns a boolean specifying if the material uses the texture
  16849. */
  16850. hasTexture(texture: BaseTexture): boolean;
  16851. /**
  16852. * Makes a duplicate of the material, and gives it a new name
  16853. * @param name defines the new name for the duplicated material
  16854. * @returns the cloned material
  16855. */
  16856. clone(name: string): ShaderMaterial;
  16857. /**
  16858. * Disposes the material
  16859. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16860. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16861. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16862. */
  16863. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16864. /**
  16865. * Serializes this material in a JSON representation
  16866. * @returns the serialized material object
  16867. */
  16868. serialize(): any;
  16869. /**
  16870. * Creates a shader material from parsed shader material data
  16871. * @param source defines the JSON represnetation of the material
  16872. * @param scene defines the hosting scene
  16873. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16874. * @returns a new material
  16875. */
  16876. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16877. /**
  16878. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16879. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16880. * @param url defines the url to load from
  16881. * @param scene defines the hosting scene
  16882. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16883. * @returns a promise that will resolve to the new ShaderMaterial
  16884. */
  16885. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16886. /**
  16887. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16888. * @param snippetId defines the snippet to load
  16889. * @param scene defines the hosting scene
  16890. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16891. * @returns a promise that will resolve to the new ShaderMaterial
  16892. */
  16893. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16894. }
  16895. }
  16896. declare module BABYLON {
  16897. /** @hidden */
  16898. export var colorPixelShader: {
  16899. name: string;
  16900. shader: string;
  16901. };
  16902. }
  16903. declare module BABYLON {
  16904. /** @hidden */
  16905. export var colorVertexShader: {
  16906. name: string;
  16907. shader: string;
  16908. };
  16909. }
  16910. declare module BABYLON {
  16911. /**
  16912. * Line mesh
  16913. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16914. */
  16915. export class LinesMesh extends Mesh {
  16916. /**
  16917. * If vertex color should be applied to the mesh
  16918. */
  16919. readonly useVertexColor?: boolean | undefined;
  16920. /**
  16921. * If vertex alpha should be applied to the mesh
  16922. */
  16923. readonly useVertexAlpha?: boolean | undefined;
  16924. /**
  16925. * Color of the line (Default: White)
  16926. */
  16927. color: Color3;
  16928. /**
  16929. * Alpha of the line (Default: 1)
  16930. */
  16931. alpha: number;
  16932. /**
  16933. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16934. * This margin is expressed in world space coordinates, so its value may vary.
  16935. * Default value is 0.1
  16936. */
  16937. intersectionThreshold: number;
  16938. private _colorShader;
  16939. private color4;
  16940. /**
  16941. * Creates a new LinesMesh
  16942. * @param name defines the name
  16943. * @param scene defines the hosting scene
  16944. * @param parent defines the parent mesh if any
  16945. * @param source defines the optional source LinesMesh used to clone data from
  16946. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16947. * When false, achieved by calling a clone(), also passing False.
  16948. * This will make creation of children, recursive.
  16949. * @param useVertexColor defines if this LinesMesh supports vertex color
  16950. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16951. */
  16952. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16953. /**
  16954. * If vertex color should be applied to the mesh
  16955. */
  16956. useVertexColor?: boolean | undefined,
  16957. /**
  16958. * If vertex alpha should be applied to the mesh
  16959. */
  16960. useVertexAlpha?: boolean | undefined);
  16961. private _addClipPlaneDefine;
  16962. private _removeClipPlaneDefine;
  16963. isReady(): boolean;
  16964. /**
  16965. * Returns the string "LineMesh"
  16966. */
  16967. getClassName(): string;
  16968. /**
  16969. * @hidden
  16970. */
  16971. get material(): Material;
  16972. /**
  16973. * @hidden
  16974. */
  16975. set material(value: Material);
  16976. /**
  16977. * @hidden
  16978. */
  16979. get checkCollisions(): boolean;
  16980. /** @hidden */
  16981. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16982. /** @hidden */
  16983. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16984. /**
  16985. * Disposes of the line mesh
  16986. * @param doNotRecurse If children should be disposed
  16987. */
  16988. dispose(doNotRecurse?: boolean): void;
  16989. /**
  16990. * Returns a new LineMesh object cloned from the current one.
  16991. */
  16992. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16993. /**
  16994. * Creates a new InstancedLinesMesh object from the mesh model.
  16995. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16996. * @param name defines the name of the new instance
  16997. * @returns a new InstancedLinesMesh
  16998. */
  16999. createInstance(name: string): InstancedLinesMesh;
  17000. }
  17001. /**
  17002. * Creates an instance based on a source LinesMesh
  17003. */
  17004. export class InstancedLinesMesh extends InstancedMesh {
  17005. /**
  17006. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17007. * This margin is expressed in world space coordinates, so its value may vary.
  17008. * Initilized with the intersectionThreshold value of the source LinesMesh
  17009. */
  17010. intersectionThreshold: number;
  17011. constructor(name: string, source: LinesMesh);
  17012. /**
  17013. * Returns the string "InstancedLinesMesh".
  17014. */
  17015. getClassName(): string;
  17016. }
  17017. }
  17018. declare module BABYLON {
  17019. /** @hidden */
  17020. export var linePixelShader: {
  17021. name: string;
  17022. shader: string;
  17023. };
  17024. }
  17025. declare module BABYLON {
  17026. /** @hidden */
  17027. export var lineVertexShader: {
  17028. name: string;
  17029. shader: string;
  17030. };
  17031. }
  17032. declare module BABYLON {
  17033. interface Scene {
  17034. /** @hidden */
  17035. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17036. }
  17037. interface AbstractMesh {
  17038. /**
  17039. * Gets the edgesRenderer associated with the mesh
  17040. */
  17041. edgesRenderer: Nullable<EdgesRenderer>;
  17042. }
  17043. interface LinesMesh {
  17044. /**
  17045. * Enables the edge rendering mode on the mesh.
  17046. * This mode makes the mesh edges visible
  17047. * @param epsilon defines the maximal distance between two angles to detect a face
  17048. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17049. * @returns the currentAbstractMesh
  17050. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17051. */
  17052. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17053. }
  17054. interface InstancedLinesMesh {
  17055. /**
  17056. * Enables the edge rendering mode on the mesh.
  17057. * This mode makes the mesh edges visible
  17058. * @param epsilon defines the maximal distance between two angles to detect a face
  17059. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17060. * @returns the current InstancedLinesMesh
  17061. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17062. */
  17063. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17064. }
  17065. /**
  17066. * Defines the minimum contract an Edges renderer should follow.
  17067. */
  17068. export interface IEdgesRenderer extends IDisposable {
  17069. /**
  17070. * Gets or sets a boolean indicating if the edgesRenderer is active
  17071. */
  17072. isEnabled: boolean;
  17073. /**
  17074. * Renders the edges of the attached mesh,
  17075. */
  17076. render(): void;
  17077. /**
  17078. * Checks wether or not the edges renderer is ready to render.
  17079. * @return true if ready, otherwise false.
  17080. */
  17081. isReady(): boolean;
  17082. /**
  17083. * List of instances to render in case the source mesh has instances
  17084. */
  17085. customInstances: SmartArray<Matrix>;
  17086. }
  17087. /**
  17088. * Defines the additional options of the edges renderer
  17089. */
  17090. export interface IEdgesRendererOptions {
  17091. /**
  17092. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17093. * If not defined, the default value is true
  17094. */
  17095. useAlternateEdgeFinder?: boolean;
  17096. /**
  17097. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17098. * If not defined, the default value is true.
  17099. * 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)
  17100. * This option is used only if useAlternateEdgeFinder = true
  17101. */
  17102. useFastVertexMerger?: boolean;
  17103. /**
  17104. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17105. * The default value is 1e-6
  17106. * This option is used only if useAlternateEdgeFinder = true
  17107. */
  17108. epsilonVertexMerge?: number;
  17109. /**
  17110. * 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
  17111. * 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.
  17112. * This option is used only if useAlternateEdgeFinder = true
  17113. */
  17114. applyTessellation?: boolean;
  17115. /**
  17116. * 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
  17117. * The default value is 1e-6
  17118. * This option is used only if useAlternateEdgeFinder = true
  17119. */
  17120. epsilonVertexAligned?: number;
  17121. }
  17122. /**
  17123. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17124. */
  17125. export class EdgesRenderer implements IEdgesRenderer {
  17126. /**
  17127. * Define the size of the edges with an orthographic camera
  17128. */
  17129. edgesWidthScalerForOrthographic: number;
  17130. /**
  17131. * Define the size of the edges with a perspective camera
  17132. */
  17133. edgesWidthScalerForPerspective: number;
  17134. protected _source: AbstractMesh;
  17135. protected _linesPositions: number[];
  17136. protected _linesNormals: number[];
  17137. protected _linesIndices: number[];
  17138. protected _epsilon: number;
  17139. protected _indicesCount: number;
  17140. protected _lineShader: ShaderMaterial;
  17141. protected _ib: DataBuffer;
  17142. protected _buffers: {
  17143. [key: string]: Nullable<VertexBuffer>;
  17144. };
  17145. protected _buffersForInstances: {
  17146. [key: string]: Nullable<VertexBuffer>;
  17147. };
  17148. protected _checkVerticesInsteadOfIndices: boolean;
  17149. protected _options: Nullable<IEdgesRendererOptions>;
  17150. private _meshRebuildObserver;
  17151. private _meshDisposeObserver;
  17152. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17153. isEnabled: boolean;
  17154. /**
  17155. * List of instances to render in case the source mesh has instances
  17156. */
  17157. customInstances: SmartArray<Matrix>;
  17158. private static GetShader;
  17159. /**
  17160. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17161. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17162. * @param source Mesh used to create edges
  17163. * @param epsilon sum of angles in adjacency to check for edge
  17164. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17165. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17166. * @param options The options to apply when generating the edges
  17167. */
  17168. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17169. protected _prepareRessources(): void;
  17170. /** @hidden */
  17171. _rebuild(): void;
  17172. /**
  17173. * Releases the required resources for the edges renderer
  17174. */
  17175. dispose(): void;
  17176. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17177. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17178. /**
  17179. * Checks if the pair of p0 and p1 is en edge
  17180. * @param faceIndex
  17181. * @param edge
  17182. * @param faceNormals
  17183. * @param p0
  17184. * @param p1
  17185. * @private
  17186. */
  17187. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17188. /**
  17189. * push line into the position, normal and index buffer
  17190. * @protected
  17191. */
  17192. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17193. /**
  17194. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17195. */
  17196. private _tessellateTriangle;
  17197. private _generateEdgesLinesAlternate;
  17198. /**
  17199. * Generates lines edges from adjacencjes
  17200. * @private
  17201. */
  17202. _generateEdgesLines(): void;
  17203. /**
  17204. * Checks wether or not the edges renderer is ready to render.
  17205. * @return true if ready, otherwise false.
  17206. */
  17207. isReady(): boolean;
  17208. /**
  17209. * Renders the edges of the attached mesh,
  17210. */
  17211. render(): void;
  17212. }
  17213. /**
  17214. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17215. */
  17216. export class LineEdgesRenderer extends EdgesRenderer {
  17217. /**
  17218. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17219. * @param source LineMesh used to generate edges
  17220. * @param epsilon not important (specified angle for edge detection)
  17221. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17222. */
  17223. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17224. /**
  17225. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17226. */
  17227. _generateEdgesLines(): void;
  17228. }
  17229. }
  17230. declare module BABYLON {
  17231. /**
  17232. * This represents the object necessary to create a rendering group.
  17233. * This is exclusively used and created by the rendering manager.
  17234. * To modify the behavior, you use the available helpers in your scene or meshes.
  17235. * @hidden
  17236. */
  17237. export class RenderingGroup {
  17238. index: number;
  17239. private static _zeroVector;
  17240. private _scene;
  17241. private _opaqueSubMeshes;
  17242. private _transparentSubMeshes;
  17243. private _alphaTestSubMeshes;
  17244. private _depthOnlySubMeshes;
  17245. private _particleSystems;
  17246. private _spriteManagers;
  17247. private _opaqueSortCompareFn;
  17248. private _alphaTestSortCompareFn;
  17249. private _transparentSortCompareFn;
  17250. private _renderOpaque;
  17251. private _renderAlphaTest;
  17252. private _renderTransparent;
  17253. /** @hidden */
  17254. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17255. onBeforeTransparentRendering: () => void;
  17256. /**
  17257. * Set the opaque sort comparison function.
  17258. * If null the sub meshes will be render in the order they were created
  17259. */
  17260. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17261. /**
  17262. * Set the alpha test sort comparison function.
  17263. * If null the sub meshes will be render in the order they were created
  17264. */
  17265. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17266. /**
  17267. * Set the transparent sort comparison function.
  17268. * If null the sub meshes will be render in the order they were created
  17269. */
  17270. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17271. /**
  17272. * Creates a new rendering group.
  17273. * @param index The rendering group index
  17274. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17275. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17276. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17277. */
  17278. 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>);
  17279. /**
  17280. * Render all the sub meshes contained in the group.
  17281. * @param customRenderFunction Used to override the default render behaviour of the group.
  17282. * @returns true if rendered some submeshes.
  17283. */
  17284. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17285. /**
  17286. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17287. * @param subMeshes The submeshes to render
  17288. */
  17289. private renderOpaqueSorted;
  17290. /**
  17291. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17292. * @param subMeshes The submeshes to render
  17293. */
  17294. private renderAlphaTestSorted;
  17295. /**
  17296. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17297. * @param subMeshes The submeshes to render
  17298. */
  17299. private renderTransparentSorted;
  17300. /**
  17301. * Renders the submeshes in a specified order.
  17302. * @param subMeshes The submeshes to sort before render
  17303. * @param sortCompareFn The comparison function use to sort
  17304. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17305. * @param transparent Specifies to activate blending if true
  17306. */
  17307. private static renderSorted;
  17308. /**
  17309. * Renders the submeshes in the order they were dispatched (no sort applied).
  17310. * @param subMeshes The submeshes to render
  17311. */
  17312. private static renderUnsorted;
  17313. /**
  17314. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17315. * are rendered back to front if in the same alpha index.
  17316. *
  17317. * @param a The first submesh
  17318. * @param b The second submesh
  17319. * @returns The result of the comparison
  17320. */
  17321. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17322. /**
  17323. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17324. * are rendered back to front.
  17325. *
  17326. * @param a The first submesh
  17327. * @param b The second submesh
  17328. * @returns The result of the comparison
  17329. */
  17330. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17331. /**
  17332. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17333. * are rendered front to back (prevent overdraw).
  17334. *
  17335. * @param a The first submesh
  17336. * @param b The second submesh
  17337. * @returns The result of the comparison
  17338. */
  17339. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17340. /**
  17341. * Resets the different lists of submeshes to prepare a new frame.
  17342. */
  17343. prepare(): void;
  17344. dispose(): void;
  17345. /**
  17346. * Inserts the submesh in its correct queue depending on its material.
  17347. * @param subMesh The submesh to dispatch
  17348. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17349. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17350. */
  17351. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17352. dispatchSprites(spriteManager: ISpriteManager): void;
  17353. dispatchParticles(particleSystem: IParticleSystem): void;
  17354. private _renderParticles;
  17355. private _renderSprites;
  17356. }
  17357. }
  17358. declare module BABYLON {
  17359. /**
  17360. * Interface describing the different options available in the rendering manager
  17361. * regarding Auto Clear between groups.
  17362. */
  17363. export interface IRenderingManagerAutoClearSetup {
  17364. /**
  17365. * Defines whether or not autoclear is enable.
  17366. */
  17367. autoClear: boolean;
  17368. /**
  17369. * Defines whether or not to autoclear the depth buffer.
  17370. */
  17371. depth: boolean;
  17372. /**
  17373. * Defines whether or not to autoclear the stencil buffer.
  17374. */
  17375. stencil: boolean;
  17376. }
  17377. /**
  17378. * This class is used by the onRenderingGroupObservable
  17379. */
  17380. export class RenderingGroupInfo {
  17381. /**
  17382. * The Scene that being rendered
  17383. */
  17384. scene: Scene;
  17385. /**
  17386. * The camera currently used for the rendering pass
  17387. */
  17388. camera: Nullable<Camera>;
  17389. /**
  17390. * The ID of the renderingGroup being processed
  17391. */
  17392. renderingGroupId: number;
  17393. }
  17394. /**
  17395. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17396. * It is enable to manage the different groups as well as the different necessary sort functions.
  17397. * This should not be used directly aside of the few static configurations
  17398. */
  17399. export class RenderingManager {
  17400. /**
  17401. * The max id used for rendering groups (not included)
  17402. */
  17403. static MAX_RENDERINGGROUPS: number;
  17404. /**
  17405. * The min id used for rendering groups (included)
  17406. */
  17407. static MIN_RENDERINGGROUPS: number;
  17408. /**
  17409. * Used to globally prevent autoclearing scenes.
  17410. */
  17411. static AUTOCLEAR: boolean;
  17412. /**
  17413. * @hidden
  17414. */
  17415. _useSceneAutoClearSetup: boolean;
  17416. private _scene;
  17417. private _renderingGroups;
  17418. private _depthStencilBufferAlreadyCleaned;
  17419. private _autoClearDepthStencil;
  17420. private _customOpaqueSortCompareFn;
  17421. private _customAlphaTestSortCompareFn;
  17422. private _customTransparentSortCompareFn;
  17423. private _renderingGroupInfo;
  17424. /**
  17425. * Instantiates a new rendering group for a particular scene
  17426. * @param scene Defines the scene the groups belongs to
  17427. */
  17428. constructor(scene: Scene);
  17429. private _clearDepthStencilBuffer;
  17430. /**
  17431. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17432. * @hidden
  17433. */
  17434. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17435. /**
  17436. * Resets the different information of the group to prepare a new frame
  17437. * @hidden
  17438. */
  17439. reset(): void;
  17440. /**
  17441. * Dispose and release the group and its associated resources.
  17442. * @hidden
  17443. */
  17444. dispose(): void;
  17445. /**
  17446. * Clear the info related to rendering groups preventing retention points during dispose.
  17447. */
  17448. freeRenderingGroups(): void;
  17449. private _prepareRenderingGroup;
  17450. /**
  17451. * Add a sprite manager to the rendering manager in order to render it this frame.
  17452. * @param spriteManager Define the sprite manager to render
  17453. */
  17454. dispatchSprites(spriteManager: ISpriteManager): void;
  17455. /**
  17456. * Add a particle system to the rendering manager in order to render it this frame.
  17457. * @param particleSystem Define the particle system to render
  17458. */
  17459. dispatchParticles(particleSystem: IParticleSystem): void;
  17460. /**
  17461. * Add a submesh to the manager in order to render it this frame
  17462. * @param subMesh The submesh to dispatch
  17463. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17464. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17465. */
  17466. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17467. /**
  17468. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17469. * This allowed control for front to back rendering or reversly depending of the special needs.
  17470. *
  17471. * @param renderingGroupId The rendering group id corresponding to its index
  17472. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17473. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17474. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17475. */
  17476. 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;
  17477. /**
  17478. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17479. *
  17480. * @param renderingGroupId The rendering group id corresponding to its index
  17481. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17482. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17483. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17484. */
  17485. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17486. /**
  17487. * Gets the current auto clear configuration for one rendering group of the rendering
  17488. * manager.
  17489. * @param index the rendering group index to get the information for
  17490. * @returns The auto clear setup for the requested rendering group
  17491. */
  17492. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17493. }
  17494. }
  17495. declare module BABYLON {
  17496. /**
  17497. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17498. */
  17499. export interface ICustomShaderOptions {
  17500. /**
  17501. * Gets or sets the custom shader name to use
  17502. */
  17503. shaderName: string;
  17504. /**
  17505. * The list of attribute names used in the shader
  17506. */
  17507. attributes?: string[];
  17508. /**
  17509. * The list of unifrom names used in the shader
  17510. */
  17511. uniforms?: string[];
  17512. /**
  17513. * The list of sampler names used in the shader
  17514. */
  17515. samplers?: string[];
  17516. /**
  17517. * The list of defines used in the shader
  17518. */
  17519. defines?: string[];
  17520. }
  17521. /**
  17522. * Interface to implement to create a shadow generator compatible with BJS.
  17523. */
  17524. export interface IShadowGenerator {
  17525. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17526. id: string;
  17527. /**
  17528. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17529. * @returns The render target texture if present otherwise, null
  17530. */
  17531. getShadowMap(): Nullable<RenderTargetTexture>;
  17532. /**
  17533. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17534. * @param subMesh The submesh we want to render in the shadow map
  17535. * @param useInstances Defines wether will draw in the map using instances
  17536. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17537. * @returns true if ready otherwise, false
  17538. */
  17539. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17540. /**
  17541. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17542. * @param defines Defines of the material we want to update
  17543. * @param lightIndex Index of the light in the enabled light list of the material
  17544. */
  17545. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17546. /**
  17547. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17548. * defined in the generator but impacting the effect).
  17549. * It implies the unifroms available on the materials are the standard BJS ones.
  17550. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17551. * @param effect The effect we are binfing the information for
  17552. */
  17553. bindShadowLight(lightIndex: string, effect: Effect): void;
  17554. /**
  17555. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17556. * (eq to shadow prjection matrix * light transform matrix)
  17557. * @returns The transform matrix used to create the shadow map
  17558. */
  17559. getTransformMatrix(): Matrix;
  17560. /**
  17561. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17562. * Cube and 2D textures for instance.
  17563. */
  17564. recreateShadowMap(): void;
  17565. /**
  17566. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17567. * @param onCompiled Callback triggered at the and of the effects compilation
  17568. * @param options Sets of optional options forcing the compilation with different modes
  17569. */
  17570. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17571. useInstances: boolean;
  17572. }>): void;
  17573. /**
  17574. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17575. * @param options Sets of optional options forcing the compilation with different modes
  17576. * @returns A promise that resolves when the compilation completes
  17577. */
  17578. forceCompilationAsync(options?: Partial<{
  17579. useInstances: boolean;
  17580. }>): Promise<void>;
  17581. /**
  17582. * Serializes the shadow generator setup to a json object.
  17583. * @returns The serialized JSON object
  17584. */
  17585. serialize(): any;
  17586. /**
  17587. * Disposes the Shadow map and related Textures and effects.
  17588. */
  17589. dispose(): void;
  17590. }
  17591. /**
  17592. * Default implementation IShadowGenerator.
  17593. * This is the main object responsible of generating shadows in the framework.
  17594. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17595. */
  17596. export class ShadowGenerator implements IShadowGenerator {
  17597. /**
  17598. * Name of the shadow generator class
  17599. */
  17600. static CLASSNAME: string;
  17601. /**
  17602. * Shadow generator mode None: no filtering applied.
  17603. */
  17604. static readonly FILTER_NONE: number;
  17605. /**
  17606. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17607. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17608. */
  17609. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17610. /**
  17611. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17612. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17613. */
  17614. static readonly FILTER_POISSONSAMPLING: number;
  17615. /**
  17616. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17617. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17618. */
  17619. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17620. /**
  17621. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17622. * edge artifacts on steep falloff.
  17623. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17624. */
  17625. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17626. /**
  17627. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17628. * edge artifacts on steep falloff.
  17629. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17630. */
  17631. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17632. /**
  17633. * Shadow generator mode PCF: Percentage Closer Filtering
  17634. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17635. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17636. */
  17637. static readonly FILTER_PCF: number;
  17638. /**
  17639. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17640. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17641. * Contact Hardening
  17642. */
  17643. static readonly FILTER_PCSS: number;
  17644. /**
  17645. * Reserved for PCF and PCSS
  17646. * Highest Quality.
  17647. *
  17648. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17649. *
  17650. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17651. */
  17652. static readonly QUALITY_HIGH: number;
  17653. /**
  17654. * Reserved for PCF and PCSS
  17655. * Good tradeoff for quality/perf cross devices
  17656. *
  17657. * Execute PCF on a 3*3 kernel.
  17658. *
  17659. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17660. */
  17661. static readonly QUALITY_MEDIUM: number;
  17662. /**
  17663. * Reserved for PCF and PCSS
  17664. * The lowest quality but the fastest.
  17665. *
  17666. * Execute PCF on a 1*1 kernel.
  17667. *
  17668. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17669. */
  17670. static readonly QUALITY_LOW: number;
  17671. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17672. id: string;
  17673. /** Gets or sets the custom shader name to use */
  17674. customShaderOptions: ICustomShaderOptions;
  17675. /**
  17676. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17677. */
  17678. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17679. /**
  17680. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17681. */
  17682. onAfterShadowMapRenderObservable: Observable<Effect>;
  17683. /**
  17684. * Observable triggered before a mesh is rendered in the shadow map.
  17685. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17686. */
  17687. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17688. /**
  17689. * Observable triggered after a mesh is rendered in the shadow map.
  17690. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17691. */
  17692. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17693. protected _bias: number;
  17694. /**
  17695. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17696. */
  17697. get bias(): number;
  17698. /**
  17699. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17700. */
  17701. set bias(bias: number);
  17702. protected _normalBias: number;
  17703. /**
  17704. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17705. */
  17706. get normalBias(): number;
  17707. /**
  17708. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17709. */
  17710. set normalBias(normalBias: number);
  17711. protected _blurBoxOffset: number;
  17712. /**
  17713. * Gets the blur box offset: offset applied during the blur pass.
  17714. * Only useful if useKernelBlur = false
  17715. */
  17716. get blurBoxOffset(): number;
  17717. /**
  17718. * Sets the blur box offset: offset applied during the blur pass.
  17719. * Only useful if useKernelBlur = false
  17720. */
  17721. set blurBoxOffset(value: number);
  17722. protected _blurScale: number;
  17723. /**
  17724. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17725. * 2 means half of the size.
  17726. */
  17727. get blurScale(): number;
  17728. /**
  17729. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17730. * 2 means half of the size.
  17731. */
  17732. set blurScale(value: number);
  17733. protected _blurKernel: number;
  17734. /**
  17735. * Gets the blur kernel: kernel size of the blur pass.
  17736. * Only useful if useKernelBlur = true
  17737. */
  17738. get blurKernel(): number;
  17739. /**
  17740. * Sets the blur kernel: kernel size of the blur pass.
  17741. * Only useful if useKernelBlur = true
  17742. */
  17743. set blurKernel(value: number);
  17744. protected _useKernelBlur: boolean;
  17745. /**
  17746. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17747. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17748. */
  17749. get useKernelBlur(): boolean;
  17750. /**
  17751. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17752. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17753. */
  17754. set useKernelBlur(value: boolean);
  17755. protected _depthScale: number;
  17756. /**
  17757. * Gets the depth scale used in ESM mode.
  17758. */
  17759. get depthScale(): number;
  17760. /**
  17761. * Sets the depth scale used in ESM mode.
  17762. * This can override the scale stored on the light.
  17763. */
  17764. set depthScale(value: number);
  17765. protected _validateFilter(filter: number): number;
  17766. protected _filter: number;
  17767. /**
  17768. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17769. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17770. */
  17771. get filter(): number;
  17772. /**
  17773. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17774. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17775. */
  17776. set filter(value: number);
  17777. /**
  17778. * Gets if the current filter is set to Poisson Sampling.
  17779. */
  17780. get usePoissonSampling(): boolean;
  17781. /**
  17782. * Sets the current filter to Poisson Sampling.
  17783. */
  17784. set usePoissonSampling(value: boolean);
  17785. /**
  17786. * Gets if the current filter is set to ESM.
  17787. */
  17788. get useExponentialShadowMap(): boolean;
  17789. /**
  17790. * Sets the current filter is to ESM.
  17791. */
  17792. set useExponentialShadowMap(value: boolean);
  17793. /**
  17794. * Gets if the current filter is set to filtered ESM.
  17795. */
  17796. get useBlurExponentialShadowMap(): boolean;
  17797. /**
  17798. * Gets if the current filter is set to filtered ESM.
  17799. */
  17800. set useBlurExponentialShadowMap(value: boolean);
  17801. /**
  17802. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17803. * exponential to prevent steep falloff artifacts).
  17804. */
  17805. get useCloseExponentialShadowMap(): boolean;
  17806. /**
  17807. * Sets the current filter to "close ESM" (using the inverse of the
  17808. * exponential to prevent steep falloff artifacts).
  17809. */
  17810. set useCloseExponentialShadowMap(value: boolean);
  17811. /**
  17812. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17813. * exponential to prevent steep falloff artifacts).
  17814. */
  17815. get useBlurCloseExponentialShadowMap(): boolean;
  17816. /**
  17817. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17818. * exponential to prevent steep falloff artifacts).
  17819. */
  17820. set useBlurCloseExponentialShadowMap(value: boolean);
  17821. /**
  17822. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17823. */
  17824. get usePercentageCloserFiltering(): boolean;
  17825. /**
  17826. * Sets the current filter to "PCF" (percentage closer filtering).
  17827. */
  17828. set usePercentageCloserFiltering(value: boolean);
  17829. protected _filteringQuality: number;
  17830. /**
  17831. * Gets the PCF or PCSS Quality.
  17832. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17833. */
  17834. get filteringQuality(): number;
  17835. /**
  17836. * Sets the PCF or PCSS Quality.
  17837. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17838. */
  17839. set filteringQuality(filteringQuality: number);
  17840. /**
  17841. * Gets if the current filter is set to "PCSS" (contact hardening).
  17842. */
  17843. get useContactHardeningShadow(): boolean;
  17844. /**
  17845. * Sets the current filter to "PCSS" (contact hardening).
  17846. */
  17847. set useContactHardeningShadow(value: boolean);
  17848. protected _contactHardeningLightSizeUVRatio: number;
  17849. /**
  17850. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17851. * Using a ratio helps keeping shape stability independently of the map size.
  17852. *
  17853. * It does not account for the light projection as it was having too much
  17854. * instability during the light setup or during light position changes.
  17855. *
  17856. * Only valid if useContactHardeningShadow is true.
  17857. */
  17858. get contactHardeningLightSizeUVRatio(): number;
  17859. /**
  17860. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17861. * Using a ratio helps keeping shape stability independently of the map size.
  17862. *
  17863. * It does not account for the light projection as it was having too much
  17864. * instability during the light setup or during light position changes.
  17865. *
  17866. * Only valid if useContactHardeningShadow is true.
  17867. */
  17868. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17869. protected _darkness: number;
  17870. /** Gets or sets the actual darkness of a shadow */
  17871. get darkness(): number;
  17872. set darkness(value: number);
  17873. /**
  17874. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17875. * 0 means strongest and 1 would means no shadow.
  17876. * @returns the darkness.
  17877. */
  17878. getDarkness(): number;
  17879. /**
  17880. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17881. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17882. * @returns the shadow generator allowing fluent coding.
  17883. */
  17884. setDarkness(darkness: number): ShadowGenerator;
  17885. protected _transparencyShadow: boolean;
  17886. /** Gets or sets the ability to have transparent shadow */
  17887. get transparencyShadow(): boolean;
  17888. set transparencyShadow(value: boolean);
  17889. /**
  17890. * Sets the ability to have transparent shadow (boolean).
  17891. * @param transparent True if transparent else False
  17892. * @returns the shadow generator allowing fluent coding
  17893. */
  17894. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17895. /**
  17896. * Enables or disables shadows with varying strength based on the transparency
  17897. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17898. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17899. * mesh.visibility * alphaTexture.a
  17900. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17901. */
  17902. enableSoftTransparentShadow: boolean;
  17903. protected _shadowMap: Nullable<RenderTargetTexture>;
  17904. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17905. /**
  17906. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17907. * @returns The render target texture if present otherwise, null
  17908. */
  17909. getShadowMap(): Nullable<RenderTargetTexture>;
  17910. /**
  17911. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17912. * @returns The render target texture if the shadow map is present otherwise, null
  17913. */
  17914. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17915. /**
  17916. * Gets the class name of that object
  17917. * @returns "ShadowGenerator"
  17918. */
  17919. getClassName(): string;
  17920. /**
  17921. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17922. * @param mesh Mesh to add
  17923. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17924. * @returns the Shadow Generator itself
  17925. */
  17926. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17927. /**
  17928. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17929. * @param mesh Mesh to remove
  17930. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17931. * @returns the Shadow Generator itself
  17932. */
  17933. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17934. /**
  17935. * Controls the extent to which the shadows fade out at the edge of the frustum
  17936. */
  17937. frustumEdgeFalloff: number;
  17938. protected _light: IShadowLight;
  17939. /**
  17940. * Returns the associated light object.
  17941. * @returns the light generating the shadow
  17942. */
  17943. getLight(): IShadowLight;
  17944. /**
  17945. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17946. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17947. * It might on the other hand introduce peter panning.
  17948. */
  17949. forceBackFacesOnly: boolean;
  17950. protected _scene: Scene;
  17951. protected _lightDirection: Vector3;
  17952. protected _effect: Effect;
  17953. protected _viewMatrix: Matrix;
  17954. protected _projectionMatrix: Matrix;
  17955. protected _transformMatrix: Matrix;
  17956. protected _cachedPosition: Vector3;
  17957. protected _cachedDirection: Vector3;
  17958. protected _cachedDefines: string;
  17959. protected _currentRenderID: number;
  17960. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17961. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17962. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17963. protected _blurPostProcesses: PostProcess[];
  17964. protected _mapSize: number;
  17965. protected _currentFaceIndex: number;
  17966. protected _currentFaceIndexCache: number;
  17967. protected _textureType: number;
  17968. protected _defaultTextureMatrix: Matrix;
  17969. protected _storedUniqueId: Nullable<number>;
  17970. /** @hidden */
  17971. static _SceneComponentInitialization: (scene: Scene) => void;
  17972. /**
  17973. * Gets or sets the size of the texture what stores the shadows
  17974. */
  17975. get mapSize(): number;
  17976. set mapSize(size: number);
  17977. /**
  17978. * Creates a ShadowGenerator object.
  17979. * A ShadowGenerator is the required tool to use the shadows.
  17980. * Each light casting shadows needs to use its own ShadowGenerator.
  17981. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17982. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17983. * @param light The light object generating the shadows.
  17984. * @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.
  17985. */
  17986. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17987. protected _initializeGenerator(): void;
  17988. protected _createTargetRenderTexture(): void;
  17989. protected _initializeShadowMap(): void;
  17990. protected _initializeBlurRTTAndPostProcesses(): void;
  17991. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17992. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17993. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17994. protected _applyFilterValues(): void;
  17995. /**
  17996. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17997. * @param onCompiled Callback triggered at the and of the effects compilation
  17998. * @param options Sets of optional options forcing the compilation with different modes
  17999. */
  18000. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18001. useInstances: boolean;
  18002. }>): void;
  18003. /**
  18004. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18005. * @param options Sets of optional options forcing the compilation with different modes
  18006. * @returns A promise that resolves when the compilation completes
  18007. */
  18008. forceCompilationAsync(options?: Partial<{
  18009. useInstances: boolean;
  18010. }>): Promise<void>;
  18011. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18012. private _prepareShadowDefines;
  18013. /**
  18014. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18015. * @param subMesh The submesh we want to render in the shadow map
  18016. * @param useInstances Defines wether will draw in the map using instances
  18017. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18018. * @returns true if ready otherwise, false
  18019. */
  18020. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18021. /**
  18022. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18023. * @param defines Defines of the material we want to update
  18024. * @param lightIndex Index of the light in the enabled light list of the material
  18025. */
  18026. prepareDefines(defines: any, lightIndex: number): void;
  18027. /**
  18028. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18029. * defined in the generator but impacting the effect).
  18030. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18031. * @param effect The effect we are binfing the information for
  18032. */
  18033. bindShadowLight(lightIndex: string, effect: Effect): void;
  18034. /**
  18035. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18036. * (eq to shadow prjection matrix * light transform matrix)
  18037. * @returns The transform matrix used to create the shadow map
  18038. */
  18039. getTransformMatrix(): Matrix;
  18040. /**
  18041. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18042. * Cube and 2D textures for instance.
  18043. */
  18044. recreateShadowMap(): void;
  18045. protected _disposeBlurPostProcesses(): void;
  18046. protected _disposeRTTandPostProcesses(): void;
  18047. /**
  18048. * Disposes the ShadowGenerator.
  18049. * Returns nothing.
  18050. */
  18051. dispose(): void;
  18052. /**
  18053. * Serializes the shadow generator setup to a json object.
  18054. * @returns The serialized JSON object
  18055. */
  18056. serialize(): any;
  18057. /**
  18058. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18059. * @param parsedShadowGenerator The JSON object to parse
  18060. * @param scene The scene to create the shadow map for
  18061. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18062. * @returns The parsed shadow generator
  18063. */
  18064. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18065. }
  18066. }
  18067. declare module BABYLON {
  18068. /**
  18069. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18070. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18071. * 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.
  18072. */
  18073. export abstract class Light extends Node {
  18074. /**
  18075. * Falloff Default: light is falling off following the material specification:
  18076. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18077. */
  18078. static readonly FALLOFF_DEFAULT: number;
  18079. /**
  18080. * Falloff Physical: light is falling off following the inverse squared distance law.
  18081. */
  18082. static readonly FALLOFF_PHYSICAL: number;
  18083. /**
  18084. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18085. * to enhance interoperability with other engines.
  18086. */
  18087. static readonly FALLOFF_GLTF: number;
  18088. /**
  18089. * Falloff Standard: light is falling off like in the standard material
  18090. * to enhance interoperability with other materials.
  18091. */
  18092. static readonly FALLOFF_STANDARD: number;
  18093. /**
  18094. * If every light affecting the material is in this lightmapMode,
  18095. * material.lightmapTexture adds or multiplies
  18096. * (depends on material.useLightmapAsShadowmap)
  18097. * after every other light calculations.
  18098. */
  18099. static readonly LIGHTMAP_DEFAULT: number;
  18100. /**
  18101. * material.lightmapTexture as only diffuse lighting from this light
  18102. * adds only specular lighting from this light
  18103. * adds dynamic shadows
  18104. */
  18105. static readonly LIGHTMAP_SPECULAR: number;
  18106. /**
  18107. * material.lightmapTexture as only lighting
  18108. * no light calculation from this light
  18109. * only adds dynamic shadows from this light
  18110. */
  18111. static readonly LIGHTMAP_SHADOWSONLY: number;
  18112. /**
  18113. * Each light type uses the default quantity according to its type:
  18114. * point/spot lights use luminous intensity
  18115. * directional lights use illuminance
  18116. */
  18117. static readonly INTENSITYMODE_AUTOMATIC: number;
  18118. /**
  18119. * lumen (lm)
  18120. */
  18121. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18122. /**
  18123. * candela (lm/sr)
  18124. */
  18125. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18126. /**
  18127. * lux (lm/m^2)
  18128. */
  18129. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18130. /**
  18131. * nit (cd/m^2)
  18132. */
  18133. static readonly INTENSITYMODE_LUMINANCE: number;
  18134. /**
  18135. * Light type const id of the point light.
  18136. */
  18137. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18138. /**
  18139. * Light type const id of the directional light.
  18140. */
  18141. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18142. /**
  18143. * Light type const id of the spot light.
  18144. */
  18145. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18146. /**
  18147. * Light type const id of the hemispheric light.
  18148. */
  18149. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18150. /**
  18151. * Diffuse gives the basic color to an object.
  18152. */
  18153. diffuse: Color3;
  18154. /**
  18155. * Specular produces a highlight color on an object.
  18156. * Note: This is note affecting PBR materials.
  18157. */
  18158. specular: Color3;
  18159. /**
  18160. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18161. * falling off base on range or angle.
  18162. * This can be set to any values in Light.FALLOFF_x.
  18163. *
  18164. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18165. * other types of materials.
  18166. */
  18167. falloffType: number;
  18168. /**
  18169. * Strength of the light.
  18170. * Note: By default it is define in the framework own unit.
  18171. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18172. */
  18173. intensity: number;
  18174. private _range;
  18175. protected _inverseSquaredRange: number;
  18176. /**
  18177. * Defines how far from the source the light is impacting in scene units.
  18178. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18179. */
  18180. get range(): number;
  18181. /**
  18182. * Defines how far from the source the light is impacting in scene units.
  18183. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18184. */
  18185. set range(value: number);
  18186. /**
  18187. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18188. * of light.
  18189. */
  18190. private _photometricScale;
  18191. private _intensityMode;
  18192. /**
  18193. * Gets the photometric scale used to interpret the intensity.
  18194. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18195. */
  18196. get intensityMode(): number;
  18197. /**
  18198. * Sets the photometric scale used to interpret the intensity.
  18199. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18200. */
  18201. set intensityMode(value: number);
  18202. private _radius;
  18203. /**
  18204. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18205. */
  18206. get radius(): number;
  18207. /**
  18208. * sets the light radius used by PBR Materials to simulate soft area lights.
  18209. */
  18210. set radius(value: number);
  18211. private _renderPriority;
  18212. /**
  18213. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18214. * exceeding the number allowed of the materials.
  18215. */
  18216. renderPriority: number;
  18217. private _shadowEnabled;
  18218. /**
  18219. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18220. * the current shadow generator.
  18221. */
  18222. get shadowEnabled(): boolean;
  18223. /**
  18224. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18225. * the current shadow generator.
  18226. */
  18227. set shadowEnabled(value: boolean);
  18228. private _includedOnlyMeshes;
  18229. /**
  18230. * Gets the only meshes impacted by this light.
  18231. */
  18232. get includedOnlyMeshes(): AbstractMesh[];
  18233. /**
  18234. * Sets the only meshes impacted by this light.
  18235. */
  18236. set includedOnlyMeshes(value: AbstractMesh[]);
  18237. private _excludedMeshes;
  18238. /**
  18239. * Gets the meshes not impacted by this light.
  18240. */
  18241. get excludedMeshes(): AbstractMesh[];
  18242. /**
  18243. * Sets the meshes not impacted by this light.
  18244. */
  18245. set excludedMeshes(value: AbstractMesh[]);
  18246. private _excludeWithLayerMask;
  18247. /**
  18248. * Gets the layer id use to find what meshes are not impacted by the light.
  18249. * Inactive if 0
  18250. */
  18251. get excludeWithLayerMask(): number;
  18252. /**
  18253. * Sets the layer id use to find what meshes are not impacted by the light.
  18254. * Inactive if 0
  18255. */
  18256. set excludeWithLayerMask(value: number);
  18257. private _includeOnlyWithLayerMask;
  18258. /**
  18259. * Gets the layer id use to find what meshes are impacted by the light.
  18260. * Inactive if 0
  18261. */
  18262. get includeOnlyWithLayerMask(): number;
  18263. /**
  18264. * Sets the layer id use to find what meshes are impacted by the light.
  18265. * Inactive if 0
  18266. */
  18267. set includeOnlyWithLayerMask(value: number);
  18268. private _lightmapMode;
  18269. /**
  18270. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18271. */
  18272. get lightmapMode(): number;
  18273. /**
  18274. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18275. */
  18276. set lightmapMode(value: number);
  18277. /**
  18278. * Shadow generator associted to the light.
  18279. * @hidden Internal use only.
  18280. */
  18281. _shadowGenerator: Nullable<IShadowGenerator>;
  18282. /**
  18283. * @hidden Internal use only.
  18284. */
  18285. _excludedMeshesIds: string[];
  18286. /**
  18287. * @hidden Internal use only.
  18288. */
  18289. _includedOnlyMeshesIds: string[];
  18290. /**
  18291. * The current light unifom buffer.
  18292. * @hidden Internal use only.
  18293. */
  18294. _uniformBuffer: UniformBuffer;
  18295. /** @hidden */
  18296. _renderId: number;
  18297. /**
  18298. * Creates a Light object in the scene.
  18299. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18300. * @param name The firendly name of the light
  18301. * @param scene The scene the light belongs too
  18302. */
  18303. constructor(name: string, scene: Scene);
  18304. protected abstract _buildUniformLayout(): void;
  18305. /**
  18306. * Sets the passed Effect "effect" with the Light information.
  18307. * @param effect The effect to update
  18308. * @param lightIndex The index of the light in the effect to update
  18309. * @returns The light
  18310. */
  18311. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18312. /**
  18313. * Sets the passed Effect "effect" with the Light textures.
  18314. * @param effect The effect to update
  18315. * @param lightIndex The index of the light in the effect to update
  18316. * @returns The light
  18317. */
  18318. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18319. /**
  18320. * Binds the lights information from the scene to the effect for the given mesh.
  18321. * @param lightIndex Light index
  18322. * @param scene The scene where the light belongs to
  18323. * @param effect The effect we are binding the data to
  18324. * @param useSpecular Defines if specular is supported
  18325. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18326. */
  18327. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18328. /**
  18329. * Sets the passed Effect "effect" with the Light information.
  18330. * @param effect The effect to update
  18331. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18332. * @returns The light
  18333. */
  18334. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18335. /**
  18336. * Returns the string "Light".
  18337. * @returns the class name
  18338. */
  18339. getClassName(): string;
  18340. /** @hidden */
  18341. readonly _isLight: boolean;
  18342. /**
  18343. * Converts the light information to a readable string for debug purpose.
  18344. * @param fullDetails Supports for multiple levels of logging within scene loading
  18345. * @returns the human readable light info
  18346. */
  18347. toString(fullDetails?: boolean): string;
  18348. /** @hidden */
  18349. protected _syncParentEnabledState(): void;
  18350. /**
  18351. * Set the enabled state of this node.
  18352. * @param value - the new enabled state
  18353. */
  18354. setEnabled(value: boolean): void;
  18355. /**
  18356. * Returns the Light associated shadow generator if any.
  18357. * @return the associated shadow generator.
  18358. */
  18359. getShadowGenerator(): Nullable<IShadowGenerator>;
  18360. /**
  18361. * Returns a Vector3, the absolute light position in the World.
  18362. * @returns the world space position of the light
  18363. */
  18364. getAbsolutePosition(): Vector3;
  18365. /**
  18366. * Specifies if the light will affect the passed mesh.
  18367. * @param mesh The mesh to test against the light
  18368. * @return true the mesh is affected otherwise, false.
  18369. */
  18370. canAffectMesh(mesh: AbstractMesh): boolean;
  18371. /**
  18372. * Sort function to order lights for rendering.
  18373. * @param a First Light object to compare to second.
  18374. * @param b Second Light object to compare first.
  18375. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18376. */
  18377. static CompareLightsPriority(a: Light, b: Light): number;
  18378. /**
  18379. * Releases resources associated with this node.
  18380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18382. */
  18383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18384. /**
  18385. * Returns the light type ID (integer).
  18386. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18387. */
  18388. getTypeID(): number;
  18389. /**
  18390. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18391. * @returns the scaled intensity in intensity mode unit
  18392. */
  18393. getScaledIntensity(): number;
  18394. /**
  18395. * Returns a new Light object, named "name", from the current one.
  18396. * @param name The name of the cloned light
  18397. * @param newParent The parent of this light, if it has one
  18398. * @returns the new created light
  18399. */
  18400. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18401. /**
  18402. * Serializes the current light into a Serialization object.
  18403. * @returns the serialized object.
  18404. */
  18405. serialize(): any;
  18406. /**
  18407. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18408. * This new light is named "name" and added to the passed scene.
  18409. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18410. * @param name The friendly name of the light
  18411. * @param scene The scene the new light will belong to
  18412. * @returns the constructor function
  18413. */
  18414. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18415. /**
  18416. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18417. * @param parsedLight The JSON representation of the light
  18418. * @param scene The scene to create the parsed light in
  18419. * @returns the created light after parsing
  18420. */
  18421. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18422. private _hookArrayForExcluded;
  18423. private _hookArrayForIncludedOnly;
  18424. private _resyncMeshes;
  18425. /**
  18426. * Forces the meshes to update their light related information in their rendering used effects
  18427. * @hidden Internal Use Only
  18428. */
  18429. _markMeshesAsLightDirty(): void;
  18430. /**
  18431. * Recomputes the cached photometric scale if needed.
  18432. */
  18433. private _computePhotometricScale;
  18434. /**
  18435. * Returns the Photometric Scale according to the light type and intensity mode.
  18436. */
  18437. private _getPhotometricScale;
  18438. /**
  18439. * Reorder the light in the scene according to their defined priority.
  18440. * @hidden Internal Use Only
  18441. */
  18442. _reorderLightsInScene(): void;
  18443. /**
  18444. * Prepares the list of defines specific to the light type.
  18445. * @param defines the list of defines
  18446. * @param lightIndex defines the index of the light for the effect
  18447. */
  18448. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18449. }
  18450. }
  18451. declare module BABYLON {
  18452. /**
  18453. * Configuration needed for prepass-capable materials
  18454. */
  18455. export class PrePassConfiguration {
  18456. /**
  18457. * Previous world matrices of meshes carrying this material
  18458. * Used for computing velocity
  18459. */
  18460. previousWorldMatrices: {
  18461. [index: number]: Matrix;
  18462. };
  18463. /**
  18464. * Previous view project matrix
  18465. * Used for computing velocity
  18466. */
  18467. previousViewProjection: Matrix;
  18468. /**
  18469. * Previous bones of meshes carrying this material
  18470. * Used for computing velocity
  18471. */
  18472. previousBones: {
  18473. [index: number]: Float32Array;
  18474. };
  18475. /**
  18476. * Add the required uniforms to the current list.
  18477. * @param uniforms defines the current uniform list.
  18478. */
  18479. static AddUniforms(uniforms: string[]): void;
  18480. /**
  18481. * Add the required samplers to the current list.
  18482. * @param samplers defines the current sampler list.
  18483. */
  18484. static AddSamplers(samplers: string[]): void;
  18485. /**
  18486. * Binds the material data.
  18487. * @param effect defines the effect to update
  18488. * @param scene defines the scene the material belongs to.
  18489. * @param mesh The mesh
  18490. * @param world World matrix of this mesh
  18491. * @param isFrozen Is the material frozen
  18492. */
  18493. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  18494. }
  18495. }
  18496. declare module BABYLON {
  18497. /**
  18498. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18499. * This is the base of the follow, arc rotate cameras and Free camera
  18500. * @see https://doc.babylonjs.com/features/cameras
  18501. */
  18502. export class TargetCamera extends Camera {
  18503. private static _RigCamTransformMatrix;
  18504. private static _TargetTransformMatrix;
  18505. private static _TargetFocalPoint;
  18506. private _tmpUpVector;
  18507. private _tmpTargetVector;
  18508. /**
  18509. * Define the current direction the camera is moving to
  18510. */
  18511. cameraDirection: Vector3;
  18512. /**
  18513. * Define the current rotation the camera is rotating to
  18514. */
  18515. cameraRotation: Vector2;
  18516. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18517. ignoreParentScaling: boolean;
  18518. /**
  18519. * When set, the up vector of the camera will be updated by the rotation of the camera
  18520. */
  18521. updateUpVectorFromRotation: boolean;
  18522. private _tmpQuaternion;
  18523. /**
  18524. * Define the current rotation of the camera
  18525. */
  18526. rotation: Vector3;
  18527. /**
  18528. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18529. */
  18530. rotationQuaternion: Quaternion;
  18531. /**
  18532. * Define the current speed of the camera
  18533. */
  18534. speed: number;
  18535. /**
  18536. * Add constraint to the camera to prevent it to move freely in all directions and
  18537. * around all axis.
  18538. */
  18539. noRotationConstraint: boolean;
  18540. /**
  18541. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18542. * panning
  18543. */
  18544. invertRotation: boolean;
  18545. /**
  18546. * Speed multiplier for inverse camera panning
  18547. */
  18548. inverseRotationSpeed: number;
  18549. /**
  18550. * Define the current target of the camera as an object or a position.
  18551. */
  18552. lockedTarget: any;
  18553. /** @hidden */
  18554. _currentTarget: Vector3;
  18555. /** @hidden */
  18556. _initialFocalDistance: number;
  18557. /** @hidden */
  18558. _viewMatrix: Matrix;
  18559. /** @hidden */
  18560. _camMatrix: Matrix;
  18561. /** @hidden */
  18562. _cameraTransformMatrix: Matrix;
  18563. /** @hidden */
  18564. _cameraRotationMatrix: Matrix;
  18565. /** @hidden */
  18566. _referencePoint: Vector3;
  18567. /** @hidden */
  18568. _transformedReferencePoint: Vector3;
  18569. /** @hidden */
  18570. _reset: () => void;
  18571. private _defaultUp;
  18572. /**
  18573. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18574. * This is the base of the follow, arc rotate cameras and Free camera
  18575. * @see https://doc.babylonjs.com/features/cameras
  18576. * @param name Defines the name of the camera in the scene
  18577. * @param position Defines the start position of the camera in the scene
  18578. * @param scene Defines the scene the camera belongs to
  18579. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18580. */
  18581. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18582. /**
  18583. * Gets the position in front of the camera at a given distance.
  18584. * @param distance The distance from the camera we want the position to be
  18585. * @returns the position
  18586. */
  18587. getFrontPosition(distance: number): Vector3;
  18588. /** @hidden */
  18589. _getLockedTargetPosition(): Nullable<Vector3>;
  18590. private _storedPosition;
  18591. private _storedRotation;
  18592. private _storedRotationQuaternion;
  18593. /**
  18594. * Store current camera state of the camera (fov, position, rotation, etc..)
  18595. * @returns the camera
  18596. */
  18597. storeState(): Camera;
  18598. /**
  18599. * Restored camera state. You must call storeState() first
  18600. * @returns whether it was successful or not
  18601. * @hidden
  18602. */
  18603. _restoreStateValues(): boolean;
  18604. /** @hidden */
  18605. _initCache(): void;
  18606. /** @hidden */
  18607. _updateCache(ignoreParentClass?: boolean): void;
  18608. /** @hidden */
  18609. _isSynchronizedViewMatrix(): boolean;
  18610. /** @hidden */
  18611. _computeLocalCameraSpeed(): number;
  18612. /**
  18613. * Defines the target the camera should look at.
  18614. * @param target Defines the new target as a Vector or a mesh
  18615. */
  18616. setTarget(target: Vector3): void;
  18617. /**
  18618. * Defines the target point of the camera.
  18619. * The camera looks towards it form the radius distance.
  18620. */
  18621. get target(): Vector3;
  18622. set target(value: Vector3);
  18623. /**
  18624. * Return the current target position of the camera. This value is expressed in local space.
  18625. * @returns the target position
  18626. */
  18627. getTarget(): Vector3;
  18628. /** @hidden */
  18629. _decideIfNeedsToMove(): boolean;
  18630. /** @hidden */
  18631. _updatePosition(): void;
  18632. /** @hidden */
  18633. _checkInputs(): void;
  18634. protected _updateCameraRotationMatrix(): void;
  18635. /**
  18636. * 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)
  18637. * @returns the current camera
  18638. */
  18639. private _rotateUpVectorWithCameraRotationMatrix;
  18640. private _cachedRotationZ;
  18641. private _cachedQuaternionRotationZ;
  18642. /** @hidden */
  18643. _getViewMatrix(): Matrix;
  18644. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18645. /**
  18646. * @hidden
  18647. */
  18648. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18649. /**
  18650. * @hidden
  18651. */
  18652. _updateRigCameras(): void;
  18653. private _getRigCamPositionAndTarget;
  18654. /**
  18655. * Gets the current object class name.
  18656. * @return the class name
  18657. */
  18658. getClassName(): string;
  18659. }
  18660. }
  18661. declare module BABYLON {
  18662. /**
  18663. * Gather the list of keyboard event types as constants.
  18664. */
  18665. export class KeyboardEventTypes {
  18666. /**
  18667. * The keydown event is fired when a key becomes active (pressed).
  18668. */
  18669. static readonly KEYDOWN: number;
  18670. /**
  18671. * The keyup event is fired when a key has been released.
  18672. */
  18673. static readonly KEYUP: number;
  18674. }
  18675. /**
  18676. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18677. */
  18678. export class KeyboardInfo {
  18679. /**
  18680. * Defines the type of event (KeyboardEventTypes)
  18681. */
  18682. type: number;
  18683. /**
  18684. * Defines the related dom event
  18685. */
  18686. event: KeyboardEvent;
  18687. /**
  18688. * Instantiates a new keyboard info.
  18689. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18690. * @param type Defines the type of event (KeyboardEventTypes)
  18691. * @param event Defines the related dom event
  18692. */
  18693. constructor(
  18694. /**
  18695. * Defines the type of event (KeyboardEventTypes)
  18696. */
  18697. type: number,
  18698. /**
  18699. * Defines the related dom event
  18700. */
  18701. event: KeyboardEvent);
  18702. }
  18703. /**
  18704. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18705. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18706. */
  18707. export class KeyboardInfoPre extends KeyboardInfo {
  18708. /**
  18709. * Defines the type of event (KeyboardEventTypes)
  18710. */
  18711. type: number;
  18712. /**
  18713. * Defines the related dom event
  18714. */
  18715. event: KeyboardEvent;
  18716. /**
  18717. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18718. */
  18719. skipOnPointerObservable: boolean;
  18720. /**
  18721. * Instantiates a new keyboard pre info.
  18722. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18723. * @param type Defines the type of event (KeyboardEventTypes)
  18724. * @param event Defines the related dom event
  18725. */
  18726. constructor(
  18727. /**
  18728. * Defines the type of event (KeyboardEventTypes)
  18729. */
  18730. type: number,
  18731. /**
  18732. * Defines the related dom event
  18733. */
  18734. event: KeyboardEvent);
  18735. }
  18736. }
  18737. declare module BABYLON {
  18738. /**
  18739. * Manage the keyboard inputs to control the movement of a free camera.
  18740. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18741. */
  18742. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18743. /**
  18744. * Defines the camera the input is attached to.
  18745. */
  18746. camera: FreeCamera;
  18747. /**
  18748. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18749. */
  18750. keysUp: number[];
  18751. /**
  18752. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18753. */
  18754. keysUpward: number[];
  18755. /**
  18756. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18757. */
  18758. keysDown: number[];
  18759. /**
  18760. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18761. */
  18762. keysDownward: number[];
  18763. /**
  18764. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18765. */
  18766. keysLeft: number[];
  18767. /**
  18768. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18769. */
  18770. keysRight: number[];
  18771. private _keys;
  18772. private _onCanvasBlurObserver;
  18773. private _onKeyboardObserver;
  18774. private _engine;
  18775. private _scene;
  18776. /**
  18777. * Attach the input controls to a specific dom element to get the input from.
  18778. * @param element Defines the element the controls should be listened from
  18779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18780. */
  18781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18782. /**
  18783. * Detach the current controls from the specified dom element.
  18784. * @param element Defines the element to stop listening the inputs from
  18785. */
  18786. detachControl(element: Nullable<HTMLElement>): void;
  18787. /**
  18788. * Update the current camera state depending on the inputs that have been used this frame.
  18789. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18790. */
  18791. checkInputs(): void;
  18792. /**
  18793. * Gets the class name of the current intput.
  18794. * @returns the class name
  18795. */
  18796. getClassName(): string;
  18797. /** @hidden */
  18798. _onLostFocus(): void;
  18799. /**
  18800. * Get the friendly name associated with the input class.
  18801. * @returns the input friendly name
  18802. */
  18803. getSimpleName(): string;
  18804. }
  18805. }
  18806. declare module BABYLON {
  18807. /**
  18808. * Gather the list of pointer event types as constants.
  18809. */
  18810. export class PointerEventTypes {
  18811. /**
  18812. * 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.
  18813. */
  18814. static readonly POINTERDOWN: number;
  18815. /**
  18816. * The pointerup event is fired when a pointer is no longer active.
  18817. */
  18818. static readonly POINTERUP: number;
  18819. /**
  18820. * The pointermove event is fired when a pointer changes coordinates.
  18821. */
  18822. static readonly POINTERMOVE: number;
  18823. /**
  18824. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18825. */
  18826. static readonly POINTERWHEEL: number;
  18827. /**
  18828. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18829. */
  18830. static readonly POINTERPICK: number;
  18831. /**
  18832. * The pointertap event is fired when a the object has been touched and released without drag.
  18833. */
  18834. static readonly POINTERTAP: number;
  18835. /**
  18836. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18837. */
  18838. static readonly POINTERDOUBLETAP: number;
  18839. }
  18840. /**
  18841. * Base class of pointer info types.
  18842. */
  18843. export class PointerInfoBase {
  18844. /**
  18845. * Defines the type of event (PointerEventTypes)
  18846. */
  18847. type: number;
  18848. /**
  18849. * Defines the related dom event
  18850. */
  18851. event: PointerEvent | MouseWheelEvent;
  18852. /**
  18853. * Instantiates the base class of pointers info.
  18854. * @param type Defines the type of event (PointerEventTypes)
  18855. * @param event Defines the related dom event
  18856. */
  18857. constructor(
  18858. /**
  18859. * Defines the type of event (PointerEventTypes)
  18860. */
  18861. type: number,
  18862. /**
  18863. * Defines the related dom event
  18864. */
  18865. event: PointerEvent | MouseWheelEvent);
  18866. }
  18867. /**
  18868. * This class is used to store pointer related info for the onPrePointerObservable event.
  18869. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18870. */
  18871. export class PointerInfoPre extends PointerInfoBase {
  18872. /**
  18873. * Ray from a pointer if availible (eg. 6dof controller)
  18874. */
  18875. ray: Nullable<Ray>;
  18876. /**
  18877. * Defines the local position of the pointer on the canvas.
  18878. */
  18879. localPosition: Vector2;
  18880. /**
  18881. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18882. */
  18883. skipOnPointerObservable: boolean;
  18884. /**
  18885. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18886. * @param type Defines the type of event (PointerEventTypes)
  18887. * @param event Defines the related dom event
  18888. * @param localX Defines the local x coordinates of the pointer when the event occured
  18889. * @param localY Defines the local y coordinates of the pointer when the event occured
  18890. */
  18891. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18892. }
  18893. /**
  18894. * This type contains all the data related to a pointer event in Babylon.js.
  18895. * 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.
  18896. */
  18897. export class PointerInfo extends PointerInfoBase {
  18898. /**
  18899. * Defines the picking info associated to the info (if any)\
  18900. */
  18901. pickInfo: Nullable<PickingInfo>;
  18902. /**
  18903. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18904. * @param type Defines the type of event (PointerEventTypes)
  18905. * @param event Defines the related dom event
  18906. * @param pickInfo Defines the picking info associated to the info (if any)\
  18907. */
  18908. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18909. /**
  18910. * Defines the picking info associated to the info (if any)\
  18911. */
  18912. pickInfo: Nullable<PickingInfo>);
  18913. }
  18914. /**
  18915. * Data relating to a touch event on the screen.
  18916. */
  18917. export interface PointerTouch {
  18918. /**
  18919. * X coordinate of touch.
  18920. */
  18921. x: number;
  18922. /**
  18923. * Y coordinate of touch.
  18924. */
  18925. y: number;
  18926. /**
  18927. * Id of touch. Unique for each finger.
  18928. */
  18929. pointerId: number;
  18930. /**
  18931. * Event type passed from DOM.
  18932. */
  18933. type: any;
  18934. }
  18935. }
  18936. declare module BABYLON {
  18937. /**
  18938. * Manage the mouse inputs to control the movement of a free camera.
  18939. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18940. */
  18941. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18942. /**
  18943. * Define if touch is enabled in the mouse input
  18944. */
  18945. touchEnabled: boolean;
  18946. /**
  18947. * Defines the camera the input is attached to.
  18948. */
  18949. camera: FreeCamera;
  18950. /**
  18951. * Defines the buttons associated with the input to handle camera move.
  18952. */
  18953. buttons: number[];
  18954. /**
  18955. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18956. */
  18957. angularSensibility: number;
  18958. private _pointerInput;
  18959. private _onMouseMove;
  18960. private _observer;
  18961. private previousPosition;
  18962. /**
  18963. * Observable for when a pointer move event occurs containing the move offset
  18964. */
  18965. onPointerMovedObservable: Observable<{
  18966. offsetX: number;
  18967. offsetY: number;
  18968. }>;
  18969. /**
  18970. * @hidden
  18971. * If the camera should be rotated automatically based on pointer movement
  18972. */
  18973. _allowCameraRotation: boolean;
  18974. /**
  18975. * Manage the mouse inputs to control the movement of a free camera.
  18976. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18977. * @param touchEnabled Defines if touch is enabled or not
  18978. */
  18979. constructor(
  18980. /**
  18981. * Define if touch is enabled in the mouse input
  18982. */
  18983. touchEnabled?: boolean);
  18984. /**
  18985. * Attach the input controls to a specific dom element to get the input from.
  18986. * @param element Defines the element the controls should be listened from
  18987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18988. */
  18989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18990. /**
  18991. * Called on JS contextmenu event.
  18992. * Override this method to provide functionality.
  18993. */
  18994. protected onContextMenu(evt: PointerEvent): void;
  18995. /**
  18996. * Detach the current controls from the specified dom element.
  18997. * @param element Defines the element to stop listening the inputs from
  18998. */
  18999. detachControl(element: Nullable<HTMLElement>): void;
  19000. /**
  19001. * Gets the class name of the current intput.
  19002. * @returns the class name
  19003. */
  19004. getClassName(): string;
  19005. /**
  19006. * Get the friendly name associated with the input class.
  19007. * @returns the input friendly name
  19008. */
  19009. getSimpleName(): string;
  19010. }
  19011. }
  19012. declare module BABYLON {
  19013. /**
  19014. * Manage the touch inputs to control the movement of a free camera.
  19015. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19016. */
  19017. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19018. /**
  19019. * Define if mouse events can be treated as touch events
  19020. */
  19021. allowMouse: boolean;
  19022. /**
  19023. * Defines the camera the input is attached to.
  19024. */
  19025. camera: FreeCamera;
  19026. /**
  19027. * Defines the touch sensibility for rotation.
  19028. * The higher the faster.
  19029. */
  19030. touchAngularSensibility: number;
  19031. /**
  19032. * Defines the touch sensibility for move.
  19033. * The higher the faster.
  19034. */
  19035. touchMoveSensibility: number;
  19036. private _offsetX;
  19037. private _offsetY;
  19038. private _pointerPressed;
  19039. private _pointerInput;
  19040. private _observer;
  19041. private _onLostFocus;
  19042. /**
  19043. * Manage the touch inputs to control the movement of a free camera.
  19044. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19045. * @param allowMouse Defines if mouse events can be treated as touch events
  19046. */
  19047. constructor(
  19048. /**
  19049. * Define if mouse events can be treated as touch events
  19050. */
  19051. allowMouse?: boolean);
  19052. /**
  19053. * Attach the input controls to a specific dom element to get the input from.
  19054. * @param element Defines the element the controls should be listened from
  19055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19056. */
  19057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19058. /**
  19059. * Detach the current controls from the specified dom element.
  19060. * @param element Defines the element to stop listening the inputs from
  19061. */
  19062. detachControl(element: Nullable<HTMLElement>): void;
  19063. /**
  19064. * Update the current camera state depending on the inputs that have been used this frame.
  19065. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19066. */
  19067. checkInputs(): void;
  19068. /**
  19069. * Gets the class name of the current intput.
  19070. * @returns the class name
  19071. */
  19072. getClassName(): string;
  19073. /**
  19074. * Get the friendly name associated with the input class.
  19075. * @returns the input friendly name
  19076. */
  19077. getSimpleName(): string;
  19078. }
  19079. }
  19080. declare module BABYLON {
  19081. /**
  19082. * Default Inputs manager for the FreeCamera.
  19083. * It groups all the default supported inputs for ease of use.
  19084. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19085. */
  19086. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19087. /**
  19088. * @hidden
  19089. */
  19090. _mouseInput: Nullable<FreeCameraMouseInput>;
  19091. /**
  19092. * Instantiates a new FreeCameraInputsManager.
  19093. * @param camera Defines the camera the inputs belong to
  19094. */
  19095. constructor(camera: FreeCamera);
  19096. /**
  19097. * Add keyboard input support to the input manager.
  19098. * @returns the current input manager
  19099. */
  19100. addKeyboard(): FreeCameraInputsManager;
  19101. /**
  19102. * Add mouse input support to the input manager.
  19103. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19104. * @returns the current input manager
  19105. */
  19106. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19107. /**
  19108. * Removes the mouse input support from the manager
  19109. * @returns the current input manager
  19110. */
  19111. removeMouse(): FreeCameraInputsManager;
  19112. /**
  19113. * Add touch input support to the input manager.
  19114. * @returns the current input manager
  19115. */
  19116. addTouch(): FreeCameraInputsManager;
  19117. /**
  19118. * Remove all attached input methods from a camera
  19119. */
  19120. clear(): void;
  19121. }
  19122. }
  19123. declare module BABYLON {
  19124. /**
  19125. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19126. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19127. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19128. */
  19129. export class FreeCamera extends TargetCamera {
  19130. /**
  19131. * Define the collision ellipsoid of the camera.
  19132. * This is helpful to simulate a camera body like the player body around the camera
  19133. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19134. */
  19135. ellipsoid: Vector3;
  19136. /**
  19137. * Define an offset for the position of the ellipsoid around the camera.
  19138. * This can be helpful to determine the center of the body near the gravity center of the body
  19139. * instead of its head.
  19140. */
  19141. ellipsoidOffset: Vector3;
  19142. /**
  19143. * Enable or disable collisions of the camera with the rest of the scene objects.
  19144. */
  19145. checkCollisions: boolean;
  19146. /**
  19147. * Enable or disable gravity on the camera.
  19148. */
  19149. applyGravity: boolean;
  19150. /**
  19151. * Define the input manager associated to the camera.
  19152. */
  19153. inputs: FreeCameraInputsManager;
  19154. /**
  19155. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19156. * Higher values reduce sensitivity.
  19157. */
  19158. get angularSensibility(): number;
  19159. /**
  19160. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19161. * Higher values reduce sensitivity.
  19162. */
  19163. set angularSensibility(value: number);
  19164. /**
  19165. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19166. */
  19167. get keysUp(): number[];
  19168. set keysUp(value: number[]);
  19169. /**
  19170. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19171. */
  19172. get keysUpward(): number[];
  19173. set keysUpward(value: number[]);
  19174. /**
  19175. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19176. */
  19177. get keysDown(): number[];
  19178. set keysDown(value: number[]);
  19179. /**
  19180. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19181. */
  19182. get keysDownward(): number[];
  19183. set keysDownward(value: number[]);
  19184. /**
  19185. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19186. */
  19187. get keysLeft(): number[];
  19188. set keysLeft(value: number[]);
  19189. /**
  19190. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19191. */
  19192. get keysRight(): number[];
  19193. set keysRight(value: number[]);
  19194. /**
  19195. * Event raised when the camera collide with a mesh in the scene.
  19196. */
  19197. onCollide: (collidedMesh: AbstractMesh) => void;
  19198. private _collider;
  19199. private _needMoveForGravity;
  19200. private _oldPosition;
  19201. private _diffPosition;
  19202. private _newPosition;
  19203. /** @hidden */
  19204. _localDirection: Vector3;
  19205. /** @hidden */
  19206. _transformedDirection: Vector3;
  19207. /**
  19208. * Instantiates a Free Camera.
  19209. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19210. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19211. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19212. * @param name Define the name of the camera in the scene
  19213. * @param position Define the start position of the camera in the scene
  19214. * @param scene Define the scene the camera belongs to
  19215. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19216. */
  19217. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19218. /**
  19219. * Attached controls to the current camera.
  19220. * @param element Defines the element the controls should be listened from
  19221. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19222. */
  19223. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19224. /**
  19225. * Detach the current controls from the camera.
  19226. * The camera will stop reacting to inputs.
  19227. * @param element Defines the element to stop listening the inputs from
  19228. */
  19229. detachControl(element: HTMLElement): void;
  19230. private _collisionMask;
  19231. /**
  19232. * Define a collision mask to limit the list of object the camera can collide with
  19233. */
  19234. get collisionMask(): number;
  19235. set collisionMask(mask: number);
  19236. /** @hidden */
  19237. _collideWithWorld(displacement: Vector3): void;
  19238. private _onCollisionPositionChange;
  19239. /** @hidden */
  19240. _checkInputs(): void;
  19241. /** @hidden */
  19242. _decideIfNeedsToMove(): boolean;
  19243. /** @hidden */
  19244. _updatePosition(): void;
  19245. /**
  19246. * Destroy the camera and release the current resources hold by it.
  19247. */
  19248. dispose(): void;
  19249. /**
  19250. * Gets the current object class name.
  19251. * @return the class name
  19252. */
  19253. getClassName(): string;
  19254. }
  19255. }
  19256. declare module BABYLON {
  19257. /**
  19258. * Represents a gamepad control stick position
  19259. */
  19260. export class StickValues {
  19261. /**
  19262. * The x component of the control stick
  19263. */
  19264. x: number;
  19265. /**
  19266. * The y component of the control stick
  19267. */
  19268. y: number;
  19269. /**
  19270. * Initializes the gamepad x and y control stick values
  19271. * @param x The x component of the gamepad control stick value
  19272. * @param y The y component of the gamepad control stick value
  19273. */
  19274. constructor(
  19275. /**
  19276. * The x component of the control stick
  19277. */
  19278. x: number,
  19279. /**
  19280. * The y component of the control stick
  19281. */
  19282. y: number);
  19283. }
  19284. /**
  19285. * An interface which manages callbacks for gamepad button changes
  19286. */
  19287. export interface GamepadButtonChanges {
  19288. /**
  19289. * Called when a gamepad has been changed
  19290. */
  19291. changed: boolean;
  19292. /**
  19293. * Called when a gamepad press event has been triggered
  19294. */
  19295. pressChanged: boolean;
  19296. /**
  19297. * Called when a touch event has been triggered
  19298. */
  19299. touchChanged: boolean;
  19300. /**
  19301. * Called when a value has changed
  19302. */
  19303. valueChanged: boolean;
  19304. }
  19305. /**
  19306. * Represents a gamepad
  19307. */
  19308. export class Gamepad {
  19309. /**
  19310. * The id of the gamepad
  19311. */
  19312. id: string;
  19313. /**
  19314. * The index of the gamepad
  19315. */
  19316. index: number;
  19317. /**
  19318. * The browser gamepad
  19319. */
  19320. browserGamepad: any;
  19321. /**
  19322. * Specifies what type of gamepad this represents
  19323. */
  19324. type: number;
  19325. private _leftStick;
  19326. private _rightStick;
  19327. /** @hidden */
  19328. _isConnected: boolean;
  19329. private _leftStickAxisX;
  19330. private _leftStickAxisY;
  19331. private _rightStickAxisX;
  19332. private _rightStickAxisY;
  19333. /**
  19334. * Triggered when the left control stick has been changed
  19335. */
  19336. private _onleftstickchanged;
  19337. /**
  19338. * Triggered when the right control stick has been changed
  19339. */
  19340. private _onrightstickchanged;
  19341. /**
  19342. * Represents a gamepad controller
  19343. */
  19344. static GAMEPAD: number;
  19345. /**
  19346. * Represents a generic controller
  19347. */
  19348. static GENERIC: number;
  19349. /**
  19350. * Represents an XBox controller
  19351. */
  19352. static XBOX: number;
  19353. /**
  19354. * Represents a pose-enabled controller
  19355. */
  19356. static POSE_ENABLED: number;
  19357. /**
  19358. * Represents an Dual Shock controller
  19359. */
  19360. static DUALSHOCK: number;
  19361. /**
  19362. * Specifies whether the left control stick should be Y-inverted
  19363. */
  19364. protected _invertLeftStickY: boolean;
  19365. /**
  19366. * Specifies if the gamepad has been connected
  19367. */
  19368. get isConnected(): boolean;
  19369. /**
  19370. * Initializes the gamepad
  19371. * @param id The id of the gamepad
  19372. * @param index The index of the gamepad
  19373. * @param browserGamepad The browser gamepad
  19374. * @param leftStickX The x component of the left joystick
  19375. * @param leftStickY The y component of the left joystick
  19376. * @param rightStickX The x component of the right joystick
  19377. * @param rightStickY The y component of the right joystick
  19378. */
  19379. constructor(
  19380. /**
  19381. * The id of the gamepad
  19382. */
  19383. id: string,
  19384. /**
  19385. * The index of the gamepad
  19386. */
  19387. index: number,
  19388. /**
  19389. * The browser gamepad
  19390. */
  19391. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19392. /**
  19393. * Callback triggered when the left joystick has changed
  19394. * @param callback
  19395. */
  19396. onleftstickchanged(callback: (values: StickValues) => void): void;
  19397. /**
  19398. * Callback triggered when the right joystick has changed
  19399. * @param callback
  19400. */
  19401. onrightstickchanged(callback: (values: StickValues) => void): void;
  19402. /**
  19403. * Gets the left joystick
  19404. */
  19405. get leftStick(): StickValues;
  19406. /**
  19407. * Sets the left joystick values
  19408. */
  19409. set leftStick(newValues: StickValues);
  19410. /**
  19411. * Gets the right joystick
  19412. */
  19413. get rightStick(): StickValues;
  19414. /**
  19415. * Sets the right joystick value
  19416. */
  19417. set rightStick(newValues: StickValues);
  19418. /**
  19419. * Updates the gamepad joystick positions
  19420. */
  19421. update(): void;
  19422. /**
  19423. * Disposes the gamepad
  19424. */
  19425. dispose(): void;
  19426. }
  19427. /**
  19428. * Represents a generic gamepad
  19429. */
  19430. export class GenericPad extends Gamepad {
  19431. private _buttons;
  19432. private _onbuttondown;
  19433. private _onbuttonup;
  19434. /**
  19435. * Observable triggered when a button has been pressed
  19436. */
  19437. onButtonDownObservable: Observable<number>;
  19438. /**
  19439. * Observable triggered when a button has been released
  19440. */
  19441. onButtonUpObservable: Observable<number>;
  19442. /**
  19443. * Callback triggered when a button has been pressed
  19444. * @param callback Called when a button has been pressed
  19445. */
  19446. onbuttondown(callback: (buttonPressed: number) => void): void;
  19447. /**
  19448. * Callback triggered when a button has been released
  19449. * @param callback Called when a button has been released
  19450. */
  19451. onbuttonup(callback: (buttonReleased: number) => void): void;
  19452. /**
  19453. * Initializes the generic gamepad
  19454. * @param id The id of the generic gamepad
  19455. * @param index The index of the generic gamepad
  19456. * @param browserGamepad The browser gamepad
  19457. */
  19458. constructor(id: string, index: number, browserGamepad: any);
  19459. private _setButtonValue;
  19460. /**
  19461. * Updates the generic gamepad
  19462. */
  19463. update(): void;
  19464. /**
  19465. * Disposes the generic gamepad
  19466. */
  19467. dispose(): void;
  19468. }
  19469. }
  19470. declare module BABYLON {
  19471. /**
  19472. * Defines the types of pose enabled controllers that are supported
  19473. */
  19474. export enum PoseEnabledControllerType {
  19475. /**
  19476. * HTC Vive
  19477. */
  19478. VIVE = 0,
  19479. /**
  19480. * Oculus Rift
  19481. */
  19482. OCULUS = 1,
  19483. /**
  19484. * Windows mixed reality
  19485. */
  19486. WINDOWS = 2,
  19487. /**
  19488. * Samsung gear VR
  19489. */
  19490. GEAR_VR = 3,
  19491. /**
  19492. * Google Daydream
  19493. */
  19494. DAYDREAM = 4,
  19495. /**
  19496. * Generic
  19497. */
  19498. GENERIC = 5
  19499. }
  19500. /**
  19501. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19502. */
  19503. export interface MutableGamepadButton {
  19504. /**
  19505. * Value of the button/trigger
  19506. */
  19507. value: number;
  19508. /**
  19509. * If the button/trigger is currently touched
  19510. */
  19511. touched: boolean;
  19512. /**
  19513. * If the button/trigger is currently pressed
  19514. */
  19515. pressed: boolean;
  19516. }
  19517. /**
  19518. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19519. * @hidden
  19520. */
  19521. export interface ExtendedGamepadButton extends GamepadButton {
  19522. /**
  19523. * If the button/trigger is currently pressed
  19524. */
  19525. readonly pressed: boolean;
  19526. /**
  19527. * If the button/trigger is currently touched
  19528. */
  19529. readonly touched: boolean;
  19530. /**
  19531. * Value of the button/trigger
  19532. */
  19533. readonly value: number;
  19534. }
  19535. /** @hidden */
  19536. export interface _GamePadFactory {
  19537. /**
  19538. * Returns whether or not the current gamepad can be created for this type of controller.
  19539. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19540. * @returns true if it can be created, otherwise false
  19541. */
  19542. canCreate(gamepadInfo: any): boolean;
  19543. /**
  19544. * Creates a new instance of the Gamepad.
  19545. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19546. * @returns the new gamepad instance
  19547. */
  19548. create(gamepadInfo: any): Gamepad;
  19549. }
  19550. /**
  19551. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19552. */
  19553. export class PoseEnabledControllerHelper {
  19554. /** @hidden */
  19555. static _ControllerFactories: _GamePadFactory[];
  19556. /** @hidden */
  19557. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19558. /**
  19559. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19560. * @param vrGamepad the gamepad to initialized
  19561. * @returns a vr controller of the type the gamepad identified as
  19562. */
  19563. static InitiateController(vrGamepad: any): Gamepad;
  19564. }
  19565. /**
  19566. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19567. */
  19568. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19569. /**
  19570. * If the controller is used in a webXR session
  19571. */
  19572. isXR: boolean;
  19573. private _deviceRoomPosition;
  19574. private _deviceRoomRotationQuaternion;
  19575. /**
  19576. * The device position in babylon space
  19577. */
  19578. devicePosition: Vector3;
  19579. /**
  19580. * The device rotation in babylon space
  19581. */
  19582. deviceRotationQuaternion: Quaternion;
  19583. /**
  19584. * The scale factor of the device in babylon space
  19585. */
  19586. deviceScaleFactor: number;
  19587. /**
  19588. * (Likely devicePosition should be used instead) The device position in its room space
  19589. */
  19590. position: Vector3;
  19591. /**
  19592. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19593. */
  19594. rotationQuaternion: Quaternion;
  19595. /**
  19596. * The type of controller (Eg. Windows mixed reality)
  19597. */
  19598. controllerType: PoseEnabledControllerType;
  19599. protected _calculatedPosition: Vector3;
  19600. private _calculatedRotation;
  19601. /**
  19602. * The raw pose from the device
  19603. */
  19604. rawPose: DevicePose;
  19605. private _trackPosition;
  19606. private _maxRotationDistFromHeadset;
  19607. private _draggedRoomRotation;
  19608. /**
  19609. * @hidden
  19610. */
  19611. _disableTrackPosition(fixedPosition: Vector3): void;
  19612. /**
  19613. * Internal, the mesh attached to the controller
  19614. * @hidden
  19615. */
  19616. _mesh: Nullable<AbstractMesh>;
  19617. private _poseControlledCamera;
  19618. private _leftHandSystemQuaternion;
  19619. /**
  19620. * Internal, matrix used to convert room space to babylon space
  19621. * @hidden
  19622. */
  19623. _deviceToWorld: Matrix;
  19624. /**
  19625. * Node to be used when casting a ray from the controller
  19626. * @hidden
  19627. */
  19628. _pointingPoseNode: Nullable<TransformNode>;
  19629. /**
  19630. * Name of the child mesh that can be used to cast a ray from the controller
  19631. */
  19632. static readonly POINTING_POSE: string;
  19633. /**
  19634. * Creates a new PoseEnabledController from a gamepad
  19635. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19636. */
  19637. constructor(browserGamepad: any);
  19638. private _workingMatrix;
  19639. /**
  19640. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19641. */
  19642. update(): void;
  19643. /**
  19644. * Updates only the pose device and mesh without doing any button event checking
  19645. */
  19646. protected _updatePoseAndMesh(): void;
  19647. /**
  19648. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19649. * @param poseData raw pose fromthe device
  19650. */
  19651. updateFromDevice(poseData: DevicePose): void;
  19652. /**
  19653. * @hidden
  19654. */
  19655. _meshAttachedObservable: Observable<AbstractMesh>;
  19656. /**
  19657. * Attaches a mesh to the controller
  19658. * @param mesh the mesh to be attached
  19659. */
  19660. attachToMesh(mesh: AbstractMesh): void;
  19661. /**
  19662. * Attaches the controllers mesh to a camera
  19663. * @param camera the camera the mesh should be attached to
  19664. */
  19665. attachToPoseControlledCamera(camera: TargetCamera): void;
  19666. /**
  19667. * Disposes of the controller
  19668. */
  19669. dispose(): void;
  19670. /**
  19671. * The mesh that is attached to the controller
  19672. */
  19673. get mesh(): Nullable<AbstractMesh>;
  19674. /**
  19675. * Gets the ray of the controller in the direction the controller is pointing
  19676. * @param length the length the resulting ray should be
  19677. * @returns a ray in the direction the controller is pointing
  19678. */
  19679. getForwardRay(length?: number): Ray;
  19680. }
  19681. }
  19682. declare module BABYLON {
  19683. /**
  19684. * Defines the WebVRController object that represents controllers tracked in 3D space
  19685. */
  19686. export abstract class WebVRController extends PoseEnabledController {
  19687. /**
  19688. * Internal, the default controller model for the controller
  19689. */
  19690. protected _defaultModel: Nullable<AbstractMesh>;
  19691. /**
  19692. * Fired when the trigger state has changed
  19693. */
  19694. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19695. /**
  19696. * Fired when the main button state has changed
  19697. */
  19698. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19699. /**
  19700. * Fired when the secondary button state has changed
  19701. */
  19702. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19703. /**
  19704. * Fired when the pad state has changed
  19705. */
  19706. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19707. /**
  19708. * Fired when controllers stick values have changed
  19709. */
  19710. onPadValuesChangedObservable: Observable<StickValues>;
  19711. /**
  19712. * Array of button availible on the controller
  19713. */
  19714. protected _buttons: Array<MutableGamepadButton>;
  19715. private _onButtonStateChange;
  19716. /**
  19717. * Fired when a controller button's state has changed
  19718. * @param callback the callback containing the button that was modified
  19719. */
  19720. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19721. /**
  19722. * X and Y axis corresponding to the controllers joystick
  19723. */
  19724. pad: StickValues;
  19725. /**
  19726. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19727. */
  19728. hand: string;
  19729. /**
  19730. * The default controller model for the controller
  19731. */
  19732. get defaultModel(): Nullable<AbstractMesh>;
  19733. /**
  19734. * Creates a new WebVRController from a gamepad
  19735. * @param vrGamepad the gamepad that the WebVRController should be created from
  19736. */
  19737. constructor(vrGamepad: any);
  19738. /**
  19739. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19740. */
  19741. update(): void;
  19742. /**
  19743. * Function to be called when a button is modified
  19744. */
  19745. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19746. /**
  19747. * Loads a mesh and attaches it to the controller
  19748. * @param scene the scene the mesh should be added to
  19749. * @param meshLoaded callback for when the mesh has been loaded
  19750. */
  19751. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19752. private _setButtonValue;
  19753. private _changes;
  19754. private _checkChanges;
  19755. /**
  19756. * Disposes of th webVRCOntroller
  19757. */
  19758. dispose(): void;
  19759. }
  19760. }
  19761. declare module BABYLON {
  19762. /**
  19763. * The HemisphericLight simulates the ambient environment light,
  19764. * so the passed direction is the light reflection direction, not the incoming direction.
  19765. */
  19766. export class HemisphericLight extends Light {
  19767. /**
  19768. * The groundColor is the light in the opposite direction to the one specified during creation.
  19769. * 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.
  19770. */
  19771. groundColor: Color3;
  19772. /**
  19773. * The light reflection direction, not the incoming direction.
  19774. */
  19775. direction: Vector3;
  19776. /**
  19777. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19778. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19779. * The HemisphericLight can't cast shadows.
  19780. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19781. * @param name The friendly name of the light
  19782. * @param direction The direction of the light reflection
  19783. * @param scene The scene the light belongs to
  19784. */
  19785. constructor(name: string, direction: Vector3, scene: Scene);
  19786. protected _buildUniformLayout(): void;
  19787. /**
  19788. * Returns the string "HemisphericLight".
  19789. * @return The class name
  19790. */
  19791. getClassName(): string;
  19792. /**
  19793. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19794. * Returns the updated direction.
  19795. * @param target The target the direction should point to
  19796. * @return The computed direction
  19797. */
  19798. setDirectionToTarget(target: Vector3): Vector3;
  19799. /**
  19800. * Returns the shadow generator associated to the light.
  19801. * @returns Always null for hemispheric lights because it does not support shadows.
  19802. */
  19803. getShadowGenerator(): Nullable<IShadowGenerator>;
  19804. /**
  19805. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19806. * @param effect The effect to update
  19807. * @param lightIndex The index of the light in the effect to update
  19808. * @returns The hemispheric light
  19809. */
  19810. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19811. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19812. /**
  19813. * Computes the world matrix of the node
  19814. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19815. * @param useWasUpdatedFlag defines a reserved property
  19816. * @returns the world matrix
  19817. */
  19818. computeWorldMatrix(): Matrix;
  19819. /**
  19820. * Returns the integer 3.
  19821. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19822. */
  19823. getTypeID(): number;
  19824. /**
  19825. * Prepares the list of defines specific to the light type.
  19826. * @param defines the list of defines
  19827. * @param lightIndex defines the index of the light for the effect
  19828. */
  19829. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19830. }
  19831. }
  19832. declare module BABYLON {
  19833. /** @hidden */
  19834. export var vrMultiviewToSingleviewPixelShader: {
  19835. name: string;
  19836. shader: string;
  19837. };
  19838. }
  19839. declare module BABYLON {
  19840. /**
  19841. * Renders to multiple views with a single draw call
  19842. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19843. */
  19844. export class MultiviewRenderTarget extends RenderTargetTexture {
  19845. /**
  19846. * Creates a multiview render target
  19847. * @param scene scene used with the render target
  19848. * @param size the size of the render target (used for each view)
  19849. */
  19850. constructor(scene: Scene, size?: number | {
  19851. width: number;
  19852. height: number;
  19853. } | {
  19854. ratio: number;
  19855. });
  19856. /**
  19857. * @hidden
  19858. * @param faceIndex the face index, if its a cube texture
  19859. */
  19860. _bindFrameBuffer(faceIndex?: number): void;
  19861. /**
  19862. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19863. * @returns the view count
  19864. */
  19865. getViewCount(): number;
  19866. }
  19867. }
  19868. declare module BABYLON {
  19869. interface Engine {
  19870. /**
  19871. * Creates a new multiview render target
  19872. * @param width defines the width of the texture
  19873. * @param height defines the height of the texture
  19874. * @returns the created multiview texture
  19875. */
  19876. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19877. /**
  19878. * Binds a multiview framebuffer to be drawn to
  19879. * @param multiviewTexture texture to bind
  19880. */
  19881. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19882. }
  19883. interface Camera {
  19884. /**
  19885. * @hidden
  19886. * 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)
  19887. */
  19888. _useMultiviewToSingleView: boolean;
  19889. /**
  19890. * @hidden
  19891. * 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)
  19892. */
  19893. _multiviewTexture: Nullable<RenderTargetTexture>;
  19894. /**
  19895. * @hidden
  19896. * ensures the multiview texture of the camera exists and has the specified width/height
  19897. * @param width height to set on the multiview texture
  19898. * @param height width to set on the multiview texture
  19899. */
  19900. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19901. }
  19902. interface Scene {
  19903. /** @hidden */
  19904. _transformMatrixR: Matrix;
  19905. /** @hidden */
  19906. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19907. /** @hidden */
  19908. _createMultiviewUbo(): void;
  19909. /** @hidden */
  19910. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19911. /** @hidden */
  19912. _renderMultiviewToSingleView(camera: Camera): void;
  19913. }
  19914. }
  19915. declare module BABYLON {
  19916. /**
  19917. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19918. * This will not be used for webXR as it supports displaying texture arrays directly
  19919. */
  19920. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19921. /**
  19922. * Gets a string identifying the name of the class
  19923. * @returns "VRMultiviewToSingleviewPostProcess" string
  19924. */
  19925. getClassName(): string;
  19926. /**
  19927. * Initializes a VRMultiviewToSingleview
  19928. * @param name name of the post process
  19929. * @param camera camera to be applied to
  19930. * @param scaleFactor scaling factor to the size of the output texture
  19931. */
  19932. constructor(name: string, camera: Camera, scaleFactor: number);
  19933. }
  19934. }
  19935. declare module BABYLON {
  19936. /**
  19937. * Interface used to define additional presentation attributes
  19938. */
  19939. export interface IVRPresentationAttributes {
  19940. /**
  19941. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19942. */
  19943. highRefreshRate: boolean;
  19944. /**
  19945. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19946. */
  19947. foveationLevel: number;
  19948. }
  19949. interface Engine {
  19950. /** @hidden */
  19951. _vrDisplay: any;
  19952. /** @hidden */
  19953. _vrSupported: boolean;
  19954. /** @hidden */
  19955. _oldSize: Size;
  19956. /** @hidden */
  19957. _oldHardwareScaleFactor: number;
  19958. /** @hidden */
  19959. _vrExclusivePointerMode: boolean;
  19960. /** @hidden */
  19961. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19962. /** @hidden */
  19963. _onVRDisplayPointerRestricted: () => void;
  19964. /** @hidden */
  19965. _onVRDisplayPointerUnrestricted: () => void;
  19966. /** @hidden */
  19967. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19968. /** @hidden */
  19969. _onVrDisplayDisconnect: Nullable<() => void>;
  19970. /** @hidden */
  19971. _onVrDisplayPresentChange: Nullable<() => void>;
  19972. /**
  19973. * Observable signaled when VR display mode changes
  19974. */
  19975. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19976. /**
  19977. * Observable signaled when VR request present is complete
  19978. */
  19979. onVRRequestPresentComplete: Observable<boolean>;
  19980. /**
  19981. * Observable signaled when VR request present starts
  19982. */
  19983. onVRRequestPresentStart: Observable<Engine>;
  19984. /**
  19985. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19986. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19987. */
  19988. isInVRExclusivePointerMode: boolean;
  19989. /**
  19990. * Gets a boolean indicating if a webVR device was detected
  19991. * @returns true if a webVR device was detected
  19992. */
  19993. isVRDevicePresent(): boolean;
  19994. /**
  19995. * Gets the current webVR device
  19996. * @returns the current webVR device (or null)
  19997. */
  19998. getVRDevice(): any;
  19999. /**
  20000. * Initializes a webVR display and starts listening to display change events
  20001. * The onVRDisplayChangedObservable will be notified upon these changes
  20002. * @returns A promise containing a VRDisplay and if vr is supported
  20003. */
  20004. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20005. /** @hidden */
  20006. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20007. /**
  20008. * Gets or sets the presentation attributes used to configure VR rendering
  20009. */
  20010. vrPresentationAttributes?: IVRPresentationAttributes;
  20011. /**
  20012. * Call this function to switch to webVR mode
  20013. * Will do nothing if webVR is not supported or if there is no webVR device
  20014. * @param options the webvr options provided to the camera. mainly used for multiview
  20015. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20016. */
  20017. enableVR(options: WebVROptions): void;
  20018. /** @hidden */
  20019. _onVRFullScreenTriggered(): void;
  20020. }
  20021. }
  20022. declare module BABYLON {
  20023. /**
  20024. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20025. * IMPORTANT!! The data is right-hand data.
  20026. * @export
  20027. * @interface DevicePose
  20028. */
  20029. export interface DevicePose {
  20030. /**
  20031. * The position of the device, values in array are [x,y,z].
  20032. */
  20033. readonly position: Nullable<Float32Array>;
  20034. /**
  20035. * The linearVelocity of the device, values in array are [x,y,z].
  20036. */
  20037. readonly linearVelocity: Nullable<Float32Array>;
  20038. /**
  20039. * The linearAcceleration of the device, values in array are [x,y,z].
  20040. */
  20041. readonly linearAcceleration: Nullable<Float32Array>;
  20042. /**
  20043. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20044. */
  20045. readonly orientation: Nullable<Float32Array>;
  20046. /**
  20047. * The angularVelocity of the device, values in array are [x,y,z].
  20048. */
  20049. readonly angularVelocity: Nullable<Float32Array>;
  20050. /**
  20051. * The angularAcceleration of the device, values in array are [x,y,z].
  20052. */
  20053. readonly angularAcceleration: Nullable<Float32Array>;
  20054. }
  20055. /**
  20056. * Interface representing a pose controlled object in Babylon.
  20057. * A pose controlled object has both regular pose values as well as pose values
  20058. * from an external device such as a VR head mounted display
  20059. */
  20060. export interface PoseControlled {
  20061. /**
  20062. * The position of the object in babylon space.
  20063. */
  20064. position: Vector3;
  20065. /**
  20066. * The rotation quaternion of the object in babylon space.
  20067. */
  20068. rotationQuaternion: Quaternion;
  20069. /**
  20070. * The position of the device in babylon space.
  20071. */
  20072. devicePosition?: Vector3;
  20073. /**
  20074. * The rotation quaternion of the device in babylon space.
  20075. */
  20076. deviceRotationQuaternion: Quaternion;
  20077. /**
  20078. * The raw pose coming from the device.
  20079. */
  20080. rawPose: Nullable<DevicePose>;
  20081. /**
  20082. * The scale of the device to be used when translating from device space to babylon space.
  20083. */
  20084. deviceScaleFactor: number;
  20085. /**
  20086. * Updates the poseControlled values based on the input device pose.
  20087. * @param poseData the pose data to update the object with
  20088. */
  20089. updateFromDevice(poseData: DevicePose): void;
  20090. }
  20091. /**
  20092. * Set of options to customize the webVRCamera
  20093. */
  20094. export interface WebVROptions {
  20095. /**
  20096. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20097. */
  20098. trackPosition?: boolean;
  20099. /**
  20100. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20101. */
  20102. positionScale?: number;
  20103. /**
  20104. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20105. */
  20106. displayName?: string;
  20107. /**
  20108. * Should the native controller meshes be initialized. (default: true)
  20109. */
  20110. controllerMeshes?: boolean;
  20111. /**
  20112. * Creating a default HemiLight only on controllers. (default: true)
  20113. */
  20114. defaultLightingOnControllers?: boolean;
  20115. /**
  20116. * If you don't want to use the default VR button of the helper. (default: false)
  20117. */
  20118. useCustomVRButton?: boolean;
  20119. /**
  20120. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20121. */
  20122. customVRButton?: HTMLButtonElement;
  20123. /**
  20124. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20125. */
  20126. rayLength?: number;
  20127. /**
  20128. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20129. */
  20130. defaultHeight?: number;
  20131. /**
  20132. * If multiview should be used if availible (default: false)
  20133. */
  20134. useMultiview?: boolean;
  20135. }
  20136. /**
  20137. * This represents a WebVR camera.
  20138. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20139. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20140. */
  20141. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20142. private webVROptions;
  20143. /**
  20144. * @hidden
  20145. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20146. */
  20147. _vrDevice: any;
  20148. /**
  20149. * The rawPose of the vrDevice.
  20150. */
  20151. rawPose: Nullable<DevicePose>;
  20152. private _onVREnabled;
  20153. private _specsVersion;
  20154. private _attached;
  20155. private _frameData;
  20156. protected _descendants: Array<Node>;
  20157. private _deviceRoomPosition;
  20158. /** @hidden */
  20159. _deviceRoomRotationQuaternion: Quaternion;
  20160. private _standingMatrix;
  20161. /**
  20162. * Represents device position in babylon space.
  20163. */
  20164. devicePosition: Vector3;
  20165. /**
  20166. * Represents device rotation in babylon space.
  20167. */
  20168. deviceRotationQuaternion: Quaternion;
  20169. /**
  20170. * The scale of the device to be used when translating from device space to babylon space.
  20171. */
  20172. deviceScaleFactor: number;
  20173. private _deviceToWorld;
  20174. private _worldToDevice;
  20175. /**
  20176. * References to the webVR controllers for the vrDevice.
  20177. */
  20178. controllers: Array<WebVRController>;
  20179. /**
  20180. * Emits an event when a controller is attached.
  20181. */
  20182. onControllersAttachedObservable: Observable<WebVRController[]>;
  20183. /**
  20184. * Emits an event when a controller's mesh has been loaded;
  20185. */
  20186. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20187. /**
  20188. * Emits an event when the HMD's pose has been updated.
  20189. */
  20190. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20191. private _poseSet;
  20192. /**
  20193. * If the rig cameras be used as parent instead of this camera.
  20194. */
  20195. rigParenting: boolean;
  20196. private _lightOnControllers;
  20197. private _defaultHeight?;
  20198. /**
  20199. * Instantiates a WebVRFreeCamera.
  20200. * @param name The name of the WebVRFreeCamera
  20201. * @param position The starting anchor position for the camera
  20202. * @param scene The scene the camera belongs to
  20203. * @param webVROptions a set of customizable options for the webVRCamera
  20204. */
  20205. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20206. /**
  20207. * Gets the device distance from the ground in meters.
  20208. * @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.
  20209. */
  20210. deviceDistanceToRoomGround(): number;
  20211. /**
  20212. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20213. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20214. */
  20215. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20216. /**
  20217. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20218. * @returns A promise with a boolean set to if the standing matrix is supported.
  20219. */
  20220. useStandingMatrixAsync(): Promise<boolean>;
  20221. /**
  20222. * Disposes the camera
  20223. */
  20224. dispose(): void;
  20225. /**
  20226. * Gets a vrController by name.
  20227. * @param name The name of the controller to retreive
  20228. * @returns the controller matching the name specified or null if not found
  20229. */
  20230. getControllerByName(name: string): Nullable<WebVRController>;
  20231. private _leftController;
  20232. /**
  20233. * The controller corresponding to the users left hand.
  20234. */
  20235. get leftController(): Nullable<WebVRController>;
  20236. private _rightController;
  20237. /**
  20238. * The controller corresponding to the users right hand.
  20239. */
  20240. get rightController(): Nullable<WebVRController>;
  20241. /**
  20242. * Casts a ray forward from the vrCamera's gaze.
  20243. * @param length Length of the ray (default: 100)
  20244. * @returns the ray corresponding to the gaze
  20245. */
  20246. getForwardRay(length?: number): Ray;
  20247. /**
  20248. * @hidden
  20249. * Updates the camera based on device's frame data
  20250. */
  20251. _checkInputs(): void;
  20252. /**
  20253. * Updates the poseControlled values based on the input device pose.
  20254. * @param poseData Pose coming from the device
  20255. */
  20256. updateFromDevice(poseData: DevicePose): void;
  20257. private _htmlElementAttached;
  20258. private _detachIfAttached;
  20259. /**
  20260. * WebVR's attach control will start broadcasting frames to the device.
  20261. * Note that in certain browsers (chrome for example) this function must be called
  20262. * within a user-interaction callback. Example:
  20263. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20264. *
  20265. * @param element html element to attach the vrDevice to
  20266. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20267. */
  20268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20269. /**
  20270. * Detaches the camera from the html element and disables VR
  20271. *
  20272. * @param element html element to detach from
  20273. */
  20274. detachControl(element: HTMLElement): void;
  20275. /**
  20276. * @returns the name of this class
  20277. */
  20278. getClassName(): string;
  20279. /**
  20280. * Calls resetPose on the vrDisplay
  20281. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20282. */
  20283. resetToCurrentRotation(): void;
  20284. /**
  20285. * @hidden
  20286. * Updates the rig cameras (left and right eye)
  20287. */
  20288. _updateRigCameras(): void;
  20289. private _workingVector;
  20290. private _oneVector;
  20291. private _workingMatrix;
  20292. private updateCacheCalled;
  20293. private _correctPositionIfNotTrackPosition;
  20294. /**
  20295. * @hidden
  20296. * Updates the cached values of the camera
  20297. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20298. */
  20299. _updateCache(ignoreParentClass?: boolean): void;
  20300. /**
  20301. * @hidden
  20302. * Get current device position in babylon world
  20303. */
  20304. _computeDevicePosition(): void;
  20305. /**
  20306. * Updates the current device position and rotation in the babylon world
  20307. */
  20308. update(): void;
  20309. /**
  20310. * @hidden
  20311. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20312. * @returns an identity matrix
  20313. */
  20314. _getViewMatrix(): Matrix;
  20315. private _tmpMatrix;
  20316. /**
  20317. * This function is called by the two RIG cameras.
  20318. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20319. * @hidden
  20320. */
  20321. _getWebVRViewMatrix(): Matrix;
  20322. /** @hidden */
  20323. _getWebVRProjectionMatrix(): Matrix;
  20324. private _onGamepadConnectedObserver;
  20325. private _onGamepadDisconnectedObserver;
  20326. private _updateCacheWhenTrackingDisabledObserver;
  20327. /**
  20328. * Initializes the controllers and their meshes
  20329. */
  20330. initControllers(): void;
  20331. }
  20332. }
  20333. declare module BABYLON {
  20334. /**
  20335. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20336. *
  20337. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20338. *
  20339. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20340. */
  20341. export class MaterialHelper {
  20342. /**
  20343. * Bind the current view position to an effect.
  20344. * @param effect The effect to be bound
  20345. * @param scene The scene the eyes position is used from
  20346. * @param variableName name of the shader variable that will hold the eye position
  20347. */
  20348. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20349. /**
  20350. * Helps preparing the defines values about the UVs in used in the effect.
  20351. * UVs are shared as much as we can accross channels in the shaders.
  20352. * @param texture The texture we are preparing the UVs for
  20353. * @param defines The defines to update
  20354. * @param key The channel key "diffuse", "specular"... used in the shader
  20355. */
  20356. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20357. /**
  20358. * Binds a texture matrix value to its corrsponding uniform
  20359. * @param texture The texture to bind the matrix for
  20360. * @param uniformBuffer The uniform buffer receivin the data
  20361. * @param key The channel key "diffuse", "specular"... used in the shader
  20362. */
  20363. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20364. /**
  20365. * Gets the current status of the fog (should it be enabled?)
  20366. * @param mesh defines the mesh to evaluate for fog support
  20367. * @param scene defines the hosting scene
  20368. * @returns true if fog must be enabled
  20369. */
  20370. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20371. /**
  20372. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20373. * @param mesh defines the current mesh
  20374. * @param scene defines the current scene
  20375. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20376. * @param pointsCloud defines if point cloud rendering has to be turned on
  20377. * @param fogEnabled defines if fog has to be turned on
  20378. * @param alphaTest defines if alpha testing has to be turned on
  20379. * @param defines defines the current list of defines
  20380. */
  20381. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20382. /**
  20383. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20384. * @param scene defines the current scene
  20385. * @param engine defines the current engine
  20386. * @param defines specifies the list of active defines
  20387. * @param useInstances defines if instances have to be turned on
  20388. * @param useClipPlane defines if clip plane have to be turned on
  20389. * @param useInstances defines if instances have to be turned on
  20390. * @param useThinInstances defines if thin instances have to be turned on
  20391. */
  20392. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20393. /**
  20394. * Prepares the defines for bones
  20395. * @param mesh The mesh containing the geometry data we will draw
  20396. * @param defines The defines to update
  20397. */
  20398. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20399. /**
  20400. * Prepares the defines for morph targets
  20401. * @param mesh The mesh containing the geometry data we will draw
  20402. * @param defines The defines to update
  20403. */
  20404. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20405. /**
  20406. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20407. * @param mesh The mesh containing the geometry data we will draw
  20408. * @param defines The defines to update
  20409. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20410. * @param useBones Precise whether bones should be used or not (override mesh info)
  20411. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20412. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20413. * @returns false if defines are considered not dirty and have not been checked
  20414. */
  20415. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20416. /**
  20417. * Prepares the defines related to multiview
  20418. * @param scene The scene we are intending to draw
  20419. * @param defines The defines to update
  20420. */
  20421. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20422. /**
  20423. * Prepares the defines related to the prepass
  20424. * @param scene The scene we are intending to draw
  20425. * @param defines The defines to update
  20426. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20427. */
  20428. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20429. /**
  20430. * Prepares the defines related to the light information passed in parameter
  20431. * @param scene The scene we are intending to draw
  20432. * @param mesh The mesh the effect is compiling for
  20433. * @param light The light the effect is compiling for
  20434. * @param lightIndex The index of the light
  20435. * @param defines The defines to update
  20436. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20437. * @param state Defines the current state regarding what is needed (normals, etc...)
  20438. */
  20439. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20440. needNormals: boolean;
  20441. needRebuild: boolean;
  20442. shadowEnabled: boolean;
  20443. specularEnabled: boolean;
  20444. lightmapMode: boolean;
  20445. }): void;
  20446. /**
  20447. * Prepares the defines related to the light information passed in parameter
  20448. * @param scene The scene we are intending to draw
  20449. * @param mesh The mesh the effect is compiling for
  20450. * @param defines The defines to update
  20451. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20452. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20453. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20454. * @returns true if normals will be required for the rest of the effect
  20455. */
  20456. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20457. /**
  20458. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20459. * @param lightIndex defines the light index
  20460. * @param uniformsList The uniform list
  20461. * @param samplersList The sampler list
  20462. * @param projectedLightTexture defines if projected texture must be used
  20463. * @param uniformBuffersList defines an optional list of uniform buffers
  20464. */
  20465. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20466. /**
  20467. * Prepares the uniforms and samplers list to be used in the effect
  20468. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20469. * @param samplersList The sampler list
  20470. * @param defines The defines helping in the list generation
  20471. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20472. */
  20473. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20474. /**
  20475. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20476. * @param defines The defines to update while falling back
  20477. * @param fallbacks The authorized effect fallbacks
  20478. * @param maxSimultaneousLights The maximum number of lights allowed
  20479. * @param rank the current rank of the Effect
  20480. * @returns The newly affected rank
  20481. */
  20482. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20483. private static _TmpMorphInfluencers;
  20484. /**
  20485. * Prepares the list of attributes required for morph targets according to the effect defines.
  20486. * @param attribs The current list of supported attribs
  20487. * @param mesh The mesh to prepare the morph targets attributes for
  20488. * @param influencers The number of influencers
  20489. */
  20490. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20491. /**
  20492. * Prepares the list of attributes required for morph targets according to the effect defines.
  20493. * @param attribs The current list of supported attribs
  20494. * @param mesh The mesh to prepare the morph targets attributes for
  20495. * @param defines The current Defines of the effect
  20496. */
  20497. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20498. /**
  20499. * Prepares the list of attributes required for bones according to the effect defines.
  20500. * @param attribs The current list of supported attribs
  20501. * @param mesh The mesh to prepare the bones attributes for
  20502. * @param defines The current Defines of the effect
  20503. * @param fallbacks The current efffect fallback strategy
  20504. */
  20505. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20506. /**
  20507. * Check and prepare the list of attributes required for instances according to the effect defines.
  20508. * @param attribs The current list of supported attribs
  20509. * @param defines The current MaterialDefines of the effect
  20510. */
  20511. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20512. /**
  20513. * Add the list of attributes required for instances to the attribs array.
  20514. * @param attribs The current list of supported attribs
  20515. */
  20516. static PushAttributesForInstances(attribs: string[]): void;
  20517. /**
  20518. * Binds the light information to the effect.
  20519. * @param light The light containing the generator
  20520. * @param effect The effect we are binding the data to
  20521. * @param lightIndex The light index in the effect used to render
  20522. */
  20523. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20524. /**
  20525. * Binds the lights information from the scene to the effect for the given mesh.
  20526. * @param light Light to bind
  20527. * @param lightIndex Light index
  20528. * @param scene The scene where the light belongs to
  20529. * @param effect The effect we are binding the data to
  20530. * @param useSpecular Defines if specular is supported
  20531. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20532. */
  20533. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20534. /**
  20535. * Binds the lights information from the scene to the effect for the given mesh.
  20536. * @param scene The scene the lights belongs to
  20537. * @param mesh The mesh we are binding the information to render
  20538. * @param effect The effect we are binding the data to
  20539. * @param defines The generated defines for the effect
  20540. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20541. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20542. */
  20543. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20544. private static _tempFogColor;
  20545. /**
  20546. * Binds the fog information from the scene to the effect for the given mesh.
  20547. * @param scene The scene the lights belongs to
  20548. * @param mesh The mesh we are binding the information to render
  20549. * @param effect The effect we are binding the data to
  20550. * @param linearSpace Defines if the fog effect is applied in linear space
  20551. */
  20552. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20553. /**
  20554. * Binds the bones information from the mesh to the effect.
  20555. * @param mesh The mesh we are binding the information to render
  20556. * @param effect The effect we are binding the data to
  20557. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  20558. */
  20559. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  20560. private static _CopyBonesTransformationMatrices;
  20561. /**
  20562. * Binds the morph targets information from the mesh to the effect.
  20563. * @param abstractMesh The mesh we are binding the information to render
  20564. * @param effect The effect we are binding the data to
  20565. */
  20566. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20567. /**
  20568. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20569. * @param defines The generated defines used in the effect
  20570. * @param effect The effect we are binding the data to
  20571. * @param scene The scene we are willing to render with logarithmic scale for
  20572. */
  20573. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20574. /**
  20575. * Binds the clip plane information from the scene to the effect.
  20576. * @param scene The scene the clip plane information are extracted from
  20577. * @param effect The effect we are binding the data to
  20578. */
  20579. static BindClipPlane(effect: Effect, scene: Scene): void;
  20580. }
  20581. }
  20582. declare module BABYLON {
  20583. /**
  20584. * Block used to expose an input value
  20585. */
  20586. export class InputBlock extends NodeMaterialBlock {
  20587. private _mode;
  20588. private _associatedVariableName;
  20589. private _storedValue;
  20590. private _valueCallback;
  20591. private _type;
  20592. private _animationType;
  20593. /** Gets or set a value used to limit the range of float values */
  20594. min: number;
  20595. /** Gets or set a value used to limit the range of float values */
  20596. max: number;
  20597. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20598. isBoolean: boolean;
  20599. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20600. matrixMode: number;
  20601. /** @hidden */
  20602. _systemValue: Nullable<NodeMaterialSystemValues>;
  20603. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20604. isConstant: boolean;
  20605. /** Gets or sets the group to use to display this block in the Inspector */
  20606. groupInInspector: string;
  20607. /** Gets an observable raised when the value is changed */
  20608. onValueChangedObservable: Observable<InputBlock>;
  20609. /**
  20610. * Gets or sets the connection point type (default is float)
  20611. */
  20612. get type(): NodeMaterialBlockConnectionPointTypes;
  20613. /**
  20614. * Creates a new InputBlock
  20615. * @param name defines the block name
  20616. * @param target defines the target of that block (Vertex by default)
  20617. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20618. */
  20619. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20620. /**
  20621. * Validates if a name is a reserve word.
  20622. * @param newName the new name to be given to the node.
  20623. * @returns false if the name is a reserve word, else true.
  20624. */
  20625. validateBlockName(newName: string): boolean;
  20626. /**
  20627. * Gets the output component
  20628. */
  20629. get output(): NodeMaterialConnectionPoint;
  20630. /**
  20631. * Set the source of this connection point to a vertex attribute
  20632. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20633. * @returns the current connection point
  20634. */
  20635. setAsAttribute(attributeName?: string): InputBlock;
  20636. /**
  20637. * Set the source of this connection point to a system value
  20638. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20639. * @returns the current connection point
  20640. */
  20641. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20642. /**
  20643. * Gets or sets the value of that point.
  20644. * Please note that this value will be ignored if valueCallback is defined
  20645. */
  20646. get value(): any;
  20647. set value(value: any);
  20648. /**
  20649. * Gets or sets a callback used to get the value of that point.
  20650. * Please note that setting this value will force the connection point to ignore the value property
  20651. */
  20652. get valueCallback(): () => any;
  20653. set valueCallback(value: () => any);
  20654. /**
  20655. * Gets or sets the associated variable name in the shader
  20656. */
  20657. get associatedVariableName(): string;
  20658. set associatedVariableName(value: string);
  20659. /** Gets or sets the type of animation applied to the input */
  20660. get animationType(): AnimatedInputBlockTypes;
  20661. set animationType(value: AnimatedInputBlockTypes);
  20662. /**
  20663. * Gets a boolean indicating that this connection point not defined yet
  20664. */
  20665. get isUndefined(): boolean;
  20666. /**
  20667. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20668. * In this case the connection point name must be the name of the uniform to use.
  20669. * Can only be set on inputs
  20670. */
  20671. get isUniform(): boolean;
  20672. set isUniform(value: boolean);
  20673. /**
  20674. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20675. * In this case the connection point name must be the name of the attribute to use
  20676. * Can only be set on inputs
  20677. */
  20678. get isAttribute(): boolean;
  20679. set isAttribute(value: boolean);
  20680. /**
  20681. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20682. * Can only be set on exit points
  20683. */
  20684. get isVarying(): boolean;
  20685. set isVarying(value: boolean);
  20686. /**
  20687. * Gets a boolean indicating that the current connection point is a system value
  20688. */
  20689. get isSystemValue(): boolean;
  20690. /**
  20691. * Gets or sets the current well known value or null if not defined as a system value
  20692. */
  20693. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20694. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20695. /**
  20696. * Gets the current class name
  20697. * @returns the class name
  20698. */
  20699. getClassName(): string;
  20700. /**
  20701. * Animate the input if animationType !== None
  20702. * @param scene defines the rendering scene
  20703. */
  20704. animate(scene: Scene): void;
  20705. private _emitDefine;
  20706. initialize(state: NodeMaterialBuildState): void;
  20707. /**
  20708. * Set the input block to its default value (based on its type)
  20709. */
  20710. setDefaultValue(): void;
  20711. private _emitConstant;
  20712. /** @hidden */
  20713. get _noContextSwitch(): boolean;
  20714. private _emit;
  20715. /** @hidden */
  20716. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20717. /** @hidden */
  20718. _transmit(effect: Effect, scene: Scene): void;
  20719. protected _buildBlock(state: NodeMaterialBuildState): void;
  20720. protected _dumpPropertiesCode(): string;
  20721. dispose(): void;
  20722. serialize(): any;
  20723. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20724. }
  20725. }
  20726. declare module BABYLON {
  20727. /**
  20728. * Enum used to define the compatibility state between two connection points
  20729. */
  20730. export enum NodeMaterialConnectionPointCompatibilityStates {
  20731. /** Points are compatibles */
  20732. Compatible = 0,
  20733. /** Points are incompatible because of their types */
  20734. TypeIncompatible = 1,
  20735. /** Points are incompatible because of their targets (vertex vs fragment) */
  20736. TargetIncompatible = 2
  20737. }
  20738. /**
  20739. * Defines the direction of a connection point
  20740. */
  20741. export enum NodeMaterialConnectionPointDirection {
  20742. /** Input */
  20743. Input = 0,
  20744. /** Output */
  20745. Output = 1
  20746. }
  20747. /**
  20748. * Defines a connection point for a block
  20749. */
  20750. export class NodeMaterialConnectionPoint {
  20751. /** @hidden */
  20752. _ownerBlock: NodeMaterialBlock;
  20753. /** @hidden */
  20754. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20755. private _endpoints;
  20756. private _associatedVariableName;
  20757. private _direction;
  20758. /** @hidden */
  20759. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20760. /** @hidden */
  20761. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20762. private _type;
  20763. /** @hidden */
  20764. _enforceAssociatedVariableName: boolean;
  20765. /** Gets the direction of the point */
  20766. get direction(): NodeMaterialConnectionPointDirection;
  20767. /** Indicates that this connection point needs dual validation before being connected to another point */
  20768. needDualDirectionValidation: boolean;
  20769. /**
  20770. * Gets or sets the additional types supported by this connection point
  20771. */
  20772. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20773. /**
  20774. * Gets or sets the additional types excluded by this connection point
  20775. */
  20776. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20777. /**
  20778. * Observable triggered when this point is connected
  20779. */
  20780. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20781. /**
  20782. * Gets or sets the associated variable name in the shader
  20783. */
  20784. get associatedVariableName(): string;
  20785. set associatedVariableName(value: string);
  20786. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20787. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20788. /**
  20789. * Gets or sets the connection point type (default is float)
  20790. */
  20791. get type(): NodeMaterialBlockConnectionPointTypes;
  20792. set type(value: NodeMaterialBlockConnectionPointTypes);
  20793. /**
  20794. * Gets or sets the connection point name
  20795. */
  20796. name: string;
  20797. /**
  20798. * Gets or sets the connection point name
  20799. */
  20800. displayName: string;
  20801. /**
  20802. * Gets or sets a boolean indicating that this connection point can be omitted
  20803. */
  20804. isOptional: boolean;
  20805. /**
  20806. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20807. */
  20808. isExposedOnFrame: boolean;
  20809. /**
  20810. * Gets or sets number indicating the position that the port is exposed to on a frame
  20811. */
  20812. exposedPortPosition: number;
  20813. /**
  20814. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20815. */
  20816. define: string;
  20817. /** @hidden */
  20818. _prioritizeVertex: boolean;
  20819. private _target;
  20820. /** Gets or sets the target of that connection point */
  20821. get target(): NodeMaterialBlockTargets;
  20822. set target(value: NodeMaterialBlockTargets);
  20823. /**
  20824. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20825. */
  20826. get isConnected(): boolean;
  20827. /**
  20828. * Gets a boolean indicating that the current point is connected to an input block
  20829. */
  20830. get isConnectedToInputBlock(): boolean;
  20831. /**
  20832. * Gets a the connected input block (if any)
  20833. */
  20834. get connectInputBlock(): Nullable<InputBlock>;
  20835. /** Get the other side of the connection (if any) */
  20836. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20837. /** Get the block that owns this connection point */
  20838. get ownerBlock(): NodeMaterialBlock;
  20839. /** Get the block connected on the other side of this connection (if any) */
  20840. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20841. /** Get the block connected on the endpoints of this connection (if any) */
  20842. get connectedBlocks(): Array<NodeMaterialBlock>;
  20843. /** Gets the list of connected endpoints */
  20844. get endpoints(): NodeMaterialConnectionPoint[];
  20845. /** Gets a boolean indicating if that output point is connected to at least one input */
  20846. get hasEndpoints(): boolean;
  20847. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20848. get isConnectedInVertexShader(): boolean;
  20849. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20850. get isConnectedInFragmentShader(): boolean;
  20851. /**
  20852. * Creates a block suitable to be used as an input for this input point.
  20853. * If null is returned, a block based on the point type will be created.
  20854. * @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
  20855. */
  20856. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20857. /**
  20858. * Creates a new connection point
  20859. * @param name defines the connection point name
  20860. * @param ownerBlock defines the block hosting this connection point
  20861. * @param direction defines the direction of the connection point
  20862. */
  20863. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20864. /**
  20865. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20866. * @returns the class name
  20867. */
  20868. getClassName(): string;
  20869. /**
  20870. * Gets a boolean indicating if the current point can be connected to another point
  20871. * @param connectionPoint defines the other connection point
  20872. * @returns a boolean
  20873. */
  20874. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20875. /**
  20876. * Gets a number indicating if the current point can be connected to another point
  20877. * @param connectionPoint defines the other connection point
  20878. * @returns a number defining the compatibility state
  20879. */
  20880. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20881. /**
  20882. * Connect this point to another connection point
  20883. * @param connectionPoint defines the other connection point
  20884. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20885. * @returns the current connection point
  20886. */
  20887. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20888. /**
  20889. * Disconnect this point from one of his endpoint
  20890. * @param endpoint defines the other connection point
  20891. * @returns the current connection point
  20892. */
  20893. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20894. /**
  20895. * Serializes this point in a JSON representation
  20896. * @param isInput defines if the connection point is an input (default is true)
  20897. * @returns the serialized point object
  20898. */
  20899. serialize(isInput?: boolean): any;
  20900. /**
  20901. * Release resources
  20902. */
  20903. dispose(): void;
  20904. }
  20905. }
  20906. declare module BABYLON {
  20907. /**
  20908. * Enum used to define the material modes
  20909. */
  20910. export enum NodeMaterialModes {
  20911. /** Regular material */
  20912. Material = 0,
  20913. /** For post process */
  20914. PostProcess = 1,
  20915. /** For particle system */
  20916. Particle = 2,
  20917. /** For procedural texture */
  20918. ProceduralTexture = 3
  20919. }
  20920. }
  20921. declare module BABYLON {
  20922. /**
  20923. * Block used to read a texture from a sampler
  20924. */
  20925. export class TextureBlock extends NodeMaterialBlock {
  20926. private _defineName;
  20927. private _linearDefineName;
  20928. private _gammaDefineName;
  20929. private _tempTextureRead;
  20930. private _samplerName;
  20931. private _transformedUVName;
  20932. private _textureTransformName;
  20933. private _textureInfoName;
  20934. private _mainUVName;
  20935. private _mainUVDefineName;
  20936. private _fragmentOnly;
  20937. /**
  20938. * Gets or sets the texture associated with the node
  20939. */
  20940. texture: Nullable<Texture>;
  20941. /**
  20942. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20943. */
  20944. convertToGammaSpace: boolean;
  20945. /**
  20946. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20947. */
  20948. convertToLinearSpace: boolean;
  20949. /**
  20950. * Create a new TextureBlock
  20951. * @param name defines the block name
  20952. */
  20953. constructor(name: string, fragmentOnly?: boolean);
  20954. /**
  20955. * Gets the current class name
  20956. * @returns the class name
  20957. */
  20958. getClassName(): string;
  20959. /**
  20960. * Gets the uv input component
  20961. */
  20962. get uv(): NodeMaterialConnectionPoint;
  20963. /**
  20964. * Gets the rgba output component
  20965. */
  20966. get rgba(): NodeMaterialConnectionPoint;
  20967. /**
  20968. * Gets the rgb output component
  20969. */
  20970. get rgb(): NodeMaterialConnectionPoint;
  20971. /**
  20972. * Gets the r output component
  20973. */
  20974. get r(): NodeMaterialConnectionPoint;
  20975. /**
  20976. * Gets the g output component
  20977. */
  20978. get g(): NodeMaterialConnectionPoint;
  20979. /**
  20980. * Gets the b output component
  20981. */
  20982. get b(): NodeMaterialConnectionPoint;
  20983. /**
  20984. * Gets the a output component
  20985. */
  20986. get a(): NodeMaterialConnectionPoint;
  20987. get target(): NodeMaterialBlockTargets;
  20988. autoConfigure(material: NodeMaterial): void;
  20989. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20990. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20991. isReady(): boolean;
  20992. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20993. private get _isMixed();
  20994. private _injectVertexCode;
  20995. private _writeTextureRead;
  20996. private _writeOutput;
  20997. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20998. protected _dumpPropertiesCode(): string;
  20999. serialize(): any;
  21000. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21001. }
  21002. }
  21003. declare module BABYLON {
  21004. /** @hidden */
  21005. export var reflectionFunction: {
  21006. name: string;
  21007. shader: string;
  21008. };
  21009. }
  21010. declare module BABYLON {
  21011. /**
  21012. * Base block used to read a reflection texture from a sampler
  21013. */
  21014. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21015. /** @hidden */
  21016. _define3DName: string;
  21017. /** @hidden */
  21018. _defineCubicName: string;
  21019. /** @hidden */
  21020. _defineExplicitName: string;
  21021. /** @hidden */
  21022. _defineProjectionName: string;
  21023. /** @hidden */
  21024. _defineLocalCubicName: string;
  21025. /** @hidden */
  21026. _defineSphericalName: string;
  21027. /** @hidden */
  21028. _definePlanarName: string;
  21029. /** @hidden */
  21030. _defineEquirectangularName: string;
  21031. /** @hidden */
  21032. _defineMirroredEquirectangularFixedName: string;
  21033. /** @hidden */
  21034. _defineEquirectangularFixedName: string;
  21035. /** @hidden */
  21036. _defineSkyboxName: string;
  21037. /** @hidden */
  21038. _defineOppositeZ: string;
  21039. /** @hidden */
  21040. _cubeSamplerName: string;
  21041. /** @hidden */
  21042. _2DSamplerName: string;
  21043. protected _positionUVWName: string;
  21044. protected _directionWName: string;
  21045. protected _reflectionVectorName: string;
  21046. /** @hidden */
  21047. _reflectionCoordsName: string;
  21048. /** @hidden */
  21049. _reflectionMatrixName: string;
  21050. protected _reflectionColorName: string;
  21051. /**
  21052. * Gets or sets the texture associated with the node
  21053. */
  21054. texture: Nullable<BaseTexture>;
  21055. /**
  21056. * Create a new ReflectionTextureBaseBlock
  21057. * @param name defines the block name
  21058. */
  21059. constructor(name: string);
  21060. /**
  21061. * Gets the current class name
  21062. * @returns the class name
  21063. */
  21064. getClassName(): string;
  21065. /**
  21066. * Gets the world position input component
  21067. */
  21068. abstract get position(): NodeMaterialConnectionPoint;
  21069. /**
  21070. * Gets the world position input component
  21071. */
  21072. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21073. /**
  21074. * Gets the world normal input component
  21075. */
  21076. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21077. /**
  21078. * Gets the world input component
  21079. */
  21080. abstract get world(): NodeMaterialConnectionPoint;
  21081. /**
  21082. * Gets the camera (or eye) position component
  21083. */
  21084. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21085. /**
  21086. * Gets the view input component
  21087. */
  21088. abstract get view(): NodeMaterialConnectionPoint;
  21089. protected _getTexture(): Nullable<BaseTexture>;
  21090. autoConfigure(material: NodeMaterial): void;
  21091. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21092. isReady(): boolean;
  21093. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21094. /**
  21095. * Gets the code to inject in the vertex shader
  21096. * @param state current state of the node material building
  21097. * @returns the shader code
  21098. */
  21099. handleVertexSide(state: NodeMaterialBuildState): string;
  21100. /**
  21101. * Handles the inits for the fragment code path
  21102. * @param state node material build state
  21103. */
  21104. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21105. /**
  21106. * Generates the reflection coords code for the fragment code path
  21107. * @param worldNormalVarName name of the world normal variable
  21108. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21109. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21110. * @returns the shader code
  21111. */
  21112. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21113. /**
  21114. * Generates the reflection color code for the fragment code path
  21115. * @param lodVarName name of the lod variable
  21116. * @param swizzleLookupTexture swizzle to use for the final color variable
  21117. * @returns the shader code
  21118. */
  21119. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21120. /**
  21121. * Generates the code corresponding to the connected output points
  21122. * @param state node material build state
  21123. * @param varName name of the variable to output
  21124. * @returns the shader code
  21125. */
  21126. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21127. protected _buildBlock(state: NodeMaterialBuildState): this;
  21128. protected _dumpPropertiesCode(): string;
  21129. serialize(): any;
  21130. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21131. }
  21132. }
  21133. declare module BABYLON {
  21134. /**
  21135. * Defines a connection point to be used for points with a custom object type
  21136. */
  21137. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21138. private _blockType;
  21139. private _blockName;
  21140. private _nameForCheking?;
  21141. /**
  21142. * Creates a new connection point
  21143. * @param name defines the connection point name
  21144. * @param ownerBlock defines the block hosting this connection point
  21145. * @param direction defines the direction of the connection point
  21146. */
  21147. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21148. /**
  21149. * Gets a number indicating if the current point can be connected to another point
  21150. * @param connectionPoint defines the other connection point
  21151. * @returns a number defining the compatibility state
  21152. */
  21153. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21154. /**
  21155. * Creates a block suitable to be used as an input for this input point.
  21156. * If null is returned, a block based on the point type will be created.
  21157. * @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
  21158. */
  21159. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21160. }
  21161. }
  21162. declare module BABYLON {
  21163. /**
  21164. * Enum defining the type of properties that can be edited in the property pages in the NME
  21165. */
  21166. export enum PropertyTypeForEdition {
  21167. /** property is a boolean */
  21168. Boolean = 0,
  21169. /** property is a float */
  21170. Float = 1,
  21171. /** property is a Vector2 */
  21172. Vector2 = 2,
  21173. /** property is a list of values */
  21174. List = 3
  21175. }
  21176. /**
  21177. * Interface that defines an option in a variable of type list
  21178. */
  21179. export interface IEditablePropertyListOption {
  21180. /** label of the option */
  21181. "label": string;
  21182. /** value of the option */
  21183. "value": number;
  21184. }
  21185. /**
  21186. * Interface that defines the options available for an editable property
  21187. */
  21188. export interface IEditablePropertyOption {
  21189. /** min value */
  21190. "min"?: number;
  21191. /** max value */
  21192. "max"?: number;
  21193. /** notifiers: indicates which actions to take when the property is changed */
  21194. "notifiers"?: {
  21195. /** the material should be rebuilt */
  21196. "rebuild"?: boolean;
  21197. /** the preview should be updated */
  21198. "update"?: boolean;
  21199. };
  21200. /** list of the options for a variable of type list */
  21201. "options"?: IEditablePropertyListOption[];
  21202. }
  21203. /**
  21204. * Interface that describes an editable property
  21205. */
  21206. export interface IPropertyDescriptionForEdition {
  21207. /** name of the property */
  21208. "propertyName": string;
  21209. /** display name of the property */
  21210. "displayName": string;
  21211. /** type of the property */
  21212. "type": PropertyTypeForEdition;
  21213. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21214. "groupName": string;
  21215. /** options for the property */
  21216. "options": IEditablePropertyOption;
  21217. }
  21218. /**
  21219. * Decorator that flags a property in a node material block as being editable
  21220. */
  21221. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21222. }
  21223. declare module BABYLON {
  21224. /**
  21225. * Block used to implement the refraction part of the sub surface module of the PBR material
  21226. */
  21227. export class RefractionBlock extends NodeMaterialBlock {
  21228. /** @hidden */
  21229. _define3DName: string;
  21230. /** @hidden */
  21231. _refractionMatrixName: string;
  21232. /** @hidden */
  21233. _defineLODRefractionAlpha: string;
  21234. /** @hidden */
  21235. _defineLinearSpecularRefraction: string;
  21236. /** @hidden */
  21237. _defineOppositeZ: string;
  21238. /** @hidden */
  21239. _cubeSamplerName: string;
  21240. /** @hidden */
  21241. _2DSamplerName: string;
  21242. /** @hidden */
  21243. _vRefractionMicrosurfaceInfosName: string;
  21244. /** @hidden */
  21245. _vRefractionInfosName: string;
  21246. private _scene;
  21247. /**
  21248. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21249. * Materials half opaque for instance using refraction could benefit from this control.
  21250. */
  21251. linkRefractionWithTransparency: boolean;
  21252. /**
  21253. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21254. */
  21255. invertRefractionY: boolean;
  21256. /**
  21257. * Gets or sets the texture associated with the node
  21258. */
  21259. texture: Nullable<BaseTexture>;
  21260. /**
  21261. * Create a new RefractionBlock
  21262. * @param name defines the block name
  21263. */
  21264. constructor(name: string);
  21265. /**
  21266. * Gets the current class name
  21267. * @returns the class name
  21268. */
  21269. getClassName(): string;
  21270. /**
  21271. * Gets the intensity input component
  21272. */
  21273. get intensity(): NodeMaterialConnectionPoint;
  21274. /**
  21275. * Gets the index of refraction input component
  21276. */
  21277. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21278. /**
  21279. * Gets the tint at distance input component
  21280. */
  21281. get tintAtDistance(): NodeMaterialConnectionPoint;
  21282. /**
  21283. * Gets the view input component
  21284. */
  21285. get view(): NodeMaterialConnectionPoint;
  21286. /**
  21287. * Gets the refraction object output component
  21288. */
  21289. get refraction(): NodeMaterialConnectionPoint;
  21290. /**
  21291. * Returns true if the block has a texture
  21292. */
  21293. get hasTexture(): boolean;
  21294. protected _getTexture(): Nullable<BaseTexture>;
  21295. autoConfigure(material: NodeMaterial): void;
  21296. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21297. isReady(): boolean;
  21298. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21299. /**
  21300. * Gets the main code of the block (fragment side)
  21301. * @param state current state of the node material building
  21302. * @returns the shader code
  21303. */
  21304. getCode(state: NodeMaterialBuildState): string;
  21305. protected _buildBlock(state: NodeMaterialBuildState): this;
  21306. protected _dumpPropertiesCode(): string;
  21307. serialize(): any;
  21308. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21309. }
  21310. }
  21311. declare module BABYLON {
  21312. /**
  21313. * Base block used as input for post process
  21314. */
  21315. export class CurrentScreenBlock extends NodeMaterialBlock {
  21316. private _samplerName;
  21317. private _linearDefineName;
  21318. private _gammaDefineName;
  21319. private _mainUVName;
  21320. private _tempTextureRead;
  21321. /**
  21322. * Gets or sets the texture associated with the node
  21323. */
  21324. texture: Nullable<BaseTexture>;
  21325. /**
  21326. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21327. */
  21328. convertToGammaSpace: boolean;
  21329. /**
  21330. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21331. */
  21332. convertToLinearSpace: boolean;
  21333. /**
  21334. * Create a new CurrentScreenBlock
  21335. * @param name defines the block name
  21336. */
  21337. constructor(name: string);
  21338. /**
  21339. * Gets the current class name
  21340. * @returns the class name
  21341. */
  21342. getClassName(): string;
  21343. /**
  21344. * Gets the uv input component
  21345. */
  21346. get uv(): NodeMaterialConnectionPoint;
  21347. /**
  21348. * Gets the rgba output component
  21349. */
  21350. get rgba(): NodeMaterialConnectionPoint;
  21351. /**
  21352. * Gets the rgb output component
  21353. */
  21354. get rgb(): NodeMaterialConnectionPoint;
  21355. /**
  21356. * Gets the r output component
  21357. */
  21358. get r(): NodeMaterialConnectionPoint;
  21359. /**
  21360. * Gets the g output component
  21361. */
  21362. get g(): NodeMaterialConnectionPoint;
  21363. /**
  21364. * Gets the b output component
  21365. */
  21366. get b(): NodeMaterialConnectionPoint;
  21367. /**
  21368. * Gets the a output component
  21369. */
  21370. get a(): NodeMaterialConnectionPoint;
  21371. /**
  21372. * Initialize the block and prepare the context for build
  21373. * @param state defines the state that will be used for the build
  21374. */
  21375. initialize(state: NodeMaterialBuildState): void;
  21376. get target(): NodeMaterialBlockTargets;
  21377. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21378. isReady(): boolean;
  21379. private _injectVertexCode;
  21380. private _writeTextureRead;
  21381. private _writeOutput;
  21382. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21383. serialize(): any;
  21384. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21385. }
  21386. }
  21387. declare module BABYLON {
  21388. /**
  21389. * Base block used for the particle texture
  21390. */
  21391. export class ParticleTextureBlock extends NodeMaterialBlock {
  21392. private _samplerName;
  21393. private _linearDefineName;
  21394. private _gammaDefineName;
  21395. private _tempTextureRead;
  21396. /**
  21397. * Gets or sets the texture associated with the node
  21398. */
  21399. texture: Nullable<BaseTexture>;
  21400. /**
  21401. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21402. */
  21403. convertToGammaSpace: boolean;
  21404. /**
  21405. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21406. */
  21407. convertToLinearSpace: boolean;
  21408. /**
  21409. * Create a new ParticleTextureBlock
  21410. * @param name defines the block name
  21411. */
  21412. constructor(name: string);
  21413. /**
  21414. * Gets the current class name
  21415. * @returns the class name
  21416. */
  21417. getClassName(): string;
  21418. /**
  21419. * Gets the uv input component
  21420. */
  21421. get uv(): NodeMaterialConnectionPoint;
  21422. /**
  21423. * Gets the rgba output component
  21424. */
  21425. get rgba(): NodeMaterialConnectionPoint;
  21426. /**
  21427. * Gets the rgb output component
  21428. */
  21429. get rgb(): NodeMaterialConnectionPoint;
  21430. /**
  21431. * Gets the r output component
  21432. */
  21433. get r(): NodeMaterialConnectionPoint;
  21434. /**
  21435. * Gets the g output component
  21436. */
  21437. get g(): NodeMaterialConnectionPoint;
  21438. /**
  21439. * Gets the b output component
  21440. */
  21441. get b(): NodeMaterialConnectionPoint;
  21442. /**
  21443. * Gets the a output component
  21444. */
  21445. get a(): NodeMaterialConnectionPoint;
  21446. /**
  21447. * Initialize the block and prepare the context for build
  21448. * @param state defines the state that will be used for the build
  21449. */
  21450. initialize(state: NodeMaterialBuildState): void;
  21451. autoConfigure(material: NodeMaterial): void;
  21452. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21453. isReady(): boolean;
  21454. private _writeOutput;
  21455. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21456. serialize(): any;
  21457. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21458. }
  21459. }
  21460. declare module BABYLON {
  21461. /**
  21462. * Class used to store shared data between 2 NodeMaterialBuildState
  21463. */
  21464. export class NodeMaterialBuildStateSharedData {
  21465. /**
  21466. * Gets the list of emitted varyings
  21467. */
  21468. temps: string[];
  21469. /**
  21470. * Gets the list of emitted varyings
  21471. */
  21472. varyings: string[];
  21473. /**
  21474. * Gets the varying declaration string
  21475. */
  21476. varyingDeclaration: string;
  21477. /**
  21478. * Input blocks
  21479. */
  21480. inputBlocks: InputBlock[];
  21481. /**
  21482. * Input blocks
  21483. */
  21484. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21485. /**
  21486. * Bindable blocks (Blocks that need to set data to the effect)
  21487. */
  21488. bindableBlocks: NodeMaterialBlock[];
  21489. /**
  21490. * List of blocks that can provide a compilation fallback
  21491. */
  21492. blocksWithFallbacks: NodeMaterialBlock[];
  21493. /**
  21494. * List of blocks that can provide a define update
  21495. */
  21496. blocksWithDefines: NodeMaterialBlock[];
  21497. /**
  21498. * List of blocks that can provide a repeatable content
  21499. */
  21500. repeatableContentBlocks: NodeMaterialBlock[];
  21501. /**
  21502. * List of blocks that can provide a dynamic list of uniforms
  21503. */
  21504. dynamicUniformBlocks: NodeMaterialBlock[];
  21505. /**
  21506. * List of blocks that can block the isReady function for the material
  21507. */
  21508. blockingBlocks: NodeMaterialBlock[];
  21509. /**
  21510. * Gets the list of animated inputs
  21511. */
  21512. animatedInputs: InputBlock[];
  21513. /**
  21514. * Build Id used to avoid multiple recompilations
  21515. */
  21516. buildId: number;
  21517. /** List of emitted variables */
  21518. variableNames: {
  21519. [key: string]: number;
  21520. };
  21521. /** List of emitted defines */
  21522. defineNames: {
  21523. [key: string]: number;
  21524. };
  21525. /** Should emit comments? */
  21526. emitComments: boolean;
  21527. /** Emit build activity */
  21528. verbose: boolean;
  21529. /** Gets or sets the hosting scene */
  21530. scene: Scene;
  21531. /**
  21532. * Gets the compilation hints emitted at compilation time
  21533. */
  21534. hints: {
  21535. needWorldViewMatrix: boolean;
  21536. needWorldViewProjectionMatrix: boolean;
  21537. needAlphaBlending: boolean;
  21538. needAlphaTesting: boolean;
  21539. };
  21540. /**
  21541. * List of compilation checks
  21542. */
  21543. checks: {
  21544. emitVertex: boolean;
  21545. emitFragment: boolean;
  21546. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21547. };
  21548. /**
  21549. * Is vertex program allowed to be empty?
  21550. */
  21551. allowEmptyVertexProgram: boolean;
  21552. /** Creates a new shared data */
  21553. constructor();
  21554. /**
  21555. * Emits console errors and exceptions if there is a failing check
  21556. */
  21557. emitErrors(): void;
  21558. }
  21559. }
  21560. declare module BABYLON {
  21561. /**
  21562. * Class used to store node based material build state
  21563. */
  21564. export class NodeMaterialBuildState {
  21565. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21566. supportUniformBuffers: boolean;
  21567. /**
  21568. * Gets the list of emitted attributes
  21569. */
  21570. attributes: string[];
  21571. /**
  21572. * Gets the list of emitted uniforms
  21573. */
  21574. uniforms: string[];
  21575. /**
  21576. * Gets the list of emitted constants
  21577. */
  21578. constants: string[];
  21579. /**
  21580. * Gets the list of emitted samplers
  21581. */
  21582. samplers: string[];
  21583. /**
  21584. * Gets the list of emitted functions
  21585. */
  21586. functions: {
  21587. [key: string]: string;
  21588. };
  21589. /**
  21590. * Gets the list of emitted extensions
  21591. */
  21592. extensions: {
  21593. [key: string]: string;
  21594. };
  21595. /**
  21596. * Gets the target of the compilation state
  21597. */
  21598. target: NodeMaterialBlockTargets;
  21599. /**
  21600. * Gets the list of emitted counters
  21601. */
  21602. counters: {
  21603. [key: string]: number;
  21604. };
  21605. /**
  21606. * Shared data between multiple NodeMaterialBuildState instances
  21607. */
  21608. sharedData: NodeMaterialBuildStateSharedData;
  21609. /** @hidden */
  21610. _vertexState: NodeMaterialBuildState;
  21611. /** @hidden */
  21612. _attributeDeclaration: string;
  21613. /** @hidden */
  21614. _uniformDeclaration: string;
  21615. /** @hidden */
  21616. _constantDeclaration: string;
  21617. /** @hidden */
  21618. _samplerDeclaration: string;
  21619. /** @hidden */
  21620. _varyingTransfer: string;
  21621. /** @hidden */
  21622. _injectAtEnd: string;
  21623. private _repeatableContentAnchorIndex;
  21624. /** @hidden */
  21625. _builtCompilationString: string;
  21626. /**
  21627. * Gets the emitted compilation strings
  21628. */
  21629. compilationString: string;
  21630. /**
  21631. * Finalize the compilation strings
  21632. * @param state defines the current compilation state
  21633. */
  21634. finalize(state: NodeMaterialBuildState): void;
  21635. /** @hidden */
  21636. get _repeatableContentAnchor(): string;
  21637. /** @hidden */
  21638. _getFreeVariableName(prefix: string): string;
  21639. /** @hidden */
  21640. _getFreeDefineName(prefix: string): string;
  21641. /** @hidden */
  21642. _excludeVariableName(name: string): void;
  21643. /** @hidden */
  21644. _emit2DSampler(name: string): void;
  21645. /** @hidden */
  21646. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21647. /** @hidden */
  21648. _emitExtension(name: string, extension: string, define?: string): void;
  21649. /** @hidden */
  21650. _emitFunction(name: string, code: string, comments: string): void;
  21651. /** @hidden */
  21652. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21653. replaceStrings?: {
  21654. search: RegExp;
  21655. replace: string;
  21656. }[];
  21657. repeatKey?: string;
  21658. }): string;
  21659. /** @hidden */
  21660. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21661. repeatKey?: string;
  21662. removeAttributes?: boolean;
  21663. removeUniforms?: boolean;
  21664. removeVaryings?: boolean;
  21665. removeIfDef?: boolean;
  21666. replaceStrings?: {
  21667. search: RegExp;
  21668. replace: string;
  21669. }[];
  21670. }, storeKey?: string): void;
  21671. /** @hidden */
  21672. _registerTempVariable(name: string): boolean;
  21673. /** @hidden */
  21674. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21675. /** @hidden */
  21676. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21677. /** @hidden */
  21678. _emitFloat(value: number): string;
  21679. }
  21680. }
  21681. declare module BABYLON {
  21682. /**
  21683. * Helper class used to generate session unique ID
  21684. */
  21685. export class UniqueIdGenerator {
  21686. private static _UniqueIdCounter;
  21687. /**
  21688. * Gets an unique (relatively to the current scene) Id
  21689. */
  21690. static get UniqueId(): number;
  21691. }
  21692. }
  21693. declare module BABYLON {
  21694. /**
  21695. * Defines a block that can be used inside a node based material
  21696. */
  21697. export class NodeMaterialBlock {
  21698. private _buildId;
  21699. private _buildTarget;
  21700. private _target;
  21701. private _isFinalMerger;
  21702. private _isInput;
  21703. private _name;
  21704. protected _isUnique: boolean;
  21705. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21706. inputsAreExclusive: boolean;
  21707. /** @hidden */
  21708. _codeVariableName: string;
  21709. /** @hidden */
  21710. _inputs: NodeMaterialConnectionPoint[];
  21711. /** @hidden */
  21712. _outputs: NodeMaterialConnectionPoint[];
  21713. /** @hidden */
  21714. _preparationId: number;
  21715. /**
  21716. * Gets the name of the block
  21717. */
  21718. get name(): string;
  21719. /**
  21720. * Sets the name of the block. Will check if the name is valid.
  21721. */
  21722. set name(newName: string);
  21723. /**
  21724. * Gets or sets the unique id of the node
  21725. */
  21726. uniqueId: number;
  21727. /**
  21728. * Gets or sets the comments associated with this block
  21729. */
  21730. comments: string;
  21731. /**
  21732. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21733. */
  21734. get isUnique(): boolean;
  21735. /**
  21736. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21737. */
  21738. get isFinalMerger(): boolean;
  21739. /**
  21740. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21741. */
  21742. get isInput(): boolean;
  21743. /**
  21744. * Gets or sets the build Id
  21745. */
  21746. get buildId(): number;
  21747. set buildId(value: number);
  21748. /**
  21749. * Gets or sets the target of the block
  21750. */
  21751. get target(): NodeMaterialBlockTargets;
  21752. set target(value: NodeMaterialBlockTargets);
  21753. /**
  21754. * Gets the list of input points
  21755. */
  21756. get inputs(): NodeMaterialConnectionPoint[];
  21757. /** Gets the list of output points */
  21758. get outputs(): NodeMaterialConnectionPoint[];
  21759. /**
  21760. * Find an input by its name
  21761. * @param name defines the name of the input to look for
  21762. * @returns the input or null if not found
  21763. */
  21764. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21765. /**
  21766. * Find an output by its name
  21767. * @param name defines the name of the outputto look for
  21768. * @returns the output or null if not found
  21769. */
  21770. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21771. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21772. visibleInInspector: boolean;
  21773. /**
  21774. * Creates a new NodeMaterialBlock
  21775. * @param name defines the block name
  21776. * @param target defines the target of that block (Vertex by default)
  21777. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21778. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21779. */
  21780. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21781. /**
  21782. * Initialize the block and prepare the context for build
  21783. * @param state defines the state that will be used for the build
  21784. */
  21785. initialize(state: NodeMaterialBuildState): void;
  21786. /**
  21787. * Bind data to effect. Will only be called for blocks with isBindable === true
  21788. * @param effect defines the effect to bind data to
  21789. * @param nodeMaterial defines the hosting NodeMaterial
  21790. * @param mesh defines the mesh that will be rendered
  21791. * @param subMesh defines the submesh that will be rendered
  21792. */
  21793. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21794. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21795. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21796. protected _writeFloat(value: number): string;
  21797. /**
  21798. * Gets the current class name e.g. "NodeMaterialBlock"
  21799. * @returns the class name
  21800. */
  21801. getClassName(): string;
  21802. /**
  21803. * Register a new input. Must be called inside a block constructor
  21804. * @param name defines the connection point name
  21805. * @param type defines the connection point type
  21806. * @param isOptional defines a boolean indicating that this input can be omitted
  21807. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21808. * @param point an already created connection point. If not provided, create a new one
  21809. * @returns the current block
  21810. */
  21811. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21812. /**
  21813. * Register a new output. Must be called inside a block constructor
  21814. * @param name defines the connection point name
  21815. * @param type defines the connection point type
  21816. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21817. * @param point an already created connection point. If not provided, create a new one
  21818. * @returns the current block
  21819. */
  21820. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21821. /**
  21822. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21823. * @param forOutput defines an optional connection point to check compatibility with
  21824. * @returns the first available input or null
  21825. */
  21826. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21827. /**
  21828. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21829. * @param forBlock defines an optional block to check compatibility with
  21830. * @returns the first available input or null
  21831. */
  21832. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21833. /**
  21834. * Gets the sibling of the given output
  21835. * @param current defines the current output
  21836. * @returns the next output in the list or null
  21837. */
  21838. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21839. /**
  21840. * Connect current block with another block
  21841. * @param other defines the block to connect with
  21842. * @param options define the various options to help pick the right connections
  21843. * @returns the current block
  21844. */
  21845. connectTo(other: NodeMaterialBlock, options?: {
  21846. input?: string;
  21847. output?: string;
  21848. outputSwizzle?: string;
  21849. }): this | undefined;
  21850. protected _buildBlock(state: NodeMaterialBuildState): void;
  21851. /**
  21852. * Add uniforms, samplers and uniform buffers at compilation time
  21853. * @param state defines the state to update
  21854. * @param nodeMaterial defines the node material requesting the update
  21855. * @param defines defines the material defines to update
  21856. * @param uniformBuffers defines the list of uniform buffer names
  21857. */
  21858. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21859. /**
  21860. * Add potential fallbacks if shader compilation fails
  21861. * @param mesh defines the mesh to be rendered
  21862. * @param fallbacks defines the current prioritized list of fallbacks
  21863. */
  21864. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21865. /**
  21866. * Initialize defines for shader compilation
  21867. * @param mesh defines the mesh to be rendered
  21868. * @param nodeMaterial defines the node material requesting the update
  21869. * @param defines defines the material defines to update
  21870. * @param useInstances specifies that instances should be used
  21871. */
  21872. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21873. /**
  21874. * Update defines for shader compilation
  21875. * @param mesh defines the mesh to be rendered
  21876. * @param nodeMaterial defines the node material requesting the update
  21877. * @param defines defines the material defines to update
  21878. * @param useInstances specifies that instances should be used
  21879. * @param subMesh defines which submesh to render
  21880. */
  21881. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21882. /**
  21883. * Lets the block try to connect some inputs automatically
  21884. * @param material defines the hosting NodeMaterial
  21885. */
  21886. autoConfigure(material: NodeMaterial): void;
  21887. /**
  21888. * Function called when a block is declared as repeatable content generator
  21889. * @param vertexShaderState defines the current compilation state for the vertex shader
  21890. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21891. * @param mesh defines the mesh to be rendered
  21892. * @param defines defines the material defines to update
  21893. */
  21894. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21895. /**
  21896. * Checks if the block is ready
  21897. * @param mesh defines the mesh to be rendered
  21898. * @param nodeMaterial defines the node material requesting the update
  21899. * @param defines defines the material defines to update
  21900. * @param useInstances specifies that instances should be used
  21901. * @returns true if the block is ready
  21902. */
  21903. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21904. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21905. private _processBuild;
  21906. /**
  21907. * Validates the new name for the block node.
  21908. * @param newName the new name to be given to the node.
  21909. * @returns false if the name is a reserve word, else true.
  21910. */
  21911. validateBlockName(newName: string): boolean;
  21912. /**
  21913. * Compile the current node and generate the shader code
  21914. * @param state defines the current compilation state (uniforms, samplers, current string)
  21915. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21916. * @returns true if already built
  21917. */
  21918. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21919. protected _inputRename(name: string): string;
  21920. protected _outputRename(name: string): string;
  21921. protected _dumpPropertiesCode(): string;
  21922. /** @hidden */
  21923. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21924. /** @hidden */
  21925. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21926. /**
  21927. * Clone the current block to a new identical block
  21928. * @param scene defines the hosting scene
  21929. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21930. * @returns a copy of the current block
  21931. */
  21932. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21933. /**
  21934. * Serializes this block in a JSON representation
  21935. * @returns the serialized block object
  21936. */
  21937. serialize(): any;
  21938. /** @hidden */
  21939. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21940. private _deserializePortDisplayNamesAndExposedOnFrame;
  21941. /**
  21942. * Release resources
  21943. */
  21944. dispose(): void;
  21945. }
  21946. }
  21947. declare module BABYLON {
  21948. /**
  21949. * Base class of materials working in push mode in babylon JS
  21950. * @hidden
  21951. */
  21952. export class PushMaterial extends Material {
  21953. protected _activeEffect: Effect;
  21954. protected _normalMatrix: Matrix;
  21955. constructor(name: string, scene: Scene);
  21956. getEffect(): Effect;
  21957. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21958. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21959. /**
  21960. * Binds the given world matrix to the active effect
  21961. *
  21962. * @param world the matrix to bind
  21963. */
  21964. bindOnlyWorldMatrix(world: Matrix): void;
  21965. /**
  21966. * Binds the given normal matrix to the active effect
  21967. *
  21968. * @param normalMatrix the matrix to bind
  21969. */
  21970. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21971. bind(world: Matrix, mesh?: Mesh): void;
  21972. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21973. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21974. }
  21975. }
  21976. declare module BABYLON {
  21977. /**
  21978. * Root class for all node material optimizers
  21979. */
  21980. export class NodeMaterialOptimizer {
  21981. /**
  21982. * Function used to optimize a NodeMaterial graph
  21983. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21984. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21985. */
  21986. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21987. }
  21988. }
  21989. declare module BABYLON {
  21990. /**
  21991. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21992. */
  21993. export class TransformBlock extends NodeMaterialBlock {
  21994. /**
  21995. * Defines the value to use to complement W value to transform it to a Vector4
  21996. */
  21997. complementW: number;
  21998. /**
  21999. * Defines the value to use to complement z value to transform it to a Vector4
  22000. */
  22001. complementZ: number;
  22002. /**
  22003. * Creates a new TransformBlock
  22004. * @param name defines the block name
  22005. */
  22006. constructor(name: string);
  22007. /**
  22008. * Gets the current class name
  22009. * @returns the class name
  22010. */
  22011. getClassName(): string;
  22012. /**
  22013. * Gets the vector input
  22014. */
  22015. get vector(): NodeMaterialConnectionPoint;
  22016. /**
  22017. * Gets the output component
  22018. */
  22019. get output(): NodeMaterialConnectionPoint;
  22020. /**
  22021. * Gets the xyz output component
  22022. */
  22023. get xyz(): NodeMaterialConnectionPoint;
  22024. /**
  22025. * Gets the matrix transform input
  22026. */
  22027. get transform(): NodeMaterialConnectionPoint;
  22028. protected _buildBlock(state: NodeMaterialBuildState): this;
  22029. /**
  22030. * Update defines for shader compilation
  22031. * @param mesh defines the mesh to be rendered
  22032. * @param nodeMaterial defines the node material requesting the update
  22033. * @param defines defines the material defines to update
  22034. * @param useInstances specifies that instances should be used
  22035. * @param subMesh defines which submesh to render
  22036. */
  22037. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22038. serialize(): any;
  22039. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22040. protected _dumpPropertiesCode(): string;
  22041. }
  22042. }
  22043. declare module BABYLON {
  22044. /**
  22045. * Block used to output the vertex position
  22046. */
  22047. export class VertexOutputBlock extends NodeMaterialBlock {
  22048. /**
  22049. * Creates a new VertexOutputBlock
  22050. * @param name defines the block name
  22051. */
  22052. constructor(name: string);
  22053. /**
  22054. * Gets the current class name
  22055. * @returns the class name
  22056. */
  22057. getClassName(): string;
  22058. /**
  22059. * Gets the vector input component
  22060. */
  22061. get vector(): NodeMaterialConnectionPoint;
  22062. protected _buildBlock(state: NodeMaterialBuildState): this;
  22063. }
  22064. }
  22065. declare module BABYLON {
  22066. /**
  22067. * Block used to output the final color
  22068. */
  22069. export class FragmentOutputBlock extends NodeMaterialBlock {
  22070. /**
  22071. * Create a new FragmentOutputBlock
  22072. * @param name defines the block name
  22073. */
  22074. constructor(name: string);
  22075. /**
  22076. * Gets the current class name
  22077. * @returns the class name
  22078. */
  22079. getClassName(): string;
  22080. /**
  22081. * Gets the rgba input component
  22082. */
  22083. get rgba(): NodeMaterialConnectionPoint;
  22084. /**
  22085. * Gets the rgb input component
  22086. */
  22087. get rgb(): NodeMaterialConnectionPoint;
  22088. /**
  22089. * Gets the a input component
  22090. */
  22091. get a(): NodeMaterialConnectionPoint;
  22092. protected _buildBlock(state: NodeMaterialBuildState): this;
  22093. }
  22094. }
  22095. declare module BABYLON {
  22096. /**
  22097. * Block used for the particle ramp gradient section
  22098. */
  22099. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22100. /**
  22101. * Create a new ParticleRampGradientBlock
  22102. * @param name defines the block name
  22103. */
  22104. constructor(name: string);
  22105. /**
  22106. * Gets the current class name
  22107. * @returns the class name
  22108. */
  22109. getClassName(): string;
  22110. /**
  22111. * Gets the color input component
  22112. */
  22113. get color(): NodeMaterialConnectionPoint;
  22114. /**
  22115. * Gets the rampColor output component
  22116. */
  22117. get rampColor(): NodeMaterialConnectionPoint;
  22118. /**
  22119. * Initialize the block and prepare the context for build
  22120. * @param state defines the state that will be used for the build
  22121. */
  22122. initialize(state: NodeMaterialBuildState): void;
  22123. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22124. }
  22125. }
  22126. declare module BABYLON {
  22127. /**
  22128. * Block used for the particle blend multiply section
  22129. */
  22130. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22131. /**
  22132. * Create a new ParticleBlendMultiplyBlock
  22133. * @param name defines the block name
  22134. */
  22135. constructor(name: string);
  22136. /**
  22137. * Gets the current class name
  22138. * @returns the class name
  22139. */
  22140. getClassName(): string;
  22141. /**
  22142. * Gets the color input component
  22143. */
  22144. get color(): NodeMaterialConnectionPoint;
  22145. /**
  22146. * Gets the alphaTexture input component
  22147. */
  22148. get alphaTexture(): NodeMaterialConnectionPoint;
  22149. /**
  22150. * Gets the alphaColor input component
  22151. */
  22152. get alphaColor(): NodeMaterialConnectionPoint;
  22153. /**
  22154. * Gets the blendColor output component
  22155. */
  22156. get blendColor(): NodeMaterialConnectionPoint;
  22157. /**
  22158. * Initialize the block and prepare the context for build
  22159. * @param state defines the state that will be used for the build
  22160. */
  22161. initialize(state: NodeMaterialBuildState): void;
  22162. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22163. }
  22164. }
  22165. declare module BABYLON {
  22166. /**
  22167. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22168. */
  22169. export class VectorMergerBlock extends NodeMaterialBlock {
  22170. /**
  22171. * Create a new VectorMergerBlock
  22172. * @param name defines the block name
  22173. */
  22174. constructor(name: string);
  22175. /**
  22176. * Gets the current class name
  22177. * @returns the class name
  22178. */
  22179. getClassName(): string;
  22180. /**
  22181. * Gets the xyz component (input)
  22182. */
  22183. get xyzIn(): NodeMaterialConnectionPoint;
  22184. /**
  22185. * Gets the xy component (input)
  22186. */
  22187. get xyIn(): NodeMaterialConnectionPoint;
  22188. /**
  22189. * Gets the x component (input)
  22190. */
  22191. get x(): NodeMaterialConnectionPoint;
  22192. /**
  22193. * Gets the y component (input)
  22194. */
  22195. get y(): NodeMaterialConnectionPoint;
  22196. /**
  22197. * Gets the z component (input)
  22198. */
  22199. get z(): NodeMaterialConnectionPoint;
  22200. /**
  22201. * Gets the w component (input)
  22202. */
  22203. get w(): NodeMaterialConnectionPoint;
  22204. /**
  22205. * Gets the xyzw component (output)
  22206. */
  22207. get xyzw(): NodeMaterialConnectionPoint;
  22208. /**
  22209. * Gets the xyz component (output)
  22210. */
  22211. get xyzOut(): NodeMaterialConnectionPoint;
  22212. /**
  22213. * Gets the xy component (output)
  22214. */
  22215. get xyOut(): NodeMaterialConnectionPoint;
  22216. /**
  22217. * Gets the xy component (output)
  22218. * @deprecated Please use xyOut instead.
  22219. */
  22220. get xy(): NodeMaterialConnectionPoint;
  22221. /**
  22222. * Gets the xyz component (output)
  22223. * @deprecated Please use xyzOut instead.
  22224. */
  22225. get xyz(): NodeMaterialConnectionPoint;
  22226. protected _buildBlock(state: NodeMaterialBuildState): this;
  22227. }
  22228. }
  22229. declare module BABYLON {
  22230. /**
  22231. * Block used to remap a float from a range to a new one
  22232. */
  22233. export class RemapBlock extends NodeMaterialBlock {
  22234. /**
  22235. * Gets or sets the source range
  22236. */
  22237. sourceRange: Vector2;
  22238. /**
  22239. * Gets or sets the target range
  22240. */
  22241. targetRange: Vector2;
  22242. /**
  22243. * Creates a new RemapBlock
  22244. * @param name defines the block name
  22245. */
  22246. constructor(name: string);
  22247. /**
  22248. * Gets the current class name
  22249. * @returns the class name
  22250. */
  22251. getClassName(): string;
  22252. /**
  22253. * Gets the input component
  22254. */
  22255. get input(): NodeMaterialConnectionPoint;
  22256. /**
  22257. * Gets the source min input component
  22258. */
  22259. get sourceMin(): NodeMaterialConnectionPoint;
  22260. /**
  22261. * Gets the source max input component
  22262. */
  22263. get sourceMax(): NodeMaterialConnectionPoint;
  22264. /**
  22265. * Gets the target min input component
  22266. */
  22267. get targetMin(): NodeMaterialConnectionPoint;
  22268. /**
  22269. * Gets the target max input component
  22270. */
  22271. get targetMax(): NodeMaterialConnectionPoint;
  22272. /**
  22273. * Gets the output component
  22274. */
  22275. get output(): NodeMaterialConnectionPoint;
  22276. protected _buildBlock(state: NodeMaterialBuildState): this;
  22277. protected _dumpPropertiesCode(): string;
  22278. serialize(): any;
  22279. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22280. }
  22281. }
  22282. declare module BABYLON {
  22283. /**
  22284. * Block used to multiply 2 values
  22285. */
  22286. export class MultiplyBlock extends NodeMaterialBlock {
  22287. /**
  22288. * Creates a new MultiplyBlock
  22289. * @param name defines the block name
  22290. */
  22291. constructor(name: string);
  22292. /**
  22293. * Gets the current class name
  22294. * @returns the class name
  22295. */
  22296. getClassName(): string;
  22297. /**
  22298. * Gets the left operand input component
  22299. */
  22300. get left(): NodeMaterialConnectionPoint;
  22301. /**
  22302. * Gets the right operand input component
  22303. */
  22304. get right(): NodeMaterialConnectionPoint;
  22305. /**
  22306. * Gets the output component
  22307. */
  22308. get output(): NodeMaterialConnectionPoint;
  22309. protected _buildBlock(state: NodeMaterialBuildState): this;
  22310. }
  22311. }
  22312. declare module BABYLON {
  22313. /**
  22314. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22315. */
  22316. export class ColorSplitterBlock extends NodeMaterialBlock {
  22317. /**
  22318. * Create a new ColorSplitterBlock
  22319. * @param name defines the block name
  22320. */
  22321. constructor(name: string);
  22322. /**
  22323. * Gets the current class name
  22324. * @returns the class name
  22325. */
  22326. getClassName(): string;
  22327. /**
  22328. * Gets the rgba component (input)
  22329. */
  22330. get rgba(): NodeMaterialConnectionPoint;
  22331. /**
  22332. * Gets the rgb component (input)
  22333. */
  22334. get rgbIn(): NodeMaterialConnectionPoint;
  22335. /**
  22336. * Gets the rgb component (output)
  22337. */
  22338. get rgbOut(): NodeMaterialConnectionPoint;
  22339. /**
  22340. * Gets the r component (output)
  22341. */
  22342. get r(): NodeMaterialConnectionPoint;
  22343. /**
  22344. * Gets the g component (output)
  22345. */
  22346. get g(): NodeMaterialConnectionPoint;
  22347. /**
  22348. * Gets the b component (output)
  22349. */
  22350. get b(): NodeMaterialConnectionPoint;
  22351. /**
  22352. * Gets the a component (output)
  22353. */
  22354. get a(): NodeMaterialConnectionPoint;
  22355. protected _inputRename(name: string): string;
  22356. protected _outputRename(name: string): string;
  22357. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22358. }
  22359. }
  22360. declare module BABYLON {
  22361. /**
  22362. * Operations supported by the Trigonometry block
  22363. */
  22364. export enum TrigonometryBlockOperations {
  22365. /** Cos */
  22366. Cos = 0,
  22367. /** Sin */
  22368. Sin = 1,
  22369. /** Abs */
  22370. Abs = 2,
  22371. /** Exp */
  22372. Exp = 3,
  22373. /** Exp2 */
  22374. Exp2 = 4,
  22375. /** Round */
  22376. Round = 5,
  22377. /** Floor */
  22378. Floor = 6,
  22379. /** Ceiling */
  22380. Ceiling = 7,
  22381. /** Square root */
  22382. Sqrt = 8,
  22383. /** Log */
  22384. Log = 9,
  22385. /** Tangent */
  22386. Tan = 10,
  22387. /** Arc tangent */
  22388. ArcTan = 11,
  22389. /** Arc cosinus */
  22390. ArcCos = 12,
  22391. /** Arc sinus */
  22392. ArcSin = 13,
  22393. /** Fraction */
  22394. Fract = 14,
  22395. /** Sign */
  22396. Sign = 15,
  22397. /** To radians (from degrees) */
  22398. Radians = 16,
  22399. /** To degrees (from radians) */
  22400. Degrees = 17
  22401. }
  22402. /**
  22403. * Block used to apply trigonometry operation to floats
  22404. */
  22405. export class TrigonometryBlock extends NodeMaterialBlock {
  22406. /**
  22407. * Gets or sets the operation applied by the block
  22408. */
  22409. operation: TrigonometryBlockOperations;
  22410. /**
  22411. * Creates a new TrigonometryBlock
  22412. * @param name defines the block name
  22413. */
  22414. constructor(name: string);
  22415. /**
  22416. * Gets the current class name
  22417. * @returns the class name
  22418. */
  22419. getClassName(): string;
  22420. /**
  22421. * Gets the input component
  22422. */
  22423. get input(): NodeMaterialConnectionPoint;
  22424. /**
  22425. * Gets the output component
  22426. */
  22427. get output(): NodeMaterialConnectionPoint;
  22428. protected _buildBlock(state: NodeMaterialBuildState): this;
  22429. serialize(): any;
  22430. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22431. protected _dumpPropertiesCode(): string;
  22432. }
  22433. }
  22434. declare module BABYLON {
  22435. /**
  22436. * Interface used to configure the node material editor
  22437. */
  22438. export interface INodeMaterialEditorOptions {
  22439. /** Define the URl to load node editor script */
  22440. editorURL?: string;
  22441. }
  22442. /** @hidden */
  22443. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22444. NORMAL: boolean;
  22445. TANGENT: boolean;
  22446. UV1: boolean;
  22447. /** BONES */
  22448. NUM_BONE_INFLUENCERS: number;
  22449. BonesPerMesh: number;
  22450. BONETEXTURE: boolean;
  22451. /** MORPH TARGETS */
  22452. MORPHTARGETS: boolean;
  22453. MORPHTARGETS_NORMAL: boolean;
  22454. MORPHTARGETS_TANGENT: boolean;
  22455. MORPHTARGETS_UV: boolean;
  22456. NUM_MORPH_INFLUENCERS: number;
  22457. /** IMAGE PROCESSING */
  22458. IMAGEPROCESSING: boolean;
  22459. VIGNETTE: boolean;
  22460. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22461. VIGNETTEBLENDMODEOPAQUE: boolean;
  22462. TONEMAPPING: boolean;
  22463. TONEMAPPING_ACES: boolean;
  22464. CONTRAST: boolean;
  22465. EXPOSURE: boolean;
  22466. COLORCURVES: boolean;
  22467. COLORGRADING: boolean;
  22468. COLORGRADING3D: boolean;
  22469. SAMPLER3DGREENDEPTH: boolean;
  22470. SAMPLER3DBGRMAP: boolean;
  22471. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22472. /** MISC. */
  22473. BUMPDIRECTUV: number;
  22474. constructor();
  22475. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22476. }
  22477. /**
  22478. * Class used to configure NodeMaterial
  22479. */
  22480. export interface INodeMaterialOptions {
  22481. /**
  22482. * Defines if blocks should emit comments
  22483. */
  22484. emitComments: boolean;
  22485. }
  22486. /**
  22487. * Class used to create a node based material built by assembling shader blocks
  22488. */
  22489. export class NodeMaterial extends PushMaterial {
  22490. private static _BuildIdGenerator;
  22491. private _options;
  22492. private _vertexCompilationState;
  22493. private _fragmentCompilationState;
  22494. private _sharedData;
  22495. private _buildId;
  22496. private _buildWasSuccessful;
  22497. private _cachedWorldViewMatrix;
  22498. private _cachedWorldViewProjectionMatrix;
  22499. private _optimizers;
  22500. private _animationFrame;
  22501. /** Define the Url to load node editor script */
  22502. static EditorURL: string;
  22503. /** Define the Url to load snippets */
  22504. static SnippetUrl: string;
  22505. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22506. static IgnoreTexturesAtLoadTime: boolean;
  22507. private BJSNODEMATERIALEDITOR;
  22508. /** Get the inspector from bundle or global */
  22509. private _getGlobalNodeMaterialEditor;
  22510. /**
  22511. * Snippet ID if the material was created from the snippet server
  22512. */
  22513. snippetId: string;
  22514. /**
  22515. * Gets or sets data used by visual editor
  22516. * @see https://nme.babylonjs.com
  22517. */
  22518. editorData: any;
  22519. /**
  22520. * 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)
  22521. */
  22522. ignoreAlpha: boolean;
  22523. /**
  22524. * Defines the maximum number of lights that can be used in the material
  22525. */
  22526. maxSimultaneousLights: number;
  22527. /**
  22528. * Observable raised when the material is built
  22529. */
  22530. onBuildObservable: Observable<NodeMaterial>;
  22531. /**
  22532. * Gets or sets the root nodes of the material vertex shader
  22533. */
  22534. _vertexOutputNodes: NodeMaterialBlock[];
  22535. /**
  22536. * Gets or sets the root nodes of the material fragment (pixel) shader
  22537. */
  22538. _fragmentOutputNodes: NodeMaterialBlock[];
  22539. /** Gets or sets options to control the node material overall behavior */
  22540. get options(): INodeMaterialOptions;
  22541. set options(options: INodeMaterialOptions);
  22542. /**
  22543. * Default configuration related to image processing available in the standard Material.
  22544. */
  22545. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22546. /**
  22547. * Gets the image processing configuration used either in this material.
  22548. */
  22549. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22550. /**
  22551. * Sets the Default image processing configuration used either in the this material.
  22552. *
  22553. * If sets to null, the scene one is in use.
  22554. */
  22555. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22556. /**
  22557. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22558. */
  22559. attachedBlocks: NodeMaterialBlock[];
  22560. /**
  22561. * Specifies the mode of the node material
  22562. * @hidden
  22563. */
  22564. _mode: NodeMaterialModes;
  22565. /**
  22566. * Gets the mode property
  22567. */
  22568. get mode(): NodeMaterialModes;
  22569. /**
  22570. * Create a new node based material
  22571. * @param name defines the material name
  22572. * @param scene defines the hosting scene
  22573. * @param options defines creation option
  22574. */
  22575. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22576. /**
  22577. * Gets the current class name of the material e.g. "NodeMaterial"
  22578. * @returns the class name
  22579. */
  22580. getClassName(): string;
  22581. /**
  22582. * Keep track of the image processing observer to allow dispose and replace.
  22583. */
  22584. private _imageProcessingObserver;
  22585. /**
  22586. * Attaches a new image processing configuration to the Standard Material.
  22587. * @param configuration
  22588. */
  22589. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22590. /**
  22591. * Get a block by its name
  22592. * @param name defines the name of the block to retrieve
  22593. * @returns the required block or null if not found
  22594. */
  22595. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22596. /**
  22597. * Get a block by its name
  22598. * @param predicate defines the predicate used to find the good candidate
  22599. * @returns the required block or null if not found
  22600. */
  22601. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22602. /**
  22603. * Get an input block by its name
  22604. * @param predicate defines the predicate used to find the good candidate
  22605. * @returns the required input block or null if not found
  22606. */
  22607. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22608. /**
  22609. * Gets the list of input blocks attached to this material
  22610. * @returns an array of InputBlocks
  22611. */
  22612. getInputBlocks(): InputBlock[];
  22613. /**
  22614. * Adds a new optimizer to the list of optimizers
  22615. * @param optimizer defines the optimizers to add
  22616. * @returns the current material
  22617. */
  22618. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22619. /**
  22620. * Remove an optimizer from the list of optimizers
  22621. * @param optimizer defines the optimizers to remove
  22622. * @returns the current material
  22623. */
  22624. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22625. /**
  22626. * Add a new block to the list of output nodes
  22627. * @param node defines the node to add
  22628. * @returns the current material
  22629. */
  22630. addOutputNode(node: NodeMaterialBlock): this;
  22631. /**
  22632. * Remove a block from the list of root nodes
  22633. * @param node defines the node to remove
  22634. * @returns the current material
  22635. */
  22636. removeOutputNode(node: NodeMaterialBlock): this;
  22637. private _addVertexOutputNode;
  22638. private _removeVertexOutputNode;
  22639. private _addFragmentOutputNode;
  22640. private _removeFragmentOutputNode;
  22641. /**
  22642. * Specifies if the material will require alpha blending
  22643. * @returns a boolean specifying if alpha blending is needed
  22644. */
  22645. needAlphaBlending(): boolean;
  22646. /**
  22647. * Specifies if this material should be rendered in alpha test mode
  22648. * @returns a boolean specifying if an alpha test is needed.
  22649. */
  22650. needAlphaTesting(): boolean;
  22651. private _initializeBlock;
  22652. private _resetDualBlocks;
  22653. /**
  22654. * Remove a block from the current node material
  22655. * @param block defines the block to remove
  22656. */
  22657. removeBlock(block: NodeMaterialBlock): void;
  22658. /**
  22659. * Build the material and generates the inner effect
  22660. * @param verbose defines if the build should log activity
  22661. */
  22662. build(verbose?: boolean): void;
  22663. /**
  22664. * Runs an otpimization phase to try to improve the shader code
  22665. */
  22666. optimize(): void;
  22667. private _prepareDefinesForAttributes;
  22668. /**
  22669. * Create a post process from the material
  22670. * @param camera The camera to apply the render pass to.
  22671. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22673. * @param engine The engine which the post process will be applied. (default: current engine)
  22674. * @param reusable If the post process can be reused on the same frame. (default: false)
  22675. * @param textureType Type of textures used when performing the post process. (default: 0)
  22676. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22677. * @returns the post process created
  22678. */
  22679. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22680. /**
  22681. * Create the post process effect from the material
  22682. * @param postProcess The post process to create the effect for
  22683. */
  22684. createEffectForPostProcess(postProcess: PostProcess): void;
  22685. private _createEffectForPostProcess;
  22686. /**
  22687. * Create a new procedural texture based on this node material
  22688. * @param size defines the size of the texture
  22689. * @param scene defines the hosting scene
  22690. * @returns the new procedural texture attached to this node material
  22691. */
  22692. createProceduralTexture(size: number | {
  22693. width: number;
  22694. height: number;
  22695. layers?: number;
  22696. }, scene: Scene): Nullable<ProceduralTexture>;
  22697. private _createEffectForParticles;
  22698. private _checkInternals;
  22699. /**
  22700. * Create the effect to be used as the custom effect for a particle system
  22701. * @param particleSystem Particle system to create the effect for
  22702. * @param onCompiled defines a function to call when the effect creation is successful
  22703. * @param onError defines a function to call when the effect creation has failed
  22704. */
  22705. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22706. private _processDefines;
  22707. /**
  22708. * Get if the submesh is ready to be used and all its information available.
  22709. * Child classes can use it to update shaders
  22710. * @param mesh defines the mesh to check
  22711. * @param subMesh defines which submesh to check
  22712. * @param useInstances specifies that instances should be used
  22713. * @returns a boolean indicating that the submesh is ready or not
  22714. */
  22715. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22716. /**
  22717. * Get a string representing the shaders built by the current node graph
  22718. */
  22719. get compiledShaders(): string;
  22720. /**
  22721. * Binds the world matrix to the material
  22722. * @param world defines the world transformation matrix
  22723. */
  22724. bindOnlyWorldMatrix(world: Matrix): void;
  22725. /**
  22726. * Binds the submesh to this material by preparing the effect and shader to draw
  22727. * @param world defines the world transformation matrix
  22728. * @param mesh defines the mesh containing the submesh
  22729. * @param subMesh defines the submesh to bind the material to
  22730. */
  22731. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22732. /**
  22733. * Gets the active textures from the material
  22734. * @returns an array of textures
  22735. */
  22736. getActiveTextures(): BaseTexture[];
  22737. /**
  22738. * Gets the list of texture blocks
  22739. * @returns an array of texture blocks
  22740. */
  22741. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22742. /**
  22743. * Specifies if the material uses a texture
  22744. * @param texture defines the texture to check against the material
  22745. * @returns a boolean specifying if the material uses the texture
  22746. */
  22747. hasTexture(texture: BaseTexture): boolean;
  22748. /**
  22749. * Disposes the material
  22750. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22751. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22752. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22753. */
  22754. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22755. /** Creates the node editor window. */
  22756. private _createNodeEditor;
  22757. /**
  22758. * Launch the node material editor
  22759. * @param config Define the configuration of the editor
  22760. * @return a promise fulfilled when the node editor is visible
  22761. */
  22762. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22763. /**
  22764. * Clear the current material
  22765. */
  22766. clear(): void;
  22767. /**
  22768. * Clear the current material and set it to a default state
  22769. */
  22770. setToDefault(): void;
  22771. /**
  22772. * Clear the current material and set it to a default state for post process
  22773. */
  22774. setToDefaultPostProcess(): void;
  22775. /**
  22776. * Clear the current material and set it to a default state for procedural texture
  22777. */
  22778. setToDefaultProceduralTexture(): void;
  22779. /**
  22780. * Clear the current material and set it to a default state for particle
  22781. */
  22782. setToDefaultParticle(): void;
  22783. /**
  22784. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22785. * @param url defines the url to load from
  22786. * @returns a promise that will fullfil when the material is fully loaded
  22787. */
  22788. loadAsync(url: string): Promise<void>;
  22789. private _gatherBlocks;
  22790. /**
  22791. * Generate a string containing the code declaration required to create an equivalent of this material
  22792. * @returns a string
  22793. */
  22794. generateCode(): string;
  22795. /**
  22796. * Serializes this material in a JSON representation
  22797. * @returns the serialized material object
  22798. */
  22799. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22800. private _restoreConnections;
  22801. /**
  22802. * Clear the current graph and load a new one from a serialization object
  22803. * @param source defines the JSON representation of the material
  22804. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22805. * @param merge defines whether or not the source must be merged or replace the current content
  22806. */
  22807. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22808. /**
  22809. * Makes a duplicate of the current material.
  22810. * @param name - name to use for the new material.
  22811. */
  22812. clone(name: string): NodeMaterial;
  22813. /**
  22814. * Creates a node material from parsed material data
  22815. * @param source defines the JSON representation of the material
  22816. * @param scene defines the hosting scene
  22817. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22818. * @returns a new node material
  22819. */
  22820. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22821. /**
  22822. * Creates a node material from a snippet saved in a remote file
  22823. * @param name defines the name of the material to create
  22824. * @param url defines the url to load from
  22825. * @param scene defines the hosting scene
  22826. * @returns a promise that will resolve to the new node material
  22827. */
  22828. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22829. /**
  22830. * Creates a node material from a snippet saved by the node material editor
  22831. * @param snippetId defines the snippet to load
  22832. * @param scene defines the hosting scene
  22833. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22834. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22835. * @returns a promise that will resolve to the new node material
  22836. */
  22837. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22838. /**
  22839. * Creates a new node material set to default basic configuration
  22840. * @param name defines the name of the material
  22841. * @param scene defines the hosting scene
  22842. * @returns a new NodeMaterial
  22843. */
  22844. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22845. }
  22846. }
  22847. declare module BABYLON {
  22848. interface ThinEngine {
  22849. /**
  22850. * Unbind a list of render target textures from the webGL context
  22851. * This is used only when drawBuffer extension or webGL2 are active
  22852. * @param textures defines the render target textures to unbind
  22853. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  22854. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  22855. */
  22856. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  22857. /**
  22858. * Create a multi render target texture
  22859. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  22860. * @param size defines the size of the texture
  22861. * @param options defines the creation options
  22862. * @returns the cube texture as an InternalTexture
  22863. */
  22864. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  22865. /**
  22866. * Update the sample count for a given multiple render target texture
  22867. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  22868. * @param textures defines the textures to update
  22869. * @param samples defines the sample count to set
  22870. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  22871. */
  22872. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  22873. /**
  22874. * Select a subsets of attachments to draw to.
  22875. * @param attachments gl attachments
  22876. */
  22877. bindAttachments(attachments: number[]): void;
  22878. /**
  22879. * Creates a layout object to draw/clear on specific textures in a MRT
  22880. * @param textureStatus textureStatus[i] indicates if the i-th is active
  22881. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  22882. */
  22883. buildTextureLayout(textureStatus: boolean[]): number[];
  22884. /**
  22885. * Restores the webgl state to only draw on the main color attachment
  22886. */
  22887. restoreSingleAttachment(): void;
  22888. }
  22889. }
  22890. declare module BABYLON {
  22891. /**
  22892. * Creation options of the multi render target texture.
  22893. */
  22894. export interface IMultiRenderTargetOptions {
  22895. /**
  22896. * Define if the texture needs to create mip maps after render.
  22897. */
  22898. generateMipMaps?: boolean;
  22899. /**
  22900. * Define the types of all the draw buffers we want to create
  22901. */
  22902. types?: number[];
  22903. /**
  22904. * Define the sampling modes of all the draw buffers we want to create
  22905. */
  22906. samplingModes?: number[];
  22907. /**
  22908. * Define if a depth buffer is required
  22909. */
  22910. generateDepthBuffer?: boolean;
  22911. /**
  22912. * Define if a stencil buffer is required
  22913. */
  22914. generateStencilBuffer?: boolean;
  22915. /**
  22916. * Define if a depth texture is required instead of a depth buffer
  22917. */
  22918. generateDepthTexture?: boolean;
  22919. /**
  22920. * Define the number of desired draw buffers
  22921. */
  22922. textureCount?: number;
  22923. /**
  22924. * Define if aspect ratio should be adapted to the texture or stay the scene one
  22925. */
  22926. doNotChangeAspectRatio?: boolean;
  22927. /**
  22928. * Define the default type of the buffers we are creating
  22929. */
  22930. defaultType?: number;
  22931. }
  22932. /**
  22933. * A multi render target, like a render target provides the ability to render to a texture.
  22934. * Unlike the render target, it can render to several draw buffers in one draw.
  22935. * This is specially interesting in deferred rendering or for any effects requiring more than
  22936. * just one color from a single pass.
  22937. */
  22938. export class MultiRenderTarget extends RenderTargetTexture {
  22939. private _internalTextures;
  22940. private _textures;
  22941. private _multiRenderTargetOptions;
  22942. private _count;
  22943. /**
  22944. * Get if draw buffers are currently supported by the used hardware and browser.
  22945. */
  22946. get isSupported(): boolean;
  22947. /**
  22948. * Get the list of textures generated by the multi render target.
  22949. */
  22950. get textures(): Texture[];
  22951. /**
  22952. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  22953. */
  22954. get count(): number;
  22955. /**
  22956. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  22957. */
  22958. get depthTexture(): Texture;
  22959. /**
  22960. * Set the wrapping mode on U of all the textures we are rendering to.
  22961. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22962. */
  22963. set wrapU(wrap: number);
  22964. /**
  22965. * Set the wrapping mode on V of all the textures we are rendering to.
  22966. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22967. */
  22968. set wrapV(wrap: number);
  22969. /**
  22970. * Instantiate a new multi render target texture.
  22971. * A multi render target, like a render target provides the ability to render to a texture.
  22972. * Unlike the render target, it can render to several draw buffers in one draw.
  22973. * This is specially interesting in deferred rendering or for any effects requiring more than
  22974. * just one color from a single pass.
  22975. * @param name Define the name of the texture
  22976. * @param size Define the size of the buffers to render to
  22977. * @param count Define the number of target we are rendering into
  22978. * @param scene Define the scene the texture belongs to
  22979. * @param options Define the options used to create the multi render target
  22980. */
  22981. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  22982. private _initTypes;
  22983. /** @hidden */
  22984. _rebuild(forceFullRebuild?: boolean): void;
  22985. private _createInternalTextures;
  22986. private _createTextures;
  22987. /**
  22988. * Replaces a texture within the MRT.
  22989. * @param texture The new texture to insert in the MRT
  22990. * @param index The index of the texture to replace
  22991. */
  22992. replaceTexture(texture: Texture, index: number): void;
  22993. /**
  22994. * Define the number of samples used if MSAA is enabled.
  22995. */
  22996. get samples(): number;
  22997. set samples(value: number);
  22998. /**
  22999. * Resize all the textures in the multi render target.
  23000. * Be careful as it will recreate all the data in the new texture.
  23001. * @param size Define the new size
  23002. */
  23003. resize(size: any): void;
  23004. /**
  23005. * Changes the number of render targets in this MRT
  23006. * Be careful as it will recreate all the data in the new texture.
  23007. * @param count new texture count
  23008. * @param options Specifies texture types and sampling modes for new textures
  23009. */
  23010. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23011. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23012. /**
  23013. * Dispose the render targets and their associated resources
  23014. */
  23015. dispose(): void;
  23016. /**
  23017. * Release all the underlying texture used as draw buffers.
  23018. */
  23019. releaseInternalTextures(): void;
  23020. }
  23021. }
  23022. declare module BABYLON {
  23023. /** @hidden */
  23024. export var imageProcessingPixelShader: {
  23025. name: string;
  23026. shader: string;
  23027. };
  23028. }
  23029. declare module BABYLON {
  23030. /**
  23031. * ImageProcessingPostProcess
  23032. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23033. */
  23034. export class ImageProcessingPostProcess extends PostProcess {
  23035. /**
  23036. * Default configuration related to image processing available in the PBR Material.
  23037. */
  23038. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23039. /**
  23040. * Gets the image processing configuration used either in this material.
  23041. */
  23042. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23043. /**
  23044. * Sets the Default image processing configuration used either in the this material.
  23045. *
  23046. * If sets to null, the scene one is in use.
  23047. */
  23048. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23049. /**
  23050. * Keep track of the image processing observer to allow dispose and replace.
  23051. */
  23052. private _imageProcessingObserver;
  23053. /**
  23054. * Attaches a new image processing configuration to the PBR Material.
  23055. * @param configuration
  23056. */
  23057. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23058. /**
  23059. * If the post process is supported.
  23060. */
  23061. get isSupported(): boolean;
  23062. /**
  23063. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23064. */
  23065. get colorCurves(): Nullable<ColorCurves>;
  23066. /**
  23067. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23068. */
  23069. set colorCurves(value: Nullable<ColorCurves>);
  23070. /**
  23071. * Gets wether the color curves effect is enabled.
  23072. */
  23073. get colorCurvesEnabled(): boolean;
  23074. /**
  23075. * Sets wether the color curves effect is enabled.
  23076. */
  23077. set colorCurvesEnabled(value: boolean);
  23078. /**
  23079. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23080. */
  23081. get colorGradingTexture(): Nullable<BaseTexture>;
  23082. /**
  23083. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23084. */
  23085. set colorGradingTexture(value: Nullable<BaseTexture>);
  23086. /**
  23087. * Gets wether the color grading effect is enabled.
  23088. */
  23089. get colorGradingEnabled(): boolean;
  23090. /**
  23091. * Gets wether the color grading effect is enabled.
  23092. */
  23093. set colorGradingEnabled(value: boolean);
  23094. /**
  23095. * Gets exposure used in the effect.
  23096. */
  23097. get exposure(): number;
  23098. /**
  23099. * Sets exposure used in the effect.
  23100. */
  23101. set exposure(value: number);
  23102. /**
  23103. * Gets wether tonemapping is enabled or not.
  23104. */
  23105. get toneMappingEnabled(): boolean;
  23106. /**
  23107. * Sets wether tonemapping is enabled or not
  23108. */
  23109. set toneMappingEnabled(value: boolean);
  23110. /**
  23111. * Gets the type of tone mapping effect.
  23112. */
  23113. get toneMappingType(): number;
  23114. /**
  23115. * Sets the type of tone mapping effect.
  23116. */
  23117. set toneMappingType(value: number);
  23118. /**
  23119. * Gets contrast used in the effect.
  23120. */
  23121. get contrast(): number;
  23122. /**
  23123. * Sets contrast used in the effect.
  23124. */
  23125. set contrast(value: number);
  23126. /**
  23127. * Gets Vignette stretch size.
  23128. */
  23129. get vignetteStretch(): number;
  23130. /**
  23131. * Sets Vignette stretch size.
  23132. */
  23133. set vignetteStretch(value: number);
  23134. /**
  23135. * Gets Vignette centre X Offset.
  23136. */
  23137. get vignetteCentreX(): number;
  23138. /**
  23139. * Sets Vignette centre X Offset.
  23140. */
  23141. set vignetteCentreX(value: number);
  23142. /**
  23143. * Gets Vignette centre Y Offset.
  23144. */
  23145. get vignetteCentreY(): number;
  23146. /**
  23147. * Sets Vignette centre Y Offset.
  23148. */
  23149. set vignetteCentreY(value: number);
  23150. /**
  23151. * Gets Vignette weight or intensity of the vignette effect.
  23152. */
  23153. get vignetteWeight(): number;
  23154. /**
  23155. * Sets Vignette weight or intensity of the vignette effect.
  23156. */
  23157. set vignetteWeight(value: number);
  23158. /**
  23159. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23160. * if vignetteEnabled is set to true.
  23161. */
  23162. get vignetteColor(): Color4;
  23163. /**
  23164. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23165. * if vignetteEnabled is set to true.
  23166. */
  23167. set vignetteColor(value: Color4);
  23168. /**
  23169. * Gets Camera field of view used by the Vignette effect.
  23170. */
  23171. get vignetteCameraFov(): number;
  23172. /**
  23173. * Sets Camera field of view used by the Vignette effect.
  23174. */
  23175. set vignetteCameraFov(value: number);
  23176. /**
  23177. * Gets the vignette blend mode allowing different kind of effect.
  23178. */
  23179. get vignetteBlendMode(): number;
  23180. /**
  23181. * Sets the vignette blend mode allowing different kind of effect.
  23182. */
  23183. set vignetteBlendMode(value: number);
  23184. /**
  23185. * Gets wether the vignette effect is enabled.
  23186. */
  23187. get vignetteEnabled(): boolean;
  23188. /**
  23189. * Sets wether the vignette effect is enabled.
  23190. */
  23191. set vignetteEnabled(value: boolean);
  23192. private _fromLinearSpace;
  23193. /**
  23194. * Gets wether the input of the processing is in Gamma or Linear Space.
  23195. */
  23196. get fromLinearSpace(): boolean;
  23197. /**
  23198. * Sets wether the input of the processing is in Gamma or Linear Space.
  23199. */
  23200. set fromLinearSpace(value: boolean);
  23201. /**
  23202. * Defines cache preventing GC.
  23203. */
  23204. private _defines;
  23205. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23206. /**
  23207. * "ImageProcessingPostProcess"
  23208. * @returns "ImageProcessingPostProcess"
  23209. */
  23210. getClassName(): string;
  23211. /**
  23212. * @hidden
  23213. */
  23214. _updateParameters(): void;
  23215. dispose(camera?: Camera): void;
  23216. }
  23217. }
  23218. declare module BABYLON {
  23219. /**
  23220. * Interface for defining prepass effects in the prepass post-process pipeline
  23221. */
  23222. export interface PrePassEffectConfiguration {
  23223. /**
  23224. * Name of the effect
  23225. */
  23226. name: string;
  23227. /**
  23228. * Post process to attach for this effect
  23229. */
  23230. postProcess?: PostProcess;
  23231. /**
  23232. * Textures required in the MRT
  23233. */
  23234. texturesRequired: number[];
  23235. /**
  23236. * Is the effect enabled
  23237. */
  23238. enabled: boolean;
  23239. /**
  23240. * Disposes the effect configuration
  23241. */
  23242. dispose?: () => void;
  23243. /**
  23244. * Creates the associated post process
  23245. */
  23246. createPostProcess?: () => PostProcess;
  23247. }
  23248. }
  23249. declare module BABYLON {
  23250. /**
  23251. * Options to be used when creating a FresnelParameters.
  23252. */
  23253. export type IFresnelParametersCreationOptions = {
  23254. /**
  23255. * Define the color used on edges (grazing angle)
  23256. */
  23257. leftColor?: Color3;
  23258. /**
  23259. * Define the color used on center
  23260. */
  23261. rightColor?: Color3;
  23262. /**
  23263. * Define bias applied to computed fresnel term
  23264. */
  23265. bias?: number;
  23266. /**
  23267. * Defined the power exponent applied to fresnel term
  23268. */
  23269. power?: number;
  23270. /**
  23271. * Define if the fresnel effect is enable or not.
  23272. */
  23273. isEnabled?: boolean;
  23274. };
  23275. /**
  23276. * Serialized format for FresnelParameters.
  23277. */
  23278. export type IFresnelParametersSerialized = {
  23279. /**
  23280. * Define the color used on edges (grazing angle) [as an array]
  23281. */
  23282. leftColor: number[];
  23283. /**
  23284. * Define the color used on center [as an array]
  23285. */
  23286. rightColor: number[];
  23287. /**
  23288. * Define bias applied to computed fresnel term
  23289. */
  23290. bias: number;
  23291. /**
  23292. * Defined the power exponent applied to fresnel term
  23293. */
  23294. power?: number;
  23295. /**
  23296. * Define if the fresnel effect is enable or not.
  23297. */
  23298. isEnabled: boolean;
  23299. };
  23300. /**
  23301. * This represents all the required information to add a fresnel effect on a material:
  23302. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23303. */
  23304. export class FresnelParameters {
  23305. private _isEnabled;
  23306. /**
  23307. * Define if the fresnel effect is enable or not.
  23308. */
  23309. get isEnabled(): boolean;
  23310. set isEnabled(value: boolean);
  23311. /**
  23312. * Define the color used on edges (grazing angle)
  23313. */
  23314. leftColor: Color3;
  23315. /**
  23316. * Define the color used on center
  23317. */
  23318. rightColor: Color3;
  23319. /**
  23320. * Define bias applied to computed fresnel term
  23321. */
  23322. bias: number;
  23323. /**
  23324. * Defined the power exponent applied to fresnel term
  23325. */
  23326. power: number;
  23327. /**
  23328. * Creates a new FresnelParameters object.
  23329. *
  23330. * @param options provide your own settings to optionally to override defaults
  23331. */
  23332. constructor(options?: IFresnelParametersCreationOptions);
  23333. /**
  23334. * Clones the current fresnel and its valuues
  23335. * @returns a clone fresnel configuration
  23336. */
  23337. clone(): FresnelParameters;
  23338. /**
  23339. * Determines equality between FresnelParameters objects
  23340. * @param otherFresnelParameters defines the second operand
  23341. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  23342. */
  23343. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  23344. /**
  23345. * Serializes the current fresnel parameters to a JSON representation.
  23346. * @return the JSON serialization
  23347. */
  23348. serialize(): IFresnelParametersSerialized;
  23349. /**
  23350. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  23351. * @param parsedFresnelParameters Define the JSON representation
  23352. * @returns the parsed parameters
  23353. */
  23354. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  23355. }
  23356. }
  23357. declare module BABYLON {
  23358. /**
  23359. * This groups all the flags used to control the materials channel.
  23360. */
  23361. export class MaterialFlags {
  23362. private static _DiffuseTextureEnabled;
  23363. /**
  23364. * Are diffuse textures enabled in the application.
  23365. */
  23366. static get DiffuseTextureEnabled(): boolean;
  23367. static set DiffuseTextureEnabled(value: boolean);
  23368. private static _DetailTextureEnabled;
  23369. /**
  23370. * Are detail textures enabled in the application.
  23371. */
  23372. static get DetailTextureEnabled(): boolean;
  23373. static set DetailTextureEnabled(value: boolean);
  23374. private static _AmbientTextureEnabled;
  23375. /**
  23376. * Are ambient textures enabled in the application.
  23377. */
  23378. static get AmbientTextureEnabled(): boolean;
  23379. static set AmbientTextureEnabled(value: boolean);
  23380. private static _OpacityTextureEnabled;
  23381. /**
  23382. * Are opacity textures enabled in the application.
  23383. */
  23384. static get OpacityTextureEnabled(): boolean;
  23385. static set OpacityTextureEnabled(value: boolean);
  23386. private static _ReflectionTextureEnabled;
  23387. /**
  23388. * Are reflection textures enabled in the application.
  23389. */
  23390. static get ReflectionTextureEnabled(): boolean;
  23391. static set ReflectionTextureEnabled(value: boolean);
  23392. private static _EmissiveTextureEnabled;
  23393. /**
  23394. * Are emissive textures enabled in the application.
  23395. */
  23396. static get EmissiveTextureEnabled(): boolean;
  23397. static set EmissiveTextureEnabled(value: boolean);
  23398. private static _SpecularTextureEnabled;
  23399. /**
  23400. * Are specular textures enabled in the application.
  23401. */
  23402. static get SpecularTextureEnabled(): boolean;
  23403. static set SpecularTextureEnabled(value: boolean);
  23404. private static _BumpTextureEnabled;
  23405. /**
  23406. * Are bump textures enabled in the application.
  23407. */
  23408. static get BumpTextureEnabled(): boolean;
  23409. static set BumpTextureEnabled(value: boolean);
  23410. private static _LightmapTextureEnabled;
  23411. /**
  23412. * Are lightmap textures enabled in the application.
  23413. */
  23414. static get LightmapTextureEnabled(): boolean;
  23415. static set LightmapTextureEnabled(value: boolean);
  23416. private static _RefractionTextureEnabled;
  23417. /**
  23418. * Are refraction textures enabled in the application.
  23419. */
  23420. static get RefractionTextureEnabled(): boolean;
  23421. static set RefractionTextureEnabled(value: boolean);
  23422. private static _ColorGradingTextureEnabled;
  23423. /**
  23424. * Are color grading textures enabled in the application.
  23425. */
  23426. static get ColorGradingTextureEnabled(): boolean;
  23427. static set ColorGradingTextureEnabled(value: boolean);
  23428. private static _FresnelEnabled;
  23429. /**
  23430. * Are fresnels enabled in the application.
  23431. */
  23432. static get FresnelEnabled(): boolean;
  23433. static set FresnelEnabled(value: boolean);
  23434. private static _ClearCoatTextureEnabled;
  23435. /**
  23436. * Are clear coat textures enabled in the application.
  23437. */
  23438. static get ClearCoatTextureEnabled(): boolean;
  23439. static set ClearCoatTextureEnabled(value: boolean);
  23440. private static _ClearCoatBumpTextureEnabled;
  23441. /**
  23442. * Are clear coat bump textures enabled in the application.
  23443. */
  23444. static get ClearCoatBumpTextureEnabled(): boolean;
  23445. static set ClearCoatBumpTextureEnabled(value: boolean);
  23446. private static _ClearCoatTintTextureEnabled;
  23447. /**
  23448. * Are clear coat tint textures enabled in the application.
  23449. */
  23450. static get ClearCoatTintTextureEnabled(): boolean;
  23451. static set ClearCoatTintTextureEnabled(value: boolean);
  23452. private static _SheenTextureEnabled;
  23453. /**
  23454. * Are sheen textures enabled in the application.
  23455. */
  23456. static get SheenTextureEnabled(): boolean;
  23457. static set SheenTextureEnabled(value: boolean);
  23458. private static _AnisotropicTextureEnabled;
  23459. /**
  23460. * Are anisotropic textures enabled in the application.
  23461. */
  23462. static get AnisotropicTextureEnabled(): boolean;
  23463. static set AnisotropicTextureEnabled(value: boolean);
  23464. private static _ThicknessTextureEnabled;
  23465. /**
  23466. * Are thickness textures enabled in the application.
  23467. */
  23468. static get ThicknessTextureEnabled(): boolean;
  23469. static set ThicknessTextureEnabled(value: boolean);
  23470. }
  23471. }
  23472. declare module BABYLON {
  23473. /** @hidden */
  23474. export var defaultFragmentDeclaration: {
  23475. name: string;
  23476. shader: string;
  23477. };
  23478. }
  23479. declare module BABYLON {
  23480. /** @hidden */
  23481. export var defaultUboDeclaration: {
  23482. name: string;
  23483. shader: string;
  23484. };
  23485. }
  23486. declare module BABYLON {
  23487. /** @hidden */
  23488. export var prePassDeclaration: {
  23489. name: string;
  23490. shader: string;
  23491. };
  23492. }
  23493. declare module BABYLON {
  23494. /** @hidden */
  23495. export var lightFragmentDeclaration: {
  23496. name: string;
  23497. shader: string;
  23498. };
  23499. }
  23500. declare module BABYLON {
  23501. /** @hidden */
  23502. export var lightUboDeclaration: {
  23503. name: string;
  23504. shader: string;
  23505. };
  23506. }
  23507. declare module BABYLON {
  23508. /** @hidden */
  23509. export var lightsFragmentFunctions: {
  23510. name: string;
  23511. shader: string;
  23512. };
  23513. }
  23514. declare module BABYLON {
  23515. /** @hidden */
  23516. export var shadowsFragmentFunctions: {
  23517. name: string;
  23518. shader: string;
  23519. };
  23520. }
  23521. declare module BABYLON {
  23522. /** @hidden */
  23523. export var fresnelFunction: {
  23524. name: string;
  23525. shader: string;
  23526. };
  23527. }
  23528. declare module BABYLON {
  23529. /** @hidden */
  23530. export var bumpFragmentMainFunctions: {
  23531. name: string;
  23532. shader: string;
  23533. };
  23534. }
  23535. declare module BABYLON {
  23536. /** @hidden */
  23537. export var bumpFragmentFunctions: {
  23538. name: string;
  23539. shader: string;
  23540. };
  23541. }
  23542. declare module BABYLON {
  23543. /** @hidden */
  23544. export var logDepthDeclaration: {
  23545. name: string;
  23546. shader: string;
  23547. };
  23548. }
  23549. declare module BABYLON {
  23550. /** @hidden */
  23551. export var bumpFragment: {
  23552. name: string;
  23553. shader: string;
  23554. };
  23555. }
  23556. declare module BABYLON {
  23557. /** @hidden */
  23558. export var depthPrePass: {
  23559. name: string;
  23560. shader: string;
  23561. };
  23562. }
  23563. declare module BABYLON {
  23564. /** @hidden */
  23565. export var lightFragment: {
  23566. name: string;
  23567. shader: string;
  23568. };
  23569. }
  23570. declare module BABYLON {
  23571. /** @hidden */
  23572. export var logDepthFragment: {
  23573. name: string;
  23574. shader: string;
  23575. };
  23576. }
  23577. declare module BABYLON {
  23578. /** @hidden */
  23579. export var defaultPixelShader: {
  23580. name: string;
  23581. shader: string;
  23582. };
  23583. }
  23584. declare module BABYLON {
  23585. /** @hidden */
  23586. export var defaultVertexDeclaration: {
  23587. name: string;
  23588. shader: string;
  23589. };
  23590. }
  23591. declare module BABYLON {
  23592. /** @hidden */
  23593. export var prePassVertexDeclaration: {
  23594. name: string;
  23595. shader: string;
  23596. };
  23597. }
  23598. declare module BABYLON {
  23599. /** @hidden */
  23600. export var bumpVertexDeclaration: {
  23601. name: string;
  23602. shader: string;
  23603. };
  23604. }
  23605. declare module BABYLON {
  23606. /** @hidden */
  23607. export var prePassVertex: {
  23608. name: string;
  23609. shader: string;
  23610. };
  23611. }
  23612. declare module BABYLON {
  23613. /** @hidden */
  23614. export var bumpVertex: {
  23615. name: string;
  23616. shader: string;
  23617. };
  23618. }
  23619. declare module BABYLON {
  23620. /** @hidden */
  23621. export var fogVertex: {
  23622. name: string;
  23623. shader: string;
  23624. };
  23625. }
  23626. declare module BABYLON {
  23627. /** @hidden */
  23628. export var shadowsVertex: {
  23629. name: string;
  23630. shader: string;
  23631. };
  23632. }
  23633. declare module BABYLON {
  23634. /** @hidden */
  23635. export var pointCloudVertex: {
  23636. name: string;
  23637. shader: string;
  23638. };
  23639. }
  23640. declare module BABYLON {
  23641. /** @hidden */
  23642. export var logDepthVertex: {
  23643. name: string;
  23644. shader: string;
  23645. };
  23646. }
  23647. declare module BABYLON {
  23648. /** @hidden */
  23649. export var defaultVertexShader: {
  23650. name: string;
  23651. shader: string;
  23652. };
  23653. }
  23654. declare module BABYLON {
  23655. /**
  23656. * @hidden
  23657. */
  23658. export interface IMaterialDetailMapDefines {
  23659. DETAIL: boolean;
  23660. DETAILDIRECTUV: number;
  23661. DETAIL_NORMALBLENDMETHOD: number;
  23662. /** @hidden */
  23663. _areTexturesDirty: boolean;
  23664. }
  23665. /**
  23666. * Define the code related to the detail map parameters of a material
  23667. *
  23668. * Inspired from:
  23669. * 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
  23670. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  23671. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  23672. */
  23673. export class DetailMapConfiguration {
  23674. private _texture;
  23675. /**
  23676. * The detail texture of the material.
  23677. */
  23678. texture: Nullable<BaseTexture>;
  23679. /**
  23680. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  23681. * Bigger values mean stronger blending
  23682. */
  23683. diffuseBlendLevel: number;
  23684. /**
  23685. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  23686. * Bigger values mean stronger blending. Only used with PBR materials
  23687. */
  23688. roughnessBlendLevel: number;
  23689. /**
  23690. * Defines how strong the bump effect from the detail map is
  23691. * Bigger values mean stronger effect
  23692. */
  23693. bumpLevel: number;
  23694. private _normalBlendMethod;
  23695. /**
  23696. * The method used to blend the bump and detail normals together
  23697. */
  23698. normalBlendMethod: number;
  23699. private _isEnabled;
  23700. /**
  23701. * Enable or disable the detail map on this material
  23702. */
  23703. isEnabled: boolean;
  23704. /** @hidden */
  23705. private _internalMarkAllSubMeshesAsTexturesDirty;
  23706. /** @hidden */
  23707. _markAllSubMeshesAsTexturesDirty(): void;
  23708. /**
  23709. * Instantiate a new detail map
  23710. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  23711. */
  23712. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  23713. /**
  23714. * Gets whether the submesh is ready to be used or not.
  23715. * @param defines the list of "defines" to update.
  23716. * @param scene defines the scene the material belongs to.
  23717. * @returns - boolean indicating that the submesh is ready or not.
  23718. */
  23719. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  23720. /**
  23721. * Update the defines for detail map usage
  23722. * @param defines the list of "defines" to update.
  23723. * @param scene defines the scene the material belongs to.
  23724. */
  23725. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  23726. /**
  23727. * Binds the material data.
  23728. * @param uniformBuffer defines the Uniform buffer to fill in.
  23729. * @param scene defines the scene the material belongs to.
  23730. * @param isFrozen defines whether the material is frozen or not.
  23731. */
  23732. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  23733. /**
  23734. * Checks to see if a texture is used in the material.
  23735. * @param texture - Base texture to use.
  23736. * @returns - Boolean specifying if a texture is used in the material.
  23737. */
  23738. hasTexture(texture: BaseTexture): boolean;
  23739. /**
  23740. * Returns an array of the actively used textures.
  23741. * @param activeTextures Array of BaseTextures
  23742. */
  23743. getActiveTextures(activeTextures: BaseTexture[]): void;
  23744. /**
  23745. * Returns the animatable textures.
  23746. * @param animatables Array of animatable textures.
  23747. */
  23748. getAnimatables(animatables: IAnimatable[]): void;
  23749. /**
  23750. * Disposes the resources of the material.
  23751. * @param forceDisposeTextures - Forces the disposal of all textures.
  23752. */
  23753. dispose(forceDisposeTextures?: boolean): void;
  23754. /**
  23755. * Get the current class name useful for serialization or dynamic coding.
  23756. * @returns "DetailMap"
  23757. */
  23758. getClassName(): string;
  23759. /**
  23760. * Add the required uniforms to the current list.
  23761. * @param uniforms defines the current uniform list.
  23762. */
  23763. static AddUniforms(uniforms: string[]): void;
  23764. /**
  23765. * Add the required samplers to the current list.
  23766. * @param samplers defines the current sampler list.
  23767. */
  23768. static AddSamplers(samplers: string[]): void;
  23769. /**
  23770. * Add the required uniforms to the current buffer.
  23771. * @param uniformBuffer defines the current uniform buffer.
  23772. */
  23773. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  23774. /**
  23775. * Makes a duplicate of the current instance into another one.
  23776. * @param detailMap define the instance where to copy the info
  23777. */
  23778. copyTo(detailMap: DetailMapConfiguration): void;
  23779. /**
  23780. * Serializes this detail map instance
  23781. * @returns - An object with the serialized instance.
  23782. */
  23783. serialize(): any;
  23784. /**
  23785. * Parses a detail map setting from a serialized object.
  23786. * @param source - Serialized object.
  23787. * @param scene Defines the scene we are parsing for
  23788. * @param rootUrl Defines the rootUrl to load from
  23789. */
  23790. parse(source: any, scene: Scene, rootUrl: string): void;
  23791. }
  23792. }
  23793. declare module BABYLON {
  23794. /** @hidden */
  23795. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  23796. MAINUV1: boolean;
  23797. MAINUV2: boolean;
  23798. DIFFUSE: boolean;
  23799. DIFFUSEDIRECTUV: number;
  23800. DETAIL: boolean;
  23801. DETAILDIRECTUV: number;
  23802. DETAIL_NORMALBLENDMETHOD: number;
  23803. AMBIENT: boolean;
  23804. AMBIENTDIRECTUV: number;
  23805. OPACITY: boolean;
  23806. OPACITYDIRECTUV: number;
  23807. OPACITYRGB: boolean;
  23808. REFLECTION: boolean;
  23809. EMISSIVE: boolean;
  23810. EMISSIVEDIRECTUV: number;
  23811. SPECULAR: boolean;
  23812. SPECULARDIRECTUV: number;
  23813. BUMP: boolean;
  23814. BUMPDIRECTUV: number;
  23815. PARALLAX: boolean;
  23816. PARALLAXOCCLUSION: boolean;
  23817. SPECULAROVERALPHA: boolean;
  23818. CLIPPLANE: boolean;
  23819. CLIPPLANE2: boolean;
  23820. CLIPPLANE3: boolean;
  23821. CLIPPLANE4: boolean;
  23822. CLIPPLANE5: boolean;
  23823. CLIPPLANE6: boolean;
  23824. ALPHATEST: boolean;
  23825. DEPTHPREPASS: boolean;
  23826. ALPHAFROMDIFFUSE: boolean;
  23827. POINTSIZE: boolean;
  23828. FOG: boolean;
  23829. SPECULARTERM: boolean;
  23830. DIFFUSEFRESNEL: boolean;
  23831. OPACITYFRESNEL: boolean;
  23832. REFLECTIONFRESNEL: boolean;
  23833. REFRACTIONFRESNEL: boolean;
  23834. EMISSIVEFRESNEL: boolean;
  23835. FRESNEL: boolean;
  23836. NORMAL: boolean;
  23837. UV1: boolean;
  23838. UV2: boolean;
  23839. VERTEXCOLOR: boolean;
  23840. VERTEXALPHA: boolean;
  23841. NUM_BONE_INFLUENCERS: number;
  23842. BonesPerMesh: number;
  23843. BONETEXTURE: boolean;
  23844. BONES_VELOCITY_ENABLED: boolean;
  23845. INSTANCES: boolean;
  23846. THIN_INSTANCES: boolean;
  23847. GLOSSINESS: boolean;
  23848. ROUGHNESS: boolean;
  23849. EMISSIVEASILLUMINATION: boolean;
  23850. LINKEMISSIVEWITHDIFFUSE: boolean;
  23851. REFLECTIONFRESNELFROMSPECULAR: boolean;
  23852. LIGHTMAP: boolean;
  23853. LIGHTMAPDIRECTUV: number;
  23854. OBJECTSPACE_NORMALMAP: boolean;
  23855. USELIGHTMAPASSHADOWMAP: boolean;
  23856. REFLECTIONMAP_3D: boolean;
  23857. REFLECTIONMAP_SPHERICAL: boolean;
  23858. REFLECTIONMAP_PLANAR: boolean;
  23859. REFLECTIONMAP_CUBIC: boolean;
  23860. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  23861. REFLECTIONMAP_PROJECTION: boolean;
  23862. REFLECTIONMAP_SKYBOX: boolean;
  23863. REFLECTIONMAP_EXPLICIT: boolean;
  23864. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  23865. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  23866. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  23867. INVERTCUBICMAP: boolean;
  23868. LOGARITHMICDEPTH: boolean;
  23869. REFRACTION: boolean;
  23870. REFRACTIONMAP_3D: boolean;
  23871. REFLECTIONOVERALPHA: boolean;
  23872. TWOSIDEDLIGHTING: boolean;
  23873. SHADOWFLOAT: boolean;
  23874. MORPHTARGETS: boolean;
  23875. MORPHTARGETS_NORMAL: boolean;
  23876. MORPHTARGETS_TANGENT: boolean;
  23877. MORPHTARGETS_UV: boolean;
  23878. NUM_MORPH_INFLUENCERS: number;
  23879. NONUNIFORMSCALING: boolean;
  23880. PREMULTIPLYALPHA: boolean;
  23881. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  23882. ALPHABLEND: boolean;
  23883. PREPASS: boolean;
  23884. PREPASS_IRRADIANCE: boolean;
  23885. PREPASS_IRRADIANCE_INDEX: number;
  23886. PREPASS_ALBEDO: boolean;
  23887. PREPASS_ALBEDO_INDEX: number;
  23888. PREPASS_DEPTHNORMAL: boolean;
  23889. PREPASS_DEPTHNORMAL_INDEX: number;
  23890. PREPASS_POSITION: boolean;
  23891. PREPASS_POSITION_INDEX: number;
  23892. PREPASS_VELOCITY: boolean;
  23893. PREPASS_VELOCITY_INDEX: number;
  23894. PREPASS_REFLECTIVITY: boolean;
  23895. PREPASS_REFLECTIVITY_INDEX: number;
  23896. SCENE_MRT_COUNT: number;
  23897. RGBDLIGHTMAP: boolean;
  23898. RGBDREFLECTION: boolean;
  23899. RGBDREFRACTION: boolean;
  23900. IMAGEPROCESSING: boolean;
  23901. VIGNETTE: boolean;
  23902. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23903. VIGNETTEBLENDMODEOPAQUE: boolean;
  23904. TONEMAPPING: boolean;
  23905. TONEMAPPING_ACES: boolean;
  23906. CONTRAST: boolean;
  23907. COLORCURVES: boolean;
  23908. COLORGRADING: boolean;
  23909. COLORGRADING3D: boolean;
  23910. SAMPLER3DGREENDEPTH: boolean;
  23911. SAMPLER3DBGRMAP: boolean;
  23912. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23913. MULTIVIEW: boolean;
  23914. /**
  23915. * If the reflection texture on this material is in linear color space
  23916. * @hidden
  23917. */
  23918. IS_REFLECTION_LINEAR: boolean;
  23919. /**
  23920. * If the refraction texture on this material is in linear color space
  23921. * @hidden
  23922. */
  23923. IS_REFRACTION_LINEAR: boolean;
  23924. EXPOSURE: boolean;
  23925. constructor();
  23926. setReflectionMode(modeToEnable: string): void;
  23927. }
  23928. /**
  23929. * This is the default material used in Babylon. It is the best trade off between quality
  23930. * and performances.
  23931. * @see https://doc.babylonjs.com/babylon101/materials
  23932. */
  23933. export class StandardMaterial extends PushMaterial {
  23934. private _diffuseTexture;
  23935. /**
  23936. * The basic texture of the material as viewed under a light.
  23937. */
  23938. diffuseTexture: Nullable<BaseTexture>;
  23939. private _ambientTexture;
  23940. /**
  23941. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  23942. */
  23943. ambientTexture: Nullable<BaseTexture>;
  23944. private _opacityTexture;
  23945. /**
  23946. * Define the transparency of the material from a texture.
  23947. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  23948. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  23949. */
  23950. opacityTexture: Nullable<BaseTexture>;
  23951. private _reflectionTexture;
  23952. /**
  23953. * Define the texture used to display the reflection.
  23954. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23955. */
  23956. reflectionTexture: Nullable<BaseTexture>;
  23957. private _emissiveTexture;
  23958. /**
  23959. * Define texture of the material as if self lit.
  23960. * This will be mixed in the final result even in the absence of light.
  23961. */
  23962. emissiveTexture: Nullable<BaseTexture>;
  23963. private _specularTexture;
  23964. /**
  23965. * Define how the color and intensity of the highlight given by the light in the material.
  23966. */
  23967. specularTexture: Nullable<BaseTexture>;
  23968. private _bumpTexture;
  23969. /**
  23970. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  23971. * 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.
  23972. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  23973. */
  23974. bumpTexture: Nullable<BaseTexture>;
  23975. private _lightmapTexture;
  23976. /**
  23977. * Complex lighting can be computationally expensive to compute at runtime.
  23978. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  23979. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  23980. */
  23981. lightmapTexture: Nullable<BaseTexture>;
  23982. private _refractionTexture;
  23983. /**
  23984. * Define the texture used to display the refraction.
  23985. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23986. */
  23987. refractionTexture: Nullable<BaseTexture>;
  23988. /**
  23989. * The color of the material lit by the environmental background lighting.
  23990. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  23991. */
  23992. ambientColor: Color3;
  23993. /**
  23994. * The basic color of the material as viewed under a light.
  23995. */
  23996. diffuseColor: Color3;
  23997. /**
  23998. * Define how the color and intensity of the highlight given by the light in the material.
  23999. */
  24000. specularColor: Color3;
  24001. /**
  24002. * Define the color of the material as if self lit.
  24003. * This will be mixed in the final result even in the absence of light.
  24004. */
  24005. emissiveColor: Color3;
  24006. /**
  24007. * Defines how sharp are the highlights in the material.
  24008. * The bigger the value the sharper giving a more glossy feeling to the result.
  24009. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24010. */
  24011. specularPower: number;
  24012. private _useAlphaFromDiffuseTexture;
  24013. /**
  24014. * Does the transparency come from the diffuse texture alpha channel.
  24015. */
  24016. useAlphaFromDiffuseTexture: boolean;
  24017. private _useEmissiveAsIllumination;
  24018. /**
  24019. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24020. */
  24021. useEmissiveAsIllumination: boolean;
  24022. private _linkEmissiveWithDiffuse;
  24023. /**
  24024. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24025. * the emissive level when the final color is close to one.
  24026. */
  24027. linkEmissiveWithDiffuse: boolean;
  24028. private _useSpecularOverAlpha;
  24029. /**
  24030. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24031. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24032. */
  24033. useSpecularOverAlpha: boolean;
  24034. private _useReflectionOverAlpha;
  24035. /**
  24036. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24037. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24038. */
  24039. useReflectionOverAlpha: boolean;
  24040. private _disableLighting;
  24041. /**
  24042. * Does lights from the scene impacts this material.
  24043. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24044. */
  24045. disableLighting: boolean;
  24046. private _useObjectSpaceNormalMap;
  24047. /**
  24048. * Allows using an object space normal map (instead of tangent space).
  24049. */
  24050. useObjectSpaceNormalMap: boolean;
  24051. private _useParallax;
  24052. /**
  24053. * Is parallax enabled or not.
  24054. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24055. */
  24056. useParallax: boolean;
  24057. private _useParallaxOcclusion;
  24058. /**
  24059. * Is parallax occlusion enabled or not.
  24060. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24061. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24062. */
  24063. useParallaxOcclusion: boolean;
  24064. /**
  24065. * 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.
  24066. */
  24067. parallaxScaleBias: number;
  24068. private _roughness;
  24069. /**
  24070. * Helps to define how blurry the reflections should appears in the material.
  24071. */
  24072. roughness: number;
  24073. /**
  24074. * In case of refraction, define the value of the index of refraction.
  24075. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24076. */
  24077. indexOfRefraction: number;
  24078. /**
  24079. * Invert the refraction texture alongside the y axis.
  24080. * It can be useful with procedural textures or probe for instance.
  24081. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24082. */
  24083. invertRefractionY: boolean;
  24084. /**
  24085. * Defines the alpha limits in alpha test mode.
  24086. */
  24087. alphaCutOff: number;
  24088. private _useLightmapAsShadowmap;
  24089. /**
  24090. * In case of light mapping, define whether the map contains light or shadow informations.
  24091. */
  24092. useLightmapAsShadowmap: boolean;
  24093. private _diffuseFresnelParameters;
  24094. /**
  24095. * Define the diffuse fresnel parameters of the material.
  24096. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24097. */
  24098. diffuseFresnelParameters: FresnelParameters;
  24099. private _opacityFresnelParameters;
  24100. /**
  24101. * Define the opacity fresnel parameters of the material.
  24102. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24103. */
  24104. opacityFresnelParameters: FresnelParameters;
  24105. private _reflectionFresnelParameters;
  24106. /**
  24107. * Define the reflection fresnel parameters of the material.
  24108. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24109. */
  24110. reflectionFresnelParameters: FresnelParameters;
  24111. private _refractionFresnelParameters;
  24112. /**
  24113. * Define the refraction fresnel parameters of the material.
  24114. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24115. */
  24116. refractionFresnelParameters: FresnelParameters;
  24117. private _emissiveFresnelParameters;
  24118. /**
  24119. * Define the emissive fresnel parameters of the material.
  24120. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24121. */
  24122. emissiveFresnelParameters: FresnelParameters;
  24123. private _useReflectionFresnelFromSpecular;
  24124. /**
  24125. * If true automatically deducts the fresnels values from the material specularity.
  24126. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24127. */
  24128. useReflectionFresnelFromSpecular: boolean;
  24129. private _useGlossinessFromSpecularMapAlpha;
  24130. /**
  24131. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  24132. */
  24133. useGlossinessFromSpecularMapAlpha: boolean;
  24134. private _maxSimultaneousLights;
  24135. /**
  24136. * Defines the maximum number of lights that can be used in the material
  24137. */
  24138. maxSimultaneousLights: number;
  24139. private _invertNormalMapX;
  24140. /**
  24141. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  24142. */
  24143. invertNormalMapX: boolean;
  24144. private _invertNormalMapY;
  24145. /**
  24146. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  24147. */
  24148. invertNormalMapY: boolean;
  24149. private _twoSidedLighting;
  24150. /**
  24151. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  24152. */
  24153. twoSidedLighting: boolean;
  24154. /**
  24155. * Default configuration related to image processing available in the standard Material.
  24156. */
  24157. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24158. /**
  24159. * Gets the image processing configuration used either in this material.
  24160. */
  24161. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24162. /**
  24163. * Sets the Default image processing configuration used either in the this material.
  24164. *
  24165. * If sets to null, the scene one is in use.
  24166. */
  24167. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24168. /**
  24169. * Keep track of the image processing observer to allow dispose and replace.
  24170. */
  24171. private _imageProcessingObserver;
  24172. /**
  24173. * Attaches a new image processing configuration to the Standard Material.
  24174. * @param configuration
  24175. */
  24176. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24177. /**
  24178. * Defines additionnal PrePass parameters for the material.
  24179. */
  24180. readonly prePassConfiguration: PrePassConfiguration;
  24181. /**
  24182. * Gets wether the color curves effect is enabled.
  24183. */
  24184. get cameraColorCurvesEnabled(): boolean;
  24185. /**
  24186. * Sets wether the color curves effect is enabled.
  24187. */
  24188. set cameraColorCurvesEnabled(value: boolean);
  24189. /**
  24190. * Gets wether the color grading effect is enabled.
  24191. */
  24192. get cameraColorGradingEnabled(): boolean;
  24193. /**
  24194. * Gets wether the color grading effect is enabled.
  24195. */
  24196. set cameraColorGradingEnabled(value: boolean);
  24197. /**
  24198. * Gets wether tonemapping is enabled or not.
  24199. */
  24200. get cameraToneMappingEnabled(): boolean;
  24201. /**
  24202. * Sets wether tonemapping is enabled or not
  24203. */
  24204. set cameraToneMappingEnabled(value: boolean);
  24205. /**
  24206. * The camera exposure used on this material.
  24207. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24208. * This corresponds to a photographic exposure.
  24209. */
  24210. get cameraExposure(): number;
  24211. /**
  24212. * The camera exposure used on this material.
  24213. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24214. * This corresponds to a photographic exposure.
  24215. */
  24216. set cameraExposure(value: number);
  24217. /**
  24218. * Gets The camera contrast used on this material.
  24219. */
  24220. get cameraContrast(): number;
  24221. /**
  24222. * Sets The camera contrast used on this material.
  24223. */
  24224. set cameraContrast(value: number);
  24225. /**
  24226. * Gets the Color Grading 2D Lookup Texture.
  24227. */
  24228. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  24229. /**
  24230. * Sets the Color Grading 2D Lookup Texture.
  24231. */
  24232. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  24233. /**
  24234. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24235. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24236. * 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;
  24237. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24238. */
  24239. get cameraColorCurves(): Nullable<ColorCurves>;
  24240. /**
  24241. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24242. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24243. * 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;
  24244. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24245. */
  24246. set cameraColorCurves(value: Nullable<ColorCurves>);
  24247. /**
  24248. * Can this material render to several textures at once
  24249. */
  24250. get canRenderToMRT(): boolean;
  24251. /**
  24252. * Defines the detail map parameters for the material.
  24253. */
  24254. readonly detailMap: DetailMapConfiguration;
  24255. protected _renderTargets: SmartArray<RenderTargetTexture>;
  24256. protected _worldViewProjectionMatrix: Matrix;
  24257. protected _globalAmbientColor: Color3;
  24258. protected _useLogarithmicDepth: boolean;
  24259. protected _rebuildInParallel: boolean;
  24260. /**
  24261. * Instantiates a new standard material.
  24262. * This is the default material used in Babylon. It is the best trade off between quality
  24263. * and performances.
  24264. * @see https://doc.babylonjs.com/babylon101/materials
  24265. * @param name Define the name of the material in the scene
  24266. * @param scene Define the scene the material belong to
  24267. */
  24268. constructor(name: string, scene: Scene);
  24269. /**
  24270. * Gets a boolean indicating that current material needs to register RTT
  24271. */
  24272. get hasRenderTargetTextures(): boolean;
  24273. /**
  24274. * Gets the current class name of the material e.g. "StandardMaterial"
  24275. * Mainly use in serialization.
  24276. * @returns the class name
  24277. */
  24278. getClassName(): string;
  24279. /**
  24280. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  24281. * You can try switching to logarithmic depth.
  24282. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  24283. */
  24284. get useLogarithmicDepth(): boolean;
  24285. set useLogarithmicDepth(value: boolean);
  24286. /**
  24287. * Specifies if the material will require alpha blending
  24288. * @returns a boolean specifying if alpha blending is needed
  24289. */
  24290. needAlphaBlending(): boolean;
  24291. /**
  24292. * Specifies if this material should be rendered in alpha test mode
  24293. * @returns a boolean specifying if an alpha test is needed.
  24294. */
  24295. needAlphaTesting(): boolean;
  24296. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24297. /**
  24298. * Get the texture used for alpha test purpose.
  24299. * @returns the diffuse texture in case of the standard material.
  24300. */
  24301. getAlphaTestTexture(): Nullable<BaseTexture>;
  24302. /**
  24303. * Get if the submesh is ready to be used and all its information available.
  24304. * Child classes can use it to update shaders
  24305. * @param mesh defines the mesh to check
  24306. * @param subMesh defines which submesh to check
  24307. * @param useInstances specifies that instances should be used
  24308. * @returns a boolean indicating that the submesh is ready or not
  24309. */
  24310. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24311. /**
  24312. * Builds the material UBO layouts.
  24313. * Used internally during the effect preparation.
  24314. */
  24315. buildUniformLayout(): void;
  24316. /**
  24317. * Unbinds the material from the mesh
  24318. */
  24319. unbind(): void;
  24320. /**
  24321. * Binds the submesh to this material by preparing the effect and shader to draw
  24322. * @param world defines the world transformation matrix
  24323. * @param mesh defines the mesh containing the submesh
  24324. * @param subMesh defines the submesh to bind the material to
  24325. */
  24326. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24327. /**
  24328. * Get the list of animatables in the material.
  24329. * @returns the list of animatables object used in the material
  24330. */
  24331. getAnimatables(): IAnimatable[];
  24332. /**
  24333. * Gets the active textures from the material
  24334. * @returns an array of textures
  24335. */
  24336. getActiveTextures(): BaseTexture[];
  24337. /**
  24338. * Specifies if the material uses a texture
  24339. * @param texture defines the texture to check against the material
  24340. * @returns a boolean specifying if the material uses the texture
  24341. */
  24342. hasTexture(texture: BaseTexture): boolean;
  24343. /**
  24344. * Disposes the material
  24345. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24346. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24347. */
  24348. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24349. /**
  24350. * Makes a duplicate of the material, and gives it a new name
  24351. * @param name defines the new name for the duplicated material
  24352. * @returns the cloned material
  24353. */
  24354. clone(name: string): StandardMaterial;
  24355. /**
  24356. * Serializes this material in a JSON representation
  24357. * @returns the serialized material object
  24358. */
  24359. serialize(): any;
  24360. /**
  24361. * Creates a standard material from parsed material data
  24362. * @param source defines the JSON representation of the material
  24363. * @param scene defines the hosting scene
  24364. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24365. * @returns a new standard material
  24366. */
  24367. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24368. /**
  24369. * Are diffuse textures enabled in the application.
  24370. */
  24371. static get DiffuseTextureEnabled(): boolean;
  24372. static set DiffuseTextureEnabled(value: boolean);
  24373. /**
  24374. * Are detail textures enabled in the application.
  24375. */
  24376. static get DetailTextureEnabled(): boolean;
  24377. static set DetailTextureEnabled(value: boolean);
  24378. /**
  24379. * Are ambient textures enabled in the application.
  24380. */
  24381. static get AmbientTextureEnabled(): boolean;
  24382. static set AmbientTextureEnabled(value: boolean);
  24383. /**
  24384. * Are opacity textures enabled in the application.
  24385. */
  24386. static get OpacityTextureEnabled(): boolean;
  24387. static set OpacityTextureEnabled(value: boolean);
  24388. /**
  24389. * Are reflection textures enabled in the application.
  24390. */
  24391. static get ReflectionTextureEnabled(): boolean;
  24392. static set ReflectionTextureEnabled(value: boolean);
  24393. /**
  24394. * Are emissive textures enabled in the application.
  24395. */
  24396. static get EmissiveTextureEnabled(): boolean;
  24397. static set EmissiveTextureEnabled(value: boolean);
  24398. /**
  24399. * Are specular textures enabled in the application.
  24400. */
  24401. static get SpecularTextureEnabled(): boolean;
  24402. static set SpecularTextureEnabled(value: boolean);
  24403. /**
  24404. * Are bump textures enabled in the application.
  24405. */
  24406. static get BumpTextureEnabled(): boolean;
  24407. static set BumpTextureEnabled(value: boolean);
  24408. /**
  24409. * Are lightmap textures enabled in the application.
  24410. */
  24411. static get LightmapTextureEnabled(): boolean;
  24412. static set LightmapTextureEnabled(value: boolean);
  24413. /**
  24414. * Are refraction textures enabled in the application.
  24415. */
  24416. static get RefractionTextureEnabled(): boolean;
  24417. static set RefractionTextureEnabled(value: boolean);
  24418. /**
  24419. * Are color grading textures enabled in the application.
  24420. */
  24421. static get ColorGradingTextureEnabled(): boolean;
  24422. static set ColorGradingTextureEnabled(value: boolean);
  24423. /**
  24424. * Are fresnels enabled in the application.
  24425. */
  24426. static get FresnelEnabled(): boolean;
  24427. static set FresnelEnabled(value: boolean);
  24428. }
  24429. }
  24430. declare module BABYLON {
  24431. /** @hidden */
  24432. export var rgbdDecodePixelShader: {
  24433. name: string;
  24434. shader: string;
  24435. };
  24436. }
  24437. declare module BABYLON {
  24438. /**
  24439. * Class used to host RGBD texture specific utilities
  24440. */
  24441. export class RGBDTextureTools {
  24442. /**
  24443. * Expand the RGBD Texture from RGBD to Half Float if possible.
  24444. * @param texture the texture to expand.
  24445. */
  24446. static ExpandRGBDTexture(texture: Texture): void;
  24447. }
  24448. }
  24449. declare module BABYLON {
  24450. /**
  24451. * Class used to host texture specific utilities
  24452. */
  24453. export class BRDFTextureTools {
  24454. /**
  24455. * Prevents texture cache collision
  24456. */
  24457. private static _instanceNumber;
  24458. /**
  24459. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  24460. * @param scene defines the hosting scene
  24461. * @returns the environment BRDF texture
  24462. */
  24463. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  24464. private static _environmentBRDFBase64Texture;
  24465. }
  24466. }
  24467. declare module BABYLON {
  24468. /**
  24469. * @hidden
  24470. */
  24471. export interface IMaterialClearCoatDefines {
  24472. CLEARCOAT: boolean;
  24473. CLEARCOAT_DEFAULTIOR: boolean;
  24474. CLEARCOAT_TEXTURE: boolean;
  24475. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  24476. CLEARCOAT_TEXTUREDIRECTUV: number;
  24477. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  24478. CLEARCOAT_BUMP: boolean;
  24479. CLEARCOAT_BUMPDIRECTUV: number;
  24480. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24481. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24482. CLEARCOAT_REMAP_F0: boolean;
  24483. CLEARCOAT_TINT: boolean;
  24484. CLEARCOAT_TINT_TEXTURE: boolean;
  24485. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  24486. /** @hidden */
  24487. _areTexturesDirty: boolean;
  24488. }
  24489. /**
  24490. * Define the code related to the clear coat parameters of the pbr material.
  24491. */
  24492. export class PBRClearCoatConfiguration {
  24493. /**
  24494. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24495. * The default fits with a polyurethane material.
  24496. */
  24497. private static readonly _DefaultIndexOfRefraction;
  24498. private _isEnabled;
  24499. /**
  24500. * Defines if the clear coat is enabled in the material.
  24501. */
  24502. isEnabled: boolean;
  24503. /**
  24504. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  24505. */
  24506. intensity: number;
  24507. /**
  24508. * Defines the clear coat layer roughness.
  24509. */
  24510. roughness: number;
  24511. private _indexOfRefraction;
  24512. /**
  24513. * Defines the index of refraction of the clear coat.
  24514. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24515. * The default fits with a polyurethane material.
  24516. * Changing the default value is more performance intensive.
  24517. */
  24518. indexOfRefraction: number;
  24519. private _texture;
  24520. /**
  24521. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  24522. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  24523. * if textureRoughness is not empty, else no texture roughness is used
  24524. */
  24525. texture: Nullable<BaseTexture>;
  24526. private _useRoughnessFromMainTexture;
  24527. /**
  24528. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  24529. * If false, the green channel from textureRoughness is used for roughness
  24530. */
  24531. useRoughnessFromMainTexture: boolean;
  24532. private _textureRoughness;
  24533. /**
  24534. * Stores the clear coat roughness in a texture (green channel)
  24535. * Not used if useRoughnessFromMainTexture is true
  24536. */
  24537. textureRoughness: Nullable<BaseTexture>;
  24538. private _remapF0OnInterfaceChange;
  24539. /**
  24540. * Defines if the F0 value should be remapped to account for the interface change in the material.
  24541. */
  24542. remapF0OnInterfaceChange: boolean;
  24543. private _bumpTexture;
  24544. /**
  24545. * Define the clear coat specific bump texture.
  24546. */
  24547. bumpTexture: Nullable<BaseTexture>;
  24548. private _isTintEnabled;
  24549. /**
  24550. * Defines if the clear coat tint is enabled in the material.
  24551. */
  24552. isTintEnabled: boolean;
  24553. /**
  24554. * Defines the clear coat tint of the material.
  24555. * This is only use if tint is enabled
  24556. */
  24557. tintColor: Color3;
  24558. /**
  24559. * Defines the distance at which the tint color should be found in the
  24560. * clear coat media.
  24561. * This is only use if tint is enabled
  24562. */
  24563. tintColorAtDistance: number;
  24564. /**
  24565. * Defines the clear coat layer thickness.
  24566. * This is only use if tint is enabled
  24567. */
  24568. tintThickness: number;
  24569. private _tintTexture;
  24570. /**
  24571. * Stores the clear tint values in a texture.
  24572. * rgb is tint
  24573. * a is a thickness factor
  24574. */
  24575. tintTexture: Nullable<BaseTexture>;
  24576. /** @hidden */
  24577. private _internalMarkAllSubMeshesAsTexturesDirty;
  24578. /** @hidden */
  24579. _markAllSubMeshesAsTexturesDirty(): void;
  24580. /**
  24581. * Instantiate a new istance of clear coat configuration.
  24582. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24583. */
  24584. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24585. /**
  24586. * Gets wehter the submesh is ready to be used or not.
  24587. * @param defines the list of "defines" to update.
  24588. * @param scene defines the scene the material belongs to.
  24589. * @param engine defines the engine the material belongs to.
  24590. * @param disableBumpMap defines wether the material disables bump or not.
  24591. * @returns - boolean indicating that the submesh is ready or not.
  24592. */
  24593. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  24594. /**
  24595. * Checks to see if a texture is used in the material.
  24596. * @param defines the list of "defines" to update.
  24597. * @param scene defines the scene to the material belongs to.
  24598. */
  24599. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  24600. /**
  24601. * Binds the material data.
  24602. * @param uniformBuffer defines the Uniform buffer to fill in.
  24603. * @param scene defines the scene the material belongs to.
  24604. * @param engine defines the engine the material belongs to.
  24605. * @param disableBumpMap defines wether the material disables bump or not.
  24606. * @param isFrozen defines wether the material is frozen or not.
  24607. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  24608. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  24609. * @param subMesh the submesh to bind data for
  24610. */
  24611. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  24612. /**
  24613. * Checks to see if a texture is used in the material.
  24614. * @param texture - Base texture to use.
  24615. * @returns - Boolean specifying if a texture is used in the material.
  24616. */
  24617. hasTexture(texture: BaseTexture): boolean;
  24618. /**
  24619. * Returns an array of the actively used textures.
  24620. * @param activeTextures Array of BaseTextures
  24621. */
  24622. getActiveTextures(activeTextures: BaseTexture[]): void;
  24623. /**
  24624. * Returns the animatable textures.
  24625. * @param animatables Array of animatable textures.
  24626. */
  24627. getAnimatables(animatables: IAnimatable[]): void;
  24628. /**
  24629. * Disposes the resources of the material.
  24630. * @param forceDisposeTextures - Forces the disposal of all textures.
  24631. */
  24632. dispose(forceDisposeTextures?: boolean): void;
  24633. /**
  24634. * Get the current class name of the texture useful for serialization or dynamic coding.
  24635. * @returns "PBRClearCoatConfiguration"
  24636. */
  24637. getClassName(): string;
  24638. /**
  24639. * Add fallbacks to the effect fallbacks list.
  24640. * @param defines defines the Base texture to use.
  24641. * @param fallbacks defines the current fallback list.
  24642. * @param currentRank defines the current fallback rank.
  24643. * @returns the new fallback rank.
  24644. */
  24645. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24646. /**
  24647. * Add the required uniforms to the current list.
  24648. * @param uniforms defines the current uniform list.
  24649. */
  24650. static AddUniforms(uniforms: string[]): void;
  24651. /**
  24652. * Add the required samplers to the current list.
  24653. * @param samplers defines the current sampler list.
  24654. */
  24655. static AddSamplers(samplers: string[]): void;
  24656. /**
  24657. * Add the required uniforms to the current buffer.
  24658. * @param uniformBuffer defines the current uniform buffer.
  24659. */
  24660. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24661. /**
  24662. * Makes a duplicate of the current configuration into another one.
  24663. * @param clearCoatConfiguration define the config where to copy the info
  24664. */
  24665. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  24666. /**
  24667. * Serializes this clear coat configuration.
  24668. * @returns - An object with the serialized config.
  24669. */
  24670. serialize(): any;
  24671. /**
  24672. * Parses a anisotropy Configuration from a serialized object.
  24673. * @param source - Serialized object.
  24674. * @param scene Defines the scene we are parsing for
  24675. * @param rootUrl Defines the rootUrl to load from
  24676. */
  24677. parse(source: any, scene: Scene, rootUrl: string): void;
  24678. }
  24679. }
  24680. declare module BABYLON {
  24681. /**
  24682. * @hidden
  24683. */
  24684. export interface IMaterialAnisotropicDefines {
  24685. ANISOTROPIC: boolean;
  24686. ANISOTROPIC_TEXTURE: boolean;
  24687. ANISOTROPIC_TEXTUREDIRECTUV: number;
  24688. MAINUV1: boolean;
  24689. _areTexturesDirty: boolean;
  24690. _needUVs: boolean;
  24691. }
  24692. /**
  24693. * Define the code related to the anisotropic parameters of the pbr material.
  24694. */
  24695. export class PBRAnisotropicConfiguration {
  24696. private _isEnabled;
  24697. /**
  24698. * Defines if the anisotropy is enabled in the material.
  24699. */
  24700. isEnabled: boolean;
  24701. /**
  24702. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  24703. */
  24704. intensity: number;
  24705. /**
  24706. * Defines if the effect is along the tangents, bitangents or in between.
  24707. * By default, the effect is "strectching" the highlights along the tangents.
  24708. */
  24709. direction: Vector2;
  24710. private _texture;
  24711. /**
  24712. * Stores the anisotropy values in a texture.
  24713. * rg is direction (like normal from -1 to 1)
  24714. * b is a intensity
  24715. */
  24716. texture: Nullable<BaseTexture>;
  24717. /** @hidden */
  24718. private _internalMarkAllSubMeshesAsTexturesDirty;
  24719. /** @hidden */
  24720. _markAllSubMeshesAsTexturesDirty(): void;
  24721. /**
  24722. * Instantiate a new istance of anisotropy configuration.
  24723. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24724. */
  24725. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24726. /**
  24727. * Specifies that the submesh is ready to be used.
  24728. * @param defines the list of "defines" to update.
  24729. * @param scene defines the scene the material belongs to.
  24730. * @returns - boolean indicating that the submesh is ready or not.
  24731. */
  24732. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  24733. /**
  24734. * Checks to see if a texture is used in the material.
  24735. * @param defines the list of "defines" to update.
  24736. * @param mesh the mesh we are preparing the defines for.
  24737. * @param scene defines the scene the material belongs to.
  24738. */
  24739. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  24740. /**
  24741. * Binds the material data.
  24742. * @param uniformBuffer defines the Uniform buffer to fill in.
  24743. * @param scene defines the scene the material belongs to.
  24744. * @param isFrozen defines wether the material is frozen or not.
  24745. */
  24746. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24747. /**
  24748. * Checks to see if a texture is used in the material.
  24749. * @param texture - Base texture to use.
  24750. * @returns - Boolean specifying if a texture is used in the material.
  24751. */
  24752. hasTexture(texture: BaseTexture): boolean;
  24753. /**
  24754. * Returns an array of the actively used textures.
  24755. * @param activeTextures Array of BaseTextures
  24756. */
  24757. getActiveTextures(activeTextures: BaseTexture[]): void;
  24758. /**
  24759. * Returns the animatable textures.
  24760. * @param animatables Array of animatable textures.
  24761. */
  24762. getAnimatables(animatables: IAnimatable[]): void;
  24763. /**
  24764. * Disposes the resources of the material.
  24765. * @param forceDisposeTextures - Forces the disposal of all textures.
  24766. */
  24767. dispose(forceDisposeTextures?: boolean): void;
  24768. /**
  24769. * Get the current class name of the texture useful for serialization or dynamic coding.
  24770. * @returns "PBRAnisotropicConfiguration"
  24771. */
  24772. getClassName(): string;
  24773. /**
  24774. * Add fallbacks to the effect fallbacks list.
  24775. * @param defines defines the Base texture to use.
  24776. * @param fallbacks defines the current fallback list.
  24777. * @param currentRank defines the current fallback rank.
  24778. * @returns the new fallback rank.
  24779. */
  24780. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24781. /**
  24782. * Add the required uniforms to the current list.
  24783. * @param uniforms defines the current uniform list.
  24784. */
  24785. static AddUniforms(uniforms: string[]): void;
  24786. /**
  24787. * Add the required uniforms to the current buffer.
  24788. * @param uniformBuffer defines the current uniform buffer.
  24789. */
  24790. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24791. /**
  24792. * Add the required samplers to the current list.
  24793. * @param samplers defines the current sampler list.
  24794. */
  24795. static AddSamplers(samplers: string[]): void;
  24796. /**
  24797. * Makes a duplicate of the current configuration into another one.
  24798. * @param anisotropicConfiguration define the config where to copy the info
  24799. */
  24800. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  24801. /**
  24802. * Serializes this anisotropy configuration.
  24803. * @returns - An object with the serialized config.
  24804. */
  24805. serialize(): any;
  24806. /**
  24807. * Parses a anisotropy Configuration from a serialized object.
  24808. * @param source - Serialized object.
  24809. * @param scene Defines the scene we are parsing for
  24810. * @param rootUrl Defines the rootUrl to load from
  24811. */
  24812. parse(source: any, scene: Scene, rootUrl: string): void;
  24813. }
  24814. }
  24815. declare module BABYLON {
  24816. /**
  24817. * @hidden
  24818. */
  24819. export interface IMaterialBRDFDefines {
  24820. BRDF_V_HEIGHT_CORRELATED: boolean;
  24821. MS_BRDF_ENERGY_CONSERVATION: boolean;
  24822. SPHERICAL_HARMONICS: boolean;
  24823. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  24824. /** @hidden */
  24825. _areMiscDirty: boolean;
  24826. }
  24827. /**
  24828. * Define the code related to the BRDF parameters of the pbr material.
  24829. */
  24830. export class PBRBRDFConfiguration {
  24831. /**
  24832. * Default value used for the energy conservation.
  24833. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  24834. */
  24835. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  24836. /**
  24837. * Default value used for the Smith Visibility Height Correlated mode.
  24838. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  24839. */
  24840. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  24841. /**
  24842. * Default value used for the IBL diffuse part.
  24843. * This can help switching back to the polynomials mode globally which is a tiny bit
  24844. * less GPU intensive at the drawback of a lower quality.
  24845. */
  24846. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  24847. /**
  24848. * Default value used for activating energy conservation for the specular workflow.
  24849. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  24850. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  24851. */
  24852. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  24853. private _useEnergyConservation;
  24854. /**
  24855. * Defines if the material uses energy conservation.
  24856. */
  24857. useEnergyConservation: boolean;
  24858. private _useSmithVisibilityHeightCorrelated;
  24859. /**
  24860. * LEGACY Mode set to false
  24861. * Defines if the material uses height smith correlated visibility term.
  24862. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  24863. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  24864. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  24865. * Not relying on height correlated will also disable energy conservation.
  24866. */
  24867. useSmithVisibilityHeightCorrelated: boolean;
  24868. private _useSphericalHarmonics;
  24869. /**
  24870. * LEGACY Mode set to false
  24871. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  24872. * diffuse part of the IBL.
  24873. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  24874. * to the ground truth.
  24875. */
  24876. useSphericalHarmonics: boolean;
  24877. private _useSpecularGlossinessInputEnergyConservation;
  24878. /**
  24879. * Defines if the material uses energy conservation, when the specular workflow is active.
  24880. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  24881. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  24882. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  24883. */
  24884. useSpecularGlossinessInputEnergyConservation: boolean;
  24885. /** @hidden */
  24886. private _internalMarkAllSubMeshesAsMiscDirty;
  24887. /** @hidden */
  24888. _markAllSubMeshesAsMiscDirty(): void;
  24889. /**
  24890. * Instantiate a new istance of clear coat configuration.
  24891. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  24892. */
  24893. constructor(markAllSubMeshesAsMiscDirty: () => void);
  24894. /**
  24895. * Checks to see if a texture is used in the material.
  24896. * @param defines the list of "defines" to update.
  24897. */
  24898. prepareDefines(defines: IMaterialBRDFDefines): void;
  24899. /**
  24900. * Get the current class name of the texture useful for serialization or dynamic coding.
  24901. * @returns "PBRClearCoatConfiguration"
  24902. */
  24903. getClassName(): string;
  24904. /**
  24905. * Makes a duplicate of the current configuration into another one.
  24906. * @param brdfConfiguration define the config where to copy the info
  24907. */
  24908. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  24909. /**
  24910. * Serializes this BRDF configuration.
  24911. * @returns - An object with the serialized config.
  24912. */
  24913. serialize(): any;
  24914. /**
  24915. * Parses a anisotropy Configuration from a serialized object.
  24916. * @param source - Serialized object.
  24917. * @param scene Defines the scene we are parsing for
  24918. * @param rootUrl Defines the rootUrl to load from
  24919. */
  24920. parse(source: any, scene: Scene, rootUrl: string): void;
  24921. }
  24922. }
  24923. declare module BABYLON {
  24924. /**
  24925. * @hidden
  24926. */
  24927. export interface IMaterialSheenDefines {
  24928. SHEEN: boolean;
  24929. SHEEN_TEXTURE: boolean;
  24930. SHEEN_TEXTURE_ROUGHNESS: boolean;
  24931. SHEEN_TEXTUREDIRECTUV: number;
  24932. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  24933. SHEEN_LINKWITHALBEDO: boolean;
  24934. SHEEN_ROUGHNESS: boolean;
  24935. SHEEN_ALBEDOSCALING: boolean;
  24936. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24937. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24938. /** @hidden */
  24939. _areTexturesDirty: boolean;
  24940. }
  24941. /**
  24942. * Define the code related to the Sheen parameters of the pbr material.
  24943. */
  24944. export class PBRSheenConfiguration {
  24945. private _isEnabled;
  24946. /**
  24947. * Defines if the material uses sheen.
  24948. */
  24949. isEnabled: boolean;
  24950. private _linkSheenWithAlbedo;
  24951. /**
  24952. * Defines if the sheen is linked to the sheen color.
  24953. */
  24954. linkSheenWithAlbedo: boolean;
  24955. /**
  24956. * Defines the sheen intensity.
  24957. */
  24958. intensity: number;
  24959. /**
  24960. * Defines the sheen color.
  24961. */
  24962. color: Color3;
  24963. private _texture;
  24964. /**
  24965. * Stores the sheen tint values in a texture.
  24966. * rgb is tint
  24967. * 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)
  24968. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  24969. */
  24970. texture: Nullable<BaseTexture>;
  24971. private _useRoughnessFromMainTexture;
  24972. /**
  24973. * Indicates that the alpha channel of the texture property will be used for roughness.
  24974. * Has no effect if the roughness (and texture!) property is not defined
  24975. */
  24976. useRoughnessFromMainTexture: boolean;
  24977. private _roughness;
  24978. /**
  24979. * Defines the sheen roughness.
  24980. * It is not taken into account if linkSheenWithAlbedo is true.
  24981. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  24982. */
  24983. roughness: Nullable<number>;
  24984. private _textureRoughness;
  24985. /**
  24986. * Stores the sheen roughness in a texture.
  24987. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  24988. */
  24989. textureRoughness: Nullable<BaseTexture>;
  24990. private _albedoScaling;
  24991. /**
  24992. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  24993. * It allows the strength of the sheen effect to not depend on the base color of the material,
  24994. * making it easier to setup and tweak the effect
  24995. */
  24996. albedoScaling: boolean;
  24997. /** @hidden */
  24998. private _internalMarkAllSubMeshesAsTexturesDirty;
  24999. /** @hidden */
  25000. _markAllSubMeshesAsTexturesDirty(): void;
  25001. /**
  25002. * Instantiate a new istance of clear coat configuration.
  25003. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25004. */
  25005. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25006. /**
  25007. * Specifies that the submesh is ready to be used.
  25008. * @param defines the list of "defines" to update.
  25009. * @param scene defines the scene the material belongs to.
  25010. * @returns - boolean indicating that the submesh is ready or not.
  25011. */
  25012. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25013. /**
  25014. * Checks to see if a texture is used in the material.
  25015. * @param defines the list of "defines" to update.
  25016. * @param scene defines the scene the material belongs to.
  25017. */
  25018. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25019. /**
  25020. * Binds the material data.
  25021. * @param uniformBuffer defines the Uniform buffer to fill in.
  25022. * @param scene defines the scene the material belongs to.
  25023. * @param isFrozen defines wether the material is frozen or not.
  25024. * @param subMesh the submesh to bind data for
  25025. */
  25026. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25027. /**
  25028. * Checks to see if a texture is used in the material.
  25029. * @param texture - Base texture to use.
  25030. * @returns - Boolean specifying if a texture is used in the material.
  25031. */
  25032. hasTexture(texture: BaseTexture): boolean;
  25033. /**
  25034. * Returns an array of the actively used textures.
  25035. * @param activeTextures Array of BaseTextures
  25036. */
  25037. getActiveTextures(activeTextures: BaseTexture[]): void;
  25038. /**
  25039. * Returns the animatable textures.
  25040. * @param animatables Array of animatable textures.
  25041. */
  25042. getAnimatables(animatables: IAnimatable[]): void;
  25043. /**
  25044. * Disposes the resources of the material.
  25045. * @param forceDisposeTextures - Forces the disposal of all textures.
  25046. */
  25047. dispose(forceDisposeTextures?: boolean): void;
  25048. /**
  25049. * Get the current class name of the texture useful for serialization or dynamic coding.
  25050. * @returns "PBRSheenConfiguration"
  25051. */
  25052. getClassName(): string;
  25053. /**
  25054. * Add fallbacks to the effect fallbacks list.
  25055. * @param defines defines the Base texture to use.
  25056. * @param fallbacks defines the current fallback list.
  25057. * @param currentRank defines the current fallback rank.
  25058. * @returns the new fallback rank.
  25059. */
  25060. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25061. /**
  25062. * Add the required uniforms to the current list.
  25063. * @param uniforms defines the current uniform list.
  25064. */
  25065. static AddUniforms(uniforms: string[]): void;
  25066. /**
  25067. * Add the required uniforms to the current buffer.
  25068. * @param uniformBuffer defines the current uniform buffer.
  25069. */
  25070. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25071. /**
  25072. * Add the required samplers to the current list.
  25073. * @param samplers defines the current sampler list.
  25074. */
  25075. static AddSamplers(samplers: string[]): void;
  25076. /**
  25077. * Makes a duplicate of the current configuration into another one.
  25078. * @param sheenConfiguration define the config where to copy the info
  25079. */
  25080. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25081. /**
  25082. * Serializes this BRDF configuration.
  25083. * @returns - An object with the serialized config.
  25084. */
  25085. serialize(): any;
  25086. /**
  25087. * Parses a anisotropy Configuration from a serialized object.
  25088. * @param source - Serialized object.
  25089. * @param scene Defines the scene we are parsing for
  25090. * @param rootUrl Defines the rootUrl to load from
  25091. */
  25092. parse(source: any, scene: Scene, rootUrl: string): void;
  25093. }
  25094. }
  25095. declare module BABYLON {
  25096. /**
  25097. * @hidden
  25098. */
  25099. export interface IMaterialSubSurfaceDefines {
  25100. SUBSURFACE: boolean;
  25101. SS_REFRACTION: boolean;
  25102. SS_TRANSLUCENCY: boolean;
  25103. SS_SCATTERING: boolean;
  25104. SS_THICKNESSANDMASK_TEXTURE: boolean;
  25105. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  25106. SS_REFRACTIONMAP_3D: boolean;
  25107. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  25108. SS_LODINREFRACTIONALPHA: boolean;
  25109. SS_GAMMAREFRACTION: boolean;
  25110. SS_RGBDREFRACTION: boolean;
  25111. SS_LINEARSPECULARREFRACTION: boolean;
  25112. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  25113. SS_ALBEDOFORREFRACTIONTINT: boolean;
  25114. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  25115. /** @hidden */
  25116. _areTexturesDirty: boolean;
  25117. }
  25118. /**
  25119. * Define the code related to the sub surface parameters of the pbr material.
  25120. */
  25121. export class PBRSubSurfaceConfiguration {
  25122. private _isRefractionEnabled;
  25123. /**
  25124. * Defines if the refraction is enabled in the material.
  25125. */
  25126. isRefractionEnabled: boolean;
  25127. private _isTranslucencyEnabled;
  25128. /**
  25129. * Defines if the translucency is enabled in the material.
  25130. */
  25131. isTranslucencyEnabled: boolean;
  25132. private _isScatteringEnabled;
  25133. /**
  25134. * Defines if the sub surface scattering is enabled in the material.
  25135. */
  25136. isScatteringEnabled: boolean;
  25137. private _scatteringDiffusionProfileIndex;
  25138. /**
  25139. * Diffusion profile for subsurface scattering.
  25140. * Useful for better scattering in the skins or foliages.
  25141. */
  25142. get scatteringDiffusionProfile(): Nullable<Color3>;
  25143. set scatteringDiffusionProfile(c: Nullable<Color3>);
  25144. /**
  25145. * Defines the refraction intensity of the material.
  25146. * The refraction when enabled replaces the Diffuse part of the material.
  25147. * The intensity helps transitionning between diffuse and refraction.
  25148. */
  25149. refractionIntensity: number;
  25150. /**
  25151. * Defines the translucency intensity of the material.
  25152. * When translucency has been enabled, this defines how much of the "translucency"
  25153. * is addded to the diffuse part of the material.
  25154. */
  25155. translucencyIntensity: number;
  25156. /**
  25157. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  25158. */
  25159. useAlbedoToTintRefraction: boolean;
  25160. private _thicknessTexture;
  25161. /**
  25162. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  25163. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  25164. * 0 would mean minimumThickness
  25165. * 1 would mean maximumThickness
  25166. * The other channels might be use as a mask to vary the different effects intensity.
  25167. */
  25168. thicknessTexture: Nullable<BaseTexture>;
  25169. private _refractionTexture;
  25170. /**
  25171. * Defines the texture to use for refraction.
  25172. */
  25173. refractionTexture: Nullable<BaseTexture>;
  25174. private _indexOfRefraction;
  25175. /**
  25176. * Index of refraction of the material base layer.
  25177. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25178. *
  25179. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  25180. *
  25181. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  25182. */
  25183. indexOfRefraction: number;
  25184. private _volumeIndexOfRefraction;
  25185. /**
  25186. * Index of refraction of the material's volume.
  25187. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25188. *
  25189. * This ONLY impacts refraction. If not provided or given a non-valid value,
  25190. * the volume will use the same IOR as the surface.
  25191. */
  25192. get volumeIndexOfRefraction(): number;
  25193. set volumeIndexOfRefraction(value: number);
  25194. private _invertRefractionY;
  25195. /**
  25196. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  25197. */
  25198. invertRefractionY: boolean;
  25199. private _linkRefractionWithTransparency;
  25200. /**
  25201. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25202. * Materials half opaque for instance using refraction could benefit from this control.
  25203. */
  25204. linkRefractionWithTransparency: boolean;
  25205. /**
  25206. * Defines the minimum thickness stored in the thickness map.
  25207. * If no thickness map is defined, this value will be used to simulate thickness.
  25208. */
  25209. minimumThickness: number;
  25210. /**
  25211. * Defines the maximum thickness stored in the thickness map.
  25212. */
  25213. maximumThickness: number;
  25214. /**
  25215. * Defines the volume tint of the material.
  25216. * This is used for both translucency and scattering.
  25217. */
  25218. tintColor: Color3;
  25219. /**
  25220. * Defines the distance at which the tint color should be found in the media.
  25221. * This is used for refraction only.
  25222. */
  25223. tintColorAtDistance: number;
  25224. /**
  25225. * Defines how far each channel transmit through the media.
  25226. * It is defined as a color to simplify it selection.
  25227. */
  25228. diffusionDistance: Color3;
  25229. private _useMaskFromThicknessTexture;
  25230. /**
  25231. * Stores the intensity of the different subsurface effects in the thickness texture.
  25232. * * the green channel is the translucency intensity.
  25233. * * the blue channel is the scattering intensity.
  25234. * * the alpha channel is the refraction intensity.
  25235. */
  25236. useMaskFromThicknessTexture: boolean;
  25237. private _scene;
  25238. /** @hidden */
  25239. private _internalMarkAllSubMeshesAsTexturesDirty;
  25240. private _internalMarkScenePrePassDirty;
  25241. /** @hidden */
  25242. _markAllSubMeshesAsTexturesDirty(): void;
  25243. /** @hidden */
  25244. _markScenePrePassDirty(): void;
  25245. /**
  25246. * Instantiate a new istance of sub surface configuration.
  25247. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25248. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  25249. * @param scene The scene
  25250. */
  25251. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  25252. /**
  25253. * Gets wehter the submesh is ready to be used or not.
  25254. * @param defines the list of "defines" to update.
  25255. * @param scene defines the scene the material belongs to.
  25256. * @returns - boolean indicating that the submesh is ready or not.
  25257. */
  25258. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  25259. /**
  25260. * Checks to see if a texture is used in the material.
  25261. * @param defines the list of "defines" to update.
  25262. * @param scene defines the scene to the material belongs to.
  25263. */
  25264. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  25265. /**
  25266. * Binds the material data.
  25267. * @param uniformBuffer defines the Uniform buffer to fill in.
  25268. * @param scene defines the scene the material belongs to.
  25269. * @param engine defines the engine the material belongs to.
  25270. * @param isFrozen defines whether the material is frozen or not.
  25271. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  25272. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  25273. */
  25274. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  25275. /**
  25276. * Unbinds the material from the mesh.
  25277. * @param activeEffect defines the effect that should be unbound from.
  25278. * @returns true if unbound, otherwise false
  25279. */
  25280. unbind(activeEffect: Effect): boolean;
  25281. /**
  25282. * Returns the texture used for refraction or null if none is used.
  25283. * @param scene defines the scene the material belongs to.
  25284. * @returns - Refraction texture if present. If no refraction texture and refraction
  25285. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25286. */
  25287. private _getRefractionTexture;
  25288. /**
  25289. * Returns true if alpha blending should be disabled.
  25290. */
  25291. get disableAlphaBlending(): boolean;
  25292. /**
  25293. * Fills the list of render target textures.
  25294. * @param renderTargets the list of render targets to update
  25295. */
  25296. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  25297. /**
  25298. * Checks to see if a texture is used in the material.
  25299. * @param texture - Base texture to use.
  25300. * @returns - Boolean specifying if a texture is used in the material.
  25301. */
  25302. hasTexture(texture: BaseTexture): boolean;
  25303. /**
  25304. * Gets a boolean indicating that current material needs to register RTT
  25305. * @returns true if this uses a render target otherwise false.
  25306. */
  25307. hasRenderTargetTextures(): boolean;
  25308. /**
  25309. * Returns an array of the actively used textures.
  25310. * @param activeTextures Array of BaseTextures
  25311. */
  25312. getActiveTextures(activeTextures: BaseTexture[]): void;
  25313. /**
  25314. * Returns the animatable textures.
  25315. * @param animatables Array of animatable textures.
  25316. */
  25317. getAnimatables(animatables: IAnimatable[]): void;
  25318. /**
  25319. * Disposes the resources of the material.
  25320. * @param forceDisposeTextures - Forces the disposal of all textures.
  25321. */
  25322. dispose(forceDisposeTextures?: boolean): void;
  25323. /**
  25324. * Get the current class name of the texture useful for serialization or dynamic coding.
  25325. * @returns "PBRSubSurfaceConfiguration"
  25326. */
  25327. getClassName(): string;
  25328. /**
  25329. * Add fallbacks to the effect fallbacks list.
  25330. * @param defines defines the Base texture to use.
  25331. * @param fallbacks defines the current fallback list.
  25332. * @param currentRank defines the current fallback rank.
  25333. * @returns the new fallback rank.
  25334. */
  25335. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25336. /**
  25337. * Add the required uniforms to the current list.
  25338. * @param uniforms defines the current uniform list.
  25339. */
  25340. static AddUniforms(uniforms: string[]): void;
  25341. /**
  25342. * Add the required samplers to the current list.
  25343. * @param samplers defines the current sampler list.
  25344. */
  25345. static AddSamplers(samplers: string[]): void;
  25346. /**
  25347. * Add the required uniforms to the current buffer.
  25348. * @param uniformBuffer defines the current uniform buffer.
  25349. */
  25350. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25351. /**
  25352. * Makes a duplicate of the current configuration into another one.
  25353. * @param configuration define the config where to copy the info
  25354. */
  25355. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  25356. /**
  25357. * Serializes this Sub Surface configuration.
  25358. * @returns - An object with the serialized config.
  25359. */
  25360. serialize(): any;
  25361. /**
  25362. * Parses a anisotropy Configuration from a serialized object.
  25363. * @param source - Serialized object.
  25364. * @param scene Defines the scene we are parsing for
  25365. * @param rootUrl Defines the rootUrl to load from
  25366. */
  25367. parse(source: any, scene: Scene, rootUrl: string): void;
  25368. }
  25369. }
  25370. declare module BABYLON {
  25371. /**
  25372. * Class representing spherical harmonics coefficients to the 3rd degree
  25373. */
  25374. export class SphericalHarmonics {
  25375. /**
  25376. * Defines whether or not the harmonics have been prescaled for rendering.
  25377. */
  25378. preScaled: boolean;
  25379. /**
  25380. * The l0,0 coefficients of the spherical harmonics
  25381. */
  25382. l00: Vector3;
  25383. /**
  25384. * The l1,-1 coefficients of the spherical harmonics
  25385. */
  25386. l1_1: Vector3;
  25387. /**
  25388. * The l1,0 coefficients of the spherical harmonics
  25389. */
  25390. l10: Vector3;
  25391. /**
  25392. * The l1,1 coefficients of the spherical harmonics
  25393. */
  25394. l11: Vector3;
  25395. /**
  25396. * The l2,-2 coefficients of the spherical harmonics
  25397. */
  25398. l2_2: Vector3;
  25399. /**
  25400. * The l2,-1 coefficients of the spherical harmonics
  25401. */
  25402. l2_1: Vector3;
  25403. /**
  25404. * The l2,0 coefficients of the spherical harmonics
  25405. */
  25406. l20: Vector3;
  25407. /**
  25408. * The l2,1 coefficients of the spherical harmonics
  25409. */
  25410. l21: Vector3;
  25411. /**
  25412. * The l2,2 coefficients of the spherical harmonics
  25413. */
  25414. l22: Vector3;
  25415. /**
  25416. * Adds a light to the spherical harmonics
  25417. * @param direction the direction of the light
  25418. * @param color the color of the light
  25419. * @param deltaSolidAngle the delta solid angle of the light
  25420. */
  25421. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  25422. /**
  25423. * Scales the spherical harmonics by the given amount
  25424. * @param scale the amount to scale
  25425. */
  25426. scaleInPlace(scale: number): void;
  25427. /**
  25428. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  25429. *
  25430. * ```
  25431. * E_lm = A_l * L_lm
  25432. * ```
  25433. *
  25434. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  25435. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  25436. * the scaling factors are given in equation 9.
  25437. */
  25438. convertIncidentRadianceToIrradiance(): void;
  25439. /**
  25440. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  25441. *
  25442. * ```
  25443. * L = (1/pi) * E * rho
  25444. * ```
  25445. *
  25446. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  25447. */
  25448. convertIrradianceToLambertianRadiance(): void;
  25449. /**
  25450. * Integrates the reconstruction coefficients directly in to the SH preventing further
  25451. * required operations at run time.
  25452. *
  25453. * This is simply done by scaling back the SH with Ylm constants parameter.
  25454. * The trigonometric part being applied by the shader at run time.
  25455. */
  25456. preScaleForRendering(): void;
  25457. /**
  25458. * Constructs a spherical harmonics from an array.
  25459. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  25460. * @returns the spherical harmonics
  25461. */
  25462. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  25463. /**
  25464. * Gets the spherical harmonics from polynomial
  25465. * @param polynomial the spherical polynomial
  25466. * @returns the spherical harmonics
  25467. */
  25468. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  25469. }
  25470. /**
  25471. * Class representing spherical polynomial coefficients to the 3rd degree
  25472. */
  25473. export class SphericalPolynomial {
  25474. private _harmonics;
  25475. /**
  25476. * The spherical harmonics used to create the polynomials.
  25477. */
  25478. get preScaledHarmonics(): SphericalHarmonics;
  25479. /**
  25480. * The x coefficients of the spherical polynomial
  25481. */
  25482. x: Vector3;
  25483. /**
  25484. * The y coefficients of the spherical polynomial
  25485. */
  25486. y: Vector3;
  25487. /**
  25488. * The z coefficients of the spherical polynomial
  25489. */
  25490. z: Vector3;
  25491. /**
  25492. * The xx coefficients of the spherical polynomial
  25493. */
  25494. xx: Vector3;
  25495. /**
  25496. * The yy coefficients of the spherical polynomial
  25497. */
  25498. yy: Vector3;
  25499. /**
  25500. * The zz coefficients of the spherical polynomial
  25501. */
  25502. zz: Vector3;
  25503. /**
  25504. * The xy coefficients of the spherical polynomial
  25505. */
  25506. xy: Vector3;
  25507. /**
  25508. * The yz coefficients of the spherical polynomial
  25509. */
  25510. yz: Vector3;
  25511. /**
  25512. * The zx coefficients of the spherical polynomial
  25513. */
  25514. zx: Vector3;
  25515. /**
  25516. * Adds an ambient color to the spherical polynomial
  25517. * @param color the color to add
  25518. */
  25519. addAmbient(color: Color3): void;
  25520. /**
  25521. * Scales the spherical polynomial by the given amount
  25522. * @param scale the amount to scale
  25523. */
  25524. scaleInPlace(scale: number): void;
  25525. /**
  25526. * Gets the spherical polynomial from harmonics
  25527. * @param harmonics the spherical harmonics
  25528. * @returns the spherical polynomial
  25529. */
  25530. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  25531. /**
  25532. * Constructs a spherical polynomial from an array.
  25533. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  25534. * @returns the spherical polynomial
  25535. */
  25536. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  25537. }
  25538. }
  25539. declare module BABYLON {
  25540. /**
  25541. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  25542. */
  25543. export interface CubeMapInfo {
  25544. /**
  25545. * The pixel array for the front face.
  25546. * This is stored in format, left to right, up to down format.
  25547. */
  25548. front: Nullable<ArrayBufferView>;
  25549. /**
  25550. * The pixel array for the back face.
  25551. * This is stored in format, left to right, up to down format.
  25552. */
  25553. back: Nullable<ArrayBufferView>;
  25554. /**
  25555. * The pixel array for the left face.
  25556. * This is stored in format, left to right, up to down format.
  25557. */
  25558. left: Nullable<ArrayBufferView>;
  25559. /**
  25560. * The pixel array for the right face.
  25561. * This is stored in format, left to right, up to down format.
  25562. */
  25563. right: Nullable<ArrayBufferView>;
  25564. /**
  25565. * The pixel array for the up face.
  25566. * This is stored in format, left to right, up to down format.
  25567. */
  25568. up: Nullable<ArrayBufferView>;
  25569. /**
  25570. * The pixel array for the down face.
  25571. * This is stored in format, left to right, up to down format.
  25572. */
  25573. down: Nullable<ArrayBufferView>;
  25574. /**
  25575. * The size of the cubemap stored.
  25576. *
  25577. * Each faces will be size * size pixels.
  25578. */
  25579. size: number;
  25580. /**
  25581. * The format of the texture.
  25582. *
  25583. * RGBA, RGB.
  25584. */
  25585. format: number;
  25586. /**
  25587. * The type of the texture data.
  25588. *
  25589. * UNSIGNED_INT, FLOAT.
  25590. */
  25591. type: number;
  25592. /**
  25593. * Specifies whether the texture is in gamma space.
  25594. */
  25595. gammaSpace: boolean;
  25596. }
  25597. /**
  25598. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  25599. */
  25600. export class PanoramaToCubeMapTools {
  25601. private static FACE_LEFT;
  25602. private static FACE_RIGHT;
  25603. private static FACE_FRONT;
  25604. private static FACE_BACK;
  25605. private static FACE_DOWN;
  25606. private static FACE_UP;
  25607. /**
  25608. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  25609. *
  25610. * @param float32Array The source data.
  25611. * @param inputWidth The width of the input panorama.
  25612. * @param inputHeight The height of the input panorama.
  25613. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  25614. * @return The cubemap data
  25615. */
  25616. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  25617. private static CreateCubemapTexture;
  25618. private static CalcProjectionSpherical;
  25619. }
  25620. }
  25621. declare module BABYLON {
  25622. /**
  25623. * Helper class dealing with the extraction of spherical polynomial dataArray
  25624. * from a cube map.
  25625. */
  25626. export class CubeMapToSphericalPolynomialTools {
  25627. private static FileFaces;
  25628. /**
  25629. * Converts a texture to the according Spherical Polynomial data.
  25630. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25631. *
  25632. * @param texture The texture to extract the information from.
  25633. * @return The Spherical Polynomial data.
  25634. */
  25635. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  25636. /**
  25637. * Converts a cubemap to the according Spherical Polynomial data.
  25638. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25639. *
  25640. * @param cubeInfo The Cube map to extract the information from.
  25641. * @return The Spherical Polynomial data.
  25642. */
  25643. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  25644. }
  25645. }
  25646. declare module BABYLON {
  25647. interface BaseTexture {
  25648. /**
  25649. * Get the polynomial representation of the texture data.
  25650. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25651. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25652. */
  25653. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25654. }
  25655. }
  25656. declare module BABYLON {
  25657. /** @hidden */
  25658. export var pbrFragmentDeclaration: {
  25659. name: string;
  25660. shader: string;
  25661. };
  25662. }
  25663. declare module BABYLON {
  25664. /** @hidden */
  25665. export var pbrUboDeclaration: {
  25666. name: string;
  25667. shader: string;
  25668. };
  25669. }
  25670. declare module BABYLON {
  25671. /** @hidden */
  25672. export var pbrFragmentExtraDeclaration: {
  25673. name: string;
  25674. shader: string;
  25675. };
  25676. }
  25677. declare module BABYLON {
  25678. /** @hidden */
  25679. export var pbrFragmentSamplersDeclaration: {
  25680. name: string;
  25681. shader: string;
  25682. };
  25683. }
  25684. declare module BABYLON {
  25685. /** @hidden */
  25686. export var subSurfaceScatteringFunctions: {
  25687. name: string;
  25688. shader: string;
  25689. };
  25690. }
  25691. declare module BABYLON {
  25692. /** @hidden */
  25693. export var importanceSampling: {
  25694. name: string;
  25695. shader: string;
  25696. };
  25697. }
  25698. declare module BABYLON {
  25699. /** @hidden */
  25700. export var pbrHelperFunctions: {
  25701. name: string;
  25702. shader: string;
  25703. };
  25704. }
  25705. declare module BABYLON {
  25706. /** @hidden */
  25707. export var harmonicsFunctions: {
  25708. name: string;
  25709. shader: string;
  25710. };
  25711. }
  25712. declare module BABYLON {
  25713. /** @hidden */
  25714. export var pbrDirectLightingSetupFunctions: {
  25715. name: string;
  25716. shader: string;
  25717. };
  25718. }
  25719. declare module BABYLON {
  25720. /** @hidden */
  25721. export var pbrDirectLightingFalloffFunctions: {
  25722. name: string;
  25723. shader: string;
  25724. };
  25725. }
  25726. declare module BABYLON {
  25727. /** @hidden */
  25728. export var pbrBRDFFunctions: {
  25729. name: string;
  25730. shader: string;
  25731. };
  25732. }
  25733. declare module BABYLON {
  25734. /** @hidden */
  25735. export var hdrFilteringFunctions: {
  25736. name: string;
  25737. shader: string;
  25738. };
  25739. }
  25740. declare module BABYLON {
  25741. /** @hidden */
  25742. export var pbrDirectLightingFunctions: {
  25743. name: string;
  25744. shader: string;
  25745. };
  25746. }
  25747. declare module BABYLON {
  25748. /** @hidden */
  25749. export var pbrIBLFunctions: {
  25750. name: string;
  25751. shader: string;
  25752. };
  25753. }
  25754. declare module BABYLON {
  25755. /** @hidden */
  25756. export var pbrBlockAlbedoOpacity: {
  25757. name: string;
  25758. shader: string;
  25759. };
  25760. }
  25761. declare module BABYLON {
  25762. /** @hidden */
  25763. export var pbrBlockReflectivity: {
  25764. name: string;
  25765. shader: string;
  25766. };
  25767. }
  25768. declare module BABYLON {
  25769. /** @hidden */
  25770. export var pbrBlockAmbientOcclusion: {
  25771. name: string;
  25772. shader: string;
  25773. };
  25774. }
  25775. declare module BABYLON {
  25776. /** @hidden */
  25777. export var pbrBlockAlphaFresnel: {
  25778. name: string;
  25779. shader: string;
  25780. };
  25781. }
  25782. declare module BABYLON {
  25783. /** @hidden */
  25784. export var pbrBlockAnisotropic: {
  25785. name: string;
  25786. shader: string;
  25787. };
  25788. }
  25789. declare module BABYLON {
  25790. /** @hidden */
  25791. export var pbrBlockReflection: {
  25792. name: string;
  25793. shader: string;
  25794. };
  25795. }
  25796. declare module BABYLON {
  25797. /** @hidden */
  25798. export var pbrBlockSheen: {
  25799. name: string;
  25800. shader: string;
  25801. };
  25802. }
  25803. declare module BABYLON {
  25804. /** @hidden */
  25805. export var pbrBlockClearcoat: {
  25806. name: string;
  25807. shader: string;
  25808. };
  25809. }
  25810. declare module BABYLON {
  25811. /** @hidden */
  25812. export var pbrBlockSubSurface: {
  25813. name: string;
  25814. shader: string;
  25815. };
  25816. }
  25817. declare module BABYLON {
  25818. /** @hidden */
  25819. export var pbrBlockNormalGeometric: {
  25820. name: string;
  25821. shader: string;
  25822. };
  25823. }
  25824. declare module BABYLON {
  25825. /** @hidden */
  25826. export var pbrBlockNormalFinal: {
  25827. name: string;
  25828. shader: string;
  25829. };
  25830. }
  25831. declare module BABYLON {
  25832. /** @hidden */
  25833. export var pbrBlockLightmapInit: {
  25834. name: string;
  25835. shader: string;
  25836. };
  25837. }
  25838. declare module BABYLON {
  25839. /** @hidden */
  25840. export var pbrBlockGeometryInfo: {
  25841. name: string;
  25842. shader: string;
  25843. };
  25844. }
  25845. declare module BABYLON {
  25846. /** @hidden */
  25847. export var pbrBlockReflectance0: {
  25848. name: string;
  25849. shader: string;
  25850. };
  25851. }
  25852. declare module BABYLON {
  25853. /** @hidden */
  25854. export var pbrBlockReflectance: {
  25855. name: string;
  25856. shader: string;
  25857. };
  25858. }
  25859. declare module BABYLON {
  25860. /** @hidden */
  25861. export var pbrBlockDirectLighting: {
  25862. name: string;
  25863. shader: string;
  25864. };
  25865. }
  25866. declare module BABYLON {
  25867. /** @hidden */
  25868. export var pbrBlockFinalLitComponents: {
  25869. name: string;
  25870. shader: string;
  25871. };
  25872. }
  25873. declare module BABYLON {
  25874. /** @hidden */
  25875. export var pbrBlockFinalUnlitComponents: {
  25876. name: string;
  25877. shader: string;
  25878. };
  25879. }
  25880. declare module BABYLON {
  25881. /** @hidden */
  25882. export var pbrBlockFinalColorComposition: {
  25883. name: string;
  25884. shader: string;
  25885. };
  25886. }
  25887. declare module BABYLON {
  25888. /** @hidden */
  25889. export var pbrBlockImageProcessing: {
  25890. name: string;
  25891. shader: string;
  25892. };
  25893. }
  25894. declare module BABYLON {
  25895. /** @hidden */
  25896. export var pbrDebug: {
  25897. name: string;
  25898. shader: string;
  25899. };
  25900. }
  25901. declare module BABYLON {
  25902. /** @hidden */
  25903. export var pbrPixelShader: {
  25904. name: string;
  25905. shader: string;
  25906. };
  25907. }
  25908. declare module BABYLON {
  25909. /** @hidden */
  25910. export var pbrVertexDeclaration: {
  25911. name: string;
  25912. shader: string;
  25913. };
  25914. }
  25915. declare module BABYLON {
  25916. /** @hidden */
  25917. export var pbrVertexShader: {
  25918. name: string;
  25919. shader: string;
  25920. };
  25921. }
  25922. declare module BABYLON {
  25923. /**
  25924. * Manages the defines for the PBR Material.
  25925. * @hidden
  25926. */
  25927. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  25928. PBR: boolean;
  25929. NUM_SAMPLES: string;
  25930. REALTIME_FILTERING: boolean;
  25931. MAINUV1: boolean;
  25932. MAINUV2: boolean;
  25933. UV1: boolean;
  25934. UV2: boolean;
  25935. ALBEDO: boolean;
  25936. GAMMAALBEDO: boolean;
  25937. ALBEDODIRECTUV: number;
  25938. VERTEXCOLOR: boolean;
  25939. DETAIL: boolean;
  25940. DETAILDIRECTUV: number;
  25941. DETAIL_NORMALBLENDMETHOD: number;
  25942. AMBIENT: boolean;
  25943. AMBIENTDIRECTUV: number;
  25944. AMBIENTINGRAYSCALE: boolean;
  25945. OPACITY: boolean;
  25946. VERTEXALPHA: boolean;
  25947. OPACITYDIRECTUV: number;
  25948. OPACITYRGB: boolean;
  25949. ALPHATEST: boolean;
  25950. DEPTHPREPASS: boolean;
  25951. ALPHABLEND: boolean;
  25952. ALPHAFROMALBEDO: boolean;
  25953. ALPHATESTVALUE: string;
  25954. SPECULAROVERALPHA: boolean;
  25955. RADIANCEOVERALPHA: boolean;
  25956. ALPHAFRESNEL: boolean;
  25957. LINEARALPHAFRESNEL: boolean;
  25958. PREMULTIPLYALPHA: boolean;
  25959. EMISSIVE: boolean;
  25960. EMISSIVEDIRECTUV: number;
  25961. REFLECTIVITY: boolean;
  25962. REFLECTIVITYDIRECTUV: number;
  25963. SPECULARTERM: boolean;
  25964. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  25965. MICROSURFACEAUTOMATIC: boolean;
  25966. LODBASEDMICROSFURACE: boolean;
  25967. MICROSURFACEMAP: boolean;
  25968. MICROSURFACEMAPDIRECTUV: number;
  25969. METALLICWORKFLOW: boolean;
  25970. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  25971. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  25972. METALLNESSSTOREINMETALMAPBLUE: boolean;
  25973. AOSTOREINMETALMAPRED: boolean;
  25974. METALLIC_REFLECTANCE: boolean;
  25975. METALLIC_REFLECTANCEDIRECTUV: number;
  25976. ENVIRONMENTBRDF: boolean;
  25977. ENVIRONMENTBRDF_RGBD: boolean;
  25978. NORMAL: boolean;
  25979. TANGENT: boolean;
  25980. BUMP: boolean;
  25981. BUMPDIRECTUV: number;
  25982. OBJECTSPACE_NORMALMAP: boolean;
  25983. PARALLAX: boolean;
  25984. PARALLAXOCCLUSION: boolean;
  25985. NORMALXYSCALE: boolean;
  25986. LIGHTMAP: boolean;
  25987. LIGHTMAPDIRECTUV: number;
  25988. USELIGHTMAPASSHADOWMAP: boolean;
  25989. GAMMALIGHTMAP: boolean;
  25990. RGBDLIGHTMAP: boolean;
  25991. REFLECTION: boolean;
  25992. REFLECTIONMAP_3D: boolean;
  25993. REFLECTIONMAP_SPHERICAL: boolean;
  25994. REFLECTIONMAP_PLANAR: boolean;
  25995. REFLECTIONMAP_CUBIC: boolean;
  25996. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  25997. REFLECTIONMAP_PROJECTION: boolean;
  25998. REFLECTIONMAP_SKYBOX: boolean;
  25999. REFLECTIONMAP_EXPLICIT: boolean;
  26000. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26001. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26002. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26003. INVERTCUBICMAP: boolean;
  26004. USESPHERICALFROMREFLECTIONMAP: boolean;
  26005. USEIRRADIANCEMAP: boolean;
  26006. SPHERICAL_HARMONICS: boolean;
  26007. USESPHERICALINVERTEX: boolean;
  26008. REFLECTIONMAP_OPPOSITEZ: boolean;
  26009. LODINREFLECTIONALPHA: boolean;
  26010. GAMMAREFLECTION: boolean;
  26011. RGBDREFLECTION: boolean;
  26012. LINEARSPECULARREFLECTION: boolean;
  26013. RADIANCEOCCLUSION: boolean;
  26014. HORIZONOCCLUSION: boolean;
  26015. INSTANCES: boolean;
  26016. THIN_INSTANCES: boolean;
  26017. PREPASS: boolean;
  26018. PREPASS_IRRADIANCE: boolean;
  26019. PREPASS_IRRADIANCE_INDEX: number;
  26020. PREPASS_ALBEDO: boolean;
  26021. PREPASS_ALBEDO_INDEX: number;
  26022. PREPASS_DEPTHNORMAL: boolean;
  26023. PREPASS_DEPTHNORMAL_INDEX: number;
  26024. PREPASS_POSITION: boolean;
  26025. PREPASS_POSITION_INDEX: number;
  26026. PREPASS_VELOCITY: boolean;
  26027. PREPASS_VELOCITY_INDEX: number;
  26028. PREPASS_REFLECTIVITY: boolean;
  26029. PREPASS_REFLECTIVITY_INDEX: number;
  26030. SCENE_MRT_COUNT: number;
  26031. NUM_BONE_INFLUENCERS: number;
  26032. BonesPerMesh: number;
  26033. BONETEXTURE: boolean;
  26034. BONES_VELOCITY_ENABLED: boolean;
  26035. NONUNIFORMSCALING: boolean;
  26036. MORPHTARGETS: boolean;
  26037. MORPHTARGETS_NORMAL: boolean;
  26038. MORPHTARGETS_TANGENT: boolean;
  26039. MORPHTARGETS_UV: boolean;
  26040. NUM_MORPH_INFLUENCERS: number;
  26041. IMAGEPROCESSING: boolean;
  26042. VIGNETTE: boolean;
  26043. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26044. VIGNETTEBLENDMODEOPAQUE: boolean;
  26045. TONEMAPPING: boolean;
  26046. TONEMAPPING_ACES: boolean;
  26047. CONTRAST: boolean;
  26048. COLORCURVES: boolean;
  26049. COLORGRADING: boolean;
  26050. COLORGRADING3D: boolean;
  26051. SAMPLER3DGREENDEPTH: boolean;
  26052. SAMPLER3DBGRMAP: boolean;
  26053. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26054. EXPOSURE: boolean;
  26055. MULTIVIEW: boolean;
  26056. USEPHYSICALLIGHTFALLOFF: boolean;
  26057. USEGLTFLIGHTFALLOFF: boolean;
  26058. TWOSIDEDLIGHTING: boolean;
  26059. SHADOWFLOAT: boolean;
  26060. CLIPPLANE: boolean;
  26061. CLIPPLANE2: boolean;
  26062. CLIPPLANE3: boolean;
  26063. CLIPPLANE4: boolean;
  26064. CLIPPLANE5: boolean;
  26065. CLIPPLANE6: boolean;
  26066. POINTSIZE: boolean;
  26067. FOG: boolean;
  26068. LOGARITHMICDEPTH: boolean;
  26069. FORCENORMALFORWARD: boolean;
  26070. SPECULARAA: boolean;
  26071. CLEARCOAT: boolean;
  26072. CLEARCOAT_DEFAULTIOR: boolean;
  26073. CLEARCOAT_TEXTURE: boolean;
  26074. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  26075. CLEARCOAT_TEXTUREDIRECTUV: number;
  26076. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  26077. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26078. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26079. CLEARCOAT_BUMP: boolean;
  26080. CLEARCOAT_BUMPDIRECTUV: number;
  26081. CLEARCOAT_REMAP_F0: boolean;
  26082. CLEARCOAT_TINT: boolean;
  26083. CLEARCOAT_TINT_TEXTURE: boolean;
  26084. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  26085. ANISOTROPIC: boolean;
  26086. ANISOTROPIC_TEXTURE: boolean;
  26087. ANISOTROPIC_TEXTUREDIRECTUV: number;
  26088. BRDF_V_HEIGHT_CORRELATED: boolean;
  26089. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26090. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26091. SHEEN: boolean;
  26092. SHEEN_TEXTURE: boolean;
  26093. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26094. SHEEN_TEXTUREDIRECTUV: number;
  26095. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26096. SHEEN_LINKWITHALBEDO: boolean;
  26097. SHEEN_ROUGHNESS: boolean;
  26098. SHEEN_ALBEDOSCALING: boolean;
  26099. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26100. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26101. SUBSURFACE: boolean;
  26102. SS_REFRACTION: boolean;
  26103. SS_TRANSLUCENCY: boolean;
  26104. SS_SCATTERING: boolean;
  26105. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26106. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26107. SS_REFRACTIONMAP_3D: boolean;
  26108. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26109. SS_LODINREFRACTIONALPHA: boolean;
  26110. SS_GAMMAREFRACTION: boolean;
  26111. SS_RGBDREFRACTION: boolean;
  26112. SS_LINEARSPECULARREFRACTION: boolean;
  26113. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26114. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26115. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26116. UNLIT: boolean;
  26117. DEBUGMODE: number;
  26118. /**
  26119. * Initializes the PBR Material defines.
  26120. */
  26121. constructor();
  26122. /**
  26123. * Resets the PBR Material defines.
  26124. */
  26125. reset(): void;
  26126. }
  26127. /**
  26128. * The Physically based material base class of BJS.
  26129. *
  26130. * This offers the main features of a standard PBR material.
  26131. * For more information, please refer to the documentation :
  26132. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26133. */
  26134. export abstract class PBRBaseMaterial extends PushMaterial {
  26135. /**
  26136. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26137. */
  26138. static readonly PBRMATERIAL_OPAQUE: number;
  26139. /**
  26140. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26141. */
  26142. static readonly PBRMATERIAL_ALPHATEST: number;
  26143. /**
  26144. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26145. */
  26146. static readonly PBRMATERIAL_ALPHABLEND: number;
  26147. /**
  26148. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26149. * They are also discarded below the alpha cutoff threshold to improve performances.
  26150. */
  26151. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26152. /**
  26153. * Defines the default value of how much AO map is occluding the analytical lights
  26154. * (point spot...).
  26155. */
  26156. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26157. /**
  26158. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  26159. */
  26160. static readonly LIGHTFALLOFF_PHYSICAL: number;
  26161. /**
  26162. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  26163. * to enhance interoperability with other engines.
  26164. */
  26165. static readonly LIGHTFALLOFF_GLTF: number;
  26166. /**
  26167. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  26168. * to enhance interoperability with other materials.
  26169. */
  26170. static readonly LIGHTFALLOFF_STANDARD: number;
  26171. /**
  26172. * Intensity of the direct lights e.g. the four lights available in your scene.
  26173. * This impacts both the direct diffuse and specular highlights.
  26174. */
  26175. protected _directIntensity: number;
  26176. /**
  26177. * Intensity of the emissive part of the material.
  26178. * This helps controlling the emissive effect without modifying the emissive color.
  26179. */
  26180. protected _emissiveIntensity: number;
  26181. /**
  26182. * Intensity of the environment e.g. how much the environment will light the object
  26183. * either through harmonics for rough material or through the refelction for shiny ones.
  26184. */
  26185. protected _environmentIntensity: number;
  26186. /**
  26187. * This is a special control allowing the reduction of the specular highlights coming from the
  26188. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26189. */
  26190. protected _specularIntensity: number;
  26191. /**
  26192. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  26193. */
  26194. private _lightingInfos;
  26195. /**
  26196. * Debug Control allowing disabling the bump map on this material.
  26197. */
  26198. protected _disableBumpMap: boolean;
  26199. /**
  26200. * AKA Diffuse Texture in standard nomenclature.
  26201. */
  26202. protected _albedoTexture: Nullable<BaseTexture>;
  26203. /**
  26204. * AKA Occlusion Texture in other nomenclature.
  26205. */
  26206. protected _ambientTexture: Nullable<BaseTexture>;
  26207. /**
  26208. * AKA Occlusion Texture Intensity in other nomenclature.
  26209. */
  26210. protected _ambientTextureStrength: number;
  26211. /**
  26212. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26213. * 1 means it completely occludes it
  26214. * 0 mean it has no impact
  26215. */
  26216. protected _ambientTextureImpactOnAnalyticalLights: number;
  26217. /**
  26218. * Stores the alpha values in a texture.
  26219. */
  26220. protected _opacityTexture: Nullable<BaseTexture>;
  26221. /**
  26222. * Stores the reflection values in a texture.
  26223. */
  26224. protected _reflectionTexture: Nullable<BaseTexture>;
  26225. /**
  26226. * Stores the emissive values in a texture.
  26227. */
  26228. protected _emissiveTexture: Nullable<BaseTexture>;
  26229. /**
  26230. * AKA Specular texture in other nomenclature.
  26231. */
  26232. protected _reflectivityTexture: Nullable<BaseTexture>;
  26233. /**
  26234. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26235. */
  26236. protected _metallicTexture: Nullable<BaseTexture>;
  26237. /**
  26238. * Specifies the metallic scalar of the metallic/roughness workflow.
  26239. * Can also be used to scale the metalness values of the metallic texture.
  26240. */
  26241. protected _metallic: Nullable<number>;
  26242. /**
  26243. * Specifies the roughness scalar of the metallic/roughness workflow.
  26244. * Can also be used to scale the roughness values of the metallic texture.
  26245. */
  26246. protected _roughness: Nullable<number>;
  26247. /**
  26248. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26249. * By default the indexOfrefraction is used to compute F0;
  26250. *
  26251. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26252. *
  26253. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26254. * F90 = metallicReflectanceColor;
  26255. */
  26256. protected _metallicF0Factor: number;
  26257. /**
  26258. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26259. * By default the F90 is always 1;
  26260. *
  26261. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26262. *
  26263. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26264. * F90 = metallicReflectanceColor;
  26265. */
  26266. protected _metallicReflectanceColor: Color3;
  26267. /**
  26268. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26269. * This is multiply against the scalar values defined in the material.
  26270. */
  26271. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  26272. /**
  26273. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26274. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26275. */
  26276. protected _microSurfaceTexture: Nullable<BaseTexture>;
  26277. /**
  26278. * Stores surface normal data used to displace a mesh in a texture.
  26279. */
  26280. protected _bumpTexture: Nullable<BaseTexture>;
  26281. /**
  26282. * Stores the pre-calculated light information of a mesh in a texture.
  26283. */
  26284. protected _lightmapTexture: Nullable<BaseTexture>;
  26285. /**
  26286. * The color of a material in ambient lighting.
  26287. */
  26288. protected _ambientColor: Color3;
  26289. /**
  26290. * AKA Diffuse Color in other nomenclature.
  26291. */
  26292. protected _albedoColor: Color3;
  26293. /**
  26294. * AKA Specular Color in other nomenclature.
  26295. */
  26296. protected _reflectivityColor: Color3;
  26297. /**
  26298. * The color applied when light is reflected from a material.
  26299. */
  26300. protected _reflectionColor: Color3;
  26301. /**
  26302. * The color applied when light is emitted from a material.
  26303. */
  26304. protected _emissiveColor: Color3;
  26305. /**
  26306. * AKA Glossiness in other nomenclature.
  26307. */
  26308. protected _microSurface: number;
  26309. /**
  26310. * Specifies that the material will use the light map as a show map.
  26311. */
  26312. protected _useLightmapAsShadowmap: boolean;
  26313. /**
  26314. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26315. * makes the reflect vector face the model (under horizon).
  26316. */
  26317. protected _useHorizonOcclusion: boolean;
  26318. /**
  26319. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26320. * too much the area relying on ambient texture to define their ambient occlusion.
  26321. */
  26322. protected _useRadianceOcclusion: boolean;
  26323. /**
  26324. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26325. */
  26326. protected _useAlphaFromAlbedoTexture: boolean;
  26327. /**
  26328. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26329. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26330. */
  26331. protected _useSpecularOverAlpha: boolean;
  26332. /**
  26333. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26334. */
  26335. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26336. /**
  26337. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26338. */
  26339. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  26340. /**
  26341. * Specifies if the metallic texture contains the roughness information in its green channel.
  26342. */
  26343. protected _useRoughnessFromMetallicTextureGreen: boolean;
  26344. /**
  26345. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26346. */
  26347. protected _useMetallnessFromMetallicTextureBlue: boolean;
  26348. /**
  26349. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26350. */
  26351. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  26352. /**
  26353. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26354. */
  26355. protected _useAmbientInGrayScale: boolean;
  26356. /**
  26357. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26358. * The material will try to infer what glossiness each pixel should be.
  26359. */
  26360. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  26361. /**
  26362. * Defines the falloff type used in this material.
  26363. * It by default is Physical.
  26364. */
  26365. protected _lightFalloff: number;
  26366. /**
  26367. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26368. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26369. */
  26370. protected _useRadianceOverAlpha: boolean;
  26371. /**
  26372. * Allows using an object space normal map (instead of tangent space).
  26373. */
  26374. protected _useObjectSpaceNormalMap: boolean;
  26375. /**
  26376. * Allows using the bump map in parallax mode.
  26377. */
  26378. protected _useParallax: boolean;
  26379. /**
  26380. * Allows using the bump map in parallax occlusion mode.
  26381. */
  26382. protected _useParallaxOcclusion: boolean;
  26383. /**
  26384. * Controls the scale bias of the parallax mode.
  26385. */
  26386. protected _parallaxScaleBias: number;
  26387. /**
  26388. * If sets to true, disables all the lights affecting the material.
  26389. */
  26390. protected _disableLighting: boolean;
  26391. /**
  26392. * Number of Simultaneous lights allowed on the material.
  26393. */
  26394. protected _maxSimultaneousLights: number;
  26395. /**
  26396. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  26397. */
  26398. protected _invertNormalMapX: boolean;
  26399. /**
  26400. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  26401. */
  26402. protected _invertNormalMapY: boolean;
  26403. /**
  26404. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26405. */
  26406. protected _twoSidedLighting: boolean;
  26407. /**
  26408. * Defines the alpha limits in alpha test mode.
  26409. */
  26410. protected _alphaCutOff: number;
  26411. /**
  26412. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26413. */
  26414. protected _forceAlphaTest: boolean;
  26415. /**
  26416. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26417. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26418. */
  26419. protected _useAlphaFresnel: boolean;
  26420. /**
  26421. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26422. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26423. */
  26424. protected _useLinearAlphaFresnel: boolean;
  26425. /**
  26426. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26427. * from cos thetav and roughness:
  26428. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26429. */
  26430. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26431. /**
  26432. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26433. */
  26434. protected _forceIrradianceInFragment: boolean;
  26435. private _realTimeFiltering;
  26436. /**
  26437. * Enables realtime filtering on the texture.
  26438. */
  26439. get realTimeFiltering(): boolean;
  26440. set realTimeFiltering(b: boolean);
  26441. private _realTimeFilteringQuality;
  26442. /**
  26443. * Quality switch for realtime filtering
  26444. */
  26445. get realTimeFilteringQuality(): number;
  26446. set realTimeFilteringQuality(n: number);
  26447. /**
  26448. * Can this material render to several textures at once
  26449. */
  26450. get canRenderToMRT(): boolean;
  26451. /**
  26452. * Force normal to face away from face.
  26453. */
  26454. protected _forceNormalForward: boolean;
  26455. /**
  26456. * Enables specular anti aliasing in the PBR shader.
  26457. * It will both interacts on the Geometry for analytical and IBL lighting.
  26458. * It also prefilter the roughness map based on the bump values.
  26459. */
  26460. protected _enableSpecularAntiAliasing: boolean;
  26461. /**
  26462. * Default configuration related to image processing available in the PBR Material.
  26463. */
  26464. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26465. /**
  26466. * Keep track of the image processing observer to allow dispose and replace.
  26467. */
  26468. private _imageProcessingObserver;
  26469. /**
  26470. * Attaches a new image processing configuration to the PBR Material.
  26471. * @param configuration
  26472. */
  26473. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26474. /**
  26475. * Stores the available render targets.
  26476. */
  26477. private _renderTargets;
  26478. /**
  26479. * Sets the global ambient color for the material used in lighting calculations.
  26480. */
  26481. private _globalAmbientColor;
  26482. /**
  26483. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26484. */
  26485. private _useLogarithmicDepth;
  26486. /**
  26487. * If set to true, no lighting calculations will be applied.
  26488. */
  26489. private _unlit;
  26490. private _debugMode;
  26491. /**
  26492. * @hidden
  26493. * This is reserved for the inspector.
  26494. * Defines the material debug mode.
  26495. * It helps seeing only some components of the material while troubleshooting.
  26496. */
  26497. debugMode: number;
  26498. /**
  26499. * @hidden
  26500. * This is reserved for the inspector.
  26501. * Specify from where on screen the debug mode should start.
  26502. * The value goes from -1 (full screen) to 1 (not visible)
  26503. * It helps with side by side comparison against the final render
  26504. * This defaults to -1
  26505. */
  26506. private debugLimit;
  26507. /**
  26508. * @hidden
  26509. * This is reserved for the inspector.
  26510. * As the default viewing range might not be enough (if the ambient is really small for instance)
  26511. * You can use the factor to better multiply the final value.
  26512. */
  26513. private debugFactor;
  26514. /**
  26515. * Defines the clear coat layer parameters for the material.
  26516. */
  26517. readonly clearCoat: PBRClearCoatConfiguration;
  26518. /**
  26519. * Defines the anisotropic parameters for the material.
  26520. */
  26521. readonly anisotropy: PBRAnisotropicConfiguration;
  26522. /**
  26523. * Defines the BRDF parameters for the material.
  26524. */
  26525. readonly brdf: PBRBRDFConfiguration;
  26526. /**
  26527. * Defines the Sheen parameters for the material.
  26528. */
  26529. readonly sheen: PBRSheenConfiguration;
  26530. /**
  26531. * Defines the SubSurface parameters for the material.
  26532. */
  26533. readonly subSurface: PBRSubSurfaceConfiguration;
  26534. /**
  26535. * Defines additionnal PrePass parameters for the material.
  26536. */
  26537. readonly prePassConfiguration: PrePassConfiguration;
  26538. /**
  26539. * Defines the detail map parameters for the material.
  26540. */
  26541. readonly detailMap: DetailMapConfiguration;
  26542. protected _rebuildInParallel: boolean;
  26543. /**
  26544. * Instantiates a new PBRMaterial instance.
  26545. *
  26546. * @param name The material name
  26547. * @param scene The scene the material will be use in.
  26548. */
  26549. constructor(name: string, scene: Scene);
  26550. /**
  26551. * Gets a boolean indicating that current material needs to register RTT
  26552. */
  26553. get hasRenderTargetTextures(): boolean;
  26554. /**
  26555. * Gets the name of the material class.
  26556. */
  26557. getClassName(): string;
  26558. /**
  26559. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26560. */
  26561. get useLogarithmicDepth(): boolean;
  26562. /**
  26563. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26564. */
  26565. set useLogarithmicDepth(value: boolean);
  26566. /**
  26567. * Returns true if alpha blending should be disabled.
  26568. */
  26569. protected get _disableAlphaBlending(): boolean;
  26570. /**
  26571. * Specifies whether or not this material should be rendered in alpha blend mode.
  26572. */
  26573. needAlphaBlending(): boolean;
  26574. /**
  26575. * Specifies whether or not this material should be rendered in alpha test mode.
  26576. */
  26577. needAlphaTesting(): boolean;
  26578. /**
  26579. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26580. */
  26581. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26582. /**
  26583. * Gets the texture used for the alpha test.
  26584. */
  26585. getAlphaTestTexture(): Nullable<BaseTexture>;
  26586. /**
  26587. * Specifies that the submesh is ready to be used.
  26588. * @param mesh - BJS mesh.
  26589. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26590. * @param useInstances - Specifies that instances should be used.
  26591. * @returns - boolean indicating that the submesh is ready or not.
  26592. */
  26593. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26594. /**
  26595. * Specifies if the material uses metallic roughness workflow.
  26596. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26597. */
  26598. isMetallicWorkflow(): boolean;
  26599. private _prepareEffect;
  26600. private _prepareDefines;
  26601. /**
  26602. * Force shader compilation
  26603. */
  26604. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  26605. /**
  26606. * Initializes the uniform buffer layout for the shader.
  26607. */
  26608. buildUniformLayout(): void;
  26609. /**
  26610. * Unbinds the material from the mesh
  26611. */
  26612. unbind(): void;
  26613. /**
  26614. * Binds the submesh data.
  26615. * @param world - The world matrix.
  26616. * @param mesh - The BJS mesh.
  26617. * @param subMesh - A submesh of the BJS mesh.
  26618. */
  26619. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26620. /**
  26621. * Returns the animatable textures.
  26622. * @returns - Array of animatable textures.
  26623. */
  26624. getAnimatables(): IAnimatable[];
  26625. /**
  26626. * Returns the texture used for reflections.
  26627. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26628. */
  26629. private _getReflectionTexture;
  26630. /**
  26631. * Returns an array of the actively used textures.
  26632. * @returns - Array of BaseTextures
  26633. */
  26634. getActiveTextures(): BaseTexture[];
  26635. /**
  26636. * Checks to see if a texture is used in the material.
  26637. * @param texture - Base texture to use.
  26638. * @returns - Boolean specifying if a texture is used in the material.
  26639. */
  26640. hasTexture(texture: BaseTexture): boolean;
  26641. /**
  26642. * Sets the required values to the prepass renderer.
  26643. * @param prePassRenderer defines the prepass renderer to setup
  26644. */
  26645. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26646. /**
  26647. * Disposes the resources of the material.
  26648. * @param forceDisposeEffect - Forces the disposal of effects.
  26649. * @param forceDisposeTextures - Forces the disposal of all textures.
  26650. */
  26651. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26652. }
  26653. }
  26654. declare module BABYLON {
  26655. /**
  26656. * The Physically based material of BJS.
  26657. *
  26658. * This offers the main features of a standard PBR material.
  26659. * For more information, please refer to the documentation :
  26660. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26661. */
  26662. export class PBRMaterial extends PBRBaseMaterial {
  26663. /**
  26664. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26665. */
  26666. static readonly PBRMATERIAL_OPAQUE: number;
  26667. /**
  26668. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26669. */
  26670. static readonly PBRMATERIAL_ALPHATEST: number;
  26671. /**
  26672. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26673. */
  26674. static readonly PBRMATERIAL_ALPHABLEND: number;
  26675. /**
  26676. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26677. * They are also discarded below the alpha cutoff threshold to improve performances.
  26678. */
  26679. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26680. /**
  26681. * Defines the default value of how much AO map is occluding the analytical lights
  26682. * (point spot...).
  26683. */
  26684. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26685. /**
  26686. * Intensity of the direct lights e.g. the four lights available in your scene.
  26687. * This impacts both the direct diffuse and specular highlights.
  26688. */
  26689. directIntensity: number;
  26690. /**
  26691. * Intensity of the emissive part of the material.
  26692. * This helps controlling the emissive effect without modifying the emissive color.
  26693. */
  26694. emissiveIntensity: number;
  26695. /**
  26696. * Intensity of the environment e.g. how much the environment will light the object
  26697. * either through harmonics for rough material or through the refelction for shiny ones.
  26698. */
  26699. environmentIntensity: number;
  26700. /**
  26701. * This is a special control allowing the reduction of the specular highlights coming from the
  26702. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26703. */
  26704. specularIntensity: number;
  26705. /**
  26706. * Debug Control allowing disabling the bump map on this material.
  26707. */
  26708. disableBumpMap: boolean;
  26709. /**
  26710. * AKA Diffuse Texture in standard nomenclature.
  26711. */
  26712. albedoTexture: BaseTexture;
  26713. /**
  26714. * AKA Occlusion Texture in other nomenclature.
  26715. */
  26716. ambientTexture: BaseTexture;
  26717. /**
  26718. * AKA Occlusion Texture Intensity in other nomenclature.
  26719. */
  26720. ambientTextureStrength: number;
  26721. /**
  26722. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26723. * 1 means it completely occludes it
  26724. * 0 mean it has no impact
  26725. */
  26726. ambientTextureImpactOnAnalyticalLights: number;
  26727. /**
  26728. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  26729. */
  26730. opacityTexture: BaseTexture;
  26731. /**
  26732. * Stores the reflection values in a texture.
  26733. */
  26734. reflectionTexture: Nullable<BaseTexture>;
  26735. /**
  26736. * Stores the emissive values in a texture.
  26737. */
  26738. emissiveTexture: BaseTexture;
  26739. /**
  26740. * AKA Specular texture in other nomenclature.
  26741. */
  26742. reflectivityTexture: BaseTexture;
  26743. /**
  26744. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26745. */
  26746. metallicTexture: BaseTexture;
  26747. /**
  26748. * Specifies the metallic scalar of the metallic/roughness workflow.
  26749. * Can also be used to scale the metalness values of the metallic texture.
  26750. */
  26751. metallic: Nullable<number>;
  26752. /**
  26753. * Specifies the roughness scalar of the metallic/roughness workflow.
  26754. * Can also be used to scale the roughness values of the metallic texture.
  26755. */
  26756. roughness: Nullable<number>;
  26757. /**
  26758. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26759. * By default the indexOfrefraction is used to compute F0;
  26760. *
  26761. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26762. *
  26763. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26764. * F90 = metallicReflectanceColor;
  26765. */
  26766. metallicF0Factor: number;
  26767. /**
  26768. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26769. * By default the F90 is always 1;
  26770. *
  26771. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26772. *
  26773. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26774. * F90 = metallicReflectanceColor;
  26775. */
  26776. metallicReflectanceColor: Color3;
  26777. /**
  26778. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26779. * This is multiply against the scalar values defined in the material.
  26780. */
  26781. metallicReflectanceTexture: Nullable<BaseTexture>;
  26782. /**
  26783. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26784. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26785. */
  26786. microSurfaceTexture: BaseTexture;
  26787. /**
  26788. * Stores surface normal data used to displace a mesh in a texture.
  26789. */
  26790. bumpTexture: BaseTexture;
  26791. /**
  26792. * Stores the pre-calculated light information of a mesh in a texture.
  26793. */
  26794. lightmapTexture: BaseTexture;
  26795. /**
  26796. * Stores the refracted light information in a texture.
  26797. */
  26798. get refractionTexture(): Nullable<BaseTexture>;
  26799. set refractionTexture(value: Nullable<BaseTexture>);
  26800. /**
  26801. * The color of a material in ambient lighting.
  26802. */
  26803. ambientColor: Color3;
  26804. /**
  26805. * AKA Diffuse Color in other nomenclature.
  26806. */
  26807. albedoColor: Color3;
  26808. /**
  26809. * AKA Specular Color in other nomenclature.
  26810. */
  26811. reflectivityColor: Color3;
  26812. /**
  26813. * The color reflected from the material.
  26814. */
  26815. reflectionColor: Color3;
  26816. /**
  26817. * The color emitted from the material.
  26818. */
  26819. emissiveColor: Color3;
  26820. /**
  26821. * AKA Glossiness in other nomenclature.
  26822. */
  26823. microSurface: number;
  26824. /**
  26825. * Index of refraction of the material base layer.
  26826. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26827. *
  26828. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26829. *
  26830. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26831. */
  26832. get indexOfRefraction(): number;
  26833. set indexOfRefraction(value: number);
  26834. /**
  26835. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26836. */
  26837. get invertRefractionY(): boolean;
  26838. set invertRefractionY(value: boolean);
  26839. /**
  26840. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26841. * Materials half opaque for instance using refraction could benefit from this control.
  26842. */
  26843. get linkRefractionWithTransparency(): boolean;
  26844. set linkRefractionWithTransparency(value: boolean);
  26845. /**
  26846. * If true, the light map contains occlusion information instead of lighting info.
  26847. */
  26848. useLightmapAsShadowmap: boolean;
  26849. /**
  26850. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26851. */
  26852. useAlphaFromAlbedoTexture: boolean;
  26853. /**
  26854. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26855. */
  26856. forceAlphaTest: boolean;
  26857. /**
  26858. * Defines the alpha limits in alpha test mode.
  26859. */
  26860. alphaCutOff: number;
  26861. /**
  26862. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26863. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26864. */
  26865. useSpecularOverAlpha: boolean;
  26866. /**
  26867. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26868. */
  26869. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26870. /**
  26871. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26872. */
  26873. useRoughnessFromMetallicTextureAlpha: boolean;
  26874. /**
  26875. * Specifies if the metallic texture contains the roughness information in its green channel.
  26876. */
  26877. useRoughnessFromMetallicTextureGreen: boolean;
  26878. /**
  26879. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26880. */
  26881. useMetallnessFromMetallicTextureBlue: boolean;
  26882. /**
  26883. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26884. */
  26885. useAmbientOcclusionFromMetallicTextureRed: boolean;
  26886. /**
  26887. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26888. */
  26889. useAmbientInGrayScale: boolean;
  26890. /**
  26891. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26892. * The material will try to infer what glossiness each pixel should be.
  26893. */
  26894. useAutoMicroSurfaceFromReflectivityMap: boolean;
  26895. /**
  26896. * BJS is using an harcoded light falloff based on a manually sets up range.
  26897. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  26898. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  26899. */
  26900. get usePhysicalLightFalloff(): boolean;
  26901. /**
  26902. * BJS is using an harcoded light falloff based on a manually sets up range.
  26903. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  26904. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  26905. */
  26906. set usePhysicalLightFalloff(value: boolean);
  26907. /**
  26908. * In order to support the falloff compatibility with gltf, a special mode has been added
  26909. * to reproduce the gltf light falloff.
  26910. */
  26911. get useGLTFLightFalloff(): boolean;
  26912. /**
  26913. * In order to support the falloff compatibility with gltf, a special mode has been added
  26914. * to reproduce the gltf light falloff.
  26915. */
  26916. set useGLTFLightFalloff(value: boolean);
  26917. /**
  26918. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26919. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26920. */
  26921. useRadianceOverAlpha: boolean;
  26922. /**
  26923. * Allows using an object space normal map (instead of tangent space).
  26924. */
  26925. useObjectSpaceNormalMap: boolean;
  26926. /**
  26927. * Allows using the bump map in parallax mode.
  26928. */
  26929. useParallax: boolean;
  26930. /**
  26931. * Allows using the bump map in parallax occlusion mode.
  26932. */
  26933. useParallaxOcclusion: boolean;
  26934. /**
  26935. * Controls the scale bias of the parallax mode.
  26936. */
  26937. parallaxScaleBias: number;
  26938. /**
  26939. * If sets to true, disables all the lights affecting the material.
  26940. */
  26941. disableLighting: boolean;
  26942. /**
  26943. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26944. */
  26945. forceIrradianceInFragment: boolean;
  26946. /**
  26947. * Number of Simultaneous lights allowed on the material.
  26948. */
  26949. maxSimultaneousLights: number;
  26950. /**
  26951. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26952. */
  26953. invertNormalMapX: boolean;
  26954. /**
  26955. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26956. */
  26957. invertNormalMapY: boolean;
  26958. /**
  26959. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26960. */
  26961. twoSidedLighting: boolean;
  26962. /**
  26963. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26964. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26965. */
  26966. useAlphaFresnel: boolean;
  26967. /**
  26968. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26969. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26970. */
  26971. useLinearAlphaFresnel: boolean;
  26972. /**
  26973. * Let user defines the brdf lookup texture used for IBL.
  26974. * A default 8bit version is embedded but you could point at :
  26975. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  26976. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  26977. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  26978. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  26979. */
  26980. environmentBRDFTexture: Nullable<BaseTexture>;
  26981. /**
  26982. * Force normal to face away from face.
  26983. */
  26984. forceNormalForward: boolean;
  26985. /**
  26986. * Enables specular anti aliasing in the PBR shader.
  26987. * It will both interacts on the Geometry for analytical and IBL lighting.
  26988. * It also prefilter the roughness map based on the bump values.
  26989. */
  26990. enableSpecularAntiAliasing: boolean;
  26991. /**
  26992. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26993. * makes the reflect vector face the model (under horizon).
  26994. */
  26995. useHorizonOcclusion: boolean;
  26996. /**
  26997. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26998. * too much the area relying on ambient texture to define their ambient occlusion.
  26999. */
  27000. useRadianceOcclusion: boolean;
  27001. /**
  27002. * If set to true, no lighting calculations will be applied.
  27003. */
  27004. unlit: boolean;
  27005. /**
  27006. * Gets the image processing configuration used either in this material.
  27007. */
  27008. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27009. /**
  27010. * Sets the Default image processing configuration used either in the this material.
  27011. *
  27012. * If sets to null, the scene one is in use.
  27013. */
  27014. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27015. /**
  27016. * Gets wether the color curves effect is enabled.
  27017. */
  27018. get cameraColorCurvesEnabled(): boolean;
  27019. /**
  27020. * Sets wether the color curves effect is enabled.
  27021. */
  27022. set cameraColorCurvesEnabled(value: boolean);
  27023. /**
  27024. * Gets wether the color grading effect is enabled.
  27025. */
  27026. get cameraColorGradingEnabled(): boolean;
  27027. /**
  27028. * Gets wether the color grading effect is enabled.
  27029. */
  27030. set cameraColorGradingEnabled(value: boolean);
  27031. /**
  27032. * Gets wether tonemapping is enabled or not.
  27033. */
  27034. get cameraToneMappingEnabled(): boolean;
  27035. /**
  27036. * Sets wether tonemapping is enabled or not
  27037. */
  27038. set cameraToneMappingEnabled(value: boolean);
  27039. /**
  27040. * The camera exposure used on this material.
  27041. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27042. * This corresponds to a photographic exposure.
  27043. */
  27044. get cameraExposure(): number;
  27045. /**
  27046. * The camera exposure used on this material.
  27047. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27048. * This corresponds to a photographic exposure.
  27049. */
  27050. set cameraExposure(value: number);
  27051. /**
  27052. * Gets The camera contrast used on this material.
  27053. */
  27054. get cameraContrast(): number;
  27055. /**
  27056. * Sets The camera contrast used on this material.
  27057. */
  27058. set cameraContrast(value: number);
  27059. /**
  27060. * Gets the Color Grading 2D Lookup Texture.
  27061. */
  27062. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27063. /**
  27064. * Sets the Color Grading 2D Lookup Texture.
  27065. */
  27066. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27067. /**
  27068. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27069. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27070. * 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;
  27071. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27072. */
  27073. get cameraColorCurves(): Nullable<ColorCurves>;
  27074. /**
  27075. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27076. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27077. * 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;
  27078. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27079. */
  27080. set cameraColorCurves(value: Nullable<ColorCurves>);
  27081. /**
  27082. * Instantiates a new PBRMaterial instance.
  27083. *
  27084. * @param name The material name
  27085. * @param scene The scene the material will be use in.
  27086. */
  27087. constructor(name: string, scene: Scene);
  27088. /**
  27089. * Returns the name of this material class.
  27090. */
  27091. getClassName(): string;
  27092. /**
  27093. * Makes a duplicate of the current material.
  27094. * @param name - name to use for the new material.
  27095. */
  27096. clone(name: string): PBRMaterial;
  27097. /**
  27098. * Serializes this PBR Material.
  27099. * @returns - An object with the serialized material.
  27100. */
  27101. serialize(): any;
  27102. /**
  27103. * Parses a PBR Material from a serialized object.
  27104. * @param source - Serialized object.
  27105. * @param scene - BJS scene instance.
  27106. * @param rootUrl - url for the scene object
  27107. * @returns - PBRMaterial
  27108. */
  27109. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  27110. }
  27111. }
  27112. declare module BABYLON {
  27113. /** @hidden */
  27114. export var mrtFragmentDeclaration: {
  27115. name: string;
  27116. shader: string;
  27117. };
  27118. }
  27119. declare module BABYLON {
  27120. /** @hidden */
  27121. export var geometryPixelShader: {
  27122. name: string;
  27123. shader: string;
  27124. };
  27125. }
  27126. declare module BABYLON {
  27127. /** @hidden */
  27128. export var geometryVertexShader: {
  27129. name: string;
  27130. shader: string;
  27131. };
  27132. }
  27133. declare module BABYLON {
  27134. /** @hidden */
  27135. interface ISavedTransformationMatrix {
  27136. world: Matrix;
  27137. viewProjection: Matrix;
  27138. }
  27139. /**
  27140. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  27141. */
  27142. export class GeometryBufferRenderer {
  27143. /**
  27144. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  27145. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  27146. */
  27147. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  27148. /**
  27149. * Constant used to retrieve the position texture index in the G-Buffer textures array
  27150. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  27151. */
  27152. static readonly POSITION_TEXTURE_TYPE: number;
  27153. /**
  27154. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  27155. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  27156. */
  27157. static readonly VELOCITY_TEXTURE_TYPE: number;
  27158. /**
  27159. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  27160. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  27161. */
  27162. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  27163. /**
  27164. * Dictionary used to store the previous transformation matrices of each rendered mesh
  27165. * in order to compute objects velocities when enableVelocity is set to "true"
  27166. * @hidden
  27167. */
  27168. _previousTransformationMatrices: {
  27169. [index: number]: ISavedTransformationMatrix;
  27170. };
  27171. /**
  27172. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  27173. * in order to compute objects velocities when enableVelocity is set to "true"
  27174. * @hidden
  27175. */
  27176. _previousBonesTransformationMatrices: {
  27177. [index: number]: Float32Array;
  27178. };
  27179. /**
  27180. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  27181. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  27182. */
  27183. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  27184. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  27185. renderTransparentMeshes: boolean;
  27186. private _scene;
  27187. private _resizeObserver;
  27188. private _multiRenderTarget;
  27189. private _ratio;
  27190. private _enablePosition;
  27191. private _enableVelocity;
  27192. private _enableReflectivity;
  27193. private _positionIndex;
  27194. private _velocityIndex;
  27195. private _reflectivityIndex;
  27196. private _depthNormalIndex;
  27197. private _linkedWithPrePass;
  27198. private _prePassRenderer;
  27199. private _attachments;
  27200. protected _effect: Effect;
  27201. protected _cachedDefines: string;
  27202. /**
  27203. * @hidden
  27204. * Sets up internal structures to share outputs with PrePassRenderer
  27205. * This method should only be called by the PrePassRenderer itself
  27206. */
  27207. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  27208. /**
  27209. * @hidden
  27210. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  27211. * This method should only be called by the PrePassRenderer itself
  27212. */
  27213. _unlinkPrePassRenderer(): void;
  27214. /**
  27215. * @hidden
  27216. * Resets the geometry buffer layout
  27217. */
  27218. _resetLayout(): void;
  27219. /**
  27220. * @hidden
  27221. * Replaces a texture in the geometry buffer renderer
  27222. * Useful when linking textures of the prepass renderer
  27223. */
  27224. _forceTextureType(geometryBufferType: number, index: number): void;
  27225. /**
  27226. * @hidden
  27227. * Sets texture attachments
  27228. * Useful when linking textures of the prepass renderer
  27229. */
  27230. _setAttachments(attachments: number[]): void;
  27231. /**
  27232. * @hidden
  27233. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  27234. * Useful when linking textures of the prepass renderer
  27235. */
  27236. _linkInternalTexture(internalTexture: InternalTexture): void;
  27237. /**
  27238. * Gets the render list (meshes to be rendered) used in the G buffer.
  27239. */
  27240. get renderList(): Nullable<AbstractMesh[]>;
  27241. /**
  27242. * Set the render list (meshes to be rendered) used in the G buffer.
  27243. */
  27244. set renderList(meshes: Nullable<AbstractMesh[]>);
  27245. /**
  27246. * Gets wether or not G buffer are supported by the running hardware.
  27247. * This requires draw buffer supports
  27248. */
  27249. get isSupported(): boolean;
  27250. /**
  27251. * Returns the index of the given texture type in the G-Buffer textures array
  27252. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  27253. * @returns the index of the given texture type in the G-Buffer textures array
  27254. */
  27255. getTextureIndex(textureType: number): number;
  27256. /**
  27257. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  27258. */
  27259. get enablePosition(): boolean;
  27260. /**
  27261. * Sets whether or not objects positions are enabled for the G buffer.
  27262. */
  27263. set enablePosition(enable: boolean);
  27264. /**
  27265. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  27266. */
  27267. get enableVelocity(): boolean;
  27268. /**
  27269. * Sets wether or not objects velocities are enabled for the G buffer.
  27270. */
  27271. set enableVelocity(enable: boolean);
  27272. /**
  27273. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  27274. */
  27275. get enableReflectivity(): boolean;
  27276. /**
  27277. * Sets wether or not objects roughness are enabled for the G buffer.
  27278. */
  27279. set enableReflectivity(enable: boolean);
  27280. /**
  27281. * Gets the scene associated with the buffer.
  27282. */
  27283. get scene(): Scene;
  27284. /**
  27285. * Gets the ratio used by the buffer during its creation.
  27286. * How big is the buffer related to the main canvas.
  27287. */
  27288. get ratio(): number;
  27289. /** @hidden */
  27290. static _SceneComponentInitialization: (scene: Scene) => void;
  27291. /**
  27292. * Creates a new G Buffer for the scene
  27293. * @param scene The scene the buffer belongs to
  27294. * @param ratio How big is the buffer related to the main canvas.
  27295. */
  27296. constructor(scene: Scene, ratio?: number);
  27297. /**
  27298. * Checks wether everything is ready to render a submesh to the G buffer.
  27299. * @param subMesh the submesh to check readiness for
  27300. * @param useInstances is the mesh drawn using instance or not
  27301. * @returns true if ready otherwise false
  27302. */
  27303. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27304. /**
  27305. * Gets the current underlying G Buffer.
  27306. * @returns the buffer
  27307. */
  27308. getGBuffer(): MultiRenderTarget;
  27309. /**
  27310. * Gets the number of samples used to render the buffer (anti aliasing).
  27311. */
  27312. get samples(): number;
  27313. /**
  27314. * Sets the number of samples used to render the buffer (anti aliasing).
  27315. */
  27316. set samples(value: number);
  27317. /**
  27318. * Disposes the renderer and frees up associated resources.
  27319. */
  27320. dispose(): void;
  27321. private _assignRenderTargetIndices;
  27322. protected _createRenderTargets(): void;
  27323. private _copyBonesTransformationMatrices;
  27324. }
  27325. }
  27326. declare module BABYLON {
  27327. /**
  27328. * Renders a pre pass of the scene
  27329. * This means every mesh in the scene will be rendered to a render target texture
  27330. * And then this texture will be composited to the rendering canvas with post processes
  27331. * It is necessary for effects like subsurface scattering or deferred shading
  27332. */
  27333. export class PrePassRenderer {
  27334. /** @hidden */
  27335. static _SceneComponentInitialization: (scene: Scene) => void;
  27336. private _textureFormats;
  27337. /**
  27338. * To save performance, we can excluded skinned meshes from the prepass
  27339. */
  27340. excludedSkinnedMesh: AbstractMesh[];
  27341. /**
  27342. * Force material to be excluded from the prepass
  27343. * Can be useful when `useGeometryBufferFallback` is set to `true`
  27344. * and you don't want a material to show in the effect.
  27345. */
  27346. excludedMaterials: Material[];
  27347. private _textureIndices;
  27348. private _scene;
  27349. private _engine;
  27350. private _isDirty;
  27351. /**
  27352. * Number of textures in the multi render target texture where the scene is directly rendered
  27353. */
  27354. mrtCount: number;
  27355. /**
  27356. * The render target where the scene is directly rendered
  27357. */
  27358. prePassRT: MultiRenderTarget;
  27359. private _multiRenderAttachments;
  27360. private _defaultAttachments;
  27361. private _clearAttachments;
  27362. private _postProcesses;
  27363. private readonly _clearColor;
  27364. /**
  27365. * Image processing post process for composition
  27366. */
  27367. imageProcessingPostProcess: ImageProcessingPostProcess;
  27368. /**
  27369. * Configuration for prepass effects
  27370. */
  27371. private _effectConfigurations;
  27372. private _mrtFormats;
  27373. private _mrtLayout;
  27374. private _enabled;
  27375. /**
  27376. * Indicates if the prepass is enabled
  27377. */
  27378. get enabled(): boolean;
  27379. /**
  27380. * How many samples are used for MSAA of the scene render target
  27381. */
  27382. get samples(): number;
  27383. set samples(n: number);
  27384. private _geometryBuffer;
  27385. private _useGeometryBufferFallback;
  27386. /**
  27387. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  27388. */
  27389. get useGeometryBufferFallback(): boolean;
  27390. set useGeometryBufferFallback(value: boolean);
  27391. /**
  27392. * Instanciates a prepass renderer
  27393. * @param scene The scene
  27394. */
  27395. constructor(scene: Scene);
  27396. private _initializeAttachments;
  27397. private _createCompositionEffect;
  27398. /**
  27399. * Indicates if rendering a prepass is supported
  27400. */
  27401. get isSupported(): boolean;
  27402. /**
  27403. * Sets the proper output textures to draw in the engine.
  27404. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  27405. * @param subMesh Submesh on which the effect is applied
  27406. */
  27407. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  27408. /**
  27409. * @hidden
  27410. */
  27411. _beforeCameraDraw(): void;
  27412. /**
  27413. * @hidden
  27414. */
  27415. _afterCameraDraw(): void;
  27416. private _checkRTSize;
  27417. private _bindFrameBuffer;
  27418. /**
  27419. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  27420. */
  27421. clear(): void;
  27422. private _setState;
  27423. private _updateGeometryBufferLayout;
  27424. /**
  27425. * Adds an effect configuration to the prepass.
  27426. * If an effect has already been added, it won't add it twice and will return the configuration
  27427. * already present.
  27428. * @param cfg the effect configuration
  27429. * @return the effect configuration now used by the prepass
  27430. */
  27431. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  27432. /**
  27433. * Returns the index of a texture in the multi render target texture array.
  27434. * @param type Texture type
  27435. * @return The index
  27436. */
  27437. getIndex(type: number): number;
  27438. private _enable;
  27439. private _disable;
  27440. private _resetLayout;
  27441. private _resetPostProcessChain;
  27442. private _bindPostProcessChain;
  27443. /**
  27444. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  27445. */
  27446. markAsDirty(): void;
  27447. /**
  27448. * Enables a texture on the MultiRenderTarget for prepass
  27449. */
  27450. private _enableTextures;
  27451. private _update;
  27452. private _markAllMaterialsAsPrePassDirty;
  27453. /**
  27454. * Disposes the prepass renderer.
  27455. */
  27456. dispose(): void;
  27457. }
  27458. }
  27459. declare module BABYLON {
  27460. /**
  27461. * Size options for a post process
  27462. */
  27463. export type PostProcessOptions = {
  27464. width: number;
  27465. height: number;
  27466. };
  27467. /**
  27468. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27469. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27470. */
  27471. export class PostProcess {
  27472. /**
  27473. * Gets or sets the unique id of the post process
  27474. */
  27475. uniqueId: number;
  27476. /** Name of the PostProcess. */
  27477. name: string;
  27478. /**
  27479. * Width of the texture to apply the post process on
  27480. */
  27481. width: number;
  27482. /**
  27483. * Height of the texture to apply the post process on
  27484. */
  27485. height: number;
  27486. /**
  27487. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  27488. */
  27489. nodeMaterialSource: Nullable<NodeMaterial>;
  27490. /**
  27491. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27492. * @hidden
  27493. */
  27494. _outputTexture: Nullable<InternalTexture>;
  27495. /**
  27496. * Sampling mode used by the shader
  27497. * See https://doc.babylonjs.com/classes/3.1/texture
  27498. */
  27499. renderTargetSamplingMode: number;
  27500. /**
  27501. * Clear color to use when screen clearing
  27502. */
  27503. clearColor: Color4;
  27504. /**
  27505. * If the buffer needs to be cleared before applying the post process. (default: true)
  27506. * Should be set to false if shader will overwrite all previous pixels.
  27507. */
  27508. autoClear: boolean;
  27509. /**
  27510. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27511. */
  27512. alphaMode: number;
  27513. /**
  27514. * Sets the setAlphaBlendConstants of the babylon engine
  27515. */
  27516. alphaConstants: Color4;
  27517. /**
  27518. * Animations to be used for the post processing
  27519. */
  27520. animations: Animation[];
  27521. /**
  27522. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27523. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27524. */
  27525. enablePixelPerfectMode: boolean;
  27526. /**
  27527. * Force the postprocess to be applied without taking in account viewport
  27528. */
  27529. forceFullscreenViewport: boolean;
  27530. /**
  27531. * List of inspectable custom properties (used by the Inspector)
  27532. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27533. */
  27534. inspectableCustomProperties: IInspectable[];
  27535. /**
  27536. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27537. *
  27538. * | Value | Type | Description |
  27539. * | ----- | ----------------------------------- | ----------- |
  27540. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27541. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27542. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27543. *
  27544. */
  27545. scaleMode: number;
  27546. /**
  27547. * Force textures to be a power of two (default: false)
  27548. */
  27549. alwaysForcePOT: boolean;
  27550. private _samples;
  27551. /**
  27552. * Number of sample textures (default: 1)
  27553. */
  27554. get samples(): number;
  27555. set samples(n: number);
  27556. /**
  27557. * Modify the scale of the post process to be the same as the viewport (default: false)
  27558. */
  27559. adaptScaleToCurrentViewport: boolean;
  27560. private _camera;
  27561. protected _scene: Scene;
  27562. private _engine;
  27563. private _options;
  27564. private _reusable;
  27565. private _textureType;
  27566. private _textureFormat;
  27567. /**
  27568. * Smart array of input and output textures for the post process.
  27569. * @hidden
  27570. */
  27571. _textures: SmartArray<InternalTexture>;
  27572. /**
  27573. * The index in _textures that corresponds to the output texture.
  27574. * @hidden
  27575. */
  27576. _currentRenderTextureInd: number;
  27577. private _effect;
  27578. private _samplers;
  27579. private _fragmentUrl;
  27580. private _vertexUrl;
  27581. private _parameters;
  27582. private _scaleRatio;
  27583. protected _indexParameters: any;
  27584. private _shareOutputWithPostProcess;
  27585. private _texelSize;
  27586. private _forcedOutputTexture;
  27587. /**
  27588. * Prepass configuration in case this post process needs a texture from prepass
  27589. * @hidden
  27590. */
  27591. _prePassEffectConfiguration: PrePassEffectConfiguration;
  27592. /**
  27593. * Returns the fragment url or shader name used in the post process.
  27594. * @returns the fragment url or name in the shader store.
  27595. */
  27596. getEffectName(): string;
  27597. /**
  27598. * An event triggered when the postprocess is activated.
  27599. */
  27600. onActivateObservable: Observable<Camera>;
  27601. private _onActivateObserver;
  27602. /**
  27603. * A function that is added to the onActivateObservable
  27604. */
  27605. set onActivate(callback: Nullable<(camera: Camera) => void>);
  27606. /**
  27607. * An event triggered when the postprocess changes its size.
  27608. */
  27609. onSizeChangedObservable: Observable<PostProcess>;
  27610. private _onSizeChangedObserver;
  27611. /**
  27612. * A function that is added to the onSizeChangedObservable
  27613. */
  27614. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  27615. /**
  27616. * An event triggered when the postprocess applies its effect.
  27617. */
  27618. onApplyObservable: Observable<Effect>;
  27619. private _onApplyObserver;
  27620. /**
  27621. * A function that is added to the onApplyObservable
  27622. */
  27623. set onApply(callback: (effect: Effect) => void);
  27624. /**
  27625. * An event triggered before rendering the postprocess
  27626. */
  27627. onBeforeRenderObservable: Observable<Effect>;
  27628. private _onBeforeRenderObserver;
  27629. /**
  27630. * A function that is added to the onBeforeRenderObservable
  27631. */
  27632. set onBeforeRender(callback: (effect: Effect) => void);
  27633. /**
  27634. * An event triggered after rendering the postprocess
  27635. */
  27636. onAfterRenderObservable: Observable<Effect>;
  27637. private _onAfterRenderObserver;
  27638. /**
  27639. * A function that is added to the onAfterRenderObservable
  27640. */
  27641. set onAfterRender(callback: (efect: Effect) => void);
  27642. /**
  27643. * 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
  27644. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27645. */
  27646. get inputTexture(): InternalTexture;
  27647. set inputTexture(value: InternalTexture);
  27648. /**
  27649. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  27650. * the only way to unset it is to use this function to restore its internal state
  27651. */
  27652. restoreDefaultInputTexture(): void;
  27653. /**
  27654. * Gets the camera which post process is applied to.
  27655. * @returns The camera the post process is applied to.
  27656. */
  27657. getCamera(): Camera;
  27658. /**
  27659. * Gets the texel size of the postprocess.
  27660. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27661. */
  27662. get texelSize(): Vector2;
  27663. /**
  27664. * Creates a new instance PostProcess
  27665. * @param name The name of the PostProcess.
  27666. * @param fragmentUrl The url of the fragment shader to be used.
  27667. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27668. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27669. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27670. * @param camera The camera to apply the render pass to.
  27671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27672. * @param engine The engine which the post process will be applied. (default: current engine)
  27673. * @param reusable If the post process can be reused on the same frame. (default: false)
  27674. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27675. * @param textureType Type of textures used when performing the post process. (default: 0)
  27676. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27677. * @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
  27678. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  27679. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  27680. */
  27681. 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);
  27682. /**
  27683. * Gets a string identifying the name of the class
  27684. * @returns "PostProcess" string
  27685. */
  27686. getClassName(): string;
  27687. /**
  27688. * Gets the engine which this post process belongs to.
  27689. * @returns The engine the post process was enabled with.
  27690. */
  27691. getEngine(): Engine;
  27692. /**
  27693. * The effect that is created when initializing the post process.
  27694. * @returns The created effect corresponding the the postprocess.
  27695. */
  27696. getEffect(): Effect;
  27697. /**
  27698. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27699. * @param postProcess The post process to share the output with.
  27700. * @returns This post process.
  27701. */
  27702. shareOutputWith(postProcess: PostProcess): PostProcess;
  27703. /**
  27704. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27705. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27706. */
  27707. useOwnOutput(): void;
  27708. /**
  27709. * Updates the effect with the current post process compile time values and recompiles the shader.
  27710. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27711. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27712. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27713. * @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
  27714. * @param onCompiled Called when the shader has been compiled.
  27715. * @param onError Called if there is an error when compiling a shader.
  27716. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  27717. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  27718. */
  27719. 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;
  27720. /**
  27721. * The post process is reusable if it can be used multiple times within one frame.
  27722. * @returns If the post process is reusable
  27723. */
  27724. isReusable(): boolean;
  27725. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  27726. markTextureDirty(): void;
  27727. /**
  27728. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  27729. * 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.
  27730. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  27731. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  27732. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  27733. * @returns The target texture that was bound to be written to.
  27734. */
  27735. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  27736. /**
  27737. * If the post process is supported.
  27738. */
  27739. get isSupported(): boolean;
  27740. /**
  27741. * The aspect ratio of the output texture.
  27742. */
  27743. get aspectRatio(): number;
  27744. /**
  27745. * Get a value indicating if the post-process is ready to be used
  27746. * @returns true if the post-process is ready (shader is compiled)
  27747. */
  27748. isReady(): boolean;
  27749. /**
  27750. * Binds all textures and uniforms to the shader, this will be run on every pass.
  27751. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  27752. */
  27753. apply(): Nullable<Effect>;
  27754. private _disposeTextures;
  27755. /**
  27756. * Sets the required values to the prepass renderer.
  27757. * @param prePassRenderer defines the prepass renderer to setup.
  27758. * @returns true if the pre pass is needed.
  27759. */
  27760. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27761. /**
  27762. * Disposes the post process.
  27763. * @param camera The camera to dispose the post process on.
  27764. */
  27765. dispose(camera?: Camera): void;
  27766. /**
  27767. * Serializes the particle system to a JSON object
  27768. * @returns the JSON object
  27769. */
  27770. serialize(): any;
  27771. /**
  27772. * Creates a material from parsed material data
  27773. * @param parsedPostProcess defines parsed post process data
  27774. * @param scene defines the hosting scene
  27775. * @param rootUrl defines the root URL to use to load textures
  27776. * @returns a new post process
  27777. */
  27778. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  27779. }
  27780. }
  27781. declare module BABYLON {
  27782. /** @hidden */
  27783. export var kernelBlurVaryingDeclaration: {
  27784. name: string;
  27785. shader: string;
  27786. };
  27787. }
  27788. declare module BABYLON {
  27789. /** @hidden */
  27790. export var kernelBlurFragment: {
  27791. name: string;
  27792. shader: string;
  27793. };
  27794. }
  27795. declare module BABYLON {
  27796. /** @hidden */
  27797. export var kernelBlurFragment2: {
  27798. name: string;
  27799. shader: string;
  27800. };
  27801. }
  27802. declare module BABYLON {
  27803. /** @hidden */
  27804. export var kernelBlurPixelShader: {
  27805. name: string;
  27806. shader: string;
  27807. };
  27808. }
  27809. declare module BABYLON {
  27810. /** @hidden */
  27811. export var kernelBlurVertex: {
  27812. name: string;
  27813. shader: string;
  27814. };
  27815. }
  27816. declare module BABYLON {
  27817. /** @hidden */
  27818. export var kernelBlurVertexShader: {
  27819. name: string;
  27820. shader: string;
  27821. };
  27822. }
  27823. declare module BABYLON {
  27824. /**
  27825. * The Blur Post Process which blurs an image based on a kernel and direction.
  27826. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27827. */
  27828. export class BlurPostProcess extends PostProcess {
  27829. private blockCompilation;
  27830. protected _kernel: number;
  27831. protected _idealKernel: number;
  27832. protected _packedFloat: boolean;
  27833. private _staticDefines;
  27834. /** The direction in which to blur the image. */
  27835. direction: Vector2;
  27836. /**
  27837. * Sets the length in pixels of the blur sample region
  27838. */
  27839. set kernel(v: number);
  27840. /**
  27841. * Gets the length in pixels of the blur sample region
  27842. */
  27843. get kernel(): number;
  27844. /**
  27845. * Sets wether or not the blur needs to unpack/repack floats
  27846. */
  27847. set packedFloat(v: boolean);
  27848. /**
  27849. * Gets wether or not the blur is unpacking/repacking floats
  27850. */
  27851. get packedFloat(): boolean;
  27852. /**
  27853. * Gets a string identifying the name of the class
  27854. * @returns "BlurPostProcess" string
  27855. */
  27856. getClassName(): string;
  27857. /**
  27858. * Creates a new instance BlurPostProcess
  27859. * @param name The name of the effect.
  27860. * @param direction The direction in which to blur the image.
  27861. * @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.
  27862. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27863. * @param camera The camera to apply the render pass to.
  27864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27865. * @param engine The engine which the post process will be applied. (default: current engine)
  27866. * @param reusable If the post process can be reused on the same frame. (default: false)
  27867. * @param textureType Type of textures used when performing the post process. (default: 0)
  27868. * @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)
  27869. */
  27870. 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);
  27871. /**
  27872. * Updates the effect with the current post process compile time values and recompiles the shader.
  27873. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27874. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27875. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27876. * @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
  27877. * @param onCompiled Called when the shader has been compiled.
  27878. * @param onError Called if there is an error when compiling a shader.
  27879. */
  27880. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27881. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27882. /**
  27883. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27884. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27885. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27886. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27887. * The gaps between physical kernels are compensated for in the weighting of the samples
  27888. * @param idealKernel Ideal blur kernel.
  27889. * @return Nearest best kernel.
  27890. */
  27891. protected _nearestBestKernel(idealKernel: number): number;
  27892. /**
  27893. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27894. * @param x The point on the Gaussian distribution to sample.
  27895. * @return the value of the Gaussian function at x.
  27896. */
  27897. protected _gaussianWeight(x: number): number;
  27898. /**
  27899. * Generates a string that can be used as a floating point number in GLSL.
  27900. * @param x Value to print.
  27901. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27902. * @return GLSL float string.
  27903. */
  27904. protected _glslFloat(x: number, decimalFigures?: number): string;
  27905. /** @hidden */
  27906. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  27907. }
  27908. }
  27909. declare module BABYLON {
  27910. /**
  27911. * Mirror texture can be used to simulate the view from a mirror in a scene.
  27912. * It will dynamically be rendered every frame to adapt to the camera point of view.
  27913. * You can then easily use it as a reflectionTexture on a flat surface.
  27914. * In case the surface is not a plane, please consider relying on reflection probes.
  27915. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27916. */
  27917. export class MirrorTexture extends RenderTargetTexture {
  27918. private scene;
  27919. /**
  27920. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  27921. * 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.
  27922. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27923. */
  27924. mirrorPlane: Plane;
  27925. /**
  27926. * Define the blur ratio used to blur the reflection if needed.
  27927. */
  27928. set blurRatio(value: number);
  27929. get blurRatio(): number;
  27930. /**
  27931. * Define the adaptive blur kernel used to blur the reflection if needed.
  27932. * This will autocompute the closest best match for the `blurKernel`
  27933. */
  27934. set adaptiveBlurKernel(value: number);
  27935. /**
  27936. * Define the blur kernel used to blur the reflection if needed.
  27937. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27938. */
  27939. set blurKernel(value: number);
  27940. /**
  27941. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  27942. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27943. */
  27944. set blurKernelX(value: number);
  27945. get blurKernelX(): number;
  27946. /**
  27947. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  27948. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27949. */
  27950. set blurKernelY(value: number);
  27951. get blurKernelY(): number;
  27952. private _autoComputeBlurKernel;
  27953. protected _onRatioRescale(): void;
  27954. private _updateGammaSpace;
  27955. private _imageProcessingConfigChangeObserver;
  27956. private _transformMatrix;
  27957. private _mirrorMatrix;
  27958. private _savedViewMatrix;
  27959. private _blurX;
  27960. private _blurY;
  27961. private _adaptiveBlurKernel;
  27962. private _blurKernelX;
  27963. private _blurKernelY;
  27964. private _blurRatio;
  27965. /**
  27966. * Instantiates a Mirror Texture.
  27967. * Mirror texture can be used to simulate the view from a mirror in a scene.
  27968. * It will dynamically be rendered every frame to adapt to the camera point of view.
  27969. * You can then easily use it as a reflectionTexture on a flat surface.
  27970. * In case the surface is not a plane, please consider relying on reflection probes.
  27971. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27972. * @param name
  27973. * @param size
  27974. * @param scene
  27975. * @param generateMipMaps
  27976. * @param type
  27977. * @param samplingMode
  27978. * @param generateDepthBuffer
  27979. */
  27980. constructor(name: string, size: number | {
  27981. width: number;
  27982. height: number;
  27983. } | {
  27984. ratio: number;
  27985. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  27986. private _preparePostProcesses;
  27987. /**
  27988. * Clone the mirror texture.
  27989. * @returns the cloned texture
  27990. */
  27991. clone(): MirrorTexture;
  27992. /**
  27993. * Serialize the texture to a JSON representation you could use in Parse later on
  27994. * @returns the serialized JSON representation
  27995. */
  27996. serialize(): any;
  27997. /**
  27998. * Dispose the texture and release its associated resources.
  27999. */
  28000. dispose(): void;
  28001. }
  28002. }
  28003. declare module BABYLON {
  28004. /**
  28005. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28006. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28007. */
  28008. export class Texture extends BaseTexture {
  28009. /**
  28010. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  28011. */
  28012. static SerializeBuffers: boolean;
  28013. /** @hidden */
  28014. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  28015. /** @hidden */
  28016. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  28017. /** @hidden */
  28018. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  28019. /** nearest is mag = nearest and min = nearest and mip = linear */
  28020. static readonly NEAREST_SAMPLINGMODE: number;
  28021. /** nearest is mag = nearest and min = nearest and mip = linear */
  28022. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  28023. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28024. static readonly BILINEAR_SAMPLINGMODE: number;
  28025. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28026. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  28027. /** Trilinear is mag = linear and min = linear and mip = linear */
  28028. static readonly TRILINEAR_SAMPLINGMODE: number;
  28029. /** Trilinear is mag = linear and min = linear and mip = linear */
  28030. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  28031. /** mag = nearest and min = nearest and mip = nearest */
  28032. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  28033. /** mag = nearest and min = linear and mip = nearest */
  28034. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  28035. /** mag = nearest and min = linear and mip = linear */
  28036. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  28037. /** mag = nearest and min = linear and mip = none */
  28038. static readonly NEAREST_LINEAR: number;
  28039. /** mag = nearest and min = nearest and mip = none */
  28040. static readonly NEAREST_NEAREST: number;
  28041. /** mag = linear and min = nearest and mip = nearest */
  28042. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  28043. /** mag = linear and min = nearest and mip = linear */
  28044. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  28045. /** mag = linear and min = linear and mip = none */
  28046. static readonly LINEAR_LINEAR: number;
  28047. /** mag = linear and min = nearest and mip = none */
  28048. static readonly LINEAR_NEAREST: number;
  28049. /** Explicit coordinates mode */
  28050. static readonly EXPLICIT_MODE: number;
  28051. /** Spherical coordinates mode */
  28052. static readonly SPHERICAL_MODE: number;
  28053. /** Planar coordinates mode */
  28054. static readonly PLANAR_MODE: number;
  28055. /** Cubic coordinates mode */
  28056. static readonly CUBIC_MODE: number;
  28057. /** Projection coordinates mode */
  28058. static readonly PROJECTION_MODE: number;
  28059. /** Inverse Cubic coordinates mode */
  28060. static readonly SKYBOX_MODE: number;
  28061. /** Inverse Cubic coordinates mode */
  28062. static readonly INVCUBIC_MODE: number;
  28063. /** Equirectangular coordinates mode */
  28064. static readonly EQUIRECTANGULAR_MODE: number;
  28065. /** Equirectangular Fixed coordinates mode */
  28066. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  28067. /** Equirectangular Fixed Mirrored coordinates mode */
  28068. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28069. /** Texture is not repeating outside of 0..1 UVs */
  28070. static readonly CLAMP_ADDRESSMODE: number;
  28071. /** Texture is repeating outside of 0..1 UVs */
  28072. static readonly WRAP_ADDRESSMODE: number;
  28073. /** Texture is repeating and mirrored */
  28074. static readonly MIRROR_ADDRESSMODE: number;
  28075. /**
  28076. * 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
  28077. */
  28078. static UseSerializedUrlIfAny: boolean;
  28079. /**
  28080. * Define the url of the texture.
  28081. */
  28082. url: Nullable<string>;
  28083. /**
  28084. * Define an offset on the texture to offset the u coordinates of the UVs
  28085. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28086. */
  28087. uOffset: number;
  28088. /**
  28089. * Define an offset on the texture to offset the v coordinates of the UVs
  28090. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28091. */
  28092. vOffset: number;
  28093. /**
  28094. * Define an offset on the texture to scale the u coordinates of the UVs
  28095. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28096. */
  28097. uScale: number;
  28098. /**
  28099. * Define an offset on the texture to scale the v coordinates of the UVs
  28100. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28101. */
  28102. vScale: number;
  28103. /**
  28104. * Define an offset on the texture to rotate around the u coordinates of the UVs
  28105. * @see https://doc.babylonjs.com/how_to/more_materials
  28106. */
  28107. uAng: number;
  28108. /**
  28109. * Define an offset on the texture to rotate around the v coordinates of the UVs
  28110. * @see https://doc.babylonjs.com/how_to/more_materials
  28111. */
  28112. vAng: number;
  28113. /**
  28114. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  28115. * @see https://doc.babylonjs.com/how_to/more_materials
  28116. */
  28117. wAng: number;
  28118. /**
  28119. * Defines the center of rotation (U)
  28120. */
  28121. uRotationCenter: number;
  28122. /**
  28123. * Defines the center of rotation (V)
  28124. */
  28125. vRotationCenter: number;
  28126. /**
  28127. * Defines the center of rotation (W)
  28128. */
  28129. wRotationCenter: number;
  28130. /**
  28131. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  28132. */
  28133. homogeneousRotationInUVTransform: boolean;
  28134. /**
  28135. * Are mip maps generated for this texture or not.
  28136. */
  28137. get noMipmap(): boolean;
  28138. /**
  28139. * List of inspectable custom properties (used by the Inspector)
  28140. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28141. */
  28142. inspectableCustomProperties: Nullable<IInspectable[]>;
  28143. private _noMipmap;
  28144. /** @hidden */
  28145. _invertY: boolean;
  28146. private _rowGenerationMatrix;
  28147. private _cachedTextureMatrix;
  28148. private _projectionModeMatrix;
  28149. private _t0;
  28150. private _t1;
  28151. private _t2;
  28152. private _cachedUOffset;
  28153. private _cachedVOffset;
  28154. private _cachedUScale;
  28155. private _cachedVScale;
  28156. private _cachedUAng;
  28157. private _cachedVAng;
  28158. private _cachedWAng;
  28159. private _cachedProjectionMatrixId;
  28160. private _cachedURotationCenter;
  28161. private _cachedVRotationCenter;
  28162. private _cachedWRotationCenter;
  28163. private _cachedHomogeneousRotationInUVTransform;
  28164. private _cachedCoordinatesMode;
  28165. /** @hidden */
  28166. protected _initialSamplingMode: number;
  28167. /** @hidden */
  28168. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  28169. private _deleteBuffer;
  28170. protected _format: Nullable<number>;
  28171. private _delayedOnLoad;
  28172. private _delayedOnError;
  28173. private _mimeType?;
  28174. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  28175. get mimeType(): string | undefined;
  28176. /**
  28177. * Observable triggered once the texture has been loaded.
  28178. */
  28179. onLoadObservable: Observable<Texture>;
  28180. protected _isBlocking: boolean;
  28181. /**
  28182. * Is the texture preventing material to render while loading.
  28183. * If false, a default texture will be used instead of the loading one during the preparation step.
  28184. */
  28185. set isBlocking(value: boolean);
  28186. get isBlocking(): boolean;
  28187. /**
  28188. * Get the current sampling mode associated with the texture.
  28189. */
  28190. get samplingMode(): number;
  28191. /**
  28192. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  28193. */
  28194. get invertY(): boolean;
  28195. /**
  28196. * Instantiates a new texture.
  28197. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28198. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28199. * @param url defines the url of the picture to load as a texture
  28200. * @param sceneOrEngine defines the scene or engine the texture will belong to
  28201. * @param noMipmap defines if the texture will require mip maps or not
  28202. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  28203. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28204. * @param onLoad defines a callback triggered when the texture has been loaded
  28205. * @param onError defines a callback triggered when an error occurred during the loading session
  28206. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  28207. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  28208. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28209. * @param mimeType defines an optional mime type information
  28210. */
  28211. 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);
  28212. /**
  28213. * Update the url (and optional buffer) of this texture if url was null during construction.
  28214. * @param url the url of the texture
  28215. * @param buffer the buffer of the texture (defaults to null)
  28216. * @param onLoad callback called when the texture is loaded (defaults to null)
  28217. */
  28218. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  28219. /**
  28220. * Finish the loading sequence of a texture flagged as delayed load.
  28221. * @hidden
  28222. */
  28223. delayLoad(): void;
  28224. private _prepareRowForTextureGeneration;
  28225. /**
  28226. * Checks if the texture has the same transform matrix than another texture
  28227. * @param texture texture to check against
  28228. * @returns true if the transforms are the same, else false
  28229. */
  28230. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  28231. /**
  28232. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  28233. * @returns the transform matrix of the texture.
  28234. */
  28235. getTextureMatrix(uBase?: number): Matrix;
  28236. /**
  28237. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  28238. * @returns The reflection texture transform
  28239. */
  28240. getReflectionTextureMatrix(): Matrix;
  28241. /**
  28242. * Clones the texture.
  28243. * @returns the cloned texture
  28244. */
  28245. clone(): Texture;
  28246. /**
  28247. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28248. * @returns The JSON representation of the texture
  28249. */
  28250. serialize(): any;
  28251. /**
  28252. * Get the current class name of the texture useful for serialization or dynamic coding.
  28253. * @returns "Texture"
  28254. */
  28255. getClassName(): string;
  28256. /**
  28257. * Dispose the texture and release its associated resources.
  28258. */
  28259. dispose(): void;
  28260. /**
  28261. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  28262. * @param parsedTexture Define the JSON representation of the texture
  28263. * @param scene Define the scene the parsed texture should be instantiated in
  28264. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  28265. * @returns The parsed texture if successful
  28266. */
  28267. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  28268. /**
  28269. * Creates a texture from its base 64 representation.
  28270. * @param data Define the base64 payload without the data: prefix
  28271. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28272. * @param scene Define the scene the texture should belong to
  28273. * @param noMipmap Forces the texture to not create mip map information if true
  28274. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28275. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28276. * @param onLoad define a callback triggered when the texture has been loaded
  28277. * @param onError define a callback triggered when an error occurred during the loading session
  28278. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28279. * @returns the created texture
  28280. */
  28281. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  28282. /**
  28283. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  28284. * @param data Define the base64 payload without the data: prefix
  28285. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28286. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  28287. * @param scene Define the scene the texture should belong to
  28288. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  28289. * @param noMipmap Forces the texture to not create mip map information if true
  28290. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28291. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28292. * @param onLoad define a callback triggered when the texture has been loaded
  28293. * @param onError define a callback triggered when an error occurred during the loading session
  28294. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28295. * @returns the created texture
  28296. */
  28297. 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;
  28298. }
  28299. }
  28300. declare module BABYLON {
  28301. /**
  28302. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28303. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28304. */
  28305. export class PostProcessManager {
  28306. private _scene;
  28307. private _indexBuffer;
  28308. private _vertexBuffers;
  28309. /**
  28310. * Creates a new instance PostProcess
  28311. * @param scene The scene that the post process is associated with.
  28312. */
  28313. constructor(scene: Scene);
  28314. private _prepareBuffers;
  28315. private _buildIndexBuffer;
  28316. /**
  28317. * Rebuilds the vertex buffers of the manager.
  28318. * @hidden
  28319. */
  28320. _rebuild(): void;
  28321. /**
  28322. * Prepares a frame to be run through a post process.
  28323. * @param sourceTexture The input texture to the post procesess. (default: null)
  28324. * @param postProcesses An array of post processes to be run. (default: null)
  28325. * @returns True if the post processes were able to be run.
  28326. * @hidden
  28327. */
  28328. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28329. /**
  28330. * Manually render a set of post processes to a texture.
  28331. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  28332. * @param postProcesses An array of post processes to be run.
  28333. * @param targetTexture The target texture to render to.
  28334. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28335. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28336. * @param lodLevel defines which lod of the texture to render to
  28337. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  28338. */
  28339. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  28340. /**
  28341. * Finalize the result of the output of the postprocesses.
  28342. * @param doNotPresent If true the result will not be displayed to the screen.
  28343. * @param targetTexture The target texture to render to.
  28344. * @param faceIndex The index of the face to bind the target texture to.
  28345. * @param postProcesses The array of post processes to render.
  28346. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28347. * @hidden
  28348. */
  28349. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28350. /**
  28351. * Disposes of the post process manager.
  28352. */
  28353. dispose(): void;
  28354. }
  28355. }
  28356. declare module BABYLON {
  28357. /**
  28358. * This Helps creating a texture that will be created from a camera in your scene.
  28359. * It is basically a dynamic texture that could be used to create special effects for instance.
  28360. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  28361. */
  28362. export class RenderTargetTexture extends Texture {
  28363. /**
  28364. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  28365. */
  28366. static readonly REFRESHRATE_RENDER_ONCE: number;
  28367. /**
  28368. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  28369. */
  28370. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28371. /**
  28372. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  28373. * the central point of your effect and can save a lot of performances.
  28374. */
  28375. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28376. /**
  28377. * Use this predicate to dynamically define the list of mesh you want to render.
  28378. * If set, the renderList property will be overwritten.
  28379. */
  28380. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  28381. private _renderList;
  28382. /**
  28383. * Use this list to define the list of mesh you want to render.
  28384. */
  28385. get renderList(): Nullable<Array<AbstractMesh>>;
  28386. set renderList(value: Nullable<Array<AbstractMesh>>);
  28387. /**
  28388. * Use this function to overload the renderList array at rendering time.
  28389. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  28390. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  28391. * the cube (if the RTT is a cube, else layerOrFace=0).
  28392. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  28393. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  28394. * hold dummy elements!
  28395. */
  28396. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  28397. private _hookArray;
  28398. /**
  28399. * Define if particles should be rendered in your texture.
  28400. */
  28401. renderParticles: boolean;
  28402. /**
  28403. * Define if sprites should be rendered in your texture.
  28404. */
  28405. renderSprites: boolean;
  28406. /**
  28407. * Define the camera used to render the texture.
  28408. */
  28409. activeCamera: Nullable<Camera>;
  28410. /**
  28411. * Override the mesh isReady function with your own one.
  28412. */
  28413. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  28414. /**
  28415. * Override the render function of the texture with your own one.
  28416. */
  28417. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  28418. /**
  28419. * Define if camera post processes should be use while rendering the texture.
  28420. */
  28421. useCameraPostProcesses: boolean;
  28422. /**
  28423. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  28424. */
  28425. ignoreCameraViewport: boolean;
  28426. private _postProcessManager;
  28427. private _postProcesses;
  28428. private _resizeObserver;
  28429. /**
  28430. * An event triggered when the texture is unbind.
  28431. */
  28432. onBeforeBindObservable: Observable<RenderTargetTexture>;
  28433. /**
  28434. * An event triggered when the texture is unbind.
  28435. */
  28436. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  28437. private _onAfterUnbindObserver;
  28438. /**
  28439. * Set a after unbind callback in the texture.
  28440. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  28441. */
  28442. set onAfterUnbind(callback: () => void);
  28443. /**
  28444. * An event triggered before rendering the texture
  28445. */
  28446. onBeforeRenderObservable: Observable<number>;
  28447. private _onBeforeRenderObserver;
  28448. /**
  28449. * Set a before render callback in the texture.
  28450. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  28451. */
  28452. set onBeforeRender(callback: (faceIndex: number) => void);
  28453. /**
  28454. * An event triggered after rendering the texture
  28455. */
  28456. onAfterRenderObservable: Observable<number>;
  28457. private _onAfterRenderObserver;
  28458. /**
  28459. * Set a after render callback in the texture.
  28460. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  28461. */
  28462. set onAfterRender(callback: (faceIndex: number) => void);
  28463. /**
  28464. * An event triggered after the texture clear
  28465. */
  28466. onClearObservable: Observable<Engine>;
  28467. private _onClearObserver;
  28468. /**
  28469. * Set a clear callback in the texture.
  28470. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  28471. */
  28472. set onClear(callback: (Engine: Engine) => void);
  28473. /**
  28474. * An event triggered when the texture is resized.
  28475. */
  28476. onResizeObservable: Observable<RenderTargetTexture>;
  28477. /**
  28478. * Define the clear color of the Render Target if it should be different from the scene.
  28479. */
  28480. clearColor: Color4;
  28481. protected _size: number | {
  28482. width: number;
  28483. height: number;
  28484. layers?: number;
  28485. };
  28486. protected _initialSizeParameter: number | {
  28487. width: number;
  28488. height: number;
  28489. } | {
  28490. ratio: number;
  28491. };
  28492. protected _sizeRatio: Nullable<number>;
  28493. /** @hidden */
  28494. _generateMipMaps: boolean;
  28495. protected _renderingManager: RenderingManager;
  28496. /** @hidden */
  28497. _waitingRenderList?: string[];
  28498. protected _doNotChangeAspectRatio: boolean;
  28499. protected _currentRefreshId: number;
  28500. protected _refreshRate: number;
  28501. protected _textureMatrix: Matrix;
  28502. protected _samples: number;
  28503. protected _renderTargetOptions: RenderTargetCreationOptions;
  28504. /**
  28505. * Gets render target creation options that were used.
  28506. */
  28507. get renderTargetOptions(): RenderTargetCreationOptions;
  28508. protected _onRatioRescale(): void;
  28509. /**
  28510. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  28511. * It must define where the camera used to render the texture is set
  28512. */
  28513. boundingBoxPosition: Vector3;
  28514. private _boundingBoxSize;
  28515. /**
  28516. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  28517. * When defined, the cubemap will switch to local mode
  28518. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28519. * @example https://www.babylonjs-playground.com/#RNASML
  28520. */
  28521. set boundingBoxSize(value: Vector3);
  28522. get boundingBoxSize(): Vector3;
  28523. /**
  28524. * In case the RTT has been created with a depth texture, get the associated
  28525. * depth texture.
  28526. * Otherwise, return null.
  28527. */
  28528. get depthStencilTexture(): Nullable<InternalTexture>;
  28529. /**
  28530. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  28531. * or used a shadow, depth texture...
  28532. * @param name The friendly name of the texture
  28533. * @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)
  28534. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  28535. * @param generateMipMaps True if mip maps need to be generated after render.
  28536. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  28537. * @param type The type of the buffer in the RTT (int, half float, float...)
  28538. * @param isCube True if a cube texture needs to be created
  28539. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  28540. * @param generateDepthBuffer True to generate a depth buffer
  28541. * @param generateStencilBuffer True to generate a stencil buffer
  28542. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  28543. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  28544. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28545. */
  28546. constructor(name: string, size: number | {
  28547. width: number;
  28548. height: number;
  28549. layers?: number;
  28550. } | {
  28551. ratio: number;
  28552. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  28553. /**
  28554. * Creates a depth stencil texture.
  28555. * This is only available in WebGL 2 or with the depth texture extension available.
  28556. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  28557. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  28558. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  28559. */
  28560. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  28561. private _processSizeParameter;
  28562. /**
  28563. * Define the number of samples to use in case of MSAA.
  28564. * It defaults to one meaning no MSAA has been enabled.
  28565. */
  28566. get samples(): number;
  28567. set samples(value: number);
  28568. /**
  28569. * Resets the refresh counter of the texture and start bak from scratch.
  28570. * Could be useful to regenerate the texture if it is setup to render only once.
  28571. */
  28572. resetRefreshCounter(): void;
  28573. /**
  28574. * Define the refresh rate of the texture or the rendering frequency.
  28575. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  28576. */
  28577. get refreshRate(): number;
  28578. set refreshRate(value: number);
  28579. /**
  28580. * Adds a post process to the render target rendering passes.
  28581. * @param postProcess define the post process to add
  28582. */
  28583. addPostProcess(postProcess: PostProcess): void;
  28584. /**
  28585. * Clear all the post processes attached to the render target
  28586. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  28587. */
  28588. clearPostProcesses(dispose?: boolean): void;
  28589. /**
  28590. * Remove one of the post process from the list of attached post processes to the texture
  28591. * @param postProcess define the post process to remove from the list
  28592. */
  28593. removePostProcess(postProcess: PostProcess): void;
  28594. /** @hidden */
  28595. _shouldRender(): boolean;
  28596. /**
  28597. * Gets the actual render size of the texture.
  28598. * @returns the width of the render size
  28599. */
  28600. getRenderSize(): number;
  28601. /**
  28602. * Gets the actual render width of the texture.
  28603. * @returns the width of the render size
  28604. */
  28605. getRenderWidth(): number;
  28606. /**
  28607. * Gets the actual render height of the texture.
  28608. * @returns the height of the render size
  28609. */
  28610. getRenderHeight(): number;
  28611. /**
  28612. * Gets the actual number of layers of the texture.
  28613. * @returns the number of layers
  28614. */
  28615. getRenderLayers(): number;
  28616. /**
  28617. * Get if the texture can be rescaled or not.
  28618. */
  28619. get canRescale(): boolean;
  28620. /**
  28621. * Resize the texture using a ratio.
  28622. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  28623. */
  28624. scale(ratio: number): void;
  28625. /**
  28626. * Get the texture reflection matrix used to rotate/transform the reflection.
  28627. * @returns the reflection matrix
  28628. */
  28629. getReflectionTextureMatrix(): Matrix;
  28630. /**
  28631. * Resize the texture to a new desired size.
  28632. * Be carrefull as it will recreate all the data in the new texture.
  28633. * @param size Define the new size. It can be:
  28634. * - a number for squared texture,
  28635. * - an object containing { width: number, height: number }
  28636. * - or an object containing a ratio { ratio: number }
  28637. */
  28638. resize(size: number | {
  28639. width: number;
  28640. height: number;
  28641. } | {
  28642. ratio: number;
  28643. }): void;
  28644. private _defaultRenderListPrepared;
  28645. /**
  28646. * Renders all the objects from the render list into the texture.
  28647. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  28648. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  28649. */
  28650. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  28651. private _bestReflectionRenderTargetDimension;
  28652. private _prepareRenderingManager;
  28653. /**
  28654. * @hidden
  28655. * @param faceIndex face index to bind to if this is a cubetexture
  28656. * @param layer defines the index of the texture to bind in the array
  28657. */
  28658. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  28659. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28660. private renderToTarget;
  28661. /**
  28662. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28663. * This allowed control for front to back rendering or reversly depending of the special needs.
  28664. *
  28665. * @param renderingGroupId The rendering group id corresponding to its index
  28666. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28667. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28668. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28669. */
  28670. 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;
  28671. /**
  28672. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28673. *
  28674. * @param renderingGroupId The rendering group id corresponding to its index
  28675. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28676. */
  28677. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28678. /**
  28679. * Clones the texture.
  28680. * @returns the cloned texture
  28681. */
  28682. clone(): RenderTargetTexture;
  28683. /**
  28684. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28685. * @returns The JSON representation of the texture
  28686. */
  28687. serialize(): any;
  28688. /**
  28689. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  28690. */
  28691. disposeFramebufferObjects(): void;
  28692. /**
  28693. * Dispose the texture and release its associated resources.
  28694. */
  28695. dispose(): void;
  28696. /** @hidden */
  28697. _rebuild(): void;
  28698. /**
  28699. * Clear the info related to rendering groups preventing retention point in material dispose.
  28700. */
  28701. freeRenderingGroups(): void;
  28702. /**
  28703. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  28704. * @returns the view count
  28705. */
  28706. getViewCount(): number;
  28707. }
  28708. }
  28709. declare module BABYLON {
  28710. /**
  28711. * Class used to manipulate GUIDs
  28712. */
  28713. export class GUID {
  28714. /**
  28715. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28716. * Be aware Math.random() could cause collisions, but:
  28717. * "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"
  28718. * @returns a pseudo random id
  28719. */
  28720. static RandomId(): string;
  28721. }
  28722. }
  28723. declare module BABYLON {
  28724. /**
  28725. * Options to be used when creating a shadow depth material
  28726. */
  28727. export interface IIOptionShadowDepthMaterial {
  28728. /** Variables in the vertex shader code that need to have their names remapped.
  28729. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  28730. * "var_name" should be either: worldPos or vNormalW
  28731. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  28732. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  28733. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  28734. */
  28735. remappedVariables?: string[];
  28736. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  28737. standalone?: boolean;
  28738. }
  28739. /**
  28740. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  28741. */
  28742. export class ShadowDepthWrapper {
  28743. private _scene;
  28744. private _options?;
  28745. private _baseMaterial;
  28746. private _onEffectCreatedObserver;
  28747. private _subMeshToEffect;
  28748. private _subMeshToDepthEffect;
  28749. private _meshes;
  28750. /** @hidden */
  28751. _matriceNames: any;
  28752. /** Gets the standalone status of the wrapper */
  28753. get standalone(): boolean;
  28754. /** Gets the base material the wrapper is built upon */
  28755. get baseMaterial(): Material;
  28756. /**
  28757. * Instantiate a new shadow depth wrapper.
  28758. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  28759. * generate the shadow depth map. For more information, please refer to the documentation:
  28760. * https://doc.babylonjs.com/babylon101/shadows
  28761. * @param baseMaterial Material to wrap
  28762. * @param scene Define the scene the material belongs to
  28763. * @param options Options used to create the wrapper
  28764. */
  28765. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  28766. /**
  28767. * Gets the effect to use to generate the depth map
  28768. * @param subMesh subMesh to get the effect for
  28769. * @param shadowGenerator shadow generator to get the effect for
  28770. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  28771. */
  28772. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  28773. /**
  28774. * Specifies that the submesh is ready to be used for depth rendering
  28775. * @param subMesh submesh to check
  28776. * @param defines the list of defines to take into account when checking the effect
  28777. * @param shadowGenerator combined with subMesh, it defines the effect to check
  28778. * @param useInstances specifies that instances should be used
  28779. * @returns a boolean indicating that the submesh is ready or not
  28780. */
  28781. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  28782. /**
  28783. * Disposes the resources
  28784. */
  28785. dispose(): void;
  28786. private _makeEffect;
  28787. }
  28788. }
  28789. declare module BABYLON {
  28790. /**
  28791. * Options for compiling materials.
  28792. */
  28793. export interface IMaterialCompilationOptions {
  28794. /**
  28795. * Defines whether clip planes are enabled.
  28796. */
  28797. clipPlane: boolean;
  28798. /**
  28799. * Defines whether instances are enabled.
  28800. */
  28801. useInstances: boolean;
  28802. }
  28803. /**
  28804. * Options passed when calling customShaderNameResolve
  28805. */
  28806. export interface ICustomShaderNameResolveOptions {
  28807. /**
  28808. * 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
  28809. */
  28810. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  28811. }
  28812. /**
  28813. * Base class for the main features of a material in Babylon.js
  28814. */
  28815. export class Material implements IAnimatable {
  28816. /**
  28817. * Returns the triangle fill mode
  28818. */
  28819. static readonly TriangleFillMode: number;
  28820. /**
  28821. * Returns the wireframe mode
  28822. */
  28823. static readonly WireFrameFillMode: number;
  28824. /**
  28825. * Returns the point fill mode
  28826. */
  28827. static readonly PointFillMode: number;
  28828. /**
  28829. * Returns the point list draw mode
  28830. */
  28831. static readonly PointListDrawMode: number;
  28832. /**
  28833. * Returns the line list draw mode
  28834. */
  28835. static readonly LineListDrawMode: number;
  28836. /**
  28837. * Returns the line loop draw mode
  28838. */
  28839. static readonly LineLoopDrawMode: number;
  28840. /**
  28841. * Returns the line strip draw mode
  28842. */
  28843. static readonly LineStripDrawMode: number;
  28844. /**
  28845. * Returns the triangle strip draw mode
  28846. */
  28847. static readonly TriangleStripDrawMode: number;
  28848. /**
  28849. * Returns the triangle fan draw mode
  28850. */
  28851. static readonly TriangleFanDrawMode: number;
  28852. /**
  28853. * Stores the clock-wise side orientation
  28854. */
  28855. static readonly ClockWiseSideOrientation: number;
  28856. /**
  28857. * Stores the counter clock-wise side orientation
  28858. */
  28859. static readonly CounterClockWiseSideOrientation: number;
  28860. /**
  28861. * The dirty texture flag value
  28862. */
  28863. static readonly TextureDirtyFlag: number;
  28864. /**
  28865. * The dirty light flag value
  28866. */
  28867. static readonly LightDirtyFlag: number;
  28868. /**
  28869. * The dirty fresnel flag value
  28870. */
  28871. static readonly FresnelDirtyFlag: number;
  28872. /**
  28873. * The dirty attribute flag value
  28874. */
  28875. static readonly AttributesDirtyFlag: number;
  28876. /**
  28877. * The dirty misc flag value
  28878. */
  28879. static readonly MiscDirtyFlag: number;
  28880. /**
  28881. * The dirty prepass flag value
  28882. */
  28883. static readonly PrePassDirtyFlag: number;
  28884. /**
  28885. * The all dirty flag value
  28886. */
  28887. static readonly AllDirtyFlag: number;
  28888. /**
  28889. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  28890. */
  28891. static readonly MATERIAL_OPAQUE: number;
  28892. /**
  28893. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  28894. */
  28895. static readonly MATERIAL_ALPHATEST: number;
  28896. /**
  28897. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28898. */
  28899. static readonly MATERIAL_ALPHABLEND: number;
  28900. /**
  28901. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28902. * They are also discarded below the alpha cutoff threshold to improve performances.
  28903. */
  28904. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  28905. /**
  28906. * The Whiteout method is used to blend normals.
  28907. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  28908. */
  28909. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  28910. /**
  28911. * The Reoriented Normal Mapping method is used to blend normals.
  28912. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  28913. */
  28914. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  28915. /**
  28916. * Custom callback helping to override the default shader used in the material.
  28917. */
  28918. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  28919. /**
  28920. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  28921. */
  28922. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  28923. /**
  28924. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  28925. * This means that the material can keep using a previous shader while a new one is being compiled.
  28926. * This is mostly used when shader parallel compilation is supported (true by default)
  28927. */
  28928. allowShaderHotSwapping: boolean;
  28929. /**
  28930. * The ID of the material
  28931. */
  28932. id: string;
  28933. /**
  28934. * Gets or sets the unique id of the material
  28935. */
  28936. uniqueId: number;
  28937. /**
  28938. * The name of the material
  28939. */
  28940. name: string;
  28941. /**
  28942. * Gets or sets user defined metadata
  28943. */
  28944. metadata: any;
  28945. /**
  28946. * For internal use only. Please do not use.
  28947. */
  28948. reservedDataStore: any;
  28949. /**
  28950. * Specifies if the ready state should be checked on each call
  28951. */
  28952. checkReadyOnEveryCall: boolean;
  28953. /**
  28954. * Specifies if the ready state should be checked once
  28955. */
  28956. checkReadyOnlyOnce: boolean;
  28957. /**
  28958. * The state of the material
  28959. */
  28960. state: string;
  28961. /**
  28962. * If the material can be rendered to several textures with MRT extension
  28963. */
  28964. get canRenderToMRT(): boolean;
  28965. /**
  28966. * The alpha value of the material
  28967. */
  28968. protected _alpha: number;
  28969. /**
  28970. * List of inspectable custom properties (used by the Inspector)
  28971. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28972. */
  28973. inspectableCustomProperties: IInspectable[];
  28974. /**
  28975. * Sets the alpha value of the material
  28976. */
  28977. set alpha(value: number);
  28978. /**
  28979. * Gets the alpha value of the material
  28980. */
  28981. get alpha(): number;
  28982. /**
  28983. * Specifies if back face culling is enabled
  28984. */
  28985. protected _backFaceCulling: boolean;
  28986. /**
  28987. * Sets the back-face culling state
  28988. */
  28989. set backFaceCulling(value: boolean);
  28990. /**
  28991. * Gets the back-face culling state
  28992. */
  28993. get backFaceCulling(): boolean;
  28994. /**
  28995. * Stores the value for side orientation
  28996. */
  28997. sideOrientation: number;
  28998. /**
  28999. * Callback triggered when the material is compiled
  29000. */
  29001. onCompiled: Nullable<(effect: Effect) => void>;
  29002. /**
  29003. * Callback triggered when an error occurs
  29004. */
  29005. onError: Nullable<(effect: Effect, errors: string) => void>;
  29006. /**
  29007. * Callback triggered to get the render target textures
  29008. */
  29009. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29010. /**
  29011. * Gets a boolean indicating that current material needs to register RTT
  29012. */
  29013. get hasRenderTargetTextures(): boolean;
  29014. /**
  29015. * Specifies if the material should be serialized
  29016. */
  29017. doNotSerialize: boolean;
  29018. /**
  29019. * @hidden
  29020. */
  29021. _storeEffectOnSubMeshes: boolean;
  29022. /**
  29023. * Stores the animations for the material
  29024. */
  29025. animations: Nullable<Array<Animation>>;
  29026. /**
  29027. * An event triggered when the material is disposed
  29028. */
  29029. onDisposeObservable: Observable<Material>;
  29030. /**
  29031. * An observer which watches for dispose events
  29032. */
  29033. private _onDisposeObserver;
  29034. private _onUnBindObservable;
  29035. /**
  29036. * Called during a dispose event
  29037. */
  29038. set onDispose(callback: () => void);
  29039. private _onBindObservable;
  29040. /**
  29041. * An event triggered when the material is bound
  29042. */
  29043. get onBindObservable(): Observable<AbstractMesh>;
  29044. /**
  29045. * An observer which watches for bind events
  29046. */
  29047. private _onBindObserver;
  29048. /**
  29049. * Called during a bind event
  29050. */
  29051. set onBind(callback: (Mesh: AbstractMesh) => void);
  29052. /**
  29053. * An event triggered when the material is unbound
  29054. */
  29055. get onUnBindObservable(): Observable<Material>;
  29056. protected _onEffectCreatedObservable: Nullable<Observable<{
  29057. effect: Effect;
  29058. subMesh: Nullable<SubMesh>;
  29059. }>>;
  29060. /**
  29061. * An event triggered when the effect is (re)created
  29062. */
  29063. get onEffectCreatedObservable(): Observable<{
  29064. effect: Effect;
  29065. subMesh: Nullable<SubMesh>;
  29066. }>;
  29067. /**
  29068. * Stores the value of the alpha mode
  29069. */
  29070. private _alphaMode;
  29071. /**
  29072. * Sets the value of the alpha mode.
  29073. *
  29074. * | Value | Type | Description |
  29075. * | --- | --- | --- |
  29076. * | 0 | ALPHA_DISABLE | |
  29077. * | 1 | ALPHA_ADD | |
  29078. * | 2 | ALPHA_COMBINE | |
  29079. * | 3 | ALPHA_SUBTRACT | |
  29080. * | 4 | ALPHA_MULTIPLY | |
  29081. * | 5 | ALPHA_MAXIMIZED | |
  29082. * | 6 | ALPHA_ONEONE | |
  29083. * | 7 | ALPHA_PREMULTIPLIED | |
  29084. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29085. * | 9 | ALPHA_INTERPOLATE | |
  29086. * | 10 | ALPHA_SCREENMODE | |
  29087. *
  29088. */
  29089. set alphaMode(value: number);
  29090. /**
  29091. * Gets the value of the alpha mode
  29092. */
  29093. get alphaMode(): number;
  29094. /**
  29095. * Stores the state of the need depth pre-pass value
  29096. */
  29097. private _needDepthPrePass;
  29098. /**
  29099. * Sets the need depth pre-pass value
  29100. */
  29101. set needDepthPrePass(value: boolean);
  29102. /**
  29103. * Gets the depth pre-pass value
  29104. */
  29105. get needDepthPrePass(): boolean;
  29106. /**
  29107. * Specifies if depth writing should be disabled
  29108. */
  29109. disableDepthWrite: boolean;
  29110. /**
  29111. * Specifies if color writing should be disabled
  29112. */
  29113. disableColorWrite: boolean;
  29114. /**
  29115. * Specifies if depth writing should be forced
  29116. */
  29117. forceDepthWrite: boolean;
  29118. /**
  29119. * Specifies the depth function that should be used. 0 means the default engine function
  29120. */
  29121. depthFunction: number;
  29122. /**
  29123. * Specifies if there should be a separate pass for culling
  29124. */
  29125. separateCullingPass: boolean;
  29126. /**
  29127. * Stores the state specifing if fog should be enabled
  29128. */
  29129. private _fogEnabled;
  29130. /**
  29131. * Sets the state for enabling fog
  29132. */
  29133. set fogEnabled(value: boolean);
  29134. /**
  29135. * Gets the value of the fog enabled state
  29136. */
  29137. get fogEnabled(): boolean;
  29138. /**
  29139. * Stores the size of points
  29140. */
  29141. pointSize: number;
  29142. /**
  29143. * Stores the z offset value
  29144. */
  29145. zOffset: number;
  29146. get wireframe(): boolean;
  29147. /**
  29148. * Sets the state of wireframe mode
  29149. */
  29150. set wireframe(value: boolean);
  29151. /**
  29152. * Gets the value specifying if point clouds are enabled
  29153. */
  29154. get pointsCloud(): boolean;
  29155. /**
  29156. * Sets the state of point cloud mode
  29157. */
  29158. set pointsCloud(value: boolean);
  29159. /**
  29160. * Gets the material fill mode
  29161. */
  29162. get fillMode(): number;
  29163. /**
  29164. * Sets the material fill mode
  29165. */
  29166. set fillMode(value: number);
  29167. /**
  29168. * @hidden
  29169. * Stores the effects for the material
  29170. */
  29171. _effect: Nullable<Effect>;
  29172. /**
  29173. * Specifies if uniform buffers should be used
  29174. */
  29175. private _useUBO;
  29176. /**
  29177. * Stores a reference to the scene
  29178. */
  29179. private _scene;
  29180. /**
  29181. * Stores the fill mode state
  29182. */
  29183. private _fillMode;
  29184. /**
  29185. * Specifies if the depth write state should be cached
  29186. */
  29187. private _cachedDepthWriteState;
  29188. /**
  29189. * Specifies if the color write state should be cached
  29190. */
  29191. private _cachedColorWriteState;
  29192. /**
  29193. * Specifies if the depth function state should be cached
  29194. */
  29195. private _cachedDepthFunctionState;
  29196. /**
  29197. * Stores the uniform buffer
  29198. */
  29199. protected _uniformBuffer: UniformBuffer;
  29200. /** @hidden */
  29201. _indexInSceneMaterialArray: number;
  29202. /** @hidden */
  29203. meshMap: Nullable<{
  29204. [id: string]: AbstractMesh | undefined;
  29205. }>;
  29206. /**
  29207. * Creates a material instance
  29208. * @param name defines the name of the material
  29209. * @param scene defines the scene to reference
  29210. * @param doNotAdd specifies if the material should be added to the scene
  29211. */
  29212. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29213. /**
  29214. * Returns a string representation of the current material
  29215. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29216. * @returns a string with material information
  29217. */
  29218. toString(fullDetails?: boolean): string;
  29219. /**
  29220. * Gets the class name of the material
  29221. * @returns a string with the class name of the material
  29222. */
  29223. getClassName(): string;
  29224. /**
  29225. * Specifies if updates for the material been locked
  29226. */
  29227. get isFrozen(): boolean;
  29228. /**
  29229. * Locks updates for the material
  29230. */
  29231. freeze(): void;
  29232. /**
  29233. * Unlocks updates for the material
  29234. */
  29235. unfreeze(): void;
  29236. /**
  29237. * Specifies if the material is ready to be used
  29238. * @param mesh defines the mesh to check
  29239. * @param useInstances specifies if instances should be used
  29240. * @returns a boolean indicating if the material is ready to be used
  29241. */
  29242. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29243. /**
  29244. * Specifies that the submesh is ready to be used
  29245. * @param mesh defines the mesh to check
  29246. * @param subMesh defines which submesh to check
  29247. * @param useInstances specifies that instances should be used
  29248. * @returns a boolean indicating that the submesh is ready or not
  29249. */
  29250. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29251. /**
  29252. * Returns the material effect
  29253. * @returns the effect associated with the material
  29254. */
  29255. getEffect(): Nullable<Effect>;
  29256. /**
  29257. * Returns the current scene
  29258. * @returns a Scene
  29259. */
  29260. getScene(): Scene;
  29261. /**
  29262. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29263. */
  29264. protected _forceAlphaTest: boolean;
  29265. /**
  29266. * The transparency mode of the material.
  29267. */
  29268. protected _transparencyMode: Nullable<number>;
  29269. /**
  29270. * Gets the current transparency mode.
  29271. */
  29272. get transparencyMode(): Nullable<number>;
  29273. /**
  29274. * Sets the transparency mode of the material.
  29275. *
  29276. * | Value | Type | Description |
  29277. * | ----- | ----------------------------------- | ----------- |
  29278. * | 0 | OPAQUE | |
  29279. * | 1 | ALPHATEST | |
  29280. * | 2 | ALPHABLEND | |
  29281. * | 3 | ALPHATESTANDBLEND | |
  29282. *
  29283. */
  29284. set transparencyMode(value: Nullable<number>);
  29285. /**
  29286. * Returns true if alpha blending should be disabled.
  29287. */
  29288. protected get _disableAlphaBlending(): boolean;
  29289. /**
  29290. * Specifies whether or not this material should be rendered in alpha blend mode.
  29291. * @returns a boolean specifying if alpha blending is needed
  29292. */
  29293. needAlphaBlending(): boolean;
  29294. /**
  29295. * Specifies if the mesh will require alpha blending
  29296. * @param mesh defines the mesh to check
  29297. * @returns a boolean specifying if alpha blending is needed for the mesh
  29298. */
  29299. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29300. /**
  29301. * Specifies whether or not this material should be rendered in alpha test mode.
  29302. * @returns a boolean specifying if an alpha test is needed.
  29303. */
  29304. needAlphaTesting(): boolean;
  29305. /**
  29306. * Specifies if material alpha testing should be turned on for the mesh
  29307. * @param mesh defines the mesh to check
  29308. */
  29309. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29310. /**
  29311. * Gets the texture used for the alpha test
  29312. * @returns the texture to use for alpha testing
  29313. */
  29314. getAlphaTestTexture(): Nullable<BaseTexture>;
  29315. /**
  29316. * Marks the material to indicate that it needs to be re-calculated
  29317. */
  29318. markDirty(): void;
  29319. /** @hidden */
  29320. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29321. /**
  29322. * Binds the material to the mesh
  29323. * @param world defines the world transformation matrix
  29324. * @param mesh defines the mesh to bind the material to
  29325. */
  29326. bind(world: Matrix, mesh?: Mesh): void;
  29327. /**
  29328. * Binds the submesh to the material
  29329. * @param world defines the world transformation matrix
  29330. * @param mesh defines the mesh containing the submesh
  29331. * @param subMesh defines the submesh to bind the material to
  29332. */
  29333. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29334. /**
  29335. * Binds the world matrix to the material
  29336. * @param world defines the world transformation matrix
  29337. */
  29338. bindOnlyWorldMatrix(world: Matrix): void;
  29339. /**
  29340. * Binds the scene's uniform buffer to the effect.
  29341. * @param effect defines the effect to bind to the scene uniform buffer
  29342. * @param sceneUbo defines the uniform buffer storing scene data
  29343. */
  29344. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29345. /**
  29346. * Binds the view matrix to the effect
  29347. * @param effect defines the effect to bind the view matrix to
  29348. */
  29349. bindView(effect: Effect): void;
  29350. /**
  29351. * Binds the view projection matrix to the effect
  29352. * @param effect defines the effect to bind the view projection matrix to
  29353. */
  29354. bindViewProjection(effect: Effect): void;
  29355. /**
  29356. * Processes to execute after binding the material to a mesh
  29357. * @param mesh defines the rendered mesh
  29358. */
  29359. protected _afterBind(mesh?: Mesh): void;
  29360. /**
  29361. * Unbinds the material from the mesh
  29362. */
  29363. unbind(): void;
  29364. /**
  29365. * Gets the active textures from the material
  29366. * @returns an array of textures
  29367. */
  29368. getActiveTextures(): BaseTexture[];
  29369. /**
  29370. * Specifies if the material uses a texture
  29371. * @param texture defines the texture to check against the material
  29372. * @returns a boolean specifying if the material uses the texture
  29373. */
  29374. hasTexture(texture: BaseTexture): boolean;
  29375. /**
  29376. * Makes a duplicate of the material, and gives it a new name
  29377. * @param name defines the new name for the duplicated material
  29378. * @returns the cloned material
  29379. */
  29380. clone(name: string): Nullable<Material>;
  29381. /**
  29382. * Gets the meshes bound to the material
  29383. * @returns an array of meshes bound to the material
  29384. */
  29385. getBindedMeshes(): AbstractMesh[];
  29386. /**
  29387. * Force shader compilation
  29388. * @param mesh defines the mesh associated with this material
  29389. * @param onCompiled defines a function to execute once the material is compiled
  29390. * @param options defines the options to configure the compilation
  29391. * @param onError defines a function to execute if the material fails compiling
  29392. */
  29393. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29394. /**
  29395. * Force shader compilation
  29396. * @param mesh defines the mesh that will use this material
  29397. * @param options defines additional options for compiling the shaders
  29398. * @returns a promise that resolves when the compilation completes
  29399. */
  29400. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29401. private static readonly _AllDirtyCallBack;
  29402. private static readonly _ImageProcessingDirtyCallBack;
  29403. private static readonly _TextureDirtyCallBack;
  29404. private static readonly _FresnelDirtyCallBack;
  29405. private static readonly _MiscDirtyCallBack;
  29406. private static readonly _PrePassDirtyCallBack;
  29407. private static readonly _LightsDirtyCallBack;
  29408. private static readonly _AttributeDirtyCallBack;
  29409. private static _FresnelAndMiscDirtyCallBack;
  29410. private static _TextureAndMiscDirtyCallBack;
  29411. private static readonly _DirtyCallbackArray;
  29412. private static readonly _RunDirtyCallBacks;
  29413. /**
  29414. * Marks a define in the material to indicate that it needs to be re-computed
  29415. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29416. */
  29417. markAsDirty(flag: number): void;
  29418. /**
  29419. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29420. * @param func defines a function which checks material defines against the submeshes
  29421. */
  29422. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29423. /**
  29424. * Indicates that the scene should check if the rendering now needs a prepass
  29425. */
  29426. protected _markScenePrePassDirty(): void;
  29427. /**
  29428. * Indicates that we need to re-calculated for all submeshes
  29429. */
  29430. protected _markAllSubMeshesAsAllDirty(): void;
  29431. /**
  29432. * Indicates that image processing needs to be re-calculated for all submeshes
  29433. */
  29434. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29435. /**
  29436. * Indicates that textures need to be re-calculated for all submeshes
  29437. */
  29438. protected _markAllSubMeshesAsTexturesDirty(): void;
  29439. /**
  29440. * Indicates that fresnel needs to be re-calculated for all submeshes
  29441. */
  29442. protected _markAllSubMeshesAsFresnelDirty(): void;
  29443. /**
  29444. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29445. */
  29446. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29447. /**
  29448. * Indicates that lights need to be re-calculated for all submeshes
  29449. */
  29450. protected _markAllSubMeshesAsLightsDirty(): void;
  29451. /**
  29452. * Indicates that attributes need to be re-calculated for all submeshes
  29453. */
  29454. protected _markAllSubMeshesAsAttributesDirty(): void;
  29455. /**
  29456. * Indicates that misc needs to be re-calculated for all submeshes
  29457. */
  29458. protected _markAllSubMeshesAsMiscDirty(): void;
  29459. /**
  29460. * Indicates that prepass needs to be re-calculated for all submeshes
  29461. */
  29462. protected _markAllSubMeshesAsPrePassDirty(): void;
  29463. /**
  29464. * Indicates that textures and misc need to be re-calculated for all submeshes
  29465. */
  29466. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29467. /**
  29468. * Sets the required values to the prepass renderer.
  29469. * @param prePassRenderer defines the prepass renderer to setup.
  29470. * @returns true if the pre pass is needed.
  29471. */
  29472. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29473. /**
  29474. * Disposes the material
  29475. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29476. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29477. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29478. */
  29479. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29480. /** @hidden */
  29481. private releaseVertexArrayObject;
  29482. /**
  29483. * Serializes this material
  29484. * @returns the serialized material object
  29485. */
  29486. serialize(): any;
  29487. /**
  29488. * Creates a material from parsed material data
  29489. * @param parsedMaterial defines parsed material data
  29490. * @param scene defines the hosting scene
  29491. * @param rootUrl defines the root URL to use to load textures
  29492. * @returns a new material
  29493. */
  29494. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29495. }
  29496. }
  29497. declare module BABYLON {
  29498. /**
  29499. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29500. * separate meshes. This can be use to improve performances.
  29501. * @see https://doc.babylonjs.com/how_to/multi_materials
  29502. */
  29503. export class MultiMaterial extends Material {
  29504. private _subMaterials;
  29505. /**
  29506. * Gets or Sets the list of Materials used within the multi material.
  29507. * They need to be ordered according to the submeshes order in the associated mesh
  29508. */
  29509. get subMaterials(): Nullable<Material>[];
  29510. set subMaterials(value: Nullable<Material>[]);
  29511. /**
  29512. * Function used to align with Node.getChildren()
  29513. * @returns the list of Materials used within the multi material
  29514. */
  29515. getChildren(): Nullable<Material>[];
  29516. /**
  29517. * Instantiates a new Multi Material
  29518. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29519. * separate meshes. This can be use to improve performances.
  29520. * @see https://doc.babylonjs.com/how_to/multi_materials
  29521. * @param name Define the name in the scene
  29522. * @param scene Define the scene the material belongs to
  29523. */
  29524. constructor(name: string, scene: Scene);
  29525. private _hookArray;
  29526. /**
  29527. * Get one of the submaterial by its index in the submaterials array
  29528. * @param index The index to look the sub material at
  29529. * @returns The Material if the index has been defined
  29530. */
  29531. getSubMaterial(index: number): Nullable<Material>;
  29532. /**
  29533. * Get the list of active textures for the whole sub materials list.
  29534. * @returns All the textures that will be used during the rendering
  29535. */
  29536. getActiveTextures(): BaseTexture[];
  29537. /**
  29538. * Gets the current class name of the material e.g. "MultiMaterial"
  29539. * Mainly use in serialization.
  29540. * @returns the class name
  29541. */
  29542. getClassName(): string;
  29543. /**
  29544. * Checks if the material is ready to render the requested sub mesh
  29545. * @param mesh Define the mesh the submesh belongs to
  29546. * @param subMesh Define the sub mesh to look readyness for
  29547. * @param useInstances Define whether or not the material is used with instances
  29548. * @returns true if ready, otherwise false
  29549. */
  29550. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29551. /**
  29552. * Clones the current material and its related sub materials
  29553. * @param name Define the name of the newly cloned material
  29554. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29555. * @returns the cloned material
  29556. */
  29557. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29558. /**
  29559. * Serializes the materials into a JSON representation.
  29560. * @returns the JSON representation
  29561. */
  29562. serialize(): any;
  29563. /**
  29564. * Dispose the material and release its associated resources
  29565. * @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)
  29566. * @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)
  29567. * @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)
  29568. */
  29569. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29570. /**
  29571. * Creates a MultiMaterial from parsed MultiMaterial data.
  29572. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29573. * @param scene defines the hosting scene
  29574. * @returns a new MultiMaterial
  29575. */
  29576. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  29577. }
  29578. }
  29579. declare module BABYLON {
  29580. /**
  29581. * Defines a subdivision inside a mesh
  29582. */
  29583. export class SubMesh implements ICullable {
  29584. /** the material index to use */
  29585. materialIndex: number;
  29586. /** vertex index start */
  29587. verticesStart: number;
  29588. /** vertices count */
  29589. verticesCount: number;
  29590. /** index start */
  29591. indexStart: number;
  29592. /** indices count */
  29593. indexCount: number;
  29594. /** @hidden */
  29595. _materialDefines: Nullable<MaterialDefines>;
  29596. /** @hidden */
  29597. _materialEffect: Nullable<Effect>;
  29598. /** @hidden */
  29599. _effectOverride: Nullable<Effect>;
  29600. /**
  29601. * Gets material defines used by the effect associated to the sub mesh
  29602. */
  29603. get materialDefines(): Nullable<MaterialDefines>;
  29604. /**
  29605. * Sets material defines used by the effect associated to the sub mesh
  29606. */
  29607. set materialDefines(defines: Nullable<MaterialDefines>);
  29608. /**
  29609. * Gets associated effect
  29610. */
  29611. get effect(): Nullable<Effect>;
  29612. /**
  29613. * Sets associated effect (effect used to render this submesh)
  29614. * @param effect defines the effect to associate with
  29615. * @param defines defines the set of defines used to compile this effect
  29616. */
  29617. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29618. /** @hidden */
  29619. _linesIndexCount: number;
  29620. private _mesh;
  29621. private _renderingMesh;
  29622. private _boundingInfo;
  29623. private _linesIndexBuffer;
  29624. /** @hidden */
  29625. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29626. /** @hidden */
  29627. _trianglePlanes: Plane[];
  29628. /** @hidden */
  29629. _lastColliderTransformMatrix: Nullable<Matrix>;
  29630. /** @hidden */
  29631. _renderId: number;
  29632. /** @hidden */
  29633. _alphaIndex: number;
  29634. /** @hidden */
  29635. _distanceToCamera: number;
  29636. /** @hidden */
  29637. _id: number;
  29638. private _currentMaterial;
  29639. /**
  29640. * Add a new submesh to a mesh
  29641. * @param materialIndex defines the material index to use
  29642. * @param verticesStart defines vertex index start
  29643. * @param verticesCount defines vertices count
  29644. * @param indexStart defines index start
  29645. * @param indexCount defines indices count
  29646. * @param mesh defines the parent mesh
  29647. * @param renderingMesh defines an optional rendering mesh
  29648. * @param createBoundingBox defines if bounding box should be created for this submesh
  29649. * @returns the new submesh
  29650. */
  29651. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29652. /**
  29653. * Creates a new submesh
  29654. * @param materialIndex defines the material index to use
  29655. * @param verticesStart defines vertex index start
  29656. * @param verticesCount defines vertices count
  29657. * @param indexStart defines index start
  29658. * @param indexCount defines indices count
  29659. * @param mesh defines the parent mesh
  29660. * @param renderingMesh defines an optional rendering mesh
  29661. * @param createBoundingBox defines if bounding box should be created for this submesh
  29662. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  29663. */
  29664. constructor(
  29665. /** the material index to use */
  29666. materialIndex: number,
  29667. /** vertex index start */
  29668. verticesStart: number,
  29669. /** vertices count */
  29670. verticesCount: number,
  29671. /** index start */
  29672. indexStart: number,
  29673. /** indices count */
  29674. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  29675. /**
  29676. * Returns true if this submesh covers the entire parent mesh
  29677. * @ignorenaming
  29678. */
  29679. get IsGlobal(): boolean;
  29680. /**
  29681. * Returns the submesh BoudingInfo object
  29682. * @returns current bounding info (or mesh's one if the submesh is global)
  29683. */
  29684. getBoundingInfo(): BoundingInfo;
  29685. /**
  29686. * Sets the submesh BoundingInfo
  29687. * @param boundingInfo defines the new bounding info to use
  29688. * @returns the SubMesh
  29689. */
  29690. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29691. /**
  29692. * Returns the mesh of the current submesh
  29693. * @return the parent mesh
  29694. */
  29695. getMesh(): AbstractMesh;
  29696. /**
  29697. * Returns the rendering mesh of the submesh
  29698. * @returns the rendering mesh (could be different from parent mesh)
  29699. */
  29700. getRenderingMesh(): Mesh;
  29701. /**
  29702. * Returns the replacement mesh of the submesh
  29703. * @returns the replacement mesh (could be different from parent mesh)
  29704. */
  29705. getReplacementMesh(): Nullable<AbstractMesh>;
  29706. /**
  29707. * Returns the effective mesh of the submesh
  29708. * @returns the effective mesh (could be different from parent mesh)
  29709. */
  29710. getEffectiveMesh(): AbstractMesh;
  29711. /**
  29712. * Returns the submesh material
  29713. * @returns null or the current material
  29714. */
  29715. getMaterial(): Nullable<Material>;
  29716. private _IsMultiMaterial;
  29717. /**
  29718. * Sets a new updated BoundingInfo object to the submesh
  29719. * @param data defines an optional position array to use to determine the bounding info
  29720. * @returns the SubMesh
  29721. */
  29722. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  29723. /** @hidden */
  29724. _checkCollision(collider: Collider): boolean;
  29725. /**
  29726. * Updates the submesh BoundingInfo
  29727. * @param world defines the world matrix to use to update the bounding info
  29728. * @returns the submesh
  29729. */
  29730. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29731. /**
  29732. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29733. * @param frustumPlanes defines the frustum planes
  29734. * @returns true if the submesh is intersecting with the frustum
  29735. */
  29736. isInFrustum(frustumPlanes: Plane[]): boolean;
  29737. /**
  29738. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29739. * @param frustumPlanes defines the frustum planes
  29740. * @returns true if the submesh is inside the frustum
  29741. */
  29742. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29743. /**
  29744. * Renders the submesh
  29745. * @param enableAlphaMode defines if alpha needs to be used
  29746. * @returns the submesh
  29747. */
  29748. render(enableAlphaMode: boolean): SubMesh;
  29749. /**
  29750. * @hidden
  29751. */
  29752. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  29753. /**
  29754. * Checks if the submesh intersects with a ray
  29755. * @param ray defines the ray to test
  29756. * @returns true is the passed ray intersects the submesh bounding box
  29757. */
  29758. canIntersects(ray: Ray): boolean;
  29759. /**
  29760. * Intersects current submesh with a ray
  29761. * @param ray defines the ray to test
  29762. * @param positions defines mesh's positions array
  29763. * @param indices defines mesh's indices array
  29764. * @param fastCheck defines if the first intersection will be used (and not the closest)
  29765. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29766. * @returns intersection info or null if no intersection
  29767. */
  29768. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  29769. /** @hidden */
  29770. private _intersectLines;
  29771. /** @hidden */
  29772. private _intersectUnIndexedLines;
  29773. /** @hidden */
  29774. private _intersectTriangles;
  29775. /** @hidden */
  29776. private _intersectUnIndexedTriangles;
  29777. /** @hidden */
  29778. _rebuild(): void;
  29779. /**
  29780. * Creates a new submesh from the passed mesh
  29781. * @param newMesh defines the new hosting mesh
  29782. * @param newRenderingMesh defines an optional rendering mesh
  29783. * @returns the new submesh
  29784. */
  29785. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29786. /**
  29787. * Release associated resources
  29788. */
  29789. dispose(): void;
  29790. /**
  29791. * Gets the class name
  29792. * @returns the string "SubMesh".
  29793. */
  29794. getClassName(): string;
  29795. /**
  29796. * Creates a new submesh from indices data
  29797. * @param materialIndex the index of the main mesh material
  29798. * @param startIndex the index where to start the copy in the mesh indices array
  29799. * @param indexCount the number of indices to copy then from the startIndex
  29800. * @param mesh the main mesh to create the submesh from
  29801. * @param renderingMesh the optional rendering mesh
  29802. * @returns a new submesh
  29803. */
  29804. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29805. }
  29806. }
  29807. declare module BABYLON {
  29808. /**
  29809. * Class used to represent data loading progression
  29810. */
  29811. export class SceneLoaderFlags {
  29812. private static _ForceFullSceneLoadingForIncremental;
  29813. private static _ShowLoadingScreen;
  29814. private static _CleanBoneMatrixWeights;
  29815. private static _loggingLevel;
  29816. /**
  29817. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  29818. */
  29819. static get ForceFullSceneLoadingForIncremental(): boolean;
  29820. static set ForceFullSceneLoadingForIncremental(value: boolean);
  29821. /**
  29822. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  29823. */
  29824. static get ShowLoadingScreen(): boolean;
  29825. static set ShowLoadingScreen(value: boolean);
  29826. /**
  29827. * Defines the current logging level (while loading the scene)
  29828. * @ignorenaming
  29829. */
  29830. static get loggingLevel(): number;
  29831. static set loggingLevel(value: number);
  29832. /**
  29833. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  29834. */
  29835. static get CleanBoneMatrixWeights(): boolean;
  29836. static set CleanBoneMatrixWeights(value: boolean);
  29837. }
  29838. }
  29839. declare module BABYLON {
  29840. /**
  29841. * Class used to store geometry data (vertex buffers + index buffer)
  29842. */
  29843. export class Geometry implements IGetSetVerticesData {
  29844. /**
  29845. * Gets or sets the ID of the geometry
  29846. */
  29847. id: string;
  29848. /**
  29849. * Gets or sets the unique ID of the geometry
  29850. */
  29851. uniqueId: number;
  29852. /**
  29853. * Gets the delay loading state of the geometry (none by default which means not delayed)
  29854. */
  29855. delayLoadState: number;
  29856. /**
  29857. * Gets the file containing the data to load when running in delay load state
  29858. */
  29859. delayLoadingFile: Nullable<string>;
  29860. /**
  29861. * Callback called when the geometry is updated
  29862. */
  29863. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  29864. private _scene;
  29865. private _engine;
  29866. private _meshes;
  29867. private _totalVertices;
  29868. /** @hidden */
  29869. _indices: IndicesArray;
  29870. /** @hidden */
  29871. _vertexBuffers: {
  29872. [key: string]: VertexBuffer;
  29873. };
  29874. private _isDisposed;
  29875. private _extend;
  29876. private _boundingBias;
  29877. /** @hidden */
  29878. _delayInfo: Array<string>;
  29879. private _indexBuffer;
  29880. private _indexBufferIsUpdatable;
  29881. /** @hidden */
  29882. _boundingInfo: Nullable<BoundingInfo>;
  29883. /** @hidden */
  29884. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  29885. /** @hidden */
  29886. _softwareSkinningFrameId: number;
  29887. private _vertexArrayObjects;
  29888. private _updatable;
  29889. /** @hidden */
  29890. _positions: Nullable<Vector3[]>;
  29891. /**
  29892. * 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
  29893. */
  29894. get boundingBias(): Vector2;
  29895. /**
  29896. * 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
  29897. */
  29898. set boundingBias(value: Vector2);
  29899. /**
  29900. * Static function used to attach a new empty geometry to a mesh
  29901. * @param mesh defines the mesh to attach the geometry to
  29902. * @returns the new Geometry
  29903. */
  29904. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  29905. /** Get the list of meshes using this geometry */
  29906. get meshes(): Mesh[];
  29907. /**
  29908. * 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
  29909. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  29910. */
  29911. useBoundingInfoFromGeometry: boolean;
  29912. /**
  29913. * Creates a new geometry
  29914. * @param id defines the unique ID
  29915. * @param scene defines the hosting scene
  29916. * @param vertexData defines the VertexData used to get geometry data
  29917. * @param updatable defines if geometry must be updatable (false by default)
  29918. * @param mesh defines the mesh that will be associated with the geometry
  29919. */
  29920. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  29921. /**
  29922. * Gets the current extend of the geometry
  29923. */
  29924. get extend(): {
  29925. minimum: Vector3;
  29926. maximum: Vector3;
  29927. };
  29928. /**
  29929. * Gets the hosting scene
  29930. * @returns the hosting Scene
  29931. */
  29932. getScene(): Scene;
  29933. /**
  29934. * Gets the hosting engine
  29935. * @returns the hosting Engine
  29936. */
  29937. getEngine(): Engine;
  29938. /**
  29939. * Defines if the geometry is ready to use
  29940. * @returns true if the geometry is ready to be used
  29941. */
  29942. isReady(): boolean;
  29943. /**
  29944. * Gets a value indicating that the geometry should not be serialized
  29945. */
  29946. get doNotSerialize(): boolean;
  29947. /** @hidden */
  29948. _rebuild(): void;
  29949. /**
  29950. * Affects all geometry data in one call
  29951. * @param vertexData defines the geometry data
  29952. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  29953. */
  29954. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  29955. /**
  29956. * Set specific vertex data
  29957. * @param kind defines the data kind (Position, normal, etc...)
  29958. * @param data defines the vertex data to use
  29959. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  29960. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  29961. */
  29962. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  29963. /**
  29964. * Removes a specific vertex data
  29965. * @param kind defines the data kind (Position, normal, etc...)
  29966. */
  29967. removeVerticesData(kind: string): void;
  29968. /**
  29969. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  29970. * @param buffer defines the vertex buffer to use
  29971. * @param totalVertices defines the total number of vertices for position kind (could be null)
  29972. */
  29973. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  29974. /**
  29975. * Update a specific vertex buffer
  29976. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  29977. * It will do nothing if the buffer is not updatable
  29978. * @param kind defines the data kind (Position, normal, etc...)
  29979. * @param data defines the data to use
  29980. * @param offset defines the offset in the target buffer where to store the data
  29981. * @param useBytes set to true if the offset is in bytes
  29982. */
  29983. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  29984. /**
  29985. * Update a specific vertex buffer
  29986. * This function will create a new buffer if the current one is not updatable
  29987. * @param kind defines the data kind (Position, normal, etc...)
  29988. * @param data defines the data to use
  29989. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  29990. */
  29991. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  29992. private _updateBoundingInfo;
  29993. /** @hidden */
  29994. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  29995. /**
  29996. * Gets total number of vertices
  29997. * @returns the total number of vertices
  29998. */
  29999. getTotalVertices(): number;
  30000. /**
  30001. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30002. * @param kind defines the data kind (Position, normal, etc...)
  30003. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30004. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30005. * @returns a float array containing vertex data
  30006. */
  30007. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30008. /**
  30009. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30010. * @param kind defines the data kind (Position, normal, etc...)
  30011. * @returns true if the vertex buffer with the specified kind is updatable
  30012. */
  30013. isVertexBufferUpdatable(kind: string): boolean;
  30014. /**
  30015. * Gets a specific vertex buffer
  30016. * @param kind defines the data kind (Position, normal, etc...)
  30017. * @returns a VertexBuffer
  30018. */
  30019. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30020. /**
  30021. * Returns all vertex buffers
  30022. * @return an object holding all vertex buffers indexed by kind
  30023. */
  30024. getVertexBuffers(): Nullable<{
  30025. [key: string]: VertexBuffer;
  30026. }>;
  30027. /**
  30028. * Gets a boolean indicating if specific vertex buffer is present
  30029. * @param kind defines the data kind (Position, normal, etc...)
  30030. * @returns true if data is present
  30031. */
  30032. isVerticesDataPresent(kind: string): boolean;
  30033. /**
  30034. * Gets a list of all attached data kinds (Position, normal, etc...)
  30035. * @returns a list of string containing all kinds
  30036. */
  30037. getVerticesDataKinds(): string[];
  30038. /**
  30039. * Update index buffer
  30040. * @param indices defines the indices to store in the index buffer
  30041. * @param offset defines the offset in the target buffer where to store the data
  30042. * @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)
  30043. */
  30044. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30045. /**
  30046. * Creates a new index buffer
  30047. * @param indices defines the indices to store in the index buffer
  30048. * @param totalVertices defines the total number of vertices (could be null)
  30049. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30050. */
  30051. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30052. /**
  30053. * Return the total number of indices
  30054. * @returns the total number of indices
  30055. */
  30056. getTotalIndices(): number;
  30057. /**
  30058. * Gets the index buffer array
  30059. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30060. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30061. * @returns the index buffer array
  30062. */
  30063. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30064. /**
  30065. * Gets the index buffer
  30066. * @return the index buffer
  30067. */
  30068. getIndexBuffer(): Nullable<DataBuffer>;
  30069. /** @hidden */
  30070. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30071. /**
  30072. * Release the associated resources for a specific mesh
  30073. * @param mesh defines the source mesh
  30074. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30075. */
  30076. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30077. /**
  30078. * Apply current geometry to a given mesh
  30079. * @param mesh defines the mesh to apply geometry to
  30080. */
  30081. applyToMesh(mesh: Mesh): void;
  30082. private _updateExtend;
  30083. private _applyToMesh;
  30084. private notifyUpdate;
  30085. /**
  30086. * Load the geometry if it was flagged as delay loaded
  30087. * @param scene defines the hosting scene
  30088. * @param onLoaded defines a callback called when the geometry is loaded
  30089. */
  30090. load(scene: Scene, onLoaded?: () => void): void;
  30091. private _queueLoad;
  30092. /**
  30093. * Invert the geometry to move from a right handed system to a left handed one.
  30094. */
  30095. toLeftHanded(): void;
  30096. /** @hidden */
  30097. _resetPointsArrayCache(): void;
  30098. /** @hidden */
  30099. _generatePointsArray(): boolean;
  30100. /**
  30101. * Gets a value indicating if the geometry is disposed
  30102. * @returns true if the geometry was disposed
  30103. */
  30104. isDisposed(): boolean;
  30105. private _disposeVertexArrayObjects;
  30106. /**
  30107. * Free all associated resources
  30108. */
  30109. dispose(): void;
  30110. /**
  30111. * Clone the current geometry into a new geometry
  30112. * @param id defines the unique ID of the new geometry
  30113. * @returns a new geometry object
  30114. */
  30115. copy(id: string): Geometry;
  30116. /**
  30117. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30118. * @return a JSON representation of the current geometry data (without the vertices data)
  30119. */
  30120. serialize(): any;
  30121. private toNumberArray;
  30122. /**
  30123. * Serialize all vertices data into a JSON oject
  30124. * @returns a JSON representation of the current geometry data
  30125. */
  30126. serializeVerticeData(): any;
  30127. /**
  30128. * Extracts a clone of a mesh geometry
  30129. * @param mesh defines the source mesh
  30130. * @param id defines the unique ID of the new geometry object
  30131. * @returns the new geometry object
  30132. */
  30133. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30134. /**
  30135. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30136. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30137. * Be aware Math.random() could cause collisions, but:
  30138. * "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"
  30139. * @returns a string containing a new GUID
  30140. */
  30141. static RandomId(): string;
  30142. /** @hidden */
  30143. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30144. private static _CleanMatricesWeights;
  30145. /**
  30146. * Create a new geometry from persisted data (Using .babylon file format)
  30147. * @param parsedVertexData defines the persisted data
  30148. * @param scene defines the hosting scene
  30149. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30150. * @returns the new geometry object
  30151. */
  30152. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30153. }
  30154. }
  30155. declare module BABYLON {
  30156. /**
  30157. * Define an interface for all classes that will get and set the data on vertices
  30158. */
  30159. export interface IGetSetVerticesData {
  30160. /**
  30161. * Gets a boolean indicating if specific vertex data is present
  30162. * @param kind defines the vertex data kind to use
  30163. * @returns true is data kind is present
  30164. */
  30165. isVerticesDataPresent(kind: string): boolean;
  30166. /**
  30167. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30168. * @param kind defines the data kind (Position, normal, etc...)
  30169. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30170. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30171. * @returns a float array containing vertex data
  30172. */
  30173. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30174. /**
  30175. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  30176. * @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.
  30177. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30178. * @returns the indices array or an empty array if the mesh has no geometry
  30179. */
  30180. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30181. /**
  30182. * Set specific vertex data
  30183. * @param kind defines the data kind (Position, normal, etc...)
  30184. * @param data defines the vertex data to use
  30185. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30186. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30187. */
  30188. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  30189. /**
  30190. * Update a specific associated vertex buffer
  30191. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  30192. * - VertexBuffer.PositionKind
  30193. * - VertexBuffer.UVKind
  30194. * - VertexBuffer.UV2Kind
  30195. * - VertexBuffer.UV3Kind
  30196. * - VertexBuffer.UV4Kind
  30197. * - VertexBuffer.UV5Kind
  30198. * - VertexBuffer.UV6Kind
  30199. * - VertexBuffer.ColorKind
  30200. * - VertexBuffer.MatricesIndicesKind
  30201. * - VertexBuffer.MatricesIndicesExtraKind
  30202. * - VertexBuffer.MatricesWeightsKind
  30203. * - VertexBuffer.MatricesWeightsExtraKind
  30204. * @param data defines the data source
  30205. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  30206. * @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)
  30207. */
  30208. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  30209. /**
  30210. * Creates a new index buffer
  30211. * @param indices defines the indices to store in the index buffer
  30212. * @param totalVertices defines the total number of vertices (could be null)
  30213. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30214. */
  30215. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  30216. }
  30217. /**
  30218. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  30219. */
  30220. export class VertexData {
  30221. /**
  30222. * Mesh side orientation : usually the external or front surface
  30223. */
  30224. static readonly FRONTSIDE: number;
  30225. /**
  30226. * Mesh side orientation : usually the internal or back surface
  30227. */
  30228. static readonly BACKSIDE: number;
  30229. /**
  30230. * Mesh side orientation : both internal and external or front and back surfaces
  30231. */
  30232. static readonly DOUBLESIDE: number;
  30233. /**
  30234. * Mesh side orientation : by default, `FRONTSIDE`
  30235. */
  30236. static readonly DEFAULTSIDE: number;
  30237. /**
  30238. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  30239. */
  30240. positions: Nullable<FloatArray>;
  30241. /**
  30242. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  30243. */
  30244. normals: Nullable<FloatArray>;
  30245. /**
  30246. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  30247. */
  30248. tangents: Nullable<FloatArray>;
  30249. /**
  30250. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30251. */
  30252. uvs: Nullable<FloatArray>;
  30253. /**
  30254. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30255. */
  30256. uvs2: Nullable<FloatArray>;
  30257. /**
  30258. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30259. */
  30260. uvs3: Nullable<FloatArray>;
  30261. /**
  30262. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30263. */
  30264. uvs4: Nullable<FloatArray>;
  30265. /**
  30266. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30267. */
  30268. uvs5: Nullable<FloatArray>;
  30269. /**
  30270. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30271. */
  30272. uvs6: Nullable<FloatArray>;
  30273. /**
  30274. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  30275. */
  30276. colors: Nullable<FloatArray>;
  30277. /**
  30278. * 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).
  30279. */
  30280. matricesIndices: Nullable<FloatArray>;
  30281. /**
  30282. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  30283. */
  30284. matricesWeights: Nullable<FloatArray>;
  30285. /**
  30286. * An array extending the number of possible indices
  30287. */
  30288. matricesIndicesExtra: Nullable<FloatArray>;
  30289. /**
  30290. * An array extending the number of possible weights when the number of indices is extended
  30291. */
  30292. matricesWeightsExtra: Nullable<FloatArray>;
  30293. /**
  30294. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  30295. */
  30296. indices: Nullable<IndicesArray>;
  30297. /**
  30298. * Uses the passed data array to set the set the values for the specified kind of data
  30299. * @param data a linear array of floating numbers
  30300. * @param kind the type of data that is being set, eg positions, colors etc
  30301. */
  30302. set(data: FloatArray, kind: string): void;
  30303. /**
  30304. * Associates the vertexData to the passed Mesh.
  30305. * Sets it as updatable or not (default `false`)
  30306. * @param mesh the mesh the vertexData is applied to
  30307. * @param updatable when used and having the value true allows new data to update the vertexData
  30308. * @returns the VertexData
  30309. */
  30310. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  30311. /**
  30312. * Associates the vertexData to the passed Geometry.
  30313. * Sets it as updatable or not (default `false`)
  30314. * @param geometry the geometry the vertexData is applied to
  30315. * @param updatable when used and having the value true allows new data to update the vertexData
  30316. * @returns VertexData
  30317. */
  30318. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  30319. /**
  30320. * Updates the associated mesh
  30321. * @param mesh the mesh to be updated
  30322. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30323. * @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
  30324. * @returns VertexData
  30325. */
  30326. updateMesh(mesh: Mesh): VertexData;
  30327. /**
  30328. * Updates the associated geometry
  30329. * @param geometry the geometry to be updated
  30330. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30331. * @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
  30332. * @returns VertexData.
  30333. */
  30334. updateGeometry(geometry: Geometry): VertexData;
  30335. private _applyTo;
  30336. private _update;
  30337. /**
  30338. * Transforms each position and each normal of the vertexData according to the passed Matrix
  30339. * @param matrix the transforming matrix
  30340. * @returns the VertexData
  30341. */
  30342. transform(matrix: Matrix): VertexData;
  30343. /**
  30344. * Merges the passed VertexData into the current one
  30345. * @param other the VertexData to be merged into the current one
  30346. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  30347. * @returns the modified VertexData
  30348. */
  30349. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  30350. private _mergeElement;
  30351. private _validate;
  30352. /**
  30353. * Serializes the VertexData
  30354. * @returns a serialized object
  30355. */
  30356. serialize(): any;
  30357. /**
  30358. * Extracts the vertexData from a mesh
  30359. * @param mesh the mesh from which to extract the VertexData
  30360. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  30361. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30362. * @returns the object VertexData associated to the passed mesh
  30363. */
  30364. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30365. /**
  30366. * Extracts the vertexData from the geometry
  30367. * @param geometry the geometry from which to extract the VertexData
  30368. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  30369. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30370. * @returns the object VertexData associated to the passed mesh
  30371. */
  30372. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30373. private static _ExtractFrom;
  30374. /**
  30375. * Creates the VertexData for a Ribbon
  30376. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  30377. * * pathArray array of paths, each of which an array of successive Vector3
  30378. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  30379. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  30380. * * 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
  30381. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30382. * * 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)
  30383. * * 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)
  30384. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  30385. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  30386. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  30387. * @returns the VertexData of the ribbon
  30388. */
  30389. static CreateRibbon(options: {
  30390. pathArray: Vector3[][];
  30391. closeArray?: boolean;
  30392. closePath?: boolean;
  30393. offset?: number;
  30394. sideOrientation?: number;
  30395. frontUVs?: Vector4;
  30396. backUVs?: Vector4;
  30397. invertUV?: boolean;
  30398. uvs?: Vector2[];
  30399. colors?: Color4[];
  30400. }): VertexData;
  30401. /**
  30402. * Creates the VertexData for a box
  30403. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30404. * * size sets the width, height and depth of the box to the value of size, optional default 1
  30405. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  30406. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  30407. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  30408. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30409. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  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. * @returns the VertexData of the box
  30414. */
  30415. static CreateBox(options: {
  30416. size?: number;
  30417. width?: number;
  30418. height?: number;
  30419. depth?: number;
  30420. faceUV?: Vector4[];
  30421. faceColors?: Color4[];
  30422. sideOrientation?: number;
  30423. frontUVs?: Vector4;
  30424. backUVs?: Vector4;
  30425. }): VertexData;
  30426. /**
  30427. * Creates the VertexData for a tiled box
  30428. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30429. * * faceTiles sets the pattern, tile size and number of tiles for a face
  30430. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30431. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30433. * @returns the VertexData of the box
  30434. */
  30435. static CreateTiledBox(options: {
  30436. pattern?: number;
  30437. width?: number;
  30438. height?: number;
  30439. depth?: number;
  30440. tileSize?: number;
  30441. tileWidth?: number;
  30442. tileHeight?: number;
  30443. alignHorizontal?: number;
  30444. alignVertical?: number;
  30445. faceUV?: Vector4[];
  30446. faceColors?: Color4[];
  30447. sideOrientation?: number;
  30448. }): VertexData;
  30449. /**
  30450. * Creates the VertexData for a tiled plane
  30451. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30452. * * pattern a limited pattern arrangement depending on the number
  30453. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  30454. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  30455. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  30456. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30457. * * 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)
  30458. * * 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)
  30459. * @returns the VertexData of the tiled plane
  30460. */
  30461. static CreateTiledPlane(options: {
  30462. pattern?: number;
  30463. tileSize?: number;
  30464. tileWidth?: number;
  30465. tileHeight?: number;
  30466. size?: number;
  30467. width?: number;
  30468. height?: number;
  30469. alignHorizontal?: number;
  30470. alignVertical?: number;
  30471. sideOrientation?: number;
  30472. frontUVs?: Vector4;
  30473. backUVs?: Vector4;
  30474. }): VertexData;
  30475. /**
  30476. * Creates the VertexData for an ellipsoid, defaults to a sphere
  30477. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30478. * * segments sets the number of horizontal strips optional, default 32
  30479. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  30480. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  30481. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  30482. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  30483. * * 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
  30484. * * 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
  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 ellipsoid
  30489. */
  30490. static CreateSphere(options: {
  30491. segments?: number;
  30492. diameter?: number;
  30493. diameterX?: number;
  30494. diameterY?: number;
  30495. diameterZ?: number;
  30496. arc?: number;
  30497. slice?: number;
  30498. sideOrientation?: number;
  30499. frontUVs?: Vector4;
  30500. backUVs?: Vector4;
  30501. }): VertexData;
  30502. /**
  30503. * Creates the VertexData for a cylinder, cone or prism
  30504. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30505. * * height sets the height (y direction) of the cylinder, optional, default 2
  30506. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  30507. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  30508. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  30509. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30510. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  30511. * * 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
  30512. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30513. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30514. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  30515. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  30516. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30517. * * 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)
  30518. * * 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)
  30519. * @returns the VertexData of the cylinder, cone or prism
  30520. */
  30521. static CreateCylinder(options: {
  30522. height?: number;
  30523. diameterTop?: number;
  30524. diameterBottom?: number;
  30525. diameter?: number;
  30526. tessellation?: number;
  30527. subdivisions?: number;
  30528. arc?: number;
  30529. faceColors?: Color4[];
  30530. faceUV?: Vector4[];
  30531. hasRings?: boolean;
  30532. enclose?: boolean;
  30533. sideOrientation?: number;
  30534. frontUVs?: Vector4;
  30535. backUVs?: Vector4;
  30536. }): VertexData;
  30537. /**
  30538. * Creates the VertexData for a torus
  30539. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30540. * * diameter the diameter of the torus, optional default 1
  30541. * * thickness the diameter of the tube forming the torus, optional default 0.5
  30542. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30543. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30544. * * 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)
  30545. * * 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)
  30546. * @returns the VertexData of the torus
  30547. */
  30548. static CreateTorus(options: {
  30549. diameter?: number;
  30550. thickness?: number;
  30551. tessellation?: number;
  30552. sideOrientation?: number;
  30553. frontUVs?: Vector4;
  30554. backUVs?: Vector4;
  30555. }): VertexData;
  30556. /**
  30557. * Creates the VertexData of the LineSystem
  30558. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  30559. * - lines an array of lines, each line being an array of successive Vector3
  30560. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  30561. * @returns the VertexData of the LineSystem
  30562. */
  30563. static CreateLineSystem(options: {
  30564. lines: Vector3[][];
  30565. colors?: Nullable<Color4[][]>;
  30566. }): VertexData;
  30567. /**
  30568. * Create the VertexData for a DashedLines
  30569. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  30570. * - points an array successive Vector3
  30571. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  30572. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  30573. * - dashNb the intended total number of dashes, optional, default 200
  30574. * @returns the VertexData for the DashedLines
  30575. */
  30576. static CreateDashedLines(options: {
  30577. points: Vector3[];
  30578. dashSize?: number;
  30579. gapSize?: number;
  30580. dashNb?: number;
  30581. }): VertexData;
  30582. /**
  30583. * Creates the VertexData for a Ground
  30584. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30585. * - width the width (x direction) of the ground, optional, default 1
  30586. * - height the height (z direction) of the ground, optional, default 1
  30587. * - subdivisions the number of subdivisions per side, optional, default 1
  30588. * @returns the VertexData of the Ground
  30589. */
  30590. static CreateGround(options: {
  30591. width?: number;
  30592. height?: number;
  30593. subdivisions?: number;
  30594. subdivisionsX?: number;
  30595. subdivisionsY?: number;
  30596. }): VertexData;
  30597. /**
  30598. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  30599. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30600. * * xmin the ground minimum X coordinate, optional, default -1
  30601. * * zmin the ground minimum Z coordinate, optional, default -1
  30602. * * xmax the ground maximum X coordinate, optional, default 1
  30603. * * zmax the ground maximum Z coordinate, optional, default 1
  30604. * * 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}
  30605. * * 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}
  30606. * @returns the VertexData of the TiledGround
  30607. */
  30608. static CreateTiledGround(options: {
  30609. xmin: number;
  30610. zmin: number;
  30611. xmax: number;
  30612. zmax: number;
  30613. subdivisions?: {
  30614. w: number;
  30615. h: number;
  30616. };
  30617. precision?: {
  30618. w: number;
  30619. h: number;
  30620. };
  30621. }): VertexData;
  30622. /**
  30623. * Creates the VertexData of the Ground designed from a heightmap
  30624. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  30625. * * width the width (x direction) of the ground
  30626. * * height the height (z direction) of the ground
  30627. * * subdivisions the number of subdivisions per side
  30628. * * minHeight the minimum altitude on the ground, optional, default 0
  30629. * * maxHeight the maximum altitude on the ground, optional default 1
  30630. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  30631. * * buffer the array holding the image color data
  30632. * * bufferWidth the width of image
  30633. * * bufferHeight the height of image
  30634. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  30635. * @returns the VertexData of the Ground designed from a heightmap
  30636. */
  30637. static CreateGroundFromHeightMap(options: {
  30638. width: number;
  30639. height: number;
  30640. subdivisions: number;
  30641. minHeight: number;
  30642. maxHeight: number;
  30643. colorFilter: Color3;
  30644. buffer: Uint8Array;
  30645. bufferWidth: number;
  30646. bufferHeight: number;
  30647. alphaFilter: number;
  30648. }): VertexData;
  30649. /**
  30650. * Creates the VertexData for a Plane
  30651. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  30652. * * size sets the width and height of the plane to the value of size, optional default 1
  30653. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  30654. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  30655. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30656. * * 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)
  30657. * * 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)
  30658. * @returns the VertexData of the box
  30659. */
  30660. static CreatePlane(options: {
  30661. size?: number;
  30662. width?: number;
  30663. height?: number;
  30664. sideOrientation?: number;
  30665. frontUVs?: Vector4;
  30666. backUVs?: Vector4;
  30667. }): VertexData;
  30668. /**
  30669. * Creates the VertexData of the Disc or regular Polygon
  30670. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  30671. * * radius the radius of the disc, optional default 0.5
  30672. * * tessellation the number of polygon sides, optional, default 64
  30673. * * 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
  30674. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30675. * * 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)
  30676. * * 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)
  30677. * @returns the VertexData of the box
  30678. */
  30679. static CreateDisc(options: {
  30680. radius?: number;
  30681. tessellation?: number;
  30682. arc?: number;
  30683. sideOrientation?: number;
  30684. frontUVs?: Vector4;
  30685. backUVs?: Vector4;
  30686. }): VertexData;
  30687. /**
  30688. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  30689. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  30690. * @param polygon a mesh built from polygonTriangulation.build()
  30691. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30692. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30693. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30694. * @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)
  30695. * @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)
  30696. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  30697. * @returns the VertexData of the Polygon
  30698. */
  30699. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  30700. /**
  30701. * Creates the VertexData of the IcoSphere
  30702. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  30703. * * radius the radius of the IcoSphere, optional default 1
  30704. * * radiusX allows stretching in the x direction, optional, default radius
  30705. * * radiusY allows stretching in the y direction, optional, default radius
  30706. * * radiusZ allows stretching in the z direction, optional, default radius
  30707. * * flat when true creates a flat shaded mesh, optional, default true
  30708. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30709. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30710. * * 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)
  30711. * * 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)
  30712. * @returns the VertexData of the IcoSphere
  30713. */
  30714. static CreateIcoSphere(options: {
  30715. radius?: number;
  30716. radiusX?: number;
  30717. radiusY?: number;
  30718. radiusZ?: number;
  30719. flat?: boolean;
  30720. subdivisions?: number;
  30721. sideOrientation?: number;
  30722. frontUVs?: Vector4;
  30723. backUVs?: Vector4;
  30724. }): VertexData;
  30725. /**
  30726. * Creates the VertexData for a Polyhedron
  30727. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  30728. * * type provided types are:
  30729. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  30730. * * 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)
  30731. * * size the size of the IcoSphere, optional default 1
  30732. * * sizeX allows stretching in the x direction, optional, default size
  30733. * * sizeY allows stretching in the y direction, optional, default size
  30734. * * sizeZ allows stretching in the z direction, optional, default size
  30735. * * 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
  30736. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30737. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30738. * * flat when true creates a flat shaded mesh, optional, default true
  30739. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30740. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30741. * * 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)
  30742. * * 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)
  30743. * @returns the VertexData of the Polyhedron
  30744. */
  30745. static CreatePolyhedron(options: {
  30746. type?: number;
  30747. size?: number;
  30748. sizeX?: number;
  30749. sizeY?: number;
  30750. sizeZ?: number;
  30751. custom?: any;
  30752. faceUV?: Vector4[];
  30753. faceColors?: Color4[];
  30754. flat?: boolean;
  30755. sideOrientation?: number;
  30756. frontUVs?: Vector4;
  30757. backUVs?: Vector4;
  30758. }): VertexData;
  30759. /**
  30760. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  30761. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  30762. * @returns the VertexData of the Capsule
  30763. */
  30764. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  30765. /**
  30766. * Creates the VertexData for a TorusKnot
  30767. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  30768. * * radius the radius of the torus knot, optional, default 2
  30769. * * tube the thickness of the tube, optional, default 0.5
  30770. * * radialSegments the number of sides on each tube segments, optional, default 32
  30771. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  30772. * * p the number of windings around the z axis, optional, default 2
  30773. * * q the number of windings around the x axis, optional, default 3
  30774. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30775. * * 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)
  30776. * * 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)
  30777. * @returns the VertexData of the Torus Knot
  30778. */
  30779. static CreateTorusKnot(options: {
  30780. radius?: number;
  30781. tube?: number;
  30782. radialSegments?: number;
  30783. tubularSegments?: number;
  30784. p?: number;
  30785. q?: number;
  30786. sideOrientation?: number;
  30787. frontUVs?: Vector4;
  30788. backUVs?: Vector4;
  30789. }): VertexData;
  30790. /**
  30791. * Compute normals for given positions and indices
  30792. * @param positions an array of vertex positions, [...., x, y, z, ......]
  30793. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  30794. * @param normals an array of vertex normals, [...., x, y, z, ......]
  30795. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  30796. * * facetNormals : optional array of facet normals (vector3)
  30797. * * facetPositions : optional array of facet positions (vector3)
  30798. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  30799. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  30800. * * bInfo : optional bounding info, required for facetPartitioning computation
  30801. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  30802. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  30803. * * useRightHandedSystem: optional boolean to for right handed system computation
  30804. * * depthSort : optional boolean to enable the facet depth sort computation
  30805. * * distanceTo : optional Vector3 to compute the facet depth from this location
  30806. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  30807. */
  30808. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  30809. facetNormals?: any;
  30810. facetPositions?: any;
  30811. facetPartitioning?: any;
  30812. ratio?: number;
  30813. bInfo?: any;
  30814. bbSize?: Vector3;
  30815. subDiv?: any;
  30816. useRightHandedSystem?: boolean;
  30817. depthSort?: boolean;
  30818. distanceTo?: Vector3;
  30819. depthSortedFacets?: any;
  30820. }): void;
  30821. /** @hidden */
  30822. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  30823. /**
  30824. * Applies VertexData created from the imported parameters to the geometry
  30825. * @param parsedVertexData the parsed data from an imported file
  30826. * @param geometry the geometry to apply the VertexData to
  30827. */
  30828. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  30829. }
  30830. }
  30831. declare module BABYLON {
  30832. /**
  30833. * Defines a target to use with MorphTargetManager
  30834. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30835. */
  30836. export class MorphTarget implements IAnimatable {
  30837. /** defines the name of the target */
  30838. name: string;
  30839. /**
  30840. * Gets or sets the list of animations
  30841. */
  30842. animations: Animation[];
  30843. private _scene;
  30844. private _positions;
  30845. private _normals;
  30846. private _tangents;
  30847. private _uvs;
  30848. private _influence;
  30849. private _uniqueId;
  30850. /**
  30851. * Observable raised when the influence changes
  30852. */
  30853. onInfluenceChanged: Observable<boolean>;
  30854. /** @hidden */
  30855. _onDataLayoutChanged: Observable<void>;
  30856. /**
  30857. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30858. */
  30859. get influence(): number;
  30860. set influence(influence: number);
  30861. /**
  30862. * Gets or sets the id of the morph Target
  30863. */
  30864. id: string;
  30865. private _animationPropertiesOverride;
  30866. /**
  30867. * Gets or sets the animation properties override
  30868. */
  30869. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30870. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30871. /**
  30872. * Creates a new MorphTarget
  30873. * @param name defines the name of the target
  30874. * @param influence defines the influence to use
  30875. * @param scene defines the scene the morphtarget belongs to
  30876. */
  30877. constructor(
  30878. /** defines the name of the target */
  30879. name: string, influence?: number, scene?: Nullable<Scene>);
  30880. /**
  30881. * Gets the unique ID of this manager
  30882. */
  30883. get uniqueId(): number;
  30884. /**
  30885. * Gets a boolean defining if the target contains position data
  30886. */
  30887. get hasPositions(): boolean;
  30888. /**
  30889. * Gets a boolean defining if the target contains normal data
  30890. */
  30891. get hasNormals(): boolean;
  30892. /**
  30893. * Gets a boolean defining if the target contains tangent data
  30894. */
  30895. get hasTangents(): boolean;
  30896. /**
  30897. * Gets a boolean defining if the target contains texture coordinates data
  30898. */
  30899. get hasUVs(): boolean;
  30900. /**
  30901. * Affects position data to this target
  30902. * @param data defines the position data to use
  30903. */
  30904. setPositions(data: Nullable<FloatArray>): void;
  30905. /**
  30906. * Gets the position data stored in this target
  30907. * @returns a FloatArray containing the position data (or null if not present)
  30908. */
  30909. getPositions(): Nullable<FloatArray>;
  30910. /**
  30911. * Affects normal data to this target
  30912. * @param data defines the normal data to use
  30913. */
  30914. setNormals(data: Nullable<FloatArray>): void;
  30915. /**
  30916. * Gets the normal data stored in this target
  30917. * @returns a FloatArray containing the normal data (or null if not present)
  30918. */
  30919. getNormals(): Nullable<FloatArray>;
  30920. /**
  30921. * Affects tangent data to this target
  30922. * @param data defines the tangent data to use
  30923. */
  30924. setTangents(data: Nullable<FloatArray>): void;
  30925. /**
  30926. * Gets the tangent data stored in this target
  30927. * @returns a FloatArray containing the tangent data (or null if not present)
  30928. */
  30929. getTangents(): Nullable<FloatArray>;
  30930. /**
  30931. * Affects texture coordinates data to this target
  30932. * @param data defines the texture coordinates data to use
  30933. */
  30934. setUVs(data: Nullable<FloatArray>): void;
  30935. /**
  30936. * Gets the texture coordinates data stored in this target
  30937. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30938. */
  30939. getUVs(): Nullable<FloatArray>;
  30940. /**
  30941. * Clone the current target
  30942. * @returns a new MorphTarget
  30943. */
  30944. clone(): MorphTarget;
  30945. /**
  30946. * Serializes the current target into a Serialization object
  30947. * @returns the serialized object
  30948. */
  30949. serialize(): any;
  30950. /**
  30951. * Returns the string "MorphTarget"
  30952. * @returns "MorphTarget"
  30953. */
  30954. getClassName(): string;
  30955. /**
  30956. * Creates a new target from serialized data
  30957. * @param serializationObject defines the serialized data to use
  30958. * @returns a new MorphTarget
  30959. */
  30960. static Parse(serializationObject: any): MorphTarget;
  30961. /**
  30962. * Creates a MorphTarget from mesh data
  30963. * @param mesh defines the source mesh
  30964. * @param name defines the name to use for the new target
  30965. * @param influence defines the influence to attach to the target
  30966. * @returns a new MorphTarget
  30967. */
  30968. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30969. }
  30970. }
  30971. declare module BABYLON {
  30972. /**
  30973. * This class is used to deform meshes using morphing between different targets
  30974. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30975. */
  30976. export class MorphTargetManager {
  30977. private _targets;
  30978. private _targetInfluenceChangedObservers;
  30979. private _targetDataLayoutChangedObservers;
  30980. private _activeTargets;
  30981. private _scene;
  30982. private _influences;
  30983. private _supportsNormals;
  30984. private _supportsTangents;
  30985. private _supportsUVs;
  30986. private _vertexCount;
  30987. private _uniqueId;
  30988. private _tempInfluences;
  30989. /**
  30990. * Gets or sets a boolean indicating if normals must be morphed
  30991. */
  30992. enableNormalMorphing: boolean;
  30993. /**
  30994. * Gets or sets a boolean indicating if tangents must be morphed
  30995. */
  30996. enableTangentMorphing: boolean;
  30997. /**
  30998. * Gets or sets a boolean indicating if UV must be morphed
  30999. */
  31000. enableUVMorphing: boolean;
  31001. /**
  31002. * Creates a new MorphTargetManager
  31003. * @param scene defines the current scene
  31004. */
  31005. constructor(scene?: Nullable<Scene>);
  31006. /**
  31007. * Gets the unique ID of this manager
  31008. */
  31009. get uniqueId(): number;
  31010. /**
  31011. * Gets the number of vertices handled by this manager
  31012. */
  31013. get vertexCount(): number;
  31014. /**
  31015. * Gets a boolean indicating if this manager supports morphing of normals
  31016. */
  31017. get supportsNormals(): boolean;
  31018. /**
  31019. * Gets a boolean indicating if this manager supports morphing of tangents
  31020. */
  31021. get supportsTangents(): boolean;
  31022. /**
  31023. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31024. */
  31025. get supportsUVs(): boolean;
  31026. /**
  31027. * Gets the number of targets stored in this manager
  31028. */
  31029. get numTargets(): number;
  31030. /**
  31031. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31032. */
  31033. get numInfluencers(): number;
  31034. /**
  31035. * Gets the list of influences (one per target)
  31036. */
  31037. get influences(): Float32Array;
  31038. /**
  31039. * Gets the active target at specified index. An active target is a target with an influence > 0
  31040. * @param index defines the index to check
  31041. * @returns the requested target
  31042. */
  31043. getActiveTarget(index: number): MorphTarget;
  31044. /**
  31045. * Gets the target at specified index
  31046. * @param index defines the index to check
  31047. * @returns the requested target
  31048. */
  31049. getTarget(index: number): MorphTarget;
  31050. /**
  31051. * Add a new target to this manager
  31052. * @param target defines the target to add
  31053. */
  31054. addTarget(target: MorphTarget): void;
  31055. /**
  31056. * Removes a target from the manager
  31057. * @param target defines the target to remove
  31058. */
  31059. removeTarget(target: MorphTarget): void;
  31060. /**
  31061. * Clone the current manager
  31062. * @returns a new MorphTargetManager
  31063. */
  31064. clone(): MorphTargetManager;
  31065. /**
  31066. * Serializes the current manager into a Serialization object
  31067. * @returns the serialized object
  31068. */
  31069. serialize(): any;
  31070. private _syncActiveTargets;
  31071. /**
  31072. * Syncrhonize the targets with all the meshes using this morph target manager
  31073. */
  31074. synchronize(): void;
  31075. /**
  31076. * Creates a new MorphTargetManager from serialized data
  31077. * @param serializationObject defines the serialized data
  31078. * @param scene defines the hosting scene
  31079. * @returns the new MorphTargetManager
  31080. */
  31081. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31082. }
  31083. }
  31084. declare module BABYLON {
  31085. /**
  31086. * Class used to represent a specific level of detail of a mesh
  31087. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31088. */
  31089. export class MeshLODLevel {
  31090. /** Defines the distance where this level should start being displayed */
  31091. distance: number;
  31092. /** Defines the mesh to use to render this level */
  31093. mesh: Nullable<Mesh>;
  31094. /**
  31095. * Creates a new LOD level
  31096. * @param distance defines the distance where this level should star being displayed
  31097. * @param mesh defines the mesh to use to render this level
  31098. */
  31099. constructor(
  31100. /** Defines the distance where this level should start being displayed */
  31101. distance: number,
  31102. /** Defines the mesh to use to render this level */
  31103. mesh: Nullable<Mesh>);
  31104. }
  31105. }
  31106. declare module BABYLON {
  31107. /**
  31108. * Helper class used to generate a canvas to manipulate images
  31109. */
  31110. export class CanvasGenerator {
  31111. /**
  31112. * Create a new canvas (or offscreen canvas depending on the context)
  31113. * @param width defines the expected width
  31114. * @param height defines the expected height
  31115. * @return a new canvas or offscreen canvas
  31116. */
  31117. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31118. }
  31119. }
  31120. declare module BABYLON {
  31121. /**
  31122. * Mesh representing the gorund
  31123. */
  31124. export class GroundMesh extends Mesh {
  31125. /** If octree should be generated */
  31126. generateOctree: boolean;
  31127. private _heightQuads;
  31128. /** @hidden */
  31129. _subdivisionsX: number;
  31130. /** @hidden */
  31131. _subdivisionsY: number;
  31132. /** @hidden */
  31133. _width: number;
  31134. /** @hidden */
  31135. _height: number;
  31136. /** @hidden */
  31137. _minX: number;
  31138. /** @hidden */
  31139. _maxX: number;
  31140. /** @hidden */
  31141. _minZ: number;
  31142. /** @hidden */
  31143. _maxZ: number;
  31144. constructor(name: string, scene: Scene);
  31145. /**
  31146. * "GroundMesh"
  31147. * @returns "GroundMesh"
  31148. */
  31149. getClassName(): string;
  31150. /**
  31151. * The minimum of x and y subdivisions
  31152. */
  31153. get subdivisions(): number;
  31154. /**
  31155. * X subdivisions
  31156. */
  31157. get subdivisionsX(): number;
  31158. /**
  31159. * Y subdivisions
  31160. */
  31161. get subdivisionsY(): number;
  31162. /**
  31163. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31164. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31165. * @param chunksCount the number of subdivisions for x and y
  31166. * @param octreeBlocksSize (Default: 32)
  31167. */
  31168. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31169. /**
  31170. * Returns a height (y) value in the Worl system :
  31171. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31172. * @param x x coordinate
  31173. * @param z z coordinate
  31174. * @returns the ground y position if (x, z) are outside the ground surface.
  31175. */
  31176. getHeightAtCoordinates(x: number, z: number): number;
  31177. /**
  31178. * Returns a normalized vector (Vector3) orthogonal to the ground
  31179. * at the ground coordinates (x, z) expressed in the World system.
  31180. * @param x x coordinate
  31181. * @param z z coordinate
  31182. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31183. */
  31184. getNormalAtCoordinates(x: number, z: number): Vector3;
  31185. /**
  31186. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31187. * at the ground coordinates (x, z) expressed in the World system.
  31188. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31189. * @param x x coordinate
  31190. * @param z z coordinate
  31191. * @param ref vector to store the result
  31192. * @returns the GroundMesh.
  31193. */
  31194. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31195. /**
  31196. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31197. * if the ground has been updated.
  31198. * This can be used in the render loop.
  31199. * @returns the GroundMesh.
  31200. */
  31201. updateCoordinateHeights(): GroundMesh;
  31202. private _getFacetAt;
  31203. private _initHeightQuads;
  31204. private _computeHeightQuads;
  31205. /**
  31206. * Serializes this ground mesh
  31207. * @param serializationObject object to write serialization to
  31208. */
  31209. serialize(serializationObject: any): void;
  31210. /**
  31211. * Parses a serialized ground mesh
  31212. * @param parsedMesh the serialized mesh
  31213. * @param scene the scene to create the ground mesh in
  31214. * @returns the created ground mesh
  31215. */
  31216. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31217. }
  31218. }
  31219. declare module BABYLON {
  31220. /**
  31221. * Interface for Physics-Joint data
  31222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31223. */
  31224. export interface PhysicsJointData {
  31225. /**
  31226. * The main pivot of the joint
  31227. */
  31228. mainPivot?: Vector3;
  31229. /**
  31230. * The connected pivot of the joint
  31231. */
  31232. connectedPivot?: Vector3;
  31233. /**
  31234. * The main axis of the joint
  31235. */
  31236. mainAxis?: Vector3;
  31237. /**
  31238. * The connected axis of the joint
  31239. */
  31240. connectedAxis?: Vector3;
  31241. /**
  31242. * The collision of the joint
  31243. */
  31244. collision?: boolean;
  31245. /**
  31246. * Native Oimo/Cannon/Energy data
  31247. */
  31248. nativeParams?: any;
  31249. }
  31250. /**
  31251. * This is a holder class for the physics joint created by the physics plugin
  31252. * It holds a set of functions to control the underlying joint
  31253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31254. */
  31255. export class PhysicsJoint {
  31256. /**
  31257. * The type of the physics joint
  31258. */
  31259. type: number;
  31260. /**
  31261. * The data for the physics joint
  31262. */
  31263. jointData: PhysicsJointData;
  31264. private _physicsJoint;
  31265. protected _physicsPlugin: IPhysicsEnginePlugin;
  31266. /**
  31267. * Initializes the physics joint
  31268. * @param type The type of the physics joint
  31269. * @param jointData The data for the physics joint
  31270. */
  31271. constructor(
  31272. /**
  31273. * The type of the physics joint
  31274. */
  31275. type: number,
  31276. /**
  31277. * The data for the physics joint
  31278. */
  31279. jointData: PhysicsJointData);
  31280. /**
  31281. * Gets the physics joint
  31282. */
  31283. get physicsJoint(): any;
  31284. /**
  31285. * Sets the physics joint
  31286. */
  31287. set physicsJoint(newJoint: any);
  31288. /**
  31289. * Sets the physics plugin
  31290. */
  31291. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31292. /**
  31293. * Execute a function that is physics-plugin specific.
  31294. * @param {Function} func the function that will be executed.
  31295. * It accepts two parameters: the physics world and the physics joint
  31296. */
  31297. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31298. /**
  31299. * Distance-Joint type
  31300. */
  31301. static DistanceJoint: number;
  31302. /**
  31303. * Hinge-Joint type
  31304. */
  31305. static HingeJoint: number;
  31306. /**
  31307. * Ball-and-Socket joint type
  31308. */
  31309. static BallAndSocketJoint: number;
  31310. /**
  31311. * Wheel-Joint type
  31312. */
  31313. static WheelJoint: number;
  31314. /**
  31315. * Slider-Joint type
  31316. */
  31317. static SliderJoint: number;
  31318. /**
  31319. * Prismatic-Joint type
  31320. */
  31321. static PrismaticJoint: number;
  31322. /**
  31323. * Universal-Joint type
  31324. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31325. */
  31326. static UniversalJoint: number;
  31327. /**
  31328. * Hinge-Joint 2 type
  31329. */
  31330. static Hinge2Joint: number;
  31331. /**
  31332. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31333. */
  31334. static PointToPointJoint: number;
  31335. /**
  31336. * Spring-Joint type
  31337. */
  31338. static SpringJoint: number;
  31339. /**
  31340. * Lock-Joint type
  31341. */
  31342. static LockJoint: number;
  31343. }
  31344. /**
  31345. * A class representing a physics distance joint
  31346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31347. */
  31348. export class DistanceJoint extends PhysicsJoint {
  31349. /**
  31350. *
  31351. * @param jointData The data for the Distance-Joint
  31352. */
  31353. constructor(jointData: DistanceJointData);
  31354. /**
  31355. * Update the predefined distance.
  31356. * @param maxDistance The maximum preferred distance
  31357. * @param minDistance The minimum preferred distance
  31358. */
  31359. updateDistance(maxDistance: number, minDistance?: number): void;
  31360. }
  31361. /**
  31362. * Represents a Motor-Enabled Joint
  31363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31364. */
  31365. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31366. /**
  31367. * Initializes the Motor-Enabled Joint
  31368. * @param type The type of the joint
  31369. * @param jointData The physica joint data for the joint
  31370. */
  31371. constructor(type: number, jointData: PhysicsJointData);
  31372. /**
  31373. * Set the motor values.
  31374. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31375. * @param force the force to apply
  31376. * @param maxForce max force for this motor.
  31377. */
  31378. setMotor(force?: number, maxForce?: number): void;
  31379. /**
  31380. * Set the motor's limits.
  31381. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31382. * @param upperLimit The upper limit of the motor
  31383. * @param lowerLimit The lower limit of the motor
  31384. */
  31385. setLimit(upperLimit: number, lowerLimit?: number): void;
  31386. }
  31387. /**
  31388. * This class represents a single physics Hinge-Joint
  31389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31390. */
  31391. export class HingeJoint extends MotorEnabledJoint {
  31392. /**
  31393. * Initializes the Hinge-Joint
  31394. * @param jointData The joint data for the Hinge-Joint
  31395. */
  31396. constructor(jointData: PhysicsJointData);
  31397. /**
  31398. * Set the motor values.
  31399. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31400. * @param {number} force the force to apply
  31401. * @param {number} maxForce max force for this motor.
  31402. */
  31403. setMotor(force?: number, maxForce?: number): void;
  31404. /**
  31405. * Set the motor's limits.
  31406. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31407. * @param upperLimit The upper limit of the motor
  31408. * @param lowerLimit The lower limit of the motor
  31409. */
  31410. setLimit(upperLimit: number, lowerLimit?: number): void;
  31411. }
  31412. /**
  31413. * This class represents a dual hinge physics joint (same as wheel joint)
  31414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31415. */
  31416. export class Hinge2Joint extends MotorEnabledJoint {
  31417. /**
  31418. * Initializes the Hinge2-Joint
  31419. * @param jointData The joint data for the Hinge2-Joint
  31420. */
  31421. constructor(jointData: PhysicsJointData);
  31422. /**
  31423. * Set the motor values.
  31424. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31425. * @param {number} targetSpeed the speed the motor is to reach
  31426. * @param {number} maxForce max force for this motor.
  31427. * @param {motorIndex} the motor's index, 0 or 1.
  31428. */
  31429. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31430. /**
  31431. * Set the motor limits.
  31432. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31433. * @param {number} upperLimit the upper limit
  31434. * @param {number} lowerLimit lower limit
  31435. * @param {motorIndex} the motor's index, 0 or 1.
  31436. */
  31437. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31438. }
  31439. /**
  31440. * Interface for a motor enabled joint
  31441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31442. */
  31443. export interface IMotorEnabledJoint {
  31444. /**
  31445. * Physics joint
  31446. */
  31447. physicsJoint: any;
  31448. /**
  31449. * Sets the motor of the motor-enabled joint
  31450. * @param force The force of the motor
  31451. * @param maxForce The maximum force of the motor
  31452. * @param motorIndex The index of the motor
  31453. */
  31454. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31455. /**
  31456. * Sets the limit of the motor
  31457. * @param upperLimit The upper limit of the motor
  31458. * @param lowerLimit The lower limit of the motor
  31459. * @param motorIndex The index of the motor
  31460. */
  31461. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31462. }
  31463. /**
  31464. * Joint data for a Distance-Joint
  31465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31466. */
  31467. export interface DistanceJointData extends PhysicsJointData {
  31468. /**
  31469. * Max distance the 2 joint objects can be apart
  31470. */
  31471. maxDistance: number;
  31472. }
  31473. /**
  31474. * Joint data from a spring joint
  31475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31476. */
  31477. export interface SpringJointData extends PhysicsJointData {
  31478. /**
  31479. * Length of the spring
  31480. */
  31481. length: number;
  31482. /**
  31483. * Stiffness of the spring
  31484. */
  31485. stiffness: number;
  31486. /**
  31487. * Damping of the spring
  31488. */
  31489. damping: number;
  31490. /** this callback will be called when applying the force to the impostors. */
  31491. forceApplicationCallback: () => void;
  31492. }
  31493. }
  31494. declare module BABYLON {
  31495. /**
  31496. * Holds the data for the raycast result
  31497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31498. */
  31499. export class PhysicsRaycastResult {
  31500. private _hasHit;
  31501. private _hitDistance;
  31502. private _hitNormalWorld;
  31503. private _hitPointWorld;
  31504. private _rayFromWorld;
  31505. private _rayToWorld;
  31506. /**
  31507. * Gets if there was a hit
  31508. */
  31509. get hasHit(): boolean;
  31510. /**
  31511. * Gets the distance from the hit
  31512. */
  31513. get hitDistance(): number;
  31514. /**
  31515. * Gets the hit normal/direction in the world
  31516. */
  31517. get hitNormalWorld(): Vector3;
  31518. /**
  31519. * Gets the hit point in the world
  31520. */
  31521. get hitPointWorld(): Vector3;
  31522. /**
  31523. * Gets the ray "start point" of the ray in the world
  31524. */
  31525. get rayFromWorld(): Vector3;
  31526. /**
  31527. * Gets the ray "end point" of the ray in the world
  31528. */
  31529. get rayToWorld(): Vector3;
  31530. /**
  31531. * Sets the hit data (normal & point in world space)
  31532. * @param hitNormalWorld defines the normal in world space
  31533. * @param hitPointWorld defines the point in world space
  31534. */
  31535. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31536. /**
  31537. * Sets the distance from the start point to the hit point
  31538. * @param distance
  31539. */
  31540. setHitDistance(distance: number): void;
  31541. /**
  31542. * Calculates the distance manually
  31543. */
  31544. calculateHitDistance(): void;
  31545. /**
  31546. * Resets all the values to default
  31547. * @param from The from point on world space
  31548. * @param to The to point on world space
  31549. */
  31550. reset(from?: Vector3, to?: Vector3): void;
  31551. }
  31552. /**
  31553. * Interface for the size containing width and height
  31554. */
  31555. interface IXYZ {
  31556. /**
  31557. * X
  31558. */
  31559. x: number;
  31560. /**
  31561. * Y
  31562. */
  31563. y: number;
  31564. /**
  31565. * Z
  31566. */
  31567. z: number;
  31568. }
  31569. }
  31570. declare module BABYLON {
  31571. /**
  31572. * Interface used to describe a physics joint
  31573. */
  31574. export interface PhysicsImpostorJoint {
  31575. /** Defines the main impostor to which the joint is linked */
  31576. mainImpostor: PhysicsImpostor;
  31577. /** Defines the impostor that is connected to the main impostor using this joint */
  31578. connectedImpostor: PhysicsImpostor;
  31579. /** Defines the joint itself */
  31580. joint: PhysicsJoint;
  31581. }
  31582. /** @hidden */
  31583. export interface IPhysicsEnginePlugin {
  31584. world: any;
  31585. name: string;
  31586. setGravity(gravity: Vector3): void;
  31587. setTimeStep(timeStep: number): void;
  31588. getTimeStep(): number;
  31589. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31590. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31591. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31592. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31593. removePhysicsBody(impostor: PhysicsImpostor): void;
  31594. generateJoint(joint: PhysicsImpostorJoint): void;
  31595. removeJoint(joint: PhysicsImpostorJoint): void;
  31596. isSupported(): boolean;
  31597. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31598. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31599. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31600. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31601. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31602. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31603. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31604. getBodyMass(impostor: PhysicsImpostor): number;
  31605. getBodyFriction(impostor: PhysicsImpostor): number;
  31606. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31607. getBodyRestitution(impostor: PhysicsImpostor): number;
  31608. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31609. getBodyPressure?(impostor: PhysicsImpostor): number;
  31610. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31611. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31612. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31613. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31614. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31615. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31616. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31617. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31618. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31619. sleepBody(impostor: PhysicsImpostor): void;
  31620. wakeUpBody(impostor: PhysicsImpostor): void;
  31621. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31622. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31623. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31624. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31625. getRadius(impostor: PhysicsImpostor): number;
  31626. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31627. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31628. dispose(): void;
  31629. }
  31630. /**
  31631. * Interface used to define a physics engine
  31632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31633. */
  31634. export interface IPhysicsEngine {
  31635. /**
  31636. * Gets the gravity vector used by the simulation
  31637. */
  31638. gravity: Vector3;
  31639. /**
  31640. * Sets the gravity vector used by the simulation
  31641. * @param gravity defines the gravity vector to use
  31642. */
  31643. setGravity(gravity: Vector3): void;
  31644. /**
  31645. * Set the time step of the physics engine.
  31646. * Default is 1/60.
  31647. * To slow it down, enter 1/600 for example.
  31648. * To speed it up, 1/30
  31649. * @param newTimeStep the new timestep to apply to this world.
  31650. */
  31651. setTimeStep(newTimeStep: number): void;
  31652. /**
  31653. * Get the time step of the physics engine.
  31654. * @returns the current time step
  31655. */
  31656. getTimeStep(): number;
  31657. /**
  31658. * Set the sub time step of the physics engine.
  31659. * Default is 0 meaning there is no sub steps
  31660. * To increase physics resolution precision, set a small value (like 1 ms)
  31661. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31662. */
  31663. setSubTimeStep(subTimeStep: number): void;
  31664. /**
  31665. * Get the sub time step of the physics engine.
  31666. * @returns the current sub time step
  31667. */
  31668. getSubTimeStep(): number;
  31669. /**
  31670. * Release all resources
  31671. */
  31672. dispose(): void;
  31673. /**
  31674. * Gets the name of the current physics plugin
  31675. * @returns the name of the plugin
  31676. */
  31677. getPhysicsPluginName(): string;
  31678. /**
  31679. * Adding a new impostor for the impostor tracking.
  31680. * This will be done by the impostor itself.
  31681. * @param impostor the impostor to add
  31682. */
  31683. addImpostor(impostor: PhysicsImpostor): void;
  31684. /**
  31685. * Remove an impostor from the engine.
  31686. * This impostor and its mesh will not longer be updated by the physics engine.
  31687. * @param impostor the impostor to remove
  31688. */
  31689. removeImpostor(impostor: PhysicsImpostor): void;
  31690. /**
  31691. * Add a joint to the physics engine
  31692. * @param mainImpostor defines the main impostor to which the joint is added.
  31693. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31694. * @param joint defines the joint that will connect both impostors.
  31695. */
  31696. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31697. /**
  31698. * Removes a joint from the simulation
  31699. * @param mainImpostor defines the impostor used with the joint
  31700. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31701. * @param joint defines the joint to remove
  31702. */
  31703. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31704. /**
  31705. * Gets the current plugin used to run the simulation
  31706. * @returns current plugin
  31707. */
  31708. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31709. /**
  31710. * Gets the list of physic impostors
  31711. * @returns an array of PhysicsImpostor
  31712. */
  31713. getImpostors(): Array<PhysicsImpostor>;
  31714. /**
  31715. * Gets the impostor for a physics enabled object
  31716. * @param object defines the object impersonated by the impostor
  31717. * @returns the PhysicsImpostor or null if not found
  31718. */
  31719. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31720. /**
  31721. * Gets the impostor for a physics body object
  31722. * @param body defines physics body used by the impostor
  31723. * @returns the PhysicsImpostor or null if not found
  31724. */
  31725. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31726. /**
  31727. * Does a raycast in the physics world
  31728. * @param from when should the ray start?
  31729. * @param to when should the ray end?
  31730. * @returns PhysicsRaycastResult
  31731. */
  31732. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31733. /**
  31734. * Called by the scene. No need to call it.
  31735. * @param delta defines the timespam between frames
  31736. */
  31737. _step(delta: number): void;
  31738. }
  31739. }
  31740. declare module BABYLON {
  31741. /**
  31742. * The interface for the physics imposter parameters
  31743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31744. */
  31745. export interface PhysicsImpostorParameters {
  31746. /**
  31747. * The mass of the physics imposter
  31748. */
  31749. mass: number;
  31750. /**
  31751. * The friction of the physics imposter
  31752. */
  31753. friction?: number;
  31754. /**
  31755. * The coefficient of restitution of the physics imposter
  31756. */
  31757. restitution?: number;
  31758. /**
  31759. * The native options of the physics imposter
  31760. */
  31761. nativeOptions?: any;
  31762. /**
  31763. * Specifies if the parent should be ignored
  31764. */
  31765. ignoreParent?: boolean;
  31766. /**
  31767. * Specifies if bi-directional transformations should be disabled
  31768. */
  31769. disableBidirectionalTransformation?: boolean;
  31770. /**
  31771. * The pressure inside the physics imposter, soft object only
  31772. */
  31773. pressure?: number;
  31774. /**
  31775. * The stiffness the physics imposter, soft object only
  31776. */
  31777. stiffness?: number;
  31778. /**
  31779. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31780. */
  31781. velocityIterations?: number;
  31782. /**
  31783. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31784. */
  31785. positionIterations?: number;
  31786. /**
  31787. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31788. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31789. * Add to fix multiple points
  31790. */
  31791. fixedPoints?: number;
  31792. /**
  31793. * The collision margin around a soft object
  31794. */
  31795. margin?: number;
  31796. /**
  31797. * The collision margin around a soft object
  31798. */
  31799. damping?: number;
  31800. /**
  31801. * The path for a rope based on an extrusion
  31802. */
  31803. path?: any;
  31804. /**
  31805. * The shape of an extrusion used for a rope based on an extrusion
  31806. */
  31807. shape?: any;
  31808. }
  31809. /**
  31810. * Interface for a physics-enabled object
  31811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31812. */
  31813. export interface IPhysicsEnabledObject {
  31814. /**
  31815. * The position of the physics-enabled object
  31816. */
  31817. position: Vector3;
  31818. /**
  31819. * The rotation of the physics-enabled object
  31820. */
  31821. rotationQuaternion: Nullable<Quaternion>;
  31822. /**
  31823. * The scale of the physics-enabled object
  31824. */
  31825. scaling: Vector3;
  31826. /**
  31827. * The rotation of the physics-enabled object
  31828. */
  31829. rotation?: Vector3;
  31830. /**
  31831. * The parent of the physics-enabled object
  31832. */
  31833. parent?: any;
  31834. /**
  31835. * The bounding info of the physics-enabled object
  31836. * @returns The bounding info of the physics-enabled object
  31837. */
  31838. getBoundingInfo(): BoundingInfo;
  31839. /**
  31840. * Computes the world matrix
  31841. * @param force Specifies if the world matrix should be computed by force
  31842. * @returns A world matrix
  31843. */
  31844. computeWorldMatrix(force: boolean): Matrix;
  31845. /**
  31846. * Gets the world matrix
  31847. * @returns A world matrix
  31848. */
  31849. getWorldMatrix?(): Matrix;
  31850. /**
  31851. * Gets the child meshes
  31852. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31853. * @returns An array of abstract meshes
  31854. */
  31855. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31856. /**
  31857. * Gets the vertex data
  31858. * @param kind The type of vertex data
  31859. * @returns A nullable array of numbers, or a float32 array
  31860. */
  31861. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31862. /**
  31863. * Gets the indices from the mesh
  31864. * @returns A nullable array of index arrays
  31865. */
  31866. getIndices?(): Nullable<IndicesArray>;
  31867. /**
  31868. * Gets the scene from the mesh
  31869. * @returns the indices array or null
  31870. */
  31871. getScene?(): Scene;
  31872. /**
  31873. * Gets the absolute position from the mesh
  31874. * @returns the absolute position
  31875. */
  31876. getAbsolutePosition(): Vector3;
  31877. /**
  31878. * Gets the absolute pivot point from the mesh
  31879. * @returns the absolute pivot point
  31880. */
  31881. getAbsolutePivotPoint(): Vector3;
  31882. /**
  31883. * Rotates the mesh
  31884. * @param axis The axis of rotation
  31885. * @param amount The amount of rotation
  31886. * @param space The space of the rotation
  31887. * @returns The rotation transform node
  31888. */
  31889. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31890. /**
  31891. * Translates the mesh
  31892. * @param axis The axis of translation
  31893. * @param distance The distance of translation
  31894. * @param space The space of the translation
  31895. * @returns The transform node
  31896. */
  31897. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31898. /**
  31899. * Sets the absolute position of the mesh
  31900. * @param absolutePosition The absolute position of the mesh
  31901. * @returns The transform node
  31902. */
  31903. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31904. /**
  31905. * Gets the class name of the mesh
  31906. * @returns The class name
  31907. */
  31908. getClassName(): string;
  31909. }
  31910. /**
  31911. * Represents a physics imposter
  31912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31913. */
  31914. export class PhysicsImpostor {
  31915. /**
  31916. * The physics-enabled object used as the physics imposter
  31917. */
  31918. object: IPhysicsEnabledObject;
  31919. /**
  31920. * The type of the physics imposter
  31921. */
  31922. type: number;
  31923. private _options;
  31924. private _scene?;
  31925. /**
  31926. * The default object size of the imposter
  31927. */
  31928. static DEFAULT_OBJECT_SIZE: Vector3;
  31929. /**
  31930. * The identity quaternion of the imposter
  31931. */
  31932. static IDENTITY_QUATERNION: Quaternion;
  31933. /** @hidden */
  31934. _pluginData: any;
  31935. private _physicsEngine;
  31936. private _physicsBody;
  31937. private _bodyUpdateRequired;
  31938. private _onBeforePhysicsStepCallbacks;
  31939. private _onAfterPhysicsStepCallbacks;
  31940. /** @hidden */
  31941. _onPhysicsCollideCallbacks: Array<{
  31942. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  31943. otherImpostors: Array<PhysicsImpostor>;
  31944. }>;
  31945. private _deltaPosition;
  31946. private _deltaRotation;
  31947. private _deltaRotationConjugated;
  31948. /** @hidden */
  31949. _isFromLine: boolean;
  31950. private _parent;
  31951. private _isDisposed;
  31952. private static _tmpVecs;
  31953. private static _tmpQuat;
  31954. /**
  31955. * Specifies if the physics imposter is disposed
  31956. */
  31957. get isDisposed(): boolean;
  31958. /**
  31959. * Gets the mass of the physics imposter
  31960. */
  31961. get mass(): number;
  31962. set mass(value: number);
  31963. /**
  31964. * Gets the coefficient of friction
  31965. */
  31966. get friction(): number;
  31967. /**
  31968. * Sets the coefficient of friction
  31969. */
  31970. set friction(value: number);
  31971. /**
  31972. * Gets the coefficient of restitution
  31973. */
  31974. get restitution(): number;
  31975. /**
  31976. * Sets the coefficient of restitution
  31977. */
  31978. set restitution(value: number);
  31979. /**
  31980. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  31981. */
  31982. get pressure(): number;
  31983. /**
  31984. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  31985. */
  31986. set pressure(value: number);
  31987. /**
  31988. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31989. */
  31990. get stiffness(): number;
  31991. /**
  31992. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31993. */
  31994. set stiffness(value: number);
  31995. /**
  31996. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31997. */
  31998. get velocityIterations(): number;
  31999. /**
  32000. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32001. */
  32002. set velocityIterations(value: number);
  32003. /**
  32004. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32005. */
  32006. get positionIterations(): number;
  32007. /**
  32008. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32009. */
  32010. set positionIterations(value: number);
  32011. /**
  32012. * The unique id of the physics imposter
  32013. * set by the physics engine when adding this impostor to the array
  32014. */
  32015. uniqueId: number;
  32016. /**
  32017. * @hidden
  32018. */
  32019. soft: boolean;
  32020. /**
  32021. * @hidden
  32022. */
  32023. segments: number;
  32024. private _joints;
  32025. /**
  32026. * Initializes the physics imposter
  32027. * @param object The physics-enabled object used as the physics imposter
  32028. * @param type The type of the physics imposter
  32029. * @param _options The options for the physics imposter
  32030. * @param _scene The Babylon scene
  32031. */
  32032. constructor(
  32033. /**
  32034. * The physics-enabled object used as the physics imposter
  32035. */
  32036. object: IPhysicsEnabledObject,
  32037. /**
  32038. * The type of the physics imposter
  32039. */
  32040. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32041. /**
  32042. * This function will completly initialize this impostor.
  32043. * It will create a new body - but only if this mesh has no parent.
  32044. * If it has, this impostor will not be used other than to define the impostor
  32045. * of the child mesh.
  32046. * @hidden
  32047. */
  32048. _init(): void;
  32049. private _getPhysicsParent;
  32050. /**
  32051. * Should a new body be generated.
  32052. * @returns boolean specifying if body initialization is required
  32053. */
  32054. isBodyInitRequired(): boolean;
  32055. /**
  32056. * Sets the updated scaling
  32057. * @param updated Specifies if the scaling is updated
  32058. */
  32059. setScalingUpdated(): void;
  32060. /**
  32061. * Force a regeneration of this or the parent's impostor's body.
  32062. * Use under cautious - This will remove all joints already implemented.
  32063. */
  32064. forceUpdate(): void;
  32065. /**
  32066. * Gets the body that holds this impostor. Either its own, or its parent.
  32067. */
  32068. get physicsBody(): any;
  32069. /**
  32070. * Get the parent of the physics imposter
  32071. * @returns Physics imposter or null
  32072. */
  32073. get parent(): Nullable<PhysicsImpostor>;
  32074. /**
  32075. * Sets the parent of the physics imposter
  32076. */
  32077. set parent(value: Nullable<PhysicsImpostor>);
  32078. /**
  32079. * Set the physics body. Used mainly by the physics engine/plugin
  32080. */
  32081. set physicsBody(physicsBody: any);
  32082. /**
  32083. * Resets the update flags
  32084. */
  32085. resetUpdateFlags(): void;
  32086. /**
  32087. * Gets the object extend size
  32088. * @returns the object extend size
  32089. */
  32090. getObjectExtendSize(): Vector3;
  32091. /**
  32092. * Gets the object center
  32093. * @returns The object center
  32094. */
  32095. getObjectCenter(): Vector3;
  32096. /**
  32097. * Get a specific parameter from the options parameters
  32098. * @param paramName The object parameter name
  32099. * @returns The object parameter
  32100. */
  32101. getParam(paramName: string): any;
  32102. /**
  32103. * Sets a specific parameter in the options given to the physics plugin
  32104. * @param paramName The parameter name
  32105. * @param value The value of the parameter
  32106. */
  32107. setParam(paramName: string, value: number): void;
  32108. /**
  32109. * Specifically change the body's mass option. Won't recreate the physics body object
  32110. * @param mass The mass of the physics imposter
  32111. */
  32112. setMass(mass: number): void;
  32113. /**
  32114. * Gets the linear velocity
  32115. * @returns linear velocity or null
  32116. */
  32117. getLinearVelocity(): Nullable<Vector3>;
  32118. /**
  32119. * Sets the linear velocity
  32120. * @param velocity linear velocity or null
  32121. */
  32122. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32123. /**
  32124. * Gets the angular velocity
  32125. * @returns angular velocity or null
  32126. */
  32127. getAngularVelocity(): Nullable<Vector3>;
  32128. /**
  32129. * Sets the angular velocity
  32130. * @param velocity The velocity or null
  32131. */
  32132. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32133. /**
  32134. * Execute a function with the physics plugin native code
  32135. * Provide a function the will have two variables - the world object and the physics body object
  32136. * @param func The function to execute with the physics plugin native code
  32137. */
  32138. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32139. /**
  32140. * Register a function that will be executed before the physics world is stepping forward
  32141. * @param func The function to execute before the physics world is stepped forward
  32142. */
  32143. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32144. /**
  32145. * Unregister a function that will be executed before the physics world is stepping forward
  32146. * @param func The function to execute before the physics world is stepped forward
  32147. */
  32148. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32149. /**
  32150. * Register a function that will be executed after the physics step
  32151. * @param func The function to execute after physics step
  32152. */
  32153. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32154. /**
  32155. * Unregisters a function that will be executed after the physics step
  32156. * @param func The function to execute after physics step
  32157. */
  32158. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32159. /**
  32160. * register a function that will be executed when this impostor collides against a different body
  32161. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32162. * @param func Callback that is executed on collision
  32163. */
  32164. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32165. /**
  32166. * Unregisters the physics imposter on contact
  32167. * @param collideAgainst The physics object to collide against
  32168. * @param func Callback to execute on collision
  32169. */
  32170. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32171. private _tmpQuat;
  32172. private _tmpQuat2;
  32173. /**
  32174. * Get the parent rotation
  32175. * @returns The parent rotation
  32176. */
  32177. getParentsRotation(): Quaternion;
  32178. /**
  32179. * this function is executed by the physics engine.
  32180. */
  32181. beforeStep: () => void;
  32182. /**
  32183. * this function is executed by the physics engine
  32184. */
  32185. afterStep: () => void;
  32186. /**
  32187. * Legacy collision detection event support
  32188. */
  32189. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32190. /**
  32191. * event and body object due to cannon's event-based architecture.
  32192. */
  32193. onCollide: (e: {
  32194. body: any;
  32195. }) => void;
  32196. /**
  32197. * Apply a force
  32198. * @param force The force to apply
  32199. * @param contactPoint The contact point for the force
  32200. * @returns The physics imposter
  32201. */
  32202. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32203. /**
  32204. * Apply an impulse
  32205. * @param force The impulse force
  32206. * @param contactPoint The contact point for the impulse force
  32207. * @returns The physics imposter
  32208. */
  32209. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32210. /**
  32211. * A help function to create a joint
  32212. * @param otherImpostor A physics imposter used to create a joint
  32213. * @param jointType The type of joint
  32214. * @param jointData The data for the joint
  32215. * @returns The physics imposter
  32216. */
  32217. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32218. /**
  32219. * Add a joint to this impostor with a different impostor
  32220. * @param otherImpostor A physics imposter used to add a joint
  32221. * @param joint The joint to add
  32222. * @returns The physics imposter
  32223. */
  32224. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32225. /**
  32226. * Add an anchor to a cloth impostor
  32227. * @param otherImpostor rigid impostor to anchor to
  32228. * @param width ratio across width from 0 to 1
  32229. * @param height ratio up height from 0 to 1
  32230. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32231. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32232. * @returns impostor the soft imposter
  32233. */
  32234. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32235. /**
  32236. * Add a hook to a rope impostor
  32237. * @param otherImpostor rigid impostor to anchor to
  32238. * @param length ratio across rope from 0 to 1
  32239. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32240. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32241. * @returns impostor the rope imposter
  32242. */
  32243. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32244. /**
  32245. * Will keep this body still, in a sleep mode.
  32246. * @returns the physics imposter
  32247. */
  32248. sleep(): PhysicsImpostor;
  32249. /**
  32250. * Wake the body up.
  32251. * @returns The physics imposter
  32252. */
  32253. wakeUp(): PhysicsImpostor;
  32254. /**
  32255. * Clones the physics imposter
  32256. * @param newObject The physics imposter clones to this physics-enabled object
  32257. * @returns A nullable physics imposter
  32258. */
  32259. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32260. /**
  32261. * Disposes the physics imposter
  32262. */
  32263. dispose(): void;
  32264. /**
  32265. * Sets the delta position
  32266. * @param position The delta position amount
  32267. */
  32268. setDeltaPosition(position: Vector3): void;
  32269. /**
  32270. * Sets the delta rotation
  32271. * @param rotation The delta rotation amount
  32272. */
  32273. setDeltaRotation(rotation: Quaternion): void;
  32274. /**
  32275. * Gets the box size of the physics imposter and stores the result in the input parameter
  32276. * @param result Stores the box size
  32277. * @returns The physics imposter
  32278. */
  32279. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32280. /**
  32281. * Gets the radius of the physics imposter
  32282. * @returns Radius of the physics imposter
  32283. */
  32284. getRadius(): number;
  32285. /**
  32286. * Sync a bone with this impostor
  32287. * @param bone The bone to sync to the impostor.
  32288. * @param boneMesh The mesh that the bone is influencing.
  32289. * @param jointPivot The pivot of the joint / bone in local space.
  32290. * @param distToJoint Optional distance from the impostor to the joint.
  32291. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32292. */
  32293. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32294. /**
  32295. * Sync impostor to a bone
  32296. * @param bone The bone that the impostor will be synced to.
  32297. * @param boneMesh The mesh that the bone is influencing.
  32298. * @param jointPivot The pivot of the joint / bone in local space.
  32299. * @param distToJoint Optional distance from the impostor to the joint.
  32300. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32301. * @param boneAxis Optional vector3 axis the bone is aligned with
  32302. */
  32303. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32304. /**
  32305. * No-Imposter type
  32306. */
  32307. static NoImpostor: number;
  32308. /**
  32309. * Sphere-Imposter type
  32310. */
  32311. static SphereImpostor: number;
  32312. /**
  32313. * Box-Imposter type
  32314. */
  32315. static BoxImpostor: number;
  32316. /**
  32317. * Plane-Imposter type
  32318. */
  32319. static PlaneImpostor: number;
  32320. /**
  32321. * Mesh-imposter type
  32322. */
  32323. static MeshImpostor: number;
  32324. /**
  32325. * Capsule-Impostor type (Ammo.js plugin only)
  32326. */
  32327. static CapsuleImpostor: number;
  32328. /**
  32329. * Cylinder-Imposter type
  32330. */
  32331. static CylinderImpostor: number;
  32332. /**
  32333. * Particle-Imposter type
  32334. */
  32335. static ParticleImpostor: number;
  32336. /**
  32337. * Heightmap-Imposter type
  32338. */
  32339. static HeightmapImpostor: number;
  32340. /**
  32341. * ConvexHull-Impostor type (Ammo.js plugin only)
  32342. */
  32343. static ConvexHullImpostor: number;
  32344. /**
  32345. * Custom-Imposter type (Ammo.js plugin only)
  32346. */
  32347. static CustomImpostor: number;
  32348. /**
  32349. * Rope-Imposter type
  32350. */
  32351. static RopeImpostor: number;
  32352. /**
  32353. * Cloth-Imposter type
  32354. */
  32355. static ClothImpostor: number;
  32356. /**
  32357. * Softbody-Imposter type
  32358. */
  32359. static SoftbodyImpostor: number;
  32360. }
  32361. }
  32362. declare module BABYLON {
  32363. /**
  32364. * @hidden
  32365. **/
  32366. export class _CreationDataStorage {
  32367. closePath?: boolean;
  32368. closeArray?: boolean;
  32369. idx: number[];
  32370. dashSize: number;
  32371. gapSize: number;
  32372. path3D: Path3D;
  32373. pathArray: Vector3[][];
  32374. arc: number;
  32375. radius: number;
  32376. cap: number;
  32377. tessellation: number;
  32378. }
  32379. /**
  32380. * @hidden
  32381. **/
  32382. class _InstanceDataStorage {
  32383. visibleInstances: any;
  32384. batchCache: _InstancesBatch;
  32385. instancesBufferSize: number;
  32386. instancesBuffer: Nullable<Buffer>;
  32387. instancesData: Float32Array;
  32388. overridenInstanceCount: number;
  32389. isFrozen: boolean;
  32390. previousBatch: Nullable<_InstancesBatch>;
  32391. hardwareInstancedRendering: boolean;
  32392. sideOrientation: number;
  32393. manualUpdate: boolean;
  32394. previousRenderId: number;
  32395. }
  32396. /**
  32397. * @hidden
  32398. **/
  32399. export class _InstancesBatch {
  32400. mustReturn: boolean;
  32401. visibleInstances: Nullable<InstancedMesh[]>[];
  32402. renderSelf: boolean[];
  32403. hardwareInstancedRendering: boolean[];
  32404. }
  32405. /**
  32406. * @hidden
  32407. **/
  32408. class _ThinInstanceDataStorage {
  32409. instancesCount: number;
  32410. matrixBuffer: Nullable<Buffer>;
  32411. matrixBufferSize: number;
  32412. matrixData: Nullable<Float32Array>;
  32413. boundingVectors: Array<Vector3>;
  32414. worldMatrices: Nullable<Matrix[]>;
  32415. }
  32416. /**
  32417. * Class used to represent renderable models
  32418. */
  32419. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32420. /**
  32421. * Mesh side orientation : usually the external or front surface
  32422. */
  32423. static readonly FRONTSIDE: number;
  32424. /**
  32425. * Mesh side orientation : usually the internal or back surface
  32426. */
  32427. static readonly BACKSIDE: number;
  32428. /**
  32429. * Mesh side orientation : both internal and external or front and back surfaces
  32430. */
  32431. static readonly DOUBLESIDE: number;
  32432. /**
  32433. * Mesh side orientation : by default, `FRONTSIDE`
  32434. */
  32435. static readonly DEFAULTSIDE: number;
  32436. /**
  32437. * Mesh cap setting : no cap
  32438. */
  32439. static readonly NO_CAP: number;
  32440. /**
  32441. * Mesh cap setting : one cap at the beginning of the mesh
  32442. */
  32443. static readonly CAP_START: number;
  32444. /**
  32445. * Mesh cap setting : one cap at the end of the mesh
  32446. */
  32447. static readonly CAP_END: number;
  32448. /**
  32449. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32450. */
  32451. static readonly CAP_ALL: number;
  32452. /**
  32453. * Mesh pattern setting : no flip or rotate
  32454. */
  32455. static readonly NO_FLIP: number;
  32456. /**
  32457. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32458. */
  32459. static readonly FLIP_TILE: number;
  32460. /**
  32461. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32462. */
  32463. static readonly ROTATE_TILE: number;
  32464. /**
  32465. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32466. */
  32467. static readonly FLIP_ROW: number;
  32468. /**
  32469. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32470. */
  32471. static readonly ROTATE_ROW: number;
  32472. /**
  32473. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32474. */
  32475. static readonly FLIP_N_ROTATE_TILE: number;
  32476. /**
  32477. * Mesh pattern setting : rotate pattern and rotate
  32478. */
  32479. static readonly FLIP_N_ROTATE_ROW: number;
  32480. /**
  32481. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32482. */
  32483. static readonly CENTER: number;
  32484. /**
  32485. * Mesh tile positioning : part tiles on left
  32486. */
  32487. static readonly LEFT: number;
  32488. /**
  32489. * Mesh tile positioning : part tiles on right
  32490. */
  32491. static readonly RIGHT: number;
  32492. /**
  32493. * Mesh tile positioning : part tiles on top
  32494. */
  32495. static readonly TOP: number;
  32496. /**
  32497. * Mesh tile positioning : part tiles on bottom
  32498. */
  32499. static readonly BOTTOM: number;
  32500. /**
  32501. * Gets the default side orientation.
  32502. * @param orientation the orientation to value to attempt to get
  32503. * @returns the default orientation
  32504. * @hidden
  32505. */
  32506. static _GetDefaultSideOrientation(orientation?: number): number;
  32507. private _internalMeshDataInfo;
  32508. get computeBonesUsingShaders(): boolean;
  32509. set computeBonesUsingShaders(value: boolean);
  32510. /**
  32511. * An event triggered before rendering the mesh
  32512. */
  32513. get onBeforeRenderObservable(): Observable<Mesh>;
  32514. /**
  32515. * An event triggered before binding the mesh
  32516. */
  32517. get onBeforeBindObservable(): Observable<Mesh>;
  32518. /**
  32519. * An event triggered after rendering the mesh
  32520. */
  32521. get onAfterRenderObservable(): Observable<Mesh>;
  32522. /**
  32523. * An event triggered before drawing the mesh
  32524. */
  32525. get onBeforeDrawObservable(): Observable<Mesh>;
  32526. private _onBeforeDrawObserver;
  32527. /**
  32528. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32529. */
  32530. set onBeforeDraw(callback: () => void);
  32531. get hasInstances(): boolean;
  32532. get hasThinInstances(): boolean;
  32533. /**
  32534. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32535. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32536. */
  32537. delayLoadState: number;
  32538. /**
  32539. * Gets the list of instances created from this mesh
  32540. * it is not supposed to be modified manually.
  32541. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32542. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32543. */
  32544. instances: InstancedMesh[];
  32545. /**
  32546. * Gets the file containing delay loading data for this mesh
  32547. */
  32548. delayLoadingFile: string;
  32549. /** @hidden */
  32550. _binaryInfo: any;
  32551. /**
  32552. * User defined function used to change how LOD level selection is done
  32553. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32554. */
  32555. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32556. /**
  32557. * Gets or sets the morph target manager
  32558. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32559. */
  32560. get morphTargetManager(): Nullable<MorphTargetManager>;
  32561. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32562. /** @hidden */
  32563. _creationDataStorage: Nullable<_CreationDataStorage>;
  32564. /** @hidden */
  32565. _geometry: Nullable<Geometry>;
  32566. /** @hidden */
  32567. _delayInfo: Array<string>;
  32568. /** @hidden */
  32569. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32570. /** @hidden */
  32571. _instanceDataStorage: _InstanceDataStorage;
  32572. /** @hidden */
  32573. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32574. private _effectiveMaterial;
  32575. /** @hidden */
  32576. _shouldGenerateFlatShading: boolean;
  32577. /** @hidden */
  32578. _originalBuilderSideOrientation: number;
  32579. /**
  32580. * Use this property to change the original side orientation defined at construction time
  32581. */
  32582. overrideMaterialSideOrientation: Nullable<number>;
  32583. /**
  32584. * Gets the source mesh (the one used to clone this one from)
  32585. */
  32586. get source(): Nullable<Mesh>;
  32587. /**
  32588. * Gets the list of clones of this mesh
  32589. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32590. * Note that useClonedMeshMap=true is the default setting
  32591. */
  32592. get cloneMeshMap(): Nullable<{
  32593. [id: string]: Mesh | undefined;
  32594. }>;
  32595. /**
  32596. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32597. */
  32598. get isUnIndexed(): boolean;
  32599. set isUnIndexed(value: boolean);
  32600. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32601. get worldMatrixInstancedBuffer(): Float32Array;
  32602. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32603. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32604. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32605. /**
  32606. * @constructor
  32607. * @param name The value used by scene.getMeshByName() to do a lookup.
  32608. * @param scene The scene to add this mesh to.
  32609. * @param parent The parent of this mesh, if it has one
  32610. * @param source An optional Mesh from which geometry is shared, cloned.
  32611. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32612. * When false, achieved by calling a clone(), also passing False.
  32613. * This will make creation of children, recursive.
  32614. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32615. */
  32616. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32617. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32618. doNotInstantiate: boolean;
  32619. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32620. /**
  32621. * Gets the class name
  32622. * @returns the string "Mesh".
  32623. */
  32624. getClassName(): string;
  32625. /** @hidden */
  32626. get _isMesh(): boolean;
  32627. /**
  32628. * Returns a description of this mesh
  32629. * @param fullDetails define if full details about this mesh must be used
  32630. * @returns a descriptive string representing this mesh
  32631. */
  32632. toString(fullDetails?: boolean): string;
  32633. /** @hidden */
  32634. _unBindEffect(): void;
  32635. /**
  32636. * Gets a boolean indicating if this mesh has LOD
  32637. */
  32638. get hasLODLevels(): boolean;
  32639. /**
  32640. * Gets the list of MeshLODLevel associated with the current mesh
  32641. * @returns an array of MeshLODLevel
  32642. */
  32643. getLODLevels(): MeshLODLevel[];
  32644. private _sortLODLevels;
  32645. /**
  32646. * Add a mesh as LOD level triggered at the given distance.
  32647. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32648. * @param distance The distance from the center of the object to show this level
  32649. * @param mesh The mesh to be added as LOD level (can be null)
  32650. * @return This mesh (for chaining)
  32651. */
  32652. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32653. /**
  32654. * Returns the LOD level mesh at the passed distance or null if not found.
  32655. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32656. * @param distance The distance from the center of the object to show this level
  32657. * @returns a Mesh or `null`
  32658. */
  32659. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32660. /**
  32661. * Remove a mesh from the LOD array
  32662. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32663. * @param mesh defines the mesh to be removed
  32664. * @return This mesh (for chaining)
  32665. */
  32666. removeLODLevel(mesh: Mesh): Mesh;
  32667. /**
  32668. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32669. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32670. * @param camera defines the camera to use to compute distance
  32671. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32672. * @return This mesh (for chaining)
  32673. */
  32674. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32675. /**
  32676. * Gets the mesh internal Geometry object
  32677. */
  32678. get geometry(): Nullable<Geometry>;
  32679. /**
  32680. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32681. * @returns the total number of vertices
  32682. */
  32683. getTotalVertices(): number;
  32684. /**
  32685. * Returns the content of an associated vertex buffer
  32686. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32687. * - VertexBuffer.PositionKind
  32688. * - VertexBuffer.UVKind
  32689. * - VertexBuffer.UV2Kind
  32690. * - VertexBuffer.UV3Kind
  32691. * - VertexBuffer.UV4Kind
  32692. * - VertexBuffer.UV5Kind
  32693. * - VertexBuffer.UV6Kind
  32694. * - VertexBuffer.ColorKind
  32695. * - VertexBuffer.MatricesIndicesKind
  32696. * - VertexBuffer.MatricesIndicesExtraKind
  32697. * - VertexBuffer.MatricesWeightsKind
  32698. * - VertexBuffer.MatricesWeightsExtraKind
  32699. * @param 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
  32700. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32701. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32702. */
  32703. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32704. /**
  32705. * Returns the mesh VertexBuffer object from the requested `kind`
  32706. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32707. * - VertexBuffer.PositionKind
  32708. * - VertexBuffer.NormalKind
  32709. * - VertexBuffer.UVKind
  32710. * - VertexBuffer.UV2Kind
  32711. * - VertexBuffer.UV3Kind
  32712. * - VertexBuffer.UV4Kind
  32713. * - VertexBuffer.UV5Kind
  32714. * - VertexBuffer.UV6Kind
  32715. * - VertexBuffer.ColorKind
  32716. * - VertexBuffer.MatricesIndicesKind
  32717. * - VertexBuffer.MatricesIndicesExtraKind
  32718. * - VertexBuffer.MatricesWeightsKind
  32719. * - VertexBuffer.MatricesWeightsExtraKind
  32720. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32721. */
  32722. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32723. /**
  32724. * Tests if a specific vertex buffer is associated with this mesh
  32725. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32726. * - VertexBuffer.PositionKind
  32727. * - VertexBuffer.NormalKind
  32728. * - VertexBuffer.UVKind
  32729. * - VertexBuffer.UV2Kind
  32730. * - VertexBuffer.UV3Kind
  32731. * - VertexBuffer.UV4Kind
  32732. * - VertexBuffer.UV5Kind
  32733. * - VertexBuffer.UV6Kind
  32734. * - VertexBuffer.ColorKind
  32735. * - VertexBuffer.MatricesIndicesKind
  32736. * - VertexBuffer.MatricesIndicesExtraKind
  32737. * - VertexBuffer.MatricesWeightsKind
  32738. * - VertexBuffer.MatricesWeightsExtraKind
  32739. * @returns a boolean
  32740. */
  32741. isVerticesDataPresent(kind: string): boolean;
  32742. /**
  32743. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32744. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32745. * - VertexBuffer.PositionKind
  32746. * - VertexBuffer.UVKind
  32747. * - VertexBuffer.UV2Kind
  32748. * - VertexBuffer.UV3Kind
  32749. * - VertexBuffer.UV4Kind
  32750. * - VertexBuffer.UV5Kind
  32751. * - VertexBuffer.UV6Kind
  32752. * - VertexBuffer.ColorKind
  32753. * - VertexBuffer.MatricesIndicesKind
  32754. * - VertexBuffer.MatricesIndicesExtraKind
  32755. * - VertexBuffer.MatricesWeightsKind
  32756. * - VertexBuffer.MatricesWeightsExtraKind
  32757. * @returns a boolean
  32758. */
  32759. isVertexBufferUpdatable(kind: string): boolean;
  32760. /**
  32761. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32762. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32763. * - VertexBuffer.PositionKind
  32764. * - VertexBuffer.NormalKind
  32765. * - VertexBuffer.UVKind
  32766. * - VertexBuffer.UV2Kind
  32767. * - VertexBuffer.UV3Kind
  32768. * - VertexBuffer.UV4Kind
  32769. * - VertexBuffer.UV5Kind
  32770. * - VertexBuffer.UV6Kind
  32771. * - VertexBuffer.ColorKind
  32772. * - VertexBuffer.MatricesIndicesKind
  32773. * - VertexBuffer.MatricesIndicesExtraKind
  32774. * - VertexBuffer.MatricesWeightsKind
  32775. * - VertexBuffer.MatricesWeightsExtraKind
  32776. * @returns an array of strings
  32777. */
  32778. getVerticesDataKinds(): string[];
  32779. /**
  32780. * Returns a positive integer : the total number of indices in this mesh geometry.
  32781. * @returns the numner of indices or zero if the mesh has no geometry.
  32782. */
  32783. getTotalIndices(): number;
  32784. /**
  32785. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32786. * @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.
  32787. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32788. * @returns the indices array or an empty array if the mesh has no geometry
  32789. */
  32790. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32791. get isBlocked(): boolean;
  32792. /**
  32793. * Determine if the current mesh is ready to be rendered
  32794. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32795. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32796. * @returns true if all associated assets are ready (material, textures, shaders)
  32797. */
  32798. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32799. /**
  32800. * 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.
  32801. */
  32802. get areNormalsFrozen(): boolean;
  32803. /**
  32804. * 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.
  32805. * @returns the current mesh
  32806. */
  32807. freezeNormals(): Mesh;
  32808. /**
  32809. * 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
  32810. * @returns the current mesh
  32811. */
  32812. unfreezeNormals(): Mesh;
  32813. /**
  32814. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32815. */
  32816. set overridenInstanceCount(count: number);
  32817. /** @hidden */
  32818. _preActivate(): Mesh;
  32819. /** @hidden */
  32820. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32821. /** @hidden */
  32822. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32823. protected _afterComputeWorldMatrix(): void;
  32824. /** @hidden */
  32825. _postActivate(): void;
  32826. /**
  32827. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32828. * This means the mesh underlying bounding box and sphere are recomputed.
  32829. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32830. * @returns the current mesh
  32831. */
  32832. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32833. /** @hidden */
  32834. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32835. /**
  32836. * This function will subdivide the mesh into multiple submeshes
  32837. * @param count defines the expected number of submeshes
  32838. */
  32839. subdivide(count: number): void;
  32840. /**
  32841. * Copy a FloatArray into a specific associated vertex buffer
  32842. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32843. * - VertexBuffer.PositionKind
  32844. * - VertexBuffer.UVKind
  32845. * - VertexBuffer.UV2Kind
  32846. * - VertexBuffer.UV3Kind
  32847. * - VertexBuffer.UV4Kind
  32848. * - VertexBuffer.UV5Kind
  32849. * - VertexBuffer.UV6Kind
  32850. * - VertexBuffer.ColorKind
  32851. * - VertexBuffer.MatricesIndicesKind
  32852. * - VertexBuffer.MatricesIndicesExtraKind
  32853. * - VertexBuffer.MatricesWeightsKind
  32854. * - VertexBuffer.MatricesWeightsExtraKind
  32855. * @param data defines the data source
  32856. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32857. * @param stride defines the data stride size (can be null)
  32858. * @returns the current mesh
  32859. */
  32860. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32861. /**
  32862. * Delete a vertex buffer associated with this mesh
  32863. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32864. * - VertexBuffer.PositionKind
  32865. * - VertexBuffer.UVKind
  32866. * - VertexBuffer.UV2Kind
  32867. * - VertexBuffer.UV3Kind
  32868. * - VertexBuffer.UV4Kind
  32869. * - VertexBuffer.UV5Kind
  32870. * - VertexBuffer.UV6Kind
  32871. * - VertexBuffer.ColorKind
  32872. * - VertexBuffer.MatricesIndicesKind
  32873. * - VertexBuffer.MatricesIndicesExtraKind
  32874. * - VertexBuffer.MatricesWeightsKind
  32875. * - VertexBuffer.MatricesWeightsExtraKind
  32876. */
  32877. removeVerticesData(kind: string): void;
  32878. /**
  32879. * Flags an associated vertex buffer as updatable
  32880. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32881. * - VertexBuffer.PositionKind
  32882. * - VertexBuffer.UVKind
  32883. * - VertexBuffer.UV2Kind
  32884. * - VertexBuffer.UV3Kind
  32885. * - VertexBuffer.UV4Kind
  32886. * - VertexBuffer.UV5Kind
  32887. * - VertexBuffer.UV6Kind
  32888. * - VertexBuffer.ColorKind
  32889. * - VertexBuffer.MatricesIndicesKind
  32890. * - VertexBuffer.MatricesIndicesExtraKind
  32891. * - VertexBuffer.MatricesWeightsKind
  32892. * - VertexBuffer.MatricesWeightsExtraKind
  32893. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32894. */
  32895. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32896. /**
  32897. * Sets the mesh global Vertex Buffer
  32898. * @param buffer defines the buffer to use
  32899. * @returns the current mesh
  32900. */
  32901. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32902. /**
  32903. * Update a specific associated vertex buffer
  32904. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32905. * - VertexBuffer.PositionKind
  32906. * - VertexBuffer.UVKind
  32907. * - VertexBuffer.UV2Kind
  32908. * - VertexBuffer.UV3Kind
  32909. * - VertexBuffer.UV4Kind
  32910. * - VertexBuffer.UV5Kind
  32911. * - VertexBuffer.UV6Kind
  32912. * - VertexBuffer.ColorKind
  32913. * - VertexBuffer.MatricesIndicesKind
  32914. * - VertexBuffer.MatricesIndicesExtraKind
  32915. * - VertexBuffer.MatricesWeightsKind
  32916. * - VertexBuffer.MatricesWeightsExtraKind
  32917. * @param data defines the data source
  32918. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32919. * @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)
  32920. * @returns the current mesh
  32921. */
  32922. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32923. /**
  32924. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32925. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32926. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32927. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32928. * @returns the current mesh
  32929. */
  32930. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32931. /**
  32932. * Creates a un-shared specific occurence of the geometry for the mesh.
  32933. * @returns the current mesh
  32934. */
  32935. makeGeometryUnique(): Mesh;
  32936. /**
  32937. * Set the index buffer of this mesh
  32938. * @param indices defines the source data
  32939. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32940. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32941. * @returns the current mesh
  32942. */
  32943. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32944. /**
  32945. * Update the current index buffer
  32946. * @param indices defines the source data
  32947. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32948. * @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)
  32949. * @returns the current mesh
  32950. */
  32951. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32952. /**
  32953. * Invert the geometry to move from a right handed system to a left handed one.
  32954. * @returns the current mesh
  32955. */
  32956. toLeftHanded(): Mesh;
  32957. /** @hidden */
  32958. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32959. /** @hidden */
  32960. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32961. /**
  32962. * Registers for this mesh a javascript function called just before the rendering process
  32963. * @param func defines the function to call before rendering this mesh
  32964. * @returns the current mesh
  32965. */
  32966. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32967. /**
  32968. * Disposes a previously registered javascript function called before the rendering
  32969. * @param func defines the function to remove
  32970. * @returns the current mesh
  32971. */
  32972. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32973. /**
  32974. * Registers for this mesh a javascript function called just after the rendering is complete
  32975. * @param func defines the function to call after rendering this mesh
  32976. * @returns the current mesh
  32977. */
  32978. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32979. /**
  32980. * Disposes a previously registered javascript function called after the rendering.
  32981. * @param func defines the function to remove
  32982. * @returns the current mesh
  32983. */
  32984. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32985. /** @hidden */
  32986. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  32987. /** @hidden */
  32988. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  32989. /** @hidden */
  32990. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  32991. /** @hidden */
  32992. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  32993. /** @hidden */
  32994. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  32995. /** @hidden */
  32996. _rebuild(): void;
  32997. /** @hidden */
  32998. _freeze(): void;
  32999. /** @hidden */
  33000. _unFreeze(): void;
  33001. /**
  33002. * 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
  33003. * @param subMesh defines the subMesh to render
  33004. * @param enableAlphaMode defines if alpha mode can be changed
  33005. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33006. * @returns the current mesh
  33007. */
  33008. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33009. private _onBeforeDraw;
  33010. /**
  33011. * Renormalize the mesh and patch it up if there are no weights
  33012. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33013. * However in the case of zero weights then we set just a single influence to 1.
  33014. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33015. */
  33016. cleanMatrixWeights(): void;
  33017. private normalizeSkinFourWeights;
  33018. private normalizeSkinWeightsAndExtra;
  33019. /**
  33020. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33021. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33022. * the user know there was an issue with importing the mesh
  33023. * @returns a validation object with skinned, valid and report string
  33024. */
  33025. validateSkinning(): {
  33026. skinned: boolean;
  33027. valid: boolean;
  33028. report: string;
  33029. };
  33030. /** @hidden */
  33031. _checkDelayState(): Mesh;
  33032. private _queueLoad;
  33033. /**
  33034. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33035. * A mesh is in the frustum if its bounding box intersects the frustum
  33036. * @param frustumPlanes defines the frustum to test
  33037. * @returns true if the mesh is in the frustum planes
  33038. */
  33039. isInFrustum(frustumPlanes: Plane[]): boolean;
  33040. /**
  33041. * Sets the mesh material by the material or multiMaterial `id` property
  33042. * @param id is a string identifying the material or the multiMaterial
  33043. * @returns the current mesh
  33044. */
  33045. setMaterialByID(id: string): Mesh;
  33046. /**
  33047. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33048. * @returns an array of IAnimatable
  33049. */
  33050. getAnimatables(): IAnimatable[];
  33051. /**
  33052. * Modifies the mesh geometry according to the passed transformation matrix.
  33053. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33054. * The mesh normals are modified using the same transformation.
  33055. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33056. * @param transform defines the transform matrix to use
  33057. * @see https://doc.babylonjs.com/resources/baking_transformations
  33058. * @returns the current mesh
  33059. */
  33060. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33061. /**
  33062. * Modifies the mesh geometry according to its own current World Matrix.
  33063. * The mesh World Matrix is then reset.
  33064. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33065. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33066. * @see https://doc.babylonjs.com/resources/baking_transformations
  33067. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33068. * @returns the current mesh
  33069. */
  33070. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33071. /** @hidden */
  33072. get _positions(): Nullable<Vector3[]>;
  33073. /** @hidden */
  33074. _resetPointsArrayCache(): Mesh;
  33075. /** @hidden */
  33076. _generatePointsArray(): boolean;
  33077. /**
  33078. * Returns a new Mesh object generated from the current mesh properties.
  33079. * This method must not get confused with createInstance()
  33080. * @param name is a string, the name given to the new mesh
  33081. * @param newParent can be any Node object (default `null`)
  33082. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33083. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33084. * @returns a new mesh
  33085. */
  33086. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33087. /**
  33088. * Releases resources associated with this mesh.
  33089. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33090. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33091. */
  33092. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33093. /** @hidden */
  33094. _disposeInstanceSpecificData(): void;
  33095. /** @hidden */
  33096. _disposeThinInstanceSpecificData(): void;
  33097. /**
  33098. * Modifies the mesh geometry according to a displacement map.
  33099. * 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.
  33100. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33101. * @param url is a string, the URL from the image file is to be downloaded.
  33102. * @param minHeight is the lower limit of the displacement.
  33103. * @param maxHeight is the upper limit of the displacement.
  33104. * @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.
  33105. * @param uvOffset is an optional vector2 used to offset UV.
  33106. * @param uvScale is an optional vector2 used to scale UV.
  33107. * @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.
  33108. * @returns the Mesh.
  33109. */
  33110. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33111. /**
  33112. * Modifies the mesh geometry according to a displacementMap buffer.
  33113. * 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.
  33114. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33115. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33116. * @param heightMapWidth is the width of the buffer image.
  33117. * @param heightMapHeight is the height of the buffer image.
  33118. * @param minHeight is the lower limit of the displacement.
  33119. * @param maxHeight is the upper limit of the displacement.
  33120. * @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.
  33121. * @param uvOffset is an optional vector2 used to offset UV.
  33122. * @param uvScale is an optional vector2 used to scale UV.
  33123. * @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.
  33124. * @returns the Mesh.
  33125. */
  33126. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33127. /**
  33128. * Modify the mesh to get a flat shading rendering.
  33129. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33130. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33131. * @returns current mesh
  33132. */
  33133. convertToFlatShadedMesh(): Mesh;
  33134. /**
  33135. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33136. * In other words, more vertices, no more indices and a single bigger VBO.
  33137. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33138. * @returns current mesh
  33139. */
  33140. convertToUnIndexedMesh(): Mesh;
  33141. /**
  33142. * Inverses facet orientations.
  33143. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33144. * @param flipNormals will also inverts the normals
  33145. * @returns current mesh
  33146. */
  33147. flipFaces(flipNormals?: boolean): Mesh;
  33148. /**
  33149. * Increase the number of facets and hence vertices in a mesh
  33150. * Vertex normals are interpolated from existing vertex normals
  33151. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33152. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33153. */
  33154. increaseVertices(numberPerEdge: number): void;
  33155. /**
  33156. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33157. * This will undo any application of covertToFlatShadedMesh
  33158. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33159. */
  33160. forceSharedVertices(): void;
  33161. /** @hidden */
  33162. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33163. /** @hidden */
  33164. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33165. /**
  33166. * Creates a new InstancedMesh object from the mesh model.
  33167. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33168. * @param name defines the name of the new instance
  33169. * @returns a new InstancedMesh
  33170. */
  33171. createInstance(name: string): InstancedMesh;
  33172. /**
  33173. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33174. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33175. * @returns the current mesh
  33176. */
  33177. synchronizeInstances(): Mesh;
  33178. /**
  33179. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33180. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33181. * This should be used together with the simplification to avoid disappearing triangles.
  33182. * @param successCallback an optional success callback to be called after the optimization finished.
  33183. * @returns the current mesh
  33184. */
  33185. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33186. /**
  33187. * Serialize current mesh
  33188. * @param serializationObject defines the object which will receive the serialization data
  33189. */
  33190. serialize(serializationObject: any): void;
  33191. /** @hidden */
  33192. _syncGeometryWithMorphTargetManager(): void;
  33193. /** @hidden */
  33194. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33195. /**
  33196. * Returns a new Mesh object parsed from the source provided.
  33197. * @param parsedMesh is the source
  33198. * @param scene defines the hosting scene
  33199. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33200. * @returns a new Mesh
  33201. */
  33202. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33203. /**
  33204. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33205. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33206. * @param name defines the name of the mesh to create
  33207. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33208. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33209. * @param closePath creates a seam between the first and the last points of each path of the path array
  33210. * @param offset is taken in account only if the `pathArray` is containing a single path
  33211. * @param scene defines the hosting scene
  33212. * @param updatable defines if the mesh must be flagged as updatable
  33213. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33214. * @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)
  33215. * @returns a new Mesh
  33216. */
  33217. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33218. /**
  33219. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33220. * @param name defines the name of the mesh to create
  33221. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33222. * @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
  33223. * @param scene defines the hosting scene
  33224. * @param updatable defines if the mesh must be flagged as updatable
  33225. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33226. * @returns a new Mesh
  33227. */
  33228. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33229. /**
  33230. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33231. * @param name defines the name of the mesh to create
  33232. * @param size sets the size (float) of each box side (default 1)
  33233. * @param scene defines the hosting scene
  33234. * @param updatable defines if the mesh must be flagged as updatable
  33235. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33236. * @returns a new Mesh
  33237. */
  33238. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33239. /**
  33240. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33241. * @param name defines the name of the mesh to create
  33242. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33243. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33244. * @param scene defines the hosting scene
  33245. * @param updatable defines if the mesh must be flagged as updatable
  33246. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33247. * @returns a new Mesh
  33248. */
  33249. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33250. /**
  33251. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33252. * @param name defines the name of the mesh to create
  33253. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33254. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33255. * @param scene defines the hosting scene
  33256. * @returns a new Mesh
  33257. */
  33258. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33259. /**
  33260. * Creates a cylinder or a cone 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 height sets the height size (float) of the cylinder/cone (float, default 2)
  33263. * @param diameterTop set the top cap diameter (floats, default 1)
  33264. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33265. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33266. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33267. * @param scene defines the hosting scene
  33268. * @param updatable defines if the mesh must be flagged as updatable
  33269. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33270. * @returns a new Mesh
  33271. */
  33272. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33273. /**
  33274. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33275. * @param name defines the name of the mesh to create
  33276. * @param diameter sets the diameter size (float) of the torus (default 1)
  33277. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33278. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33279. * @param scene defines the hosting scene
  33280. * @param updatable defines if the mesh must be flagged as updatable
  33281. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33282. * @returns a new Mesh
  33283. */
  33284. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33285. /**
  33286. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33287. * @param name defines the name of the mesh to create
  33288. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33289. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33290. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33291. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33292. * @param p the number of windings on X axis (positive integers, default 2)
  33293. * @param q the number of windings on Y axis (positive integers, default 3)
  33294. * @param scene defines the hosting scene
  33295. * @param updatable defines if the mesh must be flagged as updatable
  33296. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33297. * @returns a new Mesh
  33298. */
  33299. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33300. /**
  33301. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33302. * @param name defines the name of the mesh to create
  33303. * @param points is an array successive Vector3
  33304. * @param scene defines the hosting scene
  33305. * @param updatable defines if the mesh must be flagged as updatable
  33306. * @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).
  33307. * @returns a new Mesh
  33308. */
  33309. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33310. /**
  33311. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33312. * @param name defines the name of the mesh to create
  33313. * @param points is an array successive Vector3
  33314. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33315. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33316. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33317. * @param scene defines the hosting scene
  33318. * @param updatable defines if the mesh must be flagged as updatable
  33319. * @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)
  33320. * @returns a new Mesh
  33321. */
  33322. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33323. /**
  33324. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33325. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33326. * 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.
  33327. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33328. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33329. * Remember you can only change the shape positions, not their number when updating a polygon.
  33330. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33331. * @param name defines the name of the mesh to create
  33332. * @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
  33333. * @param scene defines the hosting scene
  33334. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33335. * @param updatable defines if the mesh must be flagged as updatable
  33336. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33337. * @param earcutInjection can be used to inject your own earcut reference
  33338. * @returns a new Mesh
  33339. */
  33340. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33341. /**
  33342. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33344. * @param name defines the name of the mesh to create
  33345. * @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
  33346. * @param depth defines the height of extrusion
  33347. * @param scene defines the hosting scene
  33348. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33349. * @param updatable defines if the mesh must be flagged as updatable
  33350. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33351. * @param earcutInjection can be used to inject your own earcut reference
  33352. * @returns a new Mesh
  33353. */
  33354. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33355. /**
  33356. * Creates an extruded shape mesh.
  33357. * 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
  33358. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33359. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33360. * @param name defines the name of the mesh to create
  33361. * @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
  33362. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33363. * @param scale is the value to scale the shape
  33364. * @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
  33365. * @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
  33366. * @param scene defines the hosting scene
  33367. * @param updatable defines if the mesh must be flagged as updatable
  33368. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33369. * @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)
  33370. * @returns a new Mesh
  33371. */
  33372. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33373. /**
  33374. * Creates an custom extruded shape mesh.
  33375. * The custom extrusion is a parametric shape.
  33376. * It has no predefined shape. Its final shape will depend on the input parameters.
  33377. * Please consider using the same method from the MeshBuilder class instead
  33378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33379. * @param name defines the name of the mesh to create
  33380. * @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
  33381. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33382. * @param scaleFunction is a custom Javascript function called on each path point
  33383. * @param rotationFunction is a custom Javascript function called on each path point
  33384. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33385. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33386. * @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
  33387. * @param scene defines the hosting scene
  33388. * @param updatable defines if the mesh must be flagged as updatable
  33389. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33390. * @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)
  33391. * @returns a new Mesh
  33392. */
  33393. 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;
  33394. /**
  33395. * Creates lathe mesh.
  33396. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33397. * Please consider using the same method from the MeshBuilder class instead
  33398. * @param name defines the name of the mesh to create
  33399. * @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
  33400. * @param radius is the radius value of the lathe
  33401. * @param tessellation is the side number of the lathe.
  33402. * @param scene defines the hosting scene
  33403. * @param updatable defines if the mesh must be flagged as updatable
  33404. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33405. * @returns a new Mesh
  33406. */
  33407. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33408. /**
  33409. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33410. * @param name defines the name of the mesh to create
  33411. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33412. * @param scene defines the hosting scene
  33413. * @param updatable defines if the mesh must be flagged as updatable
  33414. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33415. * @returns a new Mesh
  33416. */
  33417. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33418. /**
  33419. * Creates a ground mesh.
  33420. * Please consider using the same method from the MeshBuilder class instead
  33421. * @param name defines the name of the mesh to create
  33422. * @param width set the width of the ground
  33423. * @param height set the height of the ground
  33424. * @param subdivisions sets the number of subdivisions per side
  33425. * @param scene defines the hosting scene
  33426. * @param updatable defines if the mesh must be flagged as updatable
  33427. * @returns a new Mesh
  33428. */
  33429. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33430. /**
  33431. * Creates a tiled ground mesh.
  33432. * Please consider using the same method from the MeshBuilder class instead
  33433. * @param name defines the name of the mesh to create
  33434. * @param xmin set the ground minimum X coordinate
  33435. * @param zmin set the ground minimum Y coordinate
  33436. * @param xmax set the ground maximum X coordinate
  33437. * @param zmax set the ground maximum Z coordinate
  33438. * @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
  33439. * @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
  33440. * @param scene defines the hosting scene
  33441. * @param updatable defines if the mesh must be flagged as updatable
  33442. * @returns a new Mesh
  33443. */
  33444. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33445. w: number;
  33446. h: number;
  33447. }, precision: {
  33448. w: number;
  33449. h: number;
  33450. }, scene: Scene, updatable?: boolean): Mesh;
  33451. /**
  33452. * Creates a ground mesh from a height map.
  33453. * Please consider using the same method from the MeshBuilder class instead
  33454. * @see https://doc.babylonjs.com/babylon101/height_map
  33455. * @param name defines the name of the mesh to create
  33456. * @param url sets the URL of the height map image resource
  33457. * @param width set the ground width size
  33458. * @param height set the ground height size
  33459. * @param subdivisions sets the number of subdivision per side
  33460. * @param minHeight is the minimum altitude on the ground
  33461. * @param maxHeight is the maximum altitude on the ground
  33462. * @param scene defines the hosting scene
  33463. * @param updatable defines if the mesh must be flagged as updatable
  33464. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33465. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33466. * @returns a new Mesh
  33467. */
  33468. 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;
  33469. /**
  33470. * Creates a tube mesh.
  33471. * The tube is a parametric shape.
  33472. * It has no predefined shape. Its final shape will depend on the input parameters.
  33473. * Please consider using the same method from the MeshBuilder class instead
  33474. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33475. * @param name defines the name of the mesh to create
  33476. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33477. * @param radius sets the tube radius size
  33478. * @param tessellation is the number of sides on the tubular surface
  33479. * @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
  33480. * @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
  33481. * @param scene defines the hosting scene
  33482. * @param updatable defines if the mesh must be flagged as updatable
  33483. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33484. * @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)
  33485. * @returns a new Mesh
  33486. */
  33487. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33488. (i: number, distance: number): number;
  33489. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33490. /**
  33491. * Creates a polyhedron mesh.
  33492. * Please consider using the same method from the MeshBuilder class instead.
  33493. * * 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
  33494. * * The parameter `size` (positive float, default 1) sets the polygon size
  33495. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33496. * * 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`
  33497. * * 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
  33498. * * 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)`)
  33499. * * 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
  33500. * * 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
  33501. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33502. * * 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
  33503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33504. * @param name defines the name of the mesh to create
  33505. * @param options defines the options used to create the mesh
  33506. * @param scene defines the hosting scene
  33507. * @returns a new Mesh
  33508. */
  33509. static CreatePolyhedron(name: string, options: {
  33510. type?: number;
  33511. size?: number;
  33512. sizeX?: number;
  33513. sizeY?: number;
  33514. sizeZ?: number;
  33515. custom?: any;
  33516. faceUV?: Vector4[];
  33517. faceColors?: Color4[];
  33518. updatable?: boolean;
  33519. sideOrientation?: number;
  33520. }, scene: Scene): Mesh;
  33521. /**
  33522. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33523. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33524. * * 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`)
  33525. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33526. * * 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
  33527. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33528. * * 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
  33529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33530. * @param name defines the name of the mesh
  33531. * @param options defines the options used to create the mesh
  33532. * @param scene defines the hosting scene
  33533. * @returns a new Mesh
  33534. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33535. */
  33536. static CreateIcoSphere(name: string, options: {
  33537. radius?: number;
  33538. flat?: boolean;
  33539. subdivisions?: number;
  33540. sideOrientation?: number;
  33541. updatable?: boolean;
  33542. }, scene: Scene): Mesh;
  33543. /**
  33544. * Creates a decal mesh.
  33545. * Please consider using the same method from the MeshBuilder class instead.
  33546. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33547. * @param name defines the name of the mesh
  33548. * @param sourceMesh defines the mesh receiving the decal
  33549. * @param position sets the position of the decal in world coordinates
  33550. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33551. * @param size sets the decal scaling
  33552. * @param angle sets the angle to rotate the decal
  33553. * @returns a new Mesh
  33554. */
  33555. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33556. /** Creates a Capsule Mesh
  33557. * @param name defines the name of the mesh.
  33558. * @param options the constructors options used to shape the mesh.
  33559. * @param scene defines the scene the mesh is scoped to.
  33560. * @returns the capsule mesh
  33561. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33562. */
  33563. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33564. /**
  33565. * Prepare internal position array for software CPU skinning
  33566. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33567. */
  33568. setPositionsForCPUSkinning(): Float32Array;
  33569. /**
  33570. * Prepare internal normal array for software CPU skinning
  33571. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33572. */
  33573. setNormalsForCPUSkinning(): Float32Array;
  33574. /**
  33575. * Updates the vertex buffer by applying transformation from the bones
  33576. * @param skeleton defines the skeleton to apply to current mesh
  33577. * @returns the current mesh
  33578. */
  33579. applySkeleton(skeleton: Skeleton): Mesh;
  33580. /**
  33581. * 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
  33582. * @param meshes defines the list of meshes to scan
  33583. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33584. */
  33585. static MinMax(meshes: AbstractMesh[]): {
  33586. min: Vector3;
  33587. max: Vector3;
  33588. };
  33589. /**
  33590. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33591. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33592. * @returns a vector3
  33593. */
  33594. static Center(meshesOrMinMaxVector: {
  33595. min: Vector3;
  33596. max: Vector3;
  33597. } | AbstractMesh[]): Vector3;
  33598. /**
  33599. * Merge the array of meshes into a single mesh for performance reasons.
  33600. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33601. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33602. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33603. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33604. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33605. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33606. * @returns a new mesh
  33607. */
  33608. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33609. /** @hidden */
  33610. addInstance(instance: InstancedMesh): void;
  33611. /** @hidden */
  33612. removeInstance(instance: InstancedMesh): void;
  33613. }
  33614. }
  33615. declare module BABYLON {
  33616. /**
  33617. * This is the base class of all the camera used in the application.
  33618. * @see https://doc.babylonjs.com/features/cameras
  33619. */
  33620. export class Camera extends Node {
  33621. /** @hidden */
  33622. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  33623. /**
  33624. * This is the default projection mode used by the cameras.
  33625. * It helps recreating a feeling of perspective and better appreciate depth.
  33626. * This is the best way to simulate real life cameras.
  33627. */
  33628. static readonly PERSPECTIVE_CAMERA: number;
  33629. /**
  33630. * This helps creating camera with an orthographic mode.
  33631. * 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.
  33632. */
  33633. static readonly ORTHOGRAPHIC_CAMERA: number;
  33634. /**
  33635. * This is the default FOV mode for perspective cameras.
  33636. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  33637. */
  33638. static readonly FOVMODE_VERTICAL_FIXED: number;
  33639. /**
  33640. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  33641. */
  33642. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  33643. /**
  33644. * This specifies ther is no need for a camera rig.
  33645. * Basically only one eye is rendered corresponding to the camera.
  33646. */
  33647. static readonly RIG_MODE_NONE: number;
  33648. /**
  33649. * Simulates a camera Rig with one blue eye and one red eye.
  33650. * This can be use with 3d blue and red glasses.
  33651. */
  33652. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  33653. /**
  33654. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  33655. */
  33656. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  33657. /**
  33658. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  33659. */
  33660. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  33661. /**
  33662. * Defines that both eyes of the camera will be rendered over under each other.
  33663. */
  33664. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  33665. /**
  33666. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  33667. */
  33668. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  33669. /**
  33670. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  33671. */
  33672. static readonly RIG_MODE_VR: number;
  33673. /**
  33674. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  33675. */
  33676. static readonly RIG_MODE_WEBVR: number;
  33677. /**
  33678. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  33679. */
  33680. static readonly RIG_MODE_CUSTOM: number;
  33681. /**
  33682. * Defines if by default attaching controls should prevent the default javascript event to continue.
  33683. */
  33684. static ForceAttachControlToAlwaysPreventDefault: boolean;
  33685. /**
  33686. * Define the input manager associated with the camera.
  33687. */
  33688. inputs: CameraInputsManager<Camera>;
  33689. /** @hidden */
  33690. _position: Vector3;
  33691. /**
  33692. * Define the current local position of the camera in the scene
  33693. */
  33694. get position(): Vector3;
  33695. set position(newPosition: Vector3);
  33696. protected _upVector: Vector3;
  33697. /**
  33698. * The vector the camera should consider as up.
  33699. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  33700. */
  33701. set upVector(vec: Vector3);
  33702. get upVector(): Vector3;
  33703. /**
  33704. * Define the current limit on the left side for an orthographic camera
  33705. * In scene unit
  33706. */
  33707. orthoLeft: Nullable<number>;
  33708. /**
  33709. * Define the current limit on the right side for an orthographic camera
  33710. * In scene unit
  33711. */
  33712. orthoRight: Nullable<number>;
  33713. /**
  33714. * Define the current limit on the bottom side for an orthographic camera
  33715. * In scene unit
  33716. */
  33717. orthoBottom: Nullable<number>;
  33718. /**
  33719. * Define the current limit on the top side for an orthographic camera
  33720. * In scene unit
  33721. */
  33722. orthoTop: Nullable<number>;
  33723. /**
  33724. * Field Of View is set in Radians. (default is 0.8)
  33725. */
  33726. fov: number;
  33727. /**
  33728. * Define the minimum distance the camera can see from.
  33729. * This is important to note that the depth buffer are not infinite and the closer it starts
  33730. * the more your scene might encounter depth fighting issue.
  33731. */
  33732. minZ: number;
  33733. /**
  33734. * Define the maximum distance the camera can see to.
  33735. * This is important to note that the depth buffer are not infinite and the further it end
  33736. * the more your scene might encounter depth fighting issue.
  33737. */
  33738. maxZ: number;
  33739. /**
  33740. * Define the default inertia of the camera.
  33741. * This helps giving a smooth feeling to the camera movement.
  33742. */
  33743. inertia: number;
  33744. /**
  33745. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  33746. */
  33747. mode: number;
  33748. /**
  33749. * Define whether the camera is intermediate.
  33750. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  33751. */
  33752. isIntermediate: boolean;
  33753. /**
  33754. * Define the viewport of the camera.
  33755. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  33756. */
  33757. viewport: Viewport;
  33758. /**
  33759. * Restricts the camera to viewing objects with the same layerMask.
  33760. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  33761. */
  33762. layerMask: number;
  33763. /**
  33764. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  33765. */
  33766. fovMode: number;
  33767. /**
  33768. * Rig mode of the camera.
  33769. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  33770. * This is normally controlled byt the camera themselves as internal use.
  33771. */
  33772. cameraRigMode: number;
  33773. /**
  33774. * Defines the distance between both "eyes" in case of a RIG
  33775. */
  33776. interaxialDistance: number;
  33777. /**
  33778. * Defines if stereoscopic rendering is done side by side or over under.
  33779. */
  33780. isStereoscopicSideBySide: boolean;
  33781. /**
  33782. * 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
  33783. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  33784. * else in the scene. (Eg. security camera)
  33785. *
  33786. * 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)
  33787. */
  33788. customRenderTargets: RenderTargetTexture[];
  33789. /**
  33790. * When set, the camera will render to this render target instead of the default canvas
  33791. *
  33792. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  33793. */
  33794. outputRenderTarget: Nullable<RenderTargetTexture>;
  33795. /**
  33796. * Observable triggered when the camera view matrix has changed.
  33797. */
  33798. onViewMatrixChangedObservable: Observable<Camera>;
  33799. /**
  33800. * Observable triggered when the camera Projection matrix has changed.
  33801. */
  33802. onProjectionMatrixChangedObservable: Observable<Camera>;
  33803. /**
  33804. * Observable triggered when the inputs have been processed.
  33805. */
  33806. onAfterCheckInputsObservable: Observable<Camera>;
  33807. /**
  33808. * Observable triggered when reset has been called and applied to the camera.
  33809. */
  33810. onRestoreStateObservable: Observable<Camera>;
  33811. /**
  33812. * Is this camera a part of a rig system?
  33813. */
  33814. isRigCamera: boolean;
  33815. /**
  33816. * If isRigCamera set to true this will be set with the parent camera.
  33817. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  33818. */
  33819. rigParent?: Camera;
  33820. /** @hidden */
  33821. _cameraRigParams: any;
  33822. /** @hidden */
  33823. _rigCameras: Camera[];
  33824. /** @hidden */
  33825. _rigPostProcess: Nullable<PostProcess>;
  33826. protected _webvrViewMatrix: Matrix;
  33827. /** @hidden */
  33828. _skipRendering: boolean;
  33829. /** @hidden */
  33830. _projectionMatrix: Matrix;
  33831. /** @hidden */
  33832. _postProcesses: Nullable<PostProcess>[];
  33833. /** @hidden */
  33834. _activeMeshes: SmartArray<AbstractMesh>;
  33835. protected _globalPosition: Vector3;
  33836. /** @hidden */
  33837. _computedViewMatrix: Matrix;
  33838. private _doNotComputeProjectionMatrix;
  33839. private _transformMatrix;
  33840. private _frustumPlanes;
  33841. private _refreshFrustumPlanes;
  33842. private _storedFov;
  33843. private _stateStored;
  33844. /**
  33845. * Instantiates a new camera object.
  33846. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  33847. * @see https://doc.babylonjs.com/features/cameras
  33848. * @param name Defines the name of the camera in the scene
  33849. * @param position Defines the position of the camera
  33850. * @param scene Defines the scene the camera belongs too
  33851. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  33852. */
  33853. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  33854. /**
  33855. * Store current camera state (fov, position, etc..)
  33856. * @returns the camera
  33857. */
  33858. storeState(): Camera;
  33859. /**
  33860. * Restores the camera state values if it has been stored. You must call storeState() first
  33861. */
  33862. protected _restoreStateValues(): boolean;
  33863. /**
  33864. * Restored camera state. You must call storeState() first.
  33865. * @returns true if restored and false otherwise
  33866. */
  33867. restoreState(): boolean;
  33868. /**
  33869. * Gets the class name of the camera.
  33870. * @returns the class name
  33871. */
  33872. getClassName(): string;
  33873. /** @hidden */
  33874. readonly _isCamera: boolean;
  33875. /**
  33876. * Gets a string representation of the camera useful for debug purpose.
  33877. * @param fullDetails Defines that a more verboe level of logging is required
  33878. * @returns the string representation
  33879. */
  33880. toString(fullDetails?: boolean): string;
  33881. /**
  33882. * Gets the current world space position of the camera.
  33883. */
  33884. get globalPosition(): Vector3;
  33885. /**
  33886. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  33887. * @returns the active meshe list
  33888. */
  33889. getActiveMeshes(): SmartArray<AbstractMesh>;
  33890. /**
  33891. * Check whether a mesh is part of the current active mesh list of the camera
  33892. * @param mesh Defines the mesh to check
  33893. * @returns true if active, false otherwise
  33894. */
  33895. isActiveMesh(mesh: Mesh): boolean;
  33896. /**
  33897. * Is this camera ready to be used/rendered
  33898. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  33899. * @return true if the camera is ready
  33900. */
  33901. isReady(completeCheck?: boolean): boolean;
  33902. /** @hidden */
  33903. _initCache(): void;
  33904. /** @hidden */
  33905. _updateCache(ignoreParentClass?: boolean): void;
  33906. /** @hidden */
  33907. _isSynchronized(): boolean;
  33908. /** @hidden */
  33909. _isSynchronizedViewMatrix(): boolean;
  33910. /** @hidden */
  33911. _isSynchronizedProjectionMatrix(): boolean;
  33912. /**
  33913. * Attach the input controls to a specific dom element to get the input from.
  33914. * @param element Defines the element the controls should be listened from
  33915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33916. */
  33917. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33918. /**
  33919. * Detach the current controls from the specified dom element.
  33920. * @param element Defines the element to stop listening the inputs from
  33921. */
  33922. detachControl(element: HTMLElement): void;
  33923. /**
  33924. * Update the camera state according to the different inputs gathered during the frame.
  33925. */
  33926. update(): void;
  33927. /** @hidden */
  33928. _checkInputs(): void;
  33929. /** @hidden */
  33930. get rigCameras(): Camera[];
  33931. /**
  33932. * Gets the post process used by the rig cameras
  33933. */
  33934. get rigPostProcess(): Nullable<PostProcess>;
  33935. /**
  33936. * Internal, gets the first post proces.
  33937. * @returns the first post process to be run on this camera.
  33938. */
  33939. _getFirstPostProcess(): Nullable<PostProcess>;
  33940. private _cascadePostProcessesToRigCams;
  33941. /**
  33942. * Attach a post process to the camera.
  33943. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  33944. * @param postProcess The post process to attach to the camera
  33945. * @param insertAt The position of the post process in case several of them are in use in the scene
  33946. * @returns the position the post process has been inserted at
  33947. */
  33948. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  33949. /**
  33950. * Detach a post process to the camera.
  33951. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  33952. * @param postProcess The post process to detach from the camera
  33953. */
  33954. detachPostProcess(postProcess: PostProcess): void;
  33955. /**
  33956. * Gets the current world matrix of the camera
  33957. */
  33958. getWorldMatrix(): Matrix;
  33959. /** @hidden */
  33960. _getViewMatrix(): Matrix;
  33961. /**
  33962. * Gets the current view matrix of the camera.
  33963. * @param force forces the camera to recompute the matrix without looking at the cached state
  33964. * @returns the view matrix
  33965. */
  33966. getViewMatrix(force?: boolean): Matrix;
  33967. /**
  33968. * Freeze the projection matrix.
  33969. * It will prevent the cache check of the camera projection compute and can speed up perf
  33970. * if no parameter of the camera are meant to change
  33971. * @param projection Defines manually a projection if necessary
  33972. */
  33973. freezeProjectionMatrix(projection?: Matrix): void;
  33974. /**
  33975. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  33976. */
  33977. unfreezeProjectionMatrix(): void;
  33978. /**
  33979. * Gets the current projection matrix of the camera.
  33980. * @param force forces the camera to recompute the matrix without looking at the cached state
  33981. * @returns the projection matrix
  33982. */
  33983. getProjectionMatrix(force?: boolean): Matrix;
  33984. /**
  33985. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  33986. * @returns a Matrix
  33987. */
  33988. getTransformationMatrix(): Matrix;
  33989. private _updateFrustumPlanes;
  33990. /**
  33991. * Checks if a cullable object (mesh...) is in the camera frustum
  33992. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  33993. * @param target The object to check
  33994. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  33995. * @returns true if the object is in frustum otherwise false
  33996. */
  33997. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  33998. /**
  33999. * Checks if a cullable object (mesh...) is in the camera frustum
  34000. * Unlike isInFrustum this cheks the full bounding box
  34001. * @param target The object to check
  34002. * @returns true if the object is in frustum otherwise false
  34003. */
  34004. isCompletelyInFrustum(target: ICullable): boolean;
  34005. /**
  34006. * Gets a ray in the forward direction from the camera.
  34007. * @param length Defines the length of the ray to create
  34008. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34009. * @param origin Defines the start point of the ray which defaults to the camera position
  34010. * @returns the forward ray
  34011. */
  34012. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34013. /**
  34014. * Gets a ray in the forward direction from the camera.
  34015. * @param refRay the ray to (re)use when setting the values
  34016. * @param length Defines the length of the ray to create
  34017. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34018. * @param origin Defines the start point of the ray which defaults to the camera position
  34019. * @returns the forward ray
  34020. */
  34021. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34022. /**
  34023. * Releases resources associated with this node.
  34024. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34025. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34026. */
  34027. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34028. /** @hidden */
  34029. _isLeftCamera: boolean;
  34030. /**
  34031. * Gets the left camera of a rig setup in case of Rigged Camera
  34032. */
  34033. get isLeftCamera(): boolean;
  34034. /** @hidden */
  34035. _isRightCamera: boolean;
  34036. /**
  34037. * Gets the right camera of a rig setup in case of Rigged Camera
  34038. */
  34039. get isRightCamera(): boolean;
  34040. /**
  34041. * Gets the left camera of a rig setup in case of Rigged Camera
  34042. */
  34043. get leftCamera(): Nullable<FreeCamera>;
  34044. /**
  34045. * Gets the right camera of a rig setup in case of Rigged Camera
  34046. */
  34047. get rightCamera(): Nullable<FreeCamera>;
  34048. /**
  34049. * Gets the left camera target of a rig setup in case of Rigged Camera
  34050. * @returns the target position
  34051. */
  34052. getLeftTarget(): Nullable<Vector3>;
  34053. /**
  34054. * Gets the right camera target of a rig setup in case of Rigged Camera
  34055. * @returns the target position
  34056. */
  34057. getRightTarget(): Nullable<Vector3>;
  34058. /**
  34059. * @hidden
  34060. */
  34061. setCameraRigMode(mode: number, rigParams: any): void;
  34062. /** @hidden */
  34063. static _setStereoscopicRigMode(camera: Camera): void;
  34064. /** @hidden */
  34065. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  34066. /** @hidden */
  34067. static _setVRRigMode(camera: Camera, rigParams: any): void;
  34068. /** @hidden */
  34069. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  34070. /** @hidden */
  34071. _getVRProjectionMatrix(): Matrix;
  34072. protected _updateCameraRotationMatrix(): void;
  34073. protected _updateWebVRCameraRotationMatrix(): void;
  34074. /**
  34075. * This function MUST be overwritten by the different WebVR cameras available.
  34076. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34077. * @hidden
  34078. */
  34079. _getWebVRProjectionMatrix(): Matrix;
  34080. /**
  34081. * This function MUST be overwritten by the different WebVR cameras available.
  34082. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34083. * @hidden
  34084. */
  34085. _getWebVRViewMatrix(): Matrix;
  34086. /** @hidden */
  34087. setCameraRigParameter(name: string, value: any): void;
  34088. /**
  34089. * needs to be overridden by children so sub has required properties to be copied
  34090. * @hidden
  34091. */
  34092. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  34093. /**
  34094. * May need to be overridden by children
  34095. * @hidden
  34096. */
  34097. _updateRigCameras(): void;
  34098. /** @hidden */
  34099. _setupInputs(): void;
  34100. /**
  34101. * Serialiaze the camera setup to a json represention
  34102. * @returns the JSON representation
  34103. */
  34104. serialize(): any;
  34105. /**
  34106. * Clones the current camera.
  34107. * @param name The cloned camera name
  34108. * @returns the cloned camera
  34109. */
  34110. clone(name: string): Camera;
  34111. /**
  34112. * Gets the direction of the camera relative to a given local axis.
  34113. * @param localAxis Defines the reference axis to provide a relative direction.
  34114. * @return the direction
  34115. */
  34116. getDirection(localAxis: Vector3): Vector3;
  34117. /**
  34118. * Returns the current camera absolute rotation
  34119. */
  34120. get absoluteRotation(): Quaternion;
  34121. /**
  34122. * Gets the direction of the camera relative to a given local axis into a passed vector.
  34123. * @param localAxis Defines the reference axis to provide a relative direction.
  34124. * @param result Defines the vector to store the result in
  34125. */
  34126. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  34127. /**
  34128. * Gets a camera constructor for a given camera type
  34129. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  34130. * @param name The name of the camera the result will be able to instantiate
  34131. * @param scene The scene the result will construct the camera in
  34132. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  34133. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  34134. * @returns a factory method to construc the camera
  34135. */
  34136. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  34137. /**
  34138. * Compute the world matrix of the camera.
  34139. * @returns the camera world matrix
  34140. */
  34141. computeWorldMatrix(): Matrix;
  34142. /**
  34143. * Parse a JSON and creates the camera from the parsed information
  34144. * @param parsedCamera The JSON to parse
  34145. * @param scene The scene to instantiate the camera in
  34146. * @returns the newly constructed camera
  34147. */
  34148. static Parse(parsedCamera: any, scene: Scene): Camera;
  34149. }
  34150. }
  34151. declare module BABYLON {
  34152. /**
  34153. * Class containing static functions to help procedurally build meshes
  34154. */
  34155. export class DiscBuilder {
  34156. /**
  34157. * Creates a plane polygonal mesh. By default, this is a disc
  34158. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34159. * * 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
  34160. * * 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
  34161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34162. * * 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
  34163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34164. * @param name defines the name of the mesh
  34165. * @param options defines the options used to create the mesh
  34166. * @param scene defines the hosting scene
  34167. * @returns the plane polygonal mesh
  34168. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34169. */
  34170. static CreateDisc(name: string, options: {
  34171. radius?: number;
  34172. tessellation?: number;
  34173. arc?: number;
  34174. updatable?: boolean;
  34175. sideOrientation?: number;
  34176. frontUVs?: Vector4;
  34177. backUVs?: Vector4;
  34178. }, scene?: Nullable<Scene>): Mesh;
  34179. }
  34180. }
  34181. declare module BABYLON {
  34182. /**
  34183. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34184. *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.
  34185. * The SPS is also a particle system. It provides some methods to manage the particles.
  34186. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34187. *
  34188. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34189. */
  34190. export class SolidParticleSystem implements IDisposable {
  34191. /**
  34192. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34193. * Example : var p = SPS.particles[i];
  34194. */
  34195. particles: SolidParticle[];
  34196. /**
  34197. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34198. */
  34199. nbParticles: number;
  34200. /**
  34201. * If the particles must ever face the camera (default false). Useful for planar particles.
  34202. */
  34203. billboard: boolean;
  34204. /**
  34205. * Recompute normals when adding a shape
  34206. */
  34207. recomputeNormals: boolean;
  34208. /**
  34209. * This a counter ofr your own usage. It's not set by any SPS functions.
  34210. */
  34211. counter: number;
  34212. /**
  34213. * The SPS name. This name is also given to the underlying mesh.
  34214. */
  34215. name: string;
  34216. /**
  34217. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34218. */
  34219. mesh: Mesh;
  34220. /**
  34221. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34222. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34223. */
  34224. vars: any;
  34225. /**
  34226. * This array is populated when the SPS is set as 'pickable'.
  34227. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34228. * Each element of this array is an object `{idx: int, faceId: int}`.
  34229. * `idx` is the picked particle index in the `SPS.particles` array
  34230. * `faceId` is the picked face index counted within this particle.
  34231. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34232. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34233. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34234. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34235. */
  34236. pickedParticles: {
  34237. idx: number;
  34238. faceId: number;
  34239. }[];
  34240. /**
  34241. * This array is populated when the SPS is set as 'pickable'
  34242. * Each key of this array is a submesh index.
  34243. * Each element of this array is a second array defined like this :
  34244. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34245. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34246. * `idx` is the picked particle index in the `SPS.particles` array
  34247. * `faceId` is the picked face index counted within this particle.
  34248. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34249. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34250. */
  34251. pickedBySubMesh: {
  34252. idx: number;
  34253. faceId: number;
  34254. }[][];
  34255. /**
  34256. * This array is populated when `enableDepthSort` is set to true.
  34257. * Each element of this array is an instance of the class DepthSortedParticle.
  34258. */
  34259. depthSortedParticles: DepthSortedParticle[];
  34260. /**
  34261. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34262. * @hidden
  34263. */
  34264. _bSphereOnly: boolean;
  34265. /**
  34266. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34267. * @hidden
  34268. */
  34269. _bSphereRadiusFactor: number;
  34270. private _scene;
  34271. private _positions;
  34272. private _indices;
  34273. private _normals;
  34274. private _colors;
  34275. private _uvs;
  34276. private _indices32;
  34277. private _positions32;
  34278. private _normals32;
  34279. private _fixedNormal32;
  34280. private _colors32;
  34281. private _uvs32;
  34282. private _index;
  34283. private _updatable;
  34284. private _pickable;
  34285. private _isVisibilityBoxLocked;
  34286. private _alwaysVisible;
  34287. private _depthSort;
  34288. private _expandable;
  34289. private _shapeCounter;
  34290. private _copy;
  34291. private _color;
  34292. private _computeParticleColor;
  34293. private _computeParticleTexture;
  34294. private _computeParticleRotation;
  34295. private _computeParticleVertex;
  34296. private _computeBoundingBox;
  34297. private _depthSortParticles;
  34298. private _camera;
  34299. private _mustUnrotateFixedNormals;
  34300. private _particlesIntersect;
  34301. private _needs32Bits;
  34302. private _isNotBuilt;
  34303. private _lastParticleId;
  34304. private _idxOfId;
  34305. private _multimaterialEnabled;
  34306. private _useModelMaterial;
  34307. private _indicesByMaterial;
  34308. private _materialIndexes;
  34309. private _depthSortFunction;
  34310. private _materialSortFunction;
  34311. private _materials;
  34312. private _multimaterial;
  34313. private _materialIndexesById;
  34314. private _defaultMaterial;
  34315. private _autoUpdateSubMeshes;
  34316. private _tmpVertex;
  34317. /**
  34318. * Creates a SPS (Solid Particle System) object.
  34319. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34320. * @param scene (Scene) is the scene in which the SPS is added.
  34321. * @param options defines the options of the sps e.g.
  34322. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34323. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34324. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34325. * * 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.
  34326. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34327. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34328. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34329. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34330. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34331. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34332. */
  34333. constructor(name: string, scene: Scene, options?: {
  34334. updatable?: boolean;
  34335. isPickable?: boolean;
  34336. enableDepthSort?: boolean;
  34337. particleIntersection?: boolean;
  34338. boundingSphereOnly?: boolean;
  34339. bSphereRadiusFactor?: number;
  34340. expandable?: boolean;
  34341. useModelMaterial?: boolean;
  34342. enableMultiMaterial?: boolean;
  34343. });
  34344. /**
  34345. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34346. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34347. * @returns the created mesh
  34348. */
  34349. buildMesh(): Mesh;
  34350. /**
  34351. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34352. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34353. * Thus the particles generated from `digest()` have their property `position` set yet.
  34354. * @param mesh ( Mesh ) is the mesh to be digested
  34355. * @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
  34356. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34357. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34358. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34359. * @returns the current SPS
  34360. */
  34361. digest(mesh: Mesh, options?: {
  34362. facetNb?: number;
  34363. number?: number;
  34364. delta?: number;
  34365. storage?: [];
  34366. }): SolidParticleSystem;
  34367. /**
  34368. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34369. * @hidden
  34370. */
  34371. private _unrotateFixedNormals;
  34372. /**
  34373. * Resets the temporary working copy particle
  34374. * @hidden
  34375. */
  34376. private _resetCopy;
  34377. /**
  34378. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34379. * @param p the current index in the positions array to be updated
  34380. * @param ind the current index in the indices array
  34381. * @param shape a Vector3 array, the shape geometry
  34382. * @param positions the positions array to be updated
  34383. * @param meshInd the shape indices array
  34384. * @param indices the indices array to be updated
  34385. * @param meshUV the shape uv array
  34386. * @param uvs the uv array to be updated
  34387. * @param meshCol the shape color array
  34388. * @param colors the color array to be updated
  34389. * @param meshNor the shape normals array
  34390. * @param normals the normals array to be updated
  34391. * @param idx the particle index
  34392. * @param idxInShape the particle index in its shape
  34393. * @param options the addShape() method passed options
  34394. * @model the particle model
  34395. * @hidden
  34396. */
  34397. private _meshBuilder;
  34398. /**
  34399. * Returns a shape Vector3 array from positions float array
  34400. * @param positions float array
  34401. * @returns a vector3 array
  34402. * @hidden
  34403. */
  34404. private _posToShape;
  34405. /**
  34406. * Returns a shapeUV array from a float uvs (array deep copy)
  34407. * @param uvs as a float array
  34408. * @returns a shapeUV array
  34409. * @hidden
  34410. */
  34411. private _uvsToShapeUV;
  34412. /**
  34413. * Adds a new particle object in the particles array
  34414. * @param idx particle index in particles array
  34415. * @param id particle id
  34416. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34417. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34418. * @param model particle ModelShape object
  34419. * @param shapeId model shape identifier
  34420. * @param idxInShape index of the particle in the current model
  34421. * @param bInfo model bounding info object
  34422. * @param storage target storage array, if any
  34423. * @hidden
  34424. */
  34425. private _addParticle;
  34426. /**
  34427. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34428. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34429. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34430. * @param nb (positive integer) the number of particles to be created from this model
  34431. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34432. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34433. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34434. * @returns the number of shapes in the system
  34435. */
  34436. addShape(mesh: Mesh, nb: number, options?: {
  34437. positionFunction?: any;
  34438. vertexFunction?: any;
  34439. storage?: [];
  34440. }): number;
  34441. /**
  34442. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34443. * @hidden
  34444. */
  34445. private _rebuildParticle;
  34446. /**
  34447. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34448. * @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.
  34449. * @returns the SPS.
  34450. */
  34451. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34452. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34453. * Returns an array with the removed particles.
  34454. * 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.
  34455. * The SPS can't be empty so at least one particle needs to remain in place.
  34456. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34457. * @param start index of the first particle to remove
  34458. * @param end index of the last particle to remove (included)
  34459. * @returns an array populated with the removed particles
  34460. */
  34461. removeParticles(start: number, end: number): SolidParticle[];
  34462. /**
  34463. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34464. * @param solidParticleArray an array populated with Solid Particles objects
  34465. * @returns the SPS
  34466. */
  34467. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34468. /**
  34469. * Creates a new particle and modifies the SPS mesh geometry :
  34470. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34471. * - calls _addParticle() to populate the particle array
  34472. * factorized code from addShape() and insertParticlesFromArray()
  34473. * @param idx particle index in the particles array
  34474. * @param i particle index in its shape
  34475. * @param modelShape particle ModelShape object
  34476. * @param shape shape vertex array
  34477. * @param meshInd shape indices array
  34478. * @param meshUV shape uv array
  34479. * @param meshCol shape color array
  34480. * @param meshNor shape normals array
  34481. * @param bbInfo shape bounding info
  34482. * @param storage target particle storage
  34483. * @options addShape() passed options
  34484. * @hidden
  34485. */
  34486. private _insertNewParticle;
  34487. /**
  34488. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34489. * This method calls `updateParticle()` for each particle of the SPS.
  34490. * For an animated SPS, it is usually called within the render loop.
  34491. * 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.
  34492. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34493. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34494. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34495. * @returns the SPS.
  34496. */
  34497. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34498. /**
  34499. * Disposes the SPS.
  34500. */
  34501. dispose(): void;
  34502. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34503. * idx is the particle index in the SPS
  34504. * faceId is the picked face index counted within this particle.
  34505. * Returns null if the pickInfo can't identify a picked particle.
  34506. * @param pickingInfo (PickingInfo object)
  34507. * @returns {idx: number, faceId: number} or null
  34508. */
  34509. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34510. idx: number;
  34511. faceId: number;
  34512. }>;
  34513. /**
  34514. * Returns a SolidParticle object from its identifier : particle.id
  34515. * @param id (integer) the particle Id
  34516. * @returns the searched particle or null if not found in the SPS.
  34517. */
  34518. getParticleById(id: number): Nullable<SolidParticle>;
  34519. /**
  34520. * Returns a new array populated with the particles having the passed shapeId.
  34521. * @param shapeId (integer) the shape identifier
  34522. * @returns a new solid particle array
  34523. */
  34524. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34525. /**
  34526. * Populates the passed array "ref" with the particles having the passed shapeId.
  34527. * @param shapeId the shape identifier
  34528. * @returns the SPS
  34529. * @param ref
  34530. */
  34531. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34532. /**
  34533. * Computes the required SubMeshes according the materials assigned to the particles.
  34534. * @returns the solid particle system.
  34535. * Does nothing if called before the SPS mesh is built.
  34536. */
  34537. computeSubMeshes(): SolidParticleSystem;
  34538. /**
  34539. * Sorts the solid particles by material when MultiMaterial is enabled.
  34540. * Updates the indices32 array.
  34541. * Updates the indicesByMaterial array.
  34542. * Updates the mesh indices array.
  34543. * @returns the SPS
  34544. * @hidden
  34545. */
  34546. private _sortParticlesByMaterial;
  34547. /**
  34548. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34549. * @hidden
  34550. */
  34551. private _setMaterialIndexesById;
  34552. /**
  34553. * Returns an array with unique values of Materials from the passed array
  34554. * @param array the material array to be checked and filtered
  34555. * @hidden
  34556. */
  34557. private _filterUniqueMaterialId;
  34558. /**
  34559. * Sets a new Standard Material as _defaultMaterial if not already set.
  34560. * @hidden
  34561. */
  34562. private _setDefaultMaterial;
  34563. /**
  34564. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34565. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34566. * @returns the SPS.
  34567. */
  34568. refreshVisibleSize(): SolidParticleSystem;
  34569. /**
  34570. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34571. * @param size the size (float) of the visibility box
  34572. * note : this doesn't lock the SPS mesh bounding box.
  34573. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34574. */
  34575. setVisibilityBox(size: number): void;
  34576. /**
  34577. * Gets whether the SPS as always visible or not
  34578. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34579. */
  34580. get isAlwaysVisible(): boolean;
  34581. /**
  34582. * Sets the SPS as always visible or not
  34583. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34584. */
  34585. set isAlwaysVisible(val: boolean);
  34586. /**
  34587. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34588. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34589. */
  34590. set isVisibilityBoxLocked(val: boolean);
  34591. /**
  34592. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34593. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34594. */
  34595. get isVisibilityBoxLocked(): boolean;
  34596. /**
  34597. * Tells to `setParticles()` to compute the particle rotations or not.
  34598. * Default value : true. The SPS is faster when it's set to false.
  34599. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34600. */
  34601. set computeParticleRotation(val: boolean);
  34602. /**
  34603. * Tells to `setParticles()` to compute the particle colors or not.
  34604. * Default value : true. The SPS is faster when it's set to false.
  34605. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34606. */
  34607. set computeParticleColor(val: boolean);
  34608. set computeParticleTexture(val: boolean);
  34609. /**
  34610. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34611. * Default value : false. The SPS is faster when it's set to false.
  34612. * Note : the particle custom vertex positions aren't stored values.
  34613. */
  34614. set computeParticleVertex(val: boolean);
  34615. /**
  34616. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34617. */
  34618. set computeBoundingBox(val: boolean);
  34619. /**
  34620. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34621. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34622. * Default : `true`
  34623. */
  34624. set depthSortParticles(val: boolean);
  34625. /**
  34626. * Gets if `setParticles()` computes the particle rotations or not.
  34627. * Default value : true. The SPS is faster when it's set to false.
  34628. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34629. */
  34630. get computeParticleRotation(): boolean;
  34631. /**
  34632. * Gets if `setParticles()` computes the particle colors or not.
  34633. * Default value : true. The SPS is faster when it's set to false.
  34634. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34635. */
  34636. get computeParticleColor(): boolean;
  34637. /**
  34638. * Gets if `setParticles()` computes the particle textures or not.
  34639. * Default value : true. The SPS is faster when it's set to false.
  34640. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34641. */
  34642. get computeParticleTexture(): boolean;
  34643. /**
  34644. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34645. * Default value : false. The SPS is faster when it's set to false.
  34646. * Note : the particle custom vertex positions aren't stored values.
  34647. */
  34648. get computeParticleVertex(): boolean;
  34649. /**
  34650. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34651. */
  34652. get computeBoundingBox(): boolean;
  34653. /**
  34654. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34655. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34656. * Default : `true`
  34657. */
  34658. get depthSortParticles(): boolean;
  34659. /**
  34660. * Gets if the SPS is created as expandable at construction time.
  34661. * Default : `false`
  34662. */
  34663. get expandable(): boolean;
  34664. /**
  34665. * Gets if the SPS supports the Multi Materials
  34666. */
  34667. get multimaterialEnabled(): boolean;
  34668. /**
  34669. * Gets if the SPS uses the model materials for its own multimaterial.
  34670. */
  34671. get useModelMaterial(): boolean;
  34672. /**
  34673. * The SPS used material array.
  34674. */
  34675. get materials(): Material[];
  34676. /**
  34677. * Sets the SPS MultiMaterial from the passed materials.
  34678. * Note : the passed array is internally copied and not used then by reference.
  34679. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34680. */
  34681. setMultiMaterial(materials: Material[]): void;
  34682. /**
  34683. * The SPS computed multimaterial object
  34684. */
  34685. get multimaterial(): MultiMaterial;
  34686. set multimaterial(mm: MultiMaterial);
  34687. /**
  34688. * If the subMeshes must be updated on the next call to setParticles()
  34689. */
  34690. get autoUpdateSubMeshes(): boolean;
  34691. set autoUpdateSubMeshes(val: boolean);
  34692. /**
  34693. * This function does nothing. It may be overwritten to set all the particle first values.
  34694. * The SPS doesn't call this function, you may have to call it by your own.
  34695. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34696. */
  34697. initParticles(): void;
  34698. /**
  34699. * This function does nothing. It may be overwritten to recycle a particle.
  34700. * The SPS doesn't call this function, you may have to call it by your own.
  34701. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34702. * @param particle The particle to recycle
  34703. * @returns the recycled particle
  34704. */
  34705. recycleParticle(particle: SolidParticle): SolidParticle;
  34706. /**
  34707. * Updates a particle : this function should be overwritten by the user.
  34708. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34709. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34710. * @example : just set a particle position or velocity and recycle conditions
  34711. * @param particle The particle to update
  34712. * @returns the updated particle
  34713. */
  34714. updateParticle(particle: SolidParticle): SolidParticle;
  34715. /**
  34716. * Updates a vertex of a particle : it can be overwritten by the user.
  34717. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34718. * @param particle the current particle
  34719. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34720. * @param pt the index of the current vertex in the particle shape
  34721. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34722. * @example : just set a vertex particle position or color
  34723. * @returns the sps
  34724. */
  34725. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34726. /**
  34727. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34728. * This does nothing and may be overwritten by the user.
  34729. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34730. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34731. * @param update the boolean update value actually passed to setParticles()
  34732. */
  34733. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34734. /**
  34735. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34736. * This will be passed three parameters.
  34737. * This does nothing and may be overwritten by the user.
  34738. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34739. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34740. * @param update the boolean update value actually passed to setParticles()
  34741. */
  34742. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34743. }
  34744. }
  34745. declare module BABYLON {
  34746. /**
  34747. * Represents one particle of a solid particle system.
  34748. */
  34749. export class SolidParticle {
  34750. /**
  34751. * particle global index
  34752. */
  34753. idx: number;
  34754. /**
  34755. * particle identifier
  34756. */
  34757. id: number;
  34758. /**
  34759. * The color of the particle
  34760. */
  34761. color: Nullable<Color4>;
  34762. /**
  34763. * The world space position of the particle.
  34764. */
  34765. position: Vector3;
  34766. /**
  34767. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34768. */
  34769. rotation: Vector3;
  34770. /**
  34771. * The world space rotation quaternion of the particle.
  34772. */
  34773. rotationQuaternion: Nullable<Quaternion>;
  34774. /**
  34775. * The scaling of the particle.
  34776. */
  34777. scaling: Vector3;
  34778. /**
  34779. * The uvs of the particle.
  34780. */
  34781. uvs: Vector4;
  34782. /**
  34783. * The current speed of the particle.
  34784. */
  34785. velocity: Vector3;
  34786. /**
  34787. * The pivot point in the particle local space.
  34788. */
  34789. pivot: Vector3;
  34790. /**
  34791. * Must the particle be translated from its pivot point in its local space ?
  34792. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34793. * Default : false
  34794. */
  34795. translateFromPivot: boolean;
  34796. /**
  34797. * Is the particle active or not ?
  34798. */
  34799. alive: boolean;
  34800. /**
  34801. * Is the particle visible or not ?
  34802. */
  34803. isVisible: boolean;
  34804. /**
  34805. * Index of this particle in the global "positions" array (Internal use)
  34806. * @hidden
  34807. */
  34808. _pos: number;
  34809. /**
  34810. * @hidden Index of this particle in the global "indices" array (Internal use)
  34811. */
  34812. _ind: number;
  34813. /**
  34814. * @hidden ModelShape of this particle (Internal use)
  34815. */
  34816. _model: ModelShape;
  34817. /**
  34818. * ModelShape id of this particle
  34819. */
  34820. shapeId: number;
  34821. /**
  34822. * Index of the particle in its shape id
  34823. */
  34824. idxInShape: number;
  34825. /**
  34826. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34827. */
  34828. _modelBoundingInfo: BoundingInfo;
  34829. /**
  34830. * @hidden Particle BoundingInfo object (Internal use)
  34831. */
  34832. _boundingInfo: BoundingInfo;
  34833. /**
  34834. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34835. */
  34836. _sps: SolidParticleSystem;
  34837. /**
  34838. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34839. */
  34840. _stillInvisible: boolean;
  34841. /**
  34842. * @hidden Last computed particle rotation matrix
  34843. */
  34844. _rotationMatrix: number[];
  34845. /**
  34846. * Parent particle Id, if any.
  34847. * Default null.
  34848. */
  34849. parentId: Nullable<number>;
  34850. /**
  34851. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34852. */
  34853. materialIndex: Nullable<number>;
  34854. /**
  34855. * Custom object or properties.
  34856. */
  34857. props: Nullable<any>;
  34858. /**
  34859. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34860. * The possible values are :
  34861. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34862. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34863. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34864. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34865. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34866. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34867. * */
  34868. cullingStrategy: number;
  34869. /**
  34870. * @hidden Internal global position in the SPS.
  34871. */
  34872. _globalPosition: Vector3;
  34873. /**
  34874. * Creates a Solid Particle object.
  34875. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34876. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34877. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34878. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34879. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34880. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34881. * @param shapeId (integer) is the model shape identifier in the SPS.
  34882. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34883. * @param sps defines the sps it is associated to
  34884. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34885. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34886. */
  34887. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34888. /**
  34889. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34890. * @param target the particle target
  34891. * @returns the current particle
  34892. */
  34893. copyToRef(target: SolidParticle): SolidParticle;
  34894. /**
  34895. * Legacy support, changed scale to scaling
  34896. */
  34897. get scale(): Vector3;
  34898. /**
  34899. * Legacy support, changed scale to scaling
  34900. */
  34901. set scale(scale: Vector3);
  34902. /**
  34903. * Legacy support, changed quaternion to rotationQuaternion
  34904. */
  34905. get quaternion(): Nullable<Quaternion>;
  34906. /**
  34907. * Legacy support, changed quaternion to rotationQuaternion
  34908. */
  34909. set quaternion(q: Nullable<Quaternion>);
  34910. /**
  34911. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34912. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34913. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34914. * @returns true if it intersects
  34915. */
  34916. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34917. /**
  34918. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34919. * A particle is in the frustum if its bounding box intersects the frustum
  34920. * @param frustumPlanes defines the frustum to test
  34921. * @returns true if the particle is in the frustum planes
  34922. */
  34923. isInFrustum(frustumPlanes: Plane[]): boolean;
  34924. /**
  34925. * get the rotation matrix of the particle
  34926. * @hidden
  34927. */
  34928. getRotationMatrix(m: Matrix): void;
  34929. }
  34930. /**
  34931. * Represents the shape of the model used by one particle of a solid particle system.
  34932. * SPS internal tool, don't use it manually.
  34933. */
  34934. export class ModelShape {
  34935. /**
  34936. * The shape id
  34937. * @hidden
  34938. */
  34939. shapeID: number;
  34940. /**
  34941. * flat array of model positions (internal use)
  34942. * @hidden
  34943. */
  34944. _shape: Vector3[];
  34945. /**
  34946. * flat array of model UVs (internal use)
  34947. * @hidden
  34948. */
  34949. _shapeUV: number[];
  34950. /**
  34951. * color array of the model
  34952. * @hidden
  34953. */
  34954. _shapeColors: number[];
  34955. /**
  34956. * indices array of the model
  34957. * @hidden
  34958. */
  34959. _indices: number[];
  34960. /**
  34961. * normals array of the model
  34962. * @hidden
  34963. */
  34964. _normals: number[];
  34965. /**
  34966. * length of the shape in the model indices array (internal use)
  34967. * @hidden
  34968. */
  34969. _indicesLength: number;
  34970. /**
  34971. * Custom position function (internal use)
  34972. * @hidden
  34973. */
  34974. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34975. /**
  34976. * Custom vertex function (internal use)
  34977. * @hidden
  34978. */
  34979. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  34980. /**
  34981. * Model material (internal use)
  34982. * @hidden
  34983. */
  34984. _material: Nullable<Material>;
  34985. /**
  34986. * 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.
  34987. * SPS internal tool, don't use it manually.
  34988. * @hidden
  34989. */
  34990. 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>);
  34991. }
  34992. /**
  34993. * Represents a Depth Sorted Particle in the solid particle system.
  34994. * @hidden
  34995. */
  34996. export class DepthSortedParticle {
  34997. /**
  34998. * Particle index
  34999. */
  35000. idx: number;
  35001. /**
  35002. * Index of the particle in the "indices" array
  35003. */
  35004. ind: number;
  35005. /**
  35006. * Length of the particle shape in the "indices" array
  35007. */
  35008. indicesLength: number;
  35009. /**
  35010. * Squared distance from the particle to the camera
  35011. */
  35012. sqDistance: number;
  35013. /**
  35014. * Material index when used with MultiMaterials
  35015. */
  35016. materialIndex: number;
  35017. /**
  35018. * Creates a new sorted particle
  35019. * @param materialIndex
  35020. */
  35021. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35022. }
  35023. /**
  35024. * Represents a solid particle vertex
  35025. */
  35026. export class SolidParticleVertex {
  35027. /**
  35028. * Vertex position
  35029. */
  35030. position: Vector3;
  35031. /**
  35032. * Vertex color
  35033. */
  35034. color: Color4;
  35035. /**
  35036. * Vertex UV
  35037. */
  35038. uv: Vector2;
  35039. /**
  35040. * Creates a new solid particle vertex
  35041. */
  35042. constructor();
  35043. /** Vertex x coordinate */
  35044. get x(): number;
  35045. set x(val: number);
  35046. /** Vertex y coordinate */
  35047. get y(): number;
  35048. set y(val: number);
  35049. /** Vertex z coordinate */
  35050. get z(): number;
  35051. set z(val: number);
  35052. }
  35053. }
  35054. declare module BABYLON {
  35055. /**
  35056. * @hidden
  35057. */
  35058. export class _MeshCollisionData {
  35059. _checkCollisions: boolean;
  35060. _collisionMask: number;
  35061. _collisionGroup: number;
  35062. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35063. _collider: Nullable<Collider>;
  35064. _oldPositionForCollisions: Vector3;
  35065. _diffPositionForCollisions: Vector3;
  35066. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35067. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35068. _collisionResponse: boolean;
  35069. }
  35070. }
  35071. declare module BABYLON {
  35072. /** @hidden */
  35073. class _FacetDataStorage {
  35074. facetPositions: Vector3[];
  35075. facetNormals: Vector3[];
  35076. facetPartitioning: number[][];
  35077. facetNb: number;
  35078. partitioningSubdivisions: number;
  35079. partitioningBBoxRatio: number;
  35080. facetDataEnabled: boolean;
  35081. facetParameters: any;
  35082. bbSize: Vector3;
  35083. subDiv: {
  35084. max: number;
  35085. X: number;
  35086. Y: number;
  35087. Z: number;
  35088. };
  35089. facetDepthSort: boolean;
  35090. facetDepthSortEnabled: boolean;
  35091. depthSortedIndices: IndicesArray;
  35092. depthSortedFacets: {
  35093. ind: number;
  35094. sqDistance: number;
  35095. }[];
  35096. facetDepthSortFunction: (f1: {
  35097. ind: number;
  35098. sqDistance: number;
  35099. }, f2: {
  35100. ind: number;
  35101. sqDistance: number;
  35102. }) => number;
  35103. facetDepthSortFrom: Vector3;
  35104. facetDepthSortOrigin: Vector3;
  35105. invertedMatrix: Matrix;
  35106. }
  35107. /**
  35108. * @hidden
  35109. **/
  35110. class _InternalAbstractMeshDataInfo {
  35111. _hasVertexAlpha: boolean;
  35112. _useVertexColors: boolean;
  35113. _numBoneInfluencers: number;
  35114. _applyFog: boolean;
  35115. _receiveShadows: boolean;
  35116. _facetData: _FacetDataStorage;
  35117. _visibility: number;
  35118. _skeleton: Nullable<Skeleton>;
  35119. _layerMask: number;
  35120. _computeBonesUsingShaders: boolean;
  35121. _isActive: boolean;
  35122. _onlyForInstances: boolean;
  35123. _isActiveIntermediate: boolean;
  35124. _onlyForInstancesIntermediate: boolean;
  35125. _actAsRegularMesh: boolean;
  35126. }
  35127. /**
  35128. * Class used to store all common mesh properties
  35129. */
  35130. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35131. /** No occlusion */
  35132. static OCCLUSION_TYPE_NONE: number;
  35133. /** Occlusion set to optimisitic */
  35134. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35135. /** Occlusion set to strict */
  35136. static OCCLUSION_TYPE_STRICT: number;
  35137. /** Use an accurante occlusion algorithm */
  35138. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35139. /** Use a conservative occlusion algorithm */
  35140. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35141. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35142. * Test order :
  35143. * Is the bounding sphere outside the frustum ?
  35144. * If not, are the bounding box vertices outside the frustum ?
  35145. * It not, then the cullable object is in the frustum.
  35146. */
  35147. static readonly CULLINGSTRATEGY_STANDARD: number;
  35148. /** Culling strategy : Bounding Sphere Only.
  35149. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35150. * It's also less accurate than the standard because some not visible objects can still be selected.
  35151. * Test : is the bounding sphere outside the frustum ?
  35152. * If not, then the cullable object is in the frustum.
  35153. */
  35154. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35155. /** Culling strategy : Optimistic Inclusion.
  35156. * This in an inclusion test first, then the standard exclusion test.
  35157. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35158. * 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.
  35159. * Anyway, it's as accurate as the standard strategy.
  35160. * Test :
  35161. * Is the cullable object bounding sphere center in the frustum ?
  35162. * If not, apply the default culling strategy.
  35163. */
  35164. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35165. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35166. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35167. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35168. * 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.
  35169. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35170. * Test :
  35171. * Is the cullable object bounding sphere center in the frustum ?
  35172. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35173. */
  35174. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35175. /**
  35176. * No billboard
  35177. */
  35178. static get BILLBOARDMODE_NONE(): number;
  35179. /** Billboard on X axis */
  35180. static get BILLBOARDMODE_X(): number;
  35181. /** Billboard on Y axis */
  35182. static get BILLBOARDMODE_Y(): number;
  35183. /** Billboard on Z axis */
  35184. static get BILLBOARDMODE_Z(): number;
  35185. /** Billboard on all axes */
  35186. static get BILLBOARDMODE_ALL(): number;
  35187. /** Billboard on using position instead of orientation */
  35188. static get BILLBOARDMODE_USE_POSITION(): number;
  35189. /** @hidden */
  35190. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35191. /**
  35192. * The culling strategy to use to check whether the mesh must be rendered or not.
  35193. * This value can be changed at any time and will be used on the next render mesh selection.
  35194. * The possible values are :
  35195. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35196. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35197. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35198. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35199. * Please read each static variable documentation to get details about the culling process.
  35200. * */
  35201. cullingStrategy: number;
  35202. /**
  35203. * Gets the number of facets in the mesh
  35204. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35205. */
  35206. get facetNb(): number;
  35207. /**
  35208. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35209. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35210. */
  35211. get partitioningSubdivisions(): number;
  35212. set partitioningSubdivisions(nb: number);
  35213. /**
  35214. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35215. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35216. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35217. */
  35218. get partitioningBBoxRatio(): number;
  35219. set partitioningBBoxRatio(ratio: number);
  35220. /**
  35221. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35222. * Works only for updatable meshes.
  35223. * Doesn't work with multi-materials
  35224. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35225. */
  35226. get mustDepthSortFacets(): boolean;
  35227. set mustDepthSortFacets(sort: boolean);
  35228. /**
  35229. * The location (Vector3) where the facet depth sort must be computed from.
  35230. * By default, the active camera position.
  35231. * Used only when facet depth sort is enabled
  35232. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35233. */
  35234. get facetDepthSortFrom(): Vector3;
  35235. set facetDepthSortFrom(location: Vector3);
  35236. /**
  35237. * gets a boolean indicating if facetData is enabled
  35238. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35239. */
  35240. get isFacetDataEnabled(): boolean;
  35241. /** @hidden */
  35242. _updateNonUniformScalingState(value: boolean): boolean;
  35243. /**
  35244. * An event triggered when this mesh collides with another one
  35245. */
  35246. onCollideObservable: Observable<AbstractMesh>;
  35247. /** Set a function to call when this mesh collides with another one */
  35248. set onCollide(callback: () => void);
  35249. /**
  35250. * An event triggered when the collision's position changes
  35251. */
  35252. onCollisionPositionChangeObservable: Observable<Vector3>;
  35253. /** Set a function to call when the collision's position changes */
  35254. set onCollisionPositionChange(callback: () => void);
  35255. /**
  35256. * An event triggered when material is changed
  35257. */
  35258. onMaterialChangedObservable: Observable<AbstractMesh>;
  35259. /**
  35260. * Gets or sets the orientation for POV movement & rotation
  35261. */
  35262. definedFacingForward: boolean;
  35263. /** @hidden */
  35264. _occlusionQuery: Nullable<WebGLQuery>;
  35265. /** @hidden */
  35266. _renderingGroup: Nullable<RenderingGroup>;
  35267. /**
  35268. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35269. */
  35270. get visibility(): number;
  35271. /**
  35272. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35273. */
  35274. set visibility(value: number);
  35275. /** Gets or sets the alpha index used to sort transparent meshes
  35276. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35277. */
  35278. alphaIndex: number;
  35279. /**
  35280. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35281. */
  35282. isVisible: boolean;
  35283. /**
  35284. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35285. */
  35286. isPickable: boolean;
  35287. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35288. showSubMeshesBoundingBox: boolean;
  35289. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35290. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35291. */
  35292. isBlocker: boolean;
  35293. /**
  35294. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35295. */
  35296. enablePointerMoveEvents: boolean;
  35297. private _renderingGroupId;
  35298. /**
  35299. * Specifies the rendering group id for this mesh (0 by default)
  35300. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35301. */
  35302. get renderingGroupId(): number;
  35303. set renderingGroupId(value: number);
  35304. private _material;
  35305. /** Gets or sets current material */
  35306. get material(): Nullable<Material>;
  35307. set material(value: Nullable<Material>);
  35308. /**
  35309. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35310. * @see https://doc.babylonjs.com/babylon101/shadows
  35311. */
  35312. get receiveShadows(): boolean;
  35313. set receiveShadows(value: boolean);
  35314. /** Defines color to use when rendering outline */
  35315. outlineColor: Color3;
  35316. /** Define width to use when rendering outline */
  35317. outlineWidth: number;
  35318. /** Defines color to use when rendering overlay */
  35319. overlayColor: Color3;
  35320. /** Defines alpha to use when rendering overlay */
  35321. overlayAlpha: number;
  35322. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35323. get hasVertexAlpha(): boolean;
  35324. set hasVertexAlpha(value: boolean);
  35325. /** 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) */
  35326. get useVertexColors(): boolean;
  35327. set useVertexColors(value: boolean);
  35328. /**
  35329. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35330. */
  35331. get computeBonesUsingShaders(): boolean;
  35332. set computeBonesUsingShaders(value: boolean);
  35333. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35334. get numBoneInfluencers(): number;
  35335. set numBoneInfluencers(value: number);
  35336. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35337. get applyFog(): boolean;
  35338. set applyFog(value: boolean);
  35339. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35340. useOctreeForRenderingSelection: boolean;
  35341. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35342. useOctreeForPicking: boolean;
  35343. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35344. useOctreeForCollisions: boolean;
  35345. /**
  35346. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35347. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35348. */
  35349. get layerMask(): number;
  35350. set layerMask(value: number);
  35351. /**
  35352. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35353. */
  35354. alwaysSelectAsActiveMesh: boolean;
  35355. /**
  35356. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35357. */
  35358. doNotSyncBoundingInfo: boolean;
  35359. /**
  35360. * Gets or sets the current action manager
  35361. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35362. */
  35363. actionManager: Nullable<AbstractActionManager>;
  35364. private _meshCollisionData;
  35365. /**
  35366. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35367. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35368. */
  35369. ellipsoid: Vector3;
  35370. /**
  35371. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35372. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35373. */
  35374. ellipsoidOffset: Vector3;
  35375. /**
  35376. * Gets or sets a collision mask used to mask collisions (default is -1).
  35377. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35378. */
  35379. get collisionMask(): number;
  35380. set collisionMask(mask: number);
  35381. /**
  35382. * Gets or sets a collision response flag (default is true).
  35383. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35384. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35385. * to respond to the collision.
  35386. */
  35387. get collisionResponse(): boolean;
  35388. set collisionResponse(response: boolean);
  35389. /**
  35390. * Gets or sets the current collision group mask (-1 by default).
  35391. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35392. */
  35393. get collisionGroup(): number;
  35394. set collisionGroup(mask: number);
  35395. /**
  35396. * Gets or sets current surrounding meshes (null by default).
  35397. *
  35398. * By default collision detection is tested against every mesh in the scene.
  35399. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35400. * meshes will be tested for the collision.
  35401. *
  35402. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35403. */
  35404. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35405. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35406. /**
  35407. * Defines edge width used when edgesRenderer is enabled
  35408. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35409. */
  35410. edgesWidth: number;
  35411. /**
  35412. * Defines edge color used when edgesRenderer is enabled
  35413. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35414. */
  35415. edgesColor: Color4;
  35416. /** @hidden */
  35417. _edgesRenderer: Nullable<IEdgesRenderer>;
  35418. /** @hidden */
  35419. _masterMesh: Nullable<AbstractMesh>;
  35420. /** @hidden */
  35421. _boundingInfo: Nullable<BoundingInfo>;
  35422. /** @hidden */
  35423. _renderId: number;
  35424. /**
  35425. * Gets or sets the list of subMeshes
  35426. * @see https://doc.babylonjs.com/how_to/multi_materials
  35427. */
  35428. subMeshes: SubMesh[];
  35429. /** @hidden */
  35430. _intersectionsInProgress: AbstractMesh[];
  35431. /** @hidden */
  35432. _unIndexed: boolean;
  35433. /** @hidden */
  35434. _lightSources: Light[];
  35435. /** Gets the list of lights affecting that mesh */
  35436. get lightSources(): Light[];
  35437. /** @hidden */
  35438. get _positions(): Nullable<Vector3[]>;
  35439. /** @hidden */
  35440. _waitingData: {
  35441. lods: Nullable<any>;
  35442. actions: Nullable<any>;
  35443. freezeWorldMatrix: Nullable<boolean>;
  35444. };
  35445. /** @hidden */
  35446. _bonesTransformMatrices: Nullable<Float32Array>;
  35447. /** @hidden */
  35448. _transformMatrixTexture: Nullable<RawTexture>;
  35449. /**
  35450. * Gets or sets a skeleton to apply skining transformations
  35451. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35452. */
  35453. set skeleton(value: Nullable<Skeleton>);
  35454. get skeleton(): Nullable<Skeleton>;
  35455. /**
  35456. * An event triggered when the mesh is rebuilt.
  35457. */
  35458. onRebuildObservable: Observable<AbstractMesh>;
  35459. /**
  35460. * Creates a new AbstractMesh
  35461. * @param name defines the name of the mesh
  35462. * @param scene defines the hosting scene
  35463. */
  35464. constructor(name: string, scene?: Nullable<Scene>);
  35465. /**
  35466. * Returns the string "AbstractMesh"
  35467. * @returns "AbstractMesh"
  35468. */
  35469. getClassName(): string;
  35470. /**
  35471. * Gets a string representation of the current mesh
  35472. * @param fullDetails defines a boolean indicating if full details must be included
  35473. * @returns a string representation of the current mesh
  35474. */
  35475. toString(fullDetails?: boolean): string;
  35476. /**
  35477. * @hidden
  35478. */
  35479. protected _getEffectiveParent(): Nullable<Node>;
  35480. /** @hidden */
  35481. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35482. /** @hidden */
  35483. _rebuild(): void;
  35484. /** @hidden */
  35485. _resyncLightSources(): void;
  35486. /** @hidden */
  35487. _resyncLightSource(light: Light): void;
  35488. /** @hidden */
  35489. _unBindEffect(): void;
  35490. /** @hidden */
  35491. _removeLightSource(light: Light, dispose: boolean): void;
  35492. private _markSubMeshesAsDirty;
  35493. /** @hidden */
  35494. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35495. /** @hidden */
  35496. _markSubMeshesAsAttributesDirty(): void;
  35497. /** @hidden */
  35498. _markSubMeshesAsMiscDirty(): void;
  35499. /**
  35500. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35501. */
  35502. get scaling(): Vector3;
  35503. set scaling(newScaling: Vector3);
  35504. /**
  35505. * Returns true if the mesh is blocked. Implemented by child classes
  35506. */
  35507. get isBlocked(): boolean;
  35508. /**
  35509. * Returns the mesh itself by default. Implemented by child classes
  35510. * @param camera defines the camera to use to pick the right LOD level
  35511. * @returns the currentAbstractMesh
  35512. */
  35513. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35514. /**
  35515. * Returns 0 by default. Implemented by child classes
  35516. * @returns an integer
  35517. */
  35518. getTotalVertices(): number;
  35519. /**
  35520. * Returns a positive integer : the total number of indices in this mesh geometry.
  35521. * @returns the numner of indices or zero if the mesh has no geometry.
  35522. */
  35523. getTotalIndices(): number;
  35524. /**
  35525. * Returns null by default. Implemented by child classes
  35526. * @returns null
  35527. */
  35528. getIndices(): Nullable<IndicesArray>;
  35529. /**
  35530. * Returns the array of the requested vertex data kind. Implemented by child classes
  35531. * @param kind defines the vertex data kind to use
  35532. * @returns null
  35533. */
  35534. getVerticesData(kind: string): Nullable<FloatArray>;
  35535. /**
  35536. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35537. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35538. * Note that a new underlying VertexBuffer object is created each call.
  35539. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35540. * @param kind defines vertex data kind:
  35541. * * VertexBuffer.PositionKind
  35542. * * VertexBuffer.UVKind
  35543. * * VertexBuffer.UV2Kind
  35544. * * VertexBuffer.UV3Kind
  35545. * * VertexBuffer.UV4Kind
  35546. * * VertexBuffer.UV5Kind
  35547. * * VertexBuffer.UV6Kind
  35548. * * VertexBuffer.ColorKind
  35549. * * VertexBuffer.MatricesIndicesKind
  35550. * * VertexBuffer.MatricesIndicesExtraKind
  35551. * * VertexBuffer.MatricesWeightsKind
  35552. * * VertexBuffer.MatricesWeightsExtraKind
  35553. * @param data defines the data source
  35554. * @param updatable defines if the data must be flagged as updatable (or static)
  35555. * @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
  35556. * @returns the current mesh
  35557. */
  35558. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35559. /**
  35560. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35561. * If the mesh has no geometry, it is simply returned as it is.
  35562. * @param kind defines vertex data kind:
  35563. * * VertexBuffer.PositionKind
  35564. * * VertexBuffer.UVKind
  35565. * * VertexBuffer.UV2Kind
  35566. * * VertexBuffer.UV3Kind
  35567. * * VertexBuffer.UV4Kind
  35568. * * VertexBuffer.UV5Kind
  35569. * * VertexBuffer.UV6Kind
  35570. * * VertexBuffer.ColorKind
  35571. * * VertexBuffer.MatricesIndicesKind
  35572. * * VertexBuffer.MatricesIndicesExtraKind
  35573. * * VertexBuffer.MatricesWeightsKind
  35574. * * VertexBuffer.MatricesWeightsExtraKind
  35575. * @param data defines the data source
  35576. * @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
  35577. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35578. * @returns the current mesh
  35579. */
  35580. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35581. /**
  35582. * Sets the mesh indices,
  35583. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35584. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35585. * @param totalVertices Defines the total number of vertices
  35586. * @returns the current mesh
  35587. */
  35588. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35589. /**
  35590. * Gets a boolean indicating if specific vertex data is present
  35591. * @param kind defines the vertex data kind to use
  35592. * @returns true is data kind is present
  35593. */
  35594. isVerticesDataPresent(kind: string): boolean;
  35595. /**
  35596. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35597. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35598. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35599. * @returns a BoundingInfo
  35600. */
  35601. getBoundingInfo(): BoundingInfo;
  35602. /**
  35603. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35604. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35605. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35606. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35607. * @returns the current mesh
  35608. */
  35609. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35610. /**
  35611. * Overwrite the current bounding info
  35612. * @param boundingInfo defines the new bounding info
  35613. * @returns the current mesh
  35614. */
  35615. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35616. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35617. get useBones(): boolean;
  35618. /** @hidden */
  35619. _preActivate(): void;
  35620. /** @hidden */
  35621. _preActivateForIntermediateRendering(renderId: number): void;
  35622. /** @hidden */
  35623. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35624. /** @hidden */
  35625. _postActivate(): void;
  35626. /** @hidden */
  35627. _freeze(): void;
  35628. /** @hidden */
  35629. _unFreeze(): void;
  35630. /**
  35631. * Gets the current world matrix
  35632. * @returns a Matrix
  35633. */
  35634. getWorldMatrix(): Matrix;
  35635. /** @hidden */
  35636. _getWorldMatrixDeterminant(): number;
  35637. /**
  35638. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35639. */
  35640. get isAnInstance(): boolean;
  35641. /**
  35642. * Gets a boolean indicating if this mesh has instances
  35643. */
  35644. get hasInstances(): boolean;
  35645. /**
  35646. * Gets a boolean indicating if this mesh has thin instances
  35647. */
  35648. get hasThinInstances(): boolean;
  35649. /**
  35650. * Perform relative position change from the point of view of behind the front of the mesh.
  35651. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35652. * Supports definition of mesh facing forward or backward
  35653. * @param amountRight defines the distance on the right axis
  35654. * @param amountUp defines the distance on the up axis
  35655. * @param amountForward defines the distance on the forward axis
  35656. * @returns the current mesh
  35657. */
  35658. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35659. /**
  35660. * Calculate relative position change from the point of view of behind the front of the mesh.
  35661. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35662. * Supports definition of mesh facing forward or backward
  35663. * @param amountRight defines the distance on the right axis
  35664. * @param amountUp defines the distance on the up axis
  35665. * @param amountForward defines the distance on the forward axis
  35666. * @returns the new displacement vector
  35667. */
  35668. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35669. /**
  35670. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35671. * Supports definition of mesh facing forward or backward
  35672. * @param flipBack defines the flip
  35673. * @param twirlClockwise defines the twirl
  35674. * @param tiltRight defines the tilt
  35675. * @returns the current mesh
  35676. */
  35677. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35678. /**
  35679. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35680. * Supports definition of mesh facing forward or backward.
  35681. * @param flipBack defines the flip
  35682. * @param twirlClockwise defines the twirl
  35683. * @param tiltRight defines the tilt
  35684. * @returns the new rotation vector
  35685. */
  35686. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35687. /**
  35688. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35689. * This means the mesh underlying bounding box and sphere are recomputed.
  35690. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35691. * @returns the current mesh
  35692. */
  35693. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35694. /** @hidden */
  35695. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35696. /** @hidden */
  35697. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35698. /** @hidden */
  35699. _updateBoundingInfo(): AbstractMesh;
  35700. /** @hidden */
  35701. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35702. /** @hidden */
  35703. protected _afterComputeWorldMatrix(): void;
  35704. /** @hidden */
  35705. get _effectiveMesh(): AbstractMesh;
  35706. /**
  35707. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35708. * A mesh is in the frustum if its bounding box intersects the frustum
  35709. * @param frustumPlanes defines the frustum to test
  35710. * @returns true if the mesh is in the frustum planes
  35711. */
  35712. isInFrustum(frustumPlanes: Plane[]): boolean;
  35713. /**
  35714. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35715. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35716. * @param frustumPlanes defines the frustum to test
  35717. * @returns true if the mesh is completely in the frustum planes
  35718. */
  35719. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35720. /**
  35721. * True if the mesh intersects another mesh or a SolidParticle object
  35722. * @param mesh defines a target mesh or SolidParticle to test
  35723. * @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)
  35724. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35725. * @returns true if there is an intersection
  35726. */
  35727. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35728. /**
  35729. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35730. * @param point defines the point to test
  35731. * @returns true if there is an intersection
  35732. */
  35733. intersectsPoint(point: Vector3): boolean;
  35734. /**
  35735. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35736. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35737. */
  35738. get checkCollisions(): boolean;
  35739. set checkCollisions(collisionEnabled: boolean);
  35740. /**
  35741. * Gets Collider object used to compute collisions (not physics)
  35742. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35743. */
  35744. get collider(): Nullable<Collider>;
  35745. /**
  35746. * Move the mesh using collision engine
  35747. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35748. * @param displacement defines the requested displacement vector
  35749. * @returns the current mesh
  35750. */
  35751. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35752. private _onCollisionPositionChange;
  35753. /** @hidden */
  35754. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35755. /** @hidden */
  35756. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35757. /** @hidden */
  35758. _checkCollision(collider: Collider): AbstractMesh;
  35759. /** @hidden */
  35760. _generatePointsArray(): boolean;
  35761. /**
  35762. * Checks if the passed Ray intersects with the mesh
  35763. * @param ray defines the ray to use
  35764. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35765. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35766. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35767. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35768. * @returns the picking info
  35769. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35770. */
  35771. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  35772. /**
  35773. * Clones the current mesh
  35774. * @param name defines the mesh name
  35775. * @param newParent defines the new mesh parent
  35776. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35777. * @returns the new mesh
  35778. */
  35779. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35780. /**
  35781. * Disposes all the submeshes of the current meshnp
  35782. * @returns the current mesh
  35783. */
  35784. releaseSubMeshes(): AbstractMesh;
  35785. /**
  35786. * Releases resources associated with this abstract mesh.
  35787. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35788. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35789. */
  35790. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35791. /**
  35792. * Adds the passed mesh as a child to the current mesh
  35793. * @param mesh defines the child mesh
  35794. * @returns the current mesh
  35795. */
  35796. addChild(mesh: AbstractMesh): AbstractMesh;
  35797. /**
  35798. * Removes the passed mesh from the current mesh children list
  35799. * @param mesh defines the child mesh
  35800. * @returns the current mesh
  35801. */
  35802. removeChild(mesh: AbstractMesh): AbstractMesh;
  35803. /** @hidden */
  35804. private _initFacetData;
  35805. /**
  35806. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35807. * This method can be called within the render loop.
  35808. * 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
  35809. * @returns the current mesh
  35810. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35811. */
  35812. updateFacetData(): AbstractMesh;
  35813. /**
  35814. * Returns the facetLocalNormals array.
  35815. * The normals are expressed in the mesh local spac
  35816. * @returns an array of Vector3
  35817. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35818. */
  35819. getFacetLocalNormals(): Vector3[];
  35820. /**
  35821. * Returns the facetLocalPositions array.
  35822. * The facet positions are expressed in the mesh local space
  35823. * @returns an array of Vector3
  35824. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35825. */
  35826. getFacetLocalPositions(): Vector3[];
  35827. /**
  35828. * Returns the facetLocalPartioning array
  35829. * @returns an array of array of numbers
  35830. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35831. */
  35832. getFacetLocalPartitioning(): number[][];
  35833. /**
  35834. * Returns the i-th facet position in the world system.
  35835. * This method allocates a new Vector3 per call
  35836. * @param i defines the facet index
  35837. * @returns a new Vector3
  35838. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35839. */
  35840. getFacetPosition(i: number): Vector3;
  35841. /**
  35842. * Sets the reference Vector3 with the i-th facet position in the world system
  35843. * @param i defines the facet index
  35844. * @param ref defines the target vector
  35845. * @returns the current mesh
  35846. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35847. */
  35848. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35849. /**
  35850. * Returns the i-th facet normal in the world system.
  35851. * This method allocates a new Vector3 per call
  35852. * @param i defines the facet index
  35853. * @returns a new Vector3
  35854. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35855. */
  35856. getFacetNormal(i: number): Vector3;
  35857. /**
  35858. * Sets the reference Vector3 with the i-th facet normal in the world system
  35859. * @param i defines the facet index
  35860. * @param ref defines the target vector
  35861. * @returns the current mesh
  35862. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35863. */
  35864. getFacetNormalToRef(i: number, ref: Vector3): this;
  35865. /**
  35866. * 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)
  35867. * @param x defines x coordinate
  35868. * @param y defines y coordinate
  35869. * @param z defines z coordinate
  35870. * @returns the array of facet indexes
  35871. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35872. */
  35873. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35874. /**
  35875. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35876. * @param projected sets as the (x,y,z) world projection on the facet
  35877. * @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
  35878. * @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
  35879. * @param x defines x coordinate
  35880. * @param y defines y coordinate
  35881. * @param z defines z coordinate
  35882. * @returns the face index if found (or null instead)
  35883. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35884. */
  35885. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35886. /**
  35887. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35888. * @param projected sets as the (x,y,z) local projection on the facet
  35889. * @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
  35890. * @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
  35891. * @param x defines x coordinate
  35892. * @param y defines y coordinate
  35893. * @param z defines z coordinate
  35894. * @returns the face index if found (or null instead)
  35895. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35896. */
  35897. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35898. /**
  35899. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35900. * @returns the parameters
  35901. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35902. */
  35903. getFacetDataParameters(): any;
  35904. /**
  35905. * Disables the feature FacetData and frees the related memory
  35906. * @returns the current mesh
  35907. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35908. */
  35909. disableFacetData(): AbstractMesh;
  35910. /**
  35911. * Updates the AbstractMesh indices array
  35912. * @param indices defines the data source
  35913. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35914. * @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)
  35915. * @returns the current mesh
  35916. */
  35917. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35918. /**
  35919. * Creates new normals data for the mesh
  35920. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35921. * @returns the current mesh
  35922. */
  35923. createNormals(updatable: boolean): AbstractMesh;
  35924. /**
  35925. * Align the mesh with a normal
  35926. * @param normal defines the normal to use
  35927. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35928. * @returns the current mesh
  35929. */
  35930. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35931. /** @hidden */
  35932. _checkOcclusionQuery(): boolean;
  35933. /**
  35934. * Disables the mesh edge rendering mode
  35935. * @returns the currentAbstractMesh
  35936. */
  35937. disableEdgesRendering(): AbstractMesh;
  35938. /**
  35939. * Enables the edge rendering mode on the mesh.
  35940. * This mode makes the mesh edges visible
  35941. * @param epsilon defines the maximal distance between two angles to detect a face
  35942. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35943. * @returns the currentAbstractMesh
  35944. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35945. */
  35946. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35947. /**
  35948. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35949. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35950. */
  35951. getConnectedParticleSystems(): IParticleSystem[];
  35952. }
  35953. }
  35954. declare module BABYLON {
  35955. /**
  35956. * Interface used to define ActionEvent
  35957. */
  35958. export interface IActionEvent {
  35959. /** The mesh or sprite that triggered the action */
  35960. source: any;
  35961. /** The X mouse cursor position at the time of the event */
  35962. pointerX: number;
  35963. /** The Y mouse cursor position at the time of the event */
  35964. pointerY: number;
  35965. /** The mesh that is currently pointed at (can be null) */
  35966. meshUnderPointer: Nullable<AbstractMesh>;
  35967. /** the original (browser) event that triggered the ActionEvent */
  35968. sourceEvent?: any;
  35969. /** additional data for the event */
  35970. additionalData?: any;
  35971. }
  35972. /**
  35973. * ActionEvent is the event being sent when an action is triggered.
  35974. */
  35975. export class ActionEvent implements IActionEvent {
  35976. /** The mesh or sprite that triggered the action */
  35977. source: any;
  35978. /** The X mouse cursor position at the time of the event */
  35979. pointerX: number;
  35980. /** The Y mouse cursor position at the time of the event */
  35981. pointerY: number;
  35982. /** The mesh that is currently pointed at (can be null) */
  35983. meshUnderPointer: Nullable<AbstractMesh>;
  35984. /** the original (browser) event that triggered the ActionEvent */
  35985. sourceEvent?: any;
  35986. /** additional data for the event */
  35987. additionalData?: any;
  35988. /**
  35989. * Creates a new ActionEvent
  35990. * @param source The mesh or sprite that triggered the action
  35991. * @param pointerX The X mouse cursor position at the time of the event
  35992. * @param pointerY The Y mouse cursor position at the time of the event
  35993. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  35994. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  35995. * @param additionalData additional data for the event
  35996. */
  35997. constructor(
  35998. /** The mesh or sprite that triggered the action */
  35999. source: any,
  36000. /** The X mouse cursor position at the time of the event */
  36001. pointerX: number,
  36002. /** The Y mouse cursor position at the time of the event */
  36003. pointerY: number,
  36004. /** The mesh that is currently pointed at (can be null) */
  36005. meshUnderPointer: Nullable<AbstractMesh>,
  36006. /** the original (browser) event that triggered the ActionEvent */
  36007. sourceEvent?: any,
  36008. /** additional data for the event */
  36009. additionalData?: any);
  36010. /**
  36011. * Helper function to auto-create an ActionEvent from a source mesh.
  36012. * @param source The source mesh that triggered the event
  36013. * @param evt The original (browser) event
  36014. * @param additionalData additional data for the event
  36015. * @returns the new ActionEvent
  36016. */
  36017. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36018. /**
  36019. * Helper function to auto-create an ActionEvent from a source sprite
  36020. * @param source The source sprite that triggered the event
  36021. * @param scene Scene associated with the sprite
  36022. * @param evt The original (browser) event
  36023. * @param additionalData additional data for the event
  36024. * @returns the new ActionEvent
  36025. */
  36026. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36027. /**
  36028. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36029. * @param scene the scene where the event occurred
  36030. * @param evt The original (browser) event
  36031. * @returns the new ActionEvent
  36032. */
  36033. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36034. /**
  36035. * Helper function to auto-create an ActionEvent from a primitive
  36036. * @param prim defines the target primitive
  36037. * @param pointerPos defines the pointer position
  36038. * @param evt The original (browser) event
  36039. * @param additionalData additional data for the event
  36040. * @returns the new ActionEvent
  36041. */
  36042. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36043. }
  36044. }
  36045. declare module BABYLON {
  36046. /**
  36047. * Abstract class used to decouple action Manager from scene and meshes.
  36048. * Do not instantiate.
  36049. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36050. */
  36051. export abstract class AbstractActionManager implements IDisposable {
  36052. /** Gets the list of active triggers */
  36053. static Triggers: {
  36054. [key: string]: number;
  36055. };
  36056. /** Gets the cursor to use when hovering items */
  36057. hoverCursor: string;
  36058. /** Gets the list of actions */
  36059. actions: IAction[];
  36060. /**
  36061. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36062. */
  36063. isRecursive: boolean;
  36064. /**
  36065. * Releases all associated resources
  36066. */
  36067. abstract dispose(): void;
  36068. /**
  36069. * Does this action manager has pointer triggers
  36070. */
  36071. abstract get hasPointerTriggers(): boolean;
  36072. /**
  36073. * Does this action manager has pick triggers
  36074. */
  36075. abstract get hasPickTriggers(): boolean;
  36076. /**
  36077. * Process a specific trigger
  36078. * @param trigger defines the trigger to process
  36079. * @param evt defines the event details to be processed
  36080. */
  36081. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36082. /**
  36083. * Does this action manager handles actions of any of the given triggers
  36084. * @param triggers defines the triggers to be tested
  36085. * @return a boolean indicating whether one (or more) of the triggers is handled
  36086. */
  36087. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36088. /**
  36089. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36090. * speed.
  36091. * @param triggerA defines the trigger to be tested
  36092. * @param triggerB defines the trigger to be tested
  36093. * @return a boolean indicating whether one (or more) of the triggers is handled
  36094. */
  36095. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36096. /**
  36097. * Does this action manager handles actions of a given trigger
  36098. * @param trigger defines the trigger to be tested
  36099. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36100. * @return whether the trigger is handled
  36101. */
  36102. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36103. /**
  36104. * Serialize this manager to a JSON object
  36105. * @param name defines the property name to store this manager
  36106. * @returns a JSON representation of this manager
  36107. */
  36108. abstract serialize(name: string): any;
  36109. /**
  36110. * Registers an action to this action manager
  36111. * @param action defines the action to be registered
  36112. * @return the action amended (prepared) after registration
  36113. */
  36114. abstract registerAction(action: IAction): Nullable<IAction>;
  36115. /**
  36116. * Unregisters an action to this action manager
  36117. * @param action defines the action to be unregistered
  36118. * @return a boolean indicating whether the action has been unregistered
  36119. */
  36120. abstract unregisterAction(action: IAction): Boolean;
  36121. /**
  36122. * Does exist one action manager with at least one trigger
  36123. **/
  36124. static get HasTriggers(): boolean;
  36125. /**
  36126. * Does exist one action manager with at least one pick trigger
  36127. **/
  36128. static get HasPickTriggers(): boolean;
  36129. /**
  36130. * Does exist one action manager that handles actions of a given trigger
  36131. * @param trigger defines the trigger to be tested
  36132. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36133. **/
  36134. static HasSpecificTrigger(trigger: number): boolean;
  36135. }
  36136. }
  36137. declare module BABYLON {
  36138. /**
  36139. * Defines how a node can be built from a string name.
  36140. */
  36141. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36142. /**
  36143. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36144. */
  36145. export class Node implements IBehaviorAware<Node> {
  36146. /** @hidden */
  36147. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36148. private static _NodeConstructors;
  36149. /**
  36150. * Add a new node constructor
  36151. * @param type defines the type name of the node to construct
  36152. * @param constructorFunc defines the constructor function
  36153. */
  36154. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36155. /**
  36156. * Returns a node constructor based on type name
  36157. * @param type defines the type name
  36158. * @param name defines the new node name
  36159. * @param scene defines the hosting scene
  36160. * @param options defines optional options to transmit to constructors
  36161. * @returns the new constructor or null
  36162. */
  36163. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36164. /**
  36165. * Gets or sets the name of the node
  36166. */
  36167. name: string;
  36168. /**
  36169. * Gets or sets the id of the node
  36170. */
  36171. id: string;
  36172. /**
  36173. * Gets or sets the unique id of the node
  36174. */
  36175. uniqueId: number;
  36176. /**
  36177. * Gets or sets a string used to store user defined state for the node
  36178. */
  36179. state: string;
  36180. /**
  36181. * Gets or sets an object used to store user defined information for the node
  36182. */
  36183. metadata: any;
  36184. /**
  36185. * For internal use only. Please do not use.
  36186. */
  36187. reservedDataStore: any;
  36188. /**
  36189. * List of inspectable custom properties (used by the Inspector)
  36190. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36191. */
  36192. inspectableCustomProperties: IInspectable[];
  36193. private _doNotSerialize;
  36194. /**
  36195. * Gets or sets a boolean used to define if the node must be serialized
  36196. */
  36197. get doNotSerialize(): boolean;
  36198. set doNotSerialize(value: boolean);
  36199. /** @hidden */
  36200. _isDisposed: boolean;
  36201. /**
  36202. * Gets a list of Animations associated with the node
  36203. */
  36204. animations: Animation[];
  36205. protected _ranges: {
  36206. [name: string]: Nullable<AnimationRange>;
  36207. };
  36208. /**
  36209. * Callback raised when the node is ready to be used
  36210. */
  36211. onReady: Nullable<(node: Node) => void>;
  36212. private _isEnabled;
  36213. private _isParentEnabled;
  36214. private _isReady;
  36215. /** @hidden */
  36216. _currentRenderId: number;
  36217. private _parentUpdateId;
  36218. /** @hidden */
  36219. _childUpdateId: number;
  36220. /** @hidden */
  36221. _waitingParentId: Nullable<string>;
  36222. /** @hidden */
  36223. _scene: Scene;
  36224. /** @hidden */
  36225. _cache: any;
  36226. private _parentNode;
  36227. private _children;
  36228. /** @hidden */
  36229. _worldMatrix: Matrix;
  36230. /** @hidden */
  36231. _worldMatrixDeterminant: number;
  36232. /** @hidden */
  36233. _worldMatrixDeterminantIsDirty: boolean;
  36234. /** @hidden */
  36235. private _sceneRootNodesIndex;
  36236. /**
  36237. * Gets a boolean indicating if the node has been disposed
  36238. * @returns true if the node was disposed
  36239. */
  36240. isDisposed(): boolean;
  36241. /**
  36242. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36243. * @see https://doc.babylonjs.com/how_to/parenting
  36244. */
  36245. set parent(parent: Nullable<Node>);
  36246. get parent(): Nullable<Node>;
  36247. /** @hidden */
  36248. _addToSceneRootNodes(): void;
  36249. /** @hidden */
  36250. _removeFromSceneRootNodes(): void;
  36251. private _animationPropertiesOverride;
  36252. /**
  36253. * Gets or sets the animation properties override
  36254. */
  36255. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36256. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36257. /**
  36258. * Gets a string identifying the name of the class
  36259. * @returns "Node" string
  36260. */
  36261. getClassName(): string;
  36262. /** @hidden */
  36263. readonly _isNode: boolean;
  36264. /**
  36265. * An event triggered when the mesh is disposed
  36266. */
  36267. onDisposeObservable: Observable<Node>;
  36268. private _onDisposeObserver;
  36269. /**
  36270. * Sets a callback that will be raised when the node will be disposed
  36271. */
  36272. set onDispose(callback: () => void);
  36273. /**
  36274. * Creates a new Node
  36275. * @param name the name and id to be given to this node
  36276. * @param scene the scene this node will be added to
  36277. */
  36278. constructor(name: string, scene?: Nullable<Scene>);
  36279. /**
  36280. * Gets the scene of the node
  36281. * @returns a scene
  36282. */
  36283. getScene(): Scene;
  36284. /**
  36285. * Gets the engine of the node
  36286. * @returns a Engine
  36287. */
  36288. getEngine(): Engine;
  36289. private _behaviors;
  36290. /**
  36291. * Attach a behavior to the node
  36292. * @see https://doc.babylonjs.com/features/behaviour
  36293. * @param behavior defines the behavior to attach
  36294. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36295. * @returns the current Node
  36296. */
  36297. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36298. /**
  36299. * Remove an attached behavior
  36300. * @see https://doc.babylonjs.com/features/behaviour
  36301. * @param behavior defines the behavior to attach
  36302. * @returns the current Node
  36303. */
  36304. removeBehavior(behavior: Behavior<Node>): Node;
  36305. /**
  36306. * Gets the list of attached behaviors
  36307. * @see https://doc.babylonjs.com/features/behaviour
  36308. */
  36309. get behaviors(): Behavior<Node>[];
  36310. /**
  36311. * Gets an attached behavior by name
  36312. * @param name defines the name of the behavior to look for
  36313. * @see https://doc.babylonjs.com/features/behaviour
  36314. * @returns null if behavior was not found else the requested behavior
  36315. */
  36316. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36317. /**
  36318. * Returns the latest update of the World matrix
  36319. * @returns a Matrix
  36320. */
  36321. getWorldMatrix(): Matrix;
  36322. /** @hidden */
  36323. _getWorldMatrixDeterminant(): number;
  36324. /**
  36325. * Returns directly the latest state of the mesh World matrix.
  36326. * A Matrix is returned.
  36327. */
  36328. get worldMatrixFromCache(): Matrix;
  36329. /** @hidden */
  36330. _initCache(): void;
  36331. /** @hidden */
  36332. updateCache(force?: boolean): void;
  36333. /** @hidden */
  36334. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36335. /** @hidden */
  36336. _updateCache(ignoreParentClass?: boolean): void;
  36337. /** @hidden */
  36338. _isSynchronized(): boolean;
  36339. /** @hidden */
  36340. _markSyncedWithParent(): void;
  36341. /** @hidden */
  36342. isSynchronizedWithParent(): boolean;
  36343. /** @hidden */
  36344. isSynchronized(): boolean;
  36345. /**
  36346. * Is this node ready to be used/rendered
  36347. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36348. * @return true if the node is ready
  36349. */
  36350. isReady(completeCheck?: boolean): boolean;
  36351. /**
  36352. * Is this node enabled?
  36353. * 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
  36354. * @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
  36355. * @return whether this node (and its parent) is enabled
  36356. */
  36357. isEnabled(checkAncestors?: boolean): boolean;
  36358. /** @hidden */
  36359. protected _syncParentEnabledState(): void;
  36360. /**
  36361. * Set the enabled state of this node
  36362. * @param value defines the new enabled state
  36363. */
  36364. setEnabled(value: boolean): void;
  36365. /**
  36366. * Is this node a descendant of the given node?
  36367. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36368. * @param ancestor defines the parent node to inspect
  36369. * @returns a boolean indicating if this node is a descendant of the given node
  36370. */
  36371. isDescendantOf(ancestor: Node): boolean;
  36372. /** @hidden */
  36373. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36374. /**
  36375. * Will return all nodes that have this node as ascendant
  36376. * @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
  36377. * @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
  36378. * @return all children nodes of all types
  36379. */
  36380. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36381. /**
  36382. * Get all child-meshes of this node
  36383. * @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)
  36384. * @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
  36385. * @returns an array of AbstractMesh
  36386. */
  36387. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36388. /**
  36389. * Get all direct children of this node
  36390. * @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
  36391. * @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)
  36392. * @returns an array of Node
  36393. */
  36394. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36395. /** @hidden */
  36396. _setReady(state: boolean): void;
  36397. /**
  36398. * Get an animation by name
  36399. * @param name defines the name of the animation to look for
  36400. * @returns null if not found else the requested animation
  36401. */
  36402. getAnimationByName(name: string): Nullable<Animation>;
  36403. /**
  36404. * Creates an animation range for this node
  36405. * @param name defines the name of the range
  36406. * @param from defines the starting key
  36407. * @param to defines the end key
  36408. */
  36409. createAnimationRange(name: string, from: number, to: number): void;
  36410. /**
  36411. * Delete a specific animation range
  36412. * @param name defines the name of the range to delete
  36413. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36414. */
  36415. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36416. /**
  36417. * Get an animation range by name
  36418. * @param name defines the name of the animation range to look for
  36419. * @returns null if not found else the requested animation range
  36420. */
  36421. getAnimationRange(name: string): Nullable<AnimationRange>;
  36422. /**
  36423. * Gets the list of all animation ranges defined on this node
  36424. * @returns an array
  36425. */
  36426. getAnimationRanges(): Nullable<AnimationRange>[];
  36427. /**
  36428. * Will start the animation sequence
  36429. * @param name defines the range frames for animation sequence
  36430. * @param loop defines if the animation should loop (false by default)
  36431. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36432. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36433. * @returns the object created for this animation. If range does not exist, it will return null
  36434. */
  36435. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36436. /**
  36437. * Serialize animation ranges into a JSON compatible object
  36438. * @returns serialization object
  36439. */
  36440. serializeAnimationRanges(): any;
  36441. /**
  36442. * Computes the world matrix of the node
  36443. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36444. * @returns the world matrix
  36445. */
  36446. computeWorldMatrix(force?: boolean): Matrix;
  36447. /**
  36448. * Releases resources associated with this node.
  36449. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36450. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36451. */
  36452. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36453. /**
  36454. * Parse animation range data from a serialization object and store them into a given node
  36455. * @param node defines where to store the animation ranges
  36456. * @param parsedNode defines the serialization object to read data from
  36457. * @param scene defines the hosting scene
  36458. */
  36459. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36460. /**
  36461. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36462. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36463. * @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
  36464. * @returns the new bounding vectors
  36465. */
  36466. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36467. min: Vector3;
  36468. max: Vector3;
  36469. };
  36470. }
  36471. }
  36472. declare module BABYLON {
  36473. /**
  36474. * @hidden
  36475. */
  36476. export class _IAnimationState {
  36477. key: number;
  36478. repeatCount: number;
  36479. workValue?: any;
  36480. loopMode?: number;
  36481. offsetValue?: any;
  36482. highLimitValue?: any;
  36483. }
  36484. /**
  36485. * Class used to store any kind of animation
  36486. */
  36487. export class Animation {
  36488. /**Name of the animation */
  36489. name: string;
  36490. /**Property to animate */
  36491. targetProperty: string;
  36492. /**The frames per second of the animation */
  36493. framePerSecond: number;
  36494. /**The data type of the animation */
  36495. dataType: number;
  36496. /**The loop mode of the animation */
  36497. loopMode?: number | undefined;
  36498. /**Specifies if blending should be enabled */
  36499. enableBlending?: boolean | undefined;
  36500. /**
  36501. * Use matrix interpolation instead of using direct key value when animating matrices
  36502. */
  36503. static AllowMatricesInterpolation: boolean;
  36504. /**
  36505. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36506. */
  36507. static AllowMatrixDecomposeForInterpolation: boolean;
  36508. /** Define the Url to load snippets */
  36509. static SnippetUrl: string;
  36510. /** Snippet ID if the animation was created from the snippet server */
  36511. snippetId: string;
  36512. /**
  36513. * Stores the key frames of the animation
  36514. */
  36515. private _keys;
  36516. /**
  36517. * Stores the easing function of the animation
  36518. */
  36519. private _easingFunction;
  36520. /**
  36521. * @hidden Internal use only
  36522. */
  36523. _runtimeAnimations: RuntimeAnimation[];
  36524. /**
  36525. * The set of event that will be linked to this animation
  36526. */
  36527. private _events;
  36528. /**
  36529. * Stores an array of target property paths
  36530. */
  36531. targetPropertyPath: string[];
  36532. /**
  36533. * Stores the blending speed of the animation
  36534. */
  36535. blendingSpeed: number;
  36536. /**
  36537. * Stores the animation ranges for the animation
  36538. */
  36539. private _ranges;
  36540. /**
  36541. * @hidden Internal use
  36542. */
  36543. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36544. /**
  36545. * Sets up an animation
  36546. * @param property The property to animate
  36547. * @param animationType The animation type to apply
  36548. * @param framePerSecond The frames per second of the animation
  36549. * @param easingFunction The easing function used in the animation
  36550. * @returns The created animation
  36551. */
  36552. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36553. /**
  36554. * Create and start an animation on a node
  36555. * @param name defines the name of the global animation that will be run on all nodes
  36556. * @param node defines the root node where the animation will take place
  36557. * @param targetProperty defines property to animate
  36558. * @param framePerSecond defines the number of frame per second yo use
  36559. * @param totalFrame defines the number of frames in total
  36560. * @param from defines the initial value
  36561. * @param to defines the final value
  36562. * @param loopMode defines which loop mode you want to use (off by default)
  36563. * @param easingFunction defines the easing function to use (linear by default)
  36564. * @param onAnimationEnd defines the callback to call when animation end
  36565. * @returns the animatable created for this animation
  36566. */
  36567. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36568. /**
  36569. * Create and start an animation on a node and its descendants
  36570. * @param name defines the name of the global animation that will be run on all nodes
  36571. * @param node defines the root node where the animation will take place
  36572. * @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
  36573. * @param targetProperty defines property to animate
  36574. * @param framePerSecond defines the number of frame per second to use
  36575. * @param totalFrame defines the number of frames in total
  36576. * @param from defines the initial value
  36577. * @param to defines the final value
  36578. * @param loopMode defines which loop mode you want to use (off by default)
  36579. * @param easingFunction defines the easing function to use (linear by default)
  36580. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36581. * @returns the list of animatables created for all nodes
  36582. * @example https://www.babylonjs-playground.com/#MH0VLI
  36583. */
  36584. 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[]>;
  36585. /**
  36586. * Creates a new animation, merges it with the existing animations and starts it
  36587. * @param name Name of the animation
  36588. * @param node Node which contains the scene that begins the animations
  36589. * @param targetProperty Specifies which property to animate
  36590. * @param framePerSecond The frames per second of the animation
  36591. * @param totalFrame The total number of frames
  36592. * @param from The frame at the beginning of the animation
  36593. * @param to The frame at the end of the animation
  36594. * @param loopMode Specifies the loop mode of the animation
  36595. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36596. * @param onAnimationEnd Callback to run once the animation is complete
  36597. * @returns Nullable animation
  36598. */
  36599. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36600. /**
  36601. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36602. * @param sourceAnimation defines the Animation containing keyframes to convert
  36603. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36604. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36605. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36606. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36607. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36608. */
  36609. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36610. /**
  36611. * Transition property of an host to the target Value
  36612. * @param property The property to transition
  36613. * @param targetValue The target Value of the property
  36614. * @param host The object where the property to animate belongs
  36615. * @param scene Scene used to run the animation
  36616. * @param frameRate Framerate (in frame/s) to use
  36617. * @param transition The transition type we want to use
  36618. * @param duration The duration of the animation, in milliseconds
  36619. * @param onAnimationEnd Callback trigger at the end of the animation
  36620. * @returns Nullable animation
  36621. */
  36622. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36623. /**
  36624. * Return the array of runtime animations currently using this animation
  36625. */
  36626. get runtimeAnimations(): RuntimeAnimation[];
  36627. /**
  36628. * Specifies if any of the runtime animations are currently running
  36629. */
  36630. get hasRunningRuntimeAnimations(): boolean;
  36631. /**
  36632. * Initializes the animation
  36633. * @param name Name of the animation
  36634. * @param targetProperty Property to animate
  36635. * @param framePerSecond The frames per second of the animation
  36636. * @param dataType The data type of the animation
  36637. * @param loopMode The loop mode of the animation
  36638. * @param enableBlending Specifies if blending should be enabled
  36639. */
  36640. constructor(
  36641. /**Name of the animation */
  36642. name: string,
  36643. /**Property to animate */
  36644. targetProperty: string,
  36645. /**The frames per second of the animation */
  36646. framePerSecond: number,
  36647. /**The data type of the animation */
  36648. dataType: number,
  36649. /**The loop mode of the animation */
  36650. loopMode?: number | undefined,
  36651. /**Specifies if blending should be enabled */
  36652. enableBlending?: boolean | undefined);
  36653. /**
  36654. * Converts the animation to a string
  36655. * @param fullDetails support for multiple levels of logging within scene loading
  36656. * @returns String form of the animation
  36657. */
  36658. toString(fullDetails?: boolean): string;
  36659. /**
  36660. * Add an event to this animation
  36661. * @param event Event to add
  36662. */
  36663. addEvent(event: AnimationEvent): void;
  36664. /**
  36665. * Remove all events found at the given frame
  36666. * @param frame The frame to remove events from
  36667. */
  36668. removeEvents(frame: number): void;
  36669. /**
  36670. * Retrieves all the events from the animation
  36671. * @returns Events from the animation
  36672. */
  36673. getEvents(): AnimationEvent[];
  36674. /**
  36675. * Creates an animation range
  36676. * @param name Name of the animation range
  36677. * @param from Starting frame of the animation range
  36678. * @param to Ending frame of the animation
  36679. */
  36680. createRange(name: string, from: number, to: number): void;
  36681. /**
  36682. * Deletes an animation range by name
  36683. * @param name Name of the animation range to delete
  36684. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36685. */
  36686. deleteRange(name: string, deleteFrames?: boolean): void;
  36687. /**
  36688. * Gets the animation range by name, or null if not defined
  36689. * @param name Name of the animation range
  36690. * @returns Nullable animation range
  36691. */
  36692. getRange(name: string): Nullable<AnimationRange>;
  36693. /**
  36694. * Gets the key frames from the animation
  36695. * @returns The key frames of the animation
  36696. */
  36697. getKeys(): Array<IAnimationKey>;
  36698. /**
  36699. * Gets the highest frame rate of the animation
  36700. * @returns Highest frame rate of the animation
  36701. */
  36702. getHighestFrame(): number;
  36703. /**
  36704. * Gets the easing function of the animation
  36705. * @returns Easing function of the animation
  36706. */
  36707. getEasingFunction(): IEasingFunction;
  36708. /**
  36709. * Sets the easing function of the animation
  36710. * @param easingFunction A custom mathematical formula for animation
  36711. */
  36712. setEasingFunction(easingFunction: EasingFunction): void;
  36713. /**
  36714. * Interpolates a scalar linearly
  36715. * @param startValue Start value of the animation curve
  36716. * @param endValue End value of the animation curve
  36717. * @param gradient Scalar amount to interpolate
  36718. * @returns Interpolated scalar value
  36719. */
  36720. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36721. /**
  36722. * Interpolates a scalar cubically
  36723. * @param startValue Start value of the animation curve
  36724. * @param outTangent End tangent of the animation
  36725. * @param endValue End value of the animation curve
  36726. * @param inTangent Start tangent of the animation curve
  36727. * @param gradient Scalar amount to interpolate
  36728. * @returns Interpolated scalar value
  36729. */
  36730. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36731. /**
  36732. * Interpolates a quaternion using a spherical linear interpolation
  36733. * @param startValue Start value of the animation curve
  36734. * @param endValue End value of the animation curve
  36735. * @param gradient Scalar amount to interpolate
  36736. * @returns Interpolated quaternion value
  36737. */
  36738. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36739. /**
  36740. * Interpolates a quaternion cubically
  36741. * @param startValue Start value of the animation curve
  36742. * @param outTangent End tangent of the animation curve
  36743. * @param endValue End value of the animation curve
  36744. * @param inTangent Start tangent of the animation curve
  36745. * @param gradient Scalar amount to interpolate
  36746. * @returns Interpolated quaternion value
  36747. */
  36748. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36749. /**
  36750. * Interpolates a Vector3 linearl
  36751. * @param startValue Start value of the animation curve
  36752. * @param endValue End value of the animation curve
  36753. * @param gradient Scalar amount to interpolate
  36754. * @returns Interpolated scalar value
  36755. */
  36756. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36757. /**
  36758. * Interpolates a Vector3 cubically
  36759. * @param startValue Start value of the animation curve
  36760. * @param outTangent End tangent of the animation
  36761. * @param endValue End value of the animation curve
  36762. * @param inTangent Start tangent of the animation curve
  36763. * @param gradient Scalar amount to interpolate
  36764. * @returns InterpolatedVector3 value
  36765. */
  36766. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36767. /**
  36768. * Interpolates a Vector2 linearly
  36769. * @param startValue Start value of the animation curve
  36770. * @param endValue End value of the animation curve
  36771. * @param gradient Scalar amount to interpolate
  36772. * @returns Interpolated Vector2 value
  36773. */
  36774. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36775. /**
  36776. * Interpolates a Vector2 cubically
  36777. * @param startValue Start value of the animation curve
  36778. * @param outTangent End tangent of the animation
  36779. * @param endValue End value of the animation curve
  36780. * @param inTangent Start tangent of the animation curve
  36781. * @param gradient Scalar amount to interpolate
  36782. * @returns Interpolated Vector2 value
  36783. */
  36784. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36785. /**
  36786. * Interpolates a size linearly
  36787. * @param startValue Start value of the animation curve
  36788. * @param endValue End value of the animation curve
  36789. * @param gradient Scalar amount to interpolate
  36790. * @returns Interpolated Size value
  36791. */
  36792. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36793. /**
  36794. * Interpolates a Color3 linearly
  36795. * @param startValue Start value of the animation curve
  36796. * @param endValue End value of the animation curve
  36797. * @param gradient Scalar amount to interpolate
  36798. * @returns Interpolated Color3 value
  36799. */
  36800. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36801. /**
  36802. * Interpolates a Color4 linearly
  36803. * @param startValue Start value of the animation curve
  36804. * @param endValue End value of the animation curve
  36805. * @param gradient Scalar amount to interpolate
  36806. * @returns Interpolated Color3 value
  36807. */
  36808. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36809. /**
  36810. * @hidden Internal use only
  36811. */
  36812. _getKeyValue(value: any): any;
  36813. /**
  36814. * @hidden Internal use only
  36815. */
  36816. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36817. /**
  36818. * Defines the function to use to interpolate matrices
  36819. * @param startValue defines the start matrix
  36820. * @param endValue defines the end matrix
  36821. * @param gradient defines the gradient between both matrices
  36822. * @param result defines an optional target matrix where to store the interpolation
  36823. * @returns the interpolated matrix
  36824. */
  36825. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36826. /**
  36827. * Makes a copy of the animation
  36828. * @returns Cloned animation
  36829. */
  36830. clone(): Animation;
  36831. /**
  36832. * Sets the key frames of the animation
  36833. * @param values The animation key frames to set
  36834. */
  36835. setKeys(values: Array<IAnimationKey>): void;
  36836. /**
  36837. * Serializes the animation to an object
  36838. * @returns Serialized object
  36839. */
  36840. serialize(): any;
  36841. /**
  36842. * Float animation type
  36843. */
  36844. static readonly ANIMATIONTYPE_FLOAT: number;
  36845. /**
  36846. * Vector3 animation type
  36847. */
  36848. static readonly ANIMATIONTYPE_VECTOR3: number;
  36849. /**
  36850. * Quaternion animation type
  36851. */
  36852. static readonly ANIMATIONTYPE_QUATERNION: number;
  36853. /**
  36854. * Matrix animation type
  36855. */
  36856. static readonly ANIMATIONTYPE_MATRIX: number;
  36857. /**
  36858. * Color3 animation type
  36859. */
  36860. static readonly ANIMATIONTYPE_COLOR3: number;
  36861. /**
  36862. * Color3 animation type
  36863. */
  36864. static readonly ANIMATIONTYPE_COLOR4: number;
  36865. /**
  36866. * Vector2 animation type
  36867. */
  36868. static readonly ANIMATIONTYPE_VECTOR2: number;
  36869. /**
  36870. * Size animation type
  36871. */
  36872. static readonly ANIMATIONTYPE_SIZE: number;
  36873. /**
  36874. * Relative Loop Mode
  36875. */
  36876. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36877. /**
  36878. * Cycle Loop Mode
  36879. */
  36880. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36881. /**
  36882. * Constant Loop Mode
  36883. */
  36884. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36885. /** @hidden */
  36886. static _UniversalLerp(left: any, right: any, amount: number): any;
  36887. /**
  36888. * Parses an animation object and creates an animation
  36889. * @param parsedAnimation Parsed animation object
  36890. * @returns Animation object
  36891. */
  36892. static Parse(parsedAnimation: any): Animation;
  36893. /**
  36894. * Appends the serialized animations from the source animations
  36895. * @param source Source containing the animations
  36896. * @param destination Target to store the animations
  36897. */
  36898. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36899. /**
  36900. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36901. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36902. * @param url defines the url to load from
  36903. * @returns a promise that will resolve to the new animation or an array of animations
  36904. */
  36905. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36906. /**
  36907. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36908. * @param snippetId defines the snippet to load
  36909. * @returns a promise that will resolve to the new animation or a new array of animations
  36910. */
  36911. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36912. }
  36913. }
  36914. declare module BABYLON {
  36915. /**
  36916. * Interface containing an array of animations
  36917. */
  36918. export interface IAnimatable {
  36919. /**
  36920. * Array of animations
  36921. */
  36922. animations: Nullable<Array<Animation>>;
  36923. }
  36924. }
  36925. declare module BABYLON {
  36926. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36927. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36928. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36929. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36930. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36931. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36932. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36933. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36934. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36935. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36936. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36937. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36938. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36939. /**
  36940. * Decorator used to define property that can be serialized as reference to a camera
  36941. * @param sourceName defines the name of the property to decorate
  36942. */
  36943. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36944. /**
  36945. * Class used to help serialization objects
  36946. */
  36947. export class SerializationHelper {
  36948. /** @hidden */
  36949. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36950. /** @hidden */
  36951. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36952. /** @hidden */
  36953. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36954. /** @hidden */
  36955. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36956. /**
  36957. * Appends the serialized animations from the source animations
  36958. * @param source Source containing the animations
  36959. * @param destination Target to store the animations
  36960. */
  36961. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36962. /**
  36963. * Static function used to serialized a specific entity
  36964. * @param entity defines the entity to serialize
  36965. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36966. * @returns a JSON compatible object representing the serialization of the entity
  36967. */
  36968. static Serialize<T>(entity: T, serializationObject?: any): any;
  36969. /**
  36970. * Creates a new entity from a serialization data object
  36971. * @param creationFunction defines a function used to instanciated the new entity
  36972. * @param source defines the source serialization data
  36973. * @param scene defines the hosting scene
  36974. * @param rootUrl defines the root url for resources
  36975. * @returns a new entity
  36976. */
  36977. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  36978. /**
  36979. * Clones an object
  36980. * @param creationFunction defines the function used to instanciate the new object
  36981. * @param source defines the source object
  36982. * @returns the cloned object
  36983. */
  36984. static Clone<T>(creationFunction: () => T, source: T): T;
  36985. /**
  36986. * Instanciates a new object based on a source one (some data will be shared between both object)
  36987. * @param creationFunction defines the function used to instanciate the new object
  36988. * @param source defines the source object
  36989. * @returns the new object
  36990. */
  36991. static Instanciate<T>(creationFunction: () => T, source: T): T;
  36992. }
  36993. }
  36994. declare module BABYLON {
  36995. /**
  36996. * Base class of all the textures in babylon.
  36997. * It groups all the common properties the materials, post process, lights... might need
  36998. * in order to make a correct use of the texture.
  36999. */
  37000. export class BaseTexture implements IAnimatable {
  37001. /**
  37002. * Default anisotropic filtering level for the application.
  37003. * It is set to 4 as a good tradeoff between perf and quality.
  37004. */
  37005. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37006. /**
  37007. * Gets or sets the unique id of the texture
  37008. */
  37009. uniqueId: number;
  37010. /**
  37011. * Define the name of the texture.
  37012. */
  37013. name: string;
  37014. /**
  37015. * Gets or sets an object used to store user defined information.
  37016. */
  37017. metadata: any;
  37018. /**
  37019. * For internal use only. Please do not use.
  37020. */
  37021. reservedDataStore: any;
  37022. private _hasAlpha;
  37023. /**
  37024. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  37025. */
  37026. set hasAlpha(value: boolean);
  37027. get hasAlpha(): boolean;
  37028. /**
  37029. * Defines if the alpha value should be determined via the rgb values.
  37030. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  37031. */
  37032. getAlphaFromRGB: boolean;
  37033. /**
  37034. * Intensity or strength of the texture.
  37035. * It is commonly used by materials to fine tune the intensity of the texture
  37036. */
  37037. level: number;
  37038. /**
  37039. * Define the UV chanel to use starting from 0 and defaulting to 0.
  37040. * This is part of the texture as textures usually maps to one uv set.
  37041. */
  37042. coordinatesIndex: number;
  37043. protected _coordinatesMode: number;
  37044. /**
  37045. * How a texture is mapped.
  37046. *
  37047. * | Value | Type | Description |
  37048. * | ----- | ----------------------------------- | ----------- |
  37049. * | 0 | EXPLICIT_MODE | |
  37050. * | 1 | SPHERICAL_MODE | |
  37051. * | 2 | PLANAR_MODE | |
  37052. * | 3 | CUBIC_MODE | |
  37053. * | 4 | PROJECTION_MODE | |
  37054. * | 5 | SKYBOX_MODE | |
  37055. * | 6 | INVCUBIC_MODE | |
  37056. * | 7 | EQUIRECTANGULAR_MODE | |
  37057. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37058. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37059. */
  37060. set coordinatesMode(value: number);
  37061. get coordinatesMode(): number;
  37062. private _wrapU;
  37063. /**
  37064. * | Value | Type | Description |
  37065. * | ----- | ------------------ | ----------- |
  37066. * | 0 | CLAMP_ADDRESSMODE | |
  37067. * | 1 | WRAP_ADDRESSMODE | |
  37068. * | 2 | MIRROR_ADDRESSMODE | |
  37069. */
  37070. get wrapU(): number;
  37071. set wrapU(value: number);
  37072. private _wrapV;
  37073. /**
  37074. * | Value | Type | Description |
  37075. * | ----- | ------------------ | ----------- |
  37076. * | 0 | CLAMP_ADDRESSMODE | |
  37077. * | 1 | WRAP_ADDRESSMODE | |
  37078. * | 2 | MIRROR_ADDRESSMODE | |
  37079. */
  37080. get wrapV(): number;
  37081. set wrapV(value: number);
  37082. /**
  37083. * | Value | Type | Description |
  37084. * | ----- | ------------------ | ----------- |
  37085. * | 0 | CLAMP_ADDRESSMODE | |
  37086. * | 1 | WRAP_ADDRESSMODE | |
  37087. * | 2 | MIRROR_ADDRESSMODE | |
  37088. */
  37089. wrapR: number;
  37090. /**
  37091. * With compliant hardware and browser (supporting anisotropic filtering)
  37092. * this defines the level of anisotropic filtering in the texture.
  37093. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  37094. */
  37095. anisotropicFilteringLevel: number;
  37096. /**
  37097. * Define if the texture is a cube texture or if false a 2d texture.
  37098. */
  37099. get isCube(): boolean;
  37100. set isCube(value: boolean);
  37101. /**
  37102. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  37103. */
  37104. get is3D(): boolean;
  37105. set is3D(value: boolean);
  37106. /**
  37107. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  37108. */
  37109. get is2DArray(): boolean;
  37110. set is2DArray(value: boolean);
  37111. private _gammaSpace;
  37112. /**
  37113. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  37114. * HDR texture are usually stored in linear space.
  37115. * This only impacts the PBR and Background materials
  37116. */
  37117. get gammaSpace(): boolean;
  37118. set gammaSpace(gamma: boolean);
  37119. /**
  37120. * Gets or sets whether or not the texture contains RGBD data.
  37121. */
  37122. get isRGBD(): boolean;
  37123. set isRGBD(value: boolean);
  37124. /**
  37125. * Is Z inverted in the texture (useful in a cube texture).
  37126. */
  37127. invertZ: boolean;
  37128. /**
  37129. * Are mip maps generated for this texture or not.
  37130. */
  37131. get noMipmap(): boolean;
  37132. /**
  37133. * @hidden
  37134. */
  37135. lodLevelInAlpha: boolean;
  37136. /**
  37137. * With prefiltered texture, defined the offset used during the prefiltering steps.
  37138. */
  37139. get lodGenerationOffset(): number;
  37140. set lodGenerationOffset(value: number);
  37141. /**
  37142. * With prefiltered texture, defined the scale used during the prefiltering steps.
  37143. */
  37144. get lodGenerationScale(): number;
  37145. set lodGenerationScale(value: number);
  37146. /**
  37147. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  37148. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  37149. * average roughness values.
  37150. */
  37151. get linearSpecularLOD(): boolean;
  37152. set linearSpecularLOD(value: boolean);
  37153. /**
  37154. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  37155. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  37156. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  37157. */
  37158. get irradianceTexture(): Nullable<BaseTexture>;
  37159. set irradianceTexture(value: Nullable<BaseTexture>);
  37160. /**
  37161. * Define if the texture is a render target.
  37162. */
  37163. isRenderTarget: boolean;
  37164. /**
  37165. * Define the unique id of the texture in the scene.
  37166. */
  37167. get uid(): string;
  37168. /** @hidden */
  37169. _prefiltered: boolean;
  37170. /**
  37171. * Return a string representation of the texture.
  37172. * @returns the texture as a string
  37173. */
  37174. toString(): string;
  37175. /**
  37176. * Get the class name of the texture.
  37177. * @returns "BaseTexture"
  37178. */
  37179. getClassName(): string;
  37180. /**
  37181. * Define the list of animation attached to the texture.
  37182. */
  37183. animations: Animation[];
  37184. /**
  37185. * An event triggered when the texture is disposed.
  37186. */
  37187. onDisposeObservable: Observable<BaseTexture>;
  37188. private _onDisposeObserver;
  37189. /**
  37190. * Callback triggered when the texture has been disposed.
  37191. * Kept for back compatibility, you can use the onDisposeObservable instead.
  37192. */
  37193. set onDispose(callback: () => void);
  37194. /**
  37195. * Define the current state of the loading sequence when in delayed load mode.
  37196. */
  37197. delayLoadState: number;
  37198. protected _scene: Nullable<Scene>;
  37199. protected _engine: Nullable<ThinEngine>;
  37200. /** @hidden */
  37201. _texture: Nullable<InternalTexture>;
  37202. private _uid;
  37203. /**
  37204. * Define if the texture is preventinga material to render or not.
  37205. * If not and the texture is not ready, the engine will use a default black texture instead.
  37206. */
  37207. get isBlocking(): boolean;
  37208. /**
  37209. * Instantiates a new BaseTexture.
  37210. * Base class of all the textures in babylon.
  37211. * It groups all the common properties the materials, post process, lights... might need
  37212. * in order to make a correct use of the texture.
  37213. * @param sceneOrEngine Define the scene or engine the texture blongs to
  37214. */
  37215. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  37216. /**
  37217. * Get the scene the texture belongs to.
  37218. * @returns the scene or null if undefined
  37219. */
  37220. getScene(): Nullable<Scene>;
  37221. /** @hidden */
  37222. protected _getEngine(): Nullable<ThinEngine>;
  37223. /**
  37224. * Checks if the texture has the same transform matrix than another texture
  37225. * @param texture texture to check against
  37226. * @returns true if the transforms are the same, else false
  37227. */
  37228. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  37229. /**
  37230. * Get the texture transform matrix used to offset tile the texture for istance.
  37231. * @returns the transformation matrix
  37232. */
  37233. getTextureMatrix(): Matrix;
  37234. /**
  37235. * Get the texture reflection matrix used to rotate/transform the reflection.
  37236. * @returns the reflection matrix
  37237. */
  37238. getReflectionTextureMatrix(): Matrix;
  37239. /**
  37240. * Get the underlying lower level texture from Babylon.
  37241. * @returns the insternal texture
  37242. */
  37243. getInternalTexture(): Nullable<InternalTexture>;
  37244. /**
  37245. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  37246. * @returns true if ready or not blocking
  37247. */
  37248. isReadyOrNotBlocking(): boolean;
  37249. /**
  37250. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  37251. * @returns true if fully ready
  37252. */
  37253. isReady(): boolean;
  37254. private _cachedSize;
  37255. /**
  37256. * Get the size of the texture.
  37257. * @returns the texture size.
  37258. */
  37259. getSize(): ISize;
  37260. /**
  37261. * Get the base size of the texture.
  37262. * It can be different from the size if the texture has been resized for POT for instance
  37263. * @returns the base size
  37264. */
  37265. getBaseSize(): ISize;
  37266. /**
  37267. * Update the sampling mode of the texture.
  37268. * Default is Trilinear mode.
  37269. *
  37270. * | Value | Type | Description |
  37271. * | ----- | ------------------ | ----------- |
  37272. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37273. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37274. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37275. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37276. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37277. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37278. * | 7 | NEAREST_LINEAR | |
  37279. * | 8 | NEAREST_NEAREST | |
  37280. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37281. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37282. * | 11 | LINEAR_LINEAR | |
  37283. * | 12 | LINEAR_NEAREST | |
  37284. *
  37285. * > _mag_: magnification filter (close to the viewer)
  37286. * > _min_: minification filter (far from the viewer)
  37287. * > _mip_: filter used between mip map levels
  37288. *@param samplingMode Define the new sampling mode of the texture
  37289. */
  37290. updateSamplingMode(samplingMode: number): void;
  37291. /**
  37292. * Scales the texture if is `canRescale()`
  37293. * @param ratio the resize factor we want to use to rescale
  37294. */
  37295. scale(ratio: number): void;
  37296. /**
  37297. * Get if the texture can rescale.
  37298. */
  37299. get canRescale(): boolean;
  37300. /** @hidden */
  37301. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  37302. /** @hidden */
  37303. _rebuild(): void;
  37304. /**
  37305. * Triggers the load sequence in delayed load mode.
  37306. */
  37307. delayLoad(): void;
  37308. /**
  37309. * Clones the texture.
  37310. * @returns the cloned texture
  37311. */
  37312. clone(): Nullable<BaseTexture>;
  37313. /**
  37314. * Get the texture underlying type (INT, FLOAT...)
  37315. */
  37316. get textureType(): number;
  37317. /**
  37318. * Get the texture underlying format (RGB, RGBA...)
  37319. */
  37320. get textureFormat(): number;
  37321. /**
  37322. * Indicates that textures need to be re-calculated for all materials
  37323. */
  37324. protected _markAllSubMeshesAsTexturesDirty(): void;
  37325. /**
  37326. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37327. * This will returns an RGBA array buffer containing either in values (0-255) or
  37328. * float values (0-1) depending of the underlying buffer type.
  37329. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  37330. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  37331. * @param buffer defines a user defined buffer to fill with data (can be null)
  37332. * @returns The Array buffer containing the pixels data.
  37333. */
  37334. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  37335. /**
  37336. * Release and destroy the underlying lower level texture aka internalTexture.
  37337. */
  37338. releaseInternalTexture(): void;
  37339. /** @hidden */
  37340. get _lodTextureHigh(): Nullable<BaseTexture>;
  37341. /** @hidden */
  37342. get _lodTextureMid(): Nullable<BaseTexture>;
  37343. /** @hidden */
  37344. get _lodTextureLow(): Nullable<BaseTexture>;
  37345. /**
  37346. * Dispose the texture and release its associated resources.
  37347. */
  37348. dispose(): void;
  37349. /**
  37350. * Serialize the texture into a JSON representation that can be parsed later on.
  37351. * @returns the JSON representation of the texture
  37352. */
  37353. serialize(): any;
  37354. /**
  37355. * Helper function to be called back once a list of texture contains only ready textures.
  37356. * @param textures Define the list of textures to wait for
  37357. * @param callback Define the callback triggered once the entire list will be ready
  37358. */
  37359. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37360. private static _isScene;
  37361. }
  37362. }
  37363. declare module BABYLON {
  37364. /**
  37365. * Options to be used when creating an effect.
  37366. */
  37367. export interface IEffectCreationOptions {
  37368. /**
  37369. * Atrributes that will be used in the shader.
  37370. */
  37371. attributes: string[];
  37372. /**
  37373. * Uniform varible names that will be set in the shader.
  37374. */
  37375. uniformsNames: string[];
  37376. /**
  37377. * Uniform buffer variable names that will be set in the shader.
  37378. */
  37379. uniformBuffersNames: string[];
  37380. /**
  37381. * Sampler texture variable names that will be set in the shader.
  37382. */
  37383. samplers: string[];
  37384. /**
  37385. * Define statements that will be set in the shader.
  37386. */
  37387. defines: any;
  37388. /**
  37389. * Possible fallbacks for this effect to improve performance when needed.
  37390. */
  37391. fallbacks: Nullable<IEffectFallbacks>;
  37392. /**
  37393. * Callback that will be called when the shader is compiled.
  37394. */
  37395. onCompiled: Nullable<(effect: Effect) => void>;
  37396. /**
  37397. * Callback that will be called if an error occurs during shader compilation.
  37398. */
  37399. onError: Nullable<(effect: Effect, errors: string) => void>;
  37400. /**
  37401. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37402. */
  37403. indexParameters?: any;
  37404. /**
  37405. * Max number of lights that can be used in the shader.
  37406. */
  37407. maxSimultaneousLights?: number;
  37408. /**
  37409. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37410. */
  37411. transformFeedbackVaryings?: Nullable<string[]>;
  37412. /**
  37413. * 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
  37414. */
  37415. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37416. /**
  37417. * Is this effect rendering to several color attachments ?
  37418. */
  37419. multiTarget?: boolean;
  37420. }
  37421. /**
  37422. * Effect containing vertex and fragment shader that can be executed on an object.
  37423. */
  37424. export class Effect implements IDisposable {
  37425. /**
  37426. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37427. */
  37428. static ShadersRepository: string;
  37429. /**
  37430. * Enable logging of the shader code when a compilation error occurs
  37431. */
  37432. static LogShaderCodeOnCompilationError: boolean;
  37433. /**
  37434. * Name of the effect.
  37435. */
  37436. name: any;
  37437. /**
  37438. * String container all the define statements that should be set on the shader.
  37439. */
  37440. defines: string;
  37441. /**
  37442. * Callback that will be called when the shader is compiled.
  37443. */
  37444. onCompiled: Nullable<(effect: Effect) => void>;
  37445. /**
  37446. * Callback that will be called if an error occurs during shader compilation.
  37447. */
  37448. onError: Nullable<(effect: Effect, errors: string) => void>;
  37449. /**
  37450. * Callback that will be called when effect is bound.
  37451. */
  37452. onBind: Nullable<(effect: Effect) => void>;
  37453. /**
  37454. * Unique ID of the effect.
  37455. */
  37456. uniqueId: number;
  37457. /**
  37458. * Observable that will be called when the shader is compiled.
  37459. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37460. */
  37461. onCompileObservable: Observable<Effect>;
  37462. /**
  37463. * Observable that will be called if an error occurs during shader compilation.
  37464. */
  37465. onErrorObservable: Observable<Effect>;
  37466. /** @hidden */
  37467. _onBindObservable: Nullable<Observable<Effect>>;
  37468. /**
  37469. * @hidden
  37470. * Specifies if the effect was previously ready
  37471. */
  37472. _wasPreviouslyReady: boolean;
  37473. /**
  37474. * Observable that will be called when effect is bound.
  37475. */
  37476. get onBindObservable(): Observable<Effect>;
  37477. /** @hidden */
  37478. _bonesComputationForcedToCPU: boolean;
  37479. /** @hidden */
  37480. _multiTarget: boolean;
  37481. private static _uniqueIdSeed;
  37482. private _engine;
  37483. private _uniformBuffersNames;
  37484. private _uniformBuffersNamesList;
  37485. private _uniformsNames;
  37486. private _samplerList;
  37487. private _samplers;
  37488. private _isReady;
  37489. private _compilationError;
  37490. private _allFallbacksProcessed;
  37491. private _attributesNames;
  37492. private _attributes;
  37493. private _attributeLocationByName;
  37494. private _uniforms;
  37495. /**
  37496. * Key for the effect.
  37497. * @hidden
  37498. */
  37499. _key: string;
  37500. private _indexParameters;
  37501. private _fallbacks;
  37502. private _vertexSourceCode;
  37503. private _fragmentSourceCode;
  37504. private _vertexSourceCodeOverride;
  37505. private _fragmentSourceCodeOverride;
  37506. private _transformFeedbackVaryings;
  37507. /**
  37508. * Compiled shader to webGL program.
  37509. * @hidden
  37510. */
  37511. _pipelineContext: Nullable<IPipelineContext>;
  37512. private _valueCache;
  37513. private static _baseCache;
  37514. /**
  37515. * Instantiates an effect.
  37516. * An effect can be used to create/manage/execute vertex and fragment shaders.
  37517. * @param baseName Name of the effect.
  37518. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  37519. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  37520. * @param samplers List of sampler variables that will be passed to the shader.
  37521. * @param engine Engine to be used to render the effect
  37522. * @param defines Define statements to be added to the shader.
  37523. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  37524. * @param onCompiled Callback that will be called when the shader is compiled.
  37525. * @param onError Callback that will be called if an error occurs during shader compilation.
  37526. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37527. */
  37528. 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);
  37529. private _useFinalCode;
  37530. /**
  37531. * Unique key for this effect
  37532. */
  37533. get key(): string;
  37534. /**
  37535. * If the effect has been compiled and prepared.
  37536. * @returns if the effect is compiled and prepared.
  37537. */
  37538. isReady(): boolean;
  37539. private _isReadyInternal;
  37540. /**
  37541. * The engine the effect was initialized with.
  37542. * @returns the engine.
  37543. */
  37544. getEngine(): Engine;
  37545. /**
  37546. * The pipeline context for this effect
  37547. * @returns the associated pipeline context
  37548. */
  37549. getPipelineContext(): Nullable<IPipelineContext>;
  37550. /**
  37551. * The set of names of attribute variables for the shader.
  37552. * @returns An array of attribute names.
  37553. */
  37554. getAttributesNames(): string[];
  37555. /**
  37556. * Returns the attribute at the given index.
  37557. * @param index The index of the attribute.
  37558. * @returns The location of the attribute.
  37559. */
  37560. getAttributeLocation(index: number): number;
  37561. /**
  37562. * Returns the attribute based on the name of the variable.
  37563. * @param name of the attribute to look up.
  37564. * @returns the attribute location.
  37565. */
  37566. getAttributeLocationByName(name: string): number;
  37567. /**
  37568. * The number of attributes.
  37569. * @returns the numnber of attributes.
  37570. */
  37571. getAttributesCount(): number;
  37572. /**
  37573. * Gets the index of a uniform variable.
  37574. * @param uniformName of the uniform to look up.
  37575. * @returns the index.
  37576. */
  37577. getUniformIndex(uniformName: string): number;
  37578. /**
  37579. * Returns the attribute based on the name of the variable.
  37580. * @param uniformName of the uniform to look up.
  37581. * @returns the location of the uniform.
  37582. */
  37583. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  37584. /**
  37585. * Returns an array of sampler variable names
  37586. * @returns The array of sampler variable names.
  37587. */
  37588. getSamplers(): string[];
  37589. /**
  37590. * Returns an array of uniform variable names
  37591. * @returns The array of uniform variable names.
  37592. */
  37593. getUniformNames(): string[];
  37594. /**
  37595. * Returns an array of uniform buffer variable names
  37596. * @returns The array of uniform buffer variable names.
  37597. */
  37598. getUniformBuffersNames(): string[];
  37599. /**
  37600. * Returns the index parameters used to create the effect
  37601. * @returns The index parameters object
  37602. */
  37603. getIndexParameters(): any;
  37604. /**
  37605. * The error from the last compilation.
  37606. * @returns the error string.
  37607. */
  37608. getCompilationError(): string;
  37609. /**
  37610. * Gets a boolean indicating that all fallbacks were used during compilation
  37611. * @returns true if all fallbacks were used
  37612. */
  37613. allFallbacksProcessed(): boolean;
  37614. /**
  37615. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  37616. * @param func The callback to be used.
  37617. */
  37618. executeWhenCompiled(func: (effect: Effect) => void): void;
  37619. private _checkIsReady;
  37620. private _loadShader;
  37621. /**
  37622. * Gets the vertex shader source code of this effect
  37623. */
  37624. get vertexSourceCode(): string;
  37625. /**
  37626. * Gets the fragment shader source code of this effect
  37627. */
  37628. get fragmentSourceCode(): string;
  37629. /**
  37630. * Recompiles the webGL program
  37631. * @param vertexSourceCode The source code for the vertex shader.
  37632. * @param fragmentSourceCode The source code for the fragment shader.
  37633. * @param onCompiled Callback called when completed.
  37634. * @param onError Callback called on error.
  37635. * @hidden
  37636. */
  37637. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  37638. /**
  37639. * Prepares the effect
  37640. * @hidden
  37641. */
  37642. _prepareEffect(): void;
  37643. private _getShaderCodeAndErrorLine;
  37644. private _processCompilationErrors;
  37645. /**
  37646. * Checks if the effect is supported. (Must be called after compilation)
  37647. */
  37648. get isSupported(): boolean;
  37649. /**
  37650. * Binds a texture to the engine to be used as output of the shader.
  37651. * @param channel Name of the output variable.
  37652. * @param texture Texture to bind.
  37653. * @hidden
  37654. */
  37655. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  37656. /**
  37657. * Sets a texture on the engine to be used in the shader.
  37658. * @param channel Name of the sampler variable.
  37659. * @param texture Texture to set.
  37660. */
  37661. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  37662. /**
  37663. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  37664. * @param channel Name of the sampler variable.
  37665. * @param texture Texture to set.
  37666. */
  37667. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  37668. /**
  37669. * Sets an array of textures on the engine to be used in the shader.
  37670. * @param channel Name of the variable.
  37671. * @param textures Textures to set.
  37672. */
  37673. setTextureArray(channel: string, textures: BaseTexture[]): void;
  37674. /**
  37675. * 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)
  37676. * @param channel Name of the sampler variable.
  37677. * @param postProcess Post process to get the input texture from.
  37678. */
  37679. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  37680. /**
  37681. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  37682. * 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)
  37683. * @param channel Name of the sampler variable.
  37684. * @param postProcess Post process to get the output texture from.
  37685. */
  37686. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  37687. /** @hidden */
  37688. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  37689. /** @hidden */
  37690. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  37691. /** @hidden */
  37692. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  37693. /** @hidden */
  37694. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  37695. /**
  37696. * Binds a buffer to a uniform.
  37697. * @param buffer Buffer to bind.
  37698. * @param name Name of the uniform variable to bind to.
  37699. */
  37700. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  37701. /**
  37702. * Binds block to a uniform.
  37703. * @param blockName Name of the block to bind.
  37704. * @param index Index to bind.
  37705. */
  37706. bindUniformBlock(blockName: string, index: number): void;
  37707. /**
  37708. * Sets an interger value on a uniform variable.
  37709. * @param uniformName Name of the variable.
  37710. * @param value Value to be set.
  37711. * @returns this effect.
  37712. */
  37713. setInt(uniformName: string, value: number): Effect;
  37714. /**
  37715. * Sets an int array on a uniform variable.
  37716. * @param uniformName Name of the variable.
  37717. * @param array array to be set.
  37718. * @returns this effect.
  37719. */
  37720. setIntArray(uniformName: string, array: Int32Array): Effect;
  37721. /**
  37722. * 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)
  37723. * @param uniformName Name of the variable.
  37724. * @param array array to be set.
  37725. * @returns this effect.
  37726. */
  37727. setIntArray2(uniformName: string, array: Int32Array): Effect;
  37728. /**
  37729. * 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)
  37730. * @param uniformName Name of the variable.
  37731. * @param array array to be set.
  37732. * @returns this effect.
  37733. */
  37734. setIntArray3(uniformName: string, array: Int32Array): Effect;
  37735. /**
  37736. * 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)
  37737. * @param uniformName Name of the variable.
  37738. * @param array array to be set.
  37739. * @returns this effect.
  37740. */
  37741. setIntArray4(uniformName: string, array: Int32Array): Effect;
  37742. /**
  37743. * Sets an float array on a uniform variable.
  37744. * @param uniformName Name of the variable.
  37745. * @param array array to be set.
  37746. * @returns this effect.
  37747. */
  37748. setFloatArray(uniformName: string, array: Float32Array): Effect;
  37749. /**
  37750. * 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)
  37751. * @param uniformName Name of the variable.
  37752. * @param array array to be set.
  37753. * @returns this effect.
  37754. */
  37755. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  37756. /**
  37757. * 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)
  37758. * @param uniformName Name of the variable.
  37759. * @param array array to be set.
  37760. * @returns this effect.
  37761. */
  37762. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  37763. /**
  37764. * 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)
  37765. * @param uniformName Name of the variable.
  37766. * @param array array to be set.
  37767. * @returns this effect.
  37768. */
  37769. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  37770. /**
  37771. * Sets an array on a uniform variable.
  37772. * @param uniformName Name of the variable.
  37773. * @param array array to be set.
  37774. * @returns this effect.
  37775. */
  37776. setArray(uniformName: string, array: number[]): Effect;
  37777. /**
  37778. * 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)
  37779. * @param uniformName Name of the variable.
  37780. * @param array array to be set.
  37781. * @returns this effect.
  37782. */
  37783. setArray2(uniformName: string, array: number[]): Effect;
  37784. /**
  37785. * 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)
  37786. * @param uniformName Name of the variable.
  37787. * @param array array to be set.
  37788. * @returns this effect.
  37789. */
  37790. setArray3(uniformName: string, array: number[]): Effect;
  37791. /**
  37792. * 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)
  37793. * @param uniformName Name of the variable.
  37794. * @param array array to be set.
  37795. * @returns this effect.
  37796. */
  37797. setArray4(uniformName: string, array: number[]): Effect;
  37798. /**
  37799. * Sets matrices on a uniform variable.
  37800. * @param uniformName Name of the variable.
  37801. * @param matrices matrices to be set.
  37802. * @returns this effect.
  37803. */
  37804. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  37805. /**
  37806. * Sets matrix on a uniform variable.
  37807. * @param uniformName Name of the variable.
  37808. * @param matrix matrix to be set.
  37809. * @returns this effect.
  37810. */
  37811. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  37812. /**
  37813. * 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)
  37814. * @param uniformName Name of the variable.
  37815. * @param matrix matrix to be set.
  37816. * @returns this effect.
  37817. */
  37818. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  37819. /**
  37820. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  37821. * @param uniformName Name of the variable.
  37822. * @param matrix matrix to be set.
  37823. * @returns this effect.
  37824. */
  37825. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  37826. /**
  37827. * Sets a float on a uniform variable.
  37828. * @param uniformName Name of the variable.
  37829. * @param value value to be set.
  37830. * @returns this effect.
  37831. */
  37832. setFloat(uniformName: string, value: number): Effect;
  37833. /**
  37834. * Sets a boolean on a uniform variable.
  37835. * @param uniformName Name of the variable.
  37836. * @param bool value to be set.
  37837. * @returns this effect.
  37838. */
  37839. setBool(uniformName: string, bool: boolean): Effect;
  37840. /**
  37841. * Sets a Vector2 on a uniform variable.
  37842. * @param uniformName Name of the variable.
  37843. * @param vector2 vector2 to be set.
  37844. * @returns this effect.
  37845. */
  37846. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  37847. /**
  37848. * Sets a float2 on a uniform variable.
  37849. * @param uniformName Name of the variable.
  37850. * @param x First float in float2.
  37851. * @param y Second float in float2.
  37852. * @returns this effect.
  37853. */
  37854. setFloat2(uniformName: string, x: number, y: number): Effect;
  37855. /**
  37856. * Sets a Vector3 on a uniform variable.
  37857. * @param uniformName Name of the variable.
  37858. * @param vector3 Value to be set.
  37859. * @returns this effect.
  37860. */
  37861. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  37862. /**
  37863. * Sets a float3 on a uniform variable.
  37864. * @param uniformName Name of the variable.
  37865. * @param x First float in float3.
  37866. * @param y Second float in float3.
  37867. * @param z Third float in float3.
  37868. * @returns this effect.
  37869. */
  37870. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  37871. /**
  37872. * Sets a Vector4 on a uniform variable.
  37873. * @param uniformName Name of the variable.
  37874. * @param vector4 Value to be set.
  37875. * @returns this effect.
  37876. */
  37877. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  37878. /**
  37879. * Sets a float4 on a uniform variable.
  37880. * @param uniformName Name of the variable.
  37881. * @param x First float in float4.
  37882. * @param y Second float in float4.
  37883. * @param z Third float in float4.
  37884. * @param w Fourth float in float4.
  37885. * @returns this effect.
  37886. */
  37887. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  37888. /**
  37889. * Sets a Color3 on a uniform variable.
  37890. * @param uniformName Name of the variable.
  37891. * @param color3 Value to be set.
  37892. * @returns this effect.
  37893. */
  37894. setColor3(uniformName: string, color3: IColor3Like): Effect;
  37895. /**
  37896. * Sets a Color4 on a uniform variable.
  37897. * @param uniformName Name of the variable.
  37898. * @param color3 Value to be set.
  37899. * @param alpha Alpha value to be set.
  37900. * @returns this effect.
  37901. */
  37902. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  37903. /**
  37904. * Sets a Color4 on a uniform variable
  37905. * @param uniformName defines the name of the variable
  37906. * @param color4 defines the value to be set
  37907. * @returns this effect.
  37908. */
  37909. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  37910. /** Release all associated resources */
  37911. dispose(): void;
  37912. /**
  37913. * This function will add a new shader to the shader store
  37914. * @param name the name of the shader
  37915. * @param pixelShader optional pixel shader content
  37916. * @param vertexShader optional vertex shader content
  37917. */
  37918. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  37919. /**
  37920. * Store of each shader (The can be looked up using effect.key)
  37921. */
  37922. static ShadersStore: {
  37923. [key: string]: string;
  37924. };
  37925. /**
  37926. * Store of each included file for a shader (The can be looked up using effect.key)
  37927. */
  37928. static IncludesShadersStore: {
  37929. [key: string]: string;
  37930. };
  37931. /**
  37932. * Resets the cache of effects.
  37933. */
  37934. static ResetCache(): void;
  37935. }
  37936. }
  37937. declare module BABYLON {
  37938. /**
  37939. * Interface used to describe the capabilities of the engine relatively to the current browser
  37940. */
  37941. export interface EngineCapabilities {
  37942. /** Maximum textures units per fragment shader */
  37943. maxTexturesImageUnits: number;
  37944. /** Maximum texture units per vertex shader */
  37945. maxVertexTextureImageUnits: number;
  37946. /** Maximum textures units in the entire pipeline */
  37947. maxCombinedTexturesImageUnits: number;
  37948. /** Maximum texture size */
  37949. maxTextureSize: number;
  37950. /** Maximum texture samples */
  37951. maxSamples?: number;
  37952. /** Maximum cube texture size */
  37953. maxCubemapTextureSize: number;
  37954. /** Maximum render texture size */
  37955. maxRenderTextureSize: number;
  37956. /** Maximum number of vertex attributes */
  37957. maxVertexAttribs: number;
  37958. /** Maximum number of varyings */
  37959. maxVaryingVectors: number;
  37960. /** Maximum number of uniforms per vertex shader */
  37961. maxVertexUniformVectors: number;
  37962. /** Maximum number of uniforms per fragment shader */
  37963. maxFragmentUniformVectors: number;
  37964. /** Defines if standard derivates (dx/dy) are supported */
  37965. standardDerivatives: boolean;
  37966. /** Defines if s3tc texture compression is supported */
  37967. s3tc?: WEBGL_compressed_texture_s3tc;
  37968. /** Defines if pvrtc texture compression is supported */
  37969. pvrtc: any;
  37970. /** Defines if etc1 texture compression is supported */
  37971. etc1: any;
  37972. /** Defines if etc2 texture compression is supported */
  37973. etc2: any;
  37974. /** Defines if astc texture compression is supported */
  37975. astc: any;
  37976. /** Defines if bptc texture compression is supported */
  37977. bptc: any;
  37978. /** Defines if float textures are supported */
  37979. textureFloat: boolean;
  37980. /** Defines if vertex array objects are supported */
  37981. vertexArrayObject: boolean;
  37982. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  37983. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  37984. /** Gets the maximum level of anisotropy supported */
  37985. maxAnisotropy: number;
  37986. /** Defines if instancing is supported */
  37987. instancedArrays: boolean;
  37988. /** Defines if 32 bits indices are supported */
  37989. uintIndices: boolean;
  37990. /** Defines if high precision shaders are supported */
  37991. highPrecisionShaderSupported: boolean;
  37992. /** Defines if depth reading in the fragment shader is supported */
  37993. fragmentDepthSupported: boolean;
  37994. /** Defines if float texture linear filtering is supported*/
  37995. textureFloatLinearFiltering: boolean;
  37996. /** Defines if rendering to float textures is supported */
  37997. textureFloatRender: boolean;
  37998. /** Defines if half float textures are supported*/
  37999. textureHalfFloat: boolean;
  38000. /** Defines if half float texture linear filtering is supported*/
  38001. textureHalfFloatLinearFiltering: boolean;
  38002. /** Defines if rendering to half float textures is supported */
  38003. textureHalfFloatRender: boolean;
  38004. /** Defines if textureLOD shader command is supported */
  38005. textureLOD: boolean;
  38006. /** Defines if draw buffers extension is supported */
  38007. drawBuffersExtension: boolean;
  38008. /** Defines if depth textures are supported */
  38009. depthTextureExtension: boolean;
  38010. /** Defines if float color buffer are supported */
  38011. colorBufferFloat: boolean;
  38012. /** Gets disjoint timer query extension (null if not supported) */
  38013. timerQuery?: EXT_disjoint_timer_query;
  38014. /** Defines if timestamp can be used with timer query */
  38015. canUseTimestampForTimerQuery: boolean;
  38016. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38017. multiview?: any;
  38018. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38019. oculusMultiview?: any;
  38020. /** Function used to let the system compiles shaders in background */
  38021. parallelShaderCompile?: {
  38022. COMPLETION_STATUS_KHR: number;
  38023. };
  38024. /** Max number of texture samples for MSAA */
  38025. maxMSAASamples: number;
  38026. /** Defines if the blend min max extension is supported */
  38027. blendMinMax: boolean;
  38028. }
  38029. }
  38030. declare module BABYLON {
  38031. /**
  38032. * @hidden
  38033. **/
  38034. export class DepthCullingState {
  38035. private _isDepthTestDirty;
  38036. private _isDepthMaskDirty;
  38037. private _isDepthFuncDirty;
  38038. private _isCullFaceDirty;
  38039. private _isCullDirty;
  38040. private _isZOffsetDirty;
  38041. private _isFrontFaceDirty;
  38042. private _depthTest;
  38043. private _depthMask;
  38044. private _depthFunc;
  38045. private _cull;
  38046. private _cullFace;
  38047. private _zOffset;
  38048. private _frontFace;
  38049. /**
  38050. * Initializes the state.
  38051. */
  38052. constructor();
  38053. get isDirty(): boolean;
  38054. get zOffset(): number;
  38055. set zOffset(value: number);
  38056. get cullFace(): Nullable<number>;
  38057. set cullFace(value: Nullable<number>);
  38058. get cull(): Nullable<boolean>;
  38059. set cull(value: Nullable<boolean>);
  38060. get depthFunc(): Nullable<number>;
  38061. set depthFunc(value: Nullable<number>);
  38062. get depthMask(): boolean;
  38063. set depthMask(value: boolean);
  38064. get depthTest(): boolean;
  38065. set depthTest(value: boolean);
  38066. get frontFace(): Nullable<number>;
  38067. set frontFace(value: Nullable<number>);
  38068. reset(): void;
  38069. apply(gl: WebGLRenderingContext): void;
  38070. }
  38071. }
  38072. declare module BABYLON {
  38073. /**
  38074. * @hidden
  38075. **/
  38076. export class StencilState {
  38077. /** 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 */
  38078. static readonly ALWAYS: number;
  38079. /** Passed to stencilOperation to specify that stencil value must be kept */
  38080. static readonly KEEP: number;
  38081. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38082. static readonly REPLACE: number;
  38083. private _isStencilTestDirty;
  38084. private _isStencilMaskDirty;
  38085. private _isStencilFuncDirty;
  38086. private _isStencilOpDirty;
  38087. private _stencilTest;
  38088. private _stencilMask;
  38089. private _stencilFunc;
  38090. private _stencilFuncRef;
  38091. private _stencilFuncMask;
  38092. private _stencilOpStencilFail;
  38093. private _stencilOpDepthFail;
  38094. private _stencilOpStencilDepthPass;
  38095. get isDirty(): boolean;
  38096. get stencilFunc(): number;
  38097. set stencilFunc(value: number);
  38098. get stencilFuncRef(): number;
  38099. set stencilFuncRef(value: number);
  38100. get stencilFuncMask(): number;
  38101. set stencilFuncMask(value: number);
  38102. get stencilOpStencilFail(): number;
  38103. set stencilOpStencilFail(value: number);
  38104. get stencilOpDepthFail(): number;
  38105. set stencilOpDepthFail(value: number);
  38106. get stencilOpStencilDepthPass(): number;
  38107. set stencilOpStencilDepthPass(value: number);
  38108. get stencilMask(): number;
  38109. set stencilMask(value: number);
  38110. get stencilTest(): boolean;
  38111. set stencilTest(value: boolean);
  38112. constructor();
  38113. reset(): void;
  38114. apply(gl: WebGLRenderingContext): void;
  38115. }
  38116. }
  38117. declare module BABYLON {
  38118. /**
  38119. * @hidden
  38120. **/
  38121. export class AlphaState {
  38122. private _isAlphaBlendDirty;
  38123. private _isBlendFunctionParametersDirty;
  38124. private _isBlendEquationParametersDirty;
  38125. private _isBlendConstantsDirty;
  38126. private _alphaBlend;
  38127. private _blendFunctionParameters;
  38128. private _blendEquationParameters;
  38129. private _blendConstants;
  38130. /**
  38131. * Initializes the state.
  38132. */
  38133. constructor();
  38134. get isDirty(): boolean;
  38135. get alphaBlend(): boolean;
  38136. set alphaBlend(value: boolean);
  38137. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38138. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38139. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38140. reset(): void;
  38141. apply(gl: WebGLRenderingContext): void;
  38142. }
  38143. }
  38144. declare module BABYLON {
  38145. /** @hidden */
  38146. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38147. attributeProcessor(attribute: string): string;
  38148. varyingProcessor(varying: string, isFragment: boolean): string;
  38149. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38150. }
  38151. }
  38152. declare module BABYLON {
  38153. /**
  38154. * Interface for attribute information associated with buffer instanciation
  38155. */
  38156. export interface InstancingAttributeInfo {
  38157. /**
  38158. * Name of the GLSL attribute
  38159. * if attribute index is not specified, this is used to retrieve the index from the effect
  38160. */
  38161. attributeName: string;
  38162. /**
  38163. * Index/offset of the attribute in the vertex shader
  38164. * if not specified, this will be computes from the name.
  38165. */
  38166. index?: number;
  38167. /**
  38168. * size of the attribute, 1, 2, 3 or 4
  38169. */
  38170. attributeSize: number;
  38171. /**
  38172. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38173. */
  38174. offset: number;
  38175. /**
  38176. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38177. * default to 1
  38178. */
  38179. divisor?: number;
  38180. /**
  38181. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38182. * default is FLOAT
  38183. */
  38184. attributeType?: number;
  38185. /**
  38186. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38187. */
  38188. normalized?: boolean;
  38189. }
  38190. }
  38191. declare module BABYLON {
  38192. interface ThinEngine {
  38193. /**
  38194. * Update a video texture
  38195. * @param texture defines the texture to update
  38196. * @param video defines the video element to use
  38197. * @param invertY defines if data must be stored with Y axis inverted
  38198. */
  38199. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38200. }
  38201. }
  38202. declare module BABYLON {
  38203. interface ThinEngine {
  38204. /**
  38205. * Creates a dynamic texture
  38206. * @param width defines the width of the texture
  38207. * @param height defines the height of the texture
  38208. * @param generateMipMaps defines if the engine should generate the mip levels
  38209. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38210. * @returns the dynamic texture inside an InternalTexture
  38211. */
  38212. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38213. /**
  38214. * Update the content of a dynamic texture
  38215. * @param texture defines the texture to update
  38216. * @param canvas defines the canvas containing the source
  38217. * @param invertY defines if data must be stored with Y axis inverted
  38218. * @param premulAlpha defines if alpha is stored as premultiplied
  38219. * @param format defines the format of the data
  38220. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38221. */
  38222. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38223. }
  38224. }
  38225. declare module BABYLON {
  38226. /**
  38227. * Settings for finer control over video usage
  38228. */
  38229. export interface VideoTextureSettings {
  38230. /**
  38231. * Applies `autoplay` to video, if specified
  38232. */
  38233. autoPlay?: boolean;
  38234. /**
  38235. * Applies `muted` to video, if specified
  38236. */
  38237. muted?: boolean;
  38238. /**
  38239. * Applies `loop` to video, if specified
  38240. */
  38241. loop?: boolean;
  38242. /**
  38243. * Automatically updates internal texture from video at every frame in the render loop
  38244. */
  38245. autoUpdateTexture: boolean;
  38246. /**
  38247. * Image src displayed during the video loading or until the user interacts with the video.
  38248. */
  38249. poster?: string;
  38250. }
  38251. /**
  38252. * If you want to display a video in your scene, this is the special texture for that.
  38253. * This special texture works similar to other textures, with the exception of a few parameters.
  38254. * @see https://doc.babylonjs.com/how_to/video_texture
  38255. */
  38256. export class VideoTexture extends Texture {
  38257. /**
  38258. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38259. */
  38260. readonly autoUpdateTexture: boolean;
  38261. /**
  38262. * The video instance used by the texture internally
  38263. */
  38264. readonly video: HTMLVideoElement;
  38265. private _onUserActionRequestedObservable;
  38266. /**
  38267. * Event triggerd when a dom action is required by the user to play the video.
  38268. * This happens due to recent changes in browser policies preventing video to auto start.
  38269. */
  38270. get onUserActionRequestedObservable(): Observable<Texture>;
  38271. private _generateMipMaps;
  38272. private _stillImageCaptured;
  38273. private _displayingPosterTexture;
  38274. private _settings;
  38275. private _createInternalTextureOnEvent;
  38276. private _frameId;
  38277. private _currentSrc;
  38278. /**
  38279. * Creates a video texture.
  38280. * If you want to display a video in your scene, this is the special texture for that.
  38281. * This special texture works similar to other textures, with the exception of a few parameters.
  38282. * @see https://doc.babylonjs.com/how_to/video_texture
  38283. * @param name optional name, will detect from video source, if not defined
  38284. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38285. * @param scene is obviously the current scene.
  38286. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38287. * @param invertY is false by default but can be used to invert video on Y axis
  38288. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38289. * @param settings allows finer control over video usage
  38290. */
  38291. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38292. private _getName;
  38293. private _getVideo;
  38294. private _createInternalTexture;
  38295. private reset;
  38296. /**
  38297. * @hidden Internal method to initiate `update`.
  38298. */
  38299. _rebuild(): void;
  38300. /**
  38301. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38302. */
  38303. update(): void;
  38304. /**
  38305. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38306. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38307. */
  38308. updateTexture(isVisible: boolean): void;
  38309. protected _updateInternalTexture: () => void;
  38310. /**
  38311. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38312. * @param url New url.
  38313. */
  38314. updateURL(url: string): void;
  38315. /**
  38316. * Clones the texture.
  38317. * @returns the cloned texture
  38318. */
  38319. clone(): VideoTexture;
  38320. /**
  38321. * Dispose the texture and release its associated resources.
  38322. */
  38323. dispose(): void;
  38324. /**
  38325. * Creates a video texture straight from a stream.
  38326. * @param scene Define the scene the texture should be created in
  38327. * @param stream Define the stream the texture should be created from
  38328. * @returns The created video texture as a promise
  38329. */
  38330. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38331. /**
  38332. * Creates a video texture straight from your WebCam video feed.
  38333. * @param scene Define the scene the texture should be created in
  38334. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38335. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38336. * @returns The created video texture as a promise
  38337. */
  38338. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38339. minWidth: number;
  38340. maxWidth: number;
  38341. minHeight: number;
  38342. maxHeight: number;
  38343. deviceId: string;
  38344. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38345. /**
  38346. * Creates a video texture straight from your WebCam video feed.
  38347. * @param scene Define the scene the texture should be created in
  38348. * @param onReady Define a callback to triggered once the texture will be ready
  38349. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38350. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38351. */
  38352. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38353. minWidth: number;
  38354. maxWidth: number;
  38355. minHeight: number;
  38356. maxHeight: number;
  38357. deviceId: string;
  38358. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38359. }
  38360. }
  38361. declare module BABYLON {
  38362. /**
  38363. * Defines the interface used by objects working like Scene
  38364. * @hidden
  38365. */
  38366. export interface ISceneLike {
  38367. _addPendingData(data: any): void;
  38368. _removePendingData(data: any): void;
  38369. offlineProvider: IOfflineProvider;
  38370. }
  38371. /**
  38372. * Information about the current host
  38373. */
  38374. export interface HostInformation {
  38375. /**
  38376. * Defines if the current host is a mobile
  38377. */
  38378. isMobile: boolean;
  38379. }
  38380. /** Interface defining initialization parameters for Engine class */
  38381. export interface EngineOptions extends WebGLContextAttributes {
  38382. /**
  38383. * Defines if the engine should no exceed a specified device ratio
  38384. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38385. */
  38386. limitDeviceRatio?: number;
  38387. /**
  38388. * Defines if webvr should be enabled automatically
  38389. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38390. */
  38391. autoEnableWebVR?: boolean;
  38392. /**
  38393. * Defines if webgl2 should be turned off even if supported
  38394. * @see https://doc.babylonjs.com/features/webgl2
  38395. */
  38396. disableWebGL2Support?: boolean;
  38397. /**
  38398. * Defines if webaudio should be initialized as well
  38399. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38400. */
  38401. audioEngine?: boolean;
  38402. /**
  38403. * Defines if animations should run using a deterministic lock step
  38404. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38405. */
  38406. deterministicLockstep?: boolean;
  38407. /** Defines the maximum steps to use with deterministic lock step mode */
  38408. lockstepMaxSteps?: number;
  38409. /** Defines the seconds between each deterministic lock step */
  38410. timeStep?: number;
  38411. /**
  38412. * Defines that engine should ignore context lost events
  38413. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38414. */
  38415. doNotHandleContextLost?: boolean;
  38416. /**
  38417. * Defines that engine should ignore modifying touch action attribute and style
  38418. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38419. */
  38420. doNotHandleTouchAction?: boolean;
  38421. /**
  38422. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38423. */
  38424. useHighPrecisionFloats?: boolean;
  38425. /**
  38426. * Make the canvas XR Compatible for XR sessions
  38427. */
  38428. xrCompatible?: boolean;
  38429. /**
  38430. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38431. */
  38432. useHighPrecisionMatrix?: boolean;
  38433. /**
  38434. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38435. */
  38436. failIfMajorPerformanceCaveat?: boolean;
  38437. }
  38438. /**
  38439. * The base engine class (root of all engines)
  38440. */
  38441. export class ThinEngine {
  38442. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38443. static ExceptionList: ({
  38444. key: string;
  38445. capture: string;
  38446. captureConstraint: number;
  38447. targets: string[];
  38448. } | {
  38449. key: string;
  38450. capture: null;
  38451. captureConstraint: null;
  38452. targets: string[];
  38453. })[];
  38454. /** @hidden */
  38455. static _TextureLoaders: IInternalTextureLoader[];
  38456. /**
  38457. * Returns the current npm package of the sdk
  38458. */
  38459. static get NpmPackage(): string;
  38460. /**
  38461. * Returns the current version of the framework
  38462. */
  38463. static get Version(): string;
  38464. /**
  38465. * Returns a string describing the current engine
  38466. */
  38467. get description(): string;
  38468. /**
  38469. * Gets or sets the epsilon value used by collision engine
  38470. */
  38471. static CollisionsEpsilon: number;
  38472. /**
  38473. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38474. */
  38475. static get ShadersRepository(): string;
  38476. static set ShadersRepository(value: string);
  38477. /** @hidden */
  38478. _shaderProcessor: IShaderProcessor;
  38479. /**
  38480. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  38481. */
  38482. forcePOTTextures: boolean;
  38483. /**
  38484. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  38485. */
  38486. isFullscreen: boolean;
  38487. /**
  38488. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  38489. */
  38490. cullBackFaces: boolean;
  38491. /**
  38492. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  38493. */
  38494. renderEvenInBackground: boolean;
  38495. /**
  38496. * Gets or sets a boolean indicating that cache can be kept between frames
  38497. */
  38498. preventCacheWipeBetweenFrames: boolean;
  38499. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  38500. validateShaderPrograms: boolean;
  38501. /**
  38502. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  38503. * This can provide greater z depth for distant objects.
  38504. */
  38505. useReverseDepthBuffer: boolean;
  38506. /**
  38507. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  38508. */
  38509. disableUniformBuffers: boolean;
  38510. /** @hidden */
  38511. _uniformBuffers: UniformBuffer[];
  38512. /**
  38513. * Gets a boolean indicating that the engine supports uniform buffers
  38514. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  38515. */
  38516. get supportsUniformBuffers(): boolean;
  38517. /** @hidden */
  38518. _gl: WebGLRenderingContext;
  38519. /** @hidden */
  38520. _webGLVersion: number;
  38521. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  38522. protected _windowIsBackground: boolean;
  38523. protected _creationOptions: EngineOptions;
  38524. protected _highPrecisionShadersAllowed: boolean;
  38525. /** @hidden */
  38526. get _shouldUseHighPrecisionShader(): boolean;
  38527. /**
  38528. * Gets a boolean indicating that only power of 2 textures are supported
  38529. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  38530. */
  38531. get needPOTTextures(): boolean;
  38532. /** @hidden */
  38533. _badOS: boolean;
  38534. /** @hidden */
  38535. _badDesktopOS: boolean;
  38536. private _hardwareScalingLevel;
  38537. /** @hidden */
  38538. _caps: EngineCapabilities;
  38539. private _isStencilEnable;
  38540. private _glVersion;
  38541. private _glRenderer;
  38542. private _glVendor;
  38543. /** @hidden */
  38544. _videoTextureSupported: boolean;
  38545. protected _renderingQueueLaunched: boolean;
  38546. protected _activeRenderLoops: (() => void)[];
  38547. /**
  38548. * Observable signaled when a context lost event is raised
  38549. */
  38550. onContextLostObservable: Observable<ThinEngine>;
  38551. /**
  38552. * Observable signaled when a context restored event is raised
  38553. */
  38554. onContextRestoredObservable: Observable<ThinEngine>;
  38555. private _onContextLost;
  38556. private _onContextRestored;
  38557. protected _contextWasLost: boolean;
  38558. /** @hidden */
  38559. _doNotHandleContextLost: boolean;
  38560. /**
  38561. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  38562. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  38563. */
  38564. get doNotHandleContextLost(): boolean;
  38565. set doNotHandleContextLost(value: boolean);
  38566. /**
  38567. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  38568. */
  38569. disableVertexArrayObjects: boolean;
  38570. /** @hidden */
  38571. protected _colorWrite: boolean;
  38572. /** @hidden */
  38573. protected _colorWriteChanged: boolean;
  38574. /** @hidden */
  38575. protected _depthCullingState: DepthCullingState;
  38576. /** @hidden */
  38577. protected _stencilState: StencilState;
  38578. /** @hidden */
  38579. _alphaState: AlphaState;
  38580. /** @hidden */
  38581. _alphaMode: number;
  38582. /** @hidden */
  38583. _alphaEquation: number;
  38584. /** @hidden */
  38585. _internalTexturesCache: InternalTexture[];
  38586. /** @hidden */
  38587. protected _activeChannel: number;
  38588. private _currentTextureChannel;
  38589. /** @hidden */
  38590. protected _boundTexturesCache: {
  38591. [key: string]: Nullable<InternalTexture>;
  38592. };
  38593. /** @hidden */
  38594. protected _currentEffect: Nullable<Effect>;
  38595. /** @hidden */
  38596. protected _currentProgram: Nullable<WebGLProgram>;
  38597. private _compiledEffects;
  38598. private _vertexAttribArraysEnabled;
  38599. /** @hidden */
  38600. protected _cachedViewport: Nullable<IViewportLike>;
  38601. private _cachedVertexArrayObject;
  38602. /** @hidden */
  38603. protected _cachedVertexBuffers: any;
  38604. /** @hidden */
  38605. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  38606. /** @hidden */
  38607. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  38608. /** @hidden */
  38609. _currentRenderTarget: Nullable<InternalTexture>;
  38610. private _uintIndicesCurrentlySet;
  38611. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  38612. /** @hidden */
  38613. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  38614. /** @hidden */
  38615. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  38616. private _currentBufferPointers;
  38617. private _currentInstanceLocations;
  38618. private _currentInstanceBuffers;
  38619. private _textureUnits;
  38620. /** @hidden */
  38621. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38622. /** @hidden */
  38623. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38624. /** @hidden */
  38625. _boundRenderFunction: any;
  38626. private _vaoRecordInProgress;
  38627. private _mustWipeVertexAttributes;
  38628. private _emptyTexture;
  38629. private _emptyCubeTexture;
  38630. private _emptyTexture3D;
  38631. private _emptyTexture2DArray;
  38632. /** @hidden */
  38633. _frameHandler: number;
  38634. private _nextFreeTextureSlots;
  38635. private _maxSimultaneousTextures;
  38636. private _activeRequests;
  38637. /** @hidden */
  38638. _transformTextureUrl: Nullable<(url: string) => string>;
  38639. /**
  38640. * Gets information about the current host
  38641. */
  38642. hostInformation: HostInformation;
  38643. protected get _supportsHardwareTextureRescaling(): boolean;
  38644. private _framebufferDimensionsObject;
  38645. /**
  38646. * sets the object from which width and height will be taken from when getting render width and height
  38647. * Will fallback to the gl object
  38648. * @param dimensions the framebuffer width and height that will be used.
  38649. */
  38650. set framebufferDimensionsObject(dimensions: Nullable<{
  38651. framebufferWidth: number;
  38652. framebufferHeight: number;
  38653. }>);
  38654. /**
  38655. * Gets the current viewport
  38656. */
  38657. get currentViewport(): Nullable<IViewportLike>;
  38658. /**
  38659. * Gets the default empty texture
  38660. */
  38661. get emptyTexture(): InternalTexture;
  38662. /**
  38663. * Gets the default empty 3D texture
  38664. */
  38665. get emptyTexture3D(): InternalTexture;
  38666. /**
  38667. * Gets the default empty 2D array texture
  38668. */
  38669. get emptyTexture2DArray(): InternalTexture;
  38670. /**
  38671. * Gets the default empty cube texture
  38672. */
  38673. get emptyCubeTexture(): InternalTexture;
  38674. /**
  38675. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  38676. */
  38677. readonly premultipliedAlpha: boolean;
  38678. /**
  38679. * Observable event triggered before each texture is initialized
  38680. */
  38681. onBeforeTextureInitObservable: Observable<Texture>;
  38682. /**
  38683. * Creates a new engine
  38684. * @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
  38685. * @param antialias defines enable antialiasing (default: false)
  38686. * @param options defines further options to be sent to the getContext() function
  38687. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38688. */
  38689. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38690. private _rebuildInternalTextures;
  38691. private _rebuildEffects;
  38692. /**
  38693. * Gets a boolean indicating if all created effects are ready
  38694. * @returns true if all effects are ready
  38695. */
  38696. areAllEffectsReady(): boolean;
  38697. protected _rebuildBuffers(): void;
  38698. protected _initGLContext(): void;
  38699. /**
  38700. * Gets version of the current webGL context
  38701. */
  38702. get webGLVersion(): number;
  38703. /**
  38704. * Gets a string identifying the name of the class
  38705. * @returns "Engine" string
  38706. */
  38707. getClassName(): string;
  38708. /**
  38709. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  38710. */
  38711. get isStencilEnable(): boolean;
  38712. /** @hidden */
  38713. _prepareWorkingCanvas(): void;
  38714. /**
  38715. * Reset the texture cache to empty state
  38716. */
  38717. resetTextureCache(): void;
  38718. /**
  38719. * Gets an object containing information about the current webGL context
  38720. * @returns an object containing the vender, the renderer and the version of the current webGL context
  38721. */
  38722. getGlInfo(): {
  38723. vendor: string;
  38724. renderer: string;
  38725. version: string;
  38726. };
  38727. /**
  38728. * Defines the hardware scaling level.
  38729. * By default the hardware scaling level is computed from the window device ratio.
  38730. * 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.
  38731. * @param level defines the level to use
  38732. */
  38733. setHardwareScalingLevel(level: number): void;
  38734. /**
  38735. * Gets the current hardware scaling level.
  38736. * By default the hardware scaling level is computed from the window device ratio.
  38737. * 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.
  38738. * @returns a number indicating the current hardware scaling level
  38739. */
  38740. getHardwareScalingLevel(): number;
  38741. /**
  38742. * Gets the list of loaded textures
  38743. * @returns an array containing all loaded textures
  38744. */
  38745. getLoadedTexturesCache(): InternalTexture[];
  38746. /**
  38747. * Gets the object containing all engine capabilities
  38748. * @returns the EngineCapabilities object
  38749. */
  38750. getCaps(): EngineCapabilities;
  38751. /**
  38752. * stop executing a render loop function and remove it from the execution array
  38753. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  38754. */
  38755. stopRenderLoop(renderFunction?: () => void): void;
  38756. /** @hidden */
  38757. _renderLoop(): void;
  38758. /**
  38759. * Gets the HTML canvas attached with the current webGL context
  38760. * @returns a HTML canvas
  38761. */
  38762. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  38763. /**
  38764. * Gets host window
  38765. * @returns the host window object
  38766. */
  38767. getHostWindow(): Nullable<Window>;
  38768. /**
  38769. * Gets the current render width
  38770. * @param useScreen defines if screen size must be used (or the current render target if any)
  38771. * @returns a number defining the current render width
  38772. */
  38773. getRenderWidth(useScreen?: boolean): number;
  38774. /**
  38775. * Gets the current render height
  38776. * @param useScreen defines if screen size must be used (or the current render target if any)
  38777. * @returns a number defining the current render height
  38778. */
  38779. getRenderHeight(useScreen?: boolean): number;
  38780. /**
  38781. * Can be used to override the current requestAnimationFrame requester.
  38782. * @hidden
  38783. */
  38784. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  38785. /**
  38786. * Register and execute a render loop. The engine can have more than one render function
  38787. * @param renderFunction defines the function to continuously execute
  38788. */
  38789. runRenderLoop(renderFunction: () => void): void;
  38790. /**
  38791. * Clear the current render buffer or the current render target (if any is set up)
  38792. * @param color defines the color to use
  38793. * @param backBuffer defines if the back buffer must be cleared
  38794. * @param depth defines if the depth buffer must be cleared
  38795. * @param stencil defines if the stencil buffer must be cleared
  38796. */
  38797. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  38798. private _viewportCached;
  38799. /** @hidden */
  38800. _viewport(x: number, y: number, width: number, height: number): void;
  38801. /**
  38802. * Set the WebGL's viewport
  38803. * @param viewport defines the viewport element to be used
  38804. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  38805. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  38806. */
  38807. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  38808. /**
  38809. * Begin a new frame
  38810. */
  38811. beginFrame(): void;
  38812. /**
  38813. * Enf the current frame
  38814. */
  38815. endFrame(): void;
  38816. /**
  38817. * Resize the view according to the canvas' size
  38818. */
  38819. resize(): void;
  38820. /**
  38821. * Force a specific size of the canvas
  38822. * @param width defines the new canvas' width
  38823. * @param height defines the new canvas' height
  38824. * @returns true if the size was changed
  38825. */
  38826. setSize(width: number, height: number): boolean;
  38827. /**
  38828. * Binds the frame buffer to the specified texture.
  38829. * @param texture The texture to render to or null for the default canvas
  38830. * @param faceIndex The face of the texture to render to in case of cube texture
  38831. * @param requiredWidth The width of the target to render to
  38832. * @param requiredHeight The height of the target to render to
  38833. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  38834. * @param lodLevel defines the lod level to bind to the frame buffer
  38835. * @param layer defines the 2d array index to bind to frame buffer to
  38836. */
  38837. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  38838. /** @hidden */
  38839. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  38840. /**
  38841. * Unbind the current render target texture from the webGL context
  38842. * @param texture defines the render target texture to unbind
  38843. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  38844. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  38845. */
  38846. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  38847. /**
  38848. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  38849. */
  38850. flushFramebuffer(): void;
  38851. /**
  38852. * Unbind the current render target and bind the default framebuffer
  38853. */
  38854. restoreDefaultFramebuffer(): void;
  38855. /** @hidden */
  38856. protected _resetVertexBufferBinding(): void;
  38857. /**
  38858. * Creates a vertex buffer
  38859. * @param data the data for the vertex buffer
  38860. * @returns the new WebGL static buffer
  38861. */
  38862. createVertexBuffer(data: DataArray): DataBuffer;
  38863. private _createVertexBuffer;
  38864. /**
  38865. * Creates a dynamic vertex buffer
  38866. * @param data the data for the dynamic vertex buffer
  38867. * @returns the new WebGL dynamic buffer
  38868. */
  38869. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  38870. protected _resetIndexBufferBinding(): void;
  38871. /**
  38872. * Creates a new index buffer
  38873. * @param indices defines the content of the index buffer
  38874. * @param updatable defines if the index buffer must be updatable
  38875. * @returns a new webGL buffer
  38876. */
  38877. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  38878. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  38879. /**
  38880. * Bind a webGL buffer to the webGL context
  38881. * @param buffer defines the buffer to bind
  38882. */
  38883. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  38884. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  38885. private bindBuffer;
  38886. /**
  38887. * update the bound buffer with the given data
  38888. * @param data defines the data to update
  38889. */
  38890. updateArrayBuffer(data: Float32Array): void;
  38891. private _vertexAttribPointer;
  38892. /** @hidden */
  38893. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  38894. private _bindVertexBuffersAttributes;
  38895. /**
  38896. * Records a vertex array object
  38897. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  38898. * @param vertexBuffers defines the list of vertex buffers to store
  38899. * @param indexBuffer defines the index buffer to store
  38900. * @param effect defines the effect to store
  38901. * @returns the new vertex array object
  38902. */
  38903. recordVertexArrayObject(vertexBuffers: {
  38904. [key: string]: VertexBuffer;
  38905. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  38906. /**
  38907. * Bind a specific vertex array object
  38908. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  38909. * @param vertexArrayObject defines the vertex array object to bind
  38910. * @param indexBuffer defines the index buffer to bind
  38911. */
  38912. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  38913. /**
  38914. * Bind webGl buffers directly to the webGL context
  38915. * @param vertexBuffer defines the vertex buffer to bind
  38916. * @param indexBuffer defines the index buffer to bind
  38917. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  38918. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  38919. * @param effect defines the effect associated with the vertex buffer
  38920. */
  38921. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  38922. private _unbindVertexArrayObject;
  38923. /**
  38924. * Bind a list of vertex buffers to the webGL context
  38925. * @param vertexBuffers defines the list of vertex buffers to bind
  38926. * @param indexBuffer defines the index buffer to bind
  38927. * @param effect defines the effect associated with the vertex buffers
  38928. */
  38929. bindBuffers(vertexBuffers: {
  38930. [key: string]: Nullable<VertexBuffer>;
  38931. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  38932. /**
  38933. * Unbind all instance attributes
  38934. */
  38935. unbindInstanceAttributes(): void;
  38936. /**
  38937. * Release and free the memory of a vertex array object
  38938. * @param vao defines the vertex array object to delete
  38939. */
  38940. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  38941. /** @hidden */
  38942. _releaseBuffer(buffer: DataBuffer): boolean;
  38943. protected _deleteBuffer(buffer: DataBuffer): void;
  38944. /**
  38945. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  38946. * @param instancesBuffer defines the webGL buffer to update and bind
  38947. * @param data defines the data to store in the buffer
  38948. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  38949. */
  38950. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  38951. /**
  38952. * Bind the content of a webGL buffer used with instantiation
  38953. * @param instancesBuffer defines the webGL buffer to bind
  38954. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  38955. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  38956. */
  38957. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  38958. /**
  38959. * Disable the instance attribute corresponding to the name in parameter
  38960. * @param name defines the name of the attribute to disable
  38961. */
  38962. disableInstanceAttributeByName(name: string): void;
  38963. /**
  38964. * Disable the instance attribute corresponding to the location in parameter
  38965. * @param attributeLocation defines the attribute location of the attribute to disable
  38966. */
  38967. disableInstanceAttribute(attributeLocation: number): void;
  38968. /**
  38969. * Disable the attribute corresponding to the location in parameter
  38970. * @param attributeLocation defines the attribute location of the attribute to disable
  38971. */
  38972. disableAttributeByIndex(attributeLocation: number): void;
  38973. /**
  38974. * Send a draw order
  38975. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  38976. * @param indexStart defines the starting index
  38977. * @param indexCount defines the number of index to draw
  38978. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  38979. */
  38980. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  38981. /**
  38982. * Draw a list of points
  38983. * @param verticesStart defines the index of first vertex to draw
  38984. * @param verticesCount defines the count of vertices to draw
  38985. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  38986. */
  38987. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  38988. /**
  38989. * Draw a list of unindexed primitives
  38990. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  38991. * @param verticesStart defines the index of first vertex to draw
  38992. * @param verticesCount defines the count of vertices to draw
  38993. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  38994. */
  38995. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  38996. /**
  38997. * Draw a list of indexed primitives
  38998. * @param fillMode defines the primitive to use
  38999. * @param indexStart defines the starting index
  39000. * @param indexCount defines the number of index to draw
  39001. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39002. */
  39003. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39004. /**
  39005. * Draw a list of unindexed primitives
  39006. * @param fillMode defines the primitive to use
  39007. * @param verticesStart defines the index of first vertex to draw
  39008. * @param verticesCount defines the count of vertices to draw
  39009. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39010. */
  39011. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39012. private _drawMode;
  39013. /** @hidden */
  39014. protected _reportDrawCall(): void;
  39015. /** @hidden */
  39016. _releaseEffect(effect: Effect): void;
  39017. /** @hidden */
  39018. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39019. /**
  39020. * Create a new effect (used to store vertex/fragment shaders)
  39021. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39022. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39023. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39024. * @param samplers defines an array of string used to represent textures
  39025. * @param defines defines the string containing the defines to use to compile the shaders
  39026. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39027. * @param onCompiled defines a function to call when the effect creation is successful
  39028. * @param onError defines a function to call when the effect creation has failed
  39029. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39030. * @returns the new Effect
  39031. */
  39032. 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;
  39033. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39034. private _compileShader;
  39035. private _compileRawShader;
  39036. /** @hidden */
  39037. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39038. /**
  39039. * Directly creates a webGL program
  39040. * @param pipelineContext defines the pipeline context to attach to
  39041. * @param vertexCode defines the vertex shader code to use
  39042. * @param fragmentCode defines the fragment shader code to use
  39043. * @param context defines the webGL context to use (if not set, the current one will be used)
  39044. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39045. * @returns the new webGL program
  39046. */
  39047. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39048. /**
  39049. * Creates a webGL program
  39050. * @param pipelineContext defines the pipeline context to attach to
  39051. * @param vertexCode defines the vertex shader code to use
  39052. * @param fragmentCode defines the fragment shader code to use
  39053. * @param defines defines the string containing the defines to use to compile the shaders
  39054. * @param context defines the webGL context to use (if not set, the current one will be used)
  39055. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39056. * @returns the new webGL program
  39057. */
  39058. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39059. /**
  39060. * Creates a new pipeline context
  39061. * @returns the new pipeline
  39062. */
  39063. createPipelineContext(): IPipelineContext;
  39064. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39065. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39066. /** @hidden */
  39067. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39068. /** @hidden */
  39069. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39070. /** @hidden */
  39071. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39072. /**
  39073. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39074. * @param pipelineContext defines the pipeline context to use
  39075. * @param uniformsNames defines the list of uniform names
  39076. * @returns an array of webGL uniform locations
  39077. */
  39078. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39079. /**
  39080. * Gets the lsit of active attributes for a given webGL program
  39081. * @param pipelineContext defines the pipeline context to use
  39082. * @param attributesNames defines the list of attribute names to get
  39083. * @returns an array of indices indicating the offset of each attribute
  39084. */
  39085. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39086. /**
  39087. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39088. * @param effect defines the effect to activate
  39089. */
  39090. enableEffect(effect: Nullable<Effect>): void;
  39091. /**
  39092. * Set the value of an uniform to a number (int)
  39093. * @param uniform defines the webGL uniform location where to store the value
  39094. * @param value defines the int number to store
  39095. * @returns true if the value was set
  39096. */
  39097. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39098. /**
  39099. * Set the value of an uniform to an array of int32
  39100. * @param uniform defines the webGL uniform location where to store the value
  39101. * @param array defines the array of int32 to store
  39102. * @returns true if the value was set
  39103. */
  39104. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39105. /**
  39106. * Set the value of an uniform to an array of int32 (stored as vec2)
  39107. * @param uniform defines the webGL uniform location where to store the value
  39108. * @param array defines the array of int32 to store
  39109. * @returns true if the value was set
  39110. */
  39111. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39112. /**
  39113. * Set the value of an uniform to an array of int32 (stored as vec3)
  39114. * @param uniform defines the webGL uniform location where to store the value
  39115. * @param array defines the array of int32 to store
  39116. * @returns true if the value was set
  39117. */
  39118. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39119. /**
  39120. * Set the value of an uniform to an array of int32 (stored as vec4)
  39121. * @param uniform defines the webGL uniform location where to store the value
  39122. * @param array defines the array of int32 to store
  39123. * @returns true if the value was set
  39124. */
  39125. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39126. /**
  39127. * Set the value of an uniform to an array of number
  39128. * @param uniform defines the webGL uniform location where to store the value
  39129. * @param array defines the array of number to store
  39130. * @returns true if the value was set
  39131. */
  39132. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39133. /**
  39134. * Set the value of an uniform to an array of number (stored as vec2)
  39135. * @param uniform defines the webGL uniform location where to store the value
  39136. * @param array defines the array of number to store
  39137. * @returns true if the value was set
  39138. */
  39139. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39140. /**
  39141. * Set the value of an uniform to an array of number (stored as vec3)
  39142. * @param uniform defines the webGL uniform location where to store the value
  39143. * @param array defines the array of number to store
  39144. * @returns true if the value was set
  39145. */
  39146. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39147. /**
  39148. * Set the value of an uniform to an array of number (stored as vec4)
  39149. * @param uniform defines the webGL uniform location where to store the value
  39150. * @param array defines the array of number to store
  39151. * @returns true if the value was set
  39152. */
  39153. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39154. /**
  39155. * Set the value of an uniform to an array of float32 (stored as matrices)
  39156. * @param uniform defines the webGL uniform location where to store the value
  39157. * @param matrices defines the array of float32 to store
  39158. * @returns true if the value was set
  39159. */
  39160. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39161. /**
  39162. * Set the value of an uniform to a matrix (3x3)
  39163. * @param uniform defines the webGL uniform location where to store the value
  39164. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39165. * @returns true if the value was set
  39166. */
  39167. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39168. /**
  39169. * Set the value of an uniform to a matrix (2x2)
  39170. * @param uniform defines the webGL uniform location where to store the value
  39171. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39172. * @returns true if the value was set
  39173. */
  39174. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39175. /**
  39176. * Set the value of an uniform to a number (float)
  39177. * @param uniform defines the webGL uniform location where to store the value
  39178. * @param value defines the float number to store
  39179. * @returns true if the value was transfered
  39180. */
  39181. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39182. /**
  39183. * Set the value of an uniform to a vec2
  39184. * @param uniform defines the webGL uniform location where to store the value
  39185. * @param x defines the 1st component of the value
  39186. * @param y defines the 2nd component of the value
  39187. * @returns true if the value was set
  39188. */
  39189. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39190. /**
  39191. * Set the value of an uniform to a vec3
  39192. * @param uniform defines the webGL uniform location where to store the value
  39193. * @param x defines the 1st component of the value
  39194. * @param y defines the 2nd component of the value
  39195. * @param z defines the 3rd component of the value
  39196. * @returns true if the value was set
  39197. */
  39198. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39199. /**
  39200. * Set the value of an uniform to a vec4
  39201. * @param uniform defines the webGL uniform location where to store the value
  39202. * @param x defines the 1st component of the value
  39203. * @param y defines the 2nd component of the value
  39204. * @param z defines the 3rd component of the value
  39205. * @param w defines the 4th component of the value
  39206. * @returns true if the value was set
  39207. */
  39208. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39209. /**
  39210. * Apply all cached states (depth, culling, stencil and alpha)
  39211. */
  39212. applyStates(): void;
  39213. /**
  39214. * Enable or disable color writing
  39215. * @param enable defines the state to set
  39216. */
  39217. setColorWrite(enable: boolean): void;
  39218. /**
  39219. * Gets a boolean indicating if color writing is enabled
  39220. * @returns the current color writing state
  39221. */
  39222. getColorWrite(): boolean;
  39223. /**
  39224. * Gets the depth culling state manager
  39225. */
  39226. get depthCullingState(): DepthCullingState;
  39227. /**
  39228. * Gets the alpha state manager
  39229. */
  39230. get alphaState(): AlphaState;
  39231. /**
  39232. * Gets the stencil state manager
  39233. */
  39234. get stencilState(): StencilState;
  39235. /**
  39236. * Clears the list of texture accessible through engine.
  39237. * This can help preventing texture load conflict due to name collision.
  39238. */
  39239. clearInternalTexturesCache(): void;
  39240. /**
  39241. * Force the entire cache to be cleared
  39242. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39243. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39244. */
  39245. wipeCaches(bruteForce?: boolean): void;
  39246. /** @hidden */
  39247. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39248. min: number;
  39249. mag: number;
  39250. };
  39251. /** @hidden */
  39252. _createTexture(): WebGLTexture;
  39253. /**
  39254. * Usually called from Texture.ts.
  39255. * Passed information to create a WebGLTexture
  39256. * @param url defines a value which contains one of the following:
  39257. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39258. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39259. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39260. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39261. * @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)
  39262. * @param scene needed for loading to the correct scene
  39263. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39264. * @param onLoad optional callback to be called upon successful completion
  39265. * @param onError optional callback to be called upon failure
  39266. * @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
  39267. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39268. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39269. * @param forcedExtension defines the extension to use to pick the right loader
  39270. * @param mimeType defines an optional mime type
  39271. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39272. */
  39273. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  39274. /**
  39275. * Loads an image as an HTMLImageElement.
  39276. * @param input url string, ArrayBuffer, or Blob to load
  39277. * @param onLoad callback called when the image successfully loads
  39278. * @param onError callback called when the image fails to load
  39279. * @param offlineProvider offline provider for caching
  39280. * @param mimeType optional mime type
  39281. * @returns the HTMLImageElement of the loaded image
  39282. * @hidden
  39283. */
  39284. 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>;
  39285. /**
  39286. * @hidden
  39287. */
  39288. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39289. private _unpackFlipYCached;
  39290. /**
  39291. * In case you are sharing the context with other applications, it might
  39292. * be interested to not cache the unpack flip y state to ensure a consistent
  39293. * value would be set.
  39294. */
  39295. enableUnpackFlipYCached: boolean;
  39296. /** @hidden */
  39297. _unpackFlipY(value: boolean): void;
  39298. /** @hidden */
  39299. _getUnpackAlignement(): number;
  39300. private _getTextureTarget;
  39301. /**
  39302. * Update the sampling mode of a given texture
  39303. * @param samplingMode defines the required sampling mode
  39304. * @param texture defines the texture to update
  39305. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39306. */
  39307. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39308. /**
  39309. * Update the sampling mode of a given texture
  39310. * @param texture defines the texture to update
  39311. * @param wrapU defines the texture wrap mode of the u coordinates
  39312. * @param wrapV defines the texture wrap mode of the v coordinates
  39313. * @param wrapR defines the texture wrap mode of the r coordinates
  39314. */
  39315. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39316. /** @hidden */
  39317. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39318. width: number;
  39319. height: number;
  39320. layers?: number;
  39321. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39322. /** @hidden */
  39323. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39324. /** @hidden */
  39325. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39326. /**
  39327. * Update a portion of an internal texture
  39328. * @param texture defines the texture to update
  39329. * @param imageData defines the data to store into the texture
  39330. * @param xOffset defines the x coordinates of the update rectangle
  39331. * @param yOffset defines the y coordinates of the update rectangle
  39332. * @param width defines the width of the update rectangle
  39333. * @param height defines the height of the update rectangle
  39334. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39335. * @param lod defines the lod level to update (0 by default)
  39336. */
  39337. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39338. /** @hidden */
  39339. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39340. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39341. private _prepareWebGLTexture;
  39342. /** @hidden */
  39343. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39344. private _getDepthStencilBuffer;
  39345. /** @hidden */
  39346. _releaseFramebufferObjects(texture: InternalTexture): void;
  39347. /** @hidden */
  39348. _releaseTexture(texture: InternalTexture): void;
  39349. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39350. protected _setProgram(program: WebGLProgram): void;
  39351. protected _boundUniforms: {
  39352. [key: number]: WebGLUniformLocation;
  39353. };
  39354. /**
  39355. * Binds an effect to the webGL context
  39356. * @param effect defines the effect to bind
  39357. */
  39358. bindSamplers(effect: Effect): void;
  39359. private _activateCurrentTexture;
  39360. /** @hidden */
  39361. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39362. /** @hidden */
  39363. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39364. /**
  39365. * Unbind all textures from the webGL context
  39366. */
  39367. unbindAllTextures(): void;
  39368. /**
  39369. * Sets a texture to the according uniform.
  39370. * @param channel The texture channel
  39371. * @param uniform The uniform to set
  39372. * @param texture The texture to apply
  39373. */
  39374. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  39375. private _bindSamplerUniformToChannel;
  39376. private _getTextureWrapMode;
  39377. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39378. /**
  39379. * Sets an array of texture to the webGL context
  39380. * @param channel defines the channel where the texture array must be set
  39381. * @param uniform defines the associated uniform location
  39382. * @param textures defines the array of textures to bind
  39383. */
  39384. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  39385. /** @hidden */
  39386. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39387. private _setTextureParameterFloat;
  39388. private _setTextureParameterInteger;
  39389. /**
  39390. * Unbind all vertex attributes from the webGL context
  39391. */
  39392. unbindAllAttributes(): void;
  39393. /**
  39394. * 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
  39395. */
  39396. releaseEffects(): void;
  39397. /**
  39398. * Dispose and release all associated resources
  39399. */
  39400. dispose(): void;
  39401. /**
  39402. * Attach a new callback raised when context lost event is fired
  39403. * @param callback defines the callback to call
  39404. */
  39405. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39406. /**
  39407. * Attach a new callback raised when context restored event is fired
  39408. * @param callback defines the callback to call
  39409. */
  39410. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39411. /**
  39412. * Get the current error code of the webGL context
  39413. * @returns the error code
  39414. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39415. */
  39416. getError(): number;
  39417. private _canRenderToFloatFramebuffer;
  39418. private _canRenderToHalfFloatFramebuffer;
  39419. private _canRenderToFramebuffer;
  39420. /** @hidden */
  39421. _getWebGLTextureType(type: number): number;
  39422. /** @hidden */
  39423. _getInternalFormat(format: number): number;
  39424. /** @hidden */
  39425. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39426. /** @hidden */
  39427. _getRGBAMultiSampleBufferFormat(type: number): number;
  39428. /** @hidden */
  39429. _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;
  39430. /**
  39431. * Loads a file from a url
  39432. * @param url url to load
  39433. * @param onSuccess callback called when the file successfully loads
  39434. * @param onProgress callback called while file is loading (if the server supports this mode)
  39435. * @param offlineProvider defines the offline provider for caching
  39436. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39437. * @param onError callback called when the file fails to load
  39438. * @returns a file request object
  39439. * @hidden
  39440. */
  39441. 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;
  39442. /**
  39443. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39444. * @param x defines the x coordinate of the rectangle where pixels must be read
  39445. * @param y defines the y coordinate of the rectangle where pixels must be read
  39446. * @param width defines the width of the rectangle where pixels must be read
  39447. * @param height defines the height of the rectangle where pixels must be read
  39448. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39449. * @returns a Uint8Array containing RGBA colors
  39450. */
  39451. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39452. private static _IsSupported;
  39453. private static _HasMajorPerformanceCaveat;
  39454. /**
  39455. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39456. */
  39457. static get IsSupported(): boolean;
  39458. /**
  39459. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39460. * @returns true if the engine can be created
  39461. * @ignorenaming
  39462. */
  39463. static isSupported(): boolean;
  39464. /**
  39465. * 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)
  39466. */
  39467. static get HasMajorPerformanceCaveat(): boolean;
  39468. /**
  39469. * Find the next highest power of two.
  39470. * @param x Number to start search from.
  39471. * @return Next highest power of two.
  39472. */
  39473. static CeilingPOT(x: number): number;
  39474. /**
  39475. * Find the next lowest power of two.
  39476. * @param x Number to start search from.
  39477. * @return Next lowest power of two.
  39478. */
  39479. static FloorPOT(x: number): number;
  39480. /**
  39481. * Find the nearest power of two.
  39482. * @param x Number to start search from.
  39483. * @return Next nearest power of two.
  39484. */
  39485. static NearestPOT(x: number): number;
  39486. /**
  39487. * Get the closest exponent of two
  39488. * @param value defines the value to approximate
  39489. * @param max defines the maximum value to return
  39490. * @param mode defines how to define the closest value
  39491. * @returns closest exponent of two of the given value
  39492. */
  39493. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39494. /**
  39495. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39496. * @param func - the function to be called
  39497. * @param requester - the object that will request the next frame. Falls back to window.
  39498. * @returns frame number
  39499. */
  39500. static QueueNewFrame(func: () => void, requester?: any): number;
  39501. /**
  39502. * Gets host document
  39503. * @returns the host document object
  39504. */
  39505. getHostDocument(): Nullable<Document>;
  39506. }
  39507. }
  39508. declare module BABYLON {
  39509. /**
  39510. * Defines the source of the internal texture
  39511. */
  39512. export enum InternalTextureSource {
  39513. /**
  39514. * The source of the texture data is unknown
  39515. */
  39516. Unknown = 0,
  39517. /**
  39518. * Texture data comes from an URL
  39519. */
  39520. Url = 1,
  39521. /**
  39522. * Texture data is only used for temporary storage
  39523. */
  39524. Temp = 2,
  39525. /**
  39526. * Texture data comes from raw data (ArrayBuffer)
  39527. */
  39528. Raw = 3,
  39529. /**
  39530. * Texture content is dynamic (video or dynamic texture)
  39531. */
  39532. Dynamic = 4,
  39533. /**
  39534. * Texture content is generated by rendering to it
  39535. */
  39536. RenderTarget = 5,
  39537. /**
  39538. * Texture content is part of a multi render target process
  39539. */
  39540. MultiRenderTarget = 6,
  39541. /**
  39542. * Texture data comes from a cube data file
  39543. */
  39544. Cube = 7,
  39545. /**
  39546. * Texture data comes from a raw cube data
  39547. */
  39548. CubeRaw = 8,
  39549. /**
  39550. * Texture data come from a prefiltered cube data file
  39551. */
  39552. CubePrefiltered = 9,
  39553. /**
  39554. * Texture content is raw 3D data
  39555. */
  39556. Raw3D = 10,
  39557. /**
  39558. * Texture content is raw 2D array data
  39559. */
  39560. Raw2DArray = 11,
  39561. /**
  39562. * Texture content is a depth texture
  39563. */
  39564. Depth = 12,
  39565. /**
  39566. * Texture data comes from a raw cube data encoded with RGBD
  39567. */
  39568. CubeRawRGBD = 13
  39569. }
  39570. /**
  39571. * Class used to store data associated with WebGL texture data for the engine
  39572. * This class should not be used directly
  39573. */
  39574. export class InternalTexture {
  39575. /** @hidden */
  39576. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  39577. /**
  39578. * Defines if the texture is ready
  39579. */
  39580. isReady: boolean;
  39581. /**
  39582. * Defines if the texture is a cube texture
  39583. */
  39584. isCube: boolean;
  39585. /**
  39586. * Defines if the texture contains 3D data
  39587. */
  39588. is3D: boolean;
  39589. /**
  39590. * Defines if the texture contains 2D array data
  39591. */
  39592. is2DArray: boolean;
  39593. /**
  39594. * Defines if the texture contains multiview data
  39595. */
  39596. isMultiview: boolean;
  39597. /**
  39598. * Gets the URL used to load this texture
  39599. */
  39600. url: string;
  39601. /**
  39602. * Gets the sampling mode of the texture
  39603. */
  39604. samplingMode: number;
  39605. /**
  39606. * Gets a boolean indicating if the texture needs mipmaps generation
  39607. */
  39608. generateMipMaps: boolean;
  39609. /**
  39610. * Gets the number of samples used by the texture (WebGL2+ only)
  39611. */
  39612. samples: number;
  39613. /**
  39614. * Gets the type of the texture (int, float...)
  39615. */
  39616. type: number;
  39617. /**
  39618. * Gets the format of the texture (RGB, RGBA...)
  39619. */
  39620. format: number;
  39621. /**
  39622. * Observable called when the texture is loaded
  39623. */
  39624. onLoadedObservable: Observable<InternalTexture>;
  39625. /**
  39626. * Gets the width of the texture
  39627. */
  39628. width: number;
  39629. /**
  39630. * Gets the height of the texture
  39631. */
  39632. height: number;
  39633. /**
  39634. * Gets the depth of the texture
  39635. */
  39636. depth: number;
  39637. /**
  39638. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  39639. */
  39640. baseWidth: number;
  39641. /**
  39642. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  39643. */
  39644. baseHeight: number;
  39645. /**
  39646. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  39647. */
  39648. baseDepth: number;
  39649. /**
  39650. * Gets a boolean indicating if the texture is inverted on Y axis
  39651. */
  39652. invertY: boolean;
  39653. /** @hidden */
  39654. _invertVScale: boolean;
  39655. /** @hidden */
  39656. _associatedChannel: number;
  39657. /** @hidden */
  39658. _source: InternalTextureSource;
  39659. /** @hidden */
  39660. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  39661. /** @hidden */
  39662. _bufferView: Nullable<ArrayBufferView>;
  39663. /** @hidden */
  39664. _bufferViewArray: Nullable<ArrayBufferView[]>;
  39665. /** @hidden */
  39666. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  39667. /** @hidden */
  39668. _size: number;
  39669. /** @hidden */
  39670. _extension: string;
  39671. /** @hidden */
  39672. _files: Nullable<string[]>;
  39673. /** @hidden */
  39674. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39675. /** @hidden */
  39676. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39677. /** @hidden */
  39678. _framebuffer: Nullable<WebGLFramebuffer>;
  39679. /** @hidden */
  39680. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  39681. /** @hidden */
  39682. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  39683. /** @hidden */
  39684. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  39685. /** @hidden */
  39686. _attachments: Nullable<number[]>;
  39687. /** @hidden */
  39688. _textureArray: Nullable<InternalTexture[]>;
  39689. /** @hidden */
  39690. _cachedCoordinatesMode: Nullable<number>;
  39691. /** @hidden */
  39692. _cachedWrapU: Nullable<number>;
  39693. /** @hidden */
  39694. _cachedWrapV: Nullable<number>;
  39695. /** @hidden */
  39696. _cachedWrapR: Nullable<number>;
  39697. /** @hidden */
  39698. _cachedAnisotropicFilteringLevel: Nullable<number>;
  39699. /** @hidden */
  39700. _isDisabled: boolean;
  39701. /** @hidden */
  39702. _compression: Nullable<string>;
  39703. /** @hidden */
  39704. _generateStencilBuffer: boolean;
  39705. /** @hidden */
  39706. _generateDepthBuffer: boolean;
  39707. /** @hidden */
  39708. _comparisonFunction: number;
  39709. /** @hidden */
  39710. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  39711. /** @hidden */
  39712. _lodGenerationScale: number;
  39713. /** @hidden */
  39714. _lodGenerationOffset: number;
  39715. /** @hidden */
  39716. _depthStencilTexture: Nullable<InternalTexture>;
  39717. /** @hidden */
  39718. _colorTextureArray: Nullable<WebGLTexture>;
  39719. /** @hidden */
  39720. _depthStencilTextureArray: Nullable<WebGLTexture>;
  39721. /** @hidden */
  39722. _lodTextureHigh: Nullable<BaseTexture>;
  39723. /** @hidden */
  39724. _lodTextureMid: Nullable<BaseTexture>;
  39725. /** @hidden */
  39726. _lodTextureLow: Nullable<BaseTexture>;
  39727. /** @hidden */
  39728. _isRGBD: boolean;
  39729. /** @hidden */
  39730. _linearSpecularLOD: boolean;
  39731. /** @hidden */
  39732. _irradianceTexture: Nullable<BaseTexture>;
  39733. /** @hidden */
  39734. _webGLTexture: Nullable<WebGLTexture>;
  39735. /** @hidden */
  39736. _references: number;
  39737. /** @hidden */
  39738. _gammaSpace: Nullable<boolean>;
  39739. private _engine;
  39740. /**
  39741. * Gets the Engine the texture belongs to.
  39742. * @returns The babylon engine
  39743. */
  39744. getEngine(): ThinEngine;
  39745. /**
  39746. * Gets the data source type of the texture
  39747. */
  39748. get source(): InternalTextureSource;
  39749. /**
  39750. * Creates a new InternalTexture
  39751. * @param engine defines the engine to use
  39752. * @param source defines the type of data that will be used
  39753. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39754. */
  39755. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  39756. /**
  39757. * Increments the number of references (ie. the number of Texture that point to it)
  39758. */
  39759. incrementReferences(): void;
  39760. /**
  39761. * Change the size of the texture (not the size of the content)
  39762. * @param width defines the new width
  39763. * @param height defines the new height
  39764. * @param depth defines the new depth (1 by default)
  39765. */
  39766. updateSize(width: int, height: int, depth?: int): void;
  39767. /** @hidden */
  39768. _rebuild(): void;
  39769. /** @hidden */
  39770. _swapAndDie(target: InternalTexture): void;
  39771. /**
  39772. * Dispose the current allocated resources
  39773. */
  39774. dispose(): void;
  39775. }
  39776. }
  39777. declare module BABYLON {
  39778. /**
  39779. * Class used to work with sound analyzer using fast fourier transform (FFT)
  39780. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39781. */
  39782. export class Analyser {
  39783. /**
  39784. * Gets or sets the smoothing
  39785. * @ignorenaming
  39786. */
  39787. SMOOTHING: number;
  39788. /**
  39789. * Gets or sets the FFT table size
  39790. * @ignorenaming
  39791. */
  39792. FFT_SIZE: number;
  39793. /**
  39794. * Gets or sets the bar graph amplitude
  39795. * @ignorenaming
  39796. */
  39797. BARGRAPHAMPLITUDE: number;
  39798. /**
  39799. * Gets or sets the position of the debug canvas
  39800. * @ignorenaming
  39801. */
  39802. DEBUGCANVASPOS: {
  39803. x: number;
  39804. y: number;
  39805. };
  39806. /**
  39807. * Gets or sets the debug canvas size
  39808. * @ignorenaming
  39809. */
  39810. DEBUGCANVASSIZE: {
  39811. width: number;
  39812. height: number;
  39813. };
  39814. private _byteFreqs;
  39815. private _byteTime;
  39816. private _floatFreqs;
  39817. private _webAudioAnalyser;
  39818. private _debugCanvas;
  39819. private _debugCanvasContext;
  39820. private _scene;
  39821. private _registerFunc;
  39822. private _audioEngine;
  39823. /**
  39824. * Creates a new analyser
  39825. * @param scene defines hosting scene
  39826. */
  39827. constructor(scene: Scene);
  39828. /**
  39829. * Get the number of data values you will have to play with for the visualization
  39830. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  39831. * @returns a number
  39832. */
  39833. getFrequencyBinCount(): number;
  39834. /**
  39835. * Gets the current frequency data as a byte array
  39836. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  39837. * @returns a Uint8Array
  39838. */
  39839. getByteFrequencyData(): Uint8Array;
  39840. /**
  39841. * Gets the current waveform as a byte array
  39842. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  39843. * @returns a Uint8Array
  39844. */
  39845. getByteTimeDomainData(): Uint8Array;
  39846. /**
  39847. * Gets the current frequency data as a float array
  39848. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  39849. * @returns a Float32Array
  39850. */
  39851. getFloatFrequencyData(): Float32Array;
  39852. /**
  39853. * Renders the debug canvas
  39854. */
  39855. drawDebugCanvas(): void;
  39856. /**
  39857. * Stops rendering the debug canvas and removes it
  39858. */
  39859. stopDebugCanvas(): void;
  39860. /**
  39861. * Connects two audio nodes
  39862. * @param inputAudioNode defines first node to connect
  39863. * @param outputAudioNode defines second node to connect
  39864. */
  39865. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  39866. /**
  39867. * Releases all associated resources
  39868. */
  39869. dispose(): void;
  39870. }
  39871. }
  39872. declare module BABYLON {
  39873. /**
  39874. * This represents an audio engine and it is responsible
  39875. * to play, synchronize and analyse sounds throughout the application.
  39876. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39877. */
  39878. export interface IAudioEngine extends IDisposable {
  39879. /**
  39880. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  39881. */
  39882. readonly canUseWebAudio: boolean;
  39883. /**
  39884. * Gets the current AudioContext if available.
  39885. */
  39886. readonly audioContext: Nullable<AudioContext>;
  39887. /**
  39888. * The master gain node defines the global audio volume of your audio engine.
  39889. */
  39890. readonly masterGain: GainNode;
  39891. /**
  39892. * Gets whether or not mp3 are supported by your browser.
  39893. */
  39894. readonly isMP3supported: boolean;
  39895. /**
  39896. * Gets whether or not ogg are supported by your browser.
  39897. */
  39898. readonly isOGGsupported: boolean;
  39899. /**
  39900. * Defines if Babylon should emit a warning if WebAudio is not supported.
  39901. * @ignoreNaming
  39902. */
  39903. WarnedWebAudioUnsupported: boolean;
  39904. /**
  39905. * Defines if the audio engine relies on a custom unlocked button.
  39906. * In this case, the embedded button will not be displayed.
  39907. */
  39908. useCustomUnlockedButton: boolean;
  39909. /**
  39910. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  39911. */
  39912. readonly unlocked: boolean;
  39913. /**
  39914. * Event raised when audio has been unlocked on the browser.
  39915. */
  39916. onAudioUnlockedObservable: Observable<AudioEngine>;
  39917. /**
  39918. * Event raised when audio has been locked on the browser.
  39919. */
  39920. onAudioLockedObservable: Observable<AudioEngine>;
  39921. /**
  39922. * Flags the audio engine in Locked state.
  39923. * This happens due to new browser policies preventing audio to autoplay.
  39924. */
  39925. lock(): void;
  39926. /**
  39927. * Unlocks the audio engine once a user action has been done on the dom.
  39928. * This is helpful to resume play once browser policies have been satisfied.
  39929. */
  39930. unlock(): void;
  39931. /**
  39932. * Gets the global volume sets on the master gain.
  39933. * @returns the global volume if set or -1 otherwise
  39934. */
  39935. getGlobalVolume(): number;
  39936. /**
  39937. * Sets the global volume of your experience (sets on the master gain).
  39938. * @param newVolume Defines the new global volume of the application
  39939. */
  39940. setGlobalVolume(newVolume: number): void;
  39941. /**
  39942. * Connect the audio engine to an audio analyser allowing some amazing
  39943. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39944. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39945. * @param analyser The analyser to connect to the engine
  39946. */
  39947. connectToAnalyser(analyser: Analyser): void;
  39948. }
  39949. /**
  39950. * This represents the default audio engine used in babylon.
  39951. * It is responsible to play, synchronize and analyse sounds throughout the application.
  39952. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39953. */
  39954. export class AudioEngine implements IAudioEngine {
  39955. private _audioContext;
  39956. private _audioContextInitialized;
  39957. private _muteButton;
  39958. private _hostElement;
  39959. /**
  39960. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  39961. */
  39962. canUseWebAudio: boolean;
  39963. /**
  39964. * The master gain node defines the global audio volume of your audio engine.
  39965. */
  39966. masterGain: GainNode;
  39967. /**
  39968. * Defines if Babylon should emit a warning if WebAudio is not supported.
  39969. * @ignoreNaming
  39970. */
  39971. WarnedWebAudioUnsupported: boolean;
  39972. /**
  39973. * Gets whether or not mp3 are supported by your browser.
  39974. */
  39975. isMP3supported: boolean;
  39976. /**
  39977. * Gets whether or not ogg are supported by your browser.
  39978. */
  39979. isOGGsupported: boolean;
  39980. /**
  39981. * Gets whether audio has been unlocked on the device.
  39982. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  39983. * a user interaction has happened.
  39984. */
  39985. unlocked: boolean;
  39986. /**
  39987. * Defines if the audio engine relies on a custom unlocked button.
  39988. * In this case, the embedded button will not be displayed.
  39989. */
  39990. useCustomUnlockedButton: boolean;
  39991. /**
  39992. * Event raised when audio has been unlocked on the browser.
  39993. */
  39994. onAudioUnlockedObservable: Observable<AudioEngine>;
  39995. /**
  39996. * Event raised when audio has been locked on the browser.
  39997. */
  39998. onAudioLockedObservable: Observable<AudioEngine>;
  39999. /**
  40000. * Gets the current AudioContext if available.
  40001. */
  40002. get audioContext(): Nullable<AudioContext>;
  40003. private _connectedAnalyser;
  40004. /**
  40005. * Instantiates a new audio engine.
  40006. *
  40007. * There should be only one per page as some browsers restrict the number
  40008. * of audio contexts you can create.
  40009. * @param hostElement defines the host element where to display the mute icon if necessary
  40010. */
  40011. constructor(hostElement?: Nullable<HTMLElement>);
  40012. /**
  40013. * Flags the audio engine in Locked state.
  40014. * This happens due to new browser policies preventing audio to autoplay.
  40015. */
  40016. lock(): void;
  40017. /**
  40018. * Unlocks the audio engine once a user action has been done on the dom.
  40019. * This is helpful to resume play once browser policies have been satisfied.
  40020. */
  40021. unlock(): void;
  40022. private _resumeAudioContext;
  40023. private _initializeAudioContext;
  40024. private _tryToRun;
  40025. private _triggerRunningState;
  40026. private _triggerSuspendedState;
  40027. private _displayMuteButton;
  40028. private _moveButtonToTopLeft;
  40029. private _onResize;
  40030. private _hideMuteButton;
  40031. /**
  40032. * Destroy and release the resources associated with the audio ccontext.
  40033. */
  40034. dispose(): void;
  40035. /**
  40036. * Gets the global volume sets on the master gain.
  40037. * @returns the global volume if set or -1 otherwise
  40038. */
  40039. getGlobalVolume(): number;
  40040. /**
  40041. * Sets the global volume of your experience (sets on the master gain).
  40042. * @param newVolume Defines the new global volume of the application
  40043. */
  40044. setGlobalVolume(newVolume: number): void;
  40045. /**
  40046. * Connect the audio engine to an audio analyser allowing some amazing
  40047. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40048. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40049. * @param analyser The analyser to connect to the engine
  40050. */
  40051. connectToAnalyser(analyser: Analyser): void;
  40052. }
  40053. }
  40054. declare module BABYLON {
  40055. /**
  40056. * Interface used to present a loading screen while loading a scene
  40057. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40058. */
  40059. export interface ILoadingScreen {
  40060. /**
  40061. * Function called to display the loading screen
  40062. */
  40063. displayLoadingUI: () => void;
  40064. /**
  40065. * Function called to hide the loading screen
  40066. */
  40067. hideLoadingUI: () => void;
  40068. /**
  40069. * Gets or sets the color to use for the background
  40070. */
  40071. loadingUIBackgroundColor: string;
  40072. /**
  40073. * Gets or sets the text to display while loading
  40074. */
  40075. loadingUIText: string;
  40076. }
  40077. /**
  40078. * Class used for the default loading screen
  40079. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40080. */
  40081. export class DefaultLoadingScreen implements ILoadingScreen {
  40082. private _renderingCanvas;
  40083. private _loadingText;
  40084. private _loadingDivBackgroundColor;
  40085. private _loadingDiv;
  40086. private _loadingTextDiv;
  40087. /** Gets or sets the logo url to use for the default loading screen */
  40088. static DefaultLogoUrl: string;
  40089. /** Gets or sets the spinner url to use for the default loading screen */
  40090. static DefaultSpinnerUrl: string;
  40091. /**
  40092. * Creates a new default loading screen
  40093. * @param _renderingCanvas defines the canvas used to render the scene
  40094. * @param _loadingText defines the default text to display
  40095. * @param _loadingDivBackgroundColor defines the default background color
  40096. */
  40097. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40098. /**
  40099. * Function called to display the loading screen
  40100. */
  40101. displayLoadingUI(): void;
  40102. /**
  40103. * Function called to hide the loading screen
  40104. */
  40105. hideLoadingUI(): void;
  40106. /**
  40107. * Gets or sets the text to display while loading
  40108. */
  40109. set loadingUIText(text: string);
  40110. get loadingUIText(): string;
  40111. /**
  40112. * Gets or sets the color to use for the background
  40113. */
  40114. get loadingUIBackgroundColor(): string;
  40115. set loadingUIBackgroundColor(color: string);
  40116. private _resizeLoadingUI;
  40117. }
  40118. }
  40119. declare module BABYLON {
  40120. /**
  40121. * Interface for any object that can request an animation frame
  40122. */
  40123. export interface ICustomAnimationFrameRequester {
  40124. /**
  40125. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40126. */
  40127. renderFunction?: Function;
  40128. /**
  40129. * Called to request the next frame to render to
  40130. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40131. */
  40132. requestAnimationFrame: Function;
  40133. /**
  40134. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40135. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40136. */
  40137. requestID?: number;
  40138. }
  40139. }
  40140. declare module BABYLON {
  40141. /**
  40142. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40143. */
  40144. export class PerformanceMonitor {
  40145. private _enabled;
  40146. private _rollingFrameTime;
  40147. private _lastFrameTimeMs;
  40148. /**
  40149. * constructor
  40150. * @param frameSampleSize The number of samples required to saturate the sliding window
  40151. */
  40152. constructor(frameSampleSize?: number);
  40153. /**
  40154. * Samples current frame
  40155. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40156. */
  40157. sampleFrame(timeMs?: number): void;
  40158. /**
  40159. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40160. */
  40161. get averageFrameTime(): number;
  40162. /**
  40163. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40164. */
  40165. get averageFrameTimeVariance(): number;
  40166. /**
  40167. * Returns the frame time of the most recent frame
  40168. */
  40169. get instantaneousFrameTime(): number;
  40170. /**
  40171. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40172. */
  40173. get averageFPS(): number;
  40174. /**
  40175. * Returns the average framerate in frames per second using the most recent frame time
  40176. */
  40177. get instantaneousFPS(): number;
  40178. /**
  40179. * Returns true if enough samples have been taken to completely fill the sliding window
  40180. */
  40181. get isSaturated(): boolean;
  40182. /**
  40183. * Enables contributions to the sliding window sample set
  40184. */
  40185. enable(): void;
  40186. /**
  40187. * Disables contributions to the sliding window sample set
  40188. * Samples will not be interpolated over the disabled period
  40189. */
  40190. disable(): void;
  40191. /**
  40192. * Returns true if sampling is enabled
  40193. */
  40194. get isEnabled(): boolean;
  40195. /**
  40196. * Resets performance monitor
  40197. */
  40198. reset(): void;
  40199. }
  40200. /**
  40201. * RollingAverage
  40202. *
  40203. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40204. */
  40205. export class RollingAverage {
  40206. /**
  40207. * Current average
  40208. */
  40209. average: number;
  40210. /**
  40211. * Current variance
  40212. */
  40213. variance: number;
  40214. protected _samples: Array<number>;
  40215. protected _sampleCount: number;
  40216. protected _pos: number;
  40217. protected _m2: number;
  40218. /**
  40219. * constructor
  40220. * @param length The number of samples required to saturate the sliding window
  40221. */
  40222. constructor(length: number);
  40223. /**
  40224. * Adds a sample to the sample set
  40225. * @param v The sample value
  40226. */
  40227. add(v: number): void;
  40228. /**
  40229. * Returns previously added values or null if outside of history or outside the sliding window domain
  40230. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40231. * @return Value previously recorded with add() or null if outside of range
  40232. */
  40233. history(i: number): number;
  40234. /**
  40235. * Returns true if enough samples have been taken to completely fill the sliding window
  40236. * @return true if sample-set saturated
  40237. */
  40238. isSaturated(): boolean;
  40239. /**
  40240. * Resets the rolling average (equivalent to 0 samples taken so far)
  40241. */
  40242. reset(): void;
  40243. /**
  40244. * Wraps a value around the sample range boundaries
  40245. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40246. * @return Wrapped position in sample range
  40247. */
  40248. protected _wrapPosition(i: number): number;
  40249. }
  40250. }
  40251. declare module BABYLON {
  40252. /**
  40253. * This class is used to track a performance counter which is number based.
  40254. * The user has access to many properties which give statistics of different nature.
  40255. *
  40256. * The implementer can track two kinds of Performance Counter: time and count.
  40257. * 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.
  40258. * 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.
  40259. */
  40260. export class PerfCounter {
  40261. /**
  40262. * Gets or sets a global boolean to turn on and off all the counters
  40263. */
  40264. static Enabled: boolean;
  40265. /**
  40266. * Returns the smallest value ever
  40267. */
  40268. get min(): number;
  40269. /**
  40270. * Returns the biggest value ever
  40271. */
  40272. get max(): number;
  40273. /**
  40274. * Returns the average value since the performance counter is running
  40275. */
  40276. get average(): number;
  40277. /**
  40278. * Returns the average value of the last second the counter was monitored
  40279. */
  40280. get lastSecAverage(): number;
  40281. /**
  40282. * Returns the current value
  40283. */
  40284. get current(): number;
  40285. /**
  40286. * Gets the accumulated total
  40287. */
  40288. get total(): number;
  40289. /**
  40290. * Gets the total value count
  40291. */
  40292. get count(): number;
  40293. /**
  40294. * Creates a new counter
  40295. */
  40296. constructor();
  40297. /**
  40298. * Call this method to start monitoring a new frame.
  40299. * 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.
  40300. */
  40301. fetchNewFrame(): void;
  40302. /**
  40303. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40304. * @param newCount the count value to add to the monitored count
  40305. * @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.
  40306. */
  40307. addCount(newCount: number, fetchResult: boolean): void;
  40308. /**
  40309. * Start monitoring this performance counter
  40310. */
  40311. beginMonitoring(): void;
  40312. /**
  40313. * Compute the time lapsed since the previous beginMonitoring() call.
  40314. * @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
  40315. */
  40316. endMonitoring(newFrame?: boolean): void;
  40317. private _fetchResult;
  40318. private _startMonitoringTime;
  40319. private _min;
  40320. private _max;
  40321. private _average;
  40322. private _current;
  40323. private _totalValueCount;
  40324. private _totalAccumulated;
  40325. private _lastSecAverage;
  40326. private _lastSecAccumulated;
  40327. private _lastSecTime;
  40328. private _lastSecValueCount;
  40329. }
  40330. }
  40331. declare module BABYLON {
  40332. interface ThinEngine {
  40333. /** @hidden */
  40334. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40335. }
  40336. }
  40337. declare module BABYLON {
  40338. /**
  40339. * Defines the interface used by display changed events
  40340. */
  40341. export interface IDisplayChangedEventArgs {
  40342. /** Gets the vrDisplay object (if any) */
  40343. vrDisplay: Nullable<any>;
  40344. /** Gets a boolean indicating if webVR is supported */
  40345. vrSupported: boolean;
  40346. }
  40347. /**
  40348. * Defines the interface used by objects containing a viewport (like a camera)
  40349. */
  40350. interface IViewportOwnerLike {
  40351. /**
  40352. * Gets or sets the viewport
  40353. */
  40354. viewport: IViewportLike;
  40355. }
  40356. /**
  40357. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40358. */
  40359. export class Engine extends ThinEngine {
  40360. /** Defines that alpha blending is disabled */
  40361. static readonly ALPHA_DISABLE: number;
  40362. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40363. static readonly ALPHA_ADD: number;
  40364. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40365. static readonly ALPHA_COMBINE: number;
  40366. /** Defines that alpha blending to DEST - SRC * DEST */
  40367. static readonly ALPHA_SUBTRACT: number;
  40368. /** Defines that alpha blending to SRC * DEST */
  40369. static readonly ALPHA_MULTIPLY: number;
  40370. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40371. static readonly ALPHA_MAXIMIZED: number;
  40372. /** Defines that alpha blending to SRC + DEST */
  40373. static readonly ALPHA_ONEONE: number;
  40374. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40375. static readonly ALPHA_PREMULTIPLIED: number;
  40376. /**
  40377. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40378. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40379. */
  40380. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40381. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40382. static readonly ALPHA_INTERPOLATE: number;
  40383. /**
  40384. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40385. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40386. */
  40387. static readonly ALPHA_SCREENMODE: number;
  40388. /** Defines that the ressource is not delayed*/
  40389. static readonly DELAYLOADSTATE_NONE: number;
  40390. /** Defines that the ressource was successfully delay loaded */
  40391. static readonly DELAYLOADSTATE_LOADED: number;
  40392. /** Defines that the ressource is currently delay loading */
  40393. static readonly DELAYLOADSTATE_LOADING: number;
  40394. /** Defines that the ressource is delayed and has not started loading */
  40395. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40396. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40397. static readonly NEVER: number;
  40398. /** 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 */
  40399. static readonly ALWAYS: number;
  40400. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40401. static readonly LESS: number;
  40402. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40403. static readonly EQUAL: number;
  40404. /** 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 */
  40405. static readonly LEQUAL: number;
  40406. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40407. static readonly GREATER: number;
  40408. /** 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 */
  40409. static readonly GEQUAL: number;
  40410. /** 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 */
  40411. static readonly NOTEQUAL: number;
  40412. /** Passed to stencilOperation to specify that stencil value must be kept */
  40413. static readonly KEEP: number;
  40414. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40415. static readonly REPLACE: number;
  40416. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40417. static readonly INCR: number;
  40418. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40419. static readonly DECR: number;
  40420. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40421. static readonly INVERT: number;
  40422. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40423. static readonly INCR_WRAP: number;
  40424. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40425. static readonly DECR_WRAP: number;
  40426. /** Texture is not repeating outside of 0..1 UVs */
  40427. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40428. /** Texture is repeating outside of 0..1 UVs */
  40429. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40430. /** Texture is repeating and mirrored */
  40431. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40432. /** ALPHA */
  40433. static readonly TEXTUREFORMAT_ALPHA: number;
  40434. /** LUMINANCE */
  40435. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40436. /** LUMINANCE_ALPHA */
  40437. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40438. /** RGB */
  40439. static readonly TEXTUREFORMAT_RGB: number;
  40440. /** RGBA */
  40441. static readonly TEXTUREFORMAT_RGBA: number;
  40442. /** RED */
  40443. static readonly TEXTUREFORMAT_RED: number;
  40444. /** RED (2nd reference) */
  40445. static readonly TEXTUREFORMAT_R: number;
  40446. /** RG */
  40447. static readonly TEXTUREFORMAT_RG: number;
  40448. /** RED_INTEGER */
  40449. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40450. /** RED_INTEGER (2nd reference) */
  40451. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40452. /** RG_INTEGER */
  40453. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40454. /** RGB_INTEGER */
  40455. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40456. /** RGBA_INTEGER */
  40457. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40458. /** UNSIGNED_BYTE */
  40459. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40460. /** UNSIGNED_BYTE (2nd reference) */
  40461. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40462. /** FLOAT */
  40463. static readonly TEXTURETYPE_FLOAT: number;
  40464. /** HALF_FLOAT */
  40465. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40466. /** BYTE */
  40467. static readonly TEXTURETYPE_BYTE: number;
  40468. /** SHORT */
  40469. static readonly TEXTURETYPE_SHORT: number;
  40470. /** UNSIGNED_SHORT */
  40471. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40472. /** INT */
  40473. static readonly TEXTURETYPE_INT: number;
  40474. /** UNSIGNED_INT */
  40475. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40476. /** UNSIGNED_SHORT_4_4_4_4 */
  40477. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40478. /** UNSIGNED_SHORT_5_5_5_1 */
  40479. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40480. /** UNSIGNED_SHORT_5_6_5 */
  40481. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40482. /** UNSIGNED_INT_2_10_10_10_REV */
  40483. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40484. /** UNSIGNED_INT_24_8 */
  40485. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40486. /** UNSIGNED_INT_10F_11F_11F_REV */
  40487. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40488. /** UNSIGNED_INT_5_9_9_9_REV */
  40489. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40490. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40491. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40492. /** nearest is mag = nearest and min = nearest and mip = linear */
  40493. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40494. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40495. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40496. /** Trilinear is mag = linear and min = linear and mip = linear */
  40497. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40498. /** nearest is mag = nearest and min = nearest and mip = linear */
  40499. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40500. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40501. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40502. /** Trilinear is mag = linear and min = linear and mip = linear */
  40503. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40504. /** mag = nearest and min = nearest and mip = nearest */
  40505. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40506. /** mag = nearest and min = linear and mip = nearest */
  40507. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40508. /** mag = nearest and min = linear and mip = linear */
  40509. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40510. /** mag = nearest and min = linear and mip = none */
  40511. static readonly TEXTURE_NEAREST_LINEAR: number;
  40512. /** mag = nearest and min = nearest and mip = none */
  40513. static readonly TEXTURE_NEAREST_NEAREST: number;
  40514. /** mag = linear and min = nearest and mip = nearest */
  40515. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40516. /** mag = linear and min = nearest and mip = linear */
  40517. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40518. /** mag = linear and min = linear and mip = none */
  40519. static readonly TEXTURE_LINEAR_LINEAR: number;
  40520. /** mag = linear and min = nearest and mip = none */
  40521. static readonly TEXTURE_LINEAR_NEAREST: number;
  40522. /** Explicit coordinates mode */
  40523. static readonly TEXTURE_EXPLICIT_MODE: number;
  40524. /** Spherical coordinates mode */
  40525. static readonly TEXTURE_SPHERICAL_MODE: number;
  40526. /** Planar coordinates mode */
  40527. static readonly TEXTURE_PLANAR_MODE: number;
  40528. /** Cubic coordinates mode */
  40529. static readonly TEXTURE_CUBIC_MODE: number;
  40530. /** Projection coordinates mode */
  40531. static readonly TEXTURE_PROJECTION_MODE: number;
  40532. /** Skybox coordinates mode */
  40533. static readonly TEXTURE_SKYBOX_MODE: number;
  40534. /** Inverse Cubic coordinates mode */
  40535. static readonly TEXTURE_INVCUBIC_MODE: number;
  40536. /** Equirectangular coordinates mode */
  40537. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40538. /** Equirectangular Fixed coordinates mode */
  40539. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40540. /** Equirectangular Fixed Mirrored coordinates mode */
  40541. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40542. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40543. static readonly SCALEMODE_FLOOR: number;
  40544. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40545. static readonly SCALEMODE_NEAREST: number;
  40546. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40547. static readonly SCALEMODE_CEILING: number;
  40548. /**
  40549. * Returns the current npm package of the sdk
  40550. */
  40551. static get NpmPackage(): string;
  40552. /**
  40553. * Returns the current version of the framework
  40554. */
  40555. static get Version(): string;
  40556. /** Gets the list of created engines */
  40557. static get Instances(): Engine[];
  40558. /**
  40559. * Gets the latest created engine
  40560. */
  40561. static get LastCreatedEngine(): Nullable<Engine>;
  40562. /**
  40563. * Gets the latest created scene
  40564. */
  40565. static get LastCreatedScene(): Nullable<Scene>;
  40566. /**
  40567. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40568. * @param flag defines which part of the materials must be marked as dirty
  40569. * @param predicate defines a predicate used to filter which materials should be affected
  40570. */
  40571. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40572. /**
  40573. * Method called to create the default loading screen.
  40574. * This can be overriden in your own app.
  40575. * @param canvas The rendering canvas element
  40576. * @returns The loading screen
  40577. */
  40578. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  40579. /**
  40580. * Method called to create the default rescale post process on each engine.
  40581. */
  40582. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  40583. /**
  40584. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  40585. **/
  40586. enableOfflineSupport: boolean;
  40587. /**
  40588. * 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)
  40589. **/
  40590. disableManifestCheck: boolean;
  40591. /**
  40592. * Gets the list of created scenes
  40593. */
  40594. scenes: Scene[];
  40595. /**
  40596. * Event raised when a new scene is created
  40597. */
  40598. onNewSceneAddedObservable: Observable<Scene>;
  40599. /**
  40600. * Gets the list of created postprocesses
  40601. */
  40602. postProcesses: PostProcess[];
  40603. /**
  40604. * Gets a boolean indicating if the pointer is currently locked
  40605. */
  40606. isPointerLock: boolean;
  40607. /**
  40608. * Observable event triggered each time the rendering canvas is resized
  40609. */
  40610. onResizeObservable: Observable<Engine>;
  40611. /**
  40612. * Observable event triggered each time the canvas loses focus
  40613. */
  40614. onCanvasBlurObservable: Observable<Engine>;
  40615. /**
  40616. * Observable event triggered each time the canvas gains focus
  40617. */
  40618. onCanvasFocusObservable: Observable<Engine>;
  40619. /**
  40620. * Observable event triggered each time the canvas receives pointerout event
  40621. */
  40622. onCanvasPointerOutObservable: Observable<PointerEvent>;
  40623. /**
  40624. * Observable raised when the engine begins a new frame
  40625. */
  40626. onBeginFrameObservable: Observable<Engine>;
  40627. /**
  40628. * If set, will be used to request the next animation frame for the render loop
  40629. */
  40630. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  40631. /**
  40632. * Observable raised when the engine ends the current frame
  40633. */
  40634. onEndFrameObservable: Observable<Engine>;
  40635. /**
  40636. * Observable raised when the engine is about to compile a shader
  40637. */
  40638. onBeforeShaderCompilationObservable: Observable<Engine>;
  40639. /**
  40640. * Observable raised when the engine has jsut compiled a shader
  40641. */
  40642. onAfterShaderCompilationObservable: Observable<Engine>;
  40643. /**
  40644. * Gets the audio engine
  40645. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40646. * @ignorenaming
  40647. */
  40648. static audioEngine: IAudioEngine;
  40649. /**
  40650. * Default AudioEngine factory responsible of creating the Audio Engine.
  40651. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  40652. */
  40653. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  40654. /**
  40655. * Default offline support factory responsible of creating a tool used to store data locally.
  40656. * By default, this will create a Database object if the workload has been embedded.
  40657. */
  40658. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  40659. private _loadingScreen;
  40660. private _pointerLockRequested;
  40661. private _rescalePostProcess;
  40662. private _deterministicLockstep;
  40663. private _lockstepMaxSteps;
  40664. private _timeStep;
  40665. protected get _supportsHardwareTextureRescaling(): boolean;
  40666. private _fps;
  40667. private _deltaTime;
  40668. /** @hidden */
  40669. _drawCalls: PerfCounter;
  40670. /** 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 */
  40671. canvasTabIndex: number;
  40672. /**
  40673. * Turn this value on if you want to pause FPS computation when in background
  40674. */
  40675. disablePerformanceMonitorInBackground: boolean;
  40676. private _performanceMonitor;
  40677. /**
  40678. * Gets the performance monitor attached to this engine
  40679. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40680. */
  40681. get performanceMonitor(): PerformanceMonitor;
  40682. private _onFocus;
  40683. private _onBlur;
  40684. private _onCanvasPointerOut;
  40685. private _onCanvasBlur;
  40686. private _onCanvasFocus;
  40687. private _onFullscreenChange;
  40688. private _onPointerLockChange;
  40689. /**
  40690. * Gets the HTML element used to attach event listeners
  40691. * @returns a HTML element
  40692. */
  40693. getInputElement(): Nullable<HTMLElement>;
  40694. /**
  40695. * Creates a new engine
  40696. * @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
  40697. * @param antialias defines enable antialiasing (default: false)
  40698. * @param options defines further options to be sent to the getContext() function
  40699. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40700. */
  40701. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40702. /**
  40703. * Gets current aspect ratio
  40704. * @param viewportOwner defines the camera to use to get the aspect ratio
  40705. * @param useScreen defines if screen size must be used (or the current render target if any)
  40706. * @returns a number defining the aspect ratio
  40707. */
  40708. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  40709. /**
  40710. * Gets current screen aspect ratio
  40711. * @returns a number defining the aspect ratio
  40712. */
  40713. getScreenAspectRatio(): number;
  40714. /**
  40715. * Gets the client rect of the HTML canvas attached with the current webGL context
  40716. * @returns a client rectanglee
  40717. */
  40718. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  40719. /**
  40720. * Gets the client rect of the HTML element used for events
  40721. * @returns a client rectanglee
  40722. */
  40723. getInputElementClientRect(): Nullable<ClientRect>;
  40724. /**
  40725. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  40726. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40727. * @returns true if engine is in deterministic lock step mode
  40728. */
  40729. isDeterministicLockStep(): boolean;
  40730. /**
  40731. * Gets the max steps when engine is running in deterministic lock step
  40732. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40733. * @returns the max steps
  40734. */
  40735. getLockstepMaxSteps(): number;
  40736. /**
  40737. * Returns the time in ms between steps when using deterministic lock step.
  40738. * @returns time step in (ms)
  40739. */
  40740. getTimeStep(): number;
  40741. /**
  40742. * Force the mipmap generation for the given render target texture
  40743. * @param texture defines the render target texture to use
  40744. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  40745. */
  40746. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  40747. /** States */
  40748. /**
  40749. * Set various states to the webGL context
  40750. * @param culling defines backface culling state
  40751. * @param zOffset defines the value to apply to zOffset (0 by default)
  40752. * @param force defines if states must be applied even if cache is up to date
  40753. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  40754. */
  40755. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40756. /**
  40757. * Set the z offset to apply to current rendering
  40758. * @param value defines the offset to apply
  40759. */
  40760. setZOffset(value: number): void;
  40761. /**
  40762. * Gets the current value of the zOffset
  40763. * @returns the current zOffset state
  40764. */
  40765. getZOffset(): number;
  40766. /**
  40767. * Enable or disable depth buffering
  40768. * @param enable defines the state to set
  40769. */
  40770. setDepthBuffer(enable: boolean): void;
  40771. /**
  40772. * Gets a boolean indicating if depth writing is enabled
  40773. * @returns the current depth writing state
  40774. */
  40775. getDepthWrite(): boolean;
  40776. /**
  40777. * Enable or disable depth writing
  40778. * @param enable defines the state to set
  40779. */
  40780. setDepthWrite(enable: boolean): void;
  40781. /**
  40782. * Gets a boolean indicating if stencil buffer is enabled
  40783. * @returns the current stencil buffer state
  40784. */
  40785. getStencilBuffer(): boolean;
  40786. /**
  40787. * Enable or disable the stencil buffer
  40788. * @param enable defines if the stencil buffer must be enabled or disabled
  40789. */
  40790. setStencilBuffer(enable: boolean): void;
  40791. /**
  40792. * Gets the current stencil mask
  40793. * @returns a number defining the new stencil mask to use
  40794. */
  40795. getStencilMask(): number;
  40796. /**
  40797. * Sets the current stencil mask
  40798. * @param mask defines the new stencil mask to use
  40799. */
  40800. setStencilMask(mask: number): void;
  40801. /**
  40802. * Gets the current stencil function
  40803. * @returns a number defining the stencil function to use
  40804. */
  40805. getStencilFunction(): number;
  40806. /**
  40807. * Gets the current stencil reference value
  40808. * @returns a number defining the stencil reference value to use
  40809. */
  40810. getStencilFunctionReference(): number;
  40811. /**
  40812. * Gets the current stencil mask
  40813. * @returns a number defining the stencil mask to use
  40814. */
  40815. getStencilFunctionMask(): number;
  40816. /**
  40817. * Sets the current stencil function
  40818. * @param stencilFunc defines the new stencil function to use
  40819. */
  40820. setStencilFunction(stencilFunc: number): void;
  40821. /**
  40822. * Sets the current stencil reference
  40823. * @param reference defines the new stencil reference to use
  40824. */
  40825. setStencilFunctionReference(reference: number): void;
  40826. /**
  40827. * Sets the current stencil mask
  40828. * @param mask defines the new stencil mask to use
  40829. */
  40830. setStencilFunctionMask(mask: number): void;
  40831. /**
  40832. * Gets the current stencil operation when stencil fails
  40833. * @returns a number defining stencil operation to use when stencil fails
  40834. */
  40835. getStencilOperationFail(): number;
  40836. /**
  40837. * Gets the current stencil operation when depth fails
  40838. * @returns a number defining stencil operation to use when depth fails
  40839. */
  40840. getStencilOperationDepthFail(): number;
  40841. /**
  40842. * Gets the current stencil operation when stencil passes
  40843. * @returns a number defining stencil operation to use when stencil passes
  40844. */
  40845. getStencilOperationPass(): number;
  40846. /**
  40847. * Sets the stencil operation to use when stencil fails
  40848. * @param operation defines the stencil operation to use when stencil fails
  40849. */
  40850. setStencilOperationFail(operation: number): void;
  40851. /**
  40852. * Sets the stencil operation to use when depth fails
  40853. * @param operation defines the stencil operation to use when depth fails
  40854. */
  40855. setStencilOperationDepthFail(operation: number): void;
  40856. /**
  40857. * Sets the stencil operation to use when stencil passes
  40858. * @param operation defines the stencil operation to use when stencil passes
  40859. */
  40860. setStencilOperationPass(operation: number): void;
  40861. /**
  40862. * Sets a boolean indicating if the dithering state is enabled or disabled
  40863. * @param value defines the dithering state
  40864. */
  40865. setDitheringState(value: boolean): void;
  40866. /**
  40867. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  40868. * @param value defines the rasterizer state
  40869. */
  40870. setRasterizerState(value: boolean): void;
  40871. /**
  40872. * Gets the current depth function
  40873. * @returns a number defining the depth function
  40874. */
  40875. getDepthFunction(): Nullable<number>;
  40876. /**
  40877. * Sets the current depth function
  40878. * @param depthFunc defines the function to use
  40879. */
  40880. setDepthFunction(depthFunc: number): void;
  40881. /**
  40882. * Sets the current depth function to GREATER
  40883. */
  40884. setDepthFunctionToGreater(): void;
  40885. /**
  40886. * Sets the current depth function to GEQUAL
  40887. */
  40888. setDepthFunctionToGreaterOrEqual(): void;
  40889. /**
  40890. * Sets the current depth function to LESS
  40891. */
  40892. setDepthFunctionToLess(): void;
  40893. /**
  40894. * Sets the current depth function to LEQUAL
  40895. */
  40896. setDepthFunctionToLessOrEqual(): void;
  40897. private _cachedStencilBuffer;
  40898. private _cachedStencilFunction;
  40899. private _cachedStencilMask;
  40900. private _cachedStencilOperationPass;
  40901. private _cachedStencilOperationFail;
  40902. private _cachedStencilOperationDepthFail;
  40903. private _cachedStencilReference;
  40904. /**
  40905. * Caches the the state of the stencil buffer
  40906. */
  40907. cacheStencilState(): void;
  40908. /**
  40909. * Restores the state of the stencil buffer
  40910. */
  40911. restoreStencilState(): void;
  40912. /**
  40913. * Directly set the WebGL Viewport
  40914. * @param x defines the x coordinate of the viewport (in screen space)
  40915. * @param y defines the y coordinate of the viewport (in screen space)
  40916. * @param width defines the width of the viewport (in screen space)
  40917. * @param height defines the height of the viewport (in screen space)
  40918. * @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
  40919. */
  40920. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  40921. /**
  40922. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  40923. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  40924. * @param y defines the y-coordinate of the corner of the clear rectangle
  40925. * @param width defines the width of the clear rectangle
  40926. * @param height defines the height of the clear rectangle
  40927. * @param clearColor defines the clear color
  40928. */
  40929. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  40930. /**
  40931. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  40932. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  40933. * @param y defines the y-coordinate of the corner of the clear rectangle
  40934. * @param width defines the width of the clear rectangle
  40935. * @param height defines the height of the clear rectangle
  40936. */
  40937. enableScissor(x: number, y: number, width: number, height: number): void;
  40938. /**
  40939. * Disable previously set scissor test rectangle
  40940. */
  40941. disableScissor(): void;
  40942. protected _reportDrawCall(): void;
  40943. /**
  40944. * Initializes a webVR display and starts listening to display change events
  40945. * The onVRDisplayChangedObservable will be notified upon these changes
  40946. * @returns The onVRDisplayChangedObservable
  40947. */
  40948. initWebVR(): Observable<IDisplayChangedEventArgs>;
  40949. /** @hidden */
  40950. _prepareVRComponent(): void;
  40951. /** @hidden */
  40952. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  40953. /** @hidden */
  40954. _submitVRFrame(): void;
  40955. /**
  40956. * Call this function to leave webVR mode
  40957. * Will do nothing if webVR is not supported or if there is no webVR device
  40958. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40959. */
  40960. disableVR(): void;
  40961. /**
  40962. * Gets a boolean indicating that the system is in VR mode and is presenting
  40963. * @returns true if VR mode is engaged
  40964. */
  40965. isVRPresenting(): boolean;
  40966. /** @hidden */
  40967. _requestVRFrame(): void;
  40968. /** @hidden */
  40969. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40970. /**
  40971. * Gets the source code of the vertex shader associated with a specific webGL program
  40972. * @param program defines the program to use
  40973. * @returns a string containing the source code of the vertex shader associated with the program
  40974. */
  40975. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  40976. /**
  40977. * Gets the source code of the fragment shader associated with a specific webGL program
  40978. * @param program defines the program to use
  40979. * @returns a string containing the source code of the fragment shader associated with the program
  40980. */
  40981. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  40982. /**
  40983. * Sets a depth stencil texture from a render target to the according uniform.
  40984. * @param channel The texture channel
  40985. * @param uniform The uniform to set
  40986. * @param texture The render target texture containing the depth stencil texture to apply
  40987. */
  40988. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  40989. /**
  40990. * Sets a texture to the webGL context from a postprocess
  40991. * @param channel defines the channel to use
  40992. * @param postProcess defines the source postprocess
  40993. */
  40994. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  40995. /**
  40996. * Binds the output of the passed in post process to the texture channel specified
  40997. * @param channel The channel the texture should be bound to
  40998. * @param postProcess The post process which's output should be bound
  40999. */
  41000. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41001. protected _rebuildBuffers(): void;
  41002. /** @hidden */
  41003. _renderFrame(): void;
  41004. _renderLoop(): void;
  41005. /** @hidden */
  41006. _renderViews(): boolean;
  41007. /**
  41008. * Toggle full screen mode
  41009. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41010. */
  41011. switchFullscreen(requestPointerLock: boolean): void;
  41012. /**
  41013. * Enters full screen mode
  41014. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41015. */
  41016. enterFullscreen(requestPointerLock: boolean): void;
  41017. /**
  41018. * Exits full screen mode
  41019. */
  41020. exitFullscreen(): void;
  41021. /**
  41022. * Enters Pointerlock mode
  41023. */
  41024. enterPointerlock(): void;
  41025. /**
  41026. * Exits Pointerlock mode
  41027. */
  41028. exitPointerlock(): void;
  41029. /**
  41030. * Begin a new frame
  41031. */
  41032. beginFrame(): void;
  41033. /**
  41034. * Enf the current frame
  41035. */
  41036. endFrame(): void;
  41037. resize(): void;
  41038. /**
  41039. * Force a specific size of the canvas
  41040. * @param width defines the new canvas' width
  41041. * @param height defines the new canvas' height
  41042. * @returns true if the size was changed
  41043. */
  41044. setSize(width: number, height: number): boolean;
  41045. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41046. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41047. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41048. _releaseTexture(texture: InternalTexture): void;
  41049. /**
  41050. * @hidden
  41051. * Rescales a texture
  41052. * @param source input texutre
  41053. * @param destination destination texture
  41054. * @param scene scene to use to render the resize
  41055. * @param internalFormat format to use when resizing
  41056. * @param onComplete callback to be called when resize has completed
  41057. */
  41058. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41059. /**
  41060. * Gets the current framerate
  41061. * @returns a number representing the framerate
  41062. */
  41063. getFps(): number;
  41064. /**
  41065. * Gets the time spent between current and previous frame
  41066. * @returns a number representing the delta time in ms
  41067. */
  41068. getDeltaTime(): number;
  41069. private _measureFps;
  41070. /** @hidden */
  41071. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41072. /**
  41073. * Updates the sample count of a render target texture
  41074. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41075. * @param texture defines the texture to update
  41076. * @param samples defines the sample count to set
  41077. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41078. */
  41079. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41080. /**
  41081. * Updates a depth texture Comparison Mode and Function.
  41082. * If the comparison Function is equal to 0, the mode will be set to none.
  41083. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41084. * @param texture The texture to set the comparison function for
  41085. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41086. */
  41087. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41088. /**
  41089. * Creates a webGL buffer to use with instanciation
  41090. * @param capacity defines the size of the buffer
  41091. * @returns the webGL buffer
  41092. */
  41093. createInstancesBuffer(capacity: number): DataBuffer;
  41094. /**
  41095. * Delete a webGL buffer used with instanciation
  41096. * @param buffer defines the webGL buffer to delete
  41097. */
  41098. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41099. private _clientWaitAsync;
  41100. /** @hidden */
  41101. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41102. dispose(): void;
  41103. private _disableTouchAction;
  41104. /**
  41105. * Display the loading screen
  41106. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41107. */
  41108. displayLoadingUI(): void;
  41109. /**
  41110. * Hide the loading screen
  41111. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41112. */
  41113. hideLoadingUI(): void;
  41114. /**
  41115. * Gets the current loading screen object
  41116. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41117. */
  41118. get loadingScreen(): ILoadingScreen;
  41119. /**
  41120. * Sets the current loading screen object
  41121. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41122. */
  41123. set loadingScreen(loadingScreen: ILoadingScreen);
  41124. /**
  41125. * Sets the current loading screen text
  41126. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41127. */
  41128. set loadingUIText(text: string);
  41129. /**
  41130. * Sets the current loading screen background color
  41131. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41132. */
  41133. set loadingUIBackgroundColor(color: string);
  41134. /** Pointerlock and fullscreen */
  41135. /**
  41136. * Ask the browser to promote the current element to pointerlock mode
  41137. * @param element defines the DOM element to promote
  41138. */
  41139. static _RequestPointerlock(element: HTMLElement): void;
  41140. /**
  41141. * Asks the browser to exit pointerlock mode
  41142. */
  41143. static _ExitPointerlock(): void;
  41144. /**
  41145. * Ask the browser to promote the current element to fullscreen rendering mode
  41146. * @param element defines the DOM element to promote
  41147. */
  41148. static _RequestFullscreen(element: HTMLElement): void;
  41149. /**
  41150. * Asks the browser to exit fullscreen mode
  41151. */
  41152. static _ExitFullscreen(): void;
  41153. }
  41154. }
  41155. declare module BABYLON {
  41156. /**
  41157. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41158. * during the life time of the application.
  41159. */
  41160. export class EngineStore {
  41161. /** Gets the list of created engines */
  41162. static Instances: Engine[];
  41163. /** @hidden */
  41164. static _LastCreatedScene: Nullable<Scene>;
  41165. /**
  41166. * Gets the latest created engine
  41167. */
  41168. static get LastCreatedEngine(): Nullable<Engine>;
  41169. /**
  41170. * Gets the latest created scene
  41171. */
  41172. static get LastCreatedScene(): Nullable<Scene>;
  41173. /**
  41174. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41175. * @ignorenaming
  41176. */
  41177. static UseFallbackTexture: boolean;
  41178. /**
  41179. * Texture content used if a texture cannot loaded
  41180. * @ignorenaming
  41181. */
  41182. static FallbackTexture: string;
  41183. }
  41184. }
  41185. declare module BABYLON {
  41186. /**
  41187. * Helper class that provides a small promise polyfill
  41188. */
  41189. export class PromisePolyfill {
  41190. /**
  41191. * Static function used to check if the polyfill is required
  41192. * If this is the case then the function will inject the polyfill to window.Promise
  41193. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41194. */
  41195. static Apply(force?: boolean): void;
  41196. }
  41197. }
  41198. declare module BABYLON {
  41199. /**
  41200. * Interface for screenshot methods with describe argument called `size` as object with options
  41201. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41202. */
  41203. export interface IScreenshotSize {
  41204. /**
  41205. * number in pixels for canvas height
  41206. */
  41207. height?: number;
  41208. /**
  41209. * multiplier allowing render at a higher or lower resolution
  41210. * If value is defined then height and width will be ignored and taken from camera
  41211. */
  41212. precision?: number;
  41213. /**
  41214. * number in pixels for canvas width
  41215. */
  41216. width?: number;
  41217. }
  41218. }
  41219. declare module BABYLON {
  41220. interface IColor4Like {
  41221. r: float;
  41222. g: float;
  41223. b: float;
  41224. a: float;
  41225. }
  41226. /**
  41227. * Class containing a set of static utilities functions
  41228. */
  41229. export class Tools {
  41230. /**
  41231. * Gets or sets the base URL to use to load assets
  41232. */
  41233. static get BaseUrl(): string;
  41234. static set BaseUrl(value: string);
  41235. /**
  41236. * Enable/Disable Custom HTTP Request Headers globally.
  41237. * default = false
  41238. * @see CustomRequestHeaders
  41239. */
  41240. static UseCustomRequestHeaders: boolean;
  41241. /**
  41242. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41243. * i.e. when loading files, where the server/service expects an Authorization header
  41244. */
  41245. static CustomRequestHeaders: {
  41246. [key: string]: string;
  41247. };
  41248. /**
  41249. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41250. */
  41251. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41252. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41253. /**
  41254. * Default behaviour for cors in the application.
  41255. * It can be a string if the expected behavior is identical in the entire app.
  41256. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41257. */
  41258. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41259. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41260. /**
  41261. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41262. * @ignorenaming
  41263. */
  41264. static get UseFallbackTexture(): boolean;
  41265. static set UseFallbackTexture(value: boolean);
  41266. /**
  41267. * Use this object to register external classes like custom textures or material
  41268. * to allow the laoders to instantiate them
  41269. */
  41270. static get RegisteredExternalClasses(): {
  41271. [key: string]: Object;
  41272. };
  41273. static set RegisteredExternalClasses(classes: {
  41274. [key: string]: Object;
  41275. });
  41276. /**
  41277. * Texture content used if a texture cannot loaded
  41278. * @ignorenaming
  41279. */
  41280. static get fallbackTexture(): string;
  41281. static set fallbackTexture(value: string);
  41282. /**
  41283. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41284. * @param u defines the coordinate on X axis
  41285. * @param v defines the coordinate on Y axis
  41286. * @param width defines the width of the source data
  41287. * @param height defines the height of the source data
  41288. * @param pixels defines the source byte array
  41289. * @param color defines the output color
  41290. */
  41291. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41292. /**
  41293. * Interpolates between a and b via alpha
  41294. * @param a The lower value (returned when alpha = 0)
  41295. * @param b The upper value (returned when alpha = 1)
  41296. * @param alpha The interpolation-factor
  41297. * @return The mixed value
  41298. */
  41299. static Mix(a: number, b: number, alpha: number): number;
  41300. /**
  41301. * Tries to instantiate a new object from a given class name
  41302. * @param className defines the class name to instantiate
  41303. * @returns the new object or null if the system was not able to do the instantiation
  41304. */
  41305. static Instantiate(className: string): any;
  41306. /**
  41307. * Provides a slice function that will work even on IE
  41308. * @param data defines the array to slice
  41309. * @param start defines the start of the data (optional)
  41310. * @param end defines the end of the data (optional)
  41311. * @returns the new sliced array
  41312. */
  41313. static Slice<T>(data: T, start?: number, end?: number): T;
  41314. /**
  41315. * Polyfill for setImmediate
  41316. * @param action defines the action to execute after the current execution block
  41317. */
  41318. static SetImmediate(action: () => void): void;
  41319. /**
  41320. * Function indicating if a number is an exponent of 2
  41321. * @param value defines the value to test
  41322. * @returns true if the value is an exponent of 2
  41323. */
  41324. static IsExponentOfTwo(value: number): boolean;
  41325. private static _tmpFloatArray;
  41326. /**
  41327. * Returns the nearest 32-bit single precision float representation of a Number
  41328. * @param value A Number. If the parameter is of a different type, it will get converted
  41329. * to a number or to NaN if it cannot be converted
  41330. * @returns number
  41331. */
  41332. static FloatRound(value: number): number;
  41333. /**
  41334. * Extracts the filename from a path
  41335. * @param path defines the path to use
  41336. * @returns the filename
  41337. */
  41338. static GetFilename(path: string): string;
  41339. /**
  41340. * Extracts the "folder" part of a path (everything before the filename).
  41341. * @param uri The URI to extract the info from
  41342. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41343. * @returns The "folder" part of the path
  41344. */
  41345. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41346. /**
  41347. * Extracts text content from a DOM element hierarchy
  41348. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41349. */
  41350. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41351. /**
  41352. * Convert an angle in radians to degrees
  41353. * @param angle defines the angle to convert
  41354. * @returns the angle in degrees
  41355. */
  41356. static ToDegrees(angle: number): number;
  41357. /**
  41358. * Convert an angle in degrees to radians
  41359. * @param angle defines the angle to convert
  41360. * @returns the angle in radians
  41361. */
  41362. static ToRadians(angle: number): number;
  41363. /**
  41364. * Returns an array if obj is not an array
  41365. * @param obj defines the object to evaluate as an array
  41366. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41367. * @returns either obj directly if obj is an array or a new array containing obj
  41368. */
  41369. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41370. /**
  41371. * Gets the pointer prefix to use
  41372. * @param engine defines the engine we are finding the prefix for
  41373. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41374. */
  41375. static GetPointerPrefix(engine: Engine): string;
  41376. /**
  41377. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41378. * @param url define the url we are trying
  41379. * @param element define the dom element where to configure the cors policy
  41380. */
  41381. static SetCorsBehavior(url: string | string[], element: {
  41382. crossOrigin: string | null;
  41383. }): void;
  41384. /**
  41385. * Removes unwanted characters from an url
  41386. * @param url defines the url to clean
  41387. * @returns the cleaned url
  41388. */
  41389. static CleanUrl(url: string): string;
  41390. /**
  41391. * Gets or sets a function used to pre-process url before using them to load assets
  41392. */
  41393. static get PreprocessUrl(): (url: string) => string;
  41394. static set PreprocessUrl(processor: (url: string) => string);
  41395. /**
  41396. * Loads an image as an HTMLImageElement.
  41397. * @param input url string, ArrayBuffer, or Blob to load
  41398. * @param onLoad callback called when the image successfully loads
  41399. * @param onError callback called when the image fails to load
  41400. * @param offlineProvider offline provider for caching
  41401. * @param mimeType optional mime type
  41402. * @returns the HTMLImageElement of the loaded image
  41403. */
  41404. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41405. /**
  41406. * Loads a file from a url
  41407. * @param url url string, ArrayBuffer, or Blob to load
  41408. * @param onSuccess callback called when the file successfully loads
  41409. * @param onProgress callback called while file is loading (if the server supports this mode)
  41410. * @param offlineProvider defines the offline provider for caching
  41411. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41412. * @param onError callback called when the file fails to load
  41413. * @returns a file request object
  41414. */
  41415. 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;
  41416. /**
  41417. * Loads a file from a url
  41418. * @param url the file url to load
  41419. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41420. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41421. */
  41422. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41423. /**
  41424. * Load a script (identified by an url). When the url returns, the
  41425. * content of this file is added into a new script element, attached to the DOM (body element)
  41426. * @param scriptUrl defines the url of the script to laod
  41427. * @param onSuccess defines the callback called when the script is loaded
  41428. * @param onError defines the callback to call if an error occurs
  41429. * @param scriptId defines the id of the script element
  41430. */
  41431. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41432. /**
  41433. * Load an asynchronous script (identified by an url). When the url returns, the
  41434. * content of this file is added into a new script element, attached to the DOM (body element)
  41435. * @param scriptUrl defines the url of the script to laod
  41436. * @param scriptId defines the id of the script element
  41437. * @returns a promise request object
  41438. */
  41439. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41440. /**
  41441. * Loads a file from a blob
  41442. * @param fileToLoad defines the blob to use
  41443. * @param callback defines the callback to call when data is loaded
  41444. * @param progressCallback defines the callback to call during loading process
  41445. * @returns a file request object
  41446. */
  41447. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41448. /**
  41449. * Reads a file from a File object
  41450. * @param file defines the file to load
  41451. * @param onSuccess defines the callback to call when data is loaded
  41452. * @param onProgress defines the callback to call during loading process
  41453. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41454. * @param onError defines the callback to call when an error occurs
  41455. * @returns a file request object
  41456. */
  41457. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41458. /**
  41459. * Creates a data url from a given string content
  41460. * @param content defines the content to convert
  41461. * @returns the new data url link
  41462. */
  41463. static FileAsURL(content: string): string;
  41464. /**
  41465. * Format the given number to a specific decimal format
  41466. * @param value defines the number to format
  41467. * @param decimals defines the number of decimals to use
  41468. * @returns the formatted string
  41469. */
  41470. static Format(value: number, decimals?: number): string;
  41471. /**
  41472. * Tries to copy an object by duplicating every property
  41473. * @param source defines the source object
  41474. * @param destination defines the target object
  41475. * @param doNotCopyList defines a list of properties to avoid
  41476. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41477. */
  41478. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41479. /**
  41480. * Gets a boolean indicating if the given object has no own property
  41481. * @param obj defines the object to test
  41482. * @returns true if object has no own property
  41483. */
  41484. static IsEmpty(obj: any): boolean;
  41485. /**
  41486. * Function used to register events at window level
  41487. * @param windowElement defines the Window object to use
  41488. * @param events defines the events to register
  41489. */
  41490. static RegisterTopRootEvents(windowElement: Window, events: {
  41491. name: string;
  41492. handler: Nullable<(e: FocusEvent) => any>;
  41493. }[]): void;
  41494. /**
  41495. * Function used to unregister events from window level
  41496. * @param windowElement defines the Window object to use
  41497. * @param events defines the events to unregister
  41498. */
  41499. static UnregisterTopRootEvents(windowElement: Window, events: {
  41500. name: string;
  41501. handler: Nullable<(e: FocusEvent) => any>;
  41502. }[]): void;
  41503. /**
  41504. * @ignore
  41505. */
  41506. static _ScreenshotCanvas: HTMLCanvasElement;
  41507. /**
  41508. * Dumps the current bound framebuffer
  41509. * @param width defines the rendering width
  41510. * @param height defines the rendering height
  41511. * @param engine defines the hosting engine
  41512. * @param successCallback defines the callback triggered once the data are available
  41513. * @param mimeType defines the mime type of the result
  41514. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41515. */
  41516. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41517. /**
  41518. * Converts the canvas data to blob.
  41519. * This acts as a polyfill for browsers not supporting the to blob function.
  41520. * @param canvas Defines the canvas to extract the data from
  41521. * @param successCallback Defines the callback triggered once the data are available
  41522. * @param mimeType Defines the mime type of the result
  41523. */
  41524. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41525. /**
  41526. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41527. * @param successCallback defines the callback triggered once the data are available
  41528. * @param mimeType defines the mime type of the result
  41529. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41530. */
  41531. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41532. /**
  41533. * Downloads a blob in the browser
  41534. * @param blob defines the blob to download
  41535. * @param fileName defines the name of the downloaded file
  41536. */
  41537. static Download(blob: Blob, fileName: string): void;
  41538. /**
  41539. * Captures a screenshot of the current rendering
  41540. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41541. * @param engine defines the rendering engine
  41542. * @param camera defines the source camera
  41543. * @param size This parameter can be set to a single number or to an object with the
  41544. * following (optional) properties: precision, width, height. If a single number is passed,
  41545. * it will be used for both width and height. If an object is passed, the screenshot size
  41546. * will be derived from the parameters. The precision property is a multiplier allowing
  41547. * rendering at a higher or lower resolution
  41548. * @param successCallback defines the callback receives a single parameter which contains the
  41549. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41550. * src parameter of an <img> to display it
  41551. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41552. * Check your browser for supported MIME types
  41553. */
  41554. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41555. /**
  41556. * Captures a screenshot of the current rendering
  41557. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41558. * @param engine defines the rendering engine
  41559. * @param camera defines the source camera
  41560. * @param size This parameter can be set to a single number or to an object with the
  41561. * following (optional) properties: precision, width, height. If a single number is passed,
  41562. * it will be used for both width and height. If an object is passed, the screenshot size
  41563. * will be derived from the parameters. The precision property is a multiplier allowing
  41564. * rendering at a higher or lower resolution
  41565. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41566. * Check your browser for supported MIME types
  41567. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41568. * to the src parameter of an <img> to display it
  41569. */
  41570. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  41571. /**
  41572. * Generates an image screenshot from the specified camera.
  41573. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41574. * @param engine The engine to use for rendering
  41575. * @param camera The camera to use for rendering
  41576. * @param size This parameter can be set to a single number or to an object with the
  41577. * following (optional) properties: precision, width, height. If a single number is passed,
  41578. * it will be used for both width and height. If an object is passed, the screenshot size
  41579. * will be derived from the parameters. The precision property is a multiplier allowing
  41580. * rendering at a higher or lower resolution
  41581. * @param successCallback The callback receives a single parameter which contains the
  41582. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41583. * src parameter of an <img> to display it
  41584. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41585. * Check your browser for supported MIME types
  41586. * @param samples Texture samples (default: 1)
  41587. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41588. * @param fileName A name for for the downloaded file.
  41589. */
  41590. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  41591. /**
  41592. * Generates an image screenshot from the specified camera.
  41593. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41594. * @param engine The engine to use for rendering
  41595. * @param camera The camera to use for rendering
  41596. * @param size This parameter can be set to a single number or to an object with the
  41597. * following (optional) properties: precision, width, height. If a single number is passed,
  41598. * it will be used for both width and height. If an object is passed, the screenshot size
  41599. * will be derived from the parameters. The precision property is a multiplier allowing
  41600. * rendering at a higher or lower resolution
  41601. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41602. * Check your browser for supported MIME types
  41603. * @param samples Texture samples (default: 1)
  41604. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41605. * @param fileName A name for for the downloaded file.
  41606. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41607. * to the src parameter of an <img> to display it
  41608. */
  41609. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  41610. /**
  41611. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  41612. * Be aware Math.random() could cause collisions, but:
  41613. * "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"
  41614. * @returns a pseudo random id
  41615. */
  41616. static RandomId(): string;
  41617. /**
  41618. * Test if the given uri is a base64 string
  41619. * @param uri The uri to test
  41620. * @return True if the uri is a base64 string or false otherwise
  41621. */
  41622. static IsBase64(uri: string): boolean;
  41623. /**
  41624. * Decode the given base64 uri.
  41625. * @param uri The uri to decode
  41626. * @return The decoded base64 data.
  41627. */
  41628. static DecodeBase64(uri: string): ArrayBuffer;
  41629. /**
  41630. * Gets the absolute url.
  41631. * @param url the input url
  41632. * @return the absolute url
  41633. */
  41634. static GetAbsoluteUrl(url: string): string;
  41635. /**
  41636. * No log
  41637. */
  41638. static readonly NoneLogLevel: number;
  41639. /**
  41640. * Only message logs
  41641. */
  41642. static readonly MessageLogLevel: number;
  41643. /**
  41644. * Only warning logs
  41645. */
  41646. static readonly WarningLogLevel: number;
  41647. /**
  41648. * Only error logs
  41649. */
  41650. static readonly ErrorLogLevel: number;
  41651. /**
  41652. * All logs
  41653. */
  41654. static readonly AllLogLevel: number;
  41655. /**
  41656. * Gets a value indicating the number of loading errors
  41657. * @ignorenaming
  41658. */
  41659. static get errorsCount(): number;
  41660. /**
  41661. * Callback called when a new log is added
  41662. */
  41663. static OnNewCacheEntry: (entry: string) => void;
  41664. /**
  41665. * Log a message to the console
  41666. * @param message defines the message to log
  41667. */
  41668. static Log(message: string): void;
  41669. /**
  41670. * Write a warning message to the console
  41671. * @param message defines the message to log
  41672. */
  41673. static Warn(message: string): void;
  41674. /**
  41675. * Write an error message to the console
  41676. * @param message defines the message to log
  41677. */
  41678. static Error(message: string): void;
  41679. /**
  41680. * Gets current log cache (list of logs)
  41681. */
  41682. static get LogCache(): string;
  41683. /**
  41684. * Clears the log cache
  41685. */
  41686. static ClearLogCache(): void;
  41687. /**
  41688. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  41689. */
  41690. static set LogLevels(level: number);
  41691. /**
  41692. * Checks if the window object exists
  41693. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  41694. */
  41695. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  41696. /**
  41697. * No performance log
  41698. */
  41699. static readonly PerformanceNoneLogLevel: number;
  41700. /**
  41701. * Use user marks to log performance
  41702. */
  41703. static readonly PerformanceUserMarkLogLevel: number;
  41704. /**
  41705. * Log performance to the console
  41706. */
  41707. static readonly PerformanceConsoleLogLevel: number;
  41708. private static _performance;
  41709. /**
  41710. * Sets the current performance log level
  41711. */
  41712. static set PerformanceLogLevel(level: number);
  41713. private static _StartPerformanceCounterDisabled;
  41714. private static _EndPerformanceCounterDisabled;
  41715. private static _StartUserMark;
  41716. private static _EndUserMark;
  41717. private static _StartPerformanceConsole;
  41718. private static _EndPerformanceConsole;
  41719. /**
  41720. * Starts a performance counter
  41721. */
  41722. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41723. /**
  41724. * Ends a specific performance coutner
  41725. */
  41726. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41727. /**
  41728. * Gets either window.performance.now() if supported or Date.now() else
  41729. */
  41730. static get Now(): number;
  41731. /**
  41732. * This method will return the name of the class used to create the instance of the given object.
  41733. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  41734. * @param object the object to get the class name from
  41735. * @param isType defines if the object is actually a type
  41736. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  41737. */
  41738. static GetClassName(object: any, isType?: boolean): string;
  41739. /**
  41740. * Gets the first element of an array satisfying a given predicate
  41741. * @param array defines the array to browse
  41742. * @param predicate defines the predicate to use
  41743. * @returns null if not found or the element
  41744. */
  41745. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  41746. /**
  41747. * This method will return the name of the full name of the class, including its owning module (if any).
  41748. * 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).
  41749. * @param object the object to get the class name from
  41750. * @param isType defines if the object is actually a type
  41751. * @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.
  41752. * @ignorenaming
  41753. */
  41754. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  41755. /**
  41756. * Returns a promise that resolves after the given amount of time.
  41757. * @param delay Number of milliseconds to delay
  41758. * @returns Promise that resolves after the given amount of time
  41759. */
  41760. static DelayAsync(delay: number): Promise<void>;
  41761. /**
  41762. * Utility function to detect if the current user agent is Safari
  41763. * @returns whether or not the current user agent is safari
  41764. */
  41765. static IsSafari(): boolean;
  41766. }
  41767. /**
  41768. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  41769. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  41770. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  41771. * @param name The name of the class, case should be preserved
  41772. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  41773. */
  41774. export function className(name: string, module?: string): (target: Object) => void;
  41775. /**
  41776. * An implementation of a loop for asynchronous functions.
  41777. */
  41778. export class AsyncLoop {
  41779. /**
  41780. * Defines the number of iterations for the loop
  41781. */
  41782. iterations: number;
  41783. /**
  41784. * Defines the current index of the loop.
  41785. */
  41786. index: number;
  41787. private _done;
  41788. private _fn;
  41789. private _successCallback;
  41790. /**
  41791. * Constructor.
  41792. * @param iterations the number of iterations.
  41793. * @param func the function to run each iteration
  41794. * @param successCallback the callback that will be called upon succesful execution
  41795. * @param offset starting offset.
  41796. */
  41797. constructor(
  41798. /**
  41799. * Defines the number of iterations for the loop
  41800. */
  41801. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  41802. /**
  41803. * Execute the next iteration. Must be called after the last iteration was finished.
  41804. */
  41805. executeNext(): void;
  41806. /**
  41807. * Break the loop and run the success callback.
  41808. */
  41809. breakLoop(): void;
  41810. /**
  41811. * Create and run an async loop.
  41812. * @param iterations the number of iterations.
  41813. * @param fn the function to run each iteration
  41814. * @param successCallback the callback that will be called upon succesful execution
  41815. * @param offset starting offset.
  41816. * @returns the created async loop object
  41817. */
  41818. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  41819. /**
  41820. * A for-loop that will run a given number of iterations synchronous and the rest async.
  41821. * @param iterations total number of iterations
  41822. * @param syncedIterations number of synchronous iterations in each async iteration.
  41823. * @param fn the function to call each iteration.
  41824. * @param callback a success call back that will be called when iterating stops.
  41825. * @param breakFunction a break condition (optional)
  41826. * @param timeout timeout settings for the setTimeout function. default - 0.
  41827. * @returns the created async loop object
  41828. */
  41829. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  41830. }
  41831. }
  41832. declare module BABYLON {
  41833. /**
  41834. * This class implement a typical dictionary using a string as key and the generic type T as value.
  41835. * The underlying implementation relies on an associative array to ensure the best performances.
  41836. * The value can be anything including 'null' but except 'undefined'
  41837. */
  41838. export class StringDictionary<T> {
  41839. /**
  41840. * This will clear this dictionary and copy the content from the 'source' one.
  41841. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  41842. * @param source the dictionary to take the content from and copy to this dictionary
  41843. */
  41844. copyFrom(source: StringDictionary<T>): void;
  41845. /**
  41846. * Get a value based from its key
  41847. * @param key the given key to get the matching value from
  41848. * @return the value if found, otherwise undefined is returned
  41849. */
  41850. get(key: string): T | undefined;
  41851. /**
  41852. * Get a value from its key or add it if it doesn't exist.
  41853. * This method will ensure you that a given key/data will be present in the dictionary.
  41854. * @param key the given key to get the matching value from
  41855. * @param factory the factory that will create the value if the key is not present in the dictionary.
  41856. * The factory will only be invoked if there's no data for the given key.
  41857. * @return the value corresponding to the key.
  41858. */
  41859. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  41860. /**
  41861. * Get a value from its key if present in the dictionary otherwise add it
  41862. * @param key the key to get the value from
  41863. * @param val if there's no such key/value pair in the dictionary add it with this value
  41864. * @return the value corresponding to the key
  41865. */
  41866. getOrAdd(key: string, val: T): T;
  41867. /**
  41868. * Check if there's a given key in the dictionary
  41869. * @param key the key to check for
  41870. * @return true if the key is present, false otherwise
  41871. */
  41872. contains(key: string): boolean;
  41873. /**
  41874. * Add a new key and its corresponding value
  41875. * @param key the key to add
  41876. * @param value the value corresponding to the key
  41877. * @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
  41878. */
  41879. add(key: string, value: T): boolean;
  41880. /**
  41881. * Update a specific value associated to a key
  41882. * @param key defines the key to use
  41883. * @param value defines the value to store
  41884. * @returns true if the value was updated (or false if the key was not found)
  41885. */
  41886. set(key: string, value: T): boolean;
  41887. /**
  41888. * Get the element of the given key and remove it from the dictionary
  41889. * @param key defines the key to search
  41890. * @returns the value associated with the key or null if not found
  41891. */
  41892. getAndRemove(key: string): Nullable<T>;
  41893. /**
  41894. * Remove a key/value from the dictionary.
  41895. * @param key the key to remove
  41896. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  41897. */
  41898. remove(key: string): boolean;
  41899. /**
  41900. * Clear the whole content of the dictionary
  41901. */
  41902. clear(): void;
  41903. /**
  41904. * Gets the current count
  41905. */
  41906. get count(): number;
  41907. /**
  41908. * Execute a callback on each key/val of the dictionary.
  41909. * Note that you can remove any element in this dictionary in the callback implementation
  41910. * @param callback the callback to execute on a given key/value pair
  41911. */
  41912. forEach(callback: (key: string, val: T) => void): void;
  41913. /**
  41914. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  41915. * If the callback returns null or undefined the method will iterate to the next key/value pair
  41916. * Note that you can remove any element in this dictionary in the callback implementation
  41917. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  41918. * @returns the first item
  41919. */
  41920. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  41921. private _count;
  41922. private _data;
  41923. }
  41924. }
  41925. declare module BABYLON {
  41926. /** @hidden */
  41927. export interface ICollisionCoordinator {
  41928. createCollider(): Collider;
  41929. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  41930. init(scene: Scene): void;
  41931. }
  41932. /** @hidden */
  41933. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  41934. private _scene;
  41935. private _scaledPosition;
  41936. private _scaledVelocity;
  41937. private _finalPosition;
  41938. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  41939. createCollider(): Collider;
  41940. init(scene: Scene): void;
  41941. private _collideWithWorld;
  41942. }
  41943. }
  41944. declare module BABYLON {
  41945. /**
  41946. * Class used to manage all inputs for the scene.
  41947. */
  41948. export class InputManager {
  41949. /** The distance in pixel that you have to move to prevent some events */
  41950. static DragMovementThreshold: number;
  41951. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  41952. static LongPressDelay: number;
  41953. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  41954. static DoubleClickDelay: number;
  41955. /** If you need to check double click without raising a single click at first click, enable this flag */
  41956. static ExclusiveDoubleClickMode: boolean;
  41957. /** 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. */
  41958. private _alreadyAttached;
  41959. private _wheelEventName;
  41960. private _onPointerMove;
  41961. private _onPointerDown;
  41962. private _onPointerUp;
  41963. private _initClickEvent;
  41964. private _initActionManager;
  41965. private _delayedSimpleClick;
  41966. private _delayedSimpleClickTimeout;
  41967. private _previousDelayedSimpleClickTimeout;
  41968. private _meshPickProceed;
  41969. private _previousButtonPressed;
  41970. private _currentPickResult;
  41971. private _previousPickResult;
  41972. private _totalPointersPressed;
  41973. private _doubleClickOccured;
  41974. private _pointerOverMesh;
  41975. private _pickedDownMesh;
  41976. private _pickedUpMesh;
  41977. private _pointerX;
  41978. private _pointerY;
  41979. private _unTranslatedPointerX;
  41980. private _unTranslatedPointerY;
  41981. private _startingPointerPosition;
  41982. private _previousStartingPointerPosition;
  41983. private _startingPointerTime;
  41984. private _previousStartingPointerTime;
  41985. private _pointerCaptures;
  41986. private _meshUnderPointerId;
  41987. private _onKeyDown;
  41988. private _onKeyUp;
  41989. private _onCanvasFocusObserver;
  41990. private _onCanvasBlurObserver;
  41991. private _scene;
  41992. /**
  41993. * Creates a new InputManager
  41994. * @param scene defines the hosting scene
  41995. */
  41996. constructor(scene: Scene);
  41997. /**
  41998. * Gets the mesh that is currently under the pointer
  41999. */
  42000. get meshUnderPointer(): Nullable<AbstractMesh>;
  42001. /**
  42002. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42003. * @param pointerId the pointer id to use
  42004. * @returns The mesh under this pointer id or null if not found
  42005. */
  42006. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42007. /**
  42008. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42009. */
  42010. get unTranslatedPointer(): Vector2;
  42011. /**
  42012. * Gets or sets the current on-screen X position of the pointer
  42013. */
  42014. get pointerX(): number;
  42015. set pointerX(value: number);
  42016. /**
  42017. * Gets or sets the current on-screen Y position of the pointer
  42018. */
  42019. get pointerY(): number;
  42020. set pointerY(value: number);
  42021. private _updatePointerPosition;
  42022. private _processPointerMove;
  42023. private _setRayOnPointerInfo;
  42024. private _checkPrePointerObservable;
  42025. /**
  42026. * Use this method to simulate a pointer move on a mesh
  42027. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42028. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42029. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42030. */
  42031. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42032. /**
  42033. * Use this method to simulate a pointer down on a mesh
  42034. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42035. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42036. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42037. */
  42038. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42039. private _processPointerDown;
  42040. /** @hidden */
  42041. _isPointerSwiping(): boolean;
  42042. /**
  42043. * Use this method to simulate a pointer up on a mesh
  42044. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42045. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42046. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42047. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42048. */
  42049. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42050. private _processPointerUp;
  42051. /**
  42052. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42053. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42054. * @returns true if the pointer was captured
  42055. */
  42056. isPointerCaptured(pointerId?: number): boolean;
  42057. /**
  42058. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42059. * @param attachUp defines if you want to attach events to pointerup
  42060. * @param attachDown defines if you want to attach events to pointerdown
  42061. * @param attachMove defines if you want to attach events to pointermove
  42062. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42063. */
  42064. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42065. /**
  42066. * Detaches all event handlers
  42067. */
  42068. detachControl(): void;
  42069. /**
  42070. * Force the value of meshUnderPointer
  42071. * @param mesh defines the mesh to use
  42072. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42073. */
  42074. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42075. /**
  42076. * Gets the mesh under the pointer
  42077. * @returns a Mesh or null if no mesh is under the pointer
  42078. */
  42079. getPointerOverMesh(): Nullable<AbstractMesh>;
  42080. }
  42081. }
  42082. declare module BABYLON {
  42083. /**
  42084. * This class defines the direct association between an animation and a target
  42085. */
  42086. export class TargetedAnimation {
  42087. /**
  42088. * Animation to perform
  42089. */
  42090. animation: Animation;
  42091. /**
  42092. * Target to animate
  42093. */
  42094. target: any;
  42095. /**
  42096. * Returns the string "TargetedAnimation"
  42097. * @returns "TargetedAnimation"
  42098. */
  42099. getClassName(): string;
  42100. /**
  42101. * Serialize the object
  42102. * @returns the JSON object representing the current entity
  42103. */
  42104. serialize(): any;
  42105. }
  42106. /**
  42107. * Use this class to create coordinated animations on multiple targets
  42108. */
  42109. export class AnimationGroup implements IDisposable {
  42110. /** The name of the animation group */
  42111. name: string;
  42112. private _scene;
  42113. private _targetedAnimations;
  42114. private _animatables;
  42115. private _from;
  42116. private _to;
  42117. private _isStarted;
  42118. private _isPaused;
  42119. private _speedRatio;
  42120. private _loopAnimation;
  42121. private _isAdditive;
  42122. /**
  42123. * Gets or sets the unique id of the node
  42124. */
  42125. uniqueId: number;
  42126. /**
  42127. * This observable will notify when one animation have ended
  42128. */
  42129. onAnimationEndObservable: Observable<TargetedAnimation>;
  42130. /**
  42131. * Observer raised when one animation loops
  42132. */
  42133. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42134. /**
  42135. * Observer raised when all animations have looped
  42136. */
  42137. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42138. /**
  42139. * This observable will notify when all animations have ended.
  42140. */
  42141. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42142. /**
  42143. * This observable will notify when all animations have paused.
  42144. */
  42145. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42146. /**
  42147. * This observable will notify when all animations are playing.
  42148. */
  42149. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42150. /**
  42151. * Gets the first frame
  42152. */
  42153. get from(): number;
  42154. /**
  42155. * Gets the last frame
  42156. */
  42157. get to(): number;
  42158. /**
  42159. * Define if the animations are started
  42160. */
  42161. get isStarted(): boolean;
  42162. /**
  42163. * Gets a value indicating that the current group is playing
  42164. */
  42165. get isPlaying(): boolean;
  42166. /**
  42167. * Gets or sets the speed ratio to use for all animations
  42168. */
  42169. get speedRatio(): number;
  42170. /**
  42171. * Gets or sets the speed ratio to use for all animations
  42172. */
  42173. set speedRatio(value: number);
  42174. /**
  42175. * Gets or sets if all animations should loop or not
  42176. */
  42177. get loopAnimation(): boolean;
  42178. set loopAnimation(value: boolean);
  42179. /**
  42180. * Gets or sets if all animations should be evaluated additively
  42181. */
  42182. get isAdditive(): boolean;
  42183. set isAdditive(value: boolean);
  42184. /**
  42185. * Gets the targeted animations for this animation group
  42186. */
  42187. get targetedAnimations(): Array<TargetedAnimation>;
  42188. /**
  42189. * returning the list of animatables controlled by this animation group.
  42190. */
  42191. get animatables(): Array<Animatable>;
  42192. /**
  42193. * Gets the list of target animations
  42194. */
  42195. get children(): TargetedAnimation[];
  42196. /**
  42197. * Instantiates a new Animation Group.
  42198. * This helps managing several animations at once.
  42199. * @see https://doc.babylonjs.com/how_to/group
  42200. * @param name Defines the name of the group
  42201. * @param scene Defines the scene the group belongs to
  42202. */
  42203. constructor(
  42204. /** The name of the animation group */
  42205. name: string, scene?: Nullable<Scene>);
  42206. /**
  42207. * Add an animation (with its target) in the group
  42208. * @param animation defines the animation we want to add
  42209. * @param target defines the target of the animation
  42210. * @returns the TargetedAnimation object
  42211. */
  42212. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42213. /**
  42214. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42215. * It can add constant keys at begin or end
  42216. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42217. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42218. * @returns the animation group
  42219. */
  42220. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42221. private _animationLoopCount;
  42222. private _animationLoopFlags;
  42223. private _processLoop;
  42224. /**
  42225. * Start all animations on given targets
  42226. * @param loop defines if animations must loop
  42227. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42228. * @param from defines the from key (optional)
  42229. * @param to defines the to key (optional)
  42230. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42231. * @returns the current animation group
  42232. */
  42233. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42234. /**
  42235. * Pause all animations
  42236. * @returns the animation group
  42237. */
  42238. pause(): AnimationGroup;
  42239. /**
  42240. * Play all animations to initial state
  42241. * This function will start() the animations if they were not started or will restart() them if they were paused
  42242. * @param loop defines if animations must loop
  42243. * @returns the animation group
  42244. */
  42245. play(loop?: boolean): AnimationGroup;
  42246. /**
  42247. * Reset all animations to initial state
  42248. * @returns the animation group
  42249. */
  42250. reset(): AnimationGroup;
  42251. /**
  42252. * Restart animations from key 0
  42253. * @returns the animation group
  42254. */
  42255. restart(): AnimationGroup;
  42256. /**
  42257. * Stop all animations
  42258. * @returns the animation group
  42259. */
  42260. stop(): AnimationGroup;
  42261. /**
  42262. * Set animation weight for all animatables
  42263. * @param weight defines the weight to use
  42264. * @return the animationGroup
  42265. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42266. */
  42267. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42268. /**
  42269. * Synchronize and normalize all animatables with a source animatable
  42270. * @param root defines the root animatable to synchronize with
  42271. * @return the animationGroup
  42272. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42273. */
  42274. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42275. /**
  42276. * Goes to a specific frame in this animation group
  42277. * @param frame the frame number to go to
  42278. * @return the animationGroup
  42279. */
  42280. goToFrame(frame: number): AnimationGroup;
  42281. /**
  42282. * Dispose all associated resources
  42283. */
  42284. dispose(): void;
  42285. private _checkAnimationGroupEnded;
  42286. /**
  42287. * Clone the current animation group and returns a copy
  42288. * @param newName defines the name of the new group
  42289. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42290. * @returns the new aniamtion group
  42291. */
  42292. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42293. /**
  42294. * Serializes the animationGroup to an object
  42295. * @returns Serialized object
  42296. */
  42297. serialize(): any;
  42298. /**
  42299. * Returns a new AnimationGroup object parsed from the source provided.
  42300. * @param parsedAnimationGroup defines the source
  42301. * @param scene defines the scene that will receive the animationGroup
  42302. * @returns a new AnimationGroup
  42303. */
  42304. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42305. /**
  42306. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42307. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42308. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42309. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42310. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42311. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42312. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42313. */
  42314. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42315. /**
  42316. * Returns the string "AnimationGroup"
  42317. * @returns "AnimationGroup"
  42318. */
  42319. getClassName(): string;
  42320. /**
  42321. * Creates a detailled string about the object
  42322. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42323. * @returns a string representing the object
  42324. */
  42325. toString(fullDetails?: boolean): string;
  42326. }
  42327. }
  42328. declare module BABYLON {
  42329. /**
  42330. * Define an interface for all classes that will hold resources
  42331. */
  42332. export interface IDisposable {
  42333. /**
  42334. * Releases all held resources
  42335. */
  42336. dispose(): void;
  42337. }
  42338. /** Interface defining initialization parameters for Scene class */
  42339. export interface SceneOptions {
  42340. /**
  42341. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42342. * It will improve performance when the number of geometries becomes important.
  42343. */
  42344. useGeometryUniqueIdsMap?: boolean;
  42345. /**
  42346. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42347. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42348. */
  42349. useMaterialMeshMap?: boolean;
  42350. /**
  42351. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42352. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42353. */
  42354. useClonedMeshMap?: boolean;
  42355. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42356. virtual?: boolean;
  42357. }
  42358. /**
  42359. * Represents a scene to be rendered by the engine.
  42360. * @see https://doc.babylonjs.com/features/scene
  42361. */
  42362. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42363. /** The fog is deactivated */
  42364. static readonly FOGMODE_NONE: number;
  42365. /** The fog density is following an exponential function */
  42366. static readonly FOGMODE_EXP: number;
  42367. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42368. static readonly FOGMODE_EXP2: number;
  42369. /** The fog density is following a linear function. */
  42370. static readonly FOGMODE_LINEAR: number;
  42371. /**
  42372. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42373. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42374. */
  42375. static MinDeltaTime: number;
  42376. /**
  42377. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42378. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42379. */
  42380. static MaxDeltaTime: number;
  42381. /**
  42382. * Factory used to create the default material.
  42383. * @param name The name of the material to create
  42384. * @param scene The scene to create the material for
  42385. * @returns The default material
  42386. */
  42387. static DefaultMaterialFactory(scene: Scene): Material;
  42388. /**
  42389. * Factory used to create the a collision coordinator.
  42390. * @returns The collision coordinator
  42391. */
  42392. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42393. /** @hidden */
  42394. _inputManager: InputManager;
  42395. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42396. cameraToUseForPointers: Nullable<Camera>;
  42397. /** @hidden */
  42398. readonly _isScene: boolean;
  42399. /** @hidden */
  42400. _blockEntityCollection: boolean;
  42401. /**
  42402. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42403. */
  42404. autoClear: boolean;
  42405. /**
  42406. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42407. */
  42408. autoClearDepthAndStencil: boolean;
  42409. /**
  42410. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42411. */
  42412. clearColor: Color4;
  42413. /**
  42414. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42415. */
  42416. ambientColor: Color3;
  42417. /**
  42418. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42419. * It should only be one of the following (if not the default embedded one):
  42420. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42421. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42422. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42423. * The material properties need to be setup according to the type of texture in use.
  42424. */
  42425. environmentBRDFTexture: BaseTexture;
  42426. /**
  42427. * Texture used in all pbr material as the reflection texture.
  42428. * As in the majority of the scene they are the same (exception for multi room and so on),
  42429. * this is easier to reference from here than from all the materials.
  42430. */
  42431. get environmentTexture(): Nullable<BaseTexture>;
  42432. /**
  42433. * Texture used in all pbr material as the reflection texture.
  42434. * As in the majority of the scene they are the same (exception for multi room and so on),
  42435. * this is easier to set here than in all the materials.
  42436. */
  42437. set environmentTexture(value: Nullable<BaseTexture>);
  42438. /** @hidden */
  42439. protected _environmentIntensity: number;
  42440. /**
  42441. * Intensity of the environment in all pbr material.
  42442. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42443. * As in the majority of the scene they are the same (exception for multi room and so on),
  42444. * this is easier to reference from here than from all the materials.
  42445. */
  42446. get environmentIntensity(): number;
  42447. /**
  42448. * Intensity of the environment in all pbr material.
  42449. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42450. * As in the majority of the scene they are the same (exception for multi room and so on),
  42451. * this is easier to set here than in all the materials.
  42452. */
  42453. set environmentIntensity(value: number);
  42454. /** @hidden */
  42455. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42456. /**
  42457. * Default image processing configuration used either in the rendering
  42458. * Forward main pass or through the imageProcessingPostProcess if present.
  42459. * As in the majority of the scene they are the same (exception for multi camera),
  42460. * this is easier to reference from here than from all the materials and post process.
  42461. *
  42462. * No setter as we it is a shared configuration, you can set the values instead.
  42463. */
  42464. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42465. private _forceWireframe;
  42466. /**
  42467. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42468. */
  42469. set forceWireframe(value: boolean);
  42470. get forceWireframe(): boolean;
  42471. private _skipFrustumClipping;
  42472. /**
  42473. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42474. */
  42475. set skipFrustumClipping(value: boolean);
  42476. get skipFrustumClipping(): boolean;
  42477. private _forcePointsCloud;
  42478. /**
  42479. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42480. */
  42481. set forcePointsCloud(value: boolean);
  42482. get forcePointsCloud(): boolean;
  42483. /**
  42484. * Gets or sets the active clipplane 1
  42485. */
  42486. clipPlane: Nullable<Plane>;
  42487. /**
  42488. * Gets or sets the active clipplane 2
  42489. */
  42490. clipPlane2: Nullable<Plane>;
  42491. /**
  42492. * Gets or sets the active clipplane 3
  42493. */
  42494. clipPlane3: Nullable<Plane>;
  42495. /**
  42496. * Gets or sets the active clipplane 4
  42497. */
  42498. clipPlane4: Nullable<Plane>;
  42499. /**
  42500. * Gets or sets the active clipplane 5
  42501. */
  42502. clipPlane5: Nullable<Plane>;
  42503. /**
  42504. * Gets or sets the active clipplane 6
  42505. */
  42506. clipPlane6: Nullable<Plane>;
  42507. /**
  42508. * Gets or sets a boolean indicating if animations are enabled
  42509. */
  42510. animationsEnabled: boolean;
  42511. private _animationPropertiesOverride;
  42512. /**
  42513. * Gets or sets the animation properties override
  42514. */
  42515. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42516. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42517. /**
  42518. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42519. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42520. */
  42521. useConstantAnimationDeltaTime: boolean;
  42522. /**
  42523. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42524. * Please note that it requires to run a ray cast through the scene on every frame
  42525. */
  42526. constantlyUpdateMeshUnderPointer: boolean;
  42527. /**
  42528. * Defines the HTML cursor to use when hovering over interactive elements
  42529. */
  42530. hoverCursor: string;
  42531. /**
  42532. * Defines the HTML default cursor to use (empty by default)
  42533. */
  42534. defaultCursor: string;
  42535. /**
  42536. * Defines whether cursors are handled by the scene.
  42537. */
  42538. doNotHandleCursors: boolean;
  42539. /**
  42540. * This is used to call preventDefault() on pointer down
  42541. * in order to block unwanted artifacts like system double clicks
  42542. */
  42543. preventDefaultOnPointerDown: boolean;
  42544. /**
  42545. * This is used to call preventDefault() on pointer up
  42546. * in order to block unwanted artifacts like system double clicks
  42547. */
  42548. preventDefaultOnPointerUp: boolean;
  42549. /**
  42550. * Gets or sets user defined metadata
  42551. */
  42552. metadata: any;
  42553. /**
  42554. * For internal use only. Please do not use.
  42555. */
  42556. reservedDataStore: any;
  42557. /**
  42558. * Gets the name of the plugin used to load this scene (null by default)
  42559. */
  42560. loadingPluginName: string;
  42561. /**
  42562. * Use this array to add regular expressions used to disable offline support for specific urls
  42563. */
  42564. disableOfflineSupportExceptionRules: RegExp[];
  42565. /**
  42566. * An event triggered when the scene is disposed.
  42567. */
  42568. onDisposeObservable: Observable<Scene>;
  42569. private _onDisposeObserver;
  42570. /** Sets a function to be executed when this scene is disposed. */
  42571. set onDispose(callback: () => void);
  42572. /**
  42573. * An event triggered before rendering the scene (right after animations and physics)
  42574. */
  42575. onBeforeRenderObservable: Observable<Scene>;
  42576. private _onBeforeRenderObserver;
  42577. /** Sets a function to be executed before rendering this scene */
  42578. set beforeRender(callback: Nullable<() => void>);
  42579. /**
  42580. * An event triggered after rendering the scene
  42581. */
  42582. onAfterRenderObservable: Observable<Scene>;
  42583. /**
  42584. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  42585. */
  42586. onAfterRenderCameraObservable: Observable<Camera>;
  42587. private _onAfterRenderObserver;
  42588. /** Sets a function to be executed after rendering this scene */
  42589. set afterRender(callback: Nullable<() => void>);
  42590. /**
  42591. * An event triggered before animating the scene
  42592. */
  42593. onBeforeAnimationsObservable: Observable<Scene>;
  42594. /**
  42595. * An event triggered after animations processing
  42596. */
  42597. onAfterAnimationsObservable: Observable<Scene>;
  42598. /**
  42599. * An event triggered before draw calls are ready to be sent
  42600. */
  42601. onBeforeDrawPhaseObservable: Observable<Scene>;
  42602. /**
  42603. * An event triggered after draw calls have been sent
  42604. */
  42605. onAfterDrawPhaseObservable: Observable<Scene>;
  42606. /**
  42607. * An event triggered when the scene is ready
  42608. */
  42609. onReadyObservable: Observable<Scene>;
  42610. /**
  42611. * An event triggered before rendering a camera
  42612. */
  42613. onBeforeCameraRenderObservable: Observable<Camera>;
  42614. private _onBeforeCameraRenderObserver;
  42615. /** Sets a function to be executed before rendering a camera*/
  42616. set beforeCameraRender(callback: () => void);
  42617. /**
  42618. * An event triggered after rendering a camera
  42619. */
  42620. onAfterCameraRenderObservable: Observable<Camera>;
  42621. private _onAfterCameraRenderObserver;
  42622. /** Sets a function to be executed after rendering a camera*/
  42623. set afterCameraRender(callback: () => void);
  42624. /**
  42625. * An event triggered when active meshes evaluation is about to start
  42626. */
  42627. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  42628. /**
  42629. * An event triggered when active meshes evaluation is done
  42630. */
  42631. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  42632. /**
  42633. * An event triggered when particles rendering is about to start
  42634. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42635. */
  42636. onBeforeParticlesRenderingObservable: Observable<Scene>;
  42637. /**
  42638. * An event triggered when particles rendering is done
  42639. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42640. */
  42641. onAfterParticlesRenderingObservable: Observable<Scene>;
  42642. /**
  42643. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  42644. */
  42645. onDataLoadedObservable: Observable<Scene>;
  42646. /**
  42647. * An event triggered when a camera is created
  42648. */
  42649. onNewCameraAddedObservable: Observable<Camera>;
  42650. /**
  42651. * An event triggered when a camera is removed
  42652. */
  42653. onCameraRemovedObservable: Observable<Camera>;
  42654. /**
  42655. * An event triggered when a light is created
  42656. */
  42657. onNewLightAddedObservable: Observable<Light>;
  42658. /**
  42659. * An event triggered when a light is removed
  42660. */
  42661. onLightRemovedObservable: Observable<Light>;
  42662. /**
  42663. * An event triggered when a geometry is created
  42664. */
  42665. onNewGeometryAddedObservable: Observable<Geometry>;
  42666. /**
  42667. * An event triggered when a geometry is removed
  42668. */
  42669. onGeometryRemovedObservable: Observable<Geometry>;
  42670. /**
  42671. * An event triggered when a transform node is created
  42672. */
  42673. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  42674. /**
  42675. * An event triggered when a transform node is removed
  42676. */
  42677. onTransformNodeRemovedObservable: Observable<TransformNode>;
  42678. /**
  42679. * An event triggered when a mesh is created
  42680. */
  42681. onNewMeshAddedObservable: Observable<AbstractMesh>;
  42682. /**
  42683. * An event triggered when a mesh is removed
  42684. */
  42685. onMeshRemovedObservable: Observable<AbstractMesh>;
  42686. /**
  42687. * An event triggered when a skeleton is created
  42688. */
  42689. onNewSkeletonAddedObservable: Observable<Skeleton>;
  42690. /**
  42691. * An event triggered when a skeleton is removed
  42692. */
  42693. onSkeletonRemovedObservable: Observable<Skeleton>;
  42694. /**
  42695. * An event triggered when a material is created
  42696. */
  42697. onNewMaterialAddedObservable: Observable<Material>;
  42698. /**
  42699. * An event triggered when a material is removed
  42700. */
  42701. onMaterialRemovedObservable: Observable<Material>;
  42702. /**
  42703. * An event triggered when a texture is created
  42704. */
  42705. onNewTextureAddedObservable: Observable<BaseTexture>;
  42706. /**
  42707. * An event triggered when a texture is removed
  42708. */
  42709. onTextureRemovedObservable: Observable<BaseTexture>;
  42710. /**
  42711. * An event triggered when render targets are about to be rendered
  42712. * Can happen multiple times per frame.
  42713. */
  42714. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  42715. /**
  42716. * An event triggered when render targets were rendered.
  42717. * Can happen multiple times per frame.
  42718. */
  42719. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  42720. /**
  42721. * An event triggered before calculating deterministic simulation step
  42722. */
  42723. onBeforeStepObservable: Observable<Scene>;
  42724. /**
  42725. * An event triggered after calculating deterministic simulation step
  42726. */
  42727. onAfterStepObservable: Observable<Scene>;
  42728. /**
  42729. * An event triggered when the activeCamera property is updated
  42730. */
  42731. onActiveCameraChanged: Observable<Scene>;
  42732. /**
  42733. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  42734. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42735. * 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)
  42736. */
  42737. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42738. /**
  42739. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  42740. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42741. * 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)
  42742. */
  42743. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42744. /**
  42745. * This Observable will when a mesh has been imported into the scene.
  42746. */
  42747. onMeshImportedObservable: Observable<AbstractMesh>;
  42748. /**
  42749. * This Observable will when an animation file has been imported into the scene.
  42750. */
  42751. onAnimationFileImportedObservable: Observable<Scene>;
  42752. /**
  42753. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  42754. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  42755. */
  42756. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  42757. /** @hidden */
  42758. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  42759. /**
  42760. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  42761. */
  42762. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  42763. /**
  42764. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  42765. */
  42766. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  42767. /**
  42768. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  42769. */
  42770. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  42771. /** Callback called when a pointer move is detected */
  42772. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42773. /** Callback called when a pointer down is detected */
  42774. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42775. /** Callback called when a pointer up is detected */
  42776. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  42777. /** Callback called when a pointer pick is detected */
  42778. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  42779. /**
  42780. * 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).
  42781. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  42782. */
  42783. onPrePointerObservable: Observable<PointerInfoPre>;
  42784. /**
  42785. * Observable event triggered each time an input event is received from the rendering canvas
  42786. */
  42787. onPointerObservable: Observable<PointerInfo>;
  42788. /**
  42789. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  42790. */
  42791. get unTranslatedPointer(): Vector2;
  42792. /**
  42793. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  42794. */
  42795. static get DragMovementThreshold(): number;
  42796. static set DragMovementThreshold(value: number);
  42797. /**
  42798. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  42799. */
  42800. static get LongPressDelay(): number;
  42801. static set LongPressDelay(value: number);
  42802. /**
  42803. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  42804. */
  42805. static get DoubleClickDelay(): number;
  42806. static set DoubleClickDelay(value: number);
  42807. /** If you need to check double click without raising a single click at first click, enable this flag */
  42808. static get ExclusiveDoubleClickMode(): boolean;
  42809. static set ExclusiveDoubleClickMode(value: boolean);
  42810. /** @hidden */
  42811. _mirroredCameraPosition: Nullable<Vector3>;
  42812. /**
  42813. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  42814. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  42815. */
  42816. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  42817. /**
  42818. * Observable event triggered each time an keyboard event is received from the hosting window
  42819. */
  42820. onKeyboardObservable: Observable<KeyboardInfo>;
  42821. private _useRightHandedSystem;
  42822. /**
  42823. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  42824. */
  42825. set useRightHandedSystem(value: boolean);
  42826. get useRightHandedSystem(): boolean;
  42827. private _timeAccumulator;
  42828. private _currentStepId;
  42829. private _currentInternalStep;
  42830. /**
  42831. * Sets the step Id used by deterministic lock step
  42832. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42833. * @param newStepId defines the step Id
  42834. */
  42835. setStepId(newStepId: number): void;
  42836. /**
  42837. * Gets the step Id used by deterministic lock step
  42838. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42839. * @returns the step Id
  42840. */
  42841. getStepId(): number;
  42842. /**
  42843. * Gets the internal step used by deterministic lock step
  42844. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42845. * @returns the internal step
  42846. */
  42847. getInternalStep(): number;
  42848. private _fogEnabled;
  42849. /**
  42850. * Gets or sets a boolean indicating if fog is enabled on this scene
  42851. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42852. * (Default is true)
  42853. */
  42854. set fogEnabled(value: boolean);
  42855. get fogEnabled(): boolean;
  42856. private _fogMode;
  42857. /**
  42858. * Gets or sets the fog mode to use
  42859. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42860. * | mode | value |
  42861. * | --- | --- |
  42862. * | FOGMODE_NONE | 0 |
  42863. * | FOGMODE_EXP | 1 |
  42864. * | FOGMODE_EXP2 | 2 |
  42865. * | FOGMODE_LINEAR | 3 |
  42866. */
  42867. set fogMode(value: number);
  42868. get fogMode(): number;
  42869. /**
  42870. * Gets or sets the fog color to use
  42871. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42872. * (Default is Color3(0.2, 0.2, 0.3))
  42873. */
  42874. fogColor: Color3;
  42875. /**
  42876. * Gets or sets the fog density to use
  42877. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42878. * (Default is 0.1)
  42879. */
  42880. fogDensity: number;
  42881. /**
  42882. * Gets or sets the fog start distance to use
  42883. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42884. * (Default is 0)
  42885. */
  42886. fogStart: number;
  42887. /**
  42888. * Gets or sets the fog end distance to use
  42889. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42890. * (Default is 1000)
  42891. */
  42892. fogEnd: number;
  42893. /**
  42894. * Flag indicating that the frame buffer binding is handled by another component
  42895. */
  42896. prePass: boolean;
  42897. private _shadowsEnabled;
  42898. /**
  42899. * Gets or sets a boolean indicating if shadows are enabled on this scene
  42900. */
  42901. set shadowsEnabled(value: boolean);
  42902. get shadowsEnabled(): boolean;
  42903. private _lightsEnabled;
  42904. /**
  42905. * Gets or sets a boolean indicating if lights are enabled on this scene
  42906. */
  42907. set lightsEnabled(value: boolean);
  42908. get lightsEnabled(): boolean;
  42909. /** All of the active cameras added to this scene. */
  42910. activeCameras: Camera[];
  42911. /** @hidden */
  42912. _activeCamera: Nullable<Camera>;
  42913. /** Gets or sets the current active camera */
  42914. get activeCamera(): Nullable<Camera>;
  42915. set activeCamera(value: Nullable<Camera>);
  42916. private _defaultMaterial;
  42917. /** The default material used on meshes when no material is affected */
  42918. get defaultMaterial(): Material;
  42919. /** The default material used on meshes when no material is affected */
  42920. set defaultMaterial(value: Material);
  42921. private _texturesEnabled;
  42922. /**
  42923. * Gets or sets a boolean indicating if textures are enabled on this scene
  42924. */
  42925. set texturesEnabled(value: boolean);
  42926. get texturesEnabled(): boolean;
  42927. /**
  42928. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  42929. */
  42930. physicsEnabled: boolean;
  42931. /**
  42932. * Gets or sets a boolean indicating if particles are enabled on this scene
  42933. */
  42934. particlesEnabled: boolean;
  42935. /**
  42936. * Gets or sets a boolean indicating if sprites are enabled on this scene
  42937. */
  42938. spritesEnabled: boolean;
  42939. private _skeletonsEnabled;
  42940. /**
  42941. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  42942. */
  42943. set skeletonsEnabled(value: boolean);
  42944. get skeletonsEnabled(): boolean;
  42945. /**
  42946. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  42947. */
  42948. lensFlaresEnabled: boolean;
  42949. /**
  42950. * Gets or sets a boolean indicating if collisions are enabled on this scene
  42951. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  42952. */
  42953. collisionsEnabled: boolean;
  42954. private _collisionCoordinator;
  42955. /** @hidden */
  42956. get collisionCoordinator(): ICollisionCoordinator;
  42957. /**
  42958. * Defines the gravity applied to this scene (used only for collisions)
  42959. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  42960. */
  42961. gravity: Vector3;
  42962. /**
  42963. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  42964. */
  42965. postProcessesEnabled: boolean;
  42966. /**
  42967. * Gets the current postprocess manager
  42968. */
  42969. postProcessManager: PostProcessManager;
  42970. /**
  42971. * Gets or sets a boolean indicating if render targets are enabled on this scene
  42972. */
  42973. renderTargetsEnabled: boolean;
  42974. /**
  42975. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  42976. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  42977. */
  42978. dumpNextRenderTargets: boolean;
  42979. /**
  42980. * The list of user defined render targets added to the scene
  42981. */
  42982. customRenderTargets: RenderTargetTexture[];
  42983. /**
  42984. * Defines if texture loading must be delayed
  42985. * If true, textures will only be loaded when they need to be rendered
  42986. */
  42987. useDelayedTextureLoading: boolean;
  42988. /**
  42989. * Gets the list of meshes imported to the scene through SceneLoader
  42990. */
  42991. importedMeshesFiles: String[];
  42992. /**
  42993. * Gets or sets a boolean indicating if probes are enabled on this scene
  42994. */
  42995. probesEnabled: boolean;
  42996. /**
  42997. * Gets or sets the current offline provider to use to store scene data
  42998. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  42999. */
  43000. offlineProvider: IOfflineProvider;
  43001. /**
  43002. * Gets or sets the action manager associated with the scene
  43003. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43004. */
  43005. actionManager: AbstractActionManager;
  43006. private _meshesForIntersections;
  43007. /**
  43008. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43009. */
  43010. proceduralTexturesEnabled: boolean;
  43011. private _engine;
  43012. private _totalVertices;
  43013. /** @hidden */
  43014. _activeIndices: PerfCounter;
  43015. /** @hidden */
  43016. _activeParticles: PerfCounter;
  43017. /** @hidden */
  43018. _activeBones: PerfCounter;
  43019. private _animationRatio;
  43020. /** @hidden */
  43021. _animationTimeLast: number;
  43022. /** @hidden */
  43023. _animationTime: number;
  43024. /**
  43025. * Gets or sets a general scale for animation speed
  43026. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43027. */
  43028. animationTimeScale: number;
  43029. /** @hidden */
  43030. _cachedMaterial: Nullable<Material>;
  43031. /** @hidden */
  43032. _cachedEffect: Nullable<Effect>;
  43033. /** @hidden */
  43034. _cachedVisibility: Nullable<number>;
  43035. private _renderId;
  43036. private _frameId;
  43037. private _executeWhenReadyTimeoutId;
  43038. private _intermediateRendering;
  43039. private _viewUpdateFlag;
  43040. private _projectionUpdateFlag;
  43041. /** @hidden */
  43042. _toBeDisposed: Nullable<IDisposable>[];
  43043. private _activeRequests;
  43044. /** @hidden */
  43045. _pendingData: any[];
  43046. private _isDisposed;
  43047. /**
  43048. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43049. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43050. */
  43051. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43052. private _activeMeshes;
  43053. private _processedMaterials;
  43054. private _renderTargets;
  43055. /** @hidden */
  43056. _activeParticleSystems: SmartArray<IParticleSystem>;
  43057. private _activeSkeletons;
  43058. private _softwareSkinnedMeshes;
  43059. private _renderingManager;
  43060. /** @hidden */
  43061. _activeAnimatables: Animatable[];
  43062. private _transformMatrix;
  43063. private _sceneUbo;
  43064. /** @hidden */
  43065. _viewMatrix: Matrix;
  43066. private _projectionMatrix;
  43067. /** @hidden */
  43068. _forcedViewPosition: Nullable<Vector3>;
  43069. /** @hidden */
  43070. _frustumPlanes: Plane[];
  43071. /**
  43072. * Gets the list of frustum planes (built from the active camera)
  43073. */
  43074. get frustumPlanes(): Plane[];
  43075. /**
  43076. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43077. * This is useful if there are more lights that the maximum simulteanous authorized
  43078. */
  43079. requireLightSorting: boolean;
  43080. /** @hidden */
  43081. readonly useMaterialMeshMap: boolean;
  43082. /** @hidden */
  43083. readonly useClonedMeshMap: boolean;
  43084. private _externalData;
  43085. private _uid;
  43086. /**
  43087. * @hidden
  43088. * Backing store of defined scene components.
  43089. */
  43090. _components: ISceneComponent[];
  43091. /**
  43092. * @hidden
  43093. * Backing store of defined scene components.
  43094. */
  43095. _serializableComponents: ISceneSerializableComponent[];
  43096. /**
  43097. * List of components to register on the next registration step.
  43098. */
  43099. private _transientComponents;
  43100. /**
  43101. * Registers the transient components if needed.
  43102. */
  43103. private _registerTransientComponents;
  43104. /**
  43105. * @hidden
  43106. * Add a component to the scene.
  43107. * Note that the ccomponent could be registered on th next frame if this is called after
  43108. * the register component stage.
  43109. * @param component Defines the component to add to the scene
  43110. */
  43111. _addComponent(component: ISceneComponent): void;
  43112. /**
  43113. * @hidden
  43114. * Gets a component from the scene.
  43115. * @param name defines the name of the component to retrieve
  43116. * @returns the component or null if not present
  43117. */
  43118. _getComponent(name: string): Nullable<ISceneComponent>;
  43119. /**
  43120. * @hidden
  43121. * Defines the actions happening before camera updates.
  43122. */
  43123. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43124. /**
  43125. * @hidden
  43126. * Defines the actions happening before clear the canvas.
  43127. */
  43128. _beforeClearStage: Stage<SimpleStageAction>;
  43129. /**
  43130. * @hidden
  43131. * Defines the actions when collecting render targets for the frame.
  43132. */
  43133. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43134. /**
  43135. * @hidden
  43136. * Defines the actions happening for one camera in the frame.
  43137. */
  43138. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43139. /**
  43140. * @hidden
  43141. * Defines the actions happening during the per mesh ready checks.
  43142. */
  43143. _isReadyForMeshStage: Stage<MeshStageAction>;
  43144. /**
  43145. * @hidden
  43146. * Defines the actions happening before evaluate active mesh checks.
  43147. */
  43148. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43149. /**
  43150. * @hidden
  43151. * Defines the actions happening during the evaluate sub mesh checks.
  43152. */
  43153. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43154. /**
  43155. * @hidden
  43156. * Defines the actions happening during the active mesh stage.
  43157. */
  43158. _activeMeshStage: Stage<ActiveMeshStageAction>;
  43159. /**
  43160. * @hidden
  43161. * Defines the actions happening during the per camera render target step.
  43162. */
  43163. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43164. /**
  43165. * @hidden
  43166. * Defines the actions happening just before the active camera is drawing.
  43167. */
  43168. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43169. /**
  43170. * @hidden
  43171. * Defines the actions happening just before a render target is drawing.
  43172. */
  43173. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43174. /**
  43175. * @hidden
  43176. * Defines the actions happening just before a rendering group is drawing.
  43177. */
  43178. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43179. /**
  43180. * @hidden
  43181. * Defines the actions happening just before a mesh is drawing.
  43182. */
  43183. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43184. /**
  43185. * @hidden
  43186. * Defines the actions happening just after a mesh has been drawn.
  43187. */
  43188. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43189. /**
  43190. * @hidden
  43191. * Defines the actions happening just after a rendering group has been drawn.
  43192. */
  43193. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43194. /**
  43195. * @hidden
  43196. * Defines the actions happening just after the active camera has been drawn.
  43197. */
  43198. _afterCameraDrawStage: Stage<CameraStageAction>;
  43199. /**
  43200. * @hidden
  43201. * Defines the actions happening just after a render target has been drawn.
  43202. */
  43203. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43204. /**
  43205. * @hidden
  43206. * Defines the actions happening just after rendering all cameras and computing intersections.
  43207. */
  43208. _afterRenderStage: Stage<SimpleStageAction>;
  43209. /**
  43210. * @hidden
  43211. * Defines the actions happening when a pointer move event happens.
  43212. */
  43213. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43214. /**
  43215. * @hidden
  43216. * Defines the actions happening when a pointer down event happens.
  43217. */
  43218. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43219. /**
  43220. * @hidden
  43221. * Defines the actions happening when a pointer up event happens.
  43222. */
  43223. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43224. /**
  43225. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43226. */
  43227. private geometriesByUniqueId;
  43228. /**
  43229. * Creates a new Scene
  43230. * @param engine defines the engine to use to render this scene
  43231. * @param options defines the scene options
  43232. */
  43233. constructor(engine: Engine, options?: SceneOptions);
  43234. /**
  43235. * Gets a string identifying the name of the class
  43236. * @returns "Scene" string
  43237. */
  43238. getClassName(): string;
  43239. private _defaultMeshCandidates;
  43240. /**
  43241. * @hidden
  43242. */
  43243. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43244. private _defaultSubMeshCandidates;
  43245. /**
  43246. * @hidden
  43247. */
  43248. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43249. /**
  43250. * Sets the default candidate providers for the scene.
  43251. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43252. * and getCollidingSubMeshCandidates to their default function
  43253. */
  43254. setDefaultCandidateProviders(): void;
  43255. /**
  43256. * Gets the mesh that is currently under the pointer
  43257. */
  43258. get meshUnderPointer(): Nullable<AbstractMesh>;
  43259. /**
  43260. * Gets or sets the current on-screen X position of the pointer
  43261. */
  43262. get pointerX(): number;
  43263. set pointerX(value: number);
  43264. /**
  43265. * Gets or sets the current on-screen Y position of the pointer
  43266. */
  43267. get pointerY(): number;
  43268. set pointerY(value: number);
  43269. /**
  43270. * Gets the cached material (ie. the latest rendered one)
  43271. * @returns the cached material
  43272. */
  43273. getCachedMaterial(): Nullable<Material>;
  43274. /**
  43275. * Gets the cached effect (ie. the latest rendered one)
  43276. * @returns the cached effect
  43277. */
  43278. getCachedEffect(): Nullable<Effect>;
  43279. /**
  43280. * Gets the cached visibility state (ie. the latest rendered one)
  43281. * @returns the cached visibility state
  43282. */
  43283. getCachedVisibility(): Nullable<number>;
  43284. /**
  43285. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43286. * @param material defines the current material
  43287. * @param effect defines the current effect
  43288. * @param visibility defines the current visibility state
  43289. * @returns true if one parameter is not cached
  43290. */
  43291. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43292. /**
  43293. * Gets the engine associated with the scene
  43294. * @returns an Engine
  43295. */
  43296. getEngine(): Engine;
  43297. /**
  43298. * Gets the total number of vertices rendered per frame
  43299. * @returns the total number of vertices rendered per frame
  43300. */
  43301. getTotalVertices(): number;
  43302. /**
  43303. * Gets the performance counter for total vertices
  43304. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43305. */
  43306. get totalVerticesPerfCounter(): PerfCounter;
  43307. /**
  43308. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43309. * @returns the total number of active indices rendered per frame
  43310. */
  43311. getActiveIndices(): number;
  43312. /**
  43313. * Gets the performance counter for active indices
  43314. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43315. */
  43316. get totalActiveIndicesPerfCounter(): PerfCounter;
  43317. /**
  43318. * Gets the total number of active particles rendered per frame
  43319. * @returns the total number of active particles rendered per frame
  43320. */
  43321. getActiveParticles(): number;
  43322. /**
  43323. * Gets the performance counter for active particles
  43324. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43325. */
  43326. get activeParticlesPerfCounter(): PerfCounter;
  43327. /**
  43328. * Gets the total number of active bones rendered per frame
  43329. * @returns the total number of active bones rendered per frame
  43330. */
  43331. getActiveBones(): number;
  43332. /**
  43333. * Gets the performance counter for active bones
  43334. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43335. */
  43336. get activeBonesPerfCounter(): PerfCounter;
  43337. /**
  43338. * Gets the array of active meshes
  43339. * @returns an array of AbstractMesh
  43340. */
  43341. getActiveMeshes(): SmartArray<AbstractMesh>;
  43342. /**
  43343. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43344. * @returns a number
  43345. */
  43346. getAnimationRatio(): number;
  43347. /**
  43348. * Gets an unique Id for the current render phase
  43349. * @returns a number
  43350. */
  43351. getRenderId(): number;
  43352. /**
  43353. * Gets an unique Id for the current frame
  43354. * @returns a number
  43355. */
  43356. getFrameId(): number;
  43357. /** Call this function if you want to manually increment the render Id*/
  43358. incrementRenderId(): void;
  43359. private _createUbo;
  43360. /**
  43361. * Use this method to simulate a pointer move on a mesh
  43362. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43363. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43364. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43365. * @returns the current scene
  43366. */
  43367. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43368. /**
  43369. * Use this method to simulate a pointer down on a mesh
  43370. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43371. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43372. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43373. * @returns the current scene
  43374. */
  43375. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43376. /**
  43377. * Use this method to simulate a pointer up on a mesh
  43378. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43379. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43380. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43381. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43382. * @returns the current scene
  43383. */
  43384. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43385. /**
  43386. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43387. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43388. * @returns true if the pointer was captured
  43389. */
  43390. isPointerCaptured(pointerId?: number): boolean;
  43391. /**
  43392. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43393. * @param attachUp defines if you want to attach events to pointerup
  43394. * @param attachDown defines if you want to attach events to pointerdown
  43395. * @param attachMove defines if you want to attach events to pointermove
  43396. */
  43397. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43398. /** Detaches all event handlers*/
  43399. detachControl(): void;
  43400. /**
  43401. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43402. * Delay loaded resources are not taking in account
  43403. * @return true if all required resources are ready
  43404. */
  43405. isReady(): boolean;
  43406. /** Resets all cached information relative to material (including effect and visibility) */
  43407. resetCachedMaterial(): void;
  43408. /**
  43409. * Registers a function to be called before every frame render
  43410. * @param func defines the function to register
  43411. */
  43412. registerBeforeRender(func: () => void): void;
  43413. /**
  43414. * Unregisters a function called before every frame render
  43415. * @param func defines the function to unregister
  43416. */
  43417. unregisterBeforeRender(func: () => void): void;
  43418. /**
  43419. * Registers a function to be called after every frame render
  43420. * @param func defines the function to register
  43421. */
  43422. registerAfterRender(func: () => void): void;
  43423. /**
  43424. * Unregisters a function called after every frame render
  43425. * @param func defines the function to unregister
  43426. */
  43427. unregisterAfterRender(func: () => void): void;
  43428. private _executeOnceBeforeRender;
  43429. /**
  43430. * The provided function will run before render once and will be disposed afterwards.
  43431. * A timeout delay can be provided so that the function will be executed in N ms.
  43432. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43433. * @param func The function to be executed.
  43434. * @param timeout optional delay in ms
  43435. */
  43436. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43437. /** @hidden */
  43438. _addPendingData(data: any): void;
  43439. /** @hidden */
  43440. _removePendingData(data: any): void;
  43441. /**
  43442. * Returns the number of items waiting to be loaded
  43443. * @returns the number of items waiting to be loaded
  43444. */
  43445. getWaitingItemsCount(): number;
  43446. /**
  43447. * Returns a boolean indicating if the scene is still loading data
  43448. */
  43449. get isLoading(): boolean;
  43450. /**
  43451. * Registers a function to be executed when the scene is ready
  43452. * @param {Function} func - the function to be executed
  43453. */
  43454. executeWhenReady(func: () => void): void;
  43455. /**
  43456. * Returns a promise that resolves when the scene is ready
  43457. * @returns A promise that resolves when the scene is ready
  43458. */
  43459. whenReadyAsync(): Promise<void>;
  43460. /** @hidden */
  43461. _checkIsReady(): void;
  43462. /**
  43463. * Gets all animatable attached to the scene
  43464. */
  43465. get animatables(): Animatable[];
  43466. /**
  43467. * Resets the last animation time frame.
  43468. * Useful to override when animations start running when loading a scene for the first time.
  43469. */
  43470. resetLastAnimationTimeFrame(): void;
  43471. /**
  43472. * Gets the current view matrix
  43473. * @returns a Matrix
  43474. */
  43475. getViewMatrix(): Matrix;
  43476. /**
  43477. * Gets the current projection matrix
  43478. * @returns a Matrix
  43479. */
  43480. getProjectionMatrix(): Matrix;
  43481. /**
  43482. * Gets the current transform matrix
  43483. * @returns a Matrix made of View * Projection
  43484. */
  43485. getTransformMatrix(): Matrix;
  43486. /**
  43487. * Sets the current transform matrix
  43488. * @param viewL defines the View matrix to use
  43489. * @param projectionL defines the Projection matrix to use
  43490. * @param viewR defines the right View matrix to use (if provided)
  43491. * @param projectionR defines the right Projection matrix to use (if provided)
  43492. */
  43493. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43494. /**
  43495. * Gets the uniform buffer used to store scene data
  43496. * @returns a UniformBuffer
  43497. */
  43498. getSceneUniformBuffer(): UniformBuffer;
  43499. /**
  43500. * Gets an unique (relatively to the current scene) Id
  43501. * @returns an unique number for the scene
  43502. */
  43503. getUniqueId(): number;
  43504. /**
  43505. * Add a mesh to the list of scene's meshes
  43506. * @param newMesh defines the mesh to add
  43507. * @param recursive if all child meshes should also be added to the scene
  43508. */
  43509. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43510. /**
  43511. * Remove a mesh for the list of scene's meshes
  43512. * @param toRemove defines the mesh to remove
  43513. * @param recursive if all child meshes should also be removed from the scene
  43514. * @returns the index where the mesh was in the mesh list
  43515. */
  43516. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43517. /**
  43518. * Add a transform node to the list of scene's transform nodes
  43519. * @param newTransformNode defines the transform node to add
  43520. */
  43521. addTransformNode(newTransformNode: TransformNode): void;
  43522. /**
  43523. * Remove a transform node for the list of scene's transform nodes
  43524. * @param toRemove defines the transform node to remove
  43525. * @returns the index where the transform node was in the transform node list
  43526. */
  43527. removeTransformNode(toRemove: TransformNode): number;
  43528. /**
  43529. * Remove a skeleton for the list of scene's skeletons
  43530. * @param toRemove defines the skeleton to remove
  43531. * @returns the index where the skeleton was in the skeleton list
  43532. */
  43533. removeSkeleton(toRemove: Skeleton): number;
  43534. /**
  43535. * Remove a morph target for the list of scene's morph targets
  43536. * @param toRemove defines the morph target to remove
  43537. * @returns the index where the morph target was in the morph target list
  43538. */
  43539. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43540. /**
  43541. * Remove a light for the list of scene's lights
  43542. * @param toRemove defines the light to remove
  43543. * @returns the index where the light was in the light list
  43544. */
  43545. removeLight(toRemove: Light): number;
  43546. /**
  43547. * Remove a camera for the list of scene's cameras
  43548. * @param toRemove defines the camera to remove
  43549. * @returns the index where the camera was in the camera list
  43550. */
  43551. removeCamera(toRemove: Camera): number;
  43552. /**
  43553. * Remove a particle system for the list of scene's particle systems
  43554. * @param toRemove defines the particle system to remove
  43555. * @returns the index where the particle system was in the particle system list
  43556. */
  43557. removeParticleSystem(toRemove: IParticleSystem): number;
  43558. /**
  43559. * Remove a animation for the list of scene's animations
  43560. * @param toRemove defines the animation to remove
  43561. * @returns the index where the animation was in the animation list
  43562. */
  43563. removeAnimation(toRemove: Animation): number;
  43564. /**
  43565. * Will stop the animation of the given target
  43566. * @param target - the target
  43567. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  43568. * @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)
  43569. */
  43570. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  43571. /**
  43572. * Removes the given animation group from this scene.
  43573. * @param toRemove The animation group to remove
  43574. * @returns The index of the removed animation group
  43575. */
  43576. removeAnimationGroup(toRemove: AnimationGroup): number;
  43577. /**
  43578. * Removes the given multi-material from this scene.
  43579. * @param toRemove The multi-material to remove
  43580. * @returns The index of the removed multi-material
  43581. */
  43582. removeMultiMaterial(toRemove: MultiMaterial): number;
  43583. /**
  43584. * Removes the given material from this scene.
  43585. * @param toRemove The material to remove
  43586. * @returns The index of the removed material
  43587. */
  43588. removeMaterial(toRemove: Material): number;
  43589. /**
  43590. * Removes the given action manager from this scene.
  43591. * @param toRemove The action manager to remove
  43592. * @returns The index of the removed action manager
  43593. */
  43594. removeActionManager(toRemove: AbstractActionManager): number;
  43595. /**
  43596. * Removes the given texture from this scene.
  43597. * @param toRemove The texture to remove
  43598. * @returns The index of the removed texture
  43599. */
  43600. removeTexture(toRemove: BaseTexture): number;
  43601. /**
  43602. * Adds the given light to this scene
  43603. * @param newLight The light to add
  43604. */
  43605. addLight(newLight: Light): void;
  43606. /**
  43607. * Sorts the list list based on light priorities
  43608. */
  43609. sortLightsByPriority(): void;
  43610. /**
  43611. * Adds the given camera to this scene
  43612. * @param newCamera The camera to add
  43613. */
  43614. addCamera(newCamera: Camera): void;
  43615. /**
  43616. * Adds the given skeleton to this scene
  43617. * @param newSkeleton The skeleton to add
  43618. */
  43619. addSkeleton(newSkeleton: Skeleton): void;
  43620. /**
  43621. * Adds the given particle system to this scene
  43622. * @param newParticleSystem The particle system to add
  43623. */
  43624. addParticleSystem(newParticleSystem: IParticleSystem): void;
  43625. /**
  43626. * Adds the given animation to this scene
  43627. * @param newAnimation The animation to add
  43628. */
  43629. addAnimation(newAnimation: Animation): void;
  43630. /**
  43631. * Adds the given animation group to this scene.
  43632. * @param newAnimationGroup The animation group to add
  43633. */
  43634. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  43635. /**
  43636. * Adds the given multi-material to this scene
  43637. * @param newMultiMaterial The multi-material to add
  43638. */
  43639. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  43640. /**
  43641. * Adds the given material to this scene
  43642. * @param newMaterial The material to add
  43643. */
  43644. addMaterial(newMaterial: Material): void;
  43645. /**
  43646. * Adds the given morph target to this scene
  43647. * @param newMorphTargetManager The morph target to add
  43648. */
  43649. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  43650. /**
  43651. * Adds the given geometry to this scene
  43652. * @param newGeometry The geometry to add
  43653. */
  43654. addGeometry(newGeometry: Geometry): void;
  43655. /**
  43656. * Adds the given action manager to this scene
  43657. * @param newActionManager The action manager to add
  43658. */
  43659. addActionManager(newActionManager: AbstractActionManager): void;
  43660. /**
  43661. * Adds the given texture to this scene.
  43662. * @param newTexture The texture to add
  43663. */
  43664. addTexture(newTexture: BaseTexture): void;
  43665. /**
  43666. * Switch active camera
  43667. * @param newCamera defines the new active camera
  43668. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  43669. */
  43670. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  43671. /**
  43672. * sets the active camera of the scene using its ID
  43673. * @param id defines the camera's ID
  43674. * @return the new active camera or null if none found.
  43675. */
  43676. setActiveCameraByID(id: string): Nullable<Camera>;
  43677. /**
  43678. * sets the active camera of the scene using its name
  43679. * @param name defines the camera's name
  43680. * @returns the new active camera or null if none found.
  43681. */
  43682. setActiveCameraByName(name: string): Nullable<Camera>;
  43683. /**
  43684. * get an animation group using its name
  43685. * @param name defines the material's name
  43686. * @return the animation group or null if none found.
  43687. */
  43688. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  43689. /**
  43690. * Get a material using its unique id
  43691. * @param uniqueId defines the material's unique id
  43692. * @return the material or null if none found.
  43693. */
  43694. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  43695. /**
  43696. * get a material using its id
  43697. * @param id defines the material's ID
  43698. * @return the material or null if none found.
  43699. */
  43700. getMaterialByID(id: string): Nullable<Material>;
  43701. /**
  43702. * Gets a the last added material using a given id
  43703. * @param id defines the material's ID
  43704. * @return the last material with the given id or null if none found.
  43705. */
  43706. getLastMaterialByID(id: string): Nullable<Material>;
  43707. /**
  43708. * Gets a material using its name
  43709. * @param name defines the material's name
  43710. * @return the material or null if none found.
  43711. */
  43712. getMaterialByName(name: string): Nullable<Material>;
  43713. /**
  43714. * Get a texture using its unique id
  43715. * @param uniqueId defines the texture's unique id
  43716. * @return the texture or null if none found.
  43717. */
  43718. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  43719. /**
  43720. * Gets a camera using its id
  43721. * @param id defines the id to look for
  43722. * @returns the camera or null if not found
  43723. */
  43724. getCameraByID(id: string): Nullable<Camera>;
  43725. /**
  43726. * Gets a camera using its unique id
  43727. * @param uniqueId defines the unique id to look for
  43728. * @returns the camera or null if not found
  43729. */
  43730. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  43731. /**
  43732. * Gets a camera using its name
  43733. * @param name defines the camera's name
  43734. * @return the camera or null if none found.
  43735. */
  43736. getCameraByName(name: string): Nullable<Camera>;
  43737. /**
  43738. * Gets a bone using its id
  43739. * @param id defines the bone's id
  43740. * @return the bone or null if not found
  43741. */
  43742. getBoneByID(id: string): Nullable<Bone>;
  43743. /**
  43744. * Gets a bone using its id
  43745. * @param name defines the bone's name
  43746. * @return the bone or null if not found
  43747. */
  43748. getBoneByName(name: string): Nullable<Bone>;
  43749. /**
  43750. * Gets a light node using its name
  43751. * @param name defines the the light's name
  43752. * @return the light or null if none found.
  43753. */
  43754. getLightByName(name: string): Nullable<Light>;
  43755. /**
  43756. * Gets a light node using its id
  43757. * @param id defines the light's id
  43758. * @return the light or null if none found.
  43759. */
  43760. getLightByID(id: string): Nullable<Light>;
  43761. /**
  43762. * Gets a light node using its scene-generated unique ID
  43763. * @param uniqueId defines the light's unique id
  43764. * @return the light or null if none found.
  43765. */
  43766. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  43767. /**
  43768. * Gets a particle system by id
  43769. * @param id defines the particle system id
  43770. * @return the corresponding system or null if none found
  43771. */
  43772. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  43773. /**
  43774. * Gets a geometry using its ID
  43775. * @param id defines the geometry's id
  43776. * @return the geometry or null if none found.
  43777. */
  43778. getGeometryByID(id: string): Nullable<Geometry>;
  43779. private _getGeometryByUniqueID;
  43780. /**
  43781. * Add a new geometry to this scene
  43782. * @param geometry defines the geometry to be added to the scene.
  43783. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  43784. * @return a boolean defining if the geometry was added or not
  43785. */
  43786. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  43787. /**
  43788. * Removes an existing geometry
  43789. * @param geometry defines the geometry to be removed from the scene
  43790. * @return a boolean defining if the geometry was removed or not
  43791. */
  43792. removeGeometry(geometry: Geometry): boolean;
  43793. /**
  43794. * Gets the list of geometries attached to the scene
  43795. * @returns an array of Geometry
  43796. */
  43797. getGeometries(): Geometry[];
  43798. /**
  43799. * Gets the first added mesh found of a given ID
  43800. * @param id defines the id to search for
  43801. * @return the mesh found or null if not found at all
  43802. */
  43803. getMeshByID(id: string): Nullable<AbstractMesh>;
  43804. /**
  43805. * Gets a list of meshes using their id
  43806. * @param id defines the id to search for
  43807. * @returns a list of meshes
  43808. */
  43809. getMeshesByID(id: string): Array<AbstractMesh>;
  43810. /**
  43811. * Gets the first added transform node found of a given ID
  43812. * @param id defines the id to search for
  43813. * @return the found transform node or null if not found at all.
  43814. */
  43815. getTransformNodeByID(id: string): Nullable<TransformNode>;
  43816. /**
  43817. * Gets a transform node with its auto-generated unique id
  43818. * @param uniqueId efines the unique id to search for
  43819. * @return the found transform node or null if not found at all.
  43820. */
  43821. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  43822. /**
  43823. * Gets a list of transform nodes using their id
  43824. * @param id defines the id to search for
  43825. * @returns a list of transform nodes
  43826. */
  43827. getTransformNodesByID(id: string): Array<TransformNode>;
  43828. /**
  43829. * Gets a mesh with its auto-generated unique id
  43830. * @param uniqueId defines the unique id to search for
  43831. * @return the found mesh or null if not found at all.
  43832. */
  43833. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  43834. /**
  43835. * Gets a the last added mesh using a given id
  43836. * @param id defines the id to search for
  43837. * @return the found mesh or null if not found at all.
  43838. */
  43839. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  43840. /**
  43841. * Gets a the last added node (Mesh, Camera, Light) using a given id
  43842. * @param id defines the id to search for
  43843. * @return the found node or null if not found at all
  43844. */
  43845. getLastEntryByID(id: string): Nullable<Node>;
  43846. /**
  43847. * Gets a node (Mesh, Camera, Light) using a given id
  43848. * @param id defines the id to search for
  43849. * @return the found node or null if not found at all
  43850. */
  43851. getNodeByID(id: string): Nullable<Node>;
  43852. /**
  43853. * Gets a node (Mesh, Camera, Light) using a given name
  43854. * @param name defines the name to search for
  43855. * @return the found node or null if not found at all.
  43856. */
  43857. getNodeByName(name: string): Nullable<Node>;
  43858. /**
  43859. * Gets a mesh using a given name
  43860. * @param name defines the name to search for
  43861. * @return the found mesh or null if not found at all.
  43862. */
  43863. getMeshByName(name: string): Nullable<AbstractMesh>;
  43864. /**
  43865. * Gets a transform node using a given name
  43866. * @param name defines the name to search for
  43867. * @return the found transform node or null if not found at all.
  43868. */
  43869. getTransformNodeByName(name: string): Nullable<TransformNode>;
  43870. /**
  43871. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  43872. * @param id defines the id to search for
  43873. * @return the found skeleton or null if not found at all.
  43874. */
  43875. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  43876. /**
  43877. * Gets a skeleton using a given auto generated unique id
  43878. * @param uniqueId defines the unique id to search for
  43879. * @return the found skeleton or null if not found at all.
  43880. */
  43881. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  43882. /**
  43883. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  43884. * @param id defines the id to search for
  43885. * @return the found skeleton or null if not found at all.
  43886. */
  43887. getSkeletonById(id: string): Nullable<Skeleton>;
  43888. /**
  43889. * Gets a skeleton using a given name
  43890. * @param name defines the name to search for
  43891. * @return the found skeleton or null if not found at all.
  43892. */
  43893. getSkeletonByName(name: string): Nullable<Skeleton>;
  43894. /**
  43895. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  43896. * @param id defines the id to search for
  43897. * @return the found morph target manager or null if not found at all.
  43898. */
  43899. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  43900. /**
  43901. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  43902. * @param id defines the id to search for
  43903. * @return the found morph target or null if not found at all.
  43904. */
  43905. getMorphTargetById(id: string): Nullable<MorphTarget>;
  43906. /**
  43907. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  43908. * @param name defines the name to search for
  43909. * @return the found morph target or null if not found at all.
  43910. */
  43911. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  43912. /**
  43913. * Gets a post process using a given name (if many are found, this function will pick the first one)
  43914. * @param name defines the name to search for
  43915. * @return the found post process or null if not found at all.
  43916. */
  43917. getPostProcessByName(name: string): Nullable<PostProcess>;
  43918. /**
  43919. * Gets a boolean indicating if the given mesh is active
  43920. * @param mesh defines the mesh to look for
  43921. * @returns true if the mesh is in the active list
  43922. */
  43923. isActiveMesh(mesh: AbstractMesh): boolean;
  43924. /**
  43925. * Return a unique id as a string which can serve as an identifier for the scene
  43926. */
  43927. get uid(): string;
  43928. /**
  43929. * Add an externaly attached data from its key.
  43930. * This method call will fail and return false, if such key already exists.
  43931. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  43932. * @param key the unique key that identifies the data
  43933. * @param data the data object to associate to the key for this Engine instance
  43934. * @return true if no such key were already present and the data was added successfully, false otherwise
  43935. */
  43936. addExternalData<T>(key: string, data: T): boolean;
  43937. /**
  43938. * Get an externaly attached data from its key
  43939. * @param key the unique key that identifies the data
  43940. * @return the associated data, if present (can be null), or undefined if not present
  43941. */
  43942. getExternalData<T>(key: string): Nullable<T>;
  43943. /**
  43944. * Get an externaly attached data from its key, create it using a factory if it's not already present
  43945. * @param key the unique key that identifies the data
  43946. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  43947. * @return the associated data, can be null if the factory returned null.
  43948. */
  43949. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  43950. /**
  43951. * Remove an externaly attached data from the Engine instance
  43952. * @param key the unique key that identifies the data
  43953. * @return true if the data was successfully removed, false if it doesn't exist
  43954. */
  43955. removeExternalData(key: string): boolean;
  43956. private _evaluateSubMesh;
  43957. /**
  43958. * Clear the processed materials smart array preventing retention point in material dispose.
  43959. */
  43960. freeProcessedMaterials(): void;
  43961. private _preventFreeActiveMeshesAndRenderingGroups;
  43962. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  43963. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  43964. * when disposing several meshes in a row or a hierarchy of meshes.
  43965. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  43966. */
  43967. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  43968. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  43969. /**
  43970. * Clear the active meshes smart array preventing retention point in mesh dispose.
  43971. */
  43972. freeActiveMeshes(): void;
  43973. /**
  43974. * Clear the info related to rendering groups preventing retention points during dispose.
  43975. */
  43976. freeRenderingGroups(): void;
  43977. /** @hidden */
  43978. _isInIntermediateRendering(): boolean;
  43979. /**
  43980. * Lambda returning the list of potentially active meshes.
  43981. */
  43982. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  43983. /**
  43984. * Lambda returning the list of potentially active sub meshes.
  43985. */
  43986. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  43987. /**
  43988. * Lambda returning the list of potentially intersecting sub meshes.
  43989. */
  43990. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  43991. /**
  43992. * Lambda returning the list of potentially colliding sub meshes.
  43993. */
  43994. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  43995. private _activeMeshesFrozen;
  43996. private _skipEvaluateActiveMeshesCompletely;
  43997. /**
  43998. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  43999. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44000. * @param onSuccess optional success callback
  44001. * @param onError optional error callback
  44002. * @returns the current scene
  44003. */
  44004. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44005. /**
  44006. * Use this function to restart evaluating active meshes on every frame
  44007. * @returns the current scene
  44008. */
  44009. unfreezeActiveMeshes(): Scene;
  44010. private _evaluateActiveMeshes;
  44011. private _activeMesh;
  44012. /**
  44013. * Update the transform matrix to update from the current active camera
  44014. * @param force defines a boolean used to force the update even if cache is up to date
  44015. */
  44016. updateTransformMatrix(force?: boolean): void;
  44017. private _bindFrameBuffer;
  44018. /** @hidden */
  44019. _allowPostProcessClearColor: boolean;
  44020. /** @hidden */
  44021. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44022. private _processSubCameras;
  44023. private _checkIntersections;
  44024. /** @hidden */
  44025. _advancePhysicsEngineStep(step: number): void;
  44026. /**
  44027. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44028. */
  44029. getDeterministicFrameTime: () => number;
  44030. /** @hidden */
  44031. _animate(): void;
  44032. /** Execute all animations (for a frame) */
  44033. animate(): void;
  44034. /**
  44035. * Render the scene
  44036. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44037. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44038. */
  44039. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44040. /**
  44041. * Freeze all materials
  44042. * A frozen material will not be updatable but should be faster to render
  44043. */
  44044. freezeMaterials(): void;
  44045. /**
  44046. * Unfreeze all materials
  44047. * A frozen material will not be updatable but should be faster to render
  44048. */
  44049. unfreezeMaterials(): void;
  44050. /**
  44051. * Releases all held ressources
  44052. */
  44053. dispose(): void;
  44054. /**
  44055. * Gets if the scene is already disposed
  44056. */
  44057. get isDisposed(): boolean;
  44058. /**
  44059. * Call this function to reduce memory footprint of the scene.
  44060. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44061. */
  44062. clearCachedVertexData(): void;
  44063. /**
  44064. * This function will remove the local cached buffer data from texture.
  44065. * It will save memory but will prevent the texture from being rebuilt
  44066. */
  44067. cleanCachedTextureBuffer(): void;
  44068. /**
  44069. * Get the world extend vectors with an optional filter
  44070. *
  44071. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44072. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44073. */
  44074. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44075. min: Vector3;
  44076. max: Vector3;
  44077. };
  44078. /**
  44079. * Creates a ray that can be used to pick in the scene
  44080. * @param x defines the x coordinate of the origin (on-screen)
  44081. * @param y defines the y coordinate of the origin (on-screen)
  44082. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44083. * @param camera defines the camera to use for the picking
  44084. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44085. * @returns a Ray
  44086. */
  44087. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44088. /**
  44089. * Creates a ray that can be used to pick in the scene
  44090. * @param x defines the x coordinate of the origin (on-screen)
  44091. * @param y defines the y coordinate of the origin (on-screen)
  44092. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44093. * @param result defines the ray where to store the picking ray
  44094. * @param camera defines the camera to use for the picking
  44095. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44096. * @returns the current scene
  44097. */
  44098. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44099. /**
  44100. * Creates a ray that can be used to pick in the scene
  44101. * @param x defines the x coordinate of the origin (on-screen)
  44102. * @param y defines the y coordinate of the origin (on-screen)
  44103. * @param camera defines the camera to use for the picking
  44104. * @returns a Ray
  44105. */
  44106. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44107. /**
  44108. * Creates a ray that can be used to pick in the scene
  44109. * @param x defines the x coordinate of the origin (on-screen)
  44110. * @param y defines the y coordinate of the origin (on-screen)
  44111. * @param result defines the ray where to store the picking ray
  44112. * @param camera defines the camera to use for the picking
  44113. * @returns the current scene
  44114. */
  44115. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44116. /** Launch a ray to try to pick a mesh in the scene
  44117. * @param x position on screen
  44118. * @param y position on screen
  44119. * @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
  44120. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44121. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44122. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44123. * @returns a PickingInfo
  44124. */
  44125. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44126. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44127. * @param x position on screen
  44128. * @param y position on screen
  44129. * @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
  44130. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44131. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44132. * @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)
  44133. */
  44134. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44135. /** Use the given ray to pick a mesh in the scene
  44136. * @param ray The ray to use to pick meshes
  44137. * @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
  44138. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44139. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44140. * @returns a PickingInfo
  44141. */
  44142. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44143. /**
  44144. * Launch a ray to try to pick a mesh in the scene
  44145. * @param x X position on screen
  44146. * @param y Y position on screen
  44147. * @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
  44148. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44149. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44150. * @returns an array of PickingInfo
  44151. */
  44152. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44153. /**
  44154. * Launch a ray to try to pick a mesh in the scene
  44155. * @param ray Ray to use
  44156. * @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
  44157. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44158. * @returns an array of PickingInfo
  44159. */
  44160. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44161. /**
  44162. * Force the value of meshUnderPointer
  44163. * @param mesh defines the mesh to use
  44164. * @param pointerId optional pointer id when using more than one pointer
  44165. */
  44166. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44167. /**
  44168. * Gets the mesh under the pointer
  44169. * @returns a Mesh or null if no mesh is under the pointer
  44170. */
  44171. getPointerOverMesh(): Nullable<AbstractMesh>;
  44172. /** @hidden */
  44173. _rebuildGeometries(): void;
  44174. /** @hidden */
  44175. _rebuildTextures(): void;
  44176. private _getByTags;
  44177. /**
  44178. * Get a list of meshes by tags
  44179. * @param tagsQuery defines the tags query to use
  44180. * @param forEach defines a predicate used to filter results
  44181. * @returns an array of Mesh
  44182. */
  44183. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44184. /**
  44185. * Get a list of cameras by tags
  44186. * @param tagsQuery defines the tags query to use
  44187. * @param forEach defines a predicate used to filter results
  44188. * @returns an array of Camera
  44189. */
  44190. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44191. /**
  44192. * Get a list of lights by tags
  44193. * @param tagsQuery defines the tags query to use
  44194. * @param forEach defines a predicate used to filter results
  44195. * @returns an array of Light
  44196. */
  44197. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44198. /**
  44199. * Get a list of materials by tags
  44200. * @param tagsQuery defines the tags query to use
  44201. * @param forEach defines a predicate used to filter results
  44202. * @returns an array of Material
  44203. */
  44204. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44205. /**
  44206. * Get a list of transform nodes by tags
  44207. * @param tagsQuery defines the tags query to use
  44208. * @param forEach defines a predicate used to filter results
  44209. * @returns an array of TransformNode
  44210. */
  44211. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44212. /**
  44213. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44214. * This allowed control for front to back rendering or reversly depending of the special needs.
  44215. *
  44216. * @param renderingGroupId The rendering group id corresponding to its index
  44217. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44218. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44219. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44220. */
  44221. 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;
  44222. /**
  44223. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44224. *
  44225. * @param renderingGroupId The rendering group id corresponding to its index
  44226. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44227. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44228. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44229. */
  44230. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44231. /**
  44232. * Gets the current auto clear configuration for one rendering group of the rendering
  44233. * manager.
  44234. * @param index the rendering group index to get the information for
  44235. * @returns The auto clear setup for the requested rendering group
  44236. */
  44237. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44238. private _blockMaterialDirtyMechanism;
  44239. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44240. get blockMaterialDirtyMechanism(): boolean;
  44241. set blockMaterialDirtyMechanism(value: boolean);
  44242. /**
  44243. * Will flag all materials as dirty to trigger new shader compilation
  44244. * @param flag defines the flag used to specify which material part must be marked as dirty
  44245. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44246. */
  44247. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44248. /** @hidden */
  44249. _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;
  44250. /** @hidden */
  44251. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44252. /** @hidden */
  44253. _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;
  44254. /** @hidden */
  44255. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44256. /** @hidden */
  44257. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44258. /** @hidden */
  44259. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44260. }
  44261. }
  44262. declare module BABYLON {
  44263. /**
  44264. * Set of assets to keep when moving a scene into an asset container.
  44265. */
  44266. export class KeepAssets extends AbstractScene {
  44267. }
  44268. /**
  44269. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44270. */
  44271. export class InstantiatedEntries {
  44272. /**
  44273. * List of new root nodes (eg. nodes with no parent)
  44274. */
  44275. rootNodes: TransformNode[];
  44276. /**
  44277. * List of new skeletons
  44278. */
  44279. skeletons: Skeleton[];
  44280. /**
  44281. * List of new animation groups
  44282. */
  44283. animationGroups: AnimationGroup[];
  44284. }
  44285. /**
  44286. * Container with a set of assets that can be added or removed from a scene.
  44287. */
  44288. export class AssetContainer extends AbstractScene {
  44289. private _wasAddedToScene;
  44290. /**
  44291. * The scene the AssetContainer belongs to.
  44292. */
  44293. scene: Scene;
  44294. /**
  44295. * Instantiates an AssetContainer.
  44296. * @param scene The scene the AssetContainer belongs to.
  44297. */
  44298. constructor(scene: Scene);
  44299. /**
  44300. * Instantiate or clone all meshes and add the new ones to the scene.
  44301. * Skeletons and animation groups will all be cloned
  44302. * @param nameFunction defines an optional function used to get new names for clones
  44303. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44304. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44305. */
  44306. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44307. /**
  44308. * Adds all the assets from the container to the scene.
  44309. */
  44310. addAllToScene(): void;
  44311. /**
  44312. * Removes all the assets in the container from the scene
  44313. */
  44314. removeAllFromScene(): void;
  44315. /**
  44316. * Disposes all the assets in the container
  44317. */
  44318. dispose(): void;
  44319. private _moveAssets;
  44320. /**
  44321. * Removes all the assets contained in the scene and adds them to the container.
  44322. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44323. */
  44324. moveAllFromScene(keepAssets?: KeepAssets): void;
  44325. /**
  44326. * 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.
  44327. * @returns the root mesh
  44328. */
  44329. createRootMesh(): Mesh;
  44330. /**
  44331. * Merge animations (direct and animation groups) from this asset container into a scene
  44332. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44333. * @param animatables set of animatables to retarget to a node from the scene
  44334. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44335. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44336. */
  44337. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44338. }
  44339. }
  44340. declare module BABYLON {
  44341. /**
  44342. * Defines how the parser contract is defined.
  44343. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44344. */
  44345. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44346. /**
  44347. * Defines how the individual parser contract is defined.
  44348. * These parser can parse an individual asset
  44349. */
  44350. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44351. /**
  44352. * Base class of the scene acting as a container for the different elements composing a scene.
  44353. * This class is dynamically extended by the different components of the scene increasing
  44354. * flexibility and reducing coupling
  44355. */
  44356. export abstract class AbstractScene {
  44357. /**
  44358. * Stores the list of available parsers in the application.
  44359. */
  44360. private static _BabylonFileParsers;
  44361. /**
  44362. * Stores the list of available individual parsers in the application.
  44363. */
  44364. private static _IndividualBabylonFileParsers;
  44365. /**
  44366. * Adds a parser in the list of available ones
  44367. * @param name Defines the name of the parser
  44368. * @param parser Defines the parser to add
  44369. */
  44370. static AddParser(name: string, parser: BabylonFileParser): void;
  44371. /**
  44372. * Gets a general parser from the list of avaialble ones
  44373. * @param name Defines the name of the parser
  44374. * @returns the requested parser or null
  44375. */
  44376. static GetParser(name: string): Nullable<BabylonFileParser>;
  44377. /**
  44378. * Adds n individual parser in the list of available ones
  44379. * @param name Defines the name of the parser
  44380. * @param parser Defines the parser to add
  44381. */
  44382. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44383. /**
  44384. * Gets an individual parser from the list of avaialble ones
  44385. * @param name Defines the name of the parser
  44386. * @returns the requested parser or null
  44387. */
  44388. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44389. /**
  44390. * Parser json data and populate both a scene and its associated container object
  44391. * @param jsonData Defines the data to parse
  44392. * @param scene Defines the scene to parse the data for
  44393. * @param container Defines the container attached to the parsing sequence
  44394. * @param rootUrl Defines the root url of the data
  44395. */
  44396. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44397. /**
  44398. * Gets the list of root nodes (ie. nodes with no parent)
  44399. */
  44400. rootNodes: Node[];
  44401. /** All of the cameras added to this scene
  44402. * @see https://doc.babylonjs.com/babylon101/cameras
  44403. */
  44404. cameras: Camera[];
  44405. /**
  44406. * All of the lights added to this scene
  44407. * @see https://doc.babylonjs.com/babylon101/lights
  44408. */
  44409. lights: Light[];
  44410. /**
  44411. * All of the (abstract) meshes added to this scene
  44412. */
  44413. meshes: AbstractMesh[];
  44414. /**
  44415. * The list of skeletons added to the scene
  44416. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44417. */
  44418. skeletons: Skeleton[];
  44419. /**
  44420. * All of the particle systems added to this scene
  44421. * @see https://doc.babylonjs.com/babylon101/particles
  44422. */
  44423. particleSystems: IParticleSystem[];
  44424. /**
  44425. * Gets a list of Animations associated with the scene
  44426. */
  44427. animations: Animation[];
  44428. /**
  44429. * All of the animation groups added to this scene
  44430. * @see https://doc.babylonjs.com/how_to/group
  44431. */
  44432. animationGroups: AnimationGroup[];
  44433. /**
  44434. * All of the multi-materials added to this scene
  44435. * @see https://doc.babylonjs.com/how_to/multi_materials
  44436. */
  44437. multiMaterials: MultiMaterial[];
  44438. /**
  44439. * All of the materials added to this scene
  44440. * In the context of a Scene, it is not supposed to be modified manually.
  44441. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44442. * Note also that the order of the Material within the array is not significant and might change.
  44443. * @see https://doc.babylonjs.com/babylon101/materials
  44444. */
  44445. materials: Material[];
  44446. /**
  44447. * The list of morph target managers added to the scene
  44448. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44449. */
  44450. morphTargetManagers: MorphTargetManager[];
  44451. /**
  44452. * The list of geometries used in the scene.
  44453. */
  44454. geometries: Geometry[];
  44455. /**
  44456. * All of the tranform nodes added to this scene
  44457. * In the context of a Scene, it is not supposed to be modified manually.
  44458. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44459. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44460. * @see https://doc.babylonjs.com/how_to/transformnode
  44461. */
  44462. transformNodes: TransformNode[];
  44463. /**
  44464. * ActionManagers available on the scene.
  44465. */
  44466. actionManagers: AbstractActionManager[];
  44467. /**
  44468. * Textures to keep.
  44469. */
  44470. textures: BaseTexture[];
  44471. /** @hidden */
  44472. protected _environmentTexture: Nullable<BaseTexture>;
  44473. /**
  44474. * Texture used in all pbr material as the reflection texture.
  44475. * As in the majority of the scene they are the same (exception for multi room and so on),
  44476. * this is easier to reference from here than from all the materials.
  44477. */
  44478. get environmentTexture(): Nullable<BaseTexture>;
  44479. set environmentTexture(value: Nullable<BaseTexture>);
  44480. /**
  44481. * The list of postprocesses added to the scene
  44482. */
  44483. postProcesses: PostProcess[];
  44484. /**
  44485. * @returns all meshes, lights, cameras, transformNodes and bones
  44486. */
  44487. getNodes(): Array<Node>;
  44488. }
  44489. }
  44490. declare module BABYLON {
  44491. /**
  44492. * Interface used to define options for Sound class
  44493. */
  44494. export interface ISoundOptions {
  44495. /**
  44496. * Does the sound autoplay once loaded.
  44497. */
  44498. autoplay?: boolean;
  44499. /**
  44500. * Does the sound loop after it finishes playing once.
  44501. */
  44502. loop?: boolean;
  44503. /**
  44504. * Sound's volume
  44505. */
  44506. volume?: number;
  44507. /**
  44508. * Is it a spatial sound?
  44509. */
  44510. spatialSound?: boolean;
  44511. /**
  44512. * Maximum distance to hear that sound
  44513. */
  44514. maxDistance?: number;
  44515. /**
  44516. * Uses user defined attenuation function
  44517. */
  44518. useCustomAttenuation?: boolean;
  44519. /**
  44520. * Define the roll off factor of spatial sounds.
  44521. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44522. */
  44523. rolloffFactor?: number;
  44524. /**
  44525. * Define the reference distance the sound should be heard perfectly.
  44526. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44527. */
  44528. refDistance?: number;
  44529. /**
  44530. * Define the distance attenuation model the sound will follow.
  44531. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44532. */
  44533. distanceModel?: string;
  44534. /**
  44535. * Defines the playback speed (1 by default)
  44536. */
  44537. playbackRate?: number;
  44538. /**
  44539. * Defines if the sound is from a streaming source
  44540. */
  44541. streaming?: boolean;
  44542. /**
  44543. * Defines an optional length (in seconds) inside the sound file
  44544. */
  44545. length?: number;
  44546. /**
  44547. * Defines an optional offset (in seconds) inside the sound file
  44548. */
  44549. offset?: number;
  44550. /**
  44551. * If true, URLs will not be required to state the audio file codec to use.
  44552. */
  44553. skipCodecCheck?: boolean;
  44554. }
  44555. /**
  44556. * Defines a sound that can be played in the application.
  44557. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  44558. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44559. */
  44560. export class Sound {
  44561. /**
  44562. * The name of the sound in the scene.
  44563. */
  44564. name: string;
  44565. /**
  44566. * Does the sound autoplay once loaded.
  44567. */
  44568. autoplay: boolean;
  44569. /**
  44570. * Does the sound loop after it finishes playing once.
  44571. */
  44572. loop: boolean;
  44573. /**
  44574. * Does the sound use a custom attenuation curve to simulate the falloff
  44575. * happening when the source gets further away from the camera.
  44576. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44577. */
  44578. useCustomAttenuation: boolean;
  44579. /**
  44580. * The sound track id this sound belongs to.
  44581. */
  44582. soundTrackId: number;
  44583. /**
  44584. * Is this sound currently played.
  44585. */
  44586. isPlaying: boolean;
  44587. /**
  44588. * Is this sound currently paused.
  44589. */
  44590. isPaused: boolean;
  44591. /**
  44592. * Does this sound enables spatial sound.
  44593. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44594. */
  44595. spatialSound: boolean;
  44596. /**
  44597. * Define the reference distance the sound should be heard perfectly.
  44598. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44599. */
  44600. refDistance: number;
  44601. /**
  44602. * Define the roll off factor of spatial sounds.
  44603. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44604. */
  44605. rolloffFactor: number;
  44606. /**
  44607. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  44608. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44609. */
  44610. maxDistance: number;
  44611. /**
  44612. * Define the distance attenuation model the sound will follow.
  44613. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44614. */
  44615. distanceModel: string;
  44616. /**
  44617. * @hidden
  44618. * Back Compat
  44619. **/
  44620. onended: () => any;
  44621. /**
  44622. * Gets or sets an object used to store user defined information for the sound.
  44623. */
  44624. metadata: any;
  44625. /**
  44626. * Observable event when the current playing sound finishes.
  44627. */
  44628. onEndedObservable: Observable<Sound>;
  44629. private _panningModel;
  44630. private _playbackRate;
  44631. private _streaming;
  44632. private _startTime;
  44633. private _startOffset;
  44634. private _position;
  44635. /** @hidden */
  44636. _positionInEmitterSpace: boolean;
  44637. private _localDirection;
  44638. private _volume;
  44639. private _isReadyToPlay;
  44640. private _isDirectional;
  44641. private _readyToPlayCallback;
  44642. private _audioBuffer;
  44643. private _soundSource;
  44644. private _streamingSource;
  44645. private _soundPanner;
  44646. private _soundGain;
  44647. private _inputAudioNode;
  44648. private _outputAudioNode;
  44649. private _coneInnerAngle;
  44650. private _coneOuterAngle;
  44651. private _coneOuterGain;
  44652. private _scene;
  44653. private _connectedTransformNode;
  44654. private _customAttenuationFunction;
  44655. private _registerFunc;
  44656. private _isOutputConnected;
  44657. private _htmlAudioElement;
  44658. private _urlType;
  44659. private _length?;
  44660. private _offset?;
  44661. /** @hidden */
  44662. static _SceneComponentInitialization: (scene: Scene) => void;
  44663. /**
  44664. * Create a sound and attach it to a scene
  44665. * @param name Name of your sound
  44666. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  44667. * @param scene defines the scene the sound belongs to
  44668. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  44669. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  44670. */
  44671. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  44672. /**
  44673. * Release the sound and its associated resources
  44674. */
  44675. dispose(): void;
  44676. /**
  44677. * Gets if the sounds is ready to be played or not.
  44678. * @returns true if ready, otherwise false
  44679. */
  44680. isReady(): boolean;
  44681. private _soundLoaded;
  44682. /**
  44683. * Sets the data of the sound from an audiobuffer
  44684. * @param audioBuffer The audioBuffer containing the data
  44685. */
  44686. setAudioBuffer(audioBuffer: AudioBuffer): void;
  44687. /**
  44688. * Updates the current sounds options such as maxdistance, loop...
  44689. * @param options A JSON object containing values named as the object properties
  44690. */
  44691. updateOptions(options: ISoundOptions): void;
  44692. private _createSpatialParameters;
  44693. private _updateSpatialParameters;
  44694. /**
  44695. * Switch the panning model to HRTF:
  44696. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  44697. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44698. */
  44699. switchPanningModelToHRTF(): void;
  44700. /**
  44701. * Switch the panning model to Equal Power:
  44702. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  44703. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44704. */
  44705. switchPanningModelToEqualPower(): void;
  44706. private _switchPanningModel;
  44707. /**
  44708. * Connect this sound to a sound track audio node like gain...
  44709. * @param soundTrackAudioNode the sound track audio node to connect to
  44710. */
  44711. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  44712. /**
  44713. * Transform this sound into a directional source
  44714. * @param coneInnerAngle Size of the inner cone in degree
  44715. * @param coneOuterAngle Size of the outer cone in degree
  44716. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  44717. */
  44718. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  44719. /**
  44720. * Gets or sets the inner angle for the directional cone.
  44721. */
  44722. get directionalConeInnerAngle(): number;
  44723. /**
  44724. * Gets or sets the inner angle for the directional cone.
  44725. */
  44726. set directionalConeInnerAngle(value: number);
  44727. /**
  44728. * Gets or sets the outer angle for the directional cone.
  44729. */
  44730. get directionalConeOuterAngle(): number;
  44731. /**
  44732. * Gets or sets the outer angle for the directional cone.
  44733. */
  44734. set directionalConeOuterAngle(value: number);
  44735. /**
  44736. * Sets the position of the emitter if spatial sound is enabled
  44737. * @param newPosition Defines the new posisiton
  44738. */
  44739. setPosition(newPosition: Vector3): void;
  44740. /**
  44741. * Sets the local direction of the emitter if spatial sound is enabled
  44742. * @param newLocalDirection Defines the new local direction
  44743. */
  44744. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  44745. private _updateDirection;
  44746. /** @hidden */
  44747. updateDistanceFromListener(): void;
  44748. /**
  44749. * Sets a new custom attenuation function for the sound.
  44750. * @param callback Defines the function used for the attenuation
  44751. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44752. */
  44753. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  44754. /**
  44755. * Play the sound
  44756. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  44757. * @param offset (optional) Start the sound at a specific time in seconds
  44758. * @param length (optional) Sound duration (in seconds)
  44759. */
  44760. play(time?: number, offset?: number, length?: number): void;
  44761. private _onended;
  44762. /**
  44763. * Stop the sound
  44764. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  44765. */
  44766. stop(time?: number): void;
  44767. /**
  44768. * Put the sound in pause
  44769. */
  44770. pause(): void;
  44771. /**
  44772. * Sets a dedicated volume for this sounds
  44773. * @param newVolume Define the new volume of the sound
  44774. * @param time Define time for gradual change to new volume
  44775. */
  44776. setVolume(newVolume: number, time?: number): void;
  44777. /**
  44778. * Set the sound play back rate
  44779. * @param newPlaybackRate Define the playback rate the sound should be played at
  44780. */
  44781. setPlaybackRate(newPlaybackRate: number): void;
  44782. /**
  44783. * Gets the volume of the sound.
  44784. * @returns the volume of the sound
  44785. */
  44786. getVolume(): number;
  44787. /**
  44788. * Attach the sound to a dedicated mesh
  44789. * @param transformNode The transform node to connect the sound with
  44790. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  44791. */
  44792. attachToMesh(transformNode: TransformNode): void;
  44793. /**
  44794. * Detach the sound from the previously attached mesh
  44795. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  44796. */
  44797. detachFromMesh(): void;
  44798. private _onRegisterAfterWorldMatrixUpdate;
  44799. /**
  44800. * Clone the current sound in the scene.
  44801. * @returns the new sound clone
  44802. */
  44803. clone(): Nullable<Sound>;
  44804. /**
  44805. * Gets the current underlying audio buffer containing the data
  44806. * @returns the audio buffer
  44807. */
  44808. getAudioBuffer(): Nullable<AudioBuffer>;
  44809. /**
  44810. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  44811. * @returns the source node
  44812. */
  44813. getSoundSource(): Nullable<AudioBufferSourceNode>;
  44814. /**
  44815. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  44816. * @returns the gain node
  44817. */
  44818. getSoundGain(): Nullable<GainNode>;
  44819. /**
  44820. * Serializes the Sound in a JSON representation
  44821. * @returns the JSON representation of the sound
  44822. */
  44823. serialize(): any;
  44824. /**
  44825. * Parse a JSON representation of a sound to innstantiate in a given scene
  44826. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  44827. * @param scene Define the scene the new parsed sound should be created in
  44828. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  44829. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  44830. * @returns the newly parsed sound
  44831. */
  44832. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  44833. }
  44834. }
  44835. declare module BABYLON {
  44836. /**
  44837. * This defines an action helpful to play a defined sound on a triggered action.
  44838. */
  44839. export class PlaySoundAction extends Action {
  44840. private _sound;
  44841. /**
  44842. * Instantiate the action
  44843. * @param triggerOptions defines the trigger options
  44844. * @param sound defines the sound to play
  44845. * @param condition defines the trigger related conditions
  44846. */
  44847. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  44848. /** @hidden */
  44849. _prepare(): void;
  44850. /**
  44851. * Execute the action and play the sound.
  44852. */
  44853. execute(): void;
  44854. /**
  44855. * Serializes the actions and its related information.
  44856. * @param parent defines the object to serialize in
  44857. * @returns the serialized object
  44858. */
  44859. serialize(parent: any): any;
  44860. }
  44861. /**
  44862. * This defines an action helpful to stop a defined sound on a triggered action.
  44863. */
  44864. export class StopSoundAction extends Action {
  44865. private _sound;
  44866. /**
  44867. * Instantiate the action
  44868. * @param triggerOptions defines the trigger options
  44869. * @param sound defines the sound to stop
  44870. * @param condition defines the trigger related conditions
  44871. */
  44872. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  44873. /** @hidden */
  44874. _prepare(): void;
  44875. /**
  44876. * Execute the action and stop the sound.
  44877. */
  44878. execute(): void;
  44879. /**
  44880. * Serializes the actions and its related information.
  44881. * @param parent defines the object to serialize in
  44882. * @returns the serialized object
  44883. */
  44884. serialize(parent: any): any;
  44885. }
  44886. }
  44887. declare module BABYLON {
  44888. /**
  44889. * This defines an action responsible to change the value of a property
  44890. * by interpolating between its current value and the newly set one once triggered.
  44891. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44892. */
  44893. export class InterpolateValueAction extends Action {
  44894. /**
  44895. * Defines the path of the property where the value should be interpolated
  44896. */
  44897. propertyPath: string;
  44898. /**
  44899. * Defines the target value at the end of the interpolation.
  44900. */
  44901. value: any;
  44902. /**
  44903. * Defines the time it will take for the property to interpolate to the value.
  44904. */
  44905. duration: number;
  44906. /**
  44907. * Defines if the other scene animations should be stopped when the action has been triggered
  44908. */
  44909. stopOtherAnimations?: boolean;
  44910. /**
  44911. * Defines a callback raised once the interpolation animation has been done.
  44912. */
  44913. onInterpolationDone?: () => void;
  44914. /**
  44915. * Observable triggered once the interpolation animation has been done.
  44916. */
  44917. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  44918. private _target;
  44919. private _effectiveTarget;
  44920. private _property;
  44921. /**
  44922. * Instantiate the action
  44923. * @param triggerOptions defines the trigger options
  44924. * @param target defines the object containing the value to interpolate
  44925. * @param propertyPath defines the path to the property in the target object
  44926. * @param value defines the target value at the end of the interpolation
  44927. * @param duration deines the time it will take for the property to interpolate to the value.
  44928. * @param condition defines the trigger related conditions
  44929. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  44930. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  44931. */
  44932. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  44933. /** @hidden */
  44934. _prepare(): void;
  44935. /**
  44936. * Execute the action starts the value interpolation.
  44937. */
  44938. execute(): void;
  44939. /**
  44940. * Serializes the actions and its related information.
  44941. * @param parent defines the object to serialize in
  44942. * @returns the serialized object
  44943. */
  44944. serialize(parent: any): any;
  44945. }
  44946. }
  44947. declare module BABYLON {
  44948. /**
  44949. * Options allowed during the creation of a sound track.
  44950. */
  44951. export interface ISoundTrackOptions {
  44952. /**
  44953. * The volume the sound track should take during creation
  44954. */
  44955. volume?: number;
  44956. /**
  44957. * Define if the sound track is the main sound track of the scene
  44958. */
  44959. mainTrack?: boolean;
  44960. }
  44961. /**
  44962. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  44963. * It will be also used in a future release to apply effects on a specific track.
  44964. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  44965. */
  44966. export class SoundTrack {
  44967. /**
  44968. * The unique identifier of the sound track in the scene.
  44969. */
  44970. id: number;
  44971. /**
  44972. * The list of sounds included in the sound track.
  44973. */
  44974. soundCollection: Array<Sound>;
  44975. private _outputAudioNode;
  44976. private _scene;
  44977. private _connectedAnalyser;
  44978. private _options;
  44979. private _isInitialized;
  44980. /**
  44981. * Creates a new sound track.
  44982. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  44983. * @param scene Define the scene the sound track belongs to
  44984. * @param options
  44985. */
  44986. constructor(scene: Scene, options?: ISoundTrackOptions);
  44987. private _initializeSoundTrackAudioGraph;
  44988. /**
  44989. * Release the sound track and its associated resources
  44990. */
  44991. dispose(): void;
  44992. /**
  44993. * Adds a sound to this sound track
  44994. * @param sound define the cound to add
  44995. * @ignoreNaming
  44996. */
  44997. AddSound(sound: Sound): void;
  44998. /**
  44999. * Removes a sound to this sound track
  45000. * @param sound define the cound to remove
  45001. * @ignoreNaming
  45002. */
  45003. RemoveSound(sound: Sound): void;
  45004. /**
  45005. * Set a global volume for the full sound track.
  45006. * @param newVolume Define the new volume of the sound track
  45007. */
  45008. setVolume(newVolume: number): void;
  45009. /**
  45010. * Switch the panning model to HRTF:
  45011. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45012. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45013. */
  45014. switchPanningModelToHRTF(): void;
  45015. /**
  45016. * Switch the panning model to Equal Power:
  45017. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45018. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45019. */
  45020. switchPanningModelToEqualPower(): void;
  45021. /**
  45022. * Connect the sound track to an audio analyser allowing some amazing
  45023. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45024. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45025. * @param analyser The analyser to connect to the engine
  45026. */
  45027. connectToAnalyser(analyser: Analyser): void;
  45028. }
  45029. }
  45030. declare module BABYLON {
  45031. interface AbstractScene {
  45032. /**
  45033. * The list of sounds used in the scene.
  45034. */
  45035. sounds: Nullable<Array<Sound>>;
  45036. }
  45037. interface Scene {
  45038. /**
  45039. * @hidden
  45040. * Backing field
  45041. */
  45042. _mainSoundTrack: SoundTrack;
  45043. /**
  45044. * The main sound track played by the scene.
  45045. * It cotains your primary collection of sounds.
  45046. */
  45047. mainSoundTrack: SoundTrack;
  45048. /**
  45049. * The list of sound tracks added to the scene
  45050. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45051. */
  45052. soundTracks: Nullable<Array<SoundTrack>>;
  45053. /**
  45054. * Gets a sound using a given name
  45055. * @param name defines the name to search for
  45056. * @return the found sound or null if not found at all.
  45057. */
  45058. getSoundByName(name: string): Nullable<Sound>;
  45059. /**
  45060. * Gets or sets if audio support is enabled
  45061. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45062. */
  45063. audioEnabled: boolean;
  45064. /**
  45065. * Gets or sets if audio will be output to headphones
  45066. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45067. */
  45068. headphone: boolean;
  45069. /**
  45070. * Gets or sets custom audio listener position provider
  45071. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45072. */
  45073. audioListenerPositionProvider: Nullable<() => Vector3>;
  45074. /**
  45075. * Gets or sets a refresh rate when using 3D audio positioning
  45076. */
  45077. audioPositioningRefreshRate: number;
  45078. }
  45079. /**
  45080. * Defines the sound scene component responsible to manage any sounds
  45081. * in a given scene.
  45082. */
  45083. export class AudioSceneComponent implements ISceneSerializableComponent {
  45084. private static _CameraDirectionLH;
  45085. private static _CameraDirectionRH;
  45086. /**
  45087. * The component name helpfull to identify the component in the list of scene components.
  45088. */
  45089. readonly name: string;
  45090. /**
  45091. * The scene the component belongs to.
  45092. */
  45093. scene: Scene;
  45094. private _audioEnabled;
  45095. /**
  45096. * Gets whether audio is enabled or not.
  45097. * Please use related enable/disable method to switch state.
  45098. */
  45099. get audioEnabled(): boolean;
  45100. private _headphone;
  45101. /**
  45102. * Gets whether audio is outputing to headphone or not.
  45103. * Please use the according Switch methods to change output.
  45104. */
  45105. get headphone(): boolean;
  45106. /**
  45107. * Gets or sets a refresh rate when using 3D audio positioning
  45108. */
  45109. audioPositioningRefreshRate: number;
  45110. private _audioListenerPositionProvider;
  45111. /**
  45112. * Gets the current audio listener position provider
  45113. */
  45114. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45115. /**
  45116. * Sets a custom listener position for all sounds in the scene
  45117. * By default, this is the position of the first active camera
  45118. */
  45119. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45120. /**
  45121. * Creates a new instance of the component for the given scene
  45122. * @param scene Defines the scene to register the component in
  45123. */
  45124. constructor(scene: Scene);
  45125. /**
  45126. * Registers the component in a given scene
  45127. */
  45128. register(): void;
  45129. /**
  45130. * Rebuilds the elements related to this component in case of
  45131. * context lost for instance.
  45132. */
  45133. rebuild(): void;
  45134. /**
  45135. * Serializes the component data to the specified json object
  45136. * @param serializationObject The object to serialize to
  45137. */
  45138. serialize(serializationObject: any): void;
  45139. /**
  45140. * Adds all the elements from the container to the scene
  45141. * @param container the container holding the elements
  45142. */
  45143. addFromContainer(container: AbstractScene): void;
  45144. /**
  45145. * Removes all the elements in the container from the scene
  45146. * @param container contains the elements to remove
  45147. * @param dispose if the removed element should be disposed (default: false)
  45148. */
  45149. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45150. /**
  45151. * Disposes the component and the associated ressources.
  45152. */
  45153. dispose(): void;
  45154. /**
  45155. * Disables audio in the associated scene.
  45156. */
  45157. disableAudio(): void;
  45158. /**
  45159. * Enables audio in the associated scene.
  45160. */
  45161. enableAudio(): void;
  45162. /**
  45163. * Switch audio to headphone output.
  45164. */
  45165. switchAudioModeForHeadphones(): void;
  45166. /**
  45167. * Switch audio to normal speakers.
  45168. */
  45169. switchAudioModeForNormalSpeakers(): void;
  45170. private _cachedCameraDirection;
  45171. private _cachedCameraPosition;
  45172. private _lastCheck;
  45173. private _afterRender;
  45174. }
  45175. }
  45176. declare module BABYLON {
  45177. /**
  45178. * Wraps one or more Sound objects and selects one with random weight for playback.
  45179. */
  45180. export class WeightedSound {
  45181. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45182. loop: boolean;
  45183. private _coneInnerAngle;
  45184. private _coneOuterAngle;
  45185. private _volume;
  45186. /** A Sound is currently playing. */
  45187. isPlaying: boolean;
  45188. /** A Sound is currently paused. */
  45189. isPaused: boolean;
  45190. private _sounds;
  45191. private _weights;
  45192. private _currentIndex?;
  45193. /**
  45194. * Creates a new WeightedSound from the list of sounds given.
  45195. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45196. * @param sounds Array of Sounds that will be selected from.
  45197. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45198. */
  45199. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45200. /**
  45201. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45202. */
  45203. get directionalConeInnerAngle(): number;
  45204. /**
  45205. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45206. */
  45207. set directionalConeInnerAngle(value: number);
  45208. /**
  45209. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45210. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45211. */
  45212. get directionalConeOuterAngle(): number;
  45213. /**
  45214. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45215. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45216. */
  45217. set directionalConeOuterAngle(value: number);
  45218. /**
  45219. * Playback volume.
  45220. */
  45221. get volume(): number;
  45222. /**
  45223. * Playback volume.
  45224. */
  45225. set volume(value: number);
  45226. private _onended;
  45227. /**
  45228. * Suspend playback
  45229. */
  45230. pause(): void;
  45231. /**
  45232. * Stop playback
  45233. */
  45234. stop(): void;
  45235. /**
  45236. * Start playback.
  45237. * @param startOffset Position the clip head at a specific time in seconds.
  45238. */
  45239. play(startOffset?: number): void;
  45240. }
  45241. }
  45242. declare module BABYLON {
  45243. /**
  45244. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45245. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45246. */
  45247. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45248. /**
  45249. * Gets the name of the behavior.
  45250. */
  45251. get name(): string;
  45252. /**
  45253. * The easing function used by animations
  45254. */
  45255. static EasingFunction: BackEase;
  45256. /**
  45257. * The easing mode used by animations
  45258. */
  45259. static EasingMode: number;
  45260. /**
  45261. * The duration of the animation, in milliseconds
  45262. */
  45263. transitionDuration: number;
  45264. /**
  45265. * Length of the distance animated by the transition when lower radius is reached
  45266. */
  45267. lowerRadiusTransitionRange: number;
  45268. /**
  45269. * Length of the distance animated by the transition when upper radius is reached
  45270. */
  45271. upperRadiusTransitionRange: number;
  45272. private _autoTransitionRange;
  45273. /**
  45274. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45275. */
  45276. get autoTransitionRange(): boolean;
  45277. /**
  45278. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45279. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45280. */
  45281. set autoTransitionRange(value: boolean);
  45282. private _attachedCamera;
  45283. private _onAfterCheckInputsObserver;
  45284. private _onMeshTargetChangedObserver;
  45285. /**
  45286. * Initializes the behavior.
  45287. */
  45288. init(): void;
  45289. /**
  45290. * Attaches the behavior to its arc rotate camera.
  45291. * @param camera Defines the camera to attach the behavior to
  45292. */
  45293. attach(camera: ArcRotateCamera): void;
  45294. /**
  45295. * Detaches the behavior from its current arc rotate camera.
  45296. */
  45297. detach(): void;
  45298. private _radiusIsAnimating;
  45299. private _radiusBounceTransition;
  45300. private _animatables;
  45301. private _cachedWheelPrecision;
  45302. /**
  45303. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45304. * @param radiusLimit The limit to check against.
  45305. * @return Bool to indicate if at limit.
  45306. */
  45307. private _isRadiusAtLimit;
  45308. /**
  45309. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45310. * @param radiusDelta The delta by which to animate to. Can be negative.
  45311. */
  45312. private _applyBoundRadiusAnimation;
  45313. /**
  45314. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45315. */
  45316. protected _clearAnimationLocks(): void;
  45317. /**
  45318. * Stops and removes all animations that have been applied to the camera
  45319. */
  45320. stopAllAnimations(): void;
  45321. }
  45322. }
  45323. declare module BABYLON {
  45324. /**
  45325. * 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.
  45326. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45327. */
  45328. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45329. /**
  45330. * Gets the name of the behavior.
  45331. */
  45332. get name(): string;
  45333. private _mode;
  45334. private _radiusScale;
  45335. private _positionScale;
  45336. private _defaultElevation;
  45337. private _elevationReturnTime;
  45338. private _elevationReturnWaitTime;
  45339. private _zoomStopsAnimation;
  45340. private _framingTime;
  45341. /**
  45342. * The easing function used by animations
  45343. */
  45344. static EasingFunction: ExponentialEase;
  45345. /**
  45346. * The easing mode used by animations
  45347. */
  45348. static EasingMode: number;
  45349. /**
  45350. * Sets the current mode used by the behavior
  45351. */
  45352. set mode(mode: number);
  45353. /**
  45354. * Gets current mode used by the behavior.
  45355. */
  45356. get mode(): number;
  45357. /**
  45358. * Sets the scale applied to the radius (1 by default)
  45359. */
  45360. set radiusScale(radius: number);
  45361. /**
  45362. * Gets the scale applied to the radius
  45363. */
  45364. get radiusScale(): number;
  45365. /**
  45366. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45367. */
  45368. set positionScale(scale: number);
  45369. /**
  45370. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45371. */
  45372. get positionScale(): number;
  45373. /**
  45374. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45375. * behaviour is triggered, in radians.
  45376. */
  45377. set defaultElevation(elevation: number);
  45378. /**
  45379. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45380. * behaviour is triggered, in radians.
  45381. */
  45382. get defaultElevation(): number;
  45383. /**
  45384. * Sets the time (in milliseconds) taken to return to the default beta position.
  45385. * Negative value indicates camera should not return to default.
  45386. */
  45387. set elevationReturnTime(speed: number);
  45388. /**
  45389. * Gets the time (in milliseconds) taken to return to the default beta position.
  45390. * Negative value indicates camera should not return to default.
  45391. */
  45392. get elevationReturnTime(): number;
  45393. /**
  45394. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45395. */
  45396. set elevationReturnWaitTime(time: number);
  45397. /**
  45398. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45399. */
  45400. get elevationReturnWaitTime(): number;
  45401. /**
  45402. * Sets the flag that indicates if user zooming should stop animation.
  45403. */
  45404. set zoomStopsAnimation(flag: boolean);
  45405. /**
  45406. * Gets the flag that indicates if user zooming should stop animation.
  45407. */
  45408. get zoomStopsAnimation(): boolean;
  45409. /**
  45410. * Sets the transition time when framing the mesh, in milliseconds
  45411. */
  45412. set framingTime(time: number);
  45413. /**
  45414. * Gets the transition time when framing the mesh, in milliseconds
  45415. */
  45416. get framingTime(): number;
  45417. /**
  45418. * Define if the behavior should automatically change the configured
  45419. * camera limits and sensibilities.
  45420. */
  45421. autoCorrectCameraLimitsAndSensibility: boolean;
  45422. private _onPrePointerObservableObserver;
  45423. private _onAfterCheckInputsObserver;
  45424. private _onMeshTargetChangedObserver;
  45425. private _attachedCamera;
  45426. private _isPointerDown;
  45427. private _lastInteractionTime;
  45428. /**
  45429. * Initializes the behavior.
  45430. */
  45431. init(): void;
  45432. /**
  45433. * Attaches the behavior to its arc rotate camera.
  45434. * @param camera Defines the camera to attach the behavior to
  45435. */
  45436. attach(camera: ArcRotateCamera): void;
  45437. /**
  45438. * Detaches the behavior from its current arc rotate camera.
  45439. */
  45440. detach(): void;
  45441. private _animatables;
  45442. private _betaIsAnimating;
  45443. private _betaTransition;
  45444. private _radiusTransition;
  45445. private _vectorTransition;
  45446. /**
  45447. * Targets the given mesh and updates zoom level accordingly.
  45448. * @param mesh The mesh to target.
  45449. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45450. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45451. */
  45452. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45453. /**
  45454. * Targets the given mesh with its children and updates zoom level accordingly.
  45455. * @param mesh The mesh to target.
  45456. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45457. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45458. */
  45459. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45460. /**
  45461. * Targets the given meshes with their children and updates zoom level accordingly.
  45462. * @param meshes The mesh to target.
  45463. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45464. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45465. */
  45466. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45467. /**
  45468. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  45469. * @param minimumWorld Determines the smaller position of the bounding box extend
  45470. * @param maximumWorld Determines the bigger position of the bounding box extend
  45471. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45472. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45473. */
  45474. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45475. /**
  45476. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  45477. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  45478. * frustum width.
  45479. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  45480. * to fully enclose the mesh in the viewing frustum.
  45481. */
  45482. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  45483. /**
  45484. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  45485. * is automatically returned to its default position (expected to be above ground plane).
  45486. */
  45487. private _maintainCameraAboveGround;
  45488. /**
  45489. * Returns the frustum slope based on the canvas ratio and camera FOV
  45490. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  45491. */
  45492. private _getFrustumSlope;
  45493. /**
  45494. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  45495. */
  45496. private _clearAnimationLocks;
  45497. /**
  45498. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45499. */
  45500. private _applyUserInteraction;
  45501. /**
  45502. * Stops and removes all animations that have been applied to the camera
  45503. */
  45504. stopAllAnimations(): void;
  45505. /**
  45506. * Gets a value indicating if the user is moving the camera
  45507. */
  45508. get isUserIsMoving(): boolean;
  45509. /**
  45510. * The camera can move all the way towards the mesh.
  45511. */
  45512. static IgnoreBoundsSizeMode: number;
  45513. /**
  45514. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  45515. */
  45516. static FitFrustumSidesMode: number;
  45517. }
  45518. }
  45519. declare module BABYLON {
  45520. /**
  45521. * Base class for Camera Pointer Inputs.
  45522. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  45523. * for example usage.
  45524. */
  45525. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  45526. /**
  45527. * Defines the camera the input is attached to.
  45528. */
  45529. abstract camera: Camera;
  45530. /**
  45531. * Whether keyboard modifier keys are pressed at time of last mouse event.
  45532. */
  45533. protected _altKey: boolean;
  45534. protected _ctrlKey: boolean;
  45535. protected _metaKey: boolean;
  45536. protected _shiftKey: boolean;
  45537. /**
  45538. * Which mouse buttons were pressed at time of last mouse event.
  45539. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  45540. */
  45541. protected _buttonsPressed: number;
  45542. /**
  45543. * Defines the buttons associated with the input to handle camera move.
  45544. */
  45545. buttons: number[];
  45546. /**
  45547. * Attach the input controls to a specific dom element to get the input from.
  45548. * @param element Defines the element the controls should be listened from
  45549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45550. */
  45551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45552. /**
  45553. * Detach the current controls from the specified dom element.
  45554. * @param element Defines the element to stop listening the inputs from
  45555. */
  45556. detachControl(element: Nullable<HTMLElement>): void;
  45557. /**
  45558. * Gets the class name of the current input.
  45559. * @returns the class name
  45560. */
  45561. getClassName(): string;
  45562. /**
  45563. * Get the friendly name associated with the input class.
  45564. * @returns the input friendly name
  45565. */
  45566. getSimpleName(): string;
  45567. /**
  45568. * Called on pointer POINTERDOUBLETAP event.
  45569. * Override this method to provide functionality on POINTERDOUBLETAP event.
  45570. */
  45571. protected onDoubleTap(type: string): void;
  45572. /**
  45573. * Called on pointer POINTERMOVE event if only a single touch is active.
  45574. * Override this method to provide functionality.
  45575. */
  45576. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45577. /**
  45578. * Called on pointer POINTERMOVE event if multiple touches are active.
  45579. * Override this method to provide functionality.
  45580. */
  45581. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45582. /**
  45583. * Called on JS contextmenu event.
  45584. * Override this method to provide functionality.
  45585. */
  45586. protected onContextMenu(evt: PointerEvent): void;
  45587. /**
  45588. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45589. * press.
  45590. * Override this method to provide functionality.
  45591. */
  45592. protected onButtonDown(evt: PointerEvent): void;
  45593. /**
  45594. * Called each time a new POINTERUP event occurs. Ie, for each button
  45595. * release.
  45596. * Override this method to provide functionality.
  45597. */
  45598. protected onButtonUp(evt: PointerEvent): void;
  45599. /**
  45600. * Called when window becomes inactive.
  45601. * Override this method to provide functionality.
  45602. */
  45603. protected onLostFocus(): void;
  45604. private _pointerInput;
  45605. private _observer;
  45606. private _onLostFocus;
  45607. private pointA;
  45608. private pointB;
  45609. }
  45610. }
  45611. declare module BABYLON {
  45612. /**
  45613. * Manage the pointers inputs to control an arc rotate camera.
  45614. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45615. */
  45616. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  45617. /**
  45618. * Defines the camera the input is attached to.
  45619. */
  45620. camera: ArcRotateCamera;
  45621. /**
  45622. * Gets the class name of the current input.
  45623. * @returns the class name
  45624. */
  45625. getClassName(): string;
  45626. /**
  45627. * Defines the buttons associated with the input to handle camera move.
  45628. */
  45629. buttons: number[];
  45630. /**
  45631. * Defines the pointer angular sensibility along the X axis or how fast is
  45632. * the camera rotating.
  45633. */
  45634. angularSensibilityX: number;
  45635. /**
  45636. * Defines the pointer angular sensibility along the Y axis or how fast is
  45637. * the camera rotating.
  45638. */
  45639. angularSensibilityY: number;
  45640. /**
  45641. * Defines the pointer pinch precision or how fast is the camera zooming.
  45642. */
  45643. pinchPrecision: number;
  45644. /**
  45645. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45646. * from 0.
  45647. * It defines the percentage of current camera.radius to use as delta when
  45648. * pinch zoom is used.
  45649. */
  45650. pinchDeltaPercentage: number;
  45651. /**
  45652. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  45653. * that any object in the plane at the camera's target point will scale
  45654. * perfectly with finger motion.
  45655. * Overrides pinchDeltaPercentage and pinchPrecision.
  45656. */
  45657. useNaturalPinchZoom: boolean;
  45658. /**
  45659. * Defines the pointer panning sensibility or how fast is the camera moving.
  45660. */
  45661. panningSensibility: number;
  45662. /**
  45663. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  45664. */
  45665. multiTouchPanning: boolean;
  45666. /**
  45667. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  45668. * zoom (pinch) through multitouch.
  45669. */
  45670. multiTouchPanAndZoom: boolean;
  45671. /**
  45672. * Revers pinch action direction.
  45673. */
  45674. pinchInwards: boolean;
  45675. private _isPanClick;
  45676. private _twoFingerActivityCount;
  45677. private _isPinching;
  45678. /**
  45679. * Called on pointer POINTERMOVE event if only a single touch is active.
  45680. */
  45681. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45682. /**
  45683. * Called on pointer POINTERDOUBLETAP event.
  45684. */
  45685. protected onDoubleTap(type: string): void;
  45686. /**
  45687. * Called on pointer POINTERMOVE event if multiple touches are active.
  45688. */
  45689. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45690. /**
  45691. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45692. * press.
  45693. */
  45694. protected onButtonDown(evt: PointerEvent): void;
  45695. /**
  45696. * Called each time a new POINTERUP event occurs. Ie, for each button
  45697. * release.
  45698. */
  45699. protected onButtonUp(evt: PointerEvent): void;
  45700. /**
  45701. * Called when window becomes inactive.
  45702. */
  45703. protected onLostFocus(): void;
  45704. }
  45705. }
  45706. declare module BABYLON {
  45707. /**
  45708. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  45709. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45710. */
  45711. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  45712. /**
  45713. * Defines the camera the input is attached to.
  45714. */
  45715. camera: ArcRotateCamera;
  45716. /**
  45717. * Defines the list of key codes associated with the up action (increase alpha)
  45718. */
  45719. keysUp: number[];
  45720. /**
  45721. * Defines the list of key codes associated with the down action (decrease alpha)
  45722. */
  45723. keysDown: number[];
  45724. /**
  45725. * Defines the list of key codes associated with the left action (increase beta)
  45726. */
  45727. keysLeft: number[];
  45728. /**
  45729. * Defines the list of key codes associated with the right action (decrease beta)
  45730. */
  45731. keysRight: number[];
  45732. /**
  45733. * Defines the list of key codes associated with the reset action.
  45734. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  45735. */
  45736. keysReset: number[];
  45737. /**
  45738. * Defines the panning sensibility of the inputs.
  45739. * (How fast is the camera panning)
  45740. */
  45741. panningSensibility: number;
  45742. /**
  45743. * Defines the zooming sensibility of the inputs.
  45744. * (How fast is the camera zooming)
  45745. */
  45746. zoomingSensibility: number;
  45747. /**
  45748. * Defines whether maintaining the alt key down switch the movement mode from
  45749. * orientation to zoom.
  45750. */
  45751. useAltToZoom: boolean;
  45752. /**
  45753. * Rotation speed of the camera
  45754. */
  45755. angularSpeed: number;
  45756. private _keys;
  45757. private _ctrlPressed;
  45758. private _altPressed;
  45759. private _onCanvasBlurObserver;
  45760. private _onKeyboardObserver;
  45761. private _engine;
  45762. private _scene;
  45763. /**
  45764. * Attach the input controls to a specific dom element to get the input from.
  45765. * @param element Defines the element the controls should be listened from
  45766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45767. */
  45768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45769. /**
  45770. * Detach the current controls from the specified dom element.
  45771. * @param element Defines the element to stop listening the inputs from
  45772. */
  45773. detachControl(element: Nullable<HTMLElement>): void;
  45774. /**
  45775. * Update the current camera state depending on the inputs that have been used this frame.
  45776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45777. */
  45778. checkInputs(): void;
  45779. /**
  45780. * Gets the class name of the current intput.
  45781. * @returns the class name
  45782. */
  45783. getClassName(): string;
  45784. /**
  45785. * Get the friendly name associated with the input class.
  45786. * @returns the input friendly name
  45787. */
  45788. getSimpleName(): string;
  45789. }
  45790. }
  45791. declare module BABYLON {
  45792. /**
  45793. * Manage the mouse wheel inputs to control an arc rotate camera.
  45794. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45795. */
  45796. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  45797. /**
  45798. * Defines the camera the input is attached to.
  45799. */
  45800. camera: ArcRotateCamera;
  45801. /**
  45802. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  45803. */
  45804. wheelPrecision: number;
  45805. /**
  45806. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45807. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45808. */
  45809. wheelDeltaPercentage: number;
  45810. private _wheel;
  45811. private _observer;
  45812. private computeDeltaFromMouseWheelLegacyEvent;
  45813. /**
  45814. * Attach the input controls to a specific dom element to get the input from.
  45815. * @param element Defines the element the controls should be listened from
  45816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45817. */
  45818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45819. /**
  45820. * Detach the current controls from the specified dom element.
  45821. * @param element Defines the element to stop listening the inputs from
  45822. */
  45823. detachControl(element: Nullable<HTMLElement>): void;
  45824. /**
  45825. * Gets the class name of the current intput.
  45826. * @returns the class name
  45827. */
  45828. getClassName(): string;
  45829. /**
  45830. * Get the friendly name associated with the input class.
  45831. * @returns the input friendly name
  45832. */
  45833. getSimpleName(): string;
  45834. }
  45835. }
  45836. declare module BABYLON {
  45837. /**
  45838. * Default Inputs manager for the ArcRotateCamera.
  45839. * It groups all the default supported inputs for ease of use.
  45840. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45841. */
  45842. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  45843. /**
  45844. * Instantiates a new ArcRotateCameraInputsManager.
  45845. * @param camera Defines the camera the inputs belong to
  45846. */
  45847. constructor(camera: ArcRotateCamera);
  45848. /**
  45849. * Add mouse wheel input support to the input manager.
  45850. * @returns the current input manager
  45851. */
  45852. addMouseWheel(): ArcRotateCameraInputsManager;
  45853. /**
  45854. * Add pointers input support to the input manager.
  45855. * @returns the current input manager
  45856. */
  45857. addPointers(): ArcRotateCameraInputsManager;
  45858. /**
  45859. * Add keyboard input support to the input manager.
  45860. * @returns the current input manager
  45861. */
  45862. addKeyboard(): ArcRotateCameraInputsManager;
  45863. }
  45864. }
  45865. declare module BABYLON {
  45866. /**
  45867. * This represents an orbital type of camera.
  45868. *
  45869. * 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.
  45870. * 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.
  45871. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  45872. */
  45873. export class ArcRotateCamera extends TargetCamera {
  45874. /**
  45875. * Defines the rotation angle of the camera along the longitudinal axis.
  45876. */
  45877. alpha: number;
  45878. /**
  45879. * Defines the rotation angle of the camera along the latitudinal axis.
  45880. */
  45881. beta: number;
  45882. /**
  45883. * Defines the radius of the camera from it s target point.
  45884. */
  45885. radius: number;
  45886. protected _target: Vector3;
  45887. protected _targetHost: Nullable<AbstractMesh>;
  45888. /**
  45889. * Defines the target point of the camera.
  45890. * The camera looks towards it form the radius distance.
  45891. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  45892. */
  45893. get target(): Vector3;
  45894. set target(value: Vector3);
  45895. /**
  45896. * Define the current local position of the camera in the scene
  45897. */
  45898. get position(): Vector3;
  45899. set position(newPosition: Vector3);
  45900. protected _upToYMatrix: Matrix;
  45901. protected _YToUpMatrix: Matrix;
  45902. /**
  45903. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  45904. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  45905. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  45906. */
  45907. set upVector(vec: Vector3);
  45908. get upVector(): Vector3;
  45909. /**
  45910. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  45911. */
  45912. setMatUp(): void;
  45913. /**
  45914. * Current inertia value on the longitudinal axis.
  45915. * The bigger this number the longer it will take for the camera to stop.
  45916. */
  45917. inertialAlphaOffset: number;
  45918. /**
  45919. * Current inertia value on the latitudinal axis.
  45920. * The bigger this number the longer it will take for the camera to stop.
  45921. */
  45922. inertialBetaOffset: number;
  45923. /**
  45924. * Current inertia value on the radius axis.
  45925. * The bigger this number the longer it will take for the camera to stop.
  45926. */
  45927. inertialRadiusOffset: number;
  45928. /**
  45929. * Minimum allowed angle on the longitudinal axis.
  45930. * This can help limiting how the Camera is able to move in the scene.
  45931. */
  45932. lowerAlphaLimit: Nullable<number>;
  45933. /**
  45934. * Maximum allowed angle on the longitudinal axis.
  45935. * This can help limiting how the Camera is able to move in the scene.
  45936. */
  45937. upperAlphaLimit: Nullable<number>;
  45938. /**
  45939. * Minimum allowed angle on the latitudinal axis.
  45940. * This can help limiting how the Camera is able to move in the scene.
  45941. */
  45942. lowerBetaLimit: number;
  45943. /**
  45944. * Maximum allowed angle on the latitudinal axis.
  45945. * This can help limiting how the Camera is able to move in the scene.
  45946. */
  45947. upperBetaLimit: number;
  45948. /**
  45949. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  45950. * This can help limiting how the Camera is able to move in the scene.
  45951. */
  45952. lowerRadiusLimit: Nullable<number>;
  45953. /**
  45954. * Maximum allowed distance of the camera to the target (The camera can not get further).
  45955. * This can help limiting how the Camera is able to move in the scene.
  45956. */
  45957. upperRadiusLimit: Nullable<number>;
  45958. /**
  45959. * Defines the current inertia value used during panning of the camera along the X axis.
  45960. */
  45961. inertialPanningX: number;
  45962. /**
  45963. * Defines the current inertia value used during panning of the camera along the Y axis.
  45964. */
  45965. inertialPanningY: number;
  45966. /**
  45967. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  45968. * Basically if your fingers moves away from more than this distance you will be considered
  45969. * in pinch mode.
  45970. */
  45971. pinchToPanMaxDistance: number;
  45972. /**
  45973. * Defines the maximum distance the camera can pan.
  45974. * This could help keeping the cammera always in your scene.
  45975. */
  45976. panningDistanceLimit: Nullable<number>;
  45977. /**
  45978. * Defines the target of the camera before paning.
  45979. */
  45980. panningOriginTarget: Vector3;
  45981. /**
  45982. * Defines the value of the inertia used during panning.
  45983. * 0 would mean stop inertia and one would mean no decelleration at all.
  45984. */
  45985. panningInertia: number;
  45986. /**
  45987. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  45988. */
  45989. get angularSensibilityX(): number;
  45990. set angularSensibilityX(value: number);
  45991. /**
  45992. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  45993. */
  45994. get angularSensibilityY(): number;
  45995. set angularSensibilityY(value: number);
  45996. /**
  45997. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  45998. */
  45999. get pinchPrecision(): number;
  46000. set pinchPrecision(value: number);
  46001. /**
  46002. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46003. * It will be used instead of pinchDeltaPrecision if different from 0.
  46004. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46005. */
  46006. get pinchDeltaPercentage(): number;
  46007. set pinchDeltaPercentage(value: number);
  46008. /**
  46009. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46010. * and pinch delta percentage.
  46011. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46012. * that any object in the plane at the camera's target point will scale
  46013. * perfectly with finger motion.
  46014. */
  46015. get useNaturalPinchZoom(): boolean;
  46016. set useNaturalPinchZoom(value: boolean);
  46017. /**
  46018. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46019. */
  46020. get panningSensibility(): number;
  46021. set panningSensibility(value: number);
  46022. /**
  46023. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46024. */
  46025. get keysUp(): number[];
  46026. set keysUp(value: number[]);
  46027. /**
  46028. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46029. */
  46030. get keysDown(): number[];
  46031. set keysDown(value: number[]);
  46032. /**
  46033. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46034. */
  46035. get keysLeft(): number[];
  46036. set keysLeft(value: number[]);
  46037. /**
  46038. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46039. */
  46040. get keysRight(): number[];
  46041. set keysRight(value: number[]);
  46042. /**
  46043. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46044. */
  46045. get wheelPrecision(): number;
  46046. set wheelPrecision(value: number);
  46047. /**
  46048. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46049. * It will be used instead of pinchDeltaPrecision if different from 0.
  46050. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46051. */
  46052. get wheelDeltaPercentage(): number;
  46053. set wheelDeltaPercentage(value: number);
  46054. /**
  46055. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46056. */
  46057. zoomOnFactor: number;
  46058. /**
  46059. * Defines a screen offset for the camera position.
  46060. */
  46061. targetScreenOffset: Vector2;
  46062. /**
  46063. * Allows the camera to be completely reversed.
  46064. * If false the camera can not arrive upside down.
  46065. */
  46066. allowUpsideDown: boolean;
  46067. /**
  46068. * Define if double tap/click is used to restore the previously saved state of the camera.
  46069. */
  46070. useInputToRestoreState: boolean;
  46071. /** @hidden */
  46072. _viewMatrix: Matrix;
  46073. /** @hidden */
  46074. _useCtrlForPanning: boolean;
  46075. /** @hidden */
  46076. _panningMouseButton: number;
  46077. /**
  46078. * Defines the input associated to the camera.
  46079. */
  46080. inputs: ArcRotateCameraInputsManager;
  46081. /** @hidden */
  46082. _reset: () => void;
  46083. /**
  46084. * Defines the allowed panning axis.
  46085. */
  46086. panningAxis: Vector3;
  46087. protected _localDirection: Vector3;
  46088. protected _transformedDirection: Vector3;
  46089. private _bouncingBehavior;
  46090. /**
  46091. * Gets the bouncing behavior of the camera if it has been enabled.
  46092. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46093. */
  46094. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46095. /**
  46096. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46097. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46098. */
  46099. get useBouncingBehavior(): boolean;
  46100. set useBouncingBehavior(value: boolean);
  46101. private _framingBehavior;
  46102. /**
  46103. * Gets the framing behavior of the camera if it has been enabled.
  46104. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46105. */
  46106. get framingBehavior(): Nullable<FramingBehavior>;
  46107. /**
  46108. * Defines if the framing behavior of the camera is enabled on the camera.
  46109. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46110. */
  46111. get useFramingBehavior(): boolean;
  46112. set useFramingBehavior(value: boolean);
  46113. private _autoRotationBehavior;
  46114. /**
  46115. * Gets the auto rotation behavior of the camera if it has been enabled.
  46116. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46117. */
  46118. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46119. /**
  46120. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46121. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46122. */
  46123. get useAutoRotationBehavior(): boolean;
  46124. set useAutoRotationBehavior(value: boolean);
  46125. /**
  46126. * Observable triggered when the mesh target has been changed on the camera.
  46127. */
  46128. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46129. /**
  46130. * Event raised when the camera is colliding with a mesh.
  46131. */
  46132. onCollide: (collidedMesh: AbstractMesh) => void;
  46133. /**
  46134. * Defines whether the camera should check collision with the objects oh the scene.
  46135. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46136. */
  46137. checkCollisions: boolean;
  46138. /**
  46139. * Defines the collision radius of the camera.
  46140. * This simulates a sphere around the camera.
  46141. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46142. */
  46143. collisionRadius: Vector3;
  46144. protected _collider: Collider;
  46145. protected _previousPosition: Vector3;
  46146. protected _collisionVelocity: Vector3;
  46147. protected _newPosition: Vector3;
  46148. protected _previousAlpha: number;
  46149. protected _previousBeta: number;
  46150. protected _previousRadius: number;
  46151. protected _collisionTriggered: boolean;
  46152. protected _targetBoundingCenter: Nullable<Vector3>;
  46153. private _computationVector;
  46154. /**
  46155. * Instantiates a new ArcRotateCamera in a given scene
  46156. * @param name Defines the name of the camera
  46157. * @param alpha Defines the camera rotation along the logitudinal axis
  46158. * @param beta Defines the camera rotation along the latitudinal axis
  46159. * @param radius Defines the camera distance from its target
  46160. * @param target Defines the camera target
  46161. * @param scene Defines the scene the camera belongs to
  46162. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46163. */
  46164. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46165. /** @hidden */
  46166. _initCache(): void;
  46167. /** @hidden */
  46168. _updateCache(ignoreParentClass?: boolean): void;
  46169. protected _getTargetPosition(): Vector3;
  46170. private _storedAlpha;
  46171. private _storedBeta;
  46172. private _storedRadius;
  46173. private _storedTarget;
  46174. private _storedTargetScreenOffset;
  46175. /**
  46176. * Stores the current state of the camera (alpha, beta, radius and target)
  46177. * @returns the camera itself
  46178. */
  46179. storeState(): Camera;
  46180. /**
  46181. * @hidden
  46182. * Restored camera state. You must call storeState() first
  46183. */
  46184. _restoreStateValues(): boolean;
  46185. /** @hidden */
  46186. _isSynchronizedViewMatrix(): boolean;
  46187. /**
  46188. * Attached controls to the current camera.
  46189. * @param element Defines the element the controls should be listened from
  46190. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46191. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46192. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46193. */
  46194. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  46195. /**
  46196. * Detach the current controls from the camera.
  46197. * The camera will stop reacting to inputs.
  46198. * @param element Defines the element to stop listening the inputs from
  46199. */
  46200. detachControl(element: HTMLElement): void;
  46201. /** @hidden */
  46202. _checkInputs(): void;
  46203. protected _checkLimits(): void;
  46204. /**
  46205. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46206. */
  46207. rebuildAnglesAndRadius(): void;
  46208. /**
  46209. * Use a position to define the current camera related information like alpha, beta and radius
  46210. * @param position Defines the position to set the camera at
  46211. */
  46212. setPosition(position: Vector3): void;
  46213. /**
  46214. * Defines the target the camera should look at.
  46215. * This will automatically adapt alpha beta and radius to fit within the new target.
  46216. * @param target Defines the new target as a Vector or a mesh
  46217. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46218. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46219. */
  46220. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46221. /** @hidden */
  46222. _getViewMatrix(): Matrix;
  46223. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46224. /**
  46225. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46226. * @param meshes Defines the mesh to zoom on
  46227. * @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)
  46228. */
  46229. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46230. /**
  46231. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46232. * The target will be changed but the radius
  46233. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46234. * @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)
  46235. */
  46236. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46237. min: Vector3;
  46238. max: Vector3;
  46239. distance: number;
  46240. }, doNotUpdateMaxZ?: boolean): void;
  46241. /**
  46242. * @override
  46243. * Override Camera.createRigCamera
  46244. */
  46245. createRigCamera(name: string, cameraIndex: number): Camera;
  46246. /**
  46247. * @hidden
  46248. * @override
  46249. * Override Camera._updateRigCameras
  46250. */
  46251. _updateRigCameras(): void;
  46252. /**
  46253. * Destroy the camera and release the current resources hold by it.
  46254. */
  46255. dispose(): void;
  46256. /**
  46257. * Gets the current object class name.
  46258. * @return the class name
  46259. */
  46260. getClassName(): string;
  46261. }
  46262. }
  46263. declare module BABYLON {
  46264. /**
  46265. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46266. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46267. */
  46268. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46269. /**
  46270. * Gets the name of the behavior.
  46271. */
  46272. get name(): string;
  46273. private _zoomStopsAnimation;
  46274. private _idleRotationSpeed;
  46275. private _idleRotationWaitTime;
  46276. private _idleRotationSpinupTime;
  46277. /**
  46278. * Sets the flag that indicates if user zooming should stop animation.
  46279. */
  46280. set zoomStopsAnimation(flag: boolean);
  46281. /**
  46282. * Gets the flag that indicates if user zooming should stop animation.
  46283. */
  46284. get zoomStopsAnimation(): boolean;
  46285. /**
  46286. * Sets the default speed at which the camera rotates around the model.
  46287. */
  46288. set idleRotationSpeed(speed: number);
  46289. /**
  46290. * Gets the default speed at which the camera rotates around the model.
  46291. */
  46292. get idleRotationSpeed(): number;
  46293. /**
  46294. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46295. */
  46296. set idleRotationWaitTime(time: number);
  46297. /**
  46298. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46299. */
  46300. get idleRotationWaitTime(): number;
  46301. /**
  46302. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46303. */
  46304. set idleRotationSpinupTime(time: number);
  46305. /**
  46306. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46307. */
  46308. get idleRotationSpinupTime(): number;
  46309. /**
  46310. * Gets a value indicating if the camera is currently rotating because of this behavior
  46311. */
  46312. get rotationInProgress(): boolean;
  46313. private _onPrePointerObservableObserver;
  46314. private _onAfterCheckInputsObserver;
  46315. private _attachedCamera;
  46316. private _isPointerDown;
  46317. private _lastFrameTime;
  46318. private _lastInteractionTime;
  46319. private _cameraRotationSpeed;
  46320. /**
  46321. * Initializes the behavior.
  46322. */
  46323. init(): void;
  46324. /**
  46325. * Attaches the behavior to its arc rotate camera.
  46326. * @param camera Defines the camera to attach the behavior to
  46327. */
  46328. attach(camera: ArcRotateCamera): void;
  46329. /**
  46330. * Detaches the behavior from its current arc rotate camera.
  46331. */
  46332. detach(): void;
  46333. /**
  46334. * Returns true if user is scrolling.
  46335. * @return true if user is scrolling.
  46336. */
  46337. private _userIsZooming;
  46338. private _lastFrameRadius;
  46339. private _shouldAnimationStopForInteraction;
  46340. /**
  46341. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46342. */
  46343. private _applyUserInteraction;
  46344. private _userIsMoving;
  46345. }
  46346. }
  46347. declare module BABYLON {
  46348. /**
  46349. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46350. */
  46351. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46352. private ui;
  46353. /**
  46354. * The name of the behavior
  46355. */
  46356. name: string;
  46357. /**
  46358. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46359. */
  46360. distanceAwayFromFace: number;
  46361. /**
  46362. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46363. */
  46364. distanceAwayFromBottomOfFace: number;
  46365. private _faceVectors;
  46366. private _target;
  46367. private _scene;
  46368. private _onRenderObserver;
  46369. private _tmpMatrix;
  46370. private _tmpVector;
  46371. /**
  46372. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46373. * @param ui The transform node that should be attched to the mesh
  46374. */
  46375. constructor(ui: TransformNode);
  46376. /**
  46377. * Initializes the behavior
  46378. */
  46379. init(): void;
  46380. private _closestFace;
  46381. private _zeroVector;
  46382. private _lookAtTmpMatrix;
  46383. private _lookAtToRef;
  46384. /**
  46385. * Attaches the AttachToBoxBehavior to the passed in mesh
  46386. * @param target The mesh that the specified node will be attached to
  46387. */
  46388. attach(target: Mesh): void;
  46389. /**
  46390. * Detaches the behavior from the mesh
  46391. */
  46392. detach(): void;
  46393. }
  46394. }
  46395. declare module BABYLON {
  46396. /**
  46397. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46398. */
  46399. export class FadeInOutBehavior implements Behavior<Mesh> {
  46400. /**
  46401. * Time in milliseconds to delay before fading in (Default: 0)
  46402. */
  46403. delay: number;
  46404. /**
  46405. * Time in milliseconds for the mesh to fade in (Default: 300)
  46406. */
  46407. fadeInTime: number;
  46408. private _millisecondsPerFrame;
  46409. private _hovered;
  46410. private _hoverValue;
  46411. private _ownerNode;
  46412. /**
  46413. * Instatiates the FadeInOutBehavior
  46414. */
  46415. constructor();
  46416. /**
  46417. * The name of the behavior
  46418. */
  46419. get name(): string;
  46420. /**
  46421. * Initializes the behavior
  46422. */
  46423. init(): void;
  46424. /**
  46425. * Attaches the fade behavior on the passed in mesh
  46426. * @param ownerNode The mesh that will be faded in/out once attached
  46427. */
  46428. attach(ownerNode: Mesh): void;
  46429. /**
  46430. * Detaches the behavior from the mesh
  46431. */
  46432. detach(): void;
  46433. /**
  46434. * Triggers the mesh to begin fading in or out
  46435. * @param value if the object should fade in or out (true to fade in)
  46436. */
  46437. fadeIn(value: boolean): void;
  46438. private _update;
  46439. private _setAllVisibility;
  46440. }
  46441. }
  46442. declare module BABYLON {
  46443. /**
  46444. * Class containing a set of static utilities functions for managing Pivots
  46445. * @hidden
  46446. */
  46447. export class PivotTools {
  46448. private static _PivotCached;
  46449. private static _OldPivotPoint;
  46450. private static _PivotTranslation;
  46451. private static _PivotTmpVector;
  46452. private static _PivotPostMultiplyPivotMatrix;
  46453. /** @hidden */
  46454. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  46455. /** @hidden */
  46456. static _RestorePivotPoint(mesh: AbstractMesh): void;
  46457. }
  46458. }
  46459. declare module BABYLON {
  46460. /**
  46461. * Class containing static functions to help procedurally build meshes
  46462. */
  46463. export class PlaneBuilder {
  46464. /**
  46465. * Creates a plane mesh
  46466. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46467. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46468. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46470. * * 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
  46471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46472. * @param name defines the name of the mesh
  46473. * @param options defines the options used to create the mesh
  46474. * @param scene defines the hosting scene
  46475. * @returns the plane mesh
  46476. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46477. */
  46478. static CreatePlane(name: string, options: {
  46479. size?: number;
  46480. width?: number;
  46481. height?: number;
  46482. sideOrientation?: number;
  46483. frontUVs?: Vector4;
  46484. backUVs?: Vector4;
  46485. updatable?: boolean;
  46486. sourcePlane?: Plane;
  46487. }, scene?: Nullable<Scene>): Mesh;
  46488. }
  46489. }
  46490. declare module BABYLON {
  46491. /**
  46492. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  46493. */
  46494. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  46495. private static _AnyMouseID;
  46496. /**
  46497. * Abstract mesh the behavior is set on
  46498. */
  46499. attachedNode: AbstractMesh;
  46500. private _dragPlane;
  46501. private _scene;
  46502. private _pointerObserver;
  46503. private _beforeRenderObserver;
  46504. private static _planeScene;
  46505. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  46506. /**
  46507. * 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)
  46508. */
  46509. maxDragAngle: number;
  46510. /**
  46511. * @hidden
  46512. */
  46513. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  46514. /**
  46515. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46516. */
  46517. currentDraggingPointerID: number;
  46518. /**
  46519. * The last position where the pointer hit the drag plane in world space
  46520. */
  46521. lastDragPosition: Vector3;
  46522. /**
  46523. * If the behavior is currently in a dragging state
  46524. */
  46525. dragging: boolean;
  46526. /**
  46527. * 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)
  46528. */
  46529. dragDeltaRatio: number;
  46530. /**
  46531. * If the drag plane orientation should be updated during the dragging (Default: true)
  46532. */
  46533. updateDragPlane: boolean;
  46534. private _debugMode;
  46535. private _moving;
  46536. /**
  46537. * Fires each time the attached mesh is dragged with the pointer
  46538. * * delta between last drag position and current drag position in world space
  46539. * * dragDistance along the drag axis
  46540. * * dragPlaneNormal normal of the current drag plane used during the drag
  46541. * * dragPlanePoint in world space where the drag intersects the drag plane
  46542. */
  46543. onDragObservable: Observable<{
  46544. delta: Vector3;
  46545. dragPlanePoint: Vector3;
  46546. dragPlaneNormal: Vector3;
  46547. dragDistance: number;
  46548. pointerId: number;
  46549. }>;
  46550. /**
  46551. * Fires each time a drag begins (eg. mouse down on mesh)
  46552. */
  46553. onDragStartObservable: Observable<{
  46554. dragPlanePoint: Vector3;
  46555. pointerId: number;
  46556. }>;
  46557. /**
  46558. * Fires each time a drag ends (eg. mouse release after drag)
  46559. */
  46560. onDragEndObservable: Observable<{
  46561. dragPlanePoint: Vector3;
  46562. pointerId: number;
  46563. }>;
  46564. /**
  46565. * If the attached mesh should be moved when dragged
  46566. */
  46567. moveAttached: boolean;
  46568. /**
  46569. * If the drag behavior will react to drag events (Default: true)
  46570. */
  46571. enabled: boolean;
  46572. /**
  46573. * If pointer events should start and release the drag (Default: true)
  46574. */
  46575. startAndReleaseDragOnPointerEvents: boolean;
  46576. /**
  46577. * If camera controls should be detached during the drag
  46578. */
  46579. detachCameraControls: boolean;
  46580. /**
  46581. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  46582. */
  46583. useObjectOrientationForDragging: boolean;
  46584. private _options;
  46585. /**
  46586. * Gets the options used by the behavior
  46587. */
  46588. get options(): {
  46589. dragAxis?: Vector3;
  46590. dragPlaneNormal?: Vector3;
  46591. };
  46592. /**
  46593. * Sets the options used by the behavior
  46594. */
  46595. set options(options: {
  46596. dragAxis?: Vector3;
  46597. dragPlaneNormal?: Vector3;
  46598. });
  46599. /**
  46600. * Creates a pointer drag behavior that can be attached to a mesh
  46601. * @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)
  46602. */
  46603. constructor(options?: {
  46604. dragAxis?: Vector3;
  46605. dragPlaneNormal?: Vector3;
  46606. });
  46607. /**
  46608. * Predicate to determine if it is valid to move the object to a new position when it is moved
  46609. */
  46610. validateDrag: (targetPosition: Vector3) => boolean;
  46611. /**
  46612. * The name of the behavior
  46613. */
  46614. get name(): string;
  46615. /**
  46616. * Initializes the behavior
  46617. */
  46618. init(): void;
  46619. private _tmpVector;
  46620. private _alternatePickedPoint;
  46621. private _worldDragAxis;
  46622. private _targetPosition;
  46623. private _attachedElement;
  46624. /**
  46625. * Attaches the drag behavior the passed in mesh
  46626. * @param ownerNode The mesh that will be dragged around once attached
  46627. * @param predicate Predicate to use for pick filtering
  46628. */
  46629. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  46630. /**
  46631. * Force relase the drag action by code.
  46632. */
  46633. releaseDrag(): void;
  46634. private _startDragRay;
  46635. private _lastPointerRay;
  46636. /**
  46637. * Simulates the start of a pointer drag event on the behavior
  46638. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  46639. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  46640. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  46641. */
  46642. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46643. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46644. private _dragDelta;
  46645. protected _moveDrag(ray: Ray): void;
  46646. private _pickWithRayOnDragPlane;
  46647. private _pointA;
  46648. private _pointC;
  46649. private _localAxis;
  46650. private _lookAt;
  46651. private _updateDragPlanePosition;
  46652. /**
  46653. * Detaches the behavior from the mesh
  46654. */
  46655. detach(): void;
  46656. }
  46657. }
  46658. declare module BABYLON {
  46659. /**
  46660. * A behavior that when attached to a mesh will allow the mesh to be scaled
  46661. */
  46662. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  46663. private _dragBehaviorA;
  46664. private _dragBehaviorB;
  46665. private _startDistance;
  46666. private _initialScale;
  46667. private _targetScale;
  46668. private _ownerNode;
  46669. private _sceneRenderObserver;
  46670. /**
  46671. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  46672. */
  46673. constructor();
  46674. /**
  46675. * The name of the behavior
  46676. */
  46677. get name(): string;
  46678. /**
  46679. * Initializes the behavior
  46680. */
  46681. init(): void;
  46682. private _getCurrentDistance;
  46683. /**
  46684. * Attaches the scale behavior the passed in mesh
  46685. * @param ownerNode The mesh that will be scaled around once attached
  46686. */
  46687. attach(ownerNode: Mesh): void;
  46688. /**
  46689. * Detaches the behavior from the mesh
  46690. */
  46691. detach(): void;
  46692. }
  46693. }
  46694. declare module BABYLON {
  46695. /**
  46696. * 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
  46697. */
  46698. export class SixDofDragBehavior implements Behavior<Mesh> {
  46699. private static _virtualScene;
  46700. private _ownerNode;
  46701. private _sceneRenderObserver;
  46702. private _scene;
  46703. private _targetPosition;
  46704. private _virtualOriginMesh;
  46705. private _virtualDragMesh;
  46706. private _pointerObserver;
  46707. private _moving;
  46708. private _startingOrientation;
  46709. private _attachedElement;
  46710. /**
  46711. * 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)
  46712. */
  46713. private zDragFactor;
  46714. /**
  46715. * If the object should rotate to face the drag origin
  46716. */
  46717. rotateDraggedObject: boolean;
  46718. /**
  46719. * If the behavior is currently in a dragging state
  46720. */
  46721. dragging: boolean;
  46722. /**
  46723. * 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)
  46724. */
  46725. dragDeltaRatio: number;
  46726. /**
  46727. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46728. */
  46729. currentDraggingPointerID: number;
  46730. /**
  46731. * If camera controls should be detached during the drag
  46732. */
  46733. detachCameraControls: boolean;
  46734. /**
  46735. * Fires each time a drag starts
  46736. */
  46737. onDragStartObservable: Observable<{}>;
  46738. /**
  46739. * Fires each time a drag ends (eg. mouse release after drag)
  46740. */
  46741. onDragEndObservable: Observable<{}>;
  46742. /**
  46743. * 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
  46744. */
  46745. constructor();
  46746. /**
  46747. * The name of the behavior
  46748. */
  46749. get name(): string;
  46750. /**
  46751. * Initializes the behavior
  46752. */
  46753. init(): void;
  46754. /**
  46755. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  46756. */
  46757. private get _pointerCamera();
  46758. /**
  46759. * Attaches the scale behavior the passed in mesh
  46760. * @param ownerNode The mesh that will be scaled around once attached
  46761. */
  46762. attach(ownerNode: Mesh): void;
  46763. /**
  46764. * Detaches the behavior from the mesh
  46765. */
  46766. detach(): void;
  46767. }
  46768. }
  46769. declare module BABYLON {
  46770. /**
  46771. * Class used to apply inverse kinematics to bones
  46772. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  46773. */
  46774. export class BoneIKController {
  46775. private static _tmpVecs;
  46776. private static _tmpQuat;
  46777. private static _tmpMats;
  46778. /**
  46779. * Gets or sets the target mesh
  46780. */
  46781. targetMesh: AbstractMesh;
  46782. /** Gets or sets the mesh used as pole */
  46783. poleTargetMesh: AbstractMesh;
  46784. /**
  46785. * Gets or sets the bone used as pole
  46786. */
  46787. poleTargetBone: Nullable<Bone>;
  46788. /**
  46789. * Gets or sets the target position
  46790. */
  46791. targetPosition: Vector3;
  46792. /**
  46793. * Gets or sets the pole target position
  46794. */
  46795. poleTargetPosition: Vector3;
  46796. /**
  46797. * Gets or sets the pole target local offset
  46798. */
  46799. poleTargetLocalOffset: Vector3;
  46800. /**
  46801. * Gets or sets the pole angle
  46802. */
  46803. poleAngle: number;
  46804. /**
  46805. * Gets or sets the mesh associated with the controller
  46806. */
  46807. mesh: AbstractMesh;
  46808. /**
  46809. * 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)
  46810. */
  46811. slerpAmount: number;
  46812. private _bone1Quat;
  46813. private _bone1Mat;
  46814. private _bone2Ang;
  46815. private _bone1;
  46816. private _bone2;
  46817. private _bone1Length;
  46818. private _bone2Length;
  46819. private _maxAngle;
  46820. private _maxReach;
  46821. private _rightHandedSystem;
  46822. private _bendAxis;
  46823. private _slerping;
  46824. private _adjustRoll;
  46825. /**
  46826. * Gets or sets maximum allowed angle
  46827. */
  46828. get maxAngle(): number;
  46829. set maxAngle(value: number);
  46830. /**
  46831. * Creates a new BoneIKController
  46832. * @param mesh defines the mesh to control
  46833. * @param bone defines the bone to control
  46834. * @param options defines options to set up the controller
  46835. */
  46836. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  46837. targetMesh?: AbstractMesh;
  46838. poleTargetMesh?: AbstractMesh;
  46839. poleTargetBone?: Bone;
  46840. poleTargetLocalOffset?: Vector3;
  46841. poleAngle?: number;
  46842. bendAxis?: Vector3;
  46843. maxAngle?: number;
  46844. slerpAmount?: number;
  46845. });
  46846. private _setMaxAngle;
  46847. /**
  46848. * Force the controller to update the bones
  46849. */
  46850. update(): void;
  46851. }
  46852. }
  46853. declare module BABYLON {
  46854. /**
  46855. * Class used to make a bone look toward a point in space
  46856. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  46857. */
  46858. export class BoneLookController {
  46859. private static _tmpVecs;
  46860. private static _tmpQuat;
  46861. private static _tmpMats;
  46862. /**
  46863. * The target Vector3 that the bone will look at
  46864. */
  46865. target: Vector3;
  46866. /**
  46867. * The mesh that the bone is attached to
  46868. */
  46869. mesh: AbstractMesh;
  46870. /**
  46871. * The bone that will be looking to the target
  46872. */
  46873. bone: Bone;
  46874. /**
  46875. * The up axis of the coordinate system that is used when the bone is rotated
  46876. */
  46877. upAxis: Vector3;
  46878. /**
  46879. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  46880. */
  46881. upAxisSpace: Space;
  46882. /**
  46883. * Used to make an adjustment to the yaw of the bone
  46884. */
  46885. adjustYaw: number;
  46886. /**
  46887. * Used to make an adjustment to the pitch of the bone
  46888. */
  46889. adjustPitch: number;
  46890. /**
  46891. * Used to make an adjustment to the roll of the bone
  46892. */
  46893. adjustRoll: number;
  46894. /**
  46895. * 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)
  46896. */
  46897. slerpAmount: number;
  46898. private _minYaw;
  46899. private _maxYaw;
  46900. private _minPitch;
  46901. private _maxPitch;
  46902. private _minYawSin;
  46903. private _minYawCos;
  46904. private _maxYawSin;
  46905. private _maxYawCos;
  46906. private _midYawConstraint;
  46907. private _minPitchTan;
  46908. private _maxPitchTan;
  46909. private _boneQuat;
  46910. private _slerping;
  46911. private _transformYawPitch;
  46912. private _transformYawPitchInv;
  46913. private _firstFrameSkipped;
  46914. private _yawRange;
  46915. private _fowardAxis;
  46916. /**
  46917. * Gets or sets the minimum yaw angle that the bone can look to
  46918. */
  46919. get minYaw(): number;
  46920. set minYaw(value: number);
  46921. /**
  46922. * Gets or sets the maximum yaw angle that the bone can look to
  46923. */
  46924. get maxYaw(): number;
  46925. set maxYaw(value: number);
  46926. /**
  46927. * Gets or sets the minimum pitch angle that the bone can look to
  46928. */
  46929. get minPitch(): number;
  46930. set minPitch(value: number);
  46931. /**
  46932. * Gets or sets the maximum pitch angle that the bone can look to
  46933. */
  46934. get maxPitch(): number;
  46935. set maxPitch(value: number);
  46936. /**
  46937. * Create a BoneLookController
  46938. * @param mesh the mesh that the bone belongs to
  46939. * @param bone the bone that will be looking to the target
  46940. * @param target the target Vector3 to look at
  46941. * @param options optional settings:
  46942. * * maxYaw: the maximum angle the bone will yaw to
  46943. * * minYaw: the minimum angle the bone will yaw to
  46944. * * maxPitch: the maximum angle the bone will pitch to
  46945. * * minPitch: the minimum angle the bone will yaw to
  46946. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  46947. * * upAxis: the up axis of the coordinate system
  46948. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  46949. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  46950. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  46951. * * adjustYaw: used to make an adjustment to the yaw of the bone
  46952. * * adjustPitch: used to make an adjustment to the pitch of the bone
  46953. * * adjustRoll: used to make an adjustment to the roll of the bone
  46954. **/
  46955. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  46956. maxYaw?: number;
  46957. minYaw?: number;
  46958. maxPitch?: number;
  46959. minPitch?: number;
  46960. slerpAmount?: number;
  46961. upAxis?: Vector3;
  46962. upAxisSpace?: Space;
  46963. yawAxis?: Vector3;
  46964. pitchAxis?: Vector3;
  46965. adjustYaw?: number;
  46966. adjustPitch?: number;
  46967. adjustRoll?: number;
  46968. });
  46969. /**
  46970. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  46971. */
  46972. update(): void;
  46973. private _getAngleDiff;
  46974. private _getAngleBetween;
  46975. private _isAngleBetween;
  46976. }
  46977. }
  46978. declare module BABYLON {
  46979. /**
  46980. * Manage the gamepad inputs to control an arc rotate camera.
  46981. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46982. */
  46983. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  46984. /**
  46985. * Defines the camera the input is attached to.
  46986. */
  46987. camera: ArcRotateCamera;
  46988. /**
  46989. * Defines the gamepad the input is gathering event from.
  46990. */
  46991. gamepad: Nullable<Gamepad>;
  46992. /**
  46993. * Defines the gamepad rotation sensiblity.
  46994. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46995. */
  46996. gamepadRotationSensibility: number;
  46997. /**
  46998. * Defines the gamepad move sensiblity.
  46999. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47000. */
  47001. gamepadMoveSensibility: number;
  47002. private _yAxisScale;
  47003. /**
  47004. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47005. */
  47006. get invertYAxis(): boolean;
  47007. set invertYAxis(value: boolean);
  47008. private _onGamepadConnectedObserver;
  47009. private _onGamepadDisconnectedObserver;
  47010. /**
  47011. * Attach the input controls to a specific dom element to get the input from.
  47012. * @param element Defines the element the controls should be listened from
  47013. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47014. */
  47015. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47016. /**
  47017. * Detach the current controls from the specified dom element.
  47018. * @param element Defines the element to stop listening the inputs from
  47019. */
  47020. detachControl(element: Nullable<HTMLElement>): void;
  47021. /**
  47022. * Update the current camera state depending on the inputs that have been used this frame.
  47023. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47024. */
  47025. checkInputs(): void;
  47026. /**
  47027. * Gets the class name of the current intput.
  47028. * @returns the class name
  47029. */
  47030. getClassName(): string;
  47031. /**
  47032. * Get the friendly name associated with the input class.
  47033. * @returns the input friendly name
  47034. */
  47035. getSimpleName(): string;
  47036. }
  47037. }
  47038. declare module BABYLON {
  47039. interface ArcRotateCameraInputsManager {
  47040. /**
  47041. * Add orientation input support to the input manager.
  47042. * @returns the current input manager
  47043. */
  47044. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47045. }
  47046. /**
  47047. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47048. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47049. */
  47050. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47051. /**
  47052. * Defines the camera the input is attached to.
  47053. */
  47054. camera: ArcRotateCamera;
  47055. /**
  47056. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47057. */
  47058. alphaCorrection: number;
  47059. /**
  47060. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47061. */
  47062. gammaCorrection: number;
  47063. private _alpha;
  47064. private _gamma;
  47065. private _dirty;
  47066. private _deviceOrientationHandler;
  47067. /**
  47068. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47069. */
  47070. constructor();
  47071. /**
  47072. * Attach the input controls to a specific dom element to get the input from.
  47073. * @param element Defines the element the controls should be listened from
  47074. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47075. */
  47076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47077. /** @hidden */
  47078. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47079. /**
  47080. * Update the current camera state depending on the inputs that have been used this frame.
  47081. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47082. */
  47083. checkInputs(): void;
  47084. /**
  47085. * Detach the current controls from the specified dom element.
  47086. * @param element Defines the element to stop listening the inputs from
  47087. */
  47088. detachControl(element: Nullable<HTMLElement>): void;
  47089. /**
  47090. * Gets the class name of the current intput.
  47091. * @returns the class name
  47092. */
  47093. getClassName(): string;
  47094. /**
  47095. * Get the friendly name associated with the input class.
  47096. * @returns the input friendly name
  47097. */
  47098. getSimpleName(): string;
  47099. }
  47100. }
  47101. declare module BABYLON {
  47102. /**
  47103. * Listen to mouse events to control the camera.
  47104. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47105. */
  47106. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47107. /**
  47108. * Defines the camera the input is attached to.
  47109. */
  47110. camera: FlyCamera;
  47111. /**
  47112. * Defines if touch is enabled. (Default is true.)
  47113. */
  47114. touchEnabled: boolean;
  47115. /**
  47116. * Defines the buttons associated with the input to handle camera rotation.
  47117. */
  47118. buttons: number[];
  47119. /**
  47120. * Assign buttons for Yaw control.
  47121. */
  47122. buttonsYaw: number[];
  47123. /**
  47124. * Assign buttons for Pitch control.
  47125. */
  47126. buttonsPitch: number[];
  47127. /**
  47128. * Assign buttons for Roll control.
  47129. */
  47130. buttonsRoll: number[];
  47131. /**
  47132. * Detect if any button is being pressed while mouse is moved.
  47133. * -1 = Mouse locked.
  47134. * 0 = Left button.
  47135. * 1 = Middle Button.
  47136. * 2 = Right Button.
  47137. */
  47138. activeButton: number;
  47139. /**
  47140. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47141. * Higher values reduce its sensitivity.
  47142. */
  47143. angularSensibility: number;
  47144. private _observer;
  47145. private _rollObserver;
  47146. private previousPosition;
  47147. private noPreventDefault;
  47148. private element;
  47149. /**
  47150. * Listen to mouse events to control the camera.
  47151. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47152. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47153. */
  47154. constructor(touchEnabled?: boolean);
  47155. /**
  47156. * Attach the mouse control to the HTML DOM element.
  47157. * @param element Defines the element that listens to the input events.
  47158. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47159. */
  47160. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47161. /**
  47162. * Detach the current controls from the specified dom element.
  47163. * @param element Defines the element to stop listening the inputs from
  47164. */
  47165. detachControl(element: Nullable<HTMLElement>): void;
  47166. /**
  47167. * Gets the class name of the current input.
  47168. * @returns the class name.
  47169. */
  47170. getClassName(): string;
  47171. /**
  47172. * Get the friendly name associated with the input class.
  47173. * @returns the input's friendly name.
  47174. */
  47175. getSimpleName(): string;
  47176. private _pointerInput;
  47177. private _onMouseMove;
  47178. /**
  47179. * Rotate camera by mouse offset.
  47180. */
  47181. private rotateCamera;
  47182. }
  47183. }
  47184. declare module BABYLON {
  47185. /**
  47186. * Default Inputs manager for the FlyCamera.
  47187. * It groups all the default supported inputs for ease of use.
  47188. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47189. */
  47190. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47191. /**
  47192. * Instantiates a new FlyCameraInputsManager.
  47193. * @param camera Defines the camera the inputs belong to.
  47194. */
  47195. constructor(camera: FlyCamera);
  47196. /**
  47197. * Add keyboard input support to the input manager.
  47198. * @returns the new FlyCameraKeyboardMoveInput().
  47199. */
  47200. addKeyboard(): FlyCameraInputsManager;
  47201. /**
  47202. * Add mouse input support to the input manager.
  47203. * @param touchEnabled Enable touch screen support.
  47204. * @returns the new FlyCameraMouseInput().
  47205. */
  47206. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47207. }
  47208. }
  47209. declare module BABYLON {
  47210. /**
  47211. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47212. * such as in a 3D Space Shooter or a Flight Simulator.
  47213. */
  47214. export class FlyCamera extends TargetCamera {
  47215. /**
  47216. * Define the collision ellipsoid of the camera.
  47217. * This is helpful for simulating a camera body, like a player's body.
  47218. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47219. */
  47220. ellipsoid: Vector3;
  47221. /**
  47222. * Define an offset for the position of the ellipsoid around the camera.
  47223. * This can be helpful if the camera is attached away from the player's body center,
  47224. * such as at its head.
  47225. */
  47226. ellipsoidOffset: Vector3;
  47227. /**
  47228. * Enable or disable collisions of the camera with the rest of the scene objects.
  47229. */
  47230. checkCollisions: boolean;
  47231. /**
  47232. * Enable or disable gravity on the camera.
  47233. */
  47234. applyGravity: boolean;
  47235. /**
  47236. * Define the current direction the camera is moving to.
  47237. */
  47238. cameraDirection: Vector3;
  47239. /**
  47240. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47241. * This overrides and empties cameraRotation.
  47242. */
  47243. rotationQuaternion: Quaternion;
  47244. /**
  47245. * Track Roll to maintain the wanted Rolling when looking around.
  47246. */
  47247. _trackRoll: number;
  47248. /**
  47249. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47250. */
  47251. rollCorrect: number;
  47252. /**
  47253. * Mimic a banked turn, Rolling the camera when Yawing.
  47254. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47255. */
  47256. bankedTurn: boolean;
  47257. /**
  47258. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47259. */
  47260. bankedTurnLimit: number;
  47261. /**
  47262. * Value of 0 disables the banked Roll.
  47263. * Value of 1 is equal to the Yaw angle in radians.
  47264. */
  47265. bankedTurnMultiplier: number;
  47266. /**
  47267. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47268. */
  47269. inputs: FlyCameraInputsManager;
  47270. /**
  47271. * Gets the input sensibility for mouse input.
  47272. * Higher values reduce sensitivity.
  47273. */
  47274. get angularSensibility(): number;
  47275. /**
  47276. * Sets the input sensibility for a mouse input.
  47277. * Higher values reduce sensitivity.
  47278. */
  47279. set angularSensibility(value: number);
  47280. /**
  47281. * Get the keys for camera movement forward.
  47282. */
  47283. get keysForward(): number[];
  47284. /**
  47285. * Set the keys for camera movement forward.
  47286. */
  47287. set keysForward(value: number[]);
  47288. /**
  47289. * Get the keys for camera movement backward.
  47290. */
  47291. get keysBackward(): number[];
  47292. set keysBackward(value: number[]);
  47293. /**
  47294. * Get the keys for camera movement up.
  47295. */
  47296. get keysUp(): number[];
  47297. /**
  47298. * Set the keys for camera movement up.
  47299. */
  47300. set keysUp(value: number[]);
  47301. /**
  47302. * Get the keys for camera movement down.
  47303. */
  47304. get keysDown(): number[];
  47305. /**
  47306. * Set the keys for camera movement down.
  47307. */
  47308. set keysDown(value: number[]);
  47309. /**
  47310. * Get the keys for camera movement left.
  47311. */
  47312. get keysLeft(): number[];
  47313. /**
  47314. * Set the keys for camera movement left.
  47315. */
  47316. set keysLeft(value: number[]);
  47317. /**
  47318. * Set the keys for camera movement right.
  47319. */
  47320. get keysRight(): number[];
  47321. /**
  47322. * Set the keys for camera movement right.
  47323. */
  47324. set keysRight(value: number[]);
  47325. /**
  47326. * Event raised when the camera collides with a mesh in the scene.
  47327. */
  47328. onCollide: (collidedMesh: AbstractMesh) => void;
  47329. private _collider;
  47330. private _needMoveForGravity;
  47331. private _oldPosition;
  47332. private _diffPosition;
  47333. private _newPosition;
  47334. /** @hidden */
  47335. _localDirection: Vector3;
  47336. /** @hidden */
  47337. _transformedDirection: Vector3;
  47338. /**
  47339. * Instantiates a FlyCamera.
  47340. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47341. * such as in a 3D Space Shooter or a Flight Simulator.
  47342. * @param name Define the name of the camera in the scene.
  47343. * @param position Define the starting position of the camera in the scene.
  47344. * @param scene Define the scene the camera belongs to.
  47345. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47346. */
  47347. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47348. /**
  47349. * Attach a control to the HTML DOM element.
  47350. * @param element Defines the element that listens to the input events.
  47351. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  47352. */
  47353. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47354. /**
  47355. * Detach a control from the HTML DOM element.
  47356. * The camera will stop reacting to that input.
  47357. * @param element Defines the element that listens to the input events.
  47358. */
  47359. detachControl(element: HTMLElement): void;
  47360. private _collisionMask;
  47361. /**
  47362. * Get the mask that the camera ignores in collision events.
  47363. */
  47364. get collisionMask(): number;
  47365. /**
  47366. * Set the mask that the camera ignores in collision events.
  47367. */
  47368. set collisionMask(mask: number);
  47369. /** @hidden */
  47370. _collideWithWorld(displacement: Vector3): void;
  47371. /** @hidden */
  47372. private _onCollisionPositionChange;
  47373. /** @hidden */
  47374. _checkInputs(): void;
  47375. /** @hidden */
  47376. _decideIfNeedsToMove(): boolean;
  47377. /** @hidden */
  47378. _updatePosition(): void;
  47379. /**
  47380. * Restore the Roll to its target value at the rate specified.
  47381. * @param rate - Higher means slower restoring.
  47382. * @hidden
  47383. */
  47384. restoreRoll(rate: number): void;
  47385. /**
  47386. * Destroy the camera and release the current resources held by it.
  47387. */
  47388. dispose(): void;
  47389. /**
  47390. * Get the current object class name.
  47391. * @returns the class name.
  47392. */
  47393. getClassName(): string;
  47394. }
  47395. }
  47396. declare module BABYLON {
  47397. /**
  47398. * Listen to keyboard events to control the camera.
  47399. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47400. */
  47401. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47402. /**
  47403. * Defines the camera the input is attached to.
  47404. */
  47405. camera: FlyCamera;
  47406. /**
  47407. * The list of keyboard keys used to control the forward move of the camera.
  47408. */
  47409. keysForward: number[];
  47410. /**
  47411. * The list of keyboard keys used to control the backward move of the camera.
  47412. */
  47413. keysBackward: number[];
  47414. /**
  47415. * The list of keyboard keys used to control the forward move of the camera.
  47416. */
  47417. keysUp: number[];
  47418. /**
  47419. * The list of keyboard keys used to control the backward move of the camera.
  47420. */
  47421. keysDown: number[];
  47422. /**
  47423. * The list of keyboard keys used to control the right strafe move of the camera.
  47424. */
  47425. keysRight: number[];
  47426. /**
  47427. * The list of keyboard keys used to control the left strafe move of the camera.
  47428. */
  47429. keysLeft: number[];
  47430. private _keys;
  47431. private _onCanvasBlurObserver;
  47432. private _onKeyboardObserver;
  47433. private _engine;
  47434. private _scene;
  47435. /**
  47436. * Attach the input controls to a specific dom element to get the input from.
  47437. * @param element Defines the element the controls should be listened from
  47438. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47439. */
  47440. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47441. /**
  47442. * Detach the current controls from the specified dom element.
  47443. * @param element Defines the element to stop listening the inputs from
  47444. */
  47445. detachControl(element: Nullable<HTMLElement>): void;
  47446. /**
  47447. * Gets the class name of the current intput.
  47448. * @returns the class name
  47449. */
  47450. getClassName(): string;
  47451. /** @hidden */
  47452. _onLostFocus(e: FocusEvent): void;
  47453. /**
  47454. * Get the friendly name associated with the input class.
  47455. * @returns the input friendly name
  47456. */
  47457. getSimpleName(): string;
  47458. /**
  47459. * Update the current camera state depending on the inputs that have been used this frame.
  47460. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47461. */
  47462. checkInputs(): void;
  47463. }
  47464. }
  47465. declare module BABYLON {
  47466. /**
  47467. * Manage the mouse wheel inputs to control a follow camera.
  47468. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47469. */
  47470. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  47471. /**
  47472. * Defines the camera the input is attached to.
  47473. */
  47474. camera: FollowCamera;
  47475. /**
  47476. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  47477. */
  47478. axisControlRadius: boolean;
  47479. /**
  47480. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  47481. */
  47482. axisControlHeight: boolean;
  47483. /**
  47484. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  47485. */
  47486. axisControlRotation: boolean;
  47487. /**
  47488. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  47489. * relation to mouseWheel events.
  47490. */
  47491. wheelPrecision: number;
  47492. /**
  47493. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47494. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47495. */
  47496. wheelDeltaPercentage: number;
  47497. private _wheel;
  47498. private _observer;
  47499. /**
  47500. * Attach the input controls to a specific dom element to get the input from.
  47501. * @param element Defines the element the controls should be listened from
  47502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47503. */
  47504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47505. /**
  47506. * Detach the current controls from the specified dom element.
  47507. * @param element Defines the element to stop listening the inputs from
  47508. */
  47509. detachControl(element: Nullable<HTMLElement>): void;
  47510. /**
  47511. * Gets the class name of the current intput.
  47512. * @returns the class name
  47513. */
  47514. getClassName(): string;
  47515. /**
  47516. * Get the friendly name associated with the input class.
  47517. * @returns the input friendly name
  47518. */
  47519. getSimpleName(): string;
  47520. }
  47521. }
  47522. declare module BABYLON {
  47523. /**
  47524. * Manage the pointers inputs to control an follow camera.
  47525. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47526. */
  47527. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  47528. /**
  47529. * Defines the camera the input is attached to.
  47530. */
  47531. camera: FollowCamera;
  47532. /**
  47533. * Gets the class name of the current input.
  47534. * @returns the class name
  47535. */
  47536. getClassName(): string;
  47537. /**
  47538. * Defines the pointer angular sensibility along the X axis or how fast is
  47539. * the camera rotating.
  47540. * A negative number will reverse the axis direction.
  47541. */
  47542. angularSensibilityX: number;
  47543. /**
  47544. * Defines the pointer angular sensibility along the Y axis or how fast is
  47545. * the camera rotating.
  47546. * A negative number will reverse the axis direction.
  47547. */
  47548. angularSensibilityY: number;
  47549. /**
  47550. * Defines the pointer pinch precision or how fast is the camera zooming.
  47551. * A negative number will reverse the axis direction.
  47552. */
  47553. pinchPrecision: number;
  47554. /**
  47555. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47556. * from 0.
  47557. * It defines the percentage of current camera.radius to use as delta when
  47558. * pinch zoom is used.
  47559. */
  47560. pinchDeltaPercentage: number;
  47561. /**
  47562. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  47563. */
  47564. axisXControlRadius: boolean;
  47565. /**
  47566. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  47567. */
  47568. axisXControlHeight: boolean;
  47569. /**
  47570. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  47571. */
  47572. axisXControlRotation: boolean;
  47573. /**
  47574. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  47575. */
  47576. axisYControlRadius: boolean;
  47577. /**
  47578. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  47579. */
  47580. axisYControlHeight: boolean;
  47581. /**
  47582. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  47583. */
  47584. axisYControlRotation: boolean;
  47585. /**
  47586. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  47587. */
  47588. axisPinchControlRadius: boolean;
  47589. /**
  47590. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  47591. */
  47592. axisPinchControlHeight: boolean;
  47593. /**
  47594. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  47595. */
  47596. axisPinchControlRotation: boolean;
  47597. /**
  47598. * Log error messages if basic misconfiguration has occurred.
  47599. */
  47600. warningEnable: boolean;
  47601. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47602. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47603. private _warningCounter;
  47604. private _warning;
  47605. }
  47606. }
  47607. declare module BABYLON {
  47608. /**
  47609. * Default Inputs manager for the FollowCamera.
  47610. * It groups all the default supported inputs for ease of use.
  47611. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47612. */
  47613. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  47614. /**
  47615. * Instantiates a new FollowCameraInputsManager.
  47616. * @param camera Defines the camera the inputs belong to
  47617. */
  47618. constructor(camera: FollowCamera);
  47619. /**
  47620. * Add keyboard input support to the input manager.
  47621. * @returns the current input manager
  47622. */
  47623. addKeyboard(): FollowCameraInputsManager;
  47624. /**
  47625. * Add mouse wheel input support to the input manager.
  47626. * @returns the current input manager
  47627. */
  47628. addMouseWheel(): FollowCameraInputsManager;
  47629. /**
  47630. * Add pointers input support to the input manager.
  47631. * @returns the current input manager
  47632. */
  47633. addPointers(): FollowCameraInputsManager;
  47634. /**
  47635. * Add orientation input support to the input manager.
  47636. * @returns the current input manager
  47637. */
  47638. addVRDeviceOrientation(): FollowCameraInputsManager;
  47639. }
  47640. }
  47641. declare module BABYLON {
  47642. /**
  47643. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  47644. * an arc rotate version arcFollowCamera are available.
  47645. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47646. */
  47647. export class FollowCamera extends TargetCamera {
  47648. /**
  47649. * Distance the follow camera should follow an object at
  47650. */
  47651. radius: number;
  47652. /**
  47653. * Minimum allowed distance of the camera to the axis of rotation
  47654. * (The camera can not get closer).
  47655. * This can help limiting how the Camera is able to move in the scene.
  47656. */
  47657. lowerRadiusLimit: Nullable<number>;
  47658. /**
  47659. * Maximum allowed distance of the camera to the axis of rotation
  47660. * (The camera can not get further).
  47661. * This can help limiting how the Camera is able to move in the scene.
  47662. */
  47663. upperRadiusLimit: Nullable<number>;
  47664. /**
  47665. * Define a rotation offset between the camera and the object it follows
  47666. */
  47667. rotationOffset: number;
  47668. /**
  47669. * Minimum allowed angle to camera position relative to target object.
  47670. * This can help limiting how the Camera is able to move in the scene.
  47671. */
  47672. lowerRotationOffsetLimit: Nullable<number>;
  47673. /**
  47674. * Maximum allowed angle to camera position relative to target object.
  47675. * This can help limiting how the Camera is able to move in the scene.
  47676. */
  47677. upperRotationOffsetLimit: Nullable<number>;
  47678. /**
  47679. * Define a height offset between the camera and the object it follows.
  47680. * It can help following an object from the top (like a car chaing a plane)
  47681. */
  47682. heightOffset: number;
  47683. /**
  47684. * Minimum allowed height of camera position relative to target object.
  47685. * This can help limiting how the Camera is able to move in the scene.
  47686. */
  47687. lowerHeightOffsetLimit: Nullable<number>;
  47688. /**
  47689. * Maximum allowed height of camera position relative to target object.
  47690. * This can help limiting how the Camera is able to move in the scene.
  47691. */
  47692. upperHeightOffsetLimit: Nullable<number>;
  47693. /**
  47694. * Define how fast the camera can accelerate to follow it s target.
  47695. */
  47696. cameraAcceleration: number;
  47697. /**
  47698. * Define the speed limit of the camera following an object.
  47699. */
  47700. maxCameraSpeed: number;
  47701. /**
  47702. * Define the target of the camera.
  47703. */
  47704. lockedTarget: Nullable<AbstractMesh>;
  47705. /**
  47706. * Defines the input associated with the camera.
  47707. */
  47708. inputs: FollowCameraInputsManager;
  47709. /**
  47710. * Instantiates the follow camera.
  47711. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47712. * @param name Define the name of the camera in the scene
  47713. * @param position Define the position of the camera
  47714. * @param scene Define the scene the camera belong to
  47715. * @param lockedTarget Define the target of the camera
  47716. */
  47717. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  47718. private _follow;
  47719. /**
  47720. * Attached controls to the current camera.
  47721. * @param element Defines the element the controls should be listened from
  47722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47723. */
  47724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47725. /**
  47726. * Detach the current controls from the camera.
  47727. * The camera will stop reacting to inputs.
  47728. * @param element Defines the element to stop listening the inputs from
  47729. */
  47730. detachControl(element: HTMLElement): void;
  47731. /** @hidden */
  47732. _checkInputs(): void;
  47733. private _checkLimits;
  47734. /**
  47735. * Gets the camera class name.
  47736. * @returns the class name
  47737. */
  47738. getClassName(): string;
  47739. }
  47740. /**
  47741. * Arc Rotate version of the follow camera.
  47742. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  47743. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47744. */
  47745. export class ArcFollowCamera extends TargetCamera {
  47746. /** The longitudinal angle of the camera */
  47747. alpha: number;
  47748. /** The latitudinal angle of the camera */
  47749. beta: number;
  47750. /** The radius of the camera from its target */
  47751. radius: number;
  47752. private _cartesianCoordinates;
  47753. /** Define the camera target (the mesh it should follow) */
  47754. private _meshTarget;
  47755. /**
  47756. * Instantiates a new ArcFollowCamera
  47757. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47758. * @param name Define the name of the camera
  47759. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  47760. * @param beta Define the rotation angle of the camera around the elevation axis
  47761. * @param radius Define the radius of the camera from its target point
  47762. * @param target Define the target of the camera
  47763. * @param scene Define the scene the camera belongs to
  47764. */
  47765. constructor(name: string,
  47766. /** The longitudinal angle of the camera */
  47767. alpha: number,
  47768. /** The latitudinal angle of the camera */
  47769. beta: number,
  47770. /** The radius of the camera from its target */
  47771. radius: number,
  47772. /** Define the camera target (the mesh it should follow) */
  47773. target: Nullable<AbstractMesh>, scene: Scene);
  47774. private _follow;
  47775. /** @hidden */
  47776. _checkInputs(): void;
  47777. /**
  47778. * Returns the class name of the object.
  47779. * It is mostly used internally for serialization purposes.
  47780. */
  47781. getClassName(): string;
  47782. }
  47783. }
  47784. declare module BABYLON {
  47785. /**
  47786. * Manage the keyboard inputs to control the movement of a follow camera.
  47787. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47788. */
  47789. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  47790. /**
  47791. * Defines the camera the input is attached to.
  47792. */
  47793. camera: FollowCamera;
  47794. /**
  47795. * Defines the list of key codes associated with the up action (increase heightOffset)
  47796. */
  47797. keysHeightOffsetIncr: number[];
  47798. /**
  47799. * Defines the list of key codes associated with the down action (decrease heightOffset)
  47800. */
  47801. keysHeightOffsetDecr: number[];
  47802. /**
  47803. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  47804. */
  47805. keysHeightOffsetModifierAlt: boolean;
  47806. /**
  47807. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  47808. */
  47809. keysHeightOffsetModifierCtrl: boolean;
  47810. /**
  47811. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  47812. */
  47813. keysHeightOffsetModifierShift: boolean;
  47814. /**
  47815. * Defines the list of key codes associated with the left action (increase rotationOffset)
  47816. */
  47817. keysRotationOffsetIncr: number[];
  47818. /**
  47819. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  47820. */
  47821. keysRotationOffsetDecr: number[];
  47822. /**
  47823. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  47824. */
  47825. keysRotationOffsetModifierAlt: boolean;
  47826. /**
  47827. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  47828. */
  47829. keysRotationOffsetModifierCtrl: boolean;
  47830. /**
  47831. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  47832. */
  47833. keysRotationOffsetModifierShift: boolean;
  47834. /**
  47835. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  47836. */
  47837. keysRadiusIncr: number[];
  47838. /**
  47839. * Defines the list of key codes associated with the zoom-out action (increase radius)
  47840. */
  47841. keysRadiusDecr: number[];
  47842. /**
  47843. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  47844. */
  47845. keysRadiusModifierAlt: boolean;
  47846. /**
  47847. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  47848. */
  47849. keysRadiusModifierCtrl: boolean;
  47850. /**
  47851. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  47852. */
  47853. keysRadiusModifierShift: boolean;
  47854. /**
  47855. * Defines the rate of change of heightOffset.
  47856. */
  47857. heightSensibility: number;
  47858. /**
  47859. * Defines the rate of change of rotationOffset.
  47860. */
  47861. rotationSensibility: number;
  47862. /**
  47863. * Defines the rate of change of radius.
  47864. */
  47865. radiusSensibility: number;
  47866. private _keys;
  47867. private _ctrlPressed;
  47868. private _altPressed;
  47869. private _shiftPressed;
  47870. private _onCanvasBlurObserver;
  47871. private _onKeyboardObserver;
  47872. private _engine;
  47873. private _scene;
  47874. /**
  47875. * Attach the input controls to a specific dom element to get the input from.
  47876. * @param element Defines the element the controls should be listened from
  47877. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47878. */
  47879. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47880. /**
  47881. * Detach the current controls from the specified dom element.
  47882. * @param element Defines the element to stop listening the inputs from
  47883. */
  47884. detachControl(element: Nullable<HTMLElement>): void;
  47885. /**
  47886. * Update the current camera state depending on the inputs that have been used this frame.
  47887. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47888. */
  47889. checkInputs(): void;
  47890. /**
  47891. * Gets the class name of the current input.
  47892. * @returns the class name
  47893. */
  47894. getClassName(): string;
  47895. /**
  47896. * Get the friendly name associated with the input class.
  47897. * @returns the input friendly name
  47898. */
  47899. getSimpleName(): string;
  47900. /**
  47901. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47902. * allow modification of the heightOffset value.
  47903. */
  47904. private _modifierHeightOffset;
  47905. /**
  47906. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47907. * allow modification of the rotationOffset value.
  47908. */
  47909. private _modifierRotationOffset;
  47910. /**
  47911. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47912. * allow modification of the radius value.
  47913. */
  47914. private _modifierRadius;
  47915. }
  47916. }
  47917. declare module BABYLON {
  47918. interface FreeCameraInputsManager {
  47919. /**
  47920. * @hidden
  47921. */
  47922. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  47923. /**
  47924. * Add orientation input support to the input manager.
  47925. * @returns the current input manager
  47926. */
  47927. addDeviceOrientation(): FreeCameraInputsManager;
  47928. }
  47929. /**
  47930. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  47931. * Screen rotation is taken into account.
  47932. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47933. */
  47934. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  47935. private _camera;
  47936. private _screenOrientationAngle;
  47937. private _constantTranform;
  47938. private _screenQuaternion;
  47939. private _alpha;
  47940. private _beta;
  47941. private _gamma;
  47942. /**
  47943. * Can be used to detect if a device orientation sensor is available on a device
  47944. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  47945. * @returns a promise that will resolve on orientation change
  47946. */
  47947. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  47948. /**
  47949. * @hidden
  47950. */
  47951. _onDeviceOrientationChangedObservable: Observable<void>;
  47952. /**
  47953. * Instantiates a new input
  47954. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47955. */
  47956. constructor();
  47957. /**
  47958. * Define the camera controlled by the input.
  47959. */
  47960. get camera(): FreeCamera;
  47961. set camera(camera: FreeCamera);
  47962. /**
  47963. * Attach the input controls to a specific dom element to get the input from.
  47964. * @param element Defines the element the controls should be listened from
  47965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47966. */
  47967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47968. private _orientationChanged;
  47969. private _deviceOrientation;
  47970. /**
  47971. * Detach the current controls from the specified dom element.
  47972. * @param element Defines the element to stop listening the inputs from
  47973. */
  47974. detachControl(element: Nullable<HTMLElement>): void;
  47975. /**
  47976. * Update the current camera state depending on the inputs that have been used this frame.
  47977. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47978. */
  47979. checkInputs(): void;
  47980. /**
  47981. * Gets the class name of the current intput.
  47982. * @returns the class name
  47983. */
  47984. getClassName(): string;
  47985. /**
  47986. * Get the friendly name associated with the input class.
  47987. * @returns the input friendly name
  47988. */
  47989. getSimpleName(): string;
  47990. }
  47991. }
  47992. declare module BABYLON {
  47993. /**
  47994. * Manage the gamepad inputs to control a free camera.
  47995. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47996. */
  47997. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  47998. /**
  47999. * Define the camera the input is attached to.
  48000. */
  48001. camera: FreeCamera;
  48002. /**
  48003. * Define the Gamepad controlling the input
  48004. */
  48005. gamepad: Nullable<Gamepad>;
  48006. /**
  48007. * Defines the gamepad rotation sensiblity.
  48008. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48009. */
  48010. gamepadAngularSensibility: number;
  48011. /**
  48012. * Defines the gamepad move sensiblity.
  48013. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48014. */
  48015. gamepadMoveSensibility: number;
  48016. private _yAxisScale;
  48017. /**
  48018. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48019. */
  48020. get invertYAxis(): boolean;
  48021. set invertYAxis(value: boolean);
  48022. private _onGamepadConnectedObserver;
  48023. private _onGamepadDisconnectedObserver;
  48024. private _cameraTransform;
  48025. private _deltaTransform;
  48026. private _vector3;
  48027. private _vector2;
  48028. /**
  48029. * Attach the input controls to a specific dom element to get the input from.
  48030. * @param element Defines the element the controls should be listened from
  48031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48032. */
  48033. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48034. /**
  48035. * Detach the current controls from the specified dom element.
  48036. * @param element Defines the element to stop listening the inputs from
  48037. */
  48038. detachControl(element: Nullable<HTMLElement>): void;
  48039. /**
  48040. * Update the current camera state depending on the inputs that have been used this frame.
  48041. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48042. */
  48043. checkInputs(): void;
  48044. /**
  48045. * Gets the class name of the current intput.
  48046. * @returns the class name
  48047. */
  48048. getClassName(): string;
  48049. /**
  48050. * Get the friendly name associated with the input class.
  48051. * @returns the input friendly name
  48052. */
  48053. getSimpleName(): string;
  48054. }
  48055. }
  48056. declare module BABYLON {
  48057. /**
  48058. * Defines the potential axis of a Joystick
  48059. */
  48060. export enum JoystickAxis {
  48061. /** X axis */
  48062. X = 0,
  48063. /** Y axis */
  48064. Y = 1,
  48065. /** Z axis */
  48066. Z = 2
  48067. }
  48068. /**
  48069. * Represents the different customization options available
  48070. * for VirtualJoystick
  48071. */
  48072. interface VirtualJoystickCustomizations {
  48073. /**
  48074. * Size of the joystick's puck
  48075. */
  48076. puckSize: number;
  48077. /**
  48078. * Size of the joystick's container
  48079. */
  48080. containerSize: number;
  48081. /**
  48082. * Color of the joystick && puck
  48083. */
  48084. color: string;
  48085. /**
  48086. * Image URL for the joystick's puck
  48087. */
  48088. puckImage?: string;
  48089. /**
  48090. * Image URL for the joystick's container
  48091. */
  48092. containerImage?: string;
  48093. /**
  48094. * Defines the unmoving position of the joystick container
  48095. */
  48096. position?: {
  48097. x: number;
  48098. y: number;
  48099. };
  48100. /**
  48101. * Defines whether or not the joystick container is always visible
  48102. */
  48103. alwaysVisible: boolean;
  48104. /**
  48105. * Defines whether or not to limit the movement of the puck to the joystick's container
  48106. */
  48107. limitToContainer: boolean;
  48108. }
  48109. /**
  48110. * Class used to define virtual joystick (used in touch mode)
  48111. */
  48112. export class VirtualJoystick {
  48113. /**
  48114. * Gets or sets a boolean indicating that left and right values must be inverted
  48115. */
  48116. reverseLeftRight: boolean;
  48117. /**
  48118. * Gets or sets a boolean indicating that up and down values must be inverted
  48119. */
  48120. reverseUpDown: boolean;
  48121. /**
  48122. * Gets the offset value for the position (ie. the change of the position value)
  48123. */
  48124. deltaPosition: Vector3;
  48125. /**
  48126. * Gets a boolean indicating if the virtual joystick was pressed
  48127. */
  48128. pressed: boolean;
  48129. /**
  48130. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48131. */
  48132. static Canvas: Nullable<HTMLCanvasElement>;
  48133. /**
  48134. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48135. */
  48136. limitToContainer: boolean;
  48137. private static _globalJoystickIndex;
  48138. private static _alwaysVisibleSticks;
  48139. private static vjCanvasContext;
  48140. private static vjCanvasWidth;
  48141. private static vjCanvasHeight;
  48142. private static halfWidth;
  48143. private static _GetDefaultOptions;
  48144. private _action;
  48145. private _axisTargetedByLeftAndRight;
  48146. private _axisTargetedByUpAndDown;
  48147. private _joystickSensibility;
  48148. private _inversedSensibility;
  48149. private _joystickPointerID;
  48150. private _joystickColor;
  48151. private _joystickPointerPos;
  48152. private _joystickPreviousPointerPos;
  48153. private _joystickPointerStartPos;
  48154. private _deltaJoystickVector;
  48155. private _leftJoystick;
  48156. private _touches;
  48157. private _joystickPosition;
  48158. private _alwaysVisible;
  48159. private _puckImage;
  48160. private _containerImage;
  48161. private _joystickPuckSize;
  48162. private _joystickContainerSize;
  48163. private _clearPuckSize;
  48164. private _clearContainerSize;
  48165. private _clearPuckSizeOffset;
  48166. private _clearContainerSizeOffset;
  48167. private _onPointerDownHandlerRef;
  48168. private _onPointerMoveHandlerRef;
  48169. private _onPointerUpHandlerRef;
  48170. private _onResize;
  48171. /**
  48172. * Creates a new virtual joystick
  48173. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48174. * @param customizations Defines the options we want to customize the VirtualJoystick
  48175. */
  48176. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48177. /**
  48178. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48179. * @param newJoystickSensibility defines the new sensibility
  48180. */
  48181. setJoystickSensibility(newJoystickSensibility: number): void;
  48182. private _onPointerDown;
  48183. private _onPointerMove;
  48184. private _onPointerUp;
  48185. /**
  48186. * Change the color of the virtual joystick
  48187. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48188. */
  48189. setJoystickColor(newColor: string): void;
  48190. /**
  48191. * Size of the joystick's container
  48192. */
  48193. set containerSize(newSize: number);
  48194. get containerSize(): number;
  48195. /**
  48196. * Size of the joystick's puck
  48197. */
  48198. set puckSize(newSize: number);
  48199. get puckSize(): number;
  48200. /**
  48201. * Clears the set position of the joystick
  48202. */
  48203. clearPosition(): void;
  48204. /**
  48205. * Defines whether or not the joystick container is always visible
  48206. */
  48207. set alwaysVisible(value: boolean);
  48208. get alwaysVisible(): boolean;
  48209. /**
  48210. * Sets the constant position of the Joystick container
  48211. * @param x X axis coordinate
  48212. * @param y Y axis coordinate
  48213. */
  48214. setPosition(x: number, y: number): void;
  48215. /**
  48216. * Defines a callback to call when the joystick is touched
  48217. * @param action defines the callback
  48218. */
  48219. setActionOnTouch(action: () => any): void;
  48220. /**
  48221. * Defines which axis you'd like to control for left & right
  48222. * @param axis defines the axis to use
  48223. */
  48224. setAxisForLeftRight(axis: JoystickAxis): void;
  48225. /**
  48226. * Defines which axis you'd like to control for up & down
  48227. * @param axis defines the axis to use
  48228. */
  48229. setAxisForUpDown(axis: JoystickAxis): void;
  48230. /**
  48231. * Clears the canvas from the previous puck / container draw
  48232. */
  48233. private _clearPreviousDraw;
  48234. /**
  48235. * Loads `urlPath` to be used for the container's image
  48236. * @param urlPath defines the urlPath of an image to use
  48237. */
  48238. setContainerImage(urlPath: string): void;
  48239. /**
  48240. * Loads `urlPath` to be used for the puck's image
  48241. * @param urlPath defines the urlPath of an image to use
  48242. */
  48243. setPuckImage(urlPath: string): void;
  48244. /**
  48245. * Draws the Virtual Joystick's container
  48246. */
  48247. private _drawContainer;
  48248. /**
  48249. * Draws the Virtual Joystick's puck
  48250. */
  48251. private _drawPuck;
  48252. private _drawVirtualJoystick;
  48253. /**
  48254. * Release internal HTML canvas
  48255. */
  48256. releaseCanvas(): void;
  48257. }
  48258. }
  48259. declare module BABYLON {
  48260. interface FreeCameraInputsManager {
  48261. /**
  48262. * Add virtual joystick input support to the input manager.
  48263. * @returns the current input manager
  48264. */
  48265. addVirtualJoystick(): FreeCameraInputsManager;
  48266. }
  48267. /**
  48268. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48269. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48270. */
  48271. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48272. /**
  48273. * Defines the camera the input is attached to.
  48274. */
  48275. camera: FreeCamera;
  48276. private _leftjoystick;
  48277. private _rightjoystick;
  48278. /**
  48279. * Gets the left stick of the virtual joystick.
  48280. * @returns The virtual Joystick
  48281. */
  48282. getLeftJoystick(): VirtualJoystick;
  48283. /**
  48284. * Gets the right stick of the virtual joystick.
  48285. * @returns The virtual Joystick
  48286. */
  48287. getRightJoystick(): VirtualJoystick;
  48288. /**
  48289. * Update the current camera state depending on the inputs that have been used this frame.
  48290. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48291. */
  48292. checkInputs(): void;
  48293. /**
  48294. * Attach the input controls to a specific dom element to get the input from.
  48295. * @param element Defines the element the controls should be listened from
  48296. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48297. */
  48298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48299. /**
  48300. * Detach the current controls from the specified dom element.
  48301. * @param element Defines the element to stop listening the inputs from
  48302. */
  48303. detachControl(element: Nullable<HTMLElement>): void;
  48304. /**
  48305. * Gets the class name of the current intput.
  48306. * @returns the class name
  48307. */
  48308. getClassName(): string;
  48309. /**
  48310. * Get the friendly name associated with the input class.
  48311. * @returns the input friendly name
  48312. */
  48313. getSimpleName(): string;
  48314. }
  48315. }
  48316. declare module BABYLON {
  48317. /**
  48318. * This represents a FPS type of camera controlled by touch.
  48319. * This is like a universal camera minus the Gamepad controls.
  48320. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48321. */
  48322. export class TouchCamera extends FreeCamera {
  48323. /**
  48324. * Defines the touch sensibility for rotation.
  48325. * The higher the faster.
  48326. */
  48327. get touchAngularSensibility(): number;
  48328. set touchAngularSensibility(value: number);
  48329. /**
  48330. * Defines the touch sensibility for move.
  48331. * The higher the faster.
  48332. */
  48333. get touchMoveSensibility(): number;
  48334. set touchMoveSensibility(value: number);
  48335. /**
  48336. * Instantiates a new touch camera.
  48337. * This represents a FPS type of camera controlled by touch.
  48338. * This is like a universal camera minus the Gamepad controls.
  48339. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48340. * @param name Define the name of the camera in the scene
  48341. * @param position Define the start position of the camera in the scene
  48342. * @param scene Define the scene the camera belongs to
  48343. */
  48344. constructor(name: string, position: Vector3, scene: Scene);
  48345. /**
  48346. * Gets the current object class name.
  48347. * @return the class name
  48348. */
  48349. getClassName(): string;
  48350. /** @hidden */
  48351. _setupInputs(): void;
  48352. }
  48353. }
  48354. declare module BABYLON {
  48355. /**
  48356. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48357. * being tilted forward or back and left or right.
  48358. */
  48359. export class DeviceOrientationCamera extends FreeCamera {
  48360. private _initialQuaternion;
  48361. private _quaternionCache;
  48362. private _tmpDragQuaternion;
  48363. private _disablePointerInputWhenUsingDeviceOrientation;
  48364. /**
  48365. * Creates a new device orientation camera
  48366. * @param name The name of the camera
  48367. * @param position The start position camera
  48368. * @param scene The scene the camera belongs to
  48369. */
  48370. constructor(name: string, position: Vector3, scene: Scene);
  48371. /**
  48372. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48373. */
  48374. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48375. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48376. private _dragFactor;
  48377. /**
  48378. * Enabled turning on the y axis when the orientation sensor is active
  48379. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48380. */
  48381. enableHorizontalDragging(dragFactor?: number): void;
  48382. /**
  48383. * Gets the current instance class name ("DeviceOrientationCamera").
  48384. * This helps avoiding instanceof at run time.
  48385. * @returns the class name
  48386. */
  48387. getClassName(): string;
  48388. /**
  48389. * @hidden
  48390. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48391. */
  48392. _checkInputs(): void;
  48393. /**
  48394. * Reset the camera to its default orientation on the specified axis only.
  48395. * @param axis The axis to reset
  48396. */
  48397. resetToCurrentRotation(axis?: Axis): void;
  48398. }
  48399. }
  48400. declare module BABYLON {
  48401. /**
  48402. * Defines supported buttons for XBox360 compatible gamepads
  48403. */
  48404. export enum Xbox360Button {
  48405. /** A */
  48406. A = 0,
  48407. /** B */
  48408. B = 1,
  48409. /** X */
  48410. X = 2,
  48411. /** Y */
  48412. Y = 3,
  48413. /** Left button */
  48414. LB = 4,
  48415. /** Right button */
  48416. RB = 5,
  48417. /** Back */
  48418. Back = 8,
  48419. /** Start */
  48420. Start = 9,
  48421. /** Left stick */
  48422. LeftStick = 10,
  48423. /** Right stick */
  48424. RightStick = 11
  48425. }
  48426. /** Defines values for XBox360 DPad */
  48427. export enum Xbox360Dpad {
  48428. /** Up */
  48429. Up = 12,
  48430. /** Down */
  48431. Down = 13,
  48432. /** Left */
  48433. Left = 14,
  48434. /** Right */
  48435. Right = 15
  48436. }
  48437. /**
  48438. * Defines a XBox360 gamepad
  48439. */
  48440. export class Xbox360Pad extends Gamepad {
  48441. private _leftTrigger;
  48442. private _rightTrigger;
  48443. private _onlefttriggerchanged;
  48444. private _onrighttriggerchanged;
  48445. private _onbuttondown;
  48446. private _onbuttonup;
  48447. private _ondpaddown;
  48448. private _ondpadup;
  48449. /** Observable raised when a button is pressed */
  48450. onButtonDownObservable: Observable<Xbox360Button>;
  48451. /** Observable raised when a button is released */
  48452. onButtonUpObservable: Observable<Xbox360Button>;
  48453. /** Observable raised when a pad is pressed */
  48454. onPadDownObservable: Observable<Xbox360Dpad>;
  48455. /** Observable raised when a pad is released */
  48456. onPadUpObservable: Observable<Xbox360Dpad>;
  48457. private _buttonA;
  48458. private _buttonB;
  48459. private _buttonX;
  48460. private _buttonY;
  48461. private _buttonBack;
  48462. private _buttonStart;
  48463. private _buttonLB;
  48464. private _buttonRB;
  48465. private _buttonLeftStick;
  48466. private _buttonRightStick;
  48467. private _dPadUp;
  48468. private _dPadDown;
  48469. private _dPadLeft;
  48470. private _dPadRight;
  48471. private _isXboxOnePad;
  48472. /**
  48473. * Creates a new XBox360 gamepad object
  48474. * @param id defines the id of this gamepad
  48475. * @param index defines its index
  48476. * @param gamepad defines the internal HTML gamepad object
  48477. * @param xboxOne defines if it is a XBox One gamepad
  48478. */
  48479. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  48480. /**
  48481. * Defines the callback to call when left trigger is pressed
  48482. * @param callback defines the callback to use
  48483. */
  48484. onlefttriggerchanged(callback: (value: number) => void): void;
  48485. /**
  48486. * Defines the callback to call when right trigger is pressed
  48487. * @param callback defines the callback to use
  48488. */
  48489. onrighttriggerchanged(callback: (value: number) => void): void;
  48490. /**
  48491. * Gets the left trigger value
  48492. */
  48493. get leftTrigger(): number;
  48494. /**
  48495. * Sets the left trigger value
  48496. */
  48497. set leftTrigger(newValue: number);
  48498. /**
  48499. * Gets the right trigger value
  48500. */
  48501. get rightTrigger(): number;
  48502. /**
  48503. * Sets the right trigger value
  48504. */
  48505. set rightTrigger(newValue: number);
  48506. /**
  48507. * Defines the callback to call when a button is pressed
  48508. * @param callback defines the callback to use
  48509. */
  48510. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  48511. /**
  48512. * Defines the callback to call when a button is released
  48513. * @param callback defines the callback to use
  48514. */
  48515. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  48516. /**
  48517. * Defines the callback to call when a pad is pressed
  48518. * @param callback defines the callback to use
  48519. */
  48520. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  48521. /**
  48522. * Defines the callback to call when a pad is released
  48523. * @param callback defines the callback to use
  48524. */
  48525. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  48526. private _setButtonValue;
  48527. private _setDPadValue;
  48528. /**
  48529. * Gets the value of the `A` button
  48530. */
  48531. get buttonA(): number;
  48532. /**
  48533. * Sets the value of the `A` button
  48534. */
  48535. set buttonA(value: number);
  48536. /**
  48537. * Gets the value of the `B` button
  48538. */
  48539. get buttonB(): number;
  48540. /**
  48541. * Sets the value of the `B` button
  48542. */
  48543. set buttonB(value: number);
  48544. /**
  48545. * Gets the value of the `X` button
  48546. */
  48547. get buttonX(): number;
  48548. /**
  48549. * Sets the value of the `X` button
  48550. */
  48551. set buttonX(value: number);
  48552. /**
  48553. * Gets the value of the `Y` button
  48554. */
  48555. get buttonY(): number;
  48556. /**
  48557. * Sets the value of the `Y` button
  48558. */
  48559. set buttonY(value: number);
  48560. /**
  48561. * Gets the value of the `Start` button
  48562. */
  48563. get buttonStart(): number;
  48564. /**
  48565. * Sets the value of the `Start` button
  48566. */
  48567. set buttonStart(value: number);
  48568. /**
  48569. * Gets the value of the `Back` button
  48570. */
  48571. get buttonBack(): number;
  48572. /**
  48573. * Sets the value of the `Back` button
  48574. */
  48575. set buttonBack(value: number);
  48576. /**
  48577. * Gets the value of the `Left` button
  48578. */
  48579. get buttonLB(): number;
  48580. /**
  48581. * Sets the value of the `Left` button
  48582. */
  48583. set buttonLB(value: number);
  48584. /**
  48585. * Gets the value of the `Right` button
  48586. */
  48587. get buttonRB(): number;
  48588. /**
  48589. * Sets the value of the `Right` button
  48590. */
  48591. set buttonRB(value: number);
  48592. /**
  48593. * Gets the value of the Left joystick
  48594. */
  48595. get buttonLeftStick(): number;
  48596. /**
  48597. * Sets the value of the Left joystick
  48598. */
  48599. set buttonLeftStick(value: number);
  48600. /**
  48601. * Gets the value of the Right joystick
  48602. */
  48603. get buttonRightStick(): number;
  48604. /**
  48605. * Sets the value of the Right joystick
  48606. */
  48607. set buttonRightStick(value: number);
  48608. /**
  48609. * Gets the value of D-pad up
  48610. */
  48611. get dPadUp(): number;
  48612. /**
  48613. * Sets the value of D-pad up
  48614. */
  48615. set dPadUp(value: number);
  48616. /**
  48617. * Gets the value of D-pad down
  48618. */
  48619. get dPadDown(): number;
  48620. /**
  48621. * Sets the value of D-pad down
  48622. */
  48623. set dPadDown(value: number);
  48624. /**
  48625. * Gets the value of D-pad left
  48626. */
  48627. get dPadLeft(): number;
  48628. /**
  48629. * Sets the value of D-pad left
  48630. */
  48631. set dPadLeft(value: number);
  48632. /**
  48633. * Gets the value of D-pad right
  48634. */
  48635. get dPadRight(): number;
  48636. /**
  48637. * Sets the value of D-pad right
  48638. */
  48639. set dPadRight(value: number);
  48640. /**
  48641. * Force the gamepad to synchronize with device values
  48642. */
  48643. update(): void;
  48644. /**
  48645. * Disposes the gamepad
  48646. */
  48647. dispose(): void;
  48648. }
  48649. }
  48650. declare module BABYLON {
  48651. /**
  48652. * Defines supported buttons for DualShock compatible gamepads
  48653. */
  48654. export enum DualShockButton {
  48655. /** Cross */
  48656. Cross = 0,
  48657. /** Circle */
  48658. Circle = 1,
  48659. /** Square */
  48660. Square = 2,
  48661. /** Triangle */
  48662. Triangle = 3,
  48663. /** L1 */
  48664. L1 = 4,
  48665. /** R1 */
  48666. R1 = 5,
  48667. /** Share */
  48668. Share = 8,
  48669. /** Options */
  48670. Options = 9,
  48671. /** Left stick */
  48672. LeftStick = 10,
  48673. /** Right stick */
  48674. RightStick = 11
  48675. }
  48676. /** Defines values for DualShock DPad */
  48677. export enum DualShockDpad {
  48678. /** Up */
  48679. Up = 12,
  48680. /** Down */
  48681. Down = 13,
  48682. /** Left */
  48683. Left = 14,
  48684. /** Right */
  48685. Right = 15
  48686. }
  48687. /**
  48688. * Defines a DualShock gamepad
  48689. */
  48690. export class DualShockPad extends Gamepad {
  48691. private _leftTrigger;
  48692. private _rightTrigger;
  48693. private _onlefttriggerchanged;
  48694. private _onrighttriggerchanged;
  48695. private _onbuttondown;
  48696. private _onbuttonup;
  48697. private _ondpaddown;
  48698. private _ondpadup;
  48699. /** Observable raised when a button is pressed */
  48700. onButtonDownObservable: Observable<DualShockButton>;
  48701. /** Observable raised when a button is released */
  48702. onButtonUpObservable: Observable<DualShockButton>;
  48703. /** Observable raised when a pad is pressed */
  48704. onPadDownObservable: Observable<DualShockDpad>;
  48705. /** Observable raised when a pad is released */
  48706. onPadUpObservable: Observable<DualShockDpad>;
  48707. private _buttonCross;
  48708. private _buttonCircle;
  48709. private _buttonSquare;
  48710. private _buttonTriangle;
  48711. private _buttonShare;
  48712. private _buttonOptions;
  48713. private _buttonL1;
  48714. private _buttonR1;
  48715. private _buttonLeftStick;
  48716. private _buttonRightStick;
  48717. private _dPadUp;
  48718. private _dPadDown;
  48719. private _dPadLeft;
  48720. private _dPadRight;
  48721. /**
  48722. * Creates a new DualShock gamepad object
  48723. * @param id defines the id of this gamepad
  48724. * @param index defines its index
  48725. * @param gamepad defines the internal HTML gamepad object
  48726. */
  48727. constructor(id: string, index: number, gamepad: any);
  48728. /**
  48729. * Defines the callback to call when left trigger is pressed
  48730. * @param callback defines the callback to use
  48731. */
  48732. onlefttriggerchanged(callback: (value: number) => void): void;
  48733. /**
  48734. * Defines the callback to call when right trigger is pressed
  48735. * @param callback defines the callback to use
  48736. */
  48737. onrighttriggerchanged(callback: (value: number) => void): void;
  48738. /**
  48739. * Gets the left trigger value
  48740. */
  48741. get leftTrigger(): number;
  48742. /**
  48743. * Sets the left trigger value
  48744. */
  48745. set leftTrigger(newValue: number);
  48746. /**
  48747. * Gets the right trigger value
  48748. */
  48749. get rightTrigger(): number;
  48750. /**
  48751. * Sets the right trigger value
  48752. */
  48753. set rightTrigger(newValue: number);
  48754. /**
  48755. * Defines the callback to call when a button is pressed
  48756. * @param callback defines the callback to use
  48757. */
  48758. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  48759. /**
  48760. * Defines the callback to call when a button is released
  48761. * @param callback defines the callback to use
  48762. */
  48763. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  48764. /**
  48765. * Defines the callback to call when a pad is pressed
  48766. * @param callback defines the callback to use
  48767. */
  48768. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  48769. /**
  48770. * Defines the callback to call when a pad is released
  48771. * @param callback defines the callback to use
  48772. */
  48773. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  48774. private _setButtonValue;
  48775. private _setDPadValue;
  48776. /**
  48777. * Gets the value of the `Cross` button
  48778. */
  48779. get buttonCross(): number;
  48780. /**
  48781. * Sets the value of the `Cross` button
  48782. */
  48783. set buttonCross(value: number);
  48784. /**
  48785. * Gets the value of the `Circle` button
  48786. */
  48787. get buttonCircle(): number;
  48788. /**
  48789. * Sets the value of the `Circle` button
  48790. */
  48791. set buttonCircle(value: number);
  48792. /**
  48793. * Gets the value of the `Square` button
  48794. */
  48795. get buttonSquare(): number;
  48796. /**
  48797. * Sets the value of the `Square` button
  48798. */
  48799. set buttonSquare(value: number);
  48800. /**
  48801. * Gets the value of the `Triangle` button
  48802. */
  48803. get buttonTriangle(): number;
  48804. /**
  48805. * Sets the value of the `Triangle` button
  48806. */
  48807. set buttonTriangle(value: number);
  48808. /**
  48809. * Gets the value of the `Options` button
  48810. */
  48811. get buttonOptions(): number;
  48812. /**
  48813. * Sets the value of the `Options` button
  48814. */
  48815. set buttonOptions(value: number);
  48816. /**
  48817. * Gets the value of the `Share` button
  48818. */
  48819. get buttonShare(): number;
  48820. /**
  48821. * Sets the value of the `Share` button
  48822. */
  48823. set buttonShare(value: number);
  48824. /**
  48825. * Gets the value of the `L1` button
  48826. */
  48827. get buttonL1(): number;
  48828. /**
  48829. * Sets the value of the `L1` button
  48830. */
  48831. set buttonL1(value: number);
  48832. /**
  48833. * Gets the value of the `R1` button
  48834. */
  48835. get buttonR1(): number;
  48836. /**
  48837. * Sets the value of the `R1` button
  48838. */
  48839. set buttonR1(value: number);
  48840. /**
  48841. * Gets the value of the Left joystick
  48842. */
  48843. get buttonLeftStick(): number;
  48844. /**
  48845. * Sets the value of the Left joystick
  48846. */
  48847. set buttonLeftStick(value: number);
  48848. /**
  48849. * Gets the value of the Right joystick
  48850. */
  48851. get buttonRightStick(): number;
  48852. /**
  48853. * Sets the value of the Right joystick
  48854. */
  48855. set buttonRightStick(value: number);
  48856. /**
  48857. * Gets the value of D-pad up
  48858. */
  48859. get dPadUp(): number;
  48860. /**
  48861. * Sets the value of D-pad up
  48862. */
  48863. set dPadUp(value: number);
  48864. /**
  48865. * Gets the value of D-pad down
  48866. */
  48867. get dPadDown(): number;
  48868. /**
  48869. * Sets the value of D-pad down
  48870. */
  48871. set dPadDown(value: number);
  48872. /**
  48873. * Gets the value of D-pad left
  48874. */
  48875. get dPadLeft(): number;
  48876. /**
  48877. * Sets the value of D-pad left
  48878. */
  48879. set dPadLeft(value: number);
  48880. /**
  48881. * Gets the value of D-pad right
  48882. */
  48883. get dPadRight(): number;
  48884. /**
  48885. * Sets the value of D-pad right
  48886. */
  48887. set dPadRight(value: number);
  48888. /**
  48889. * Force the gamepad to synchronize with device values
  48890. */
  48891. update(): void;
  48892. /**
  48893. * Disposes the gamepad
  48894. */
  48895. dispose(): void;
  48896. }
  48897. }
  48898. declare module BABYLON {
  48899. /**
  48900. * Manager for handling gamepads
  48901. */
  48902. export class GamepadManager {
  48903. private _scene?;
  48904. private _babylonGamepads;
  48905. private _oneGamepadConnected;
  48906. /** @hidden */
  48907. _isMonitoring: boolean;
  48908. private _gamepadEventSupported;
  48909. private _gamepadSupport?;
  48910. /**
  48911. * observable to be triggered when the gamepad controller has been connected
  48912. */
  48913. onGamepadConnectedObservable: Observable<Gamepad>;
  48914. /**
  48915. * observable to be triggered when the gamepad controller has been disconnected
  48916. */
  48917. onGamepadDisconnectedObservable: Observable<Gamepad>;
  48918. private _onGamepadConnectedEvent;
  48919. private _onGamepadDisconnectedEvent;
  48920. /**
  48921. * Initializes the gamepad manager
  48922. * @param _scene BabylonJS scene
  48923. */
  48924. constructor(_scene?: Scene | undefined);
  48925. /**
  48926. * The gamepads in the game pad manager
  48927. */
  48928. get gamepads(): Gamepad[];
  48929. /**
  48930. * Get the gamepad controllers based on type
  48931. * @param type The type of gamepad controller
  48932. * @returns Nullable gamepad
  48933. */
  48934. getGamepadByType(type?: number): Nullable<Gamepad>;
  48935. /**
  48936. * Disposes the gamepad manager
  48937. */
  48938. dispose(): void;
  48939. private _addNewGamepad;
  48940. private _startMonitoringGamepads;
  48941. private _stopMonitoringGamepads;
  48942. /** @hidden */
  48943. _checkGamepadsStatus(): void;
  48944. private _updateGamepadObjects;
  48945. }
  48946. }
  48947. declare module BABYLON {
  48948. interface Scene {
  48949. /** @hidden */
  48950. _gamepadManager: Nullable<GamepadManager>;
  48951. /**
  48952. * Gets the gamepad manager associated with the scene
  48953. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  48954. */
  48955. gamepadManager: GamepadManager;
  48956. }
  48957. /**
  48958. * Interface representing a free camera inputs manager
  48959. */
  48960. interface FreeCameraInputsManager {
  48961. /**
  48962. * Adds gamepad input support to the FreeCameraInputsManager.
  48963. * @returns the FreeCameraInputsManager
  48964. */
  48965. addGamepad(): FreeCameraInputsManager;
  48966. }
  48967. /**
  48968. * Interface representing an arc rotate camera inputs manager
  48969. */
  48970. interface ArcRotateCameraInputsManager {
  48971. /**
  48972. * Adds gamepad input support to the ArcRotateCamera InputManager.
  48973. * @returns the camera inputs manager
  48974. */
  48975. addGamepad(): ArcRotateCameraInputsManager;
  48976. }
  48977. /**
  48978. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  48979. */
  48980. export class GamepadSystemSceneComponent implements ISceneComponent {
  48981. /**
  48982. * The component name helpfull to identify the component in the list of scene components.
  48983. */
  48984. readonly name: string;
  48985. /**
  48986. * The scene the component belongs to.
  48987. */
  48988. scene: Scene;
  48989. /**
  48990. * Creates a new instance of the component for the given scene
  48991. * @param scene Defines the scene to register the component in
  48992. */
  48993. constructor(scene: Scene);
  48994. /**
  48995. * Registers the component in a given scene
  48996. */
  48997. register(): void;
  48998. /**
  48999. * Rebuilds the elements related to this component in case of
  49000. * context lost for instance.
  49001. */
  49002. rebuild(): void;
  49003. /**
  49004. * Disposes the component and the associated ressources
  49005. */
  49006. dispose(): void;
  49007. private _beforeCameraUpdate;
  49008. }
  49009. }
  49010. declare module BABYLON {
  49011. /**
  49012. * 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,
  49013. * which still works and will still be found in many Playgrounds.
  49014. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49015. */
  49016. export class UniversalCamera extends TouchCamera {
  49017. /**
  49018. * Defines the gamepad rotation sensiblity.
  49019. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49020. */
  49021. get gamepadAngularSensibility(): number;
  49022. set gamepadAngularSensibility(value: number);
  49023. /**
  49024. * Defines the gamepad move sensiblity.
  49025. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49026. */
  49027. get gamepadMoveSensibility(): number;
  49028. set gamepadMoveSensibility(value: number);
  49029. /**
  49030. * 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,
  49031. * which still works and will still be found in many Playgrounds.
  49032. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49033. * @param name Define the name of the camera in the scene
  49034. * @param position Define the start position of the camera in the scene
  49035. * @param scene Define the scene the camera belongs to
  49036. */
  49037. constructor(name: string, position: Vector3, scene: Scene);
  49038. /**
  49039. * Gets the current object class name.
  49040. * @return the class name
  49041. */
  49042. getClassName(): string;
  49043. }
  49044. }
  49045. declare module BABYLON {
  49046. /**
  49047. * This represents a FPS type of camera. This is only here for back compat purpose.
  49048. * Please use the UniversalCamera instead as both are identical.
  49049. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49050. */
  49051. export class GamepadCamera extends UniversalCamera {
  49052. /**
  49053. * Instantiates a new Gamepad Camera
  49054. * This represents a FPS type of camera. This is only here for back compat purpose.
  49055. * Please use the UniversalCamera instead as both are identical.
  49056. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49057. * @param name Define the name of the camera in the scene
  49058. * @param position Define the start position of the camera in the scene
  49059. * @param scene Define the scene the camera belongs to
  49060. */
  49061. constructor(name: string, position: Vector3, scene: Scene);
  49062. /**
  49063. * Gets the current object class name.
  49064. * @return the class name
  49065. */
  49066. getClassName(): string;
  49067. }
  49068. }
  49069. declare module BABYLON {
  49070. /** @hidden */
  49071. export var passPixelShader: {
  49072. name: string;
  49073. shader: string;
  49074. };
  49075. }
  49076. declare module BABYLON {
  49077. /** @hidden */
  49078. export var passCubePixelShader: {
  49079. name: string;
  49080. shader: string;
  49081. };
  49082. }
  49083. declare module BABYLON {
  49084. /**
  49085. * PassPostProcess which produces an output the same as it's input
  49086. */
  49087. export class PassPostProcess extends PostProcess {
  49088. /**
  49089. * Gets a string identifying the name of the class
  49090. * @returns "PassPostProcess" string
  49091. */
  49092. getClassName(): string;
  49093. /**
  49094. * Creates the PassPostProcess
  49095. * @param name The name of the effect.
  49096. * @param options The required width/height ratio to downsize to before computing the render pass.
  49097. * @param camera The camera to apply the render pass to.
  49098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49099. * @param engine The engine which the post process will be applied. (default: current engine)
  49100. * @param reusable If the post process can be reused on the same frame. (default: false)
  49101. * @param textureType The type of texture to be used when performing the post processing.
  49102. * @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)
  49103. */
  49104. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49105. /** @hidden */
  49106. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49107. }
  49108. /**
  49109. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49110. */
  49111. export class PassCubePostProcess extends PostProcess {
  49112. private _face;
  49113. /**
  49114. * Gets or sets the cube face to display.
  49115. * * 0 is +X
  49116. * * 1 is -X
  49117. * * 2 is +Y
  49118. * * 3 is -Y
  49119. * * 4 is +Z
  49120. * * 5 is -Z
  49121. */
  49122. get face(): number;
  49123. set face(value: number);
  49124. /**
  49125. * Gets a string identifying the name of the class
  49126. * @returns "PassCubePostProcess" string
  49127. */
  49128. getClassName(): string;
  49129. /**
  49130. * Creates the PassCubePostProcess
  49131. * @param name The name of the effect.
  49132. * @param options The required width/height ratio to downsize to before computing the render pass.
  49133. * @param camera The camera to apply the render pass to.
  49134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49135. * @param engine The engine which the post process will be applied. (default: current engine)
  49136. * @param reusable If the post process can be reused on the same frame. (default: false)
  49137. * @param textureType The type of texture to be used when performing the post processing.
  49138. * @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)
  49139. */
  49140. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49141. /** @hidden */
  49142. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49143. }
  49144. }
  49145. declare module BABYLON {
  49146. /** @hidden */
  49147. export var anaglyphPixelShader: {
  49148. name: string;
  49149. shader: string;
  49150. };
  49151. }
  49152. declare module BABYLON {
  49153. /**
  49154. * Postprocess used to generate anaglyphic rendering
  49155. */
  49156. export class AnaglyphPostProcess extends PostProcess {
  49157. private _passedProcess;
  49158. /**
  49159. * Gets a string identifying the name of the class
  49160. * @returns "AnaglyphPostProcess" string
  49161. */
  49162. getClassName(): string;
  49163. /**
  49164. * Creates a new AnaglyphPostProcess
  49165. * @param name defines postprocess name
  49166. * @param options defines creation options or target ratio scale
  49167. * @param rigCameras defines cameras using this postprocess
  49168. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49169. * @param engine defines hosting engine
  49170. * @param reusable defines if the postprocess will be reused multiple times per frame
  49171. */
  49172. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49173. }
  49174. }
  49175. declare module BABYLON {
  49176. /**
  49177. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49178. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49179. */
  49180. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49181. /**
  49182. * Creates a new AnaglyphArcRotateCamera
  49183. * @param name defines camera name
  49184. * @param alpha defines alpha angle (in radians)
  49185. * @param beta defines beta angle (in radians)
  49186. * @param radius defines radius
  49187. * @param target defines camera target
  49188. * @param interaxialDistance defines distance between each color axis
  49189. * @param scene defines the hosting scene
  49190. */
  49191. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49192. /**
  49193. * Gets camera class name
  49194. * @returns AnaglyphArcRotateCamera
  49195. */
  49196. getClassName(): string;
  49197. }
  49198. }
  49199. declare module BABYLON {
  49200. /**
  49201. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49202. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49203. */
  49204. export class AnaglyphFreeCamera extends FreeCamera {
  49205. /**
  49206. * Creates a new AnaglyphFreeCamera
  49207. * @param name defines camera name
  49208. * @param position defines initial position
  49209. * @param interaxialDistance defines distance between each color axis
  49210. * @param scene defines the hosting scene
  49211. */
  49212. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49213. /**
  49214. * Gets camera class name
  49215. * @returns AnaglyphFreeCamera
  49216. */
  49217. getClassName(): string;
  49218. }
  49219. }
  49220. declare module BABYLON {
  49221. /**
  49222. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49223. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49224. */
  49225. export class AnaglyphGamepadCamera extends GamepadCamera {
  49226. /**
  49227. * Creates a new AnaglyphGamepadCamera
  49228. * @param name defines camera name
  49229. * @param position defines initial position
  49230. * @param interaxialDistance defines distance between each color axis
  49231. * @param scene defines the hosting scene
  49232. */
  49233. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49234. /**
  49235. * Gets camera class name
  49236. * @returns AnaglyphGamepadCamera
  49237. */
  49238. getClassName(): string;
  49239. }
  49240. }
  49241. declare module BABYLON {
  49242. /**
  49243. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49244. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49245. */
  49246. export class AnaglyphUniversalCamera extends UniversalCamera {
  49247. /**
  49248. * Creates a new AnaglyphUniversalCamera
  49249. * @param name defines camera name
  49250. * @param position defines initial position
  49251. * @param interaxialDistance defines distance between each color axis
  49252. * @param scene defines the hosting scene
  49253. */
  49254. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49255. /**
  49256. * Gets camera class name
  49257. * @returns AnaglyphUniversalCamera
  49258. */
  49259. getClassName(): string;
  49260. }
  49261. }
  49262. declare module BABYLON {
  49263. /**
  49264. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49265. * @see https://doc.babylonjs.com/features/cameras
  49266. */
  49267. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49268. /**
  49269. * Creates a new StereoscopicArcRotateCamera
  49270. * @param name defines camera name
  49271. * @param alpha defines alpha angle (in radians)
  49272. * @param beta defines beta angle (in radians)
  49273. * @param radius defines radius
  49274. * @param target defines camera target
  49275. * @param interaxialDistance defines distance between each color axis
  49276. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49277. * @param scene defines the hosting scene
  49278. */
  49279. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49280. /**
  49281. * Gets camera class name
  49282. * @returns StereoscopicArcRotateCamera
  49283. */
  49284. getClassName(): string;
  49285. }
  49286. }
  49287. declare module BABYLON {
  49288. /**
  49289. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49290. * @see https://doc.babylonjs.com/features/cameras
  49291. */
  49292. export class StereoscopicFreeCamera extends FreeCamera {
  49293. /**
  49294. * Creates a new StereoscopicFreeCamera
  49295. * @param name defines camera name
  49296. * @param position defines initial position
  49297. * @param interaxialDistance defines distance between each color axis
  49298. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49299. * @param scene defines the hosting scene
  49300. */
  49301. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49302. /**
  49303. * Gets camera class name
  49304. * @returns StereoscopicFreeCamera
  49305. */
  49306. getClassName(): string;
  49307. }
  49308. }
  49309. declare module BABYLON {
  49310. /**
  49311. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49312. * @see https://doc.babylonjs.com/features/cameras
  49313. */
  49314. export class StereoscopicGamepadCamera extends GamepadCamera {
  49315. /**
  49316. * Creates a new StereoscopicGamepadCamera
  49317. * @param name defines camera name
  49318. * @param position defines initial position
  49319. * @param interaxialDistance defines distance between each color axis
  49320. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49321. * @param scene defines the hosting scene
  49322. */
  49323. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49324. /**
  49325. * Gets camera class name
  49326. * @returns StereoscopicGamepadCamera
  49327. */
  49328. getClassName(): string;
  49329. }
  49330. }
  49331. declare module BABYLON {
  49332. /**
  49333. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49334. * @see https://doc.babylonjs.com/features/cameras
  49335. */
  49336. export class StereoscopicUniversalCamera extends UniversalCamera {
  49337. /**
  49338. * Creates a new StereoscopicUniversalCamera
  49339. * @param name defines camera name
  49340. * @param position defines initial position
  49341. * @param interaxialDistance defines distance between each color axis
  49342. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49343. * @param scene defines the hosting scene
  49344. */
  49345. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49346. /**
  49347. * Gets camera class name
  49348. * @returns StereoscopicUniversalCamera
  49349. */
  49350. getClassName(): string;
  49351. }
  49352. }
  49353. declare module BABYLON {
  49354. /**
  49355. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49356. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49357. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49358. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49359. */
  49360. export class VirtualJoysticksCamera extends FreeCamera {
  49361. /**
  49362. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49363. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49364. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49365. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49366. * @param name Define the name of the camera in the scene
  49367. * @param position Define the start position of the camera in the scene
  49368. * @param scene Define the scene the camera belongs to
  49369. */
  49370. constructor(name: string, position: Vector3, scene: Scene);
  49371. /**
  49372. * Gets the current object class name.
  49373. * @return the class name
  49374. */
  49375. getClassName(): string;
  49376. }
  49377. }
  49378. declare module BABYLON {
  49379. /**
  49380. * This represents all the required metrics to create a VR camera.
  49381. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49382. */
  49383. export class VRCameraMetrics {
  49384. /**
  49385. * Define the horizontal resolution off the screen.
  49386. */
  49387. hResolution: number;
  49388. /**
  49389. * Define the vertical resolution off the screen.
  49390. */
  49391. vResolution: number;
  49392. /**
  49393. * Define the horizontal screen size.
  49394. */
  49395. hScreenSize: number;
  49396. /**
  49397. * Define the vertical screen size.
  49398. */
  49399. vScreenSize: number;
  49400. /**
  49401. * Define the vertical screen center position.
  49402. */
  49403. vScreenCenter: number;
  49404. /**
  49405. * Define the distance of the eyes to the screen.
  49406. */
  49407. eyeToScreenDistance: number;
  49408. /**
  49409. * Define the distance between both lenses
  49410. */
  49411. lensSeparationDistance: number;
  49412. /**
  49413. * Define the distance between both viewer's eyes.
  49414. */
  49415. interpupillaryDistance: number;
  49416. /**
  49417. * Define the distortion factor of the VR postprocess.
  49418. * Please, touch with care.
  49419. */
  49420. distortionK: number[];
  49421. /**
  49422. * Define the chromatic aberration correction factors for the VR post process.
  49423. */
  49424. chromaAbCorrection: number[];
  49425. /**
  49426. * Define the scale factor of the post process.
  49427. * The smaller the better but the slower.
  49428. */
  49429. postProcessScaleFactor: number;
  49430. /**
  49431. * Define an offset for the lens center.
  49432. */
  49433. lensCenterOffset: number;
  49434. /**
  49435. * Define if the current vr camera should compensate the distortion of the lense or not.
  49436. */
  49437. compensateDistortion: boolean;
  49438. /**
  49439. * Defines if multiview should be enabled when rendering (Default: false)
  49440. */
  49441. multiviewEnabled: boolean;
  49442. /**
  49443. * Gets the rendering aspect ratio based on the provided resolutions.
  49444. */
  49445. get aspectRatio(): number;
  49446. /**
  49447. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49448. */
  49449. get aspectRatioFov(): number;
  49450. /**
  49451. * @hidden
  49452. */
  49453. get leftHMatrix(): Matrix;
  49454. /**
  49455. * @hidden
  49456. */
  49457. get rightHMatrix(): Matrix;
  49458. /**
  49459. * @hidden
  49460. */
  49461. get leftPreViewMatrix(): Matrix;
  49462. /**
  49463. * @hidden
  49464. */
  49465. get rightPreViewMatrix(): Matrix;
  49466. /**
  49467. * Get the default VRMetrics based on the most generic setup.
  49468. * @returns the default vr metrics
  49469. */
  49470. static GetDefault(): VRCameraMetrics;
  49471. }
  49472. }
  49473. declare module BABYLON {
  49474. /** @hidden */
  49475. export var vrDistortionCorrectionPixelShader: {
  49476. name: string;
  49477. shader: string;
  49478. };
  49479. }
  49480. declare module BABYLON {
  49481. /**
  49482. * VRDistortionCorrectionPostProcess used for mobile VR
  49483. */
  49484. export class VRDistortionCorrectionPostProcess extends PostProcess {
  49485. private _isRightEye;
  49486. private _distortionFactors;
  49487. private _postProcessScaleFactor;
  49488. private _lensCenterOffset;
  49489. private _scaleIn;
  49490. private _scaleFactor;
  49491. private _lensCenter;
  49492. /**
  49493. * Gets a string identifying the name of the class
  49494. * @returns "VRDistortionCorrectionPostProcess" string
  49495. */
  49496. getClassName(): string;
  49497. /**
  49498. * Initializes the VRDistortionCorrectionPostProcess
  49499. * @param name The name of the effect.
  49500. * @param camera The camera to apply the render pass to.
  49501. * @param isRightEye If this is for the right eye distortion
  49502. * @param vrMetrics All the required metrics for the VR camera
  49503. */
  49504. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  49505. }
  49506. }
  49507. declare module BABYLON {
  49508. /**
  49509. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  49510. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49511. */
  49512. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  49513. /**
  49514. * Creates a new VRDeviceOrientationArcRotateCamera
  49515. * @param name defines camera name
  49516. * @param alpha defines the camera rotation along the logitudinal axis
  49517. * @param beta defines the camera rotation along the latitudinal axis
  49518. * @param radius defines the camera distance from its target
  49519. * @param target defines the camera target
  49520. * @param scene defines the scene the camera belongs to
  49521. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49522. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49523. */
  49524. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49525. /**
  49526. * Gets camera class name
  49527. * @returns VRDeviceOrientationArcRotateCamera
  49528. */
  49529. getClassName(): string;
  49530. }
  49531. }
  49532. declare module BABYLON {
  49533. /**
  49534. * Camera used to simulate VR rendering (based on FreeCamera)
  49535. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49536. */
  49537. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  49538. /**
  49539. * Creates a new VRDeviceOrientationFreeCamera
  49540. * @param name defines camera name
  49541. * @param position defines the start position of the camera
  49542. * @param scene defines the scene the camera belongs to
  49543. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49544. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49545. */
  49546. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49547. /**
  49548. * Gets camera class name
  49549. * @returns VRDeviceOrientationFreeCamera
  49550. */
  49551. getClassName(): string;
  49552. }
  49553. }
  49554. declare module BABYLON {
  49555. /**
  49556. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  49557. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49558. */
  49559. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  49560. /**
  49561. * Creates a new VRDeviceOrientationGamepadCamera
  49562. * @param name defines camera name
  49563. * @param position defines the start position of the camera
  49564. * @param scene defines the scene the camera belongs to
  49565. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49566. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49567. */
  49568. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49569. /**
  49570. * Gets camera class name
  49571. * @returns VRDeviceOrientationGamepadCamera
  49572. */
  49573. getClassName(): string;
  49574. }
  49575. }
  49576. declare module BABYLON {
  49577. /**
  49578. * A class extending Texture allowing drawing on a texture
  49579. * @see https://doc.babylonjs.com/how_to/dynamictexture
  49580. */
  49581. export class DynamicTexture extends Texture {
  49582. private _generateMipMaps;
  49583. private _canvas;
  49584. private _context;
  49585. /**
  49586. * Creates a DynamicTexture
  49587. * @param name defines the name of the texture
  49588. * @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
  49589. * @param scene defines the scene where you want the texture
  49590. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  49591. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  49592. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  49593. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  49594. */
  49595. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  49596. /**
  49597. * Get the current class name of the texture useful for serialization or dynamic coding.
  49598. * @returns "DynamicTexture"
  49599. */
  49600. getClassName(): string;
  49601. /**
  49602. * Gets the current state of canRescale
  49603. */
  49604. get canRescale(): boolean;
  49605. private _recreate;
  49606. /**
  49607. * Scales the texture
  49608. * @param ratio the scale factor to apply to both width and height
  49609. */
  49610. scale(ratio: number): void;
  49611. /**
  49612. * Resizes the texture
  49613. * @param width the new width
  49614. * @param height the new height
  49615. */
  49616. scaleTo(width: number, height: number): void;
  49617. /**
  49618. * Gets the context of the canvas used by the texture
  49619. * @returns the canvas context of the dynamic texture
  49620. */
  49621. getContext(): CanvasRenderingContext2D;
  49622. /**
  49623. * Clears the texture
  49624. */
  49625. clear(): void;
  49626. /**
  49627. * Updates the texture
  49628. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49629. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  49630. */
  49631. update(invertY?: boolean, premulAlpha?: boolean): void;
  49632. /**
  49633. * Draws text onto the texture
  49634. * @param text defines the text to be drawn
  49635. * @param x defines the placement of the text from the left
  49636. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  49637. * @param font defines the font to be used with font-style, font-size, font-name
  49638. * @param color defines the color used for the text
  49639. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  49640. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49641. * @param update defines whether texture is immediately update (default is true)
  49642. */
  49643. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  49644. /**
  49645. * Clones the texture
  49646. * @returns the clone of the texture.
  49647. */
  49648. clone(): DynamicTexture;
  49649. /**
  49650. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  49651. * @returns a serialized dynamic texture object
  49652. */
  49653. serialize(): any;
  49654. private _IsCanvasElement;
  49655. /** @hidden */
  49656. _rebuild(): void;
  49657. }
  49658. }
  49659. declare module BABYLON {
  49660. /**
  49661. * Class containing static functions to help procedurally build meshes
  49662. */
  49663. export class GroundBuilder {
  49664. /**
  49665. * Creates a ground mesh
  49666. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49667. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49669. * @param name defines the name of the mesh
  49670. * @param options defines the options used to create the mesh
  49671. * @param scene defines the hosting scene
  49672. * @returns the ground mesh
  49673. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49674. */
  49675. static CreateGround(name: string, options: {
  49676. width?: number;
  49677. height?: number;
  49678. subdivisions?: number;
  49679. subdivisionsX?: number;
  49680. subdivisionsY?: number;
  49681. updatable?: boolean;
  49682. }, scene: any): Mesh;
  49683. /**
  49684. * Creates a tiled ground mesh
  49685. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49686. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49687. * * 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
  49688. * * 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
  49689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49690. * @param name defines the name of the mesh
  49691. * @param options defines the options used to create the mesh
  49692. * @param scene defines the hosting scene
  49693. * @returns the tiled ground mesh
  49694. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49695. */
  49696. static CreateTiledGround(name: string, options: {
  49697. xmin: number;
  49698. zmin: number;
  49699. xmax: number;
  49700. zmax: number;
  49701. subdivisions?: {
  49702. w: number;
  49703. h: number;
  49704. };
  49705. precision?: {
  49706. w: number;
  49707. h: number;
  49708. };
  49709. updatable?: boolean;
  49710. }, scene?: Nullable<Scene>): Mesh;
  49711. /**
  49712. * Creates a ground mesh from a height map
  49713. * * The parameter `url` sets the URL of the height map image resource.
  49714. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49715. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49716. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49717. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49718. * * 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.
  49719. * * 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).
  49720. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49722. * @param name defines the name of the mesh
  49723. * @param url defines the url to the height map
  49724. * @param options defines the options used to create the mesh
  49725. * @param scene defines the hosting scene
  49726. * @returns the ground mesh
  49727. * @see https://doc.babylonjs.com/babylon101/height_map
  49728. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49729. */
  49730. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49731. width?: number;
  49732. height?: number;
  49733. subdivisions?: number;
  49734. minHeight?: number;
  49735. maxHeight?: number;
  49736. colorFilter?: Color3;
  49737. alphaFilter?: number;
  49738. updatable?: boolean;
  49739. onReady?: (mesh: GroundMesh) => void;
  49740. }, scene?: Nullable<Scene>): GroundMesh;
  49741. }
  49742. }
  49743. declare module BABYLON {
  49744. /**
  49745. * Class containing static functions to help procedurally build meshes
  49746. */
  49747. export class TorusBuilder {
  49748. /**
  49749. * Creates a torus mesh
  49750. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49751. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49752. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49754. * * 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
  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 options defines the options used to create the mesh
  49758. * @param scene defines the hosting scene
  49759. * @returns the torus mesh
  49760. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49761. */
  49762. static CreateTorus(name: string, options: {
  49763. diameter?: number;
  49764. thickness?: number;
  49765. tessellation?: number;
  49766. updatable?: boolean;
  49767. sideOrientation?: number;
  49768. frontUVs?: Vector4;
  49769. backUVs?: Vector4;
  49770. }, scene: any): Mesh;
  49771. }
  49772. }
  49773. declare module BABYLON {
  49774. /**
  49775. * Class containing static functions to help procedurally build meshes
  49776. */
  49777. export class CylinderBuilder {
  49778. /**
  49779. * Creates a cylinder or a cone mesh
  49780. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49781. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49782. * * 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.
  49783. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49784. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49785. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49786. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49787. * * 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).
  49788. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49789. * * 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).
  49790. * * 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
  49791. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49792. * * 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
  49793. * * 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.
  49794. * * If `enclose` is false, a ring surface is one element.
  49795. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49796. * * 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
  49797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49798. * * 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
  49799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49800. * @param name defines the name of the mesh
  49801. * @param options defines the options used to create the mesh
  49802. * @param scene defines the hosting scene
  49803. * @returns the cylinder mesh
  49804. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49805. */
  49806. static CreateCylinder(name: string, options: {
  49807. height?: number;
  49808. diameterTop?: number;
  49809. diameterBottom?: number;
  49810. diameter?: number;
  49811. tessellation?: number;
  49812. subdivisions?: number;
  49813. arc?: number;
  49814. faceColors?: Color4[];
  49815. faceUV?: Vector4[];
  49816. updatable?: boolean;
  49817. hasRings?: boolean;
  49818. enclose?: boolean;
  49819. cap?: number;
  49820. sideOrientation?: number;
  49821. frontUVs?: Vector4;
  49822. backUVs?: Vector4;
  49823. }, scene: any): Mesh;
  49824. }
  49825. }
  49826. declare module BABYLON {
  49827. /**
  49828. * States of the webXR experience
  49829. */
  49830. export enum WebXRState {
  49831. /**
  49832. * Transitioning to being in XR mode
  49833. */
  49834. ENTERING_XR = 0,
  49835. /**
  49836. * Transitioning to non XR mode
  49837. */
  49838. EXITING_XR = 1,
  49839. /**
  49840. * In XR mode and presenting
  49841. */
  49842. IN_XR = 2,
  49843. /**
  49844. * Not entered XR mode
  49845. */
  49846. NOT_IN_XR = 3
  49847. }
  49848. /**
  49849. * Abstraction of the XR render target
  49850. */
  49851. export interface WebXRRenderTarget extends IDisposable {
  49852. /**
  49853. * xrpresent context of the canvas which can be used to display/mirror xr content
  49854. */
  49855. canvasContext: WebGLRenderingContext;
  49856. /**
  49857. * xr layer for the canvas
  49858. */
  49859. xrLayer: Nullable<XRWebGLLayer>;
  49860. /**
  49861. * Initializes the xr layer for the session
  49862. * @param xrSession xr session
  49863. * @returns a promise that will resolve once the XR Layer has been created
  49864. */
  49865. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  49866. }
  49867. }
  49868. declare module BABYLON {
  49869. /**
  49870. * COnfiguration object for WebXR output canvas
  49871. */
  49872. export class WebXRManagedOutputCanvasOptions {
  49873. /**
  49874. * An optional canvas in case you wish to create it yourself and provide it here.
  49875. * If not provided, a new canvas will be created
  49876. */
  49877. canvasElement?: HTMLCanvasElement;
  49878. /**
  49879. * Options for this XR Layer output
  49880. */
  49881. canvasOptions?: XRWebGLLayerOptions;
  49882. /**
  49883. * CSS styling for a newly created canvas (if not provided)
  49884. */
  49885. newCanvasCssStyle?: string;
  49886. /**
  49887. * Get the default values of the configuration object
  49888. * @param engine defines the engine to use (can be null)
  49889. * @returns default values of this configuration object
  49890. */
  49891. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  49892. }
  49893. /**
  49894. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  49895. */
  49896. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  49897. private _options;
  49898. private _canvas;
  49899. private _engine;
  49900. private _originalCanvasSize;
  49901. /**
  49902. * Rendering context of the canvas which can be used to display/mirror xr content
  49903. */
  49904. canvasContext: WebGLRenderingContext;
  49905. /**
  49906. * xr layer for the canvas
  49907. */
  49908. xrLayer: Nullable<XRWebGLLayer>;
  49909. /**
  49910. * Obseervers registered here will be triggered when the xr layer was initialized
  49911. */
  49912. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  49913. /**
  49914. * Initializes the canvas to be added/removed upon entering/exiting xr
  49915. * @param _xrSessionManager The XR Session manager
  49916. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  49917. */
  49918. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  49919. /**
  49920. * Disposes of the object
  49921. */
  49922. dispose(): void;
  49923. /**
  49924. * Initializes the xr layer for the session
  49925. * @param xrSession xr session
  49926. * @returns a promise that will resolve once the XR Layer has been created
  49927. */
  49928. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  49929. private _addCanvas;
  49930. private _removeCanvas;
  49931. private _setCanvasSize;
  49932. private _setManagedOutputCanvas;
  49933. }
  49934. }
  49935. declare module BABYLON {
  49936. /**
  49937. * Manages an XRSession to work with Babylon's engine
  49938. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  49939. */
  49940. export class WebXRSessionManager implements IDisposable {
  49941. /** The scene which the session should be created for */
  49942. scene: Scene;
  49943. private _referenceSpace;
  49944. private _rttProvider;
  49945. private _sessionEnded;
  49946. private _xrNavigator;
  49947. private baseLayer;
  49948. /**
  49949. * The base reference space from which the session started. good if you want to reset your
  49950. * reference space
  49951. */
  49952. baseReferenceSpace: XRReferenceSpace;
  49953. /**
  49954. * Current XR frame
  49955. */
  49956. currentFrame: Nullable<XRFrame>;
  49957. /** WebXR timestamp updated every frame */
  49958. currentTimestamp: number;
  49959. /**
  49960. * Used just in case of a failure to initialize an immersive session.
  49961. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  49962. */
  49963. defaultHeightCompensation: number;
  49964. /**
  49965. * Fires every time a new xrFrame arrives which can be used to update the camera
  49966. */
  49967. onXRFrameObservable: Observable<XRFrame>;
  49968. /**
  49969. * Fires when the reference space changed
  49970. */
  49971. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  49972. /**
  49973. * Fires when the xr session is ended either by the device or manually done
  49974. */
  49975. onXRSessionEnded: Observable<any>;
  49976. /**
  49977. * Fires when the xr session is ended either by the device or manually done
  49978. */
  49979. onXRSessionInit: Observable<XRSession>;
  49980. /**
  49981. * Underlying xr session
  49982. */
  49983. session: XRSession;
  49984. /**
  49985. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  49986. * or get the offset the player is currently at.
  49987. */
  49988. viewerReferenceSpace: XRReferenceSpace;
  49989. /**
  49990. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  49991. * @param scene The scene which the session should be created for
  49992. */
  49993. constructor(
  49994. /** The scene which the session should be created for */
  49995. scene: Scene);
  49996. /**
  49997. * The current reference space used in this session. This reference space can constantly change!
  49998. * It is mainly used to offset the camera's position.
  49999. */
  50000. get referenceSpace(): XRReferenceSpace;
  50001. /**
  50002. * Set a new reference space and triggers the observable
  50003. */
  50004. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50005. /**
  50006. * Disposes of the session manager
  50007. */
  50008. dispose(): void;
  50009. /**
  50010. * Stops the xrSession and restores the render loop
  50011. * @returns Promise which resolves after it exits XR
  50012. */
  50013. exitXRAsync(): Promise<void>;
  50014. /**
  50015. * Gets the correct render target texture to be rendered this frame for this eye
  50016. * @param eye the eye for which to get the render target
  50017. * @returns the render target for the specified eye
  50018. */
  50019. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50020. /**
  50021. * Creates a WebXRRenderTarget object for the XR session
  50022. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50023. * @param options optional options to provide when creating a new render target
  50024. * @returns a WebXR render target to which the session can render
  50025. */
  50026. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50027. /**
  50028. * Initializes the manager
  50029. * After initialization enterXR can be called to start an XR session
  50030. * @returns Promise which resolves after it is initialized
  50031. */
  50032. initializeAsync(): Promise<void>;
  50033. /**
  50034. * Initializes an xr session
  50035. * @param xrSessionMode mode to initialize
  50036. * @param xrSessionInit defines optional and required values to pass to the session builder
  50037. * @returns a promise which will resolve once the session has been initialized
  50038. */
  50039. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50040. /**
  50041. * Checks if a session would be supported for the creation options specified
  50042. * @param sessionMode session mode to check if supported eg. immersive-vr
  50043. * @returns A Promise that resolves to true if supported and false if not
  50044. */
  50045. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50046. /**
  50047. * Resets the reference space to the one started the session
  50048. */
  50049. resetReferenceSpace(): void;
  50050. /**
  50051. * Starts rendering to the xr layer
  50052. */
  50053. runXRRenderLoop(): void;
  50054. /**
  50055. * Sets the reference space on the xr session
  50056. * @param referenceSpaceType space to set
  50057. * @returns a promise that will resolve once the reference space has been set
  50058. */
  50059. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50060. /**
  50061. * Updates the render state of the session
  50062. * @param state state to set
  50063. * @returns a promise that resolves once the render state has been updated
  50064. */
  50065. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50066. /**
  50067. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50068. * @param sessionMode defines the session to test
  50069. * @returns a promise with boolean as final value
  50070. */
  50071. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50072. private _createRenderTargetTexture;
  50073. }
  50074. }
  50075. declare module BABYLON {
  50076. /**
  50077. * WebXR Camera which holds the views for the xrSession
  50078. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50079. */
  50080. export class WebXRCamera extends FreeCamera {
  50081. private _xrSessionManager;
  50082. private _firstFrame;
  50083. private _referenceQuaternion;
  50084. private _referencedPosition;
  50085. private _xrInvPositionCache;
  50086. private _xrInvQuaternionCache;
  50087. /**
  50088. * Observable raised before camera teleportation
  50089. */
  50090. onBeforeCameraTeleport: Observable<Vector3>;
  50091. /**
  50092. * Observable raised after camera teleportation
  50093. */
  50094. onAfterCameraTeleport: Observable<Vector3>;
  50095. /**
  50096. * Should position compensation execute on first frame.
  50097. * This is used when copying the position from a native (non XR) camera
  50098. */
  50099. compensateOnFirstFrame: boolean;
  50100. /**
  50101. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50102. * @param name the name of the camera
  50103. * @param scene the scene to add the camera to
  50104. * @param _xrSessionManager a constructed xr session manager
  50105. */
  50106. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50107. /**
  50108. * Return the user's height, unrelated to the current ground.
  50109. * This will be the y position of this camera, when ground level is 0.
  50110. */
  50111. get realWorldHeight(): number;
  50112. /** @hidden */
  50113. _updateForDualEyeDebugging(): void;
  50114. /**
  50115. * Sets this camera's transformation based on a non-vr camera
  50116. * @param otherCamera the non-vr camera to copy the transformation from
  50117. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50118. */
  50119. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50120. /**
  50121. * Gets the current instance class name ("WebXRCamera").
  50122. * @returns the class name
  50123. */
  50124. getClassName(): string;
  50125. private _rotate180;
  50126. private _updateFromXRSession;
  50127. private _updateNumberOfRigCameras;
  50128. private _updateReferenceSpace;
  50129. private _updateReferenceSpaceOffset;
  50130. }
  50131. }
  50132. declare module BABYLON {
  50133. /**
  50134. * Defining the interface required for a (webxr) feature
  50135. */
  50136. export interface IWebXRFeature extends IDisposable {
  50137. /**
  50138. * Is this feature attached
  50139. */
  50140. attached: boolean;
  50141. /**
  50142. * Should auto-attach be disabled?
  50143. */
  50144. disableAutoAttach: boolean;
  50145. /**
  50146. * Attach the feature to the session
  50147. * Will usually be called by the features manager
  50148. *
  50149. * @param force should attachment be forced (even when already attached)
  50150. * @returns true if successful.
  50151. */
  50152. attach(force?: boolean): boolean;
  50153. /**
  50154. * Detach the feature from the session
  50155. * Will usually be called by the features manager
  50156. *
  50157. * @returns true if successful.
  50158. */
  50159. detach(): boolean;
  50160. /**
  50161. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50162. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50163. *
  50164. * @returns whether or not the feature is compatible in this environment
  50165. */
  50166. isCompatible(): boolean;
  50167. /**
  50168. * Was this feature disposed;
  50169. */
  50170. isDisposed: boolean;
  50171. /**
  50172. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50173. */
  50174. xrNativeFeatureName?: string;
  50175. /**
  50176. * A list of (Babylon WebXR) features this feature depends on
  50177. */
  50178. dependsOn?: string[];
  50179. }
  50180. /**
  50181. * A list of the currently available features without referencing them
  50182. */
  50183. export class WebXRFeatureName {
  50184. /**
  50185. * The name of the anchor system feature
  50186. */
  50187. static readonly ANCHOR_SYSTEM: string;
  50188. /**
  50189. * The name of the background remover feature
  50190. */
  50191. static readonly BACKGROUND_REMOVER: string;
  50192. /**
  50193. * The name of the hit test feature
  50194. */
  50195. static readonly HIT_TEST: string;
  50196. /**
  50197. * physics impostors for xr controllers feature
  50198. */
  50199. static readonly PHYSICS_CONTROLLERS: string;
  50200. /**
  50201. * The name of the plane detection feature
  50202. */
  50203. static readonly PLANE_DETECTION: string;
  50204. /**
  50205. * The name of the pointer selection feature
  50206. */
  50207. static readonly POINTER_SELECTION: string;
  50208. /**
  50209. * The name of the teleportation feature
  50210. */
  50211. static readonly TELEPORTATION: string;
  50212. /**
  50213. * The name of the feature points feature.
  50214. */
  50215. static readonly FEATURE_POINTS: string;
  50216. /**
  50217. * The name of the hand tracking feature.
  50218. */
  50219. static readonly HAND_TRACKING: string;
  50220. }
  50221. /**
  50222. * Defining the constructor of a feature. Used to register the modules.
  50223. */
  50224. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50225. /**
  50226. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50227. * It is mainly used in AR sessions.
  50228. *
  50229. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50230. */
  50231. export class WebXRFeaturesManager implements IDisposable {
  50232. private _xrSessionManager;
  50233. private static readonly _AvailableFeatures;
  50234. private _features;
  50235. /**
  50236. * constructs a new features manages.
  50237. *
  50238. * @param _xrSessionManager an instance of WebXRSessionManager
  50239. */
  50240. constructor(_xrSessionManager: WebXRSessionManager);
  50241. /**
  50242. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50243. * Mainly used internally.
  50244. *
  50245. * @param featureName the name of the feature to register
  50246. * @param constructorFunction the function used to construct the module
  50247. * @param version the (babylon) version of the module
  50248. * @param stable is that a stable version of this module
  50249. */
  50250. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50251. /**
  50252. * Returns a constructor of a specific feature.
  50253. *
  50254. * @param featureName the name of the feature to construct
  50255. * @param version the version of the feature to load
  50256. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50257. * @param options optional options provided to the module.
  50258. * @returns a function that, when called, will return a new instance of this feature
  50259. */
  50260. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50261. /**
  50262. * Can be used to return the list of features currently registered
  50263. *
  50264. * @returns an Array of available features
  50265. */
  50266. static GetAvailableFeatures(): string[];
  50267. /**
  50268. * Gets the versions available for a specific feature
  50269. * @param featureName the name of the feature
  50270. * @returns an array with the available versions
  50271. */
  50272. static GetAvailableVersions(featureName: string): string[];
  50273. /**
  50274. * Return the latest unstable version of this feature
  50275. * @param featureName the name of the feature to search
  50276. * @returns the version number. if not found will return -1
  50277. */
  50278. static GetLatestVersionOfFeature(featureName: string): number;
  50279. /**
  50280. * Return the latest stable version of this feature
  50281. * @param featureName the name of the feature to search
  50282. * @returns the version number. if not found will return -1
  50283. */
  50284. static GetStableVersionOfFeature(featureName: string): number;
  50285. /**
  50286. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50287. * Can be used during a session to start a feature
  50288. * @param featureName the name of feature to attach
  50289. */
  50290. attachFeature(featureName: string): void;
  50291. /**
  50292. * Can be used inside a session or when the session ends to detach a specific feature
  50293. * @param featureName the name of the feature to detach
  50294. */
  50295. detachFeature(featureName: string): void;
  50296. /**
  50297. * Used to disable an already-enabled feature
  50298. * The feature will be disposed and will be recreated once enabled.
  50299. * @param featureName the feature to disable
  50300. * @returns true if disable was successful
  50301. */
  50302. disableFeature(featureName: string | {
  50303. Name: string;
  50304. }): boolean;
  50305. /**
  50306. * dispose this features manager
  50307. */
  50308. dispose(): void;
  50309. /**
  50310. * 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.
  50311. * 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.
  50312. *
  50313. * @param featureName the name of the feature to load or the class of the feature
  50314. * @param version optional version to load. if not provided the latest version will be enabled
  50315. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50316. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50317. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50318. * @returns a new constructed feature or throws an error if feature not found.
  50319. */
  50320. enableFeature(featureName: string | {
  50321. Name: string;
  50322. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50323. /**
  50324. * get the implementation of an enabled feature.
  50325. * @param featureName the name of the feature to load
  50326. * @returns the feature class, if found
  50327. */
  50328. getEnabledFeature(featureName: string): IWebXRFeature;
  50329. /**
  50330. * Get the list of enabled features
  50331. * @returns an array of enabled features
  50332. */
  50333. getEnabledFeatures(): string[];
  50334. /**
  50335. * This function will exten the session creation configuration object with enabled features.
  50336. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50337. * according to the defined "required" variable, provided during enableFeature call
  50338. * @param xrSessionInit the xr Session init object to extend
  50339. *
  50340. * @returns an extended XRSessionInit object
  50341. */
  50342. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50343. }
  50344. }
  50345. declare module BABYLON {
  50346. /**
  50347. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50348. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50349. */
  50350. export class WebXRExperienceHelper implements IDisposable {
  50351. private scene;
  50352. private _nonVRCamera;
  50353. private _originalSceneAutoClear;
  50354. private _supported;
  50355. /**
  50356. * Camera used to render xr content
  50357. */
  50358. camera: WebXRCamera;
  50359. /** A features manager for this xr session */
  50360. featuresManager: WebXRFeaturesManager;
  50361. /**
  50362. * Observers registered here will be triggered after the camera's initial transformation is set
  50363. * This can be used to set a different ground level or an extra rotation.
  50364. *
  50365. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50366. * to the position set after this observable is done executing.
  50367. */
  50368. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50369. /**
  50370. * Fires when the state of the experience helper has changed
  50371. */
  50372. onStateChangedObservable: Observable<WebXRState>;
  50373. /** Session manager used to keep track of xr session */
  50374. sessionManager: WebXRSessionManager;
  50375. /**
  50376. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50377. */
  50378. state: WebXRState;
  50379. /**
  50380. * Creates a WebXRExperienceHelper
  50381. * @param scene The scene the helper should be created in
  50382. */
  50383. private constructor();
  50384. /**
  50385. * Creates the experience helper
  50386. * @param scene the scene to attach the experience helper to
  50387. * @returns a promise for the experience helper
  50388. */
  50389. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50390. /**
  50391. * Disposes of the experience helper
  50392. */
  50393. dispose(): void;
  50394. /**
  50395. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50396. * @param sessionMode options for the XR session
  50397. * @param referenceSpaceType frame of reference of the XR session
  50398. * @param renderTarget the output canvas that will be used to enter XR mode
  50399. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50400. * @returns promise that resolves after xr mode has entered
  50401. */
  50402. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50403. /**
  50404. * Exits XR mode and returns the scene to its original state
  50405. * @returns promise that resolves after xr mode has exited
  50406. */
  50407. exitXRAsync(): Promise<void>;
  50408. private _nonXRToXRCamera;
  50409. private _setState;
  50410. }
  50411. }
  50412. declare module BABYLON {
  50413. /**
  50414. * X-Y values for axes in WebXR
  50415. */
  50416. export interface IWebXRMotionControllerAxesValue {
  50417. /**
  50418. * The value of the x axis
  50419. */
  50420. x: number;
  50421. /**
  50422. * The value of the y-axis
  50423. */
  50424. y: number;
  50425. }
  50426. /**
  50427. * changed / previous values for the values of this component
  50428. */
  50429. export interface IWebXRMotionControllerComponentChangesValues<T> {
  50430. /**
  50431. * current (this frame) value
  50432. */
  50433. current: T;
  50434. /**
  50435. * previous (last change) value
  50436. */
  50437. previous: T;
  50438. }
  50439. /**
  50440. * Represents changes in the component between current frame and last values recorded
  50441. */
  50442. export interface IWebXRMotionControllerComponentChanges {
  50443. /**
  50444. * will be populated with previous and current values if axes changed
  50445. */
  50446. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  50447. /**
  50448. * will be populated with previous and current values if pressed changed
  50449. */
  50450. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50451. /**
  50452. * will be populated with previous and current values if touched changed
  50453. */
  50454. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50455. /**
  50456. * will be populated with previous and current values if value changed
  50457. */
  50458. value?: IWebXRMotionControllerComponentChangesValues<number>;
  50459. }
  50460. /**
  50461. * This class represents a single component (for example button or thumbstick) of a motion controller
  50462. */
  50463. export class WebXRControllerComponent implements IDisposable {
  50464. /**
  50465. * the id of this component
  50466. */
  50467. id: string;
  50468. /**
  50469. * the type of the component
  50470. */
  50471. type: MotionControllerComponentType;
  50472. private _buttonIndex;
  50473. private _axesIndices;
  50474. private _axes;
  50475. private _changes;
  50476. private _currentValue;
  50477. private _hasChanges;
  50478. private _pressed;
  50479. private _touched;
  50480. /**
  50481. * button component type
  50482. */
  50483. static BUTTON_TYPE: MotionControllerComponentType;
  50484. /**
  50485. * squeeze component type
  50486. */
  50487. static SQUEEZE_TYPE: MotionControllerComponentType;
  50488. /**
  50489. * Thumbstick component type
  50490. */
  50491. static THUMBSTICK_TYPE: MotionControllerComponentType;
  50492. /**
  50493. * Touchpad component type
  50494. */
  50495. static TOUCHPAD_TYPE: MotionControllerComponentType;
  50496. /**
  50497. * trigger component type
  50498. */
  50499. static TRIGGER_TYPE: MotionControllerComponentType;
  50500. /**
  50501. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  50502. * the axes data changes
  50503. */
  50504. onAxisValueChangedObservable: Observable<{
  50505. x: number;
  50506. y: number;
  50507. }>;
  50508. /**
  50509. * Observers registered here will be triggered when the state of a button changes
  50510. * State change is either pressed / touched / value
  50511. */
  50512. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  50513. /**
  50514. * Creates a new component for a motion controller.
  50515. * It is created by the motion controller itself
  50516. *
  50517. * @param id the id of this component
  50518. * @param type the type of the component
  50519. * @param _buttonIndex index in the buttons array of the gamepad
  50520. * @param _axesIndices indices of the values in the axes array of the gamepad
  50521. */
  50522. constructor(
  50523. /**
  50524. * the id of this component
  50525. */
  50526. id: string,
  50527. /**
  50528. * the type of the component
  50529. */
  50530. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  50531. /**
  50532. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  50533. */
  50534. get axes(): IWebXRMotionControllerAxesValue;
  50535. /**
  50536. * Get the changes. Elements will be populated only if they changed with their previous and current value
  50537. */
  50538. get changes(): IWebXRMotionControllerComponentChanges;
  50539. /**
  50540. * Return whether or not the component changed the last frame
  50541. */
  50542. get hasChanges(): boolean;
  50543. /**
  50544. * is the button currently pressed
  50545. */
  50546. get pressed(): boolean;
  50547. /**
  50548. * is the button currently touched
  50549. */
  50550. get touched(): boolean;
  50551. /**
  50552. * Get the current value of this component
  50553. */
  50554. get value(): number;
  50555. /**
  50556. * Dispose this component
  50557. */
  50558. dispose(): void;
  50559. /**
  50560. * Are there axes correlating to this component
  50561. * @return true is axes data is available
  50562. */
  50563. isAxes(): boolean;
  50564. /**
  50565. * Is this component a button (hence - pressable)
  50566. * @returns true if can be pressed
  50567. */
  50568. isButton(): boolean;
  50569. /**
  50570. * update this component using the gamepad object it is in. Called on every frame
  50571. * @param nativeController the native gamepad controller object
  50572. */
  50573. update(nativeController: IMinimalMotionControllerObject): void;
  50574. }
  50575. }
  50576. declare module BABYLON {
  50577. /**
  50578. * Interface used to represent data loading progression
  50579. */
  50580. export interface ISceneLoaderProgressEvent {
  50581. /**
  50582. * Defines if data length to load can be evaluated
  50583. */
  50584. readonly lengthComputable: boolean;
  50585. /**
  50586. * Defines the loaded data length
  50587. */
  50588. readonly loaded: number;
  50589. /**
  50590. * Defines the data length to load
  50591. */
  50592. readonly total: number;
  50593. }
  50594. /**
  50595. * Interface used by SceneLoader plugins to define supported file extensions
  50596. */
  50597. export interface ISceneLoaderPluginExtensions {
  50598. /**
  50599. * Defines the list of supported extensions
  50600. */
  50601. [extension: string]: {
  50602. isBinary: boolean;
  50603. };
  50604. }
  50605. /**
  50606. * Interface used by SceneLoader plugin factory
  50607. */
  50608. export interface ISceneLoaderPluginFactory {
  50609. /**
  50610. * Defines the name of the factory
  50611. */
  50612. name: string;
  50613. /**
  50614. * Function called to create a new plugin
  50615. * @return the new plugin
  50616. */
  50617. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  50618. /**
  50619. * The callback that returns true if the data can be directly loaded.
  50620. * @param data string containing the file data
  50621. * @returns if the data can be loaded directly
  50622. */
  50623. canDirectLoad?(data: string): boolean;
  50624. }
  50625. /**
  50626. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  50627. */
  50628. export interface ISceneLoaderPluginBase {
  50629. /**
  50630. * The friendly name of this plugin.
  50631. */
  50632. name: string;
  50633. /**
  50634. * The file extensions supported by this plugin.
  50635. */
  50636. extensions: string | ISceneLoaderPluginExtensions;
  50637. /**
  50638. * The callback called when loading from a url.
  50639. * @param scene scene loading this url
  50640. * @param url url to load
  50641. * @param onSuccess callback called when the file successfully loads
  50642. * @param onProgress callback called while file is loading (if the server supports this mode)
  50643. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  50644. * @param onError callback called when the file fails to load
  50645. * @returns a file request object
  50646. */
  50647. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50648. /**
  50649. * The callback called when loading from a file object.
  50650. * @param scene scene loading this file
  50651. * @param file defines the file to load
  50652. * @param onSuccess defines the callback to call when data is loaded
  50653. * @param onProgress defines the callback to call during loading process
  50654. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  50655. * @param onError defines the callback to call when an error occurs
  50656. * @returns a file request object
  50657. */
  50658. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50659. /**
  50660. * The callback that returns true if the data can be directly loaded.
  50661. * @param data string containing the file data
  50662. * @returns if the data can be loaded directly
  50663. */
  50664. canDirectLoad?(data: string): boolean;
  50665. /**
  50666. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  50667. * @param scene scene loading this data
  50668. * @param data string containing the data
  50669. * @returns data to pass to the plugin
  50670. */
  50671. directLoad?(scene: Scene, data: string): any;
  50672. /**
  50673. * The callback that allows custom handling of the root url based on the response url.
  50674. * @param rootUrl the original root url
  50675. * @param responseURL the response url if available
  50676. * @returns the new root url
  50677. */
  50678. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  50679. }
  50680. /**
  50681. * Interface used to define a SceneLoader plugin
  50682. */
  50683. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  50684. /**
  50685. * Import meshes into a scene.
  50686. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50687. * @param scene The scene to import into
  50688. * @param data The data to import
  50689. * @param rootUrl The root url for scene and resources
  50690. * @param meshes The meshes array to import into
  50691. * @param particleSystems The particle systems array to import into
  50692. * @param skeletons The skeletons array to import into
  50693. * @param onError The callback when import fails
  50694. * @returns True if successful or false otherwise
  50695. */
  50696. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  50697. /**
  50698. * Load into a scene.
  50699. * @param scene The scene to load into
  50700. * @param data The data to import
  50701. * @param rootUrl The root url for scene and resources
  50702. * @param onError The callback when import fails
  50703. * @returns True if successful or false otherwise
  50704. */
  50705. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  50706. /**
  50707. * Load into an asset container.
  50708. * @param scene The scene to load into
  50709. * @param data The data to import
  50710. * @param rootUrl The root url for scene and resources
  50711. * @param onError The callback when import fails
  50712. * @returns The loaded asset container
  50713. */
  50714. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  50715. }
  50716. /**
  50717. * Interface used to define an async SceneLoader plugin
  50718. */
  50719. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  50720. /**
  50721. * Import meshes into a scene.
  50722. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50723. * @param scene The scene to import into
  50724. * @param data The data to import
  50725. * @param rootUrl The root url for scene and resources
  50726. * @param onProgress The callback when the load progresses
  50727. * @param fileName Defines the name of the file to load
  50728. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  50729. */
  50730. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  50731. meshes: AbstractMesh[];
  50732. particleSystems: IParticleSystem[];
  50733. skeletons: Skeleton[];
  50734. animationGroups: AnimationGroup[];
  50735. }>;
  50736. /**
  50737. * Load into a scene.
  50738. * @param scene The scene to load into
  50739. * @param data The data to import
  50740. * @param rootUrl The root url for scene and resources
  50741. * @param onProgress The callback when the load progresses
  50742. * @param fileName Defines the name of the file to load
  50743. * @returns Nothing
  50744. */
  50745. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  50746. /**
  50747. * Load into an asset container.
  50748. * @param scene The scene to load into
  50749. * @param data The data to import
  50750. * @param rootUrl The root url for scene and resources
  50751. * @param onProgress The callback when the load progresses
  50752. * @param fileName Defines the name of the file to load
  50753. * @returns The loaded asset container
  50754. */
  50755. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  50756. }
  50757. /**
  50758. * Mode that determines how to handle old animation groups before loading new ones.
  50759. */
  50760. export enum SceneLoaderAnimationGroupLoadingMode {
  50761. /**
  50762. * Reset all old animations to initial state then dispose them.
  50763. */
  50764. Clean = 0,
  50765. /**
  50766. * Stop all old animations.
  50767. */
  50768. Stop = 1,
  50769. /**
  50770. * Restart old animations from first frame.
  50771. */
  50772. Sync = 2,
  50773. /**
  50774. * Old animations remains untouched.
  50775. */
  50776. NoSync = 3
  50777. }
  50778. /**
  50779. * Defines a plugin registered by the SceneLoader
  50780. */
  50781. interface IRegisteredPlugin {
  50782. /**
  50783. * Defines the plugin to use
  50784. */
  50785. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  50786. /**
  50787. * Defines if the plugin supports binary data
  50788. */
  50789. isBinary: boolean;
  50790. }
  50791. /**
  50792. * Class used to load scene from various file formats using registered plugins
  50793. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  50794. */
  50795. export class SceneLoader {
  50796. /**
  50797. * No logging while loading
  50798. */
  50799. static readonly NO_LOGGING: number;
  50800. /**
  50801. * Minimal logging while loading
  50802. */
  50803. static readonly MINIMAL_LOGGING: number;
  50804. /**
  50805. * Summary logging while loading
  50806. */
  50807. static readonly SUMMARY_LOGGING: number;
  50808. /**
  50809. * Detailled logging while loading
  50810. */
  50811. static readonly DETAILED_LOGGING: number;
  50812. /**
  50813. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  50814. */
  50815. static get ForceFullSceneLoadingForIncremental(): boolean;
  50816. static set ForceFullSceneLoadingForIncremental(value: boolean);
  50817. /**
  50818. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  50819. */
  50820. static get ShowLoadingScreen(): boolean;
  50821. static set ShowLoadingScreen(value: boolean);
  50822. /**
  50823. * Defines the current logging level (while loading the scene)
  50824. * @ignorenaming
  50825. */
  50826. static get loggingLevel(): number;
  50827. static set loggingLevel(value: number);
  50828. /**
  50829. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  50830. */
  50831. static get CleanBoneMatrixWeights(): boolean;
  50832. static set CleanBoneMatrixWeights(value: boolean);
  50833. /**
  50834. * Event raised when a plugin is used to load a scene
  50835. */
  50836. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  50837. private static _registeredPlugins;
  50838. private static _showingLoadingScreen;
  50839. /**
  50840. * Gets the default plugin (used to load Babylon files)
  50841. * @returns the .babylon plugin
  50842. */
  50843. static GetDefaultPlugin(): IRegisteredPlugin;
  50844. private static _GetPluginForExtension;
  50845. private static _GetPluginForDirectLoad;
  50846. private static _GetPluginForFilename;
  50847. private static _GetDirectLoad;
  50848. private static _LoadData;
  50849. private static _GetFileInfo;
  50850. /**
  50851. * Gets a plugin that can load the given extension
  50852. * @param extension defines the extension to load
  50853. * @returns a plugin or null if none works
  50854. */
  50855. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  50856. /**
  50857. * Gets a boolean indicating that the given extension can be loaded
  50858. * @param extension defines the extension to load
  50859. * @returns true if the extension is supported
  50860. */
  50861. static IsPluginForExtensionAvailable(extension: string): boolean;
  50862. /**
  50863. * Adds a new plugin to the list of registered plugins
  50864. * @param plugin defines the plugin to add
  50865. */
  50866. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  50867. /**
  50868. * Import meshes into a scene
  50869. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50870. * @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)
  50871. * @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)
  50872. * @param scene the instance of BABYLON.Scene to append to
  50873. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  50874. * @param onProgress a callback with a progress event for each file being loaded
  50875. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50876. * @param pluginExtension the extension used to determine the plugin
  50877. * @returns The loaded plugin
  50878. */
  50879. 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>;
  50880. /**
  50881. * Import meshes into a scene
  50882. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50883. * @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)
  50884. * @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)
  50885. * @param scene the instance of BABYLON.Scene to append to
  50886. * @param onProgress a callback with a progress event for each file being loaded
  50887. * @param pluginExtension the extension used to determine the plugin
  50888. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  50889. */
  50890. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  50891. meshes: AbstractMesh[];
  50892. particleSystems: IParticleSystem[];
  50893. skeletons: Skeleton[];
  50894. animationGroups: AnimationGroup[];
  50895. }>;
  50896. /**
  50897. * Load a scene
  50898. * @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)
  50899. * @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)
  50900. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50901. * @param onSuccess a callback with the scene when import succeeds
  50902. * @param onProgress a callback with a progress event for each file being loaded
  50903. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50904. * @param pluginExtension the extension used to determine the plugin
  50905. * @returns The loaded plugin
  50906. */
  50907. 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>;
  50908. /**
  50909. * Load a scene
  50910. * @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)
  50911. * @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)
  50912. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50913. * @param onProgress a callback with a progress event for each file being loaded
  50914. * @param pluginExtension the extension used to determine the plugin
  50915. * @returns The loaded scene
  50916. */
  50917. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  50918. /**
  50919. * Append a scene
  50920. * @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)
  50921. * @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)
  50922. * @param scene is the instance of BABYLON.Scene to append to
  50923. * @param onSuccess a callback with the scene when import succeeds
  50924. * @param onProgress a callback with a progress event for each file being loaded
  50925. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50926. * @param pluginExtension the extension used to determine the plugin
  50927. * @returns The loaded plugin
  50928. */
  50929. 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>;
  50930. /**
  50931. * Append a scene
  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 is the instance of BABYLON.Scene to append to
  50935. * @param onProgress a callback with a progress event for each file being loaded
  50936. * @param pluginExtension the extension used to determine the plugin
  50937. * @returns The given scene
  50938. */
  50939. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  50940. /**
  50941. * Load a scene into an asset container
  50942. * @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)
  50943. * @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)
  50944. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  50945. * @param onSuccess a callback with the scene when import succeeds
  50946. * @param onProgress a callback with a progress event for each file being loaded
  50947. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50948. * @param pluginExtension the extension used to determine the plugin
  50949. * @returns The loaded plugin
  50950. */
  50951. 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>;
  50952. /**
  50953. * Load a scene into an asset container
  50954. * @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)
  50955. * @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)
  50956. * @param scene is the instance of Scene to append to
  50957. * @param onProgress a callback with a progress event for each file being loaded
  50958. * @param pluginExtension the extension used to determine the plugin
  50959. * @returns The loaded asset container
  50960. */
  50961. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  50962. /**
  50963. * Import animations from a file into a scene
  50964. * @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)
  50965. * @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)
  50966. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  50967. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  50968. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  50969. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  50970. * @param onSuccess a callback with the scene when import succeeds
  50971. * @param onProgress a callback with a progress event for each file being loaded
  50972. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50973. * @param pluginExtension the extension used to determine the plugin
  50974. */
  50975. 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;
  50976. /**
  50977. * Import animations from a file into a scene
  50978. * @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)
  50979. * @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)
  50980. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  50981. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  50982. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  50983. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  50984. * @param onSuccess a callback with the scene when import succeeds
  50985. * @param onProgress a callback with a progress event for each file being loaded
  50986. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50987. * @param pluginExtension the extension used to determine the plugin
  50988. * @returns the updated scene with imported animations
  50989. */
  50990. 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>;
  50991. }
  50992. }
  50993. declare module BABYLON {
  50994. /**
  50995. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  50996. */
  50997. export type MotionControllerHandedness = "none" | "left" | "right";
  50998. /**
  50999. * The type of components available in motion controllers.
  51000. * This is not the name of the component.
  51001. */
  51002. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51003. /**
  51004. * The state of a controller component
  51005. */
  51006. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51007. /**
  51008. * The schema of motion controller layout.
  51009. * No object will be initialized using this interface
  51010. * This is used just to define the profile.
  51011. */
  51012. export interface IMotionControllerLayout {
  51013. /**
  51014. * Path to load the assets. Usually relative to the base path
  51015. */
  51016. assetPath: string;
  51017. /**
  51018. * Available components (unsorted)
  51019. */
  51020. components: {
  51021. /**
  51022. * A map of component Ids
  51023. */
  51024. [componentId: string]: {
  51025. /**
  51026. * The type of input the component outputs
  51027. */
  51028. type: MotionControllerComponentType;
  51029. /**
  51030. * The indices of this component in the gamepad object
  51031. */
  51032. gamepadIndices: {
  51033. /**
  51034. * Index of button
  51035. */
  51036. button?: number;
  51037. /**
  51038. * If available, index of x-axis
  51039. */
  51040. xAxis?: number;
  51041. /**
  51042. * If available, index of y-axis
  51043. */
  51044. yAxis?: number;
  51045. };
  51046. /**
  51047. * The mesh's root node name
  51048. */
  51049. rootNodeName: string;
  51050. /**
  51051. * Animation definitions for this model
  51052. */
  51053. visualResponses: {
  51054. [stateKey: string]: {
  51055. /**
  51056. * What property will be animated
  51057. */
  51058. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51059. /**
  51060. * What states influence this visual response
  51061. */
  51062. states: MotionControllerComponentStateType[];
  51063. /**
  51064. * Type of animation - movement or visibility
  51065. */
  51066. valueNodeProperty: "transform" | "visibility";
  51067. /**
  51068. * Base node name to move. Its position will be calculated according to the min and max nodes
  51069. */
  51070. valueNodeName?: string;
  51071. /**
  51072. * Minimum movement node
  51073. */
  51074. minNodeName?: string;
  51075. /**
  51076. * Max movement node
  51077. */
  51078. maxNodeName?: string;
  51079. };
  51080. };
  51081. /**
  51082. * If touch enabled, what is the name of node to display user feedback
  51083. */
  51084. touchPointNodeName?: string;
  51085. };
  51086. };
  51087. /**
  51088. * Is it xr standard mapping or not
  51089. */
  51090. gamepadMapping: "" | "xr-standard";
  51091. /**
  51092. * Base root node of this entire model
  51093. */
  51094. rootNodeName: string;
  51095. /**
  51096. * Defines the main button component id
  51097. */
  51098. selectComponentId: string;
  51099. }
  51100. /**
  51101. * A definition for the layout map in the input profile
  51102. */
  51103. export interface IMotionControllerLayoutMap {
  51104. /**
  51105. * Layouts with handedness type as a key
  51106. */
  51107. [handedness: string]: IMotionControllerLayout;
  51108. }
  51109. /**
  51110. * The XR Input profile schema
  51111. * Profiles can be found here:
  51112. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51113. */
  51114. export interface IMotionControllerProfile {
  51115. /**
  51116. * fallback profiles for this profileId
  51117. */
  51118. fallbackProfileIds: string[];
  51119. /**
  51120. * The layout map, with handedness as key
  51121. */
  51122. layouts: IMotionControllerLayoutMap;
  51123. /**
  51124. * The id of this profile
  51125. * correlates to the profile(s) in the xrInput.profiles array
  51126. */
  51127. profileId: string;
  51128. }
  51129. /**
  51130. * A helper-interface for the 3 meshes needed for controller button animation
  51131. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51132. */
  51133. export interface IMotionControllerButtonMeshMap {
  51134. /**
  51135. * the mesh that defines the pressed value mesh position.
  51136. * This is used to find the max-position of this button
  51137. */
  51138. pressedMesh: AbstractMesh;
  51139. /**
  51140. * the mesh that defines the unpressed value mesh position.
  51141. * This is used to find the min (or initial) position of this button
  51142. */
  51143. unpressedMesh: AbstractMesh;
  51144. /**
  51145. * The mesh that will be changed when value changes
  51146. */
  51147. valueMesh: AbstractMesh;
  51148. }
  51149. /**
  51150. * A helper-interface for the 3 meshes needed for controller axis animation.
  51151. * This will be expanded when touchpad animations are fully supported
  51152. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51153. */
  51154. export interface IMotionControllerMeshMap {
  51155. /**
  51156. * the mesh that defines the maximum value mesh position.
  51157. */
  51158. maxMesh?: AbstractMesh;
  51159. /**
  51160. * the mesh that defines the minimum value mesh position.
  51161. */
  51162. minMesh?: AbstractMesh;
  51163. /**
  51164. * The mesh that will be changed when axis value changes
  51165. */
  51166. valueMesh?: AbstractMesh;
  51167. }
  51168. /**
  51169. * The elements needed for change-detection of the gamepad objects in motion controllers
  51170. */
  51171. export interface IMinimalMotionControllerObject {
  51172. /**
  51173. * Available axes of this controller
  51174. */
  51175. axes: number[];
  51176. /**
  51177. * An array of available buttons
  51178. */
  51179. buttons: Array<{
  51180. /**
  51181. * Value of the button/trigger
  51182. */
  51183. value: number;
  51184. /**
  51185. * If the button/trigger is currently touched
  51186. */
  51187. touched: boolean;
  51188. /**
  51189. * If the button/trigger is currently pressed
  51190. */
  51191. pressed: boolean;
  51192. }>;
  51193. /**
  51194. * EXPERIMENTAL haptic support.
  51195. */
  51196. hapticActuators?: Array<{
  51197. pulse: (value: number, duration: number) => Promise<boolean>;
  51198. }>;
  51199. }
  51200. /**
  51201. * An Abstract Motion controller
  51202. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51203. * Each component has an observable to check for changes in value and state
  51204. */
  51205. export abstract class WebXRAbstractMotionController implements IDisposable {
  51206. protected scene: Scene;
  51207. protected layout: IMotionControllerLayout;
  51208. /**
  51209. * The gamepad object correlating to this controller
  51210. */
  51211. gamepadObject: IMinimalMotionControllerObject;
  51212. /**
  51213. * handedness (left/right/none) of this controller
  51214. */
  51215. handedness: MotionControllerHandedness;
  51216. private _initComponent;
  51217. private _modelReady;
  51218. /**
  51219. * A map of components (WebXRControllerComponent) in this motion controller
  51220. * Components have a ComponentType and can also have both button and axis definitions
  51221. */
  51222. readonly components: {
  51223. [id: string]: WebXRControllerComponent;
  51224. };
  51225. /**
  51226. * Disable the model's animation. Can be set at any time.
  51227. */
  51228. disableAnimation: boolean;
  51229. /**
  51230. * Observers registered here will be triggered when the model of this controller is done loading
  51231. */
  51232. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51233. /**
  51234. * The profile id of this motion controller
  51235. */
  51236. abstract profileId: string;
  51237. /**
  51238. * The root mesh of the model. It is null if the model was not yet initialized
  51239. */
  51240. rootMesh: Nullable<AbstractMesh>;
  51241. /**
  51242. * constructs a new abstract motion controller
  51243. * @param scene the scene to which the model of the controller will be added
  51244. * @param layout The profile layout to load
  51245. * @param gamepadObject The gamepad object correlating to this controller
  51246. * @param handedness handedness (left/right/none) of this controller
  51247. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51248. */
  51249. constructor(scene: Scene, layout: IMotionControllerLayout,
  51250. /**
  51251. * The gamepad object correlating to this controller
  51252. */
  51253. gamepadObject: IMinimalMotionControllerObject,
  51254. /**
  51255. * handedness (left/right/none) of this controller
  51256. */
  51257. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51258. /**
  51259. * Dispose this controller, the model mesh and all its components
  51260. */
  51261. dispose(): void;
  51262. /**
  51263. * Returns all components of specific type
  51264. * @param type the type to search for
  51265. * @return an array of components with this type
  51266. */
  51267. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51268. /**
  51269. * get a component based an its component id as defined in layout.components
  51270. * @param id the id of the component
  51271. * @returns the component correlates to the id or undefined if not found
  51272. */
  51273. getComponent(id: string): WebXRControllerComponent;
  51274. /**
  51275. * Get the list of components available in this motion controller
  51276. * @returns an array of strings correlating to available components
  51277. */
  51278. getComponentIds(): string[];
  51279. /**
  51280. * Get the first component of specific type
  51281. * @param type type of component to find
  51282. * @return a controller component or null if not found
  51283. */
  51284. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51285. /**
  51286. * Get the main (Select) component of this controller as defined in the layout
  51287. * @returns the main component of this controller
  51288. */
  51289. getMainComponent(): WebXRControllerComponent;
  51290. /**
  51291. * Loads the model correlating to this controller
  51292. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51293. * @returns A promise fulfilled with the result of the model loading
  51294. */
  51295. loadModel(): Promise<boolean>;
  51296. /**
  51297. * Update this model using the current XRFrame
  51298. * @param xrFrame the current xr frame to use and update the model
  51299. */
  51300. updateFromXRFrame(xrFrame: XRFrame): void;
  51301. /**
  51302. * Backwards compatibility due to a deeply-integrated typo
  51303. */
  51304. get handness(): XREye;
  51305. /**
  51306. * Pulse (vibrate) this controller
  51307. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51308. * Consecutive calls to this function will cancel the last pulse call
  51309. *
  51310. * @param value the strength of the pulse in 0.0...1.0 range
  51311. * @param duration Duration of the pulse in milliseconds
  51312. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51313. * @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
  51314. */
  51315. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51316. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51317. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51318. /**
  51319. * Moves the axis on the controller mesh based on its current state
  51320. * @param axis the index of the axis
  51321. * @param axisValue the value of the axis which determines the meshes new position
  51322. * @hidden
  51323. */
  51324. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51325. /**
  51326. * Update the model itself with the current frame data
  51327. * @param xrFrame the frame to use for updating the model mesh
  51328. */
  51329. protected updateModel(xrFrame: XRFrame): void;
  51330. /**
  51331. * Get the filename and path for this controller's model
  51332. * @returns a map of filename and path
  51333. */
  51334. protected abstract _getFilenameAndPath(): {
  51335. filename: string;
  51336. path: string;
  51337. };
  51338. /**
  51339. * This function is called before the mesh is loaded. It checks for loading constraints.
  51340. * For example, this function can check if the GLB loader is available
  51341. * If this function returns false, the generic controller will be loaded instead
  51342. * @returns Is the client ready to load the mesh
  51343. */
  51344. protected abstract _getModelLoadingConstraints(): boolean;
  51345. /**
  51346. * This function will be called after the model was successfully loaded and can be used
  51347. * for mesh transformations before it is available for the user
  51348. * @param meshes the loaded meshes
  51349. */
  51350. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51351. /**
  51352. * Set the root mesh for this controller. Important for the WebXR controller class
  51353. * @param meshes the loaded meshes
  51354. */
  51355. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51356. /**
  51357. * A function executed each frame that updates the mesh (if needed)
  51358. * @param xrFrame the current xrFrame
  51359. */
  51360. protected abstract _updateModel(xrFrame: XRFrame): void;
  51361. private _getGenericFilenameAndPath;
  51362. private _getGenericParentMesh;
  51363. }
  51364. }
  51365. declare module BABYLON {
  51366. /**
  51367. * A generic trigger-only motion controller for WebXR
  51368. */
  51369. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51370. /**
  51371. * Static version of the profile id of this controller
  51372. */
  51373. static ProfileId: string;
  51374. profileId: string;
  51375. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51376. protected _getFilenameAndPath(): {
  51377. filename: string;
  51378. path: string;
  51379. };
  51380. protected _getModelLoadingConstraints(): boolean;
  51381. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51382. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51383. protected _updateModel(): void;
  51384. }
  51385. }
  51386. declare module BABYLON {
  51387. /**
  51388. * Class containing static functions to help procedurally build meshes
  51389. */
  51390. export class SphereBuilder {
  51391. /**
  51392. * Creates a sphere mesh
  51393. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51394. * * 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`)
  51395. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51396. * * 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
  51397. * * 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)
  51398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51399. * * 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
  51400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51401. * @param name defines the name of the mesh
  51402. * @param options defines the options used to create the mesh
  51403. * @param scene defines the hosting scene
  51404. * @returns the sphere mesh
  51405. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51406. */
  51407. static CreateSphere(name: string, options: {
  51408. segments?: number;
  51409. diameter?: number;
  51410. diameterX?: number;
  51411. diameterY?: number;
  51412. diameterZ?: number;
  51413. arc?: number;
  51414. slice?: number;
  51415. sideOrientation?: number;
  51416. frontUVs?: Vector4;
  51417. backUVs?: Vector4;
  51418. updatable?: boolean;
  51419. }, scene?: Nullable<Scene>): Mesh;
  51420. }
  51421. }
  51422. declare module BABYLON {
  51423. /**
  51424. * A profiled motion controller has its profile loaded from an online repository.
  51425. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51426. */
  51427. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51428. private _repositoryUrl;
  51429. private _buttonMeshMapping;
  51430. private _touchDots;
  51431. /**
  51432. * The profile ID of this controller. Will be populated when the controller initializes.
  51433. */
  51434. profileId: string;
  51435. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  51436. dispose(): void;
  51437. protected _getFilenameAndPath(): {
  51438. filename: string;
  51439. path: string;
  51440. };
  51441. protected _getModelLoadingConstraints(): boolean;
  51442. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  51443. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51444. protected _updateModel(_xrFrame: XRFrame): void;
  51445. }
  51446. }
  51447. declare module BABYLON {
  51448. /**
  51449. * A construction function type to create a new controller based on an xrInput object
  51450. */
  51451. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  51452. /**
  51453. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  51454. *
  51455. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  51456. * it should be replaced with auto-loaded controllers.
  51457. *
  51458. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  51459. */
  51460. export class WebXRMotionControllerManager {
  51461. private static _AvailableControllers;
  51462. private static _Fallbacks;
  51463. private static _ProfileLoadingPromises;
  51464. private static _ProfilesList;
  51465. /**
  51466. * The base URL of the online controller repository. Can be changed at any time.
  51467. */
  51468. static BaseRepositoryUrl: string;
  51469. /**
  51470. * Which repository gets priority - local or online
  51471. */
  51472. static PrioritizeOnlineRepository: boolean;
  51473. /**
  51474. * Use the online repository, or use only locally-defined controllers
  51475. */
  51476. static UseOnlineRepository: boolean;
  51477. /**
  51478. * Clear the cache used for profile loading and reload when requested again
  51479. */
  51480. static ClearProfilesCache(): void;
  51481. /**
  51482. * Register the default fallbacks.
  51483. * This function is called automatically when this file is imported.
  51484. */
  51485. static DefaultFallbacks(): void;
  51486. /**
  51487. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  51488. * @param profileId the profile to which a fallback needs to be found
  51489. * @return an array with corresponding fallback profiles
  51490. */
  51491. static FindFallbackWithProfileId(profileId: string): string[];
  51492. /**
  51493. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  51494. * The order of search:
  51495. *
  51496. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  51497. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  51498. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  51499. * 4) return the generic trigger controller if none were found
  51500. *
  51501. * @param xrInput the xrInput to which a new controller is initialized
  51502. * @param scene the scene to which the model will be added
  51503. * @param forceProfile force a certain profile for this controller
  51504. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  51505. */
  51506. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  51507. /**
  51508. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  51509. *
  51510. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  51511. *
  51512. * @param type the profile type to register
  51513. * @param constructFunction the function to be called when loading this profile
  51514. */
  51515. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  51516. /**
  51517. * Register a fallback to a specific profile.
  51518. * @param profileId the profileId that will receive the fallbacks
  51519. * @param fallbacks A list of fallback profiles
  51520. */
  51521. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  51522. /**
  51523. * Will update the list of profiles available in the repository
  51524. * @return a promise that resolves to a map of profiles available online
  51525. */
  51526. static UpdateProfilesList(): Promise<{
  51527. [profile: string]: string;
  51528. }>;
  51529. private static _LoadProfileFromRepository;
  51530. private static _LoadProfilesFromAvailableControllers;
  51531. }
  51532. }
  51533. declare module BABYLON {
  51534. /**
  51535. * Configuration options for the WebXR controller creation
  51536. */
  51537. export interface IWebXRControllerOptions {
  51538. /**
  51539. * Should the controller mesh be animated when a user interacts with it
  51540. * The pressed buttons / thumbstick and touchpad animations will be disabled
  51541. */
  51542. disableMotionControllerAnimation?: boolean;
  51543. /**
  51544. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  51545. */
  51546. doNotLoadControllerMesh?: boolean;
  51547. /**
  51548. * Force a specific controller type for this controller.
  51549. * This can be used when creating your own profile or when testing different controllers
  51550. */
  51551. forceControllerProfile?: string;
  51552. /**
  51553. * Defines a rendering group ID for meshes that will be loaded.
  51554. * This is for the default controllers only.
  51555. */
  51556. renderingGroupId?: number;
  51557. }
  51558. /**
  51559. * Represents an XR controller
  51560. */
  51561. export class WebXRInputSource {
  51562. private _scene;
  51563. /** The underlying input source for the controller */
  51564. inputSource: XRInputSource;
  51565. private _options;
  51566. private _tmpVector;
  51567. private _uniqueId;
  51568. private _disposed;
  51569. /**
  51570. * 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
  51571. */
  51572. grip?: AbstractMesh;
  51573. /**
  51574. * If available, this is the gamepad object related to this controller.
  51575. * Using this object it is possible to get click events and trackpad changes of the
  51576. * webxr controller that is currently being used.
  51577. */
  51578. motionController?: WebXRAbstractMotionController;
  51579. /**
  51580. * Event that fires when the controller is removed/disposed.
  51581. * The object provided as event data is this controller, after associated assets were disposed.
  51582. * uniqueId is still available.
  51583. */
  51584. onDisposeObservable: Observable<WebXRInputSource>;
  51585. /**
  51586. * Will be triggered when the mesh associated with the motion controller is done loading.
  51587. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  51588. * A shortened version of controller -> motion controller -> on mesh loaded.
  51589. */
  51590. onMeshLoadedObservable: Observable<AbstractMesh>;
  51591. /**
  51592. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  51593. */
  51594. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  51595. /**
  51596. * Pointer which can be used to select objects or attach a visible laser to
  51597. */
  51598. pointer: AbstractMesh;
  51599. /**
  51600. * Creates the input source object
  51601. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  51602. * @param _scene the scene which the controller should be associated to
  51603. * @param inputSource the underlying input source for the controller
  51604. * @param _options options for this controller creation
  51605. */
  51606. constructor(_scene: Scene,
  51607. /** The underlying input source for the controller */
  51608. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  51609. /**
  51610. * Get this controllers unique id
  51611. */
  51612. get uniqueId(): string;
  51613. /**
  51614. * Disposes of the object
  51615. */
  51616. dispose(): void;
  51617. /**
  51618. * Gets a world space ray coming from the pointer or grip
  51619. * @param result the resulting ray
  51620. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  51621. */
  51622. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  51623. /**
  51624. * Updates the controller pose based on the given XRFrame
  51625. * @param xrFrame xr frame to update the pose with
  51626. * @param referenceSpace reference space to use
  51627. */
  51628. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  51629. }
  51630. }
  51631. declare module BABYLON {
  51632. /**
  51633. * The schema for initialization options of the XR Input class
  51634. */
  51635. export interface IWebXRInputOptions {
  51636. /**
  51637. * If set to true no model will be automatically loaded
  51638. */
  51639. doNotLoadControllerMeshes?: boolean;
  51640. /**
  51641. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  51642. * If not found, the xr input profile data will be used.
  51643. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  51644. */
  51645. forceInputProfile?: string;
  51646. /**
  51647. * Do not send a request to the controller repository to load the profile.
  51648. *
  51649. * Instead, use the controllers available in babylon itself.
  51650. */
  51651. disableOnlineControllerRepository?: boolean;
  51652. /**
  51653. * A custom URL for the controllers repository
  51654. */
  51655. customControllersRepositoryURL?: string;
  51656. /**
  51657. * Should the controller model's components not move according to the user input
  51658. */
  51659. disableControllerAnimation?: boolean;
  51660. /**
  51661. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  51662. */
  51663. controllerOptions?: IWebXRControllerOptions;
  51664. }
  51665. /**
  51666. * XR input used to track XR inputs such as controllers/rays
  51667. */
  51668. export class WebXRInput implements IDisposable {
  51669. /**
  51670. * the xr session manager for this session
  51671. */
  51672. xrSessionManager: WebXRSessionManager;
  51673. /**
  51674. * the WebXR camera for this session. Mainly used for teleportation
  51675. */
  51676. xrCamera: WebXRCamera;
  51677. private readonly options;
  51678. /**
  51679. * XR controllers being tracked
  51680. */
  51681. controllers: Array<WebXRInputSource>;
  51682. private _frameObserver;
  51683. private _sessionEndedObserver;
  51684. private _sessionInitObserver;
  51685. /**
  51686. * Event when a controller has been connected/added
  51687. */
  51688. onControllerAddedObservable: Observable<WebXRInputSource>;
  51689. /**
  51690. * Event when a controller has been removed/disconnected
  51691. */
  51692. onControllerRemovedObservable: Observable<WebXRInputSource>;
  51693. /**
  51694. * Initializes the WebXRInput
  51695. * @param xrSessionManager the xr session manager for this session
  51696. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  51697. * @param options = initialization options for this xr input
  51698. */
  51699. constructor(
  51700. /**
  51701. * the xr session manager for this session
  51702. */
  51703. xrSessionManager: WebXRSessionManager,
  51704. /**
  51705. * the WebXR camera for this session. Mainly used for teleportation
  51706. */
  51707. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  51708. private _onInputSourcesChange;
  51709. private _addAndRemoveControllers;
  51710. /**
  51711. * Disposes of the object
  51712. */
  51713. dispose(): void;
  51714. }
  51715. }
  51716. declare module BABYLON {
  51717. /**
  51718. * This is the base class for all WebXR features.
  51719. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  51720. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  51721. */
  51722. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  51723. protected _xrSessionManager: WebXRSessionManager;
  51724. private _attached;
  51725. private _removeOnDetach;
  51726. /**
  51727. * Is this feature disposed?
  51728. */
  51729. isDisposed: boolean;
  51730. /**
  51731. * Should auto-attach be disabled?
  51732. */
  51733. disableAutoAttach: boolean;
  51734. /**
  51735. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  51736. */
  51737. xrNativeFeatureName: string;
  51738. /**
  51739. * Construct a new (abstract) WebXR feature
  51740. * @param _xrSessionManager the xr session manager for this feature
  51741. */
  51742. constructor(_xrSessionManager: WebXRSessionManager);
  51743. /**
  51744. * Is this feature attached
  51745. */
  51746. get attached(): boolean;
  51747. /**
  51748. * attach this feature
  51749. *
  51750. * @param force should attachment be forced (even when already attached)
  51751. * @returns true if successful, false is failed or already attached
  51752. */
  51753. attach(force?: boolean): boolean;
  51754. /**
  51755. * detach this feature.
  51756. *
  51757. * @returns true if successful, false if failed or already detached
  51758. */
  51759. detach(): boolean;
  51760. /**
  51761. * Dispose this feature and all of the resources attached
  51762. */
  51763. dispose(): void;
  51764. /**
  51765. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  51766. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  51767. *
  51768. * @returns whether or not the feature is compatible in this environment
  51769. */
  51770. isCompatible(): boolean;
  51771. /**
  51772. * This is used to register callbacks that will automatically be removed when detach is called.
  51773. * @param observable the observable to which the observer will be attached
  51774. * @param callback the callback to register
  51775. */
  51776. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  51777. /**
  51778. * Code in this function will be executed on each xrFrame received from the browser.
  51779. * This function will not execute after the feature is detached.
  51780. * @param _xrFrame the current frame
  51781. */
  51782. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  51783. }
  51784. }
  51785. declare module BABYLON {
  51786. /**
  51787. * Renders a layer on top of an existing scene
  51788. */
  51789. export class UtilityLayerRenderer implements IDisposable {
  51790. /** the original scene that will be rendered on top of */
  51791. originalScene: Scene;
  51792. private _pointerCaptures;
  51793. private _lastPointerEvents;
  51794. private static _DefaultUtilityLayer;
  51795. private static _DefaultKeepDepthUtilityLayer;
  51796. private _sharedGizmoLight;
  51797. private _renderCamera;
  51798. /**
  51799. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  51800. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  51801. * @returns the camera that is used when rendering the utility layer
  51802. */
  51803. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  51804. /**
  51805. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  51806. * @param cam the camera that should be used when rendering the utility layer
  51807. */
  51808. setRenderCamera(cam: Nullable<Camera>): void;
  51809. /**
  51810. * @hidden
  51811. * Light which used by gizmos to get light shading
  51812. */
  51813. _getSharedGizmoLight(): HemisphericLight;
  51814. /**
  51815. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  51816. */
  51817. pickUtilitySceneFirst: boolean;
  51818. /**
  51819. * 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)
  51820. */
  51821. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  51822. /**
  51823. * 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)
  51824. */
  51825. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  51826. /**
  51827. * The scene that is rendered on top of the original scene
  51828. */
  51829. utilityLayerScene: Scene;
  51830. /**
  51831. * If the utility layer should automatically be rendered on top of existing scene
  51832. */
  51833. shouldRender: boolean;
  51834. /**
  51835. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  51836. */
  51837. onlyCheckPointerDownEvents: boolean;
  51838. /**
  51839. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  51840. */
  51841. processAllEvents: boolean;
  51842. /**
  51843. * Observable raised when the pointer move from the utility layer scene to the main scene
  51844. */
  51845. onPointerOutObservable: Observable<number>;
  51846. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  51847. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  51848. private _afterRenderObserver;
  51849. private _sceneDisposeObserver;
  51850. private _originalPointerObserver;
  51851. /**
  51852. * Instantiates a UtilityLayerRenderer
  51853. * @param originalScene the original scene that will be rendered on top of
  51854. * @param handleEvents boolean indicating if the utility layer should handle events
  51855. */
  51856. constructor(
  51857. /** the original scene that will be rendered on top of */
  51858. originalScene: Scene, handleEvents?: boolean);
  51859. private _notifyObservers;
  51860. /**
  51861. * Renders the utility layers scene on top of the original scene
  51862. */
  51863. render(): void;
  51864. /**
  51865. * Disposes of the renderer
  51866. */
  51867. dispose(): void;
  51868. private _updateCamera;
  51869. }
  51870. }
  51871. declare module BABYLON {
  51872. /**
  51873. * Options interface for the pointer selection module
  51874. */
  51875. export interface IWebXRControllerPointerSelectionOptions {
  51876. /**
  51877. * if provided, this scene will be used to render meshes.
  51878. */
  51879. customUtilityLayerScene?: Scene;
  51880. /**
  51881. * 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)
  51882. * If not disabled, the last picked point will be used to execute a pointer up event
  51883. * If disabled, pointer up event will be triggered right after the pointer down event.
  51884. * Used in screen and gaze target ray mode only
  51885. */
  51886. disablePointerUpOnTouchOut: boolean;
  51887. /**
  51888. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  51889. */
  51890. forceGazeMode: boolean;
  51891. /**
  51892. * 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
  51893. * to start a new countdown to the pointer down event.
  51894. * Defaults to 1.
  51895. */
  51896. gazeModePointerMovedFactor?: number;
  51897. /**
  51898. * Different button type to use instead of the main component
  51899. */
  51900. overrideButtonId?: string;
  51901. /**
  51902. * use this rendering group id for the meshes (optional)
  51903. */
  51904. renderingGroupId?: number;
  51905. /**
  51906. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  51907. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  51908. * 3000 means 3 seconds between pointing at something and selecting it
  51909. */
  51910. timeToSelect?: number;
  51911. /**
  51912. * Should meshes created here be added to a utility layer or the main scene
  51913. */
  51914. useUtilityLayer?: boolean;
  51915. /**
  51916. * Optional WebXR camera to be used for gaze selection
  51917. */
  51918. gazeCamera?: WebXRCamera;
  51919. /**
  51920. * the xr input to use with this pointer selection
  51921. */
  51922. xrInput: WebXRInput;
  51923. }
  51924. /**
  51925. * A module that will enable pointer selection for motion controllers of XR Input Sources
  51926. */
  51927. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  51928. private readonly _options;
  51929. private static _idCounter;
  51930. private _attachController;
  51931. private _controllers;
  51932. private _scene;
  51933. private _tmpVectorForPickCompare;
  51934. /**
  51935. * The module's name
  51936. */
  51937. static readonly Name: string;
  51938. /**
  51939. * The (Babylon) version of this module.
  51940. * This is an integer representing the implementation version.
  51941. * This number does not correspond to the WebXR specs version
  51942. */
  51943. static readonly Version: number;
  51944. /**
  51945. * Disable lighting on the laser pointer (so it will always be visible)
  51946. */
  51947. disablePointerLighting: boolean;
  51948. /**
  51949. * Disable lighting on the selection mesh (so it will always be visible)
  51950. */
  51951. disableSelectionMeshLighting: boolean;
  51952. /**
  51953. * Should the laser pointer be displayed
  51954. */
  51955. displayLaserPointer: boolean;
  51956. /**
  51957. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  51958. */
  51959. displaySelectionMesh: boolean;
  51960. /**
  51961. * This color will be set to the laser pointer when selection is triggered
  51962. */
  51963. laserPointerPickedColor: Color3;
  51964. /**
  51965. * Default color of the laser pointer
  51966. */
  51967. laserPointerDefaultColor: Color3;
  51968. /**
  51969. * default color of the selection ring
  51970. */
  51971. selectionMeshDefaultColor: Color3;
  51972. /**
  51973. * This color will be applied to the selection ring when selection is triggered
  51974. */
  51975. selectionMeshPickedColor: Color3;
  51976. /**
  51977. * Optional filter to be used for ray selection. This predicate shares behavior with
  51978. * scene.pointerMovePredicate which takes priority if it is also assigned.
  51979. */
  51980. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51981. /**
  51982. * constructs a new background remover module
  51983. * @param _xrSessionManager the session manager for this module
  51984. * @param _options read-only options to be used in this module
  51985. */
  51986. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  51987. /**
  51988. * attach this feature
  51989. * Will usually be called by the features manager
  51990. *
  51991. * @returns true if successful.
  51992. */
  51993. attach(): boolean;
  51994. /**
  51995. * detach this feature.
  51996. * Will usually be called by the features manager
  51997. *
  51998. * @returns true if successful.
  51999. */
  52000. detach(): boolean;
  52001. /**
  52002. * Will get the mesh under a specific pointer.
  52003. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52004. * @param controllerId the controllerId to check
  52005. * @returns The mesh under pointer or null if no mesh is under the pointer
  52006. */
  52007. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52008. /**
  52009. * Get the xr controller that correlates to the pointer id in the pointer event
  52010. *
  52011. * @param id the pointer id to search for
  52012. * @returns the controller that correlates to this id or null if not found
  52013. */
  52014. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52015. protected _onXRFrame(_xrFrame: XRFrame): void;
  52016. private _attachGazeMode;
  52017. private _attachScreenRayMode;
  52018. private _attachTrackedPointerRayMode;
  52019. private _convertNormalToDirectionOfRay;
  52020. private _detachController;
  52021. private _generateNewMeshPair;
  52022. private _pickingMoved;
  52023. private _updatePointerDistance;
  52024. /** @hidden */
  52025. get lasterPointerDefaultColor(): Color3;
  52026. }
  52027. }
  52028. declare module BABYLON {
  52029. /**
  52030. * Button which can be used to enter a different mode of XR
  52031. */
  52032. export class WebXREnterExitUIButton {
  52033. /** button element */
  52034. element: HTMLElement;
  52035. /** XR initialization options for the button */
  52036. sessionMode: XRSessionMode;
  52037. /** Reference space type */
  52038. referenceSpaceType: XRReferenceSpaceType;
  52039. /**
  52040. * Creates a WebXREnterExitUIButton
  52041. * @param element button element
  52042. * @param sessionMode XR initialization session mode
  52043. * @param referenceSpaceType the type of reference space to be used
  52044. */
  52045. constructor(
  52046. /** button element */
  52047. element: HTMLElement,
  52048. /** XR initialization options for the button */
  52049. sessionMode: XRSessionMode,
  52050. /** Reference space type */
  52051. referenceSpaceType: XRReferenceSpaceType);
  52052. /**
  52053. * Extendable function which can be used to update the button's visuals when the state changes
  52054. * @param activeButton the current active button in the UI
  52055. */
  52056. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52057. }
  52058. /**
  52059. * Options to create the webXR UI
  52060. */
  52061. export class WebXREnterExitUIOptions {
  52062. /**
  52063. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52064. */
  52065. customButtons?: Array<WebXREnterExitUIButton>;
  52066. /**
  52067. * A reference space type to use when creating the default button.
  52068. * Default is local-floor
  52069. */
  52070. referenceSpaceType?: XRReferenceSpaceType;
  52071. /**
  52072. * Context to enter xr with
  52073. */
  52074. renderTarget?: Nullable<WebXRRenderTarget>;
  52075. /**
  52076. * A session mode to use when creating the default button.
  52077. * Default is immersive-vr
  52078. */
  52079. sessionMode?: XRSessionMode;
  52080. /**
  52081. * A list of optional features to init the session with
  52082. */
  52083. optionalFeatures?: string[];
  52084. /**
  52085. * A list of optional features to init the session with
  52086. */
  52087. requiredFeatures?: string[];
  52088. }
  52089. /**
  52090. * UI to allow the user to enter/exit XR mode
  52091. */
  52092. export class WebXREnterExitUI implements IDisposable {
  52093. private scene;
  52094. /** version of the options passed to this UI */
  52095. options: WebXREnterExitUIOptions;
  52096. private _activeButton;
  52097. private _buttons;
  52098. /**
  52099. * The HTML Div Element to which buttons are added.
  52100. */
  52101. readonly overlay: HTMLDivElement;
  52102. /**
  52103. * Fired every time the active button is changed.
  52104. *
  52105. * When xr is entered via a button that launches xr that button will be the callback parameter
  52106. *
  52107. * When exiting xr the callback parameter will be null)
  52108. */
  52109. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52110. /**
  52111. *
  52112. * @param scene babylon scene object to use
  52113. * @param options (read-only) version of the options passed to this UI
  52114. */
  52115. private constructor();
  52116. /**
  52117. * Creates UI to allow the user to enter/exit XR mode
  52118. * @param scene the scene to add the ui to
  52119. * @param helper the xr experience helper to enter/exit xr with
  52120. * @param options options to configure the UI
  52121. * @returns the created ui
  52122. */
  52123. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52124. /**
  52125. * Disposes of the XR UI component
  52126. */
  52127. dispose(): void;
  52128. private _updateButtons;
  52129. }
  52130. }
  52131. declare module BABYLON {
  52132. /**
  52133. * Class containing static functions to help procedurally build meshes
  52134. */
  52135. export class LinesBuilder {
  52136. /**
  52137. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52138. * * 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
  52139. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52140. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52141. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52142. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52143. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52144. * * 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
  52145. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52148. * @param name defines the name of the new line system
  52149. * @param options defines the options used to create the line system
  52150. * @param scene defines the hosting scene
  52151. * @returns a new line system mesh
  52152. */
  52153. static CreateLineSystem(name: string, options: {
  52154. lines: Vector3[][];
  52155. updatable?: boolean;
  52156. instance?: Nullable<LinesMesh>;
  52157. colors?: Nullable<Color4[][]>;
  52158. useVertexAlpha?: boolean;
  52159. }, scene: Nullable<Scene>): LinesMesh;
  52160. /**
  52161. * Creates a line mesh
  52162. * 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
  52163. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52164. * * The parameter `points` is an array successive Vector3
  52165. * * 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
  52166. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52167. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52168. * * When updating an instance, remember that only point positions can change, not the number of points
  52169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52171. * @param name defines the name of the new line system
  52172. * @param options defines the options used to create the line system
  52173. * @param scene defines the hosting scene
  52174. * @returns a new line mesh
  52175. */
  52176. static CreateLines(name: string, options: {
  52177. points: Vector3[];
  52178. updatable?: boolean;
  52179. instance?: Nullable<LinesMesh>;
  52180. colors?: Color4[];
  52181. useVertexAlpha?: boolean;
  52182. }, scene?: Nullable<Scene>): LinesMesh;
  52183. /**
  52184. * Creates a dashed line mesh
  52185. * * 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
  52186. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52187. * * The parameter `points` is an array successive Vector3
  52188. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52189. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52190. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52191. * * 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
  52192. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52193. * * When updating an instance, remember that only point positions can change, not the number of points
  52194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52195. * @param name defines the name of the mesh
  52196. * @param options defines the options used to create the mesh
  52197. * @param scene defines the hosting scene
  52198. * @returns the dashed line mesh
  52199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52200. */
  52201. static CreateDashedLines(name: string, options: {
  52202. points: Vector3[];
  52203. dashSize?: number;
  52204. gapSize?: number;
  52205. dashNb?: number;
  52206. updatable?: boolean;
  52207. instance?: LinesMesh;
  52208. useVertexAlpha?: boolean;
  52209. }, scene?: Nullable<Scene>): LinesMesh;
  52210. }
  52211. }
  52212. declare module BABYLON {
  52213. /**
  52214. * Construction options for a timer
  52215. */
  52216. export interface ITimerOptions<T> {
  52217. /**
  52218. * Time-to-end
  52219. */
  52220. timeout: number;
  52221. /**
  52222. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52223. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52224. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52225. */
  52226. contextObservable: Observable<T>;
  52227. /**
  52228. * Optional parameters when adding an observer to the observable
  52229. */
  52230. observableParameters?: {
  52231. mask?: number;
  52232. insertFirst?: boolean;
  52233. scope?: any;
  52234. };
  52235. /**
  52236. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52237. */
  52238. breakCondition?: (data?: ITimerData<T>) => boolean;
  52239. /**
  52240. * Will be triggered when the time condition has met
  52241. */
  52242. onEnded?: (data: ITimerData<any>) => void;
  52243. /**
  52244. * Will be triggered when the break condition has met (prematurely ended)
  52245. */
  52246. onAborted?: (data: ITimerData<any>) => void;
  52247. /**
  52248. * Optional function to execute on each tick (or count)
  52249. */
  52250. onTick?: (data: ITimerData<any>) => void;
  52251. }
  52252. /**
  52253. * An interface defining the data sent by the timer
  52254. */
  52255. export interface ITimerData<T> {
  52256. /**
  52257. * When did it start
  52258. */
  52259. startTime: number;
  52260. /**
  52261. * Time now
  52262. */
  52263. currentTime: number;
  52264. /**
  52265. * Time passed since started
  52266. */
  52267. deltaTime: number;
  52268. /**
  52269. * How much is completed, in [0.0...1.0].
  52270. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52271. */
  52272. completeRate: number;
  52273. /**
  52274. * What the registered observable sent in the last count
  52275. */
  52276. payload: T;
  52277. }
  52278. /**
  52279. * The current state of the timer
  52280. */
  52281. export enum TimerState {
  52282. /**
  52283. * Timer initialized, not yet started
  52284. */
  52285. INIT = 0,
  52286. /**
  52287. * Timer started and counting
  52288. */
  52289. STARTED = 1,
  52290. /**
  52291. * Timer ended (whether aborted or time reached)
  52292. */
  52293. ENDED = 2
  52294. }
  52295. /**
  52296. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52297. *
  52298. * @param options options with which to initialize this timer
  52299. */
  52300. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52301. /**
  52302. * An advanced implementation of a timer class
  52303. */
  52304. export class AdvancedTimer<T = any> implements IDisposable {
  52305. /**
  52306. * Will notify each time the timer calculates the remaining time
  52307. */
  52308. onEachCountObservable: Observable<ITimerData<T>>;
  52309. /**
  52310. * Will trigger when the timer was aborted due to the break condition
  52311. */
  52312. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52313. /**
  52314. * Will trigger when the timer ended successfully
  52315. */
  52316. onTimerEndedObservable: Observable<ITimerData<T>>;
  52317. /**
  52318. * Will trigger when the timer state has changed
  52319. */
  52320. onStateChangedObservable: Observable<TimerState>;
  52321. private _observer;
  52322. private _contextObservable;
  52323. private _observableParameters;
  52324. private _startTime;
  52325. private _timer;
  52326. private _state;
  52327. private _breakCondition;
  52328. private _timeToEnd;
  52329. private _breakOnNextTick;
  52330. /**
  52331. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52332. * @param options construction options for this advanced timer
  52333. */
  52334. constructor(options: ITimerOptions<T>);
  52335. /**
  52336. * set a breaking condition for this timer. Default is to never break during count
  52337. * @param predicate the new break condition. Returns true to break, false otherwise
  52338. */
  52339. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52340. /**
  52341. * Reset ALL associated observables in this advanced timer
  52342. */
  52343. clearObservables(): void;
  52344. /**
  52345. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52346. *
  52347. * @param timeToEnd how much time to measure until timer ended
  52348. */
  52349. start(timeToEnd?: number): void;
  52350. /**
  52351. * Will force a stop on the next tick.
  52352. */
  52353. stop(): void;
  52354. /**
  52355. * Dispose this timer, clearing all resources
  52356. */
  52357. dispose(): void;
  52358. private _setState;
  52359. private _tick;
  52360. private _stop;
  52361. }
  52362. }
  52363. declare module BABYLON {
  52364. /**
  52365. * The options container for the teleportation module
  52366. */
  52367. export interface IWebXRTeleportationOptions {
  52368. /**
  52369. * if provided, this scene will be used to render meshes.
  52370. */
  52371. customUtilityLayerScene?: Scene;
  52372. /**
  52373. * Values to configure the default target mesh
  52374. */
  52375. defaultTargetMeshOptions?: {
  52376. /**
  52377. * Fill color of the teleportation area
  52378. */
  52379. teleportationFillColor?: string;
  52380. /**
  52381. * Border color for the teleportation area
  52382. */
  52383. teleportationBorderColor?: string;
  52384. /**
  52385. * Disable the mesh's animation sequence
  52386. */
  52387. disableAnimation?: boolean;
  52388. /**
  52389. * Disable lighting on the material or the ring and arrow
  52390. */
  52391. disableLighting?: boolean;
  52392. /**
  52393. * Override the default material of the torus and arrow
  52394. */
  52395. torusArrowMaterial?: Material;
  52396. };
  52397. /**
  52398. * A list of meshes to use as floor meshes.
  52399. * Meshes can be added and removed after initializing the feature using the
  52400. * addFloorMesh and removeFloorMesh functions
  52401. * If empty, rotation will still work
  52402. */
  52403. floorMeshes?: AbstractMesh[];
  52404. /**
  52405. * use this rendering group id for the meshes (optional)
  52406. */
  52407. renderingGroupId?: number;
  52408. /**
  52409. * Should teleportation move only to snap points
  52410. */
  52411. snapPointsOnly?: boolean;
  52412. /**
  52413. * An array of points to which the teleportation will snap to.
  52414. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  52415. */
  52416. snapPositions?: Vector3[];
  52417. /**
  52418. * How close should the teleportation ray be in order to snap to position.
  52419. * Default to 0.8 units (meters)
  52420. */
  52421. snapToPositionRadius?: number;
  52422. /**
  52423. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  52424. * If you want to support rotation, make sure your mesh has a direction indicator.
  52425. *
  52426. * When left untouched, the default mesh will be initialized.
  52427. */
  52428. teleportationTargetMesh?: AbstractMesh;
  52429. /**
  52430. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  52431. */
  52432. timeToTeleport?: number;
  52433. /**
  52434. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  52435. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  52436. */
  52437. useMainComponentOnly?: boolean;
  52438. /**
  52439. * Should meshes created here be added to a utility layer or the main scene
  52440. */
  52441. useUtilityLayer?: boolean;
  52442. /**
  52443. * Babylon XR Input class for controller
  52444. */
  52445. xrInput: WebXRInput;
  52446. /**
  52447. * Meshes that the teleportation ray cannot go through
  52448. */
  52449. pickBlockerMeshes?: AbstractMesh[];
  52450. }
  52451. /**
  52452. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  52453. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  52454. * the input of the attached controllers.
  52455. */
  52456. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  52457. private _options;
  52458. private _controllers;
  52459. private _currentTeleportationControllerId;
  52460. private _floorMeshes;
  52461. private _quadraticBezierCurve;
  52462. private _selectionFeature;
  52463. private _snapToPositions;
  52464. private _snappedToPoint;
  52465. private _teleportationRingMaterial?;
  52466. private _tmpRay;
  52467. private _tmpVector;
  52468. private _tmpQuaternion;
  52469. /**
  52470. * The module's name
  52471. */
  52472. static readonly Name: string;
  52473. /**
  52474. * The (Babylon) version of this module.
  52475. * This is an integer representing the implementation version.
  52476. * This number does not correspond to the webxr specs version
  52477. */
  52478. static readonly Version: number;
  52479. /**
  52480. * Is movement backwards enabled
  52481. */
  52482. backwardsMovementEnabled: boolean;
  52483. /**
  52484. * Distance to travel when moving backwards
  52485. */
  52486. backwardsTeleportationDistance: number;
  52487. /**
  52488. * The distance from the user to the inspection point in the direction of the controller
  52489. * A higher number will allow the user to move further
  52490. * defaults to 5 (meters, in xr units)
  52491. */
  52492. parabolicCheckRadius: number;
  52493. /**
  52494. * Should the module support parabolic ray on top of direct ray
  52495. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  52496. * Very helpful when moving between floors / different heights
  52497. */
  52498. parabolicRayEnabled: boolean;
  52499. /**
  52500. * How much rotation should be applied when rotating right and left
  52501. */
  52502. rotationAngle: number;
  52503. /**
  52504. * Is rotation enabled when moving forward?
  52505. * Disabling this feature will prevent the user from deciding the direction when teleporting
  52506. */
  52507. rotationEnabled: boolean;
  52508. /**
  52509. * constructs a new anchor system
  52510. * @param _xrSessionManager an instance of WebXRSessionManager
  52511. * @param _options configuration object for this feature
  52512. */
  52513. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  52514. /**
  52515. * Get the snapPointsOnly flag
  52516. */
  52517. get snapPointsOnly(): boolean;
  52518. /**
  52519. * Sets the snapPointsOnly flag
  52520. * @param snapToPoints should teleportation be exclusively to snap points
  52521. */
  52522. set snapPointsOnly(snapToPoints: boolean);
  52523. /**
  52524. * Add a new mesh to the floor meshes array
  52525. * @param mesh the mesh to use as floor mesh
  52526. */
  52527. addFloorMesh(mesh: AbstractMesh): void;
  52528. /**
  52529. * Add a new snap-to point to fix teleportation to this position
  52530. * @param newSnapPoint The new Snap-To point
  52531. */
  52532. addSnapPoint(newSnapPoint: Vector3): void;
  52533. attach(): boolean;
  52534. detach(): boolean;
  52535. dispose(): void;
  52536. /**
  52537. * Remove a mesh from the floor meshes array
  52538. * @param mesh the mesh to remove
  52539. */
  52540. removeFloorMesh(mesh: AbstractMesh): void;
  52541. /**
  52542. * Remove a mesh from the floor meshes array using its name
  52543. * @param name the mesh name to remove
  52544. */
  52545. removeFloorMeshByName(name: string): void;
  52546. /**
  52547. * 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
  52548. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  52549. * @returns was the point found and removed or not
  52550. */
  52551. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  52552. /**
  52553. * This function sets a selection feature that will be disabled when
  52554. * the forward ray is shown and will be reattached when hidden.
  52555. * This is used to remove the selection rays when moving.
  52556. * @param selectionFeature the feature to disable when forward movement is enabled
  52557. */
  52558. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  52559. protected _onXRFrame(_xrFrame: XRFrame): void;
  52560. private _attachController;
  52561. private _createDefaultTargetMesh;
  52562. private _detachController;
  52563. private _findClosestSnapPointWithRadius;
  52564. private _setTargetMeshPosition;
  52565. private _setTargetMeshVisibility;
  52566. private _showParabolicPath;
  52567. private _teleportForward;
  52568. }
  52569. }
  52570. declare module BABYLON {
  52571. /**
  52572. * Options for the default xr helper
  52573. */
  52574. export class WebXRDefaultExperienceOptions {
  52575. /**
  52576. * Enable or disable default UI to enter XR
  52577. */
  52578. disableDefaultUI?: boolean;
  52579. /**
  52580. * Should teleportation not initialize. defaults to false.
  52581. */
  52582. disableTeleportation?: boolean;
  52583. /**
  52584. * Floor meshes that will be used for teleport
  52585. */
  52586. floorMeshes?: Array<AbstractMesh>;
  52587. /**
  52588. * If set to true, the first frame will not be used to reset position
  52589. * The first frame is mainly used when copying transformation from the old camera
  52590. * Mainly used in AR
  52591. */
  52592. ignoreNativeCameraTransformation?: boolean;
  52593. /**
  52594. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  52595. */
  52596. inputOptions?: IWebXRInputOptions;
  52597. /**
  52598. * optional configuration for the output canvas
  52599. */
  52600. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  52601. /**
  52602. * optional UI options. This can be used among other to change session mode and reference space type
  52603. */
  52604. uiOptions?: WebXREnterExitUIOptions;
  52605. /**
  52606. * When loading teleportation and pointer select, use stable versions instead of latest.
  52607. */
  52608. useStablePlugins?: boolean;
  52609. /**
  52610. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  52611. */
  52612. renderingGroupId?: number;
  52613. /**
  52614. * A list of optional features to init the session with
  52615. * If set to true, all features we support will be added
  52616. */
  52617. optionalFeatures?: boolean | string[];
  52618. }
  52619. /**
  52620. * Default experience which provides a similar setup to the previous webVRExperience
  52621. */
  52622. export class WebXRDefaultExperience {
  52623. /**
  52624. * Base experience
  52625. */
  52626. baseExperience: WebXRExperienceHelper;
  52627. /**
  52628. * Enables ui for entering/exiting xr
  52629. */
  52630. enterExitUI: WebXREnterExitUI;
  52631. /**
  52632. * Input experience extension
  52633. */
  52634. input: WebXRInput;
  52635. /**
  52636. * Enables laser pointer and selection
  52637. */
  52638. pointerSelection: WebXRControllerPointerSelection;
  52639. /**
  52640. * Default target xr should render to
  52641. */
  52642. renderTarget: WebXRRenderTarget;
  52643. /**
  52644. * Enables teleportation
  52645. */
  52646. teleportation: WebXRMotionControllerTeleportation;
  52647. private constructor();
  52648. /**
  52649. * Creates the default xr experience
  52650. * @param scene scene
  52651. * @param options options for basic configuration
  52652. * @returns resulting WebXRDefaultExperience
  52653. */
  52654. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52655. /**
  52656. * DIsposes of the experience helper
  52657. */
  52658. dispose(): void;
  52659. }
  52660. }
  52661. declare module BABYLON {
  52662. /**
  52663. * Options to modify the vr teleportation behavior.
  52664. */
  52665. export interface VRTeleportationOptions {
  52666. /**
  52667. * The name of the mesh which should be used as the teleportation floor. (default: null)
  52668. */
  52669. floorMeshName?: string;
  52670. /**
  52671. * A list of meshes to be used as the teleportation floor. (default: empty)
  52672. */
  52673. floorMeshes?: Mesh[];
  52674. /**
  52675. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  52676. */
  52677. teleportationMode?: number;
  52678. /**
  52679. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  52680. */
  52681. teleportationTime?: number;
  52682. /**
  52683. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  52684. */
  52685. teleportationSpeed?: number;
  52686. /**
  52687. * The easing function used in the animation or null for Linear. (default CircleEase)
  52688. */
  52689. easingFunction?: EasingFunction;
  52690. }
  52691. /**
  52692. * Options to modify the vr experience helper's behavior.
  52693. */
  52694. export interface VRExperienceHelperOptions extends WebVROptions {
  52695. /**
  52696. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  52697. */
  52698. createDeviceOrientationCamera?: boolean;
  52699. /**
  52700. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  52701. */
  52702. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  52703. /**
  52704. * Uses the main button on the controller to toggle the laser casted. (default: true)
  52705. */
  52706. laserToggle?: boolean;
  52707. /**
  52708. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  52709. */
  52710. floorMeshes?: Mesh[];
  52711. /**
  52712. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  52713. */
  52714. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  52715. /**
  52716. * Defines if WebXR should be used instead of WebVR (if available)
  52717. */
  52718. useXR?: boolean;
  52719. }
  52720. /**
  52721. * Event containing information after VR has been entered
  52722. */
  52723. export class OnAfterEnteringVRObservableEvent {
  52724. /**
  52725. * If entering vr was successful
  52726. */
  52727. success: boolean;
  52728. }
  52729. /**
  52730. * Helps to quickly add VR support to an existing scene.
  52731. * See https://doc.babylonjs.com/how_to/webvr_helper
  52732. */
  52733. export class VRExperienceHelper {
  52734. /** Options to modify the vr experience helper's behavior. */
  52735. webVROptions: VRExperienceHelperOptions;
  52736. private _scene;
  52737. private _position;
  52738. private _btnVR;
  52739. private _btnVRDisplayed;
  52740. private _webVRsupported;
  52741. private _webVRready;
  52742. private _webVRrequesting;
  52743. private _webVRpresenting;
  52744. private _hasEnteredVR;
  52745. private _fullscreenVRpresenting;
  52746. private _inputElement;
  52747. private _webVRCamera;
  52748. private _vrDeviceOrientationCamera;
  52749. private _deviceOrientationCamera;
  52750. private _existingCamera;
  52751. private _onKeyDown;
  52752. private _onVrDisplayPresentChange;
  52753. private _onVRDisplayChanged;
  52754. private _onVRRequestPresentStart;
  52755. private _onVRRequestPresentComplete;
  52756. /**
  52757. * 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)
  52758. */
  52759. enableGazeEvenWhenNoPointerLock: boolean;
  52760. /**
  52761. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  52762. */
  52763. exitVROnDoubleTap: boolean;
  52764. /**
  52765. * Observable raised right before entering VR.
  52766. */
  52767. onEnteringVRObservable: Observable<VRExperienceHelper>;
  52768. /**
  52769. * Observable raised when entering VR has completed.
  52770. */
  52771. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  52772. /**
  52773. * Observable raised when exiting VR.
  52774. */
  52775. onExitingVRObservable: Observable<VRExperienceHelper>;
  52776. /**
  52777. * Observable raised when controller mesh is loaded.
  52778. */
  52779. onControllerMeshLoadedObservable: Observable<WebVRController>;
  52780. /** Return this.onEnteringVRObservable
  52781. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  52782. */
  52783. get onEnteringVR(): Observable<VRExperienceHelper>;
  52784. /** Return this.onExitingVRObservable
  52785. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  52786. */
  52787. get onExitingVR(): Observable<VRExperienceHelper>;
  52788. /** Return this.onControllerMeshLoadedObservable
  52789. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  52790. */
  52791. get onControllerMeshLoaded(): Observable<WebVRController>;
  52792. private _rayLength;
  52793. private _useCustomVRButton;
  52794. private _teleportationRequested;
  52795. private _teleportActive;
  52796. private _floorMeshName;
  52797. private _floorMeshesCollection;
  52798. private _teleportationMode;
  52799. private _teleportationTime;
  52800. private _teleportationSpeed;
  52801. private _teleportationEasing;
  52802. private _rotationAllowed;
  52803. private _teleportBackwardsVector;
  52804. private _teleportationTarget;
  52805. private _isDefaultTeleportationTarget;
  52806. private _postProcessMove;
  52807. private _teleportationFillColor;
  52808. private _teleportationBorderColor;
  52809. private _rotationAngle;
  52810. private _haloCenter;
  52811. private _cameraGazer;
  52812. private _padSensibilityUp;
  52813. private _padSensibilityDown;
  52814. private _leftController;
  52815. private _rightController;
  52816. private _gazeColor;
  52817. private _laserColor;
  52818. private _pickedLaserColor;
  52819. private _pickedGazeColor;
  52820. /**
  52821. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  52822. */
  52823. onNewMeshSelected: Observable<AbstractMesh>;
  52824. /**
  52825. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  52826. * This observable will provide the mesh and the controller used to select the mesh
  52827. */
  52828. onMeshSelectedWithController: Observable<{
  52829. mesh: AbstractMesh;
  52830. controller: WebVRController;
  52831. }>;
  52832. /**
  52833. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  52834. */
  52835. onNewMeshPicked: Observable<PickingInfo>;
  52836. private _circleEase;
  52837. /**
  52838. * Observable raised before camera teleportation
  52839. */
  52840. onBeforeCameraTeleport: Observable<Vector3>;
  52841. /**
  52842. * Observable raised after camera teleportation
  52843. */
  52844. onAfterCameraTeleport: Observable<Vector3>;
  52845. /**
  52846. * Observable raised when current selected mesh gets unselected
  52847. */
  52848. onSelectedMeshUnselected: Observable<AbstractMesh>;
  52849. private _raySelectionPredicate;
  52850. /**
  52851. * To be optionaly changed by user to define custom ray selection
  52852. */
  52853. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52854. /**
  52855. * To be optionaly changed by user to define custom selection logic (after ray selection)
  52856. */
  52857. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52858. /**
  52859. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  52860. */
  52861. teleportationEnabled: boolean;
  52862. private _defaultHeight;
  52863. private _teleportationInitialized;
  52864. private _interactionsEnabled;
  52865. private _interactionsRequested;
  52866. private _displayGaze;
  52867. private _displayLaserPointer;
  52868. /**
  52869. * The mesh used to display where the user is going to teleport.
  52870. */
  52871. get teleportationTarget(): Mesh;
  52872. /**
  52873. * Sets the mesh to be used to display where the user is going to teleport.
  52874. */
  52875. set teleportationTarget(value: Mesh);
  52876. /**
  52877. * 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
  52878. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  52879. * See https://doc.babylonjs.com/resources/baking_transformations
  52880. */
  52881. get gazeTrackerMesh(): Mesh;
  52882. set gazeTrackerMesh(value: Mesh);
  52883. /**
  52884. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  52885. */
  52886. updateGazeTrackerScale: boolean;
  52887. /**
  52888. * If the gaze trackers color should be updated when selecting meshes
  52889. */
  52890. updateGazeTrackerColor: boolean;
  52891. /**
  52892. * If the controller laser color should be updated when selecting meshes
  52893. */
  52894. updateControllerLaserColor: boolean;
  52895. /**
  52896. * The gaze tracking mesh corresponding to the left controller
  52897. */
  52898. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  52899. /**
  52900. * The gaze tracking mesh corresponding to the right controller
  52901. */
  52902. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  52903. /**
  52904. * If the ray of the gaze should be displayed.
  52905. */
  52906. get displayGaze(): boolean;
  52907. /**
  52908. * Sets if the ray of the gaze should be displayed.
  52909. */
  52910. set displayGaze(value: boolean);
  52911. /**
  52912. * If the ray of the LaserPointer should be displayed.
  52913. */
  52914. get displayLaserPointer(): boolean;
  52915. /**
  52916. * Sets if the ray of the LaserPointer should be displayed.
  52917. */
  52918. set displayLaserPointer(value: boolean);
  52919. /**
  52920. * The deviceOrientationCamera used as the camera when not in VR.
  52921. */
  52922. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  52923. /**
  52924. * Based on the current WebVR support, returns the current VR camera used.
  52925. */
  52926. get currentVRCamera(): Nullable<Camera>;
  52927. /**
  52928. * The webVRCamera which is used when in VR.
  52929. */
  52930. get webVRCamera(): WebVRFreeCamera;
  52931. /**
  52932. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  52933. */
  52934. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  52935. /**
  52936. * The html button that is used to trigger entering into VR.
  52937. */
  52938. get vrButton(): Nullable<HTMLButtonElement>;
  52939. private get _teleportationRequestInitiated();
  52940. /**
  52941. * Defines whether or not Pointer lock should be requested when switching to
  52942. * full screen.
  52943. */
  52944. requestPointerLockOnFullScreen: boolean;
  52945. /**
  52946. * If asking to force XR, this will be populated with the default xr experience
  52947. */
  52948. xr: WebXRDefaultExperience;
  52949. /**
  52950. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  52951. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  52952. */
  52953. xrTestDone: boolean;
  52954. /**
  52955. * Instantiates a VRExperienceHelper.
  52956. * Helps to quickly add VR support to an existing scene.
  52957. * @param scene The scene the VRExperienceHelper belongs to.
  52958. * @param webVROptions Options to modify the vr experience helper's behavior.
  52959. */
  52960. constructor(scene: Scene,
  52961. /** Options to modify the vr experience helper's behavior. */
  52962. webVROptions?: VRExperienceHelperOptions);
  52963. private completeVRInit;
  52964. private _onDefaultMeshLoaded;
  52965. private _onResize;
  52966. private _onFullscreenChange;
  52967. /**
  52968. * Gets a value indicating if we are currently in VR mode.
  52969. */
  52970. get isInVRMode(): boolean;
  52971. private onVrDisplayPresentChange;
  52972. private onVRDisplayChanged;
  52973. private moveButtonToBottomRight;
  52974. private displayVRButton;
  52975. private updateButtonVisibility;
  52976. private _cachedAngularSensibility;
  52977. /**
  52978. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  52979. * Otherwise, will use the fullscreen API.
  52980. */
  52981. enterVR(): void;
  52982. /**
  52983. * Attempt to exit VR, or fullscreen.
  52984. */
  52985. exitVR(): void;
  52986. /**
  52987. * The position of the vr experience helper.
  52988. */
  52989. get position(): Vector3;
  52990. /**
  52991. * Sets the position of the vr experience helper.
  52992. */
  52993. set position(value: Vector3);
  52994. /**
  52995. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  52996. */
  52997. enableInteractions(): void;
  52998. private get _noControllerIsActive();
  52999. private beforeRender;
  53000. private _isTeleportationFloor;
  53001. /**
  53002. * Adds a floor mesh to be used for teleportation.
  53003. * @param floorMesh the mesh to be used for teleportation.
  53004. */
  53005. addFloorMesh(floorMesh: Mesh): void;
  53006. /**
  53007. * Removes a floor mesh from being used for teleportation.
  53008. * @param floorMesh the mesh to be removed.
  53009. */
  53010. removeFloorMesh(floorMesh: Mesh): void;
  53011. /**
  53012. * Enables interactions and teleportation using the VR controllers and gaze.
  53013. * @param vrTeleportationOptions options to modify teleportation behavior.
  53014. */
  53015. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53016. private _onNewGamepadConnected;
  53017. private _tryEnableInteractionOnController;
  53018. private _onNewGamepadDisconnected;
  53019. private _enableInteractionOnController;
  53020. private _checkTeleportWithRay;
  53021. private _checkRotate;
  53022. private _checkTeleportBackwards;
  53023. private _enableTeleportationOnController;
  53024. private _createTeleportationCircles;
  53025. private _displayTeleportationTarget;
  53026. private _hideTeleportationTarget;
  53027. private _rotateCamera;
  53028. private _moveTeleportationSelectorTo;
  53029. private _workingVector;
  53030. private _workingQuaternion;
  53031. private _workingMatrix;
  53032. /**
  53033. * Time Constant Teleportation Mode
  53034. */
  53035. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53036. /**
  53037. * Speed Constant Teleportation Mode
  53038. */
  53039. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53040. /**
  53041. * Teleports the users feet to the desired location
  53042. * @param location The location where the user's feet should be placed
  53043. */
  53044. teleportCamera(location: Vector3): void;
  53045. private _convertNormalToDirectionOfRay;
  53046. private _castRayAndSelectObject;
  53047. private _notifySelectedMeshUnselected;
  53048. /**
  53049. * Permanently set new colors for the laser pointer
  53050. * @param color the new laser color
  53051. * @param pickedColor the new laser color when picked mesh detected
  53052. */
  53053. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53054. /**
  53055. * Set lighting enabled / disabled on the laser pointer of both controllers
  53056. * @param enabled should the lighting be enabled on the laser pointer
  53057. */
  53058. setLaserLightingState(enabled?: boolean): void;
  53059. /**
  53060. * Permanently set new colors for the gaze pointer
  53061. * @param color the new gaze color
  53062. * @param pickedColor the new gaze color when picked mesh detected
  53063. */
  53064. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53065. /**
  53066. * Sets the color of the laser ray from the vr controllers.
  53067. * @param color new color for the ray.
  53068. */
  53069. changeLaserColor(color: Color3): void;
  53070. /**
  53071. * Sets the color of the ray from the vr headsets gaze.
  53072. * @param color new color for the ray.
  53073. */
  53074. changeGazeColor(color: Color3): void;
  53075. /**
  53076. * Exits VR and disposes of the vr experience helper
  53077. */
  53078. dispose(): void;
  53079. /**
  53080. * Gets the name of the VRExperienceHelper class
  53081. * @returns "VRExperienceHelper"
  53082. */
  53083. getClassName(): string;
  53084. }
  53085. }
  53086. declare module BABYLON {
  53087. /**
  53088. * Contains an array of blocks representing the octree
  53089. */
  53090. export interface IOctreeContainer<T> {
  53091. /**
  53092. * Blocks within the octree
  53093. */
  53094. blocks: Array<OctreeBlock<T>>;
  53095. }
  53096. /**
  53097. * Class used to store a cell in an octree
  53098. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53099. */
  53100. export class OctreeBlock<T> {
  53101. /**
  53102. * Gets the content of the current block
  53103. */
  53104. entries: T[];
  53105. /**
  53106. * Gets the list of block children
  53107. */
  53108. blocks: Array<OctreeBlock<T>>;
  53109. private _depth;
  53110. private _maxDepth;
  53111. private _capacity;
  53112. private _minPoint;
  53113. private _maxPoint;
  53114. private _boundingVectors;
  53115. private _creationFunc;
  53116. /**
  53117. * Creates a new block
  53118. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53119. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53120. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53121. * @param depth defines the current depth of this block in the octree
  53122. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53123. * @param creationFunc defines a callback to call when an element is added to the block
  53124. */
  53125. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53126. /**
  53127. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53128. */
  53129. get capacity(): number;
  53130. /**
  53131. * Gets the minimum vector (in world space) of the block's bounding box
  53132. */
  53133. get minPoint(): Vector3;
  53134. /**
  53135. * Gets the maximum vector (in world space) of the block's bounding box
  53136. */
  53137. get maxPoint(): Vector3;
  53138. /**
  53139. * Add a new element to this block
  53140. * @param entry defines the element to add
  53141. */
  53142. addEntry(entry: T): void;
  53143. /**
  53144. * Remove an element from this block
  53145. * @param entry defines the element to remove
  53146. */
  53147. removeEntry(entry: T): void;
  53148. /**
  53149. * Add an array of elements to this block
  53150. * @param entries defines the array of elements to add
  53151. */
  53152. addEntries(entries: T[]): void;
  53153. /**
  53154. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53155. * @param frustumPlanes defines the frustum planes to test
  53156. * @param selection defines the array to store current content if selection is positive
  53157. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53158. */
  53159. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53160. /**
  53161. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53162. * @param sphereCenter defines the bounding sphere center
  53163. * @param sphereRadius defines the bounding sphere radius
  53164. * @param selection defines the array to store current content if selection is positive
  53165. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53166. */
  53167. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53168. /**
  53169. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53170. * @param ray defines the ray to test with
  53171. * @param selection defines the array to store current content if selection is positive
  53172. */
  53173. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53174. /**
  53175. * Subdivide the content into child blocks (this block will then be empty)
  53176. */
  53177. createInnerBlocks(): void;
  53178. /**
  53179. * @hidden
  53180. */
  53181. 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;
  53182. }
  53183. }
  53184. declare module BABYLON {
  53185. /**
  53186. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53187. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53188. */
  53189. export class Octree<T> {
  53190. /** 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.) */
  53191. maxDepth: number;
  53192. /**
  53193. * Blocks within the octree containing objects
  53194. */
  53195. blocks: Array<OctreeBlock<T>>;
  53196. /**
  53197. * Content stored in the octree
  53198. */
  53199. dynamicContent: T[];
  53200. private _maxBlockCapacity;
  53201. private _selectionContent;
  53202. private _creationFunc;
  53203. /**
  53204. * Creates a octree
  53205. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53206. * @param creationFunc function to be used to instatiate the octree
  53207. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53208. * @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.)
  53209. */
  53210. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53211. /** 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.) */
  53212. maxDepth?: number);
  53213. /**
  53214. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53215. * @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);
  53216. * @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);
  53217. * @param entries meshes to be added to the octree blocks
  53218. */
  53219. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53220. /**
  53221. * Adds a mesh to the octree
  53222. * @param entry Mesh to add to the octree
  53223. */
  53224. addMesh(entry: T): void;
  53225. /**
  53226. * Remove an element from the octree
  53227. * @param entry defines the element to remove
  53228. */
  53229. removeMesh(entry: T): void;
  53230. /**
  53231. * Selects an array of meshes within the frustum
  53232. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53233. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53234. * @returns array of meshes within the frustum
  53235. */
  53236. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53237. /**
  53238. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53239. * @param sphereCenter defines the bounding sphere center
  53240. * @param sphereRadius defines the bounding sphere radius
  53241. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53242. * @returns an array of objects that intersect the sphere
  53243. */
  53244. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53245. /**
  53246. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53247. * @param ray defines the ray to test with
  53248. * @returns array of intersected objects
  53249. */
  53250. intersectsRay(ray: Ray): SmartArray<T>;
  53251. /**
  53252. * Adds a mesh into the octree block if it intersects the block
  53253. */
  53254. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53255. /**
  53256. * Adds a submesh into the octree block if it intersects the block
  53257. */
  53258. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53259. }
  53260. }
  53261. declare module BABYLON {
  53262. interface Scene {
  53263. /**
  53264. * @hidden
  53265. * Backing Filed
  53266. */
  53267. _selectionOctree: Octree<AbstractMesh>;
  53268. /**
  53269. * Gets the octree used to boost mesh selection (picking)
  53270. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53271. */
  53272. selectionOctree: Octree<AbstractMesh>;
  53273. /**
  53274. * Creates or updates the octree used to boost selection (picking)
  53275. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53276. * @param maxCapacity defines the maximum capacity per leaf
  53277. * @param maxDepth defines the maximum depth of the octree
  53278. * @returns an octree of AbstractMesh
  53279. */
  53280. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53281. }
  53282. interface AbstractMesh {
  53283. /**
  53284. * @hidden
  53285. * Backing Field
  53286. */
  53287. _submeshesOctree: Octree<SubMesh>;
  53288. /**
  53289. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53290. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53291. * @param maxCapacity defines the maximum size of each block (64 by default)
  53292. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53293. * @returns the new octree
  53294. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53295. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53296. */
  53297. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53298. }
  53299. /**
  53300. * Defines the octree scene component responsible to manage any octrees
  53301. * in a given scene.
  53302. */
  53303. export class OctreeSceneComponent {
  53304. /**
  53305. * The component name help to identify the component in the list of scene components.
  53306. */
  53307. readonly name: string;
  53308. /**
  53309. * The scene the component belongs to.
  53310. */
  53311. scene: Scene;
  53312. /**
  53313. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53314. */
  53315. readonly checksIsEnabled: boolean;
  53316. /**
  53317. * Creates a new instance of the component for the given scene
  53318. * @param scene Defines the scene to register the component in
  53319. */
  53320. constructor(scene: Scene);
  53321. /**
  53322. * Registers the component in a given scene
  53323. */
  53324. register(): void;
  53325. /**
  53326. * Return the list of active meshes
  53327. * @returns the list of active meshes
  53328. */
  53329. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53330. /**
  53331. * Return the list of active sub meshes
  53332. * @param mesh The mesh to get the candidates sub meshes from
  53333. * @returns the list of active sub meshes
  53334. */
  53335. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53336. private _tempRay;
  53337. /**
  53338. * Return the list of sub meshes intersecting with a given local ray
  53339. * @param mesh defines the mesh to find the submesh for
  53340. * @param localRay defines the ray in local space
  53341. * @returns the list of intersecting sub meshes
  53342. */
  53343. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53344. /**
  53345. * Return the list of sub meshes colliding with a collider
  53346. * @param mesh defines the mesh to find the submesh for
  53347. * @param collider defines the collider to evaluate the collision against
  53348. * @returns the list of colliding sub meshes
  53349. */
  53350. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53351. /**
  53352. * Rebuilds the elements related to this component in case of
  53353. * context lost for instance.
  53354. */
  53355. rebuild(): void;
  53356. /**
  53357. * Disposes the component and the associated ressources.
  53358. */
  53359. dispose(): void;
  53360. }
  53361. }
  53362. declare module BABYLON {
  53363. /**
  53364. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53365. */
  53366. export class Gizmo implements IDisposable {
  53367. /** The utility layer the gizmo will be added to */
  53368. gizmoLayer: UtilityLayerRenderer;
  53369. /**
  53370. * The root mesh of the gizmo
  53371. */
  53372. _rootMesh: Mesh;
  53373. private _attachedMesh;
  53374. private _attachedNode;
  53375. /**
  53376. * Ratio for the scale of the gizmo (Default: 1)
  53377. */
  53378. protected _scaleRatio: number;
  53379. /**
  53380. * boolean updated by pointermove when a gizmo mesh is hovered
  53381. */
  53382. protected _isHovered: boolean;
  53383. /**
  53384. * Ratio for the scale of the gizmo (Default: 1)
  53385. */
  53386. set scaleRatio(value: number);
  53387. get scaleRatio(): number;
  53388. /**
  53389. * True when the mouse pointer is hovered a gizmo mesh
  53390. */
  53391. get isHovered(): boolean;
  53392. /**
  53393. * If a custom mesh has been set (Default: false)
  53394. */
  53395. protected _customMeshSet: boolean;
  53396. /**
  53397. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  53398. * * When set, interactions will be enabled
  53399. */
  53400. get attachedMesh(): Nullable<AbstractMesh>;
  53401. set attachedMesh(value: Nullable<AbstractMesh>);
  53402. /**
  53403. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  53404. * * When set, interactions will be enabled
  53405. */
  53406. get attachedNode(): Nullable<Node>;
  53407. set attachedNode(value: Nullable<Node>);
  53408. /**
  53409. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53410. * @param mesh The mesh to replace the default mesh of the gizmo
  53411. */
  53412. setCustomMesh(mesh: Mesh): void;
  53413. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  53414. /**
  53415. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  53416. */
  53417. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53418. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53419. /**
  53420. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  53421. */
  53422. updateGizmoPositionToMatchAttachedMesh: boolean;
  53423. /**
  53424. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  53425. */
  53426. updateScale: boolean;
  53427. protected _interactionsEnabled: boolean;
  53428. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53429. private _beforeRenderObserver;
  53430. private _tempQuaternion;
  53431. private _tempVector;
  53432. private _tempVector2;
  53433. private _tempMatrix1;
  53434. private _tempMatrix2;
  53435. private _rightHandtoLeftHandMatrix;
  53436. /**
  53437. * Creates a gizmo
  53438. * @param gizmoLayer The utility layer the gizmo will be added to
  53439. */
  53440. constructor(
  53441. /** The utility layer the gizmo will be added to */
  53442. gizmoLayer?: UtilityLayerRenderer);
  53443. /**
  53444. * Updates the gizmo to match the attached mesh's position/rotation
  53445. */
  53446. protected _update(): void;
  53447. /**
  53448. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  53449. * @param value Node, TransformNode or mesh
  53450. */
  53451. protected _matrixChanged(): void;
  53452. /**
  53453. * Disposes of the gizmo
  53454. */
  53455. dispose(): void;
  53456. }
  53457. }
  53458. declare module BABYLON {
  53459. /**
  53460. * Single plane drag gizmo
  53461. */
  53462. export class PlaneDragGizmo extends Gizmo {
  53463. /**
  53464. * Drag behavior responsible for the gizmos dragging interactions
  53465. */
  53466. dragBehavior: PointerDragBehavior;
  53467. private _pointerObserver;
  53468. /**
  53469. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53470. */
  53471. snapDistance: number;
  53472. /**
  53473. * Event that fires each time the gizmo snaps to a new location.
  53474. * * snapDistance is the the change in distance
  53475. */
  53476. onSnapObservable: Observable<{
  53477. snapDistance: number;
  53478. }>;
  53479. private _plane;
  53480. private _coloredMaterial;
  53481. private _hoverMaterial;
  53482. private _isEnabled;
  53483. private _parent;
  53484. /** @hidden */
  53485. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  53486. /** @hidden */
  53487. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53488. /**
  53489. * Creates a PlaneDragGizmo
  53490. * @param gizmoLayer The utility layer the gizmo will be added to
  53491. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  53492. * @param color The color of the gizmo
  53493. */
  53494. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  53495. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53496. /**
  53497. * If the gizmo is enabled
  53498. */
  53499. set isEnabled(value: boolean);
  53500. get isEnabled(): boolean;
  53501. /**
  53502. * Disposes of the gizmo
  53503. */
  53504. dispose(): void;
  53505. }
  53506. }
  53507. declare module BABYLON {
  53508. /**
  53509. * Gizmo that enables dragging a mesh along 3 axis
  53510. */
  53511. export class PositionGizmo extends Gizmo {
  53512. /**
  53513. * Internal gizmo used for interactions on the x axis
  53514. */
  53515. xGizmo: AxisDragGizmo;
  53516. /**
  53517. * Internal gizmo used for interactions on the y axis
  53518. */
  53519. yGizmo: AxisDragGizmo;
  53520. /**
  53521. * Internal gizmo used for interactions on the z axis
  53522. */
  53523. zGizmo: AxisDragGizmo;
  53524. /**
  53525. * Internal gizmo used for interactions on the yz plane
  53526. */
  53527. xPlaneGizmo: PlaneDragGizmo;
  53528. /**
  53529. * Internal gizmo used for interactions on the xz plane
  53530. */
  53531. yPlaneGizmo: PlaneDragGizmo;
  53532. /**
  53533. * Internal gizmo used for interactions on the xy plane
  53534. */
  53535. zPlaneGizmo: PlaneDragGizmo;
  53536. /**
  53537. * private variables
  53538. */
  53539. private _meshAttached;
  53540. private _nodeAttached;
  53541. private _snapDistance;
  53542. /** Fires an event when any of it's sub gizmos are dragged */
  53543. onDragStartObservable: Observable<unknown>;
  53544. /** Fires an event when any of it's sub gizmos are released from dragging */
  53545. onDragEndObservable: Observable<unknown>;
  53546. /**
  53547. * If set to true, planar drag is enabled
  53548. */
  53549. private _planarGizmoEnabled;
  53550. get attachedMesh(): Nullable<AbstractMesh>;
  53551. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53552. get attachedNode(): Nullable<Node>;
  53553. set attachedNode(node: Nullable<Node>);
  53554. /**
  53555. * True when the mouse pointer is hovering a gizmo mesh
  53556. */
  53557. get isHovered(): boolean;
  53558. /**
  53559. * Creates a PositionGizmo
  53560. * @param gizmoLayer The utility layer the gizmo will be added to
  53561. @param thickness display gizmo axis thickness
  53562. */
  53563. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53564. /**
  53565. * If the planar drag gizmo is enabled
  53566. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  53567. */
  53568. set planarGizmoEnabled(value: boolean);
  53569. get planarGizmoEnabled(): boolean;
  53570. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53571. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53572. /**
  53573. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53574. */
  53575. set snapDistance(value: number);
  53576. get snapDistance(): number;
  53577. /**
  53578. * Ratio for the scale of the gizmo (Default: 1)
  53579. */
  53580. set scaleRatio(value: number);
  53581. get scaleRatio(): number;
  53582. /**
  53583. * Disposes of the gizmo
  53584. */
  53585. dispose(): void;
  53586. /**
  53587. * CustomMeshes are not supported by this gizmo
  53588. * @param mesh The mesh to replace the default mesh of the gizmo
  53589. */
  53590. setCustomMesh(mesh: Mesh): void;
  53591. }
  53592. }
  53593. declare module BABYLON {
  53594. /**
  53595. * Single axis drag gizmo
  53596. */
  53597. export class AxisDragGizmo extends Gizmo {
  53598. /**
  53599. * Drag behavior responsible for the gizmos dragging interactions
  53600. */
  53601. dragBehavior: PointerDragBehavior;
  53602. private _pointerObserver;
  53603. /**
  53604. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53605. */
  53606. snapDistance: number;
  53607. /**
  53608. * Event that fires each time the gizmo snaps to a new location.
  53609. * * snapDistance is the the change in distance
  53610. */
  53611. onSnapObservable: Observable<{
  53612. snapDistance: number;
  53613. }>;
  53614. private _isEnabled;
  53615. private _parent;
  53616. private _arrow;
  53617. private _coloredMaterial;
  53618. private _hoverMaterial;
  53619. /** @hidden */
  53620. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  53621. /** @hidden */
  53622. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53623. /**
  53624. * Creates an AxisDragGizmo
  53625. * @param gizmoLayer The utility layer the gizmo will be added to
  53626. * @param dragAxis The axis which the gizmo will be able to drag on
  53627. * @param color The color of the gizmo
  53628. * @param thickness display gizmo axis thickness
  53629. */
  53630. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  53631. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53632. /**
  53633. * If the gizmo is enabled
  53634. */
  53635. set isEnabled(value: boolean);
  53636. get isEnabled(): boolean;
  53637. /**
  53638. * Disposes of the gizmo
  53639. */
  53640. dispose(): void;
  53641. }
  53642. }
  53643. declare module BABYLON.Debug {
  53644. /**
  53645. * The Axes viewer will show 3 axes in a specific point in space
  53646. */
  53647. export class AxesViewer {
  53648. private _xAxis;
  53649. private _yAxis;
  53650. private _zAxis;
  53651. private _scaleLinesFactor;
  53652. private _instanced;
  53653. /**
  53654. * Gets the hosting scene
  53655. */
  53656. scene: Nullable<Scene>;
  53657. /**
  53658. * Gets or sets a number used to scale line length
  53659. */
  53660. scaleLines: number;
  53661. /** Gets the node hierarchy used to render x-axis */
  53662. get xAxis(): TransformNode;
  53663. /** Gets the node hierarchy used to render y-axis */
  53664. get yAxis(): TransformNode;
  53665. /** Gets the node hierarchy used to render z-axis */
  53666. get zAxis(): TransformNode;
  53667. /**
  53668. * Creates a new AxesViewer
  53669. * @param scene defines the hosting scene
  53670. * @param scaleLines defines a number used to scale line length (1 by default)
  53671. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  53672. * @param xAxis defines the node hierarchy used to render the x-axis
  53673. * @param yAxis defines the node hierarchy used to render the y-axis
  53674. * @param zAxis defines the node hierarchy used to render the z-axis
  53675. */
  53676. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  53677. /**
  53678. * Force the viewer to update
  53679. * @param position defines the position of the viewer
  53680. * @param xaxis defines the x axis of the viewer
  53681. * @param yaxis defines the y axis of the viewer
  53682. * @param zaxis defines the z axis of the viewer
  53683. */
  53684. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  53685. /**
  53686. * Creates an instance of this axes viewer.
  53687. * @returns a new axes viewer with instanced meshes
  53688. */
  53689. createInstance(): AxesViewer;
  53690. /** Releases resources */
  53691. dispose(): void;
  53692. private static _SetRenderingGroupId;
  53693. }
  53694. }
  53695. declare module BABYLON.Debug {
  53696. /**
  53697. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  53698. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  53699. */
  53700. export class BoneAxesViewer extends AxesViewer {
  53701. /**
  53702. * Gets or sets the target mesh where to display the axes viewer
  53703. */
  53704. mesh: Nullable<Mesh>;
  53705. /**
  53706. * Gets or sets the target bone where to display the axes viewer
  53707. */
  53708. bone: Nullable<Bone>;
  53709. /** Gets current position */
  53710. pos: Vector3;
  53711. /** Gets direction of X axis */
  53712. xaxis: Vector3;
  53713. /** Gets direction of Y axis */
  53714. yaxis: Vector3;
  53715. /** Gets direction of Z axis */
  53716. zaxis: Vector3;
  53717. /**
  53718. * Creates a new BoneAxesViewer
  53719. * @param scene defines the hosting scene
  53720. * @param bone defines the target bone
  53721. * @param mesh defines the target mesh
  53722. * @param scaleLines defines a scaling factor for line length (1 by default)
  53723. */
  53724. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  53725. /**
  53726. * Force the viewer to update
  53727. */
  53728. update(): void;
  53729. /** Releases resources */
  53730. dispose(): void;
  53731. }
  53732. }
  53733. declare module BABYLON {
  53734. /**
  53735. * Interface used to define scene explorer extensibility option
  53736. */
  53737. export interface IExplorerExtensibilityOption {
  53738. /**
  53739. * Define the option label
  53740. */
  53741. label: string;
  53742. /**
  53743. * Defines the action to execute on click
  53744. */
  53745. action: (entity: any) => void;
  53746. }
  53747. /**
  53748. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  53749. */
  53750. export interface IExplorerExtensibilityGroup {
  53751. /**
  53752. * Defines a predicate to test if a given type mut be extended
  53753. */
  53754. predicate: (entity: any) => boolean;
  53755. /**
  53756. * Gets the list of options added to a type
  53757. */
  53758. entries: IExplorerExtensibilityOption[];
  53759. }
  53760. /**
  53761. * Interface used to define the options to use to create the Inspector
  53762. */
  53763. export interface IInspectorOptions {
  53764. /**
  53765. * Display in overlay mode (default: false)
  53766. */
  53767. overlay?: boolean;
  53768. /**
  53769. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  53770. */
  53771. globalRoot?: HTMLElement;
  53772. /**
  53773. * Display the Scene explorer
  53774. */
  53775. showExplorer?: boolean;
  53776. /**
  53777. * Display the property inspector
  53778. */
  53779. showInspector?: boolean;
  53780. /**
  53781. * Display in embed mode (both panes on the right)
  53782. */
  53783. embedMode?: boolean;
  53784. /**
  53785. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  53786. */
  53787. handleResize?: boolean;
  53788. /**
  53789. * Allow the panes to popup (default: true)
  53790. */
  53791. enablePopup?: boolean;
  53792. /**
  53793. * Allow the panes to be closed by users (default: true)
  53794. */
  53795. enableClose?: boolean;
  53796. /**
  53797. * Optional list of extensibility entries
  53798. */
  53799. explorerExtensibility?: IExplorerExtensibilityGroup[];
  53800. /**
  53801. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  53802. */
  53803. inspectorURL?: string;
  53804. /**
  53805. * Optional initial tab (default to DebugLayerTab.Properties)
  53806. */
  53807. initialTab?: DebugLayerTab;
  53808. }
  53809. interface Scene {
  53810. /**
  53811. * @hidden
  53812. * Backing field
  53813. */
  53814. _debugLayer: DebugLayer;
  53815. /**
  53816. * Gets the debug layer (aka Inspector) associated with the scene
  53817. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53818. */
  53819. debugLayer: DebugLayer;
  53820. }
  53821. /**
  53822. * Enum of inspector action tab
  53823. */
  53824. export enum DebugLayerTab {
  53825. /**
  53826. * Properties tag (default)
  53827. */
  53828. Properties = 0,
  53829. /**
  53830. * Debug tab
  53831. */
  53832. Debug = 1,
  53833. /**
  53834. * Statistics tab
  53835. */
  53836. Statistics = 2,
  53837. /**
  53838. * Tools tab
  53839. */
  53840. Tools = 3,
  53841. /**
  53842. * Settings tab
  53843. */
  53844. Settings = 4
  53845. }
  53846. /**
  53847. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53848. * what is happening in your scene
  53849. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53850. */
  53851. export class DebugLayer {
  53852. /**
  53853. * Define the url to get the inspector script from.
  53854. * By default it uses the babylonjs CDN.
  53855. * @ignoreNaming
  53856. */
  53857. static InspectorURL: string;
  53858. private _scene;
  53859. private BJSINSPECTOR;
  53860. private _onPropertyChangedObservable?;
  53861. /**
  53862. * Observable triggered when a property is changed through the inspector.
  53863. */
  53864. get onPropertyChangedObservable(): any;
  53865. /**
  53866. * Instantiates a new debug layer.
  53867. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53868. * what is happening in your scene
  53869. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53870. * @param scene Defines the scene to inspect
  53871. */
  53872. constructor(scene: Scene);
  53873. /** Creates the inspector window. */
  53874. private _createInspector;
  53875. /**
  53876. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  53877. * @param entity defines the entity to select
  53878. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  53879. */
  53880. select(entity: any, lineContainerTitles?: string | string[]): void;
  53881. /** Get the inspector from bundle or global */
  53882. private _getGlobalInspector;
  53883. /**
  53884. * Get if the inspector is visible or not.
  53885. * @returns true if visible otherwise, false
  53886. */
  53887. isVisible(): boolean;
  53888. /**
  53889. * Hide the inspector and close its window.
  53890. */
  53891. hide(): void;
  53892. /**
  53893. * Update the scene in the inspector
  53894. */
  53895. setAsActiveScene(): void;
  53896. /**
  53897. * Launch the debugLayer.
  53898. * @param config Define the configuration of the inspector
  53899. * @return a promise fulfilled when the debug layer is visible
  53900. */
  53901. show(config?: IInspectorOptions): Promise<DebugLayer>;
  53902. }
  53903. }
  53904. declare module BABYLON {
  53905. /**
  53906. * Class containing static functions to help procedurally build meshes
  53907. */
  53908. export class BoxBuilder {
  53909. /**
  53910. * Creates a box mesh
  53911. * * The parameter `size` sets the size (float) of each box side (default 1)
  53912. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53913. * * 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)
  53914. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53916. * * 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
  53917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53918. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53919. * @param name defines the name of the mesh
  53920. * @param options defines the options used to create the mesh
  53921. * @param scene defines the hosting scene
  53922. * @returns the box mesh
  53923. */
  53924. static CreateBox(name: string, options: {
  53925. size?: number;
  53926. width?: number;
  53927. height?: number;
  53928. depth?: number;
  53929. faceUV?: Vector4[];
  53930. faceColors?: Color4[];
  53931. sideOrientation?: number;
  53932. frontUVs?: Vector4;
  53933. backUVs?: Vector4;
  53934. wrap?: boolean;
  53935. topBaseAt?: number;
  53936. bottomBaseAt?: number;
  53937. updatable?: boolean;
  53938. }, scene?: Nullable<Scene>): Mesh;
  53939. }
  53940. }
  53941. declare module BABYLON.Debug {
  53942. /**
  53943. * Used to show the physics impostor around the specific mesh
  53944. */
  53945. export class PhysicsViewer {
  53946. /** @hidden */
  53947. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  53948. /** @hidden */
  53949. protected _meshes: Array<Nullable<AbstractMesh>>;
  53950. /** @hidden */
  53951. protected _scene: Nullable<Scene>;
  53952. /** @hidden */
  53953. protected _numMeshes: number;
  53954. /** @hidden */
  53955. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53956. private _renderFunction;
  53957. private _utilityLayer;
  53958. private _debugBoxMesh;
  53959. private _debugSphereMesh;
  53960. private _debugCylinderMesh;
  53961. private _debugMaterial;
  53962. private _debugMeshMeshes;
  53963. /**
  53964. * Creates a new PhysicsViewer
  53965. * @param scene defines the hosting scene
  53966. */
  53967. constructor(scene: Scene);
  53968. /** @hidden */
  53969. protected _updateDebugMeshes(): void;
  53970. /**
  53971. * Renders a specified physic impostor
  53972. * @param impostor defines the impostor to render
  53973. * @param targetMesh defines the mesh represented by the impostor
  53974. * @returns the new debug mesh used to render the impostor
  53975. */
  53976. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53977. /**
  53978. * Hides a specified physic impostor
  53979. * @param impostor defines the impostor to hide
  53980. */
  53981. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53982. private _getDebugMaterial;
  53983. private _getDebugBoxMesh;
  53984. private _getDebugSphereMesh;
  53985. private _getDebugCylinderMesh;
  53986. private _getDebugMeshMesh;
  53987. private _getDebugMesh;
  53988. /** Releases all resources */
  53989. dispose(): void;
  53990. }
  53991. }
  53992. declare module BABYLON {
  53993. /**
  53994. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53995. * in order to better appreciate the issue one might have.
  53996. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53997. */
  53998. export class RayHelper {
  53999. /**
  54000. * Defines the ray we are currently tryin to visualize.
  54001. */
  54002. ray: Nullable<Ray>;
  54003. private _renderPoints;
  54004. private _renderLine;
  54005. private _renderFunction;
  54006. private _scene;
  54007. private _onAfterRenderObserver;
  54008. private _onAfterStepObserver;
  54009. private _attachedToMesh;
  54010. private _meshSpaceDirection;
  54011. private _meshSpaceOrigin;
  54012. /**
  54013. * Helper function to create a colored helper in a scene in one line.
  54014. * @param ray Defines the ray we are currently tryin to visualize
  54015. * @param scene Defines the scene the ray is used in
  54016. * @param color Defines the color we want to see the ray in
  54017. * @returns The newly created ray helper.
  54018. */
  54019. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  54020. /**
  54021. * Instantiate a new ray helper.
  54022. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54023. * in order to better appreciate the issue one might have.
  54024. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54025. * @param ray Defines the ray we are currently tryin to visualize
  54026. */
  54027. constructor(ray: Ray);
  54028. /**
  54029. * Shows the ray we are willing to debug.
  54030. * @param scene Defines the scene the ray needs to be rendered in
  54031. * @param color Defines the color the ray needs to be rendered in
  54032. */
  54033. show(scene: Scene, color?: Color3): void;
  54034. /**
  54035. * Hides the ray we are debugging.
  54036. */
  54037. hide(): void;
  54038. private _render;
  54039. /**
  54040. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  54041. * @param mesh Defines the mesh we want the helper attached to
  54042. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  54043. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  54044. * @param length Defines the length of the ray
  54045. */
  54046. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  54047. /**
  54048. * Detach the ray helper from the mesh it has previously been attached to.
  54049. */
  54050. detachFromMesh(): void;
  54051. private _updateToMesh;
  54052. /**
  54053. * Dispose the helper and release its associated resources.
  54054. */
  54055. dispose(): void;
  54056. }
  54057. }
  54058. declare module BABYLON {
  54059. /**
  54060. * Defines the options associated with the creation of a SkeletonViewer.
  54061. */
  54062. export interface ISkeletonViewerOptions {
  54063. /** Should the system pause animations before building the Viewer? */
  54064. pauseAnimations: boolean;
  54065. /** Should the system return the skeleton to rest before building? */
  54066. returnToRest: boolean;
  54067. /** public Display Mode of the Viewer */
  54068. displayMode: number;
  54069. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54070. displayOptions: ISkeletonViewerDisplayOptions;
  54071. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54072. computeBonesUsingShaders: boolean;
  54073. /** Flag ignore non weighted bones */
  54074. useAllBones: boolean;
  54075. }
  54076. /**
  54077. * Defines how to display the various bone meshes for the viewer.
  54078. */
  54079. export interface ISkeletonViewerDisplayOptions {
  54080. /** How far down to start tapering the bone spurs */
  54081. midStep?: number;
  54082. /** How big is the midStep? */
  54083. midStepFactor?: number;
  54084. /** Base for the Sphere Size */
  54085. sphereBaseSize?: number;
  54086. /** The ratio of the sphere to the longest bone in units */
  54087. sphereScaleUnit?: number;
  54088. /** Ratio for the Sphere Size */
  54089. sphereFactor?: number;
  54090. /** Whether a spur should attach its far end to the child bone position */
  54091. spurFollowsChild?: boolean;
  54092. /** Whether to show local axes or not */
  54093. showLocalAxes?: boolean;
  54094. /** Length of each local axis */
  54095. localAxesSize?: number;
  54096. }
  54097. /**
  54098. * Defines the constructor options for the BoneWeight Shader.
  54099. */
  54100. export interface IBoneWeightShaderOptions {
  54101. /** Skeleton to Map */
  54102. skeleton: Skeleton;
  54103. /** Colors for Uninfluenced bones */
  54104. colorBase?: Color3;
  54105. /** Colors for 0.0-0.25 Weight bones */
  54106. colorZero?: Color3;
  54107. /** Color for 0.25-0.5 Weight Influence */
  54108. colorQuarter?: Color3;
  54109. /** Color for 0.5-0.75 Weight Influence */
  54110. colorHalf?: Color3;
  54111. /** Color for 0.75-1 Weight Influence */
  54112. colorFull?: Color3;
  54113. /** Color for Zero Weight Influence */
  54114. targetBoneIndex?: number;
  54115. }
  54116. /**
  54117. * Simple structure of the gradient steps for the Color Map.
  54118. */
  54119. export interface ISkeletonMapShaderColorMapKnot {
  54120. /** Color of the Knot */
  54121. color: Color3;
  54122. /** Location of the Knot */
  54123. location: number;
  54124. }
  54125. /**
  54126. * Defines the constructor options for the SkeletonMap Shader.
  54127. */
  54128. export interface ISkeletonMapShaderOptions {
  54129. /** Skeleton to Map */
  54130. skeleton: Skeleton;
  54131. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  54132. colorMap?: ISkeletonMapShaderColorMapKnot[];
  54133. }
  54134. }
  54135. declare module BABYLON {
  54136. /**
  54137. * Class containing static functions to help procedurally build meshes
  54138. */
  54139. export class RibbonBuilder {
  54140. /**
  54141. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54142. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54143. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54144. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54145. * * 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
  54146. * * 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
  54147. * * 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
  54148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54149. * * 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
  54150. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54151. * * 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
  54152. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54153. * * 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
  54154. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54156. * @param name defines the name of the mesh
  54157. * @param options defines the options used to create the mesh
  54158. * @param scene defines the hosting scene
  54159. * @returns the ribbon mesh
  54160. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54161. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54162. */
  54163. static CreateRibbon(name: string, options: {
  54164. pathArray: Vector3[][];
  54165. closeArray?: boolean;
  54166. closePath?: boolean;
  54167. offset?: number;
  54168. updatable?: boolean;
  54169. sideOrientation?: number;
  54170. frontUVs?: Vector4;
  54171. backUVs?: Vector4;
  54172. instance?: Mesh;
  54173. invertUV?: boolean;
  54174. uvs?: Vector2[];
  54175. colors?: Color4[];
  54176. }, scene?: Nullable<Scene>): Mesh;
  54177. }
  54178. }
  54179. declare module BABYLON {
  54180. /**
  54181. * Class containing static functions to help procedurally build meshes
  54182. */
  54183. export class ShapeBuilder {
  54184. /**
  54185. * 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.
  54186. * * 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.
  54187. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54188. * * 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.
  54189. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54190. * * 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
  54191. * * 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
  54192. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54194. * * 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
  54195. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54197. * @param name defines the name of the mesh
  54198. * @param options defines the options used to create the mesh
  54199. * @param scene defines the hosting scene
  54200. * @returns the extruded shape mesh
  54201. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54202. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54203. */
  54204. static ExtrudeShape(name: string, options: {
  54205. shape: Vector3[];
  54206. path: Vector3[];
  54207. scale?: number;
  54208. rotation?: number;
  54209. cap?: number;
  54210. updatable?: boolean;
  54211. sideOrientation?: number;
  54212. frontUVs?: Vector4;
  54213. backUVs?: Vector4;
  54214. instance?: Mesh;
  54215. invertUV?: boolean;
  54216. }, scene?: Nullable<Scene>): Mesh;
  54217. /**
  54218. * Creates an custom extruded shape mesh.
  54219. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54220. * * 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.
  54221. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54222. * * 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
  54223. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54224. * * 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
  54225. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54226. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54227. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54228. * * 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
  54229. * * 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
  54230. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54232. * * 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
  54233. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54235. * @param name defines the name of the mesh
  54236. * @param options defines the options used to create the mesh
  54237. * @param scene defines the hosting scene
  54238. * @returns the custom extruded shape mesh
  54239. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54240. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54242. */
  54243. static ExtrudeShapeCustom(name: string, options: {
  54244. shape: Vector3[];
  54245. path: Vector3[];
  54246. scaleFunction?: any;
  54247. rotationFunction?: any;
  54248. ribbonCloseArray?: boolean;
  54249. ribbonClosePath?: boolean;
  54250. cap?: number;
  54251. updatable?: boolean;
  54252. sideOrientation?: number;
  54253. frontUVs?: Vector4;
  54254. backUVs?: Vector4;
  54255. instance?: Mesh;
  54256. invertUV?: boolean;
  54257. }, scene?: Nullable<Scene>): Mesh;
  54258. private static _ExtrudeShapeGeneric;
  54259. }
  54260. }
  54261. declare module BABYLON.Debug {
  54262. /**
  54263. * Class used to render a debug view of a given skeleton
  54264. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  54265. */
  54266. export class SkeletonViewer {
  54267. /** defines the skeleton to render */
  54268. skeleton: Skeleton;
  54269. /** defines the mesh attached to the skeleton */
  54270. mesh: AbstractMesh;
  54271. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54272. autoUpdateBonesMatrices: boolean;
  54273. /** defines the rendering group id to use with the viewer */
  54274. renderingGroupId: number;
  54275. /** is the options for the viewer */
  54276. options: Partial<ISkeletonViewerOptions>;
  54277. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  54278. static readonly DISPLAY_LINES: number;
  54279. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  54280. static readonly DISPLAY_SPHERES: number;
  54281. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  54282. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  54283. /** public static method to create a BoneWeight Shader
  54284. * @param options The constructor options
  54285. * @param scene The scene that the shader is scoped to
  54286. * @returns The created ShaderMaterial
  54287. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  54288. */
  54289. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  54290. /** public static method to create a BoneWeight Shader
  54291. * @param options The constructor options
  54292. * @param scene The scene that the shader is scoped to
  54293. * @returns The created ShaderMaterial
  54294. */
  54295. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  54296. /** private static method to create a BoneWeight Shader
  54297. * @param size The size of the buffer to create (usually the bone count)
  54298. * @param colorMap The gradient data to generate
  54299. * @param scene The scene that the shader is scoped to
  54300. * @returns an Array of floats from the color gradient values
  54301. */
  54302. private static _CreateBoneMapColorBuffer;
  54303. /** If SkeletonViewer scene scope. */
  54304. private _scene;
  54305. /** Gets or sets the color used to render the skeleton */
  54306. color: Color3;
  54307. /** Array of the points of the skeleton fo the line view. */
  54308. private _debugLines;
  54309. /** The SkeletonViewers Mesh. */
  54310. private _debugMesh;
  54311. /** The local axes Meshes. */
  54312. private _localAxes;
  54313. /** If SkeletonViewer is enabled. */
  54314. private _isEnabled;
  54315. /** If SkeletonViewer is ready. */
  54316. private _ready;
  54317. /** SkeletonViewer render observable. */
  54318. private _obs;
  54319. /** The Utility Layer to render the gizmos in. */
  54320. private _utilityLayer;
  54321. private _boneIndices;
  54322. /** Gets the Scene. */
  54323. get scene(): Scene;
  54324. /** Gets the utilityLayer. */
  54325. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  54326. /** Checks Ready Status. */
  54327. get isReady(): Boolean;
  54328. /** Sets Ready Status. */
  54329. set ready(value: boolean);
  54330. /** Gets the debugMesh */
  54331. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  54332. /** Sets the debugMesh */
  54333. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  54334. /** Gets the displayMode */
  54335. get displayMode(): number;
  54336. /** Sets the displayMode */
  54337. set displayMode(value: number);
  54338. /**
  54339. * Creates a new SkeletonViewer
  54340. * @param skeleton defines the skeleton to render
  54341. * @param mesh defines the mesh attached to the skeleton
  54342. * @param scene defines the hosting scene
  54343. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  54344. * @param renderingGroupId defines the rendering group id to use with the viewer
  54345. * @param options All of the extra constructor options for the SkeletonViewer
  54346. */
  54347. constructor(
  54348. /** defines the skeleton to render */
  54349. skeleton: Skeleton,
  54350. /** defines the mesh attached to the skeleton */
  54351. mesh: AbstractMesh,
  54352. /** The Scene scope*/
  54353. scene: Scene,
  54354. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54355. autoUpdateBonesMatrices?: boolean,
  54356. /** defines the rendering group id to use with the viewer */
  54357. renderingGroupId?: number,
  54358. /** is the options for the viewer */
  54359. options?: Partial<ISkeletonViewerOptions>);
  54360. /** The Dynamic bindings for the update functions */
  54361. private _bindObs;
  54362. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  54363. update(): void;
  54364. /** Gets or sets a boolean indicating if the viewer is enabled */
  54365. set isEnabled(value: boolean);
  54366. get isEnabled(): boolean;
  54367. private _getBonePosition;
  54368. private _getLinesForBonesWithLength;
  54369. private _getLinesForBonesNoLength;
  54370. /** function to revert the mesh and scene back to the initial state. */
  54371. private _revert;
  54372. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  54373. private _getAbsoluteBindPoseToRef;
  54374. /** function to build and bind sphere joint points and spur bone representations. */
  54375. private _buildSpheresAndSpurs;
  54376. private _buildLocalAxes;
  54377. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  54378. private _displayLinesUpdate;
  54379. /** Changes the displayMode of the skeleton viewer
  54380. * @param mode The displayMode numerical value
  54381. */
  54382. changeDisplayMode(mode: number): void;
  54383. /** Sets a display option of the skeleton viewer
  54384. *
  54385. * | Option | Type | Default | Description |
  54386. * | ---------------- | ------- | ------- | ----------- |
  54387. * | 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`. |
  54388. * | 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`. |
  54389. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54390. * | 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`. |
  54391. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  54392. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  54393. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  54394. *
  54395. * @param option String of the option name
  54396. * @param value The numerical option value
  54397. */
  54398. changeDisplayOptions(option: string, value: number): void;
  54399. /** Release associated resources */
  54400. dispose(): void;
  54401. }
  54402. }
  54403. declare module BABYLON {
  54404. /**
  54405. * Enum for Device Types
  54406. */
  54407. export enum DeviceType {
  54408. /** Generic */
  54409. Generic = 0,
  54410. /** Keyboard */
  54411. Keyboard = 1,
  54412. /** Mouse */
  54413. Mouse = 2,
  54414. /** Touch Pointers */
  54415. Touch = 3,
  54416. /** PS4 Dual Shock */
  54417. DualShock = 4,
  54418. /** Xbox */
  54419. Xbox = 5,
  54420. /** Switch Controller */
  54421. Switch = 6
  54422. }
  54423. /**
  54424. * Enum for All Pointers (Touch/Mouse)
  54425. */
  54426. export enum PointerInput {
  54427. /** Horizontal Axis */
  54428. Horizontal = 0,
  54429. /** Vertical Axis */
  54430. Vertical = 1,
  54431. /** Left Click or Touch */
  54432. LeftClick = 2,
  54433. /** Middle Click */
  54434. MiddleClick = 3,
  54435. /** Right Click */
  54436. RightClick = 4,
  54437. /** Browser Back */
  54438. BrowserBack = 5,
  54439. /** Browser Forward */
  54440. BrowserForward = 6
  54441. }
  54442. /**
  54443. * Enum for Dual Shock Gamepad
  54444. */
  54445. export enum DualShockInput {
  54446. /** Cross */
  54447. Cross = 0,
  54448. /** Circle */
  54449. Circle = 1,
  54450. /** Square */
  54451. Square = 2,
  54452. /** Triangle */
  54453. Triangle = 3,
  54454. /** L1 */
  54455. L1 = 4,
  54456. /** R1 */
  54457. R1 = 5,
  54458. /** L2 */
  54459. L2 = 6,
  54460. /** R2 */
  54461. R2 = 7,
  54462. /** Share */
  54463. Share = 8,
  54464. /** Options */
  54465. Options = 9,
  54466. /** L3 */
  54467. L3 = 10,
  54468. /** R3 */
  54469. R3 = 11,
  54470. /** DPadUp */
  54471. DPadUp = 12,
  54472. /** DPadDown */
  54473. DPadDown = 13,
  54474. /** DPadLeft */
  54475. DPadLeft = 14,
  54476. /** DRight */
  54477. DPadRight = 15,
  54478. /** Home */
  54479. Home = 16,
  54480. /** TouchPad */
  54481. TouchPad = 17,
  54482. /** LStickXAxis */
  54483. LStickXAxis = 18,
  54484. /** LStickYAxis */
  54485. LStickYAxis = 19,
  54486. /** RStickXAxis */
  54487. RStickXAxis = 20,
  54488. /** RStickYAxis */
  54489. RStickYAxis = 21
  54490. }
  54491. /**
  54492. * Enum for Xbox Gamepad
  54493. */
  54494. export enum XboxInput {
  54495. /** A */
  54496. A = 0,
  54497. /** B */
  54498. B = 1,
  54499. /** X */
  54500. X = 2,
  54501. /** Y */
  54502. Y = 3,
  54503. /** LB */
  54504. LB = 4,
  54505. /** RB */
  54506. RB = 5,
  54507. /** LT */
  54508. LT = 6,
  54509. /** RT */
  54510. RT = 7,
  54511. /** Back */
  54512. Back = 8,
  54513. /** Start */
  54514. Start = 9,
  54515. /** LS */
  54516. LS = 10,
  54517. /** RS */
  54518. RS = 11,
  54519. /** DPadUp */
  54520. DPadUp = 12,
  54521. /** DPadDown */
  54522. DPadDown = 13,
  54523. /** DPadLeft */
  54524. DPadLeft = 14,
  54525. /** DRight */
  54526. DPadRight = 15,
  54527. /** Home */
  54528. Home = 16,
  54529. /** LStickXAxis */
  54530. LStickXAxis = 17,
  54531. /** LStickYAxis */
  54532. LStickYAxis = 18,
  54533. /** RStickXAxis */
  54534. RStickXAxis = 19,
  54535. /** RStickYAxis */
  54536. RStickYAxis = 20
  54537. }
  54538. /**
  54539. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  54540. */
  54541. export enum SwitchInput {
  54542. /** B */
  54543. B = 0,
  54544. /** A */
  54545. A = 1,
  54546. /** Y */
  54547. Y = 2,
  54548. /** X */
  54549. X = 3,
  54550. /** L */
  54551. L = 4,
  54552. /** R */
  54553. R = 5,
  54554. /** ZL */
  54555. ZL = 6,
  54556. /** ZR */
  54557. ZR = 7,
  54558. /** Minus */
  54559. Minus = 8,
  54560. /** Plus */
  54561. Plus = 9,
  54562. /** LS */
  54563. LS = 10,
  54564. /** RS */
  54565. RS = 11,
  54566. /** DPadUp */
  54567. DPadUp = 12,
  54568. /** DPadDown */
  54569. DPadDown = 13,
  54570. /** DPadLeft */
  54571. DPadLeft = 14,
  54572. /** DRight */
  54573. DPadRight = 15,
  54574. /** Home */
  54575. Home = 16,
  54576. /** Capture */
  54577. Capture = 17,
  54578. /** LStickXAxis */
  54579. LStickXAxis = 18,
  54580. /** LStickYAxis */
  54581. LStickYAxis = 19,
  54582. /** RStickXAxis */
  54583. RStickXAxis = 20,
  54584. /** RStickYAxis */
  54585. RStickYAxis = 21
  54586. }
  54587. }
  54588. declare module BABYLON {
  54589. /**
  54590. * This class will take all inputs from Keyboard, Pointer, and
  54591. * any Gamepads and provide a polling system that all devices
  54592. * will use. This class assumes that there will only be one
  54593. * pointer device and one keyboard.
  54594. */
  54595. export class DeviceInputSystem implements IDisposable {
  54596. /**
  54597. * Callback to be triggered when a device is connected
  54598. */
  54599. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54600. /**
  54601. * Callback to be triggered when a device is disconnected
  54602. */
  54603. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54604. /**
  54605. * Callback to be triggered when event driven input is updated
  54606. */
  54607. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  54608. private _inputs;
  54609. private _gamepads;
  54610. private _keyboardActive;
  54611. private _pointerActive;
  54612. private _elementToAttachTo;
  54613. private _keyboardDownEvent;
  54614. private _keyboardUpEvent;
  54615. private _pointerMoveEvent;
  54616. private _pointerDownEvent;
  54617. private _pointerUpEvent;
  54618. private _gamepadConnectedEvent;
  54619. private _gamepadDisconnectedEvent;
  54620. private static _MAX_KEYCODES;
  54621. private static _MAX_POINTER_INPUTS;
  54622. private constructor();
  54623. /**
  54624. * Creates a new DeviceInputSystem instance
  54625. * @param engine Engine to pull input element from
  54626. * @returns The new instance
  54627. */
  54628. static Create(engine: Engine): DeviceInputSystem;
  54629. /**
  54630. * Checks for current device input value, given an id and input index
  54631. * @param deviceName Id of connected device
  54632. * @param inputIndex Index of device input
  54633. * @returns Current value of input
  54634. */
  54635. /**
  54636. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  54637. * @param deviceType Enum specifiying device type
  54638. * @param deviceSlot "Slot" or index that device is referenced in
  54639. * @param inputIndex Id of input to be checked
  54640. * @returns Current value of input
  54641. */
  54642. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  54643. /**
  54644. * Dispose of all the eventlisteners
  54645. */
  54646. dispose(): void;
  54647. /**
  54648. * Add device and inputs to device array
  54649. * @param deviceType Enum specifiying device type
  54650. * @param deviceSlot "Slot" or index that device is referenced in
  54651. * @param numberOfInputs Number of input entries to create for given device
  54652. */
  54653. private _registerDevice;
  54654. /**
  54655. * Given a specific device name, remove that device from the device map
  54656. * @param deviceType Enum specifiying device type
  54657. * @param deviceSlot "Slot" or index that device is referenced in
  54658. */
  54659. private _unregisterDevice;
  54660. /**
  54661. * Handle all actions that come from keyboard interaction
  54662. */
  54663. private _handleKeyActions;
  54664. /**
  54665. * Handle all actions that come from pointer interaction
  54666. */
  54667. private _handlePointerActions;
  54668. /**
  54669. * Handle all actions that come from gamepad interaction
  54670. */
  54671. private _handleGamepadActions;
  54672. /**
  54673. * Update all non-event based devices with each frame
  54674. * @param deviceType Enum specifiying device type
  54675. * @param deviceSlot "Slot" or index that device is referenced in
  54676. * @param inputIndex Id of input to be checked
  54677. */
  54678. private _updateDevice;
  54679. /**
  54680. * Gets DeviceType from the device name
  54681. * @param deviceName Name of Device from DeviceInputSystem
  54682. * @returns DeviceType enum value
  54683. */
  54684. private _getGamepadDeviceType;
  54685. }
  54686. }
  54687. declare module BABYLON {
  54688. /**
  54689. * Type to handle enforcement of inputs
  54690. */
  54691. 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;
  54692. }
  54693. declare module BABYLON {
  54694. /**
  54695. * Class that handles all input for a specific device
  54696. */
  54697. export class DeviceSource<T extends DeviceType> {
  54698. /** Type of device */
  54699. readonly deviceType: DeviceType;
  54700. /** "Slot" or index that device is referenced in */
  54701. readonly deviceSlot: number;
  54702. /**
  54703. * Observable to handle device input changes per device
  54704. */
  54705. readonly onInputChangedObservable: Observable<{
  54706. inputIndex: DeviceInput<T>;
  54707. previousState: Nullable<number>;
  54708. currentState: Nullable<number>;
  54709. }>;
  54710. private readonly _deviceInputSystem;
  54711. /**
  54712. * Default Constructor
  54713. * @param deviceInputSystem Reference to DeviceInputSystem
  54714. * @param deviceType Type of device
  54715. * @param deviceSlot "Slot" or index that device is referenced in
  54716. */
  54717. constructor(deviceInputSystem: DeviceInputSystem,
  54718. /** Type of device */
  54719. deviceType: DeviceType,
  54720. /** "Slot" or index that device is referenced in */
  54721. deviceSlot?: number);
  54722. /**
  54723. * Get input for specific input
  54724. * @param inputIndex index of specific input on device
  54725. * @returns Input value from DeviceInputSystem
  54726. */
  54727. getInput(inputIndex: DeviceInput<T>): number;
  54728. }
  54729. /**
  54730. * Class to keep track of devices
  54731. */
  54732. export class DeviceSourceManager implements IDisposable {
  54733. /**
  54734. * Observable to be triggered when before a device is connected
  54735. */
  54736. readonly onBeforeDeviceConnectedObservable: Observable<{
  54737. deviceType: DeviceType;
  54738. deviceSlot: number;
  54739. }>;
  54740. /**
  54741. * Observable to be triggered when before a device is disconnected
  54742. */
  54743. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  54744. deviceType: DeviceType;
  54745. deviceSlot: number;
  54746. }>;
  54747. /**
  54748. * Observable to be triggered when after a device is connected
  54749. */
  54750. readonly onAfterDeviceConnectedObservable: Observable<{
  54751. deviceType: DeviceType;
  54752. deviceSlot: number;
  54753. }>;
  54754. /**
  54755. * Observable to be triggered when after a device is disconnected
  54756. */
  54757. readonly onAfterDeviceDisconnectedObservable: Observable<{
  54758. deviceType: DeviceType;
  54759. deviceSlot: number;
  54760. }>;
  54761. private readonly _devices;
  54762. private readonly _firstDevice;
  54763. private readonly _deviceInputSystem;
  54764. /**
  54765. * Default Constructor
  54766. * @param engine engine to pull input element from
  54767. */
  54768. constructor(engine: Engine);
  54769. /**
  54770. * Gets a DeviceSource, given a type and slot
  54771. * @param deviceType Enum specifying device type
  54772. * @param deviceSlot "Slot" or index that device is referenced in
  54773. * @returns DeviceSource object
  54774. */
  54775. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  54776. /**
  54777. * Gets an array of DeviceSource objects for a given device type
  54778. * @param deviceType Enum specifying device type
  54779. * @returns Array of DeviceSource objects
  54780. */
  54781. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  54782. /**
  54783. * Dispose of DeviceInputSystem and other parts
  54784. */
  54785. dispose(): void;
  54786. /**
  54787. * Function to add device name to device list
  54788. * @param deviceType Enum specifying device type
  54789. * @param deviceSlot "Slot" or index that device is referenced in
  54790. */
  54791. private _addDevice;
  54792. /**
  54793. * Function to remove device name to device list
  54794. * @param deviceType Enum specifying device type
  54795. * @param deviceSlot "Slot" or index that device is referenced in
  54796. */
  54797. private _removeDevice;
  54798. /**
  54799. * Updates array storing first connected device of each type
  54800. * @param type Type of Device
  54801. */
  54802. private _updateFirstDevices;
  54803. }
  54804. }
  54805. declare module BABYLON {
  54806. /**
  54807. * Options to create the null engine
  54808. */
  54809. export class NullEngineOptions {
  54810. /**
  54811. * Render width (Default: 512)
  54812. */
  54813. renderWidth: number;
  54814. /**
  54815. * Render height (Default: 256)
  54816. */
  54817. renderHeight: number;
  54818. /**
  54819. * Texture size (Default: 512)
  54820. */
  54821. textureSize: number;
  54822. /**
  54823. * If delta time between frames should be constant
  54824. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54825. */
  54826. deterministicLockstep: boolean;
  54827. /**
  54828. * Maximum about of steps between frames (Default: 4)
  54829. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54830. */
  54831. lockstepMaxSteps: number;
  54832. /**
  54833. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54834. */
  54835. useHighPrecisionMatrix?: boolean;
  54836. }
  54837. /**
  54838. * The null engine class provides support for headless version of babylon.js.
  54839. * This can be used in server side scenario or for testing purposes
  54840. */
  54841. export class NullEngine extends Engine {
  54842. private _options;
  54843. /**
  54844. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54845. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54846. * @returns true if engine is in deterministic lock step mode
  54847. */
  54848. isDeterministicLockStep(): boolean;
  54849. /**
  54850. * Gets the max steps when engine is running in deterministic lock step
  54851. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54852. * @returns the max steps
  54853. */
  54854. getLockstepMaxSteps(): number;
  54855. /**
  54856. * Gets the current hardware scaling level.
  54857. * By default the hardware scaling level is computed from the window device ratio.
  54858. * 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.
  54859. * @returns a number indicating the current hardware scaling level
  54860. */
  54861. getHardwareScalingLevel(): number;
  54862. constructor(options?: NullEngineOptions);
  54863. /**
  54864. * Creates a vertex buffer
  54865. * @param vertices the data for the vertex buffer
  54866. * @returns the new WebGL static buffer
  54867. */
  54868. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54869. /**
  54870. * Creates a new index buffer
  54871. * @param indices defines the content of the index buffer
  54872. * @param updatable defines if the index buffer must be updatable
  54873. * @returns a new webGL buffer
  54874. */
  54875. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54876. /**
  54877. * Clear the current render buffer or the current render target (if any is set up)
  54878. * @param color defines the color to use
  54879. * @param backBuffer defines if the back buffer must be cleared
  54880. * @param depth defines if the depth buffer must be cleared
  54881. * @param stencil defines if the stencil buffer must be cleared
  54882. */
  54883. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54884. /**
  54885. * Gets the current render width
  54886. * @param useScreen defines if screen size must be used (or the current render target if any)
  54887. * @returns a number defining the current render width
  54888. */
  54889. getRenderWidth(useScreen?: boolean): number;
  54890. /**
  54891. * Gets the current render height
  54892. * @param useScreen defines if screen size must be used (or the current render target if any)
  54893. * @returns a number defining the current render height
  54894. */
  54895. getRenderHeight(useScreen?: boolean): number;
  54896. /**
  54897. * Set the WebGL's viewport
  54898. * @param viewport defines the viewport element to be used
  54899. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54900. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54901. */
  54902. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54903. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54904. /**
  54905. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54906. * @param pipelineContext defines the pipeline context to use
  54907. * @param uniformsNames defines the list of uniform names
  54908. * @returns an array of webGL uniform locations
  54909. */
  54910. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54911. /**
  54912. * Gets the lsit of active attributes for a given webGL program
  54913. * @param pipelineContext defines the pipeline context to use
  54914. * @param attributesNames defines the list of attribute names to get
  54915. * @returns an array of indices indicating the offset of each attribute
  54916. */
  54917. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54918. /**
  54919. * Binds an effect to the webGL context
  54920. * @param effect defines the effect to bind
  54921. */
  54922. bindSamplers(effect: Effect): void;
  54923. /**
  54924. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54925. * @param effect defines the effect to activate
  54926. */
  54927. enableEffect(effect: Effect): void;
  54928. /**
  54929. * Set various states to the webGL context
  54930. * @param culling defines backface culling state
  54931. * @param zOffset defines the value to apply to zOffset (0 by default)
  54932. * @param force defines if states must be applied even if cache is up to date
  54933. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54934. */
  54935. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54936. /**
  54937. * Set the value of an uniform to an array of int32
  54938. * @param uniform defines the webGL uniform location where to store the value
  54939. * @param array defines the array of int32 to store
  54940. * @returns true if value was set
  54941. */
  54942. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54943. /**
  54944. * Set the value of an uniform to an array of int32 (stored as vec2)
  54945. * @param uniform defines the webGL uniform location where to store the value
  54946. * @param array defines the array of int32 to store
  54947. * @returns true if value was set
  54948. */
  54949. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54950. /**
  54951. * Set the value of an uniform to an array of int32 (stored as vec3)
  54952. * @param uniform defines the webGL uniform location where to store the value
  54953. * @param array defines the array of int32 to store
  54954. * @returns true if value was set
  54955. */
  54956. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54957. /**
  54958. * Set the value of an uniform to an array of int32 (stored as vec4)
  54959. * @param uniform defines the webGL uniform location where to store the value
  54960. * @param array defines the array of int32 to store
  54961. * @returns true if value was set
  54962. */
  54963. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54964. /**
  54965. * Set the value of an uniform to an array of float32
  54966. * @param uniform defines the webGL uniform location where to store the value
  54967. * @param array defines the array of float32 to store
  54968. * @returns true if value was set
  54969. */
  54970. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54971. /**
  54972. * Set the value of an uniform to an array of float32 (stored as vec2)
  54973. * @param uniform defines the webGL uniform location where to store the value
  54974. * @param array defines the array of float32 to store
  54975. * @returns true if value was set
  54976. */
  54977. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54978. /**
  54979. * Set the value of an uniform to an array of float32 (stored as vec3)
  54980. * @param uniform defines the webGL uniform location where to store the value
  54981. * @param array defines the array of float32 to store
  54982. * @returns true if value was set
  54983. */
  54984. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54985. /**
  54986. * Set the value of an uniform to an array of float32 (stored as vec4)
  54987. * @param uniform defines the webGL uniform location where to store the value
  54988. * @param array defines the array of float32 to store
  54989. * @returns true if value was set
  54990. */
  54991. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54992. /**
  54993. * Set the value of an uniform to an array of number
  54994. * @param uniform defines the webGL uniform location where to store the value
  54995. * @param array defines the array of number to store
  54996. * @returns true if value was set
  54997. */
  54998. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  54999. /**
  55000. * Set the value of an uniform to an array of number (stored as vec2)
  55001. * @param uniform defines the webGL uniform location where to store the value
  55002. * @param array defines the array of number to store
  55003. * @returns true if value was set
  55004. */
  55005. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55006. /**
  55007. * Set the value of an uniform to an array of number (stored as vec3)
  55008. * @param uniform defines the webGL uniform location where to store the value
  55009. * @param array defines the array of number to store
  55010. * @returns true if value was set
  55011. */
  55012. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55013. /**
  55014. * Set the value of an uniform to an array of number (stored as vec4)
  55015. * @param uniform defines the webGL uniform location where to store the value
  55016. * @param array defines the array of number to store
  55017. * @returns true if value was set
  55018. */
  55019. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55020. /**
  55021. * Set the value of an uniform to an array of float32 (stored as matrices)
  55022. * @param uniform defines the webGL uniform location where to store the value
  55023. * @param matrices defines the array of float32 to store
  55024. * @returns true if value was set
  55025. */
  55026. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55027. /**
  55028. * Set the value of an uniform to a matrix (3x3)
  55029. * @param uniform defines the webGL uniform location where to store the value
  55030. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  55031. * @returns true if value was set
  55032. */
  55033. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55034. /**
  55035. * Set the value of an uniform to a matrix (2x2)
  55036. * @param uniform defines the webGL uniform location where to store the value
  55037. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  55038. * @returns true if value was set
  55039. */
  55040. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55041. /**
  55042. * Set the value of an uniform to a number (float)
  55043. * @param uniform defines the webGL uniform location where to store the value
  55044. * @param value defines the float number to store
  55045. * @returns true if value was set
  55046. */
  55047. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55048. /**
  55049. * Set the value of an uniform to a vec2
  55050. * @param uniform defines the webGL uniform location where to store the value
  55051. * @param x defines the 1st component of the value
  55052. * @param y defines the 2nd component of the value
  55053. * @returns true if value was set
  55054. */
  55055. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55056. /**
  55057. * Set the value of an uniform to a vec3
  55058. * @param uniform defines the webGL uniform location where to store the value
  55059. * @param x defines the 1st component of the value
  55060. * @param y defines the 2nd component of the value
  55061. * @param z defines the 3rd component of the value
  55062. * @returns true if value was set
  55063. */
  55064. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55065. /**
  55066. * Set the value of an uniform to a boolean
  55067. * @param uniform defines the webGL uniform location where to store the value
  55068. * @param bool defines the boolean to store
  55069. * @returns true if value was set
  55070. */
  55071. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  55072. /**
  55073. * Set the value of an uniform to a vec4
  55074. * @param uniform defines the webGL uniform location where to store the value
  55075. * @param x defines the 1st component of the value
  55076. * @param y defines the 2nd component of the value
  55077. * @param z defines the 3rd component of the value
  55078. * @param w defines the 4th component of the value
  55079. * @returns true if value was set
  55080. */
  55081. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55082. /**
  55083. * Sets the current alpha mode
  55084. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  55085. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55086. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55087. */
  55088. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55089. /**
  55090. * Bind webGl buffers directly to the webGL context
  55091. * @param vertexBuffers defines the vertex buffer to bind
  55092. * @param indexBuffer defines the index buffer to bind
  55093. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  55094. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  55095. * @param effect defines the effect associated with the vertex buffer
  55096. */
  55097. bindBuffers(vertexBuffers: {
  55098. [key: string]: VertexBuffer;
  55099. }, indexBuffer: DataBuffer, effect: Effect): void;
  55100. /**
  55101. * Force the entire cache to be cleared
  55102. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  55103. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  55104. */
  55105. wipeCaches(bruteForce?: boolean): void;
  55106. /**
  55107. * Send a draw order
  55108. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  55109. * @param indexStart defines the starting index
  55110. * @param indexCount defines the number of index to draw
  55111. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55112. */
  55113. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  55114. /**
  55115. * Draw a list of indexed primitives
  55116. * @param fillMode defines the primitive to use
  55117. * @param indexStart defines the starting index
  55118. * @param indexCount defines the number of index to draw
  55119. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55120. */
  55121. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55122. /**
  55123. * Draw a list of unindexed primitives
  55124. * @param fillMode defines the primitive to use
  55125. * @param verticesStart defines the index of first vertex to draw
  55126. * @param verticesCount defines the count of vertices to draw
  55127. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55128. */
  55129. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55130. /** @hidden */
  55131. _createTexture(): WebGLTexture;
  55132. /** @hidden */
  55133. _releaseTexture(texture: InternalTexture): void;
  55134. /**
  55135. * Usually called from Texture.ts.
  55136. * Passed information to create a WebGLTexture
  55137. * @param urlArg defines a value which contains one of the following:
  55138. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55139. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55140. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55141. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55142. * @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)
  55143. * @param scene needed for loading to the correct scene
  55144. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55145. * @param onLoad optional callback to be called upon successful completion
  55146. * @param onError optional callback to be called upon failure
  55147. * @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
  55148. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55149. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55150. * @param forcedExtension defines the extension to use to pick the right loader
  55151. * @param mimeType defines an optional mime type
  55152. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55153. */
  55154. 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;
  55155. /**
  55156. * Creates a new render target texture
  55157. * @param size defines the size of the texture
  55158. * @param options defines the options used to create the texture
  55159. * @returns a new render target texture stored in an InternalTexture
  55160. */
  55161. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  55162. /**
  55163. * Update the sampling mode of a given texture
  55164. * @param samplingMode defines the required sampling mode
  55165. * @param texture defines the texture to update
  55166. */
  55167. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55168. /**
  55169. * Binds the frame buffer to the specified texture.
  55170. * @param texture The texture to render to or null for the default canvas
  55171. * @param faceIndex The face of the texture to render to in case of cube texture
  55172. * @param requiredWidth The width of the target to render to
  55173. * @param requiredHeight The height of the target to render to
  55174. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  55175. * @param lodLevel defines le lod level to bind to the frame buffer
  55176. */
  55177. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55178. /**
  55179. * Unbind the current render target texture from the webGL context
  55180. * @param texture defines the render target texture to unbind
  55181. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  55182. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  55183. */
  55184. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55185. /**
  55186. * Creates a dynamic vertex buffer
  55187. * @param vertices the data for the dynamic vertex buffer
  55188. * @returns the new WebGL dynamic buffer
  55189. */
  55190. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  55191. /**
  55192. * Update the content of a dynamic texture
  55193. * @param texture defines the texture to update
  55194. * @param canvas defines the canvas containing the source
  55195. * @param invertY defines if data must be stored with Y axis inverted
  55196. * @param premulAlpha defines if alpha is stored as premultiplied
  55197. * @param format defines the format of the data
  55198. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55199. */
  55200. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55201. /**
  55202. * Gets a boolean indicating if all created effects are ready
  55203. * @returns true if all effects are ready
  55204. */
  55205. areAllEffectsReady(): boolean;
  55206. /**
  55207. * @hidden
  55208. * Get the current error code of the webGL context
  55209. * @returns the error code
  55210. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  55211. */
  55212. getError(): number;
  55213. /** @hidden */
  55214. _getUnpackAlignement(): number;
  55215. /** @hidden */
  55216. _unpackFlipY(value: boolean): void;
  55217. /**
  55218. * Update a dynamic index buffer
  55219. * @param indexBuffer defines the target index buffer
  55220. * @param indices defines the data to update
  55221. * @param offset defines the offset in the target index buffer where update should start
  55222. */
  55223. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  55224. /**
  55225. * Updates a dynamic vertex buffer.
  55226. * @param vertexBuffer the vertex buffer to update
  55227. * @param vertices the data used to update the vertex buffer
  55228. * @param byteOffset the byte offset of the data (optional)
  55229. * @param byteLength the byte length of the data (optional)
  55230. */
  55231. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  55232. /** @hidden */
  55233. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  55234. /** @hidden */
  55235. _bindTexture(channel: number, texture: InternalTexture): void;
  55236. protected _deleteBuffer(buffer: WebGLBuffer): void;
  55237. /**
  55238. * 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
  55239. */
  55240. releaseEffects(): void;
  55241. displayLoadingUI(): void;
  55242. hideLoadingUI(): void;
  55243. /** @hidden */
  55244. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55245. /** @hidden */
  55246. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55247. /** @hidden */
  55248. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55249. /** @hidden */
  55250. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55251. }
  55252. }
  55253. declare module BABYLON {
  55254. /**
  55255. * @hidden
  55256. **/
  55257. export class _TimeToken {
  55258. _startTimeQuery: Nullable<WebGLQuery>;
  55259. _endTimeQuery: Nullable<WebGLQuery>;
  55260. _timeElapsedQuery: Nullable<WebGLQuery>;
  55261. _timeElapsedQueryEnded: boolean;
  55262. }
  55263. }
  55264. declare module BABYLON {
  55265. /** @hidden */
  55266. export class _OcclusionDataStorage {
  55267. /** @hidden */
  55268. occlusionInternalRetryCounter: number;
  55269. /** @hidden */
  55270. isOcclusionQueryInProgress: boolean;
  55271. /** @hidden */
  55272. isOccluded: boolean;
  55273. /** @hidden */
  55274. occlusionRetryCount: number;
  55275. /** @hidden */
  55276. occlusionType: number;
  55277. /** @hidden */
  55278. occlusionQueryAlgorithmType: number;
  55279. }
  55280. interface Engine {
  55281. /**
  55282. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  55283. * @return the new query
  55284. */
  55285. createQuery(): WebGLQuery;
  55286. /**
  55287. * Delete and release a webGL query
  55288. * @param query defines the query to delete
  55289. * @return the current engine
  55290. */
  55291. deleteQuery(query: WebGLQuery): Engine;
  55292. /**
  55293. * Check if a given query has resolved and got its value
  55294. * @param query defines the query to check
  55295. * @returns true if the query got its value
  55296. */
  55297. isQueryResultAvailable(query: WebGLQuery): boolean;
  55298. /**
  55299. * Gets the value of a given query
  55300. * @param query defines the query to check
  55301. * @returns the value of the query
  55302. */
  55303. getQueryResult(query: WebGLQuery): number;
  55304. /**
  55305. * Initiates an occlusion query
  55306. * @param algorithmType defines the algorithm to use
  55307. * @param query defines the query to use
  55308. * @returns the current engine
  55309. * @see https://doc.babylonjs.com/features/occlusionquery
  55310. */
  55311. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  55312. /**
  55313. * Ends an occlusion query
  55314. * @see https://doc.babylonjs.com/features/occlusionquery
  55315. * @param algorithmType defines the algorithm to use
  55316. * @returns the current engine
  55317. */
  55318. endOcclusionQuery(algorithmType: number): Engine;
  55319. /**
  55320. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  55321. * Please note that only one query can be issued at a time
  55322. * @returns a time token used to track the time span
  55323. */
  55324. startTimeQuery(): Nullable<_TimeToken>;
  55325. /**
  55326. * Ends a time query
  55327. * @param token defines the token used to measure the time span
  55328. * @returns the time spent (in ns)
  55329. */
  55330. endTimeQuery(token: _TimeToken): int;
  55331. /** @hidden */
  55332. _currentNonTimestampToken: Nullable<_TimeToken>;
  55333. /** @hidden */
  55334. _createTimeQuery(): WebGLQuery;
  55335. /** @hidden */
  55336. _deleteTimeQuery(query: WebGLQuery): void;
  55337. /** @hidden */
  55338. _getGlAlgorithmType(algorithmType: number): number;
  55339. /** @hidden */
  55340. _getTimeQueryResult(query: WebGLQuery): any;
  55341. /** @hidden */
  55342. _getTimeQueryAvailability(query: WebGLQuery): any;
  55343. }
  55344. interface AbstractMesh {
  55345. /**
  55346. * Backing filed
  55347. * @hidden
  55348. */
  55349. __occlusionDataStorage: _OcclusionDataStorage;
  55350. /**
  55351. * Access property
  55352. * @hidden
  55353. */
  55354. _occlusionDataStorage: _OcclusionDataStorage;
  55355. /**
  55356. * 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.
  55357. * The default value is -1 which means don't break the query and wait till the result
  55358. * @see https://doc.babylonjs.com/features/occlusionquery
  55359. */
  55360. occlusionRetryCount: number;
  55361. /**
  55362. * 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:
  55363. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  55364. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  55365. * * 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.
  55366. * @see https://doc.babylonjs.com/features/occlusionquery
  55367. */
  55368. occlusionType: number;
  55369. /**
  55370. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  55371. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  55372. * * 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.
  55373. * @see https://doc.babylonjs.com/features/occlusionquery
  55374. */
  55375. occlusionQueryAlgorithmType: number;
  55376. /**
  55377. * 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
  55378. * @see https://doc.babylonjs.com/features/occlusionquery
  55379. */
  55380. isOccluded: boolean;
  55381. /**
  55382. * Flag to check the progress status of the query
  55383. * @see https://doc.babylonjs.com/features/occlusionquery
  55384. */
  55385. isOcclusionQueryInProgress: boolean;
  55386. }
  55387. }
  55388. declare module BABYLON {
  55389. /** @hidden */
  55390. export var _forceTransformFeedbackToBundle: boolean;
  55391. interface Engine {
  55392. /**
  55393. * Creates a webGL transform feedback object
  55394. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  55395. * @returns the webGL transform feedback object
  55396. */
  55397. createTransformFeedback(): WebGLTransformFeedback;
  55398. /**
  55399. * Delete a webGL transform feedback object
  55400. * @param value defines the webGL transform feedback object to delete
  55401. */
  55402. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  55403. /**
  55404. * Bind a webGL transform feedback object to the webgl context
  55405. * @param value defines the webGL transform feedback object to bind
  55406. */
  55407. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  55408. /**
  55409. * Begins a transform feedback operation
  55410. * @param usePoints defines if points or triangles must be used
  55411. */
  55412. beginTransformFeedback(usePoints: boolean): void;
  55413. /**
  55414. * Ends a transform feedback operation
  55415. */
  55416. endTransformFeedback(): void;
  55417. /**
  55418. * Specify the varyings to use with transform feedback
  55419. * @param program defines the associated webGL program
  55420. * @param value defines the list of strings representing the varying names
  55421. */
  55422. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  55423. /**
  55424. * Bind a webGL buffer for a transform feedback operation
  55425. * @param value defines the webGL buffer to bind
  55426. */
  55427. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  55428. }
  55429. }
  55430. declare module BABYLON {
  55431. /**
  55432. * Class used to define an additional view for the engine
  55433. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55434. */
  55435. export class EngineView {
  55436. /** Defines the canvas where to render the view */
  55437. target: HTMLCanvasElement;
  55438. /** Defines an optional camera used to render the view (will use active camera else) */
  55439. camera?: Camera;
  55440. }
  55441. interface Engine {
  55442. /**
  55443. * Gets or sets the HTML element to use for attaching events
  55444. */
  55445. inputElement: Nullable<HTMLElement>;
  55446. /**
  55447. * Gets the current engine view
  55448. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55449. */
  55450. activeView: Nullable<EngineView>;
  55451. /** Gets or sets the list of views */
  55452. views: EngineView[];
  55453. /**
  55454. * Register a new child canvas
  55455. * @param canvas defines the canvas to register
  55456. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  55457. * @returns the associated view
  55458. */
  55459. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  55460. /**
  55461. * Remove a registered child canvas
  55462. * @param canvas defines the canvas to remove
  55463. * @returns the current engine
  55464. */
  55465. unRegisterView(canvas: HTMLCanvasElement): Engine;
  55466. }
  55467. }
  55468. declare module BABYLON {
  55469. interface Engine {
  55470. /** @hidden */
  55471. _excludedCompressedTextures: string[];
  55472. /** @hidden */
  55473. _textureFormatInUse: string;
  55474. /**
  55475. * Gets the list of texture formats supported
  55476. */
  55477. readonly texturesSupported: Array<string>;
  55478. /**
  55479. * Gets the texture format in use
  55480. */
  55481. readonly textureFormatInUse: Nullable<string>;
  55482. /**
  55483. * Set the compressed texture extensions or file names to skip.
  55484. *
  55485. * @param skippedFiles defines the list of those texture files you want to skip
  55486. * Example: [".dds", ".env", "myfile.png"]
  55487. */
  55488. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  55489. /**
  55490. * Set the compressed texture format to use, based on the formats you have, and the formats
  55491. * supported by the hardware / browser.
  55492. *
  55493. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  55494. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  55495. * to API arguments needed to compressed textures. This puts the burden on the container
  55496. * generator to house the arcane code for determining these for current & future formats.
  55497. *
  55498. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55499. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55500. *
  55501. * Note: The result of this call is not taken into account when a texture is base64.
  55502. *
  55503. * @param formatsAvailable defines the list of those format families you have created
  55504. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  55505. *
  55506. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  55507. * @returns The extension selected.
  55508. */
  55509. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  55510. }
  55511. }
  55512. declare module BABYLON {
  55513. /** @hidden */
  55514. export var rgbdEncodePixelShader: {
  55515. name: string;
  55516. shader: string;
  55517. };
  55518. }
  55519. declare module BABYLON {
  55520. /**
  55521. * Raw texture data and descriptor sufficient for WebGL texture upload
  55522. */
  55523. export interface EnvironmentTextureInfo {
  55524. /**
  55525. * Version of the environment map
  55526. */
  55527. version: number;
  55528. /**
  55529. * Width of image
  55530. */
  55531. width: number;
  55532. /**
  55533. * Irradiance information stored in the file.
  55534. */
  55535. irradiance: any;
  55536. /**
  55537. * Specular information stored in the file.
  55538. */
  55539. specular: any;
  55540. }
  55541. /**
  55542. * Defines One Image in the file. It requires only the position in the file
  55543. * as well as the length.
  55544. */
  55545. interface BufferImageData {
  55546. /**
  55547. * Length of the image data.
  55548. */
  55549. length: number;
  55550. /**
  55551. * Position of the data from the null terminator delimiting the end of the JSON.
  55552. */
  55553. position: number;
  55554. }
  55555. /**
  55556. * Defines the specular data enclosed in the file.
  55557. * This corresponds to the version 1 of the data.
  55558. */
  55559. export interface EnvironmentTextureSpecularInfoV1 {
  55560. /**
  55561. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55562. */
  55563. specularDataPosition?: number;
  55564. /**
  55565. * This contains all the images data needed to reconstruct the cubemap.
  55566. */
  55567. mipmaps: Array<BufferImageData>;
  55568. /**
  55569. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55570. */
  55571. lodGenerationScale: number;
  55572. }
  55573. /**
  55574. * Sets of helpers addressing the serialization and deserialization of environment texture
  55575. * stored in a BabylonJS env file.
  55576. * Those files are usually stored as .env files.
  55577. */
  55578. export class EnvironmentTextureTools {
  55579. /**
  55580. * Magic number identifying the env file.
  55581. */
  55582. private static _MagicBytes;
  55583. /**
  55584. * Gets the environment info from an env file.
  55585. * @param data The array buffer containing the .env bytes.
  55586. * @returns the environment file info (the json header) if successfully parsed.
  55587. */
  55588. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  55589. /**
  55590. * Creates an environment texture from a loaded cube texture.
  55591. * @param texture defines the cube texture to convert in env file
  55592. * @return a promise containing the environment data if succesfull.
  55593. */
  55594. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  55595. /**
  55596. * Creates a JSON representation of the spherical data.
  55597. * @param texture defines the texture containing the polynomials
  55598. * @return the JSON representation of the spherical info
  55599. */
  55600. private static _CreateEnvTextureIrradiance;
  55601. /**
  55602. * Creates the ArrayBufferViews used for initializing environment texture image data.
  55603. * @param data the image data
  55604. * @param info parameters that determine what views will be created for accessing the underlying buffer
  55605. * @return the views described by info providing access to the underlying buffer
  55606. */
  55607. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  55608. /**
  55609. * Uploads the texture info contained in the env file to the GPU.
  55610. * @param texture defines the internal texture to upload to
  55611. * @param data defines the data to load
  55612. * @param info defines the texture info retrieved through the GetEnvInfo method
  55613. * @returns a promise
  55614. */
  55615. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  55616. private static _OnImageReadyAsync;
  55617. /**
  55618. * Uploads the levels of image data to the GPU.
  55619. * @param texture defines the internal texture to upload to
  55620. * @param imageData defines the array buffer views of image data [mipmap][face]
  55621. * @returns a promise
  55622. */
  55623. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  55624. /**
  55625. * Uploads spherical polynomials information to the texture.
  55626. * @param texture defines the texture we are trying to upload the information to
  55627. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  55628. */
  55629. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  55630. /** @hidden */
  55631. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55632. }
  55633. }
  55634. declare module BABYLON {
  55635. /**
  55636. * Class used to inline functions in shader code
  55637. */
  55638. export class ShaderCodeInliner {
  55639. private static readonly _RegexpFindFunctionNameAndType;
  55640. private _sourceCode;
  55641. private _functionDescr;
  55642. private _numMaxIterations;
  55643. /** Gets or sets the token used to mark the functions to inline */
  55644. inlineToken: string;
  55645. /** Gets or sets the debug mode */
  55646. debug: boolean;
  55647. /** Gets the code after the inlining process */
  55648. get code(): string;
  55649. /**
  55650. * Initializes the inliner
  55651. * @param sourceCode shader code source to inline
  55652. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55653. */
  55654. constructor(sourceCode: string, numMaxIterations?: number);
  55655. /**
  55656. * Start the processing of the shader code
  55657. */
  55658. processCode(): void;
  55659. private _collectFunctions;
  55660. private _processInlining;
  55661. private _extractBetweenMarkers;
  55662. private _skipWhitespaces;
  55663. private _removeComments;
  55664. private _replaceFunctionCallsByCode;
  55665. private _findBackward;
  55666. private _escapeRegExp;
  55667. private _replaceNames;
  55668. }
  55669. }
  55670. declare module BABYLON {
  55671. /**
  55672. * Container for accessors for natively-stored mesh data buffers.
  55673. */
  55674. class NativeDataBuffer extends DataBuffer {
  55675. /**
  55676. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55677. */
  55678. nativeIndexBuffer?: any;
  55679. /**
  55680. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55681. */
  55682. nativeVertexBuffer?: any;
  55683. }
  55684. /** @hidden */
  55685. class NativeTexture extends InternalTexture {
  55686. getInternalTexture(): InternalTexture;
  55687. getViewCount(): number;
  55688. }
  55689. /** @hidden */
  55690. export class NativeEngine extends Engine {
  55691. private readonly _native;
  55692. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55693. private readonly INVALID_HANDLE;
  55694. private _boundBuffersVertexArray;
  55695. private _currentDepthTest;
  55696. getHardwareScalingLevel(): number;
  55697. constructor();
  55698. dispose(): void;
  55699. /**
  55700. * Can be used to override the current requestAnimationFrame requester.
  55701. * @hidden
  55702. */
  55703. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55704. /**
  55705. * Override default engine behavior.
  55706. * @param color
  55707. * @param backBuffer
  55708. * @param depth
  55709. * @param stencil
  55710. */
  55711. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55712. /**
  55713. * Gets host document
  55714. * @returns the host document object
  55715. */
  55716. getHostDocument(): Nullable<Document>;
  55717. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55718. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55719. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55720. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55721. [key: string]: VertexBuffer;
  55722. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55723. bindBuffers(vertexBuffers: {
  55724. [key: string]: VertexBuffer;
  55725. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55726. recordVertexArrayObject(vertexBuffers: {
  55727. [key: string]: VertexBuffer;
  55728. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55729. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55730. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55731. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55732. /**
  55733. * Draw a list of indexed primitives
  55734. * @param fillMode defines the primitive to use
  55735. * @param indexStart defines the starting index
  55736. * @param indexCount defines the number of index to draw
  55737. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55738. */
  55739. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55740. /**
  55741. * Draw a list of unindexed primitives
  55742. * @param fillMode defines the primitive to use
  55743. * @param verticesStart defines the index of first vertex to draw
  55744. * @param verticesCount defines the count of vertices to draw
  55745. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55746. */
  55747. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55748. createPipelineContext(): IPipelineContext;
  55749. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55750. /** @hidden */
  55751. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55752. /** @hidden */
  55753. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55754. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55755. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55756. protected _setProgram(program: WebGLProgram): void;
  55757. _releaseEffect(effect: Effect): void;
  55758. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55759. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55760. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55761. bindSamplers(effect: Effect): void;
  55762. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55763. getRenderWidth(useScreen?: boolean): number;
  55764. getRenderHeight(useScreen?: boolean): number;
  55765. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55766. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55767. /**
  55768. * Set the z offset to apply to current rendering
  55769. * @param value defines the offset to apply
  55770. */
  55771. setZOffset(value: number): void;
  55772. /**
  55773. * Gets the current value of the zOffset
  55774. * @returns the current zOffset state
  55775. */
  55776. getZOffset(): number;
  55777. /**
  55778. * Enable or disable depth buffering
  55779. * @param enable defines the state to set
  55780. */
  55781. setDepthBuffer(enable: boolean): void;
  55782. /**
  55783. * Gets a boolean indicating if depth writing is enabled
  55784. * @returns the current depth writing state
  55785. */
  55786. getDepthWrite(): boolean;
  55787. setDepthFunctionToGreater(): void;
  55788. setDepthFunctionToGreaterOrEqual(): void;
  55789. setDepthFunctionToLess(): void;
  55790. setDepthFunctionToLessOrEqual(): void;
  55791. /**
  55792. * Enable or disable depth writing
  55793. * @param enable defines the state to set
  55794. */
  55795. setDepthWrite(enable: boolean): void;
  55796. /**
  55797. * Enable or disable color writing
  55798. * @param enable defines the state to set
  55799. */
  55800. setColorWrite(enable: boolean): void;
  55801. /**
  55802. * Gets a boolean indicating if color writing is enabled
  55803. * @returns the current color writing state
  55804. */
  55805. getColorWrite(): boolean;
  55806. /**
  55807. * Sets alpha constants used by some alpha blending modes
  55808. * @param r defines the red component
  55809. * @param g defines the green component
  55810. * @param b defines the blue component
  55811. * @param a defines the alpha component
  55812. */
  55813. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55814. /**
  55815. * Sets the current alpha mode
  55816. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55817. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55818. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55819. */
  55820. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55821. /**
  55822. * Gets the current alpha mode
  55823. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55824. * @returns the current alpha mode
  55825. */
  55826. getAlphaMode(): number;
  55827. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55828. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55829. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55830. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55831. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55832. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55833. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55834. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55835. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55836. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55837. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55838. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55839. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55840. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55841. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55842. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55843. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55844. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55845. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55846. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55847. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55848. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55849. wipeCaches(bruteForce?: boolean): void;
  55850. _createTexture(): WebGLTexture;
  55851. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55852. /**
  55853. * Update the content of a dynamic texture
  55854. * @param texture defines the texture to update
  55855. * @param canvas defines the canvas containing the source
  55856. * @param invertY defines if data must be stored with Y axis inverted
  55857. * @param premulAlpha defines if alpha is stored as premultiplied
  55858. * @param format defines the format of the data
  55859. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55860. */
  55861. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55862. /**
  55863. * Usually called from Texture.ts.
  55864. * Passed information to create a WebGLTexture
  55865. * @param url defines a value which contains one of the following:
  55866. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55867. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55868. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55869. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55870. * @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)
  55871. * @param scene needed for loading to the correct scene
  55872. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55873. * @param onLoad optional callback to be called upon successful completion
  55874. * @param onError optional callback to be called upon failure
  55875. * @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
  55876. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55877. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55878. * @param forcedExtension defines the extension to use to pick the right loader
  55879. * @param mimeType defines an optional mime type
  55880. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55881. */
  55882. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  55883. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  55884. _releaseFramebufferObjects(texture: InternalTexture): void;
  55885. /**
  55886. * Creates a cube texture
  55887. * @param rootUrl defines the url where the files to load is located
  55888. * @param scene defines the current scene
  55889. * @param files defines the list of files to load (1 per face)
  55890. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55891. * @param onLoad defines an optional callback raised when the texture is loaded
  55892. * @param onError defines an optional callback raised if there is an issue to load the texture
  55893. * @param format defines the format of the data
  55894. * @param forcedExtension defines the extension to use to pick the right loader
  55895. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55896. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55897. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55898. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55899. * @returns the cube texture as an InternalTexture
  55900. */
  55901. 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;
  55902. createRenderTargetTexture(size: number | {
  55903. width: number;
  55904. height: number;
  55905. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55906. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55907. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55908. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55909. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55910. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55911. /**
  55912. * Updates a dynamic vertex buffer.
  55913. * @param vertexBuffer the vertex buffer to update
  55914. * @param data the data used to update the vertex buffer
  55915. * @param byteOffset the byte offset of the data (optional)
  55916. * @param byteLength the byte length of the data (optional)
  55917. */
  55918. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55919. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55920. private _updateAnisotropicLevel;
  55921. private _getAddressMode;
  55922. /** @hidden */
  55923. _bindTexture(channel: number, texture: InternalTexture): void;
  55924. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55925. releaseEffects(): void;
  55926. /** @hidden */
  55927. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55928. /** @hidden */
  55929. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55930. /** @hidden */
  55931. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55932. /** @hidden */
  55933. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55934. private _getNativeSamplingMode;
  55935. private _getNativeTextureFormat;
  55936. private _getNativeAlphaMode;
  55937. private _getNativeAttribType;
  55938. }
  55939. }
  55940. declare module BABYLON {
  55941. /**
  55942. * Gather the list of clipboard event types as constants.
  55943. */
  55944. export class ClipboardEventTypes {
  55945. /**
  55946. * The clipboard event is fired when a copy command is active (pressed).
  55947. */
  55948. static readonly COPY: number;
  55949. /**
  55950. * The clipboard event is fired when a cut command is active (pressed).
  55951. */
  55952. static readonly CUT: number;
  55953. /**
  55954. * The clipboard event is fired when a paste command is active (pressed).
  55955. */
  55956. static readonly PASTE: number;
  55957. }
  55958. /**
  55959. * This class is used to store clipboard related info for the onClipboardObservable event.
  55960. */
  55961. export class ClipboardInfo {
  55962. /**
  55963. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55964. */
  55965. type: number;
  55966. /**
  55967. * Defines the related dom event
  55968. */
  55969. event: ClipboardEvent;
  55970. /**
  55971. *Creates an instance of ClipboardInfo.
  55972. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55973. * @param event Defines the related dom event
  55974. */
  55975. constructor(
  55976. /**
  55977. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55978. */
  55979. type: number,
  55980. /**
  55981. * Defines the related dom event
  55982. */
  55983. event: ClipboardEvent);
  55984. /**
  55985. * Get the clipboard event's type from the keycode.
  55986. * @param keyCode Defines the keyCode for the current keyboard event.
  55987. * @return {number}
  55988. */
  55989. static GetTypeFromCharacter(keyCode: number): number;
  55990. }
  55991. }
  55992. declare module BABYLON {
  55993. /**
  55994. * Google Daydream controller
  55995. */
  55996. export class DaydreamController extends WebVRController {
  55997. /**
  55998. * Base Url for the controller model.
  55999. */
  56000. static MODEL_BASE_URL: string;
  56001. /**
  56002. * File name for the controller model.
  56003. */
  56004. static MODEL_FILENAME: string;
  56005. /**
  56006. * Gamepad Id prefix used to identify Daydream Controller.
  56007. */
  56008. static readonly GAMEPAD_ID_PREFIX: string;
  56009. /**
  56010. * Creates a new DaydreamController from a gamepad
  56011. * @param vrGamepad the gamepad that the controller should be created from
  56012. */
  56013. constructor(vrGamepad: any);
  56014. /**
  56015. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56016. * @param scene scene in which to add meshes
  56017. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56018. */
  56019. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56020. /**
  56021. * Called once for each button that changed state since the last frame
  56022. * @param buttonIdx Which button index changed
  56023. * @param state New state of the button
  56024. * @param changes Which properties on the state changed since last frame
  56025. */
  56026. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56027. }
  56028. }
  56029. declare module BABYLON {
  56030. /**
  56031. * Gear VR Controller
  56032. */
  56033. export class GearVRController extends WebVRController {
  56034. /**
  56035. * Base Url for the controller model.
  56036. */
  56037. static MODEL_BASE_URL: string;
  56038. /**
  56039. * File name for the controller model.
  56040. */
  56041. static MODEL_FILENAME: string;
  56042. /**
  56043. * Gamepad Id prefix used to identify this controller.
  56044. */
  56045. static readonly GAMEPAD_ID_PREFIX: string;
  56046. private readonly _buttonIndexToObservableNameMap;
  56047. /**
  56048. * Creates a new GearVRController from a gamepad
  56049. * @param vrGamepad the gamepad that the controller should be created from
  56050. */
  56051. constructor(vrGamepad: any);
  56052. /**
  56053. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56054. * @param scene scene in which to add meshes
  56055. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56056. */
  56057. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56058. /**
  56059. * Called once for each button that changed state since the last frame
  56060. * @param buttonIdx Which button index changed
  56061. * @param state New state of the button
  56062. * @param changes Which properties on the state changed since last frame
  56063. */
  56064. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56065. }
  56066. }
  56067. declare module BABYLON {
  56068. /**
  56069. * Generic Controller
  56070. */
  56071. export class GenericController extends WebVRController {
  56072. /**
  56073. * Base Url for the controller model.
  56074. */
  56075. static readonly MODEL_BASE_URL: string;
  56076. /**
  56077. * File name for the controller model.
  56078. */
  56079. static readonly MODEL_FILENAME: string;
  56080. /**
  56081. * Creates a new GenericController from a gamepad
  56082. * @param vrGamepad the gamepad that the controller should be created from
  56083. */
  56084. constructor(vrGamepad: any);
  56085. /**
  56086. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56087. * @param scene scene in which to add meshes
  56088. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56089. */
  56090. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56091. /**
  56092. * Called once for each button that changed state since the last frame
  56093. * @param buttonIdx Which button index changed
  56094. * @param state New state of the button
  56095. * @param changes Which properties on the state changed since last frame
  56096. */
  56097. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56098. }
  56099. }
  56100. declare module BABYLON {
  56101. /**
  56102. * Oculus Touch Controller
  56103. */
  56104. export class OculusTouchController extends WebVRController {
  56105. /**
  56106. * Base Url for the controller model.
  56107. */
  56108. static MODEL_BASE_URL: string;
  56109. /**
  56110. * File name for the left controller model.
  56111. */
  56112. static MODEL_LEFT_FILENAME: string;
  56113. /**
  56114. * File name for the right controller model.
  56115. */
  56116. static MODEL_RIGHT_FILENAME: string;
  56117. /**
  56118. * Base Url for the Quest controller model.
  56119. */
  56120. static QUEST_MODEL_BASE_URL: string;
  56121. /**
  56122. * @hidden
  56123. * If the controllers are running on a device that needs the updated Quest controller models
  56124. */
  56125. static _IsQuest: boolean;
  56126. /**
  56127. * Fired when the secondary trigger on this controller is modified
  56128. */
  56129. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  56130. /**
  56131. * Fired when the thumb rest on this controller is modified
  56132. */
  56133. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  56134. /**
  56135. * Creates a new OculusTouchController from a gamepad
  56136. * @param vrGamepad the gamepad that the controller should be created from
  56137. */
  56138. constructor(vrGamepad: any);
  56139. /**
  56140. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56141. * @param scene scene in which to add meshes
  56142. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56143. */
  56144. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56145. /**
  56146. * Fired when the A button on this controller is modified
  56147. */
  56148. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56149. /**
  56150. * Fired when the B button on this controller is modified
  56151. */
  56152. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56153. /**
  56154. * Fired when the X button on this controller is modified
  56155. */
  56156. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56157. /**
  56158. * Fired when the Y button on this controller is modified
  56159. */
  56160. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56161. /**
  56162. * Called once for each button that changed state since the last frame
  56163. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  56164. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  56165. * 2) secondary trigger (same)
  56166. * 3) A (right) X (left), touch, pressed = value
  56167. * 4) B / Y
  56168. * 5) thumb rest
  56169. * @param buttonIdx Which button index changed
  56170. * @param state New state of the button
  56171. * @param changes Which properties on the state changed since last frame
  56172. */
  56173. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56174. }
  56175. }
  56176. declare module BABYLON {
  56177. /**
  56178. * Vive Controller
  56179. */
  56180. export class ViveController extends WebVRController {
  56181. /**
  56182. * Base Url for the controller model.
  56183. */
  56184. static MODEL_BASE_URL: string;
  56185. /**
  56186. * File name for the controller model.
  56187. */
  56188. static MODEL_FILENAME: string;
  56189. /**
  56190. * Creates a new ViveController from a gamepad
  56191. * @param vrGamepad the gamepad that the controller should be created from
  56192. */
  56193. constructor(vrGamepad: any);
  56194. /**
  56195. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56196. * @param scene scene in which to add meshes
  56197. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56198. */
  56199. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56200. /**
  56201. * Fired when the left button on this controller is modified
  56202. */
  56203. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56204. /**
  56205. * Fired when the right button on this controller is modified
  56206. */
  56207. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56208. /**
  56209. * Fired when the menu button on this controller is modified
  56210. */
  56211. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56212. /**
  56213. * Called once for each button that changed state since the last frame
  56214. * Vive mapping:
  56215. * 0: touchpad
  56216. * 1: trigger
  56217. * 2: left AND right buttons
  56218. * 3: menu button
  56219. * @param buttonIdx Which button index changed
  56220. * @param state New state of the button
  56221. * @param changes Which properties on the state changed since last frame
  56222. */
  56223. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56224. }
  56225. }
  56226. declare module BABYLON {
  56227. /**
  56228. * Defines the WindowsMotionController object that the state of the windows motion controller
  56229. */
  56230. export class WindowsMotionController extends WebVRController {
  56231. /**
  56232. * The base url used to load the left and right controller models
  56233. */
  56234. static MODEL_BASE_URL: string;
  56235. /**
  56236. * The name of the left controller model file
  56237. */
  56238. static MODEL_LEFT_FILENAME: string;
  56239. /**
  56240. * The name of the right controller model file
  56241. */
  56242. static MODEL_RIGHT_FILENAME: string;
  56243. /**
  56244. * The controller name prefix for this controller type
  56245. */
  56246. static readonly GAMEPAD_ID_PREFIX: string;
  56247. /**
  56248. * The controller id pattern for this controller type
  56249. */
  56250. private static readonly GAMEPAD_ID_PATTERN;
  56251. private _loadedMeshInfo;
  56252. protected readonly _mapping: {
  56253. buttons: string[];
  56254. buttonMeshNames: {
  56255. trigger: string;
  56256. menu: string;
  56257. grip: string;
  56258. thumbstick: string;
  56259. trackpad: string;
  56260. };
  56261. buttonObservableNames: {
  56262. trigger: string;
  56263. menu: string;
  56264. grip: string;
  56265. thumbstick: string;
  56266. trackpad: string;
  56267. };
  56268. axisMeshNames: string[];
  56269. pointingPoseMeshName: string;
  56270. };
  56271. /**
  56272. * Fired when the trackpad on this controller is clicked
  56273. */
  56274. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56275. /**
  56276. * Fired when the trackpad on this controller is modified
  56277. */
  56278. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56279. /**
  56280. * The current x and y values of this controller's trackpad
  56281. */
  56282. trackpad: StickValues;
  56283. /**
  56284. * Creates a new WindowsMotionController from a gamepad
  56285. * @param vrGamepad the gamepad that the controller should be created from
  56286. */
  56287. constructor(vrGamepad: any);
  56288. /**
  56289. * Fired when the trigger on this controller is modified
  56290. */
  56291. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56292. /**
  56293. * Fired when the menu button on this controller is modified
  56294. */
  56295. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56296. /**
  56297. * Fired when the grip button on this controller is modified
  56298. */
  56299. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56300. /**
  56301. * Fired when the thumbstick button on this controller is modified
  56302. */
  56303. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56304. /**
  56305. * Fired when the touchpad button on this controller is modified
  56306. */
  56307. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56308. /**
  56309. * Fired when the touchpad values on this controller are modified
  56310. */
  56311. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  56312. protected _updateTrackpad(): void;
  56313. /**
  56314. * Called once per frame by the engine.
  56315. */
  56316. update(): void;
  56317. /**
  56318. * Called once for each button that changed state since the last frame
  56319. * @param buttonIdx Which button index changed
  56320. * @param state New state of the button
  56321. * @param changes Which properties on the state changed since last frame
  56322. */
  56323. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56324. /**
  56325. * Moves the buttons on the controller mesh based on their current state
  56326. * @param buttonName the name of the button to move
  56327. * @param buttonValue the value of the button which determines the buttons new position
  56328. */
  56329. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  56330. /**
  56331. * Moves the axis on the controller mesh based on its current state
  56332. * @param axis the index of the axis
  56333. * @param axisValue the value of the axis which determines the meshes new position
  56334. * @hidden
  56335. */
  56336. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  56337. /**
  56338. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56339. * @param scene scene in which to add meshes
  56340. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56341. */
  56342. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  56343. /**
  56344. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  56345. * can be transformed by button presses and axes values, based on this._mapping.
  56346. *
  56347. * @param scene scene in which the meshes exist
  56348. * @param meshes list of meshes that make up the controller model to process
  56349. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  56350. */
  56351. private processModel;
  56352. private createMeshInfo;
  56353. /**
  56354. * Gets the ray of the controller in the direction the controller is pointing
  56355. * @param length the length the resulting ray should be
  56356. * @returns a ray in the direction the controller is pointing
  56357. */
  56358. getForwardRay(length?: number): Ray;
  56359. /**
  56360. * Disposes of the controller
  56361. */
  56362. dispose(): void;
  56363. }
  56364. /**
  56365. * This class represents a new windows motion controller in XR.
  56366. */
  56367. export class XRWindowsMotionController extends WindowsMotionController {
  56368. /**
  56369. * Changing the original WIndowsMotionController mapping to fir the new mapping
  56370. */
  56371. protected readonly _mapping: {
  56372. buttons: string[];
  56373. buttonMeshNames: {
  56374. trigger: string;
  56375. menu: string;
  56376. grip: string;
  56377. thumbstick: string;
  56378. trackpad: string;
  56379. };
  56380. buttonObservableNames: {
  56381. trigger: string;
  56382. menu: string;
  56383. grip: string;
  56384. thumbstick: string;
  56385. trackpad: string;
  56386. };
  56387. axisMeshNames: string[];
  56388. pointingPoseMeshName: string;
  56389. };
  56390. /**
  56391. * Construct a new XR-Based windows motion controller
  56392. *
  56393. * @param gamepadInfo the gamepad object from the browser
  56394. */
  56395. constructor(gamepadInfo: any);
  56396. /**
  56397. * holds the thumbstick values (X,Y)
  56398. */
  56399. thumbstickValues: StickValues;
  56400. /**
  56401. * Fired when the thumbstick on this controller is clicked
  56402. */
  56403. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  56404. /**
  56405. * Fired when the thumbstick on this controller is modified
  56406. */
  56407. onThumbstickValuesChangedObservable: Observable<StickValues>;
  56408. /**
  56409. * Fired when the touchpad button on this controller is modified
  56410. */
  56411. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56412. /**
  56413. * Fired when the touchpad values on this controller are modified
  56414. */
  56415. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56416. /**
  56417. * Fired when the thumbstick button on this controller is modified
  56418. * here to prevent breaking changes
  56419. */
  56420. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56421. /**
  56422. * updating the thumbstick(!) and not the trackpad.
  56423. * This is named this way due to the difference between WebVR and XR and to avoid
  56424. * changing the parent class.
  56425. */
  56426. protected _updateTrackpad(): void;
  56427. /**
  56428. * Disposes the class with joy
  56429. */
  56430. dispose(): void;
  56431. }
  56432. }
  56433. declare module BABYLON {
  56434. /**
  56435. * Class containing static functions to help procedurally build meshes
  56436. */
  56437. export class PolyhedronBuilder {
  56438. /**
  56439. * Creates a polyhedron mesh
  56440. * * 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
  56441. * * The parameter `size` (positive float, default 1) sets the polygon size
  56442. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56443. * * 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`
  56444. * * 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
  56445. * * 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)`)
  56446. * * 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
  56447. * * 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
  56448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56449. * * 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
  56450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56451. * @param name defines the name of the mesh
  56452. * @param options defines the options used to create the mesh
  56453. * @param scene defines the hosting scene
  56454. * @returns the polyhedron mesh
  56455. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56456. */
  56457. static CreatePolyhedron(name: string, options: {
  56458. type?: number;
  56459. size?: number;
  56460. sizeX?: number;
  56461. sizeY?: number;
  56462. sizeZ?: number;
  56463. custom?: any;
  56464. faceUV?: Vector4[];
  56465. faceColors?: Color4[];
  56466. flat?: boolean;
  56467. updatable?: boolean;
  56468. sideOrientation?: number;
  56469. frontUVs?: Vector4;
  56470. backUVs?: Vector4;
  56471. }, scene?: Nullable<Scene>): Mesh;
  56472. }
  56473. }
  56474. declare module BABYLON {
  56475. /**
  56476. * Gizmo that enables scaling a mesh along 3 axis
  56477. */
  56478. export class ScaleGizmo extends Gizmo {
  56479. /**
  56480. * Internal gizmo used for interactions on the x axis
  56481. */
  56482. xGizmo: AxisScaleGizmo;
  56483. /**
  56484. * Internal gizmo used for interactions on the y axis
  56485. */
  56486. yGizmo: AxisScaleGizmo;
  56487. /**
  56488. * Internal gizmo used for interactions on the z axis
  56489. */
  56490. zGizmo: AxisScaleGizmo;
  56491. /**
  56492. * Internal gizmo used to scale all axis equally
  56493. */
  56494. uniformScaleGizmo: AxisScaleGizmo;
  56495. private _meshAttached;
  56496. private _nodeAttached;
  56497. private _snapDistance;
  56498. private _uniformScalingMesh;
  56499. private _octahedron;
  56500. private _sensitivity;
  56501. /** Fires an event when any of it's sub gizmos are dragged */
  56502. onDragStartObservable: Observable<unknown>;
  56503. /** Fires an event when any of it's sub gizmos are released from dragging */
  56504. onDragEndObservable: Observable<unknown>;
  56505. get attachedMesh(): Nullable<AbstractMesh>;
  56506. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56507. get attachedNode(): Nullable<Node>;
  56508. set attachedNode(node: Nullable<Node>);
  56509. /**
  56510. * True when the mouse pointer is hovering a gizmo mesh
  56511. */
  56512. get isHovered(): boolean;
  56513. /**
  56514. * Creates a ScaleGizmo
  56515. * @param gizmoLayer The utility layer the gizmo will be added to
  56516. * @param thickness display gizmo axis thickness
  56517. */
  56518. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56519. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56520. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56521. /**
  56522. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56523. */
  56524. set snapDistance(value: number);
  56525. get snapDistance(): number;
  56526. /**
  56527. * Ratio for the scale of the gizmo (Default: 1)
  56528. */
  56529. set scaleRatio(value: number);
  56530. get scaleRatio(): number;
  56531. /**
  56532. * Sensitivity factor for dragging (Default: 1)
  56533. */
  56534. set sensitivity(value: number);
  56535. get sensitivity(): number;
  56536. /**
  56537. * Disposes of the gizmo
  56538. */
  56539. dispose(): void;
  56540. }
  56541. }
  56542. declare module BABYLON {
  56543. /**
  56544. * Single axis scale gizmo
  56545. */
  56546. export class AxisScaleGizmo extends Gizmo {
  56547. /**
  56548. * Drag behavior responsible for the gizmos dragging interactions
  56549. */
  56550. dragBehavior: PointerDragBehavior;
  56551. private _pointerObserver;
  56552. /**
  56553. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56554. */
  56555. snapDistance: number;
  56556. /**
  56557. * Event that fires each time the gizmo snaps to a new location.
  56558. * * snapDistance is the the change in distance
  56559. */
  56560. onSnapObservable: Observable<{
  56561. snapDistance: number;
  56562. }>;
  56563. /**
  56564. * If the scaling operation should be done on all axis (default: false)
  56565. */
  56566. uniformScaling: boolean;
  56567. /**
  56568. * Custom sensitivity value for the drag strength
  56569. */
  56570. sensitivity: number;
  56571. private _isEnabled;
  56572. private _parent;
  56573. private _arrow;
  56574. private _coloredMaterial;
  56575. private _hoverMaterial;
  56576. /**
  56577. * Creates an AxisScaleGizmo
  56578. * @param gizmoLayer The utility layer the gizmo will be added to
  56579. * @param dragAxis The axis which the gizmo will be able to scale on
  56580. * @param color The color of the gizmo
  56581. * @param thickness display gizmo axis thickness
  56582. */
  56583. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56584. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56585. /**
  56586. * If the gizmo is enabled
  56587. */
  56588. set isEnabled(value: boolean);
  56589. get isEnabled(): boolean;
  56590. /**
  56591. * Disposes of the gizmo
  56592. */
  56593. dispose(): void;
  56594. /**
  56595. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56596. * @param mesh The mesh to replace the default mesh of the gizmo
  56597. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56598. */
  56599. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56600. }
  56601. }
  56602. declare module BABYLON {
  56603. /**
  56604. * Bounding box gizmo
  56605. */
  56606. export class BoundingBoxGizmo extends Gizmo {
  56607. private _lineBoundingBox;
  56608. private _rotateSpheresParent;
  56609. private _scaleBoxesParent;
  56610. private _boundingDimensions;
  56611. private _renderObserver;
  56612. private _pointerObserver;
  56613. private _scaleDragSpeed;
  56614. private _tmpQuaternion;
  56615. private _tmpVector;
  56616. private _tmpRotationMatrix;
  56617. /**
  56618. * 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)
  56619. */
  56620. ignoreChildren: boolean;
  56621. /**
  56622. * 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)
  56623. */
  56624. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56625. /**
  56626. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56627. */
  56628. rotationSphereSize: number;
  56629. /**
  56630. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56631. */
  56632. scaleBoxSize: number;
  56633. /**
  56634. * 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)
  56635. */
  56636. fixedDragMeshScreenSize: boolean;
  56637. /**
  56638. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56639. */
  56640. fixedDragMeshScreenSizeDistanceFactor: number;
  56641. /**
  56642. * Fired when a rotation sphere or scale box is dragged
  56643. */
  56644. onDragStartObservable: Observable<{}>;
  56645. /**
  56646. * Fired when a scale box is dragged
  56647. */
  56648. onScaleBoxDragObservable: Observable<{}>;
  56649. /**
  56650. * Fired when a scale box drag is ended
  56651. */
  56652. onScaleBoxDragEndObservable: Observable<{}>;
  56653. /**
  56654. * Fired when a rotation sphere is dragged
  56655. */
  56656. onRotationSphereDragObservable: Observable<{}>;
  56657. /**
  56658. * Fired when a rotation sphere drag is ended
  56659. */
  56660. onRotationSphereDragEndObservable: Observable<{}>;
  56661. /**
  56662. * 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)
  56663. */
  56664. scalePivot: Nullable<Vector3>;
  56665. /**
  56666. * Mesh used as a pivot to rotate the attached node
  56667. */
  56668. private _anchorMesh;
  56669. private _existingMeshScale;
  56670. private _dragMesh;
  56671. private pointerDragBehavior;
  56672. private coloredMaterial;
  56673. private hoverColoredMaterial;
  56674. /**
  56675. * Sets the color of the bounding box gizmo
  56676. * @param color the color to set
  56677. */
  56678. setColor(color: Color3): void;
  56679. /**
  56680. * Creates an BoundingBoxGizmo
  56681. * @param gizmoLayer The utility layer the gizmo will be added to
  56682. * @param color The color of the gizmo
  56683. */
  56684. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56685. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56686. private _selectNode;
  56687. /**
  56688. * Updates the bounding box information for the Gizmo
  56689. */
  56690. updateBoundingBox(): void;
  56691. private _updateRotationSpheres;
  56692. private _updateScaleBoxes;
  56693. /**
  56694. * Enables rotation on the specified axis and disables rotation on the others
  56695. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56696. */
  56697. setEnabledRotationAxis(axis: string): void;
  56698. /**
  56699. * Enables/disables scaling
  56700. * @param enable if scaling should be enabled
  56701. * @param homogeneousScaling defines if scaling should only be homogeneous
  56702. */
  56703. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56704. private _updateDummy;
  56705. /**
  56706. * Enables a pointer drag behavior on the bounding box of the gizmo
  56707. */
  56708. enableDragBehavior(): void;
  56709. /**
  56710. * Disposes of the gizmo
  56711. */
  56712. dispose(): void;
  56713. /**
  56714. * 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)
  56715. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56716. * @returns the bounding box mesh with the passed in mesh as a child
  56717. */
  56718. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56719. /**
  56720. * CustomMeshes are not supported by this gizmo
  56721. * @param mesh The mesh to replace the default mesh of the gizmo
  56722. */
  56723. setCustomMesh(mesh: Mesh): void;
  56724. }
  56725. }
  56726. declare module BABYLON {
  56727. /**
  56728. * Single plane rotation gizmo
  56729. */
  56730. export class PlaneRotationGizmo extends Gizmo {
  56731. /**
  56732. * Drag behavior responsible for the gizmos dragging interactions
  56733. */
  56734. dragBehavior: PointerDragBehavior;
  56735. private _pointerObserver;
  56736. /**
  56737. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56738. */
  56739. snapDistance: number;
  56740. /**
  56741. * Event that fires each time the gizmo snaps to a new location.
  56742. * * snapDistance is the the change in distance
  56743. */
  56744. onSnapObservable: Observable<{
  56745. snapDistance: number;
  56746. }>;
  56747. private _isEnabled;
  56748. private _parent;
  56749. /**
  56750. * Creates a PlaneRotationGizmo
  56751. * @param gizmoLayer The utility layer the gizmo will be added to
  56752. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56753. * @param color The color of the gizmo
  56754. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56755. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56756. * @param thickness display gizmo axis thickness
  56757. */
  56758. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56759. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56760. /**
  56761. * If the gizmo is enabled
  56762. */
  56763. set isEnabled(value: boolean);
  56764. get isEnabled(): boolean;
  56765. /**
  56766. * Disposes of the gizmo
  56767. */
  56768. dispose(): void;
  56769. }
  56770. }
  56771. declare module BABYLON {
  56772. /**
  56773. * Gizmo that enables rotating a mesh along 3 axis
  56774. */
  56775. export class RotationGizmo extends Gizmo {
  56776. /**
  56777. * Internal gizmo used for interactions on the x axis
  56778. */
  56779. xGizmo: PlaneRotationGizmo;
  56780. /**
  56781. * Internal gizmo used for interactions on the y axis
  56782. */
  56783. yGizmo: PlaneRotationGizmo;
  56784. /**
  56785. * Internal gizmo used for interactions on the z axis
  56786. */
  56787. zGizmo: PlaneRotationGizmo;
  56788. /** Fires an event when any of it's sub gizmos are dragged */
  56789. onDragStartObservable: Observable<unknown>;
  56790. /** Fires an event when any of it's sub gizmos are released from dragging */
  56791. onDragEndObservable: Observable<unknown>;
  56792. private _meshAttached;
  56793. private _nodeAttached;
  56794. get attachedMesh(): Nullable<AbstractMesh>;
  56795. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56796. get attachedNode(): Nullable<Node>;
  56797. set attachedNode(node: Nullable<Node>);
  56798. protected _checkBillboardTransform(): void;
  56799. /**
  56800. * True when the mouse pointer is hovering a gizmo mesh
  56801. */
  56802. get isHovered(): boolean;
  56803. /**
  56804. * Creates a RotationGizmo
  56805. * @param gizmoLayer The utility layer the gizmo will be added to
  56806. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56807. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56808. * @param thickness display gizmo axis thickness
  56809. */
  56810. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56811. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56812. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56813. /**
  56814. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56815. */
  56816. set snapDistance(value: number);
  56817. get snapDistance(): number;
  56818. /**
  56819. * Ratio for the scale of the gizmo (Default: 1)
  56820. */
  56821. set scaleRatio(value: number);
  56822. get scaleRatio(): number;
  56823. /**
  56824. * Disposes of the gizmo
  56825. */
  56826. dispose(): void;
  56827. /**
  56828. * CustomMeshes are not supported by this gizmo
  56829. * @param mesh The mesh to replace the default mesh of the gizmo
  56830. */
  56831. setCustomMesh(mesh: Mesh): void;
  56832. }
  56833. }
  56834. declare module BABYLON {
  56835. /**
  56836. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56837. */
  56838. export class GizmoManager implements IDisposable {
  56839. private scene;
  56840. /**
  56841. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56842. */
  56843. gizmos: {
  56844. positionGizmo: Nullable<PositionGizmo>;
  56845. rotationGizmo: Nullable<RotationGizmo>;
  56846. scaleGizmo: Nullable<ScaleGizmo>;
  56847. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56848. };
  56849. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56850. clearGizmoOnEmptyPointerEvent: boolean;
  56851. /** Fires an event when the manager is attached to a mesh */
  56852. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56853. /** Fires an event when the manager is attached to a node */
  56854. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56855. private _gizmosEnabled;
  56856. private _pointerObserver;
  56857. private _attachedMesh;
  56858. private _attachedNode;
  56859. private _boundingBoxColor;
  56860. private _defaultUtilityLayer;
  56861. private _defaultKeepDepthUtilityLayer;
  56862. private _thickness;
  56863. /**
  56864. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56865. */
  56866. boundingBoxDragBehavior: SixDofDragBehavior;
  56867. /**
  56868. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56869. */
  56870. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56871. /**
  56872. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56873. */
  56874. attachableNodes: Nullable<Array<Node>>;
  56875. /**
  56876. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56877. */
  56878. usePointerToAttachGizmos: boolean;
  56879. /**
  56880. * Utility layer that the bounding box gizmo belongs to
  56881. */
  56882. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56883. /**
  56884. * Utility layer that all gizmos besides bounding box belong to
  56885. */
  56886. get utilityLayer(): UtilityLayerRenderer;
  56887. /**
  56888. * True when the mouse pointer is hovering a gizmo mesh
  56889. */
  56890. get isHovered(): boolean;
  56891. /**
  56892. * Instatiates a gizmo manager
  56893. * @param scene the scene to overlay the gizmos on top of
  56894. * @param thickness display gizmo axis thickness
  56895. */
  56896. constructor(scene: Scene, thickness?: number);
  56897. /**
  56898. * Attaches a set of gizmos to the specified mesh
  56899. * @param mesh The mesh the gizmo's should be attached to
  56900. */
  56901. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56902. /**
  56903. * Attaches a set of gizmos to the specified node
  56904. * @param node The node the gizmo's should be attached to
  56905. */
  56906. attachToNode(node: Nullable<Node>): void;
  56907. /**
  56908. * If the position gizmo is enabled
  56909. */
  56910. set positionGizmoEnabled(value: boolean);
  56911. get positionGizmoEnabled(): boolean;
  56912. /**
  56913. * If the rotation gizmo is enabled
  56914. */
  56915. set rotationGizmoEnabled(value: boolean);
  56916. get rotationGizmoEnabled(): boolean;
  56917. /**
  56918. * If the scale gizmo is enabled
  56919. */
  56920. set scaleGizmoEnabled(value: boolean);
  56921. get scaleGizmoEnabled(): boolean;
  56922. /**
  56923. * If the boundingBox gizmo is enabled
  56924. */
  56925. set boundingBoxGizmoEnabled(value: boolean);
  56926. get boundingBoxGizmoEnabled(): boolean;
  56927. /**
  56928. * Disposes of the gizmo manager
  56929. */
  56930. dispose(): void;
  56931. }
  56932. }
  56933. declare module BABYLON {
  56934. /**
  56935. * A directional light is defined by a direction (what a surprise!).
  56936. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56937. * 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.
  56938. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56939. */
  56940. export class DirectionalLight extends ShadowLight {
  56941. private _shadowFrustumSize;
  56942. /**
  56943. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56944. */
  56945. get shadowFrustumSize(): number;
  56946. /**
  56947. * Specifies a fix frustum size for the shadow generation.
  56948. */
  56949. set shadowFrustumSize(value: number);
  56950. private _shadowOrthoScale;
  56951. /**
  56952. * Gets the shadow projection scale against the optimal computed one.
  56953. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56954. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56955. */
  56956. get shadowOrthoScale(): number;
  56957. /**
  56958. * Sets the shadow projection scale against the optimal computed one.
  56959. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56960. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56961. */
  56962. set shadowOrthoScale(value: number);
  56963. /**
  56964. * Automatically compute the projection matrix to best fit (including all the casters)
  56965. * on each frame.
  56966. */
  56967. autoUpdateExtends: boolean;
  56968. /**
  56969. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56970. * on each frame. autoUpdateExtends must be set to true for this to work
  56971. */
  56972. autoCalcShadowZBounds: boolean;
  56973. private _orthoLeft;
  56974. private _orthoRight;
  56975. private _orthoTop;
  56976. private _orthoBottom;
  56977. /**
  56978. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56979. * The directional light is emitted from everywhere in the given direction.
  56980. * It can cast shadows.
  56981. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56982. * @param name The friendly name of the light
  56983. * @param direction The direction of the light
  56984. * @param scene The scene the light belongs to
  56985. */
  56986. constructor(name: string, direction: Vector3, scene: Scene);
  56987. /**
  56988. * Returns the string "DirectionalLight".
  56989. * @return The class name
  56990. */
  56991. getClassName(): string;
  56992. /**
  56993. * Returns the integer 1.
  56994. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56995. */
  56996. getTypeID(): number;
  56997. /**
  56998. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56999. * Returns the DirectionalLight Shadow projection matrix.
  57000. */
  57001. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57002. /**
  57003. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57004. * Returns the DirectionalLight Shadow projection matrix.
  57005. */
  57006. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57007. /**
  57008. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57009. * Returns the DirectionalLight Shadow projection matrix.
  57010. */
  57011. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57012. protected _buildUniformLayout(): void;
  57013. /**
  57014. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57015. * @param effect The effect to update
  57016. * @param lightIndex The index of the light in the effect to update
  57017. * @returns The directional light
  57018. */
  57019. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57020. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57021. /**
  57022. * Gets the minZ used for shadow according to both the scene and the light.
  57023. *
  57024. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57025. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57026. * @param activeCamera The camera we are returning the min for
  57027. * @returns the depth min z
  57028. */
  57029. getDepthMinZ(activeCamera: Camera): number;
  57030. /**
  57031. * Gets the maxZ used for shadow according to both the scene and the light.
  57032. *
  57033. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57034. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57035. * @param activeCamera The camera we are returning the max for
  57036. * @returns the depth max z
  57037. */
  57038. getDepthMaxZ(activeCamera: Camera): number;
  57039. /**
  57040. * Prepares the list of defines specific to the light type.
  57041. * @param defines the list of defines
  57042. * @param lightIndex defines the index of the light for the effect
  57043. */
  57044. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57045. }
  57046. }
  57047. declare module BABYLON {
  57048. /**
  57049. * Class containing static functions to help procedurally build meshes
  57050. */
  57051. export class HemisphereBuilder {
  57052. /**
  57053. * Creates a hemisphere mesh
  57054. * @param name defines the name of the mesh
  57055. * @param options defines the options used to create the mesh
  57056. * @param scene defines the hosting scene
  57057. * @returns the hemisphere mesh
  57058. */
  57059. static CreateHemisphere(name: string, options: {
  57060. segments?: number;
  57061. diameter?: number;
  57062. sideOrientation?: number;
  57063. }, scene: any): Mesh;
  57064. }
  57065. }
  57066. declare module BABYLON {
  57067. /**
  57068. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57069. * These values define a cone of light starting from the position, emitting toward the direction.
  57070. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57071. * and the exponent defines the speed of the decay of the light with distance (reach).
  57072. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57073. */
  57074. export class SpotLight extends ShadowLight {
  57075. private _angle;
  57076. private _innerAngle;
  57077. private _cosHalfAngle;
  57078. private _lightAngleScale;
  57079. private _lightAngleOffset;
  57080. /**
  57081. * Gets the cone angle of the spot light in Radians.
  57082. */
  57083. get angle(): number;
  57084. /**
  57085. * Sets the cone angle of the spot light in Radians.
  57086. */
  57087. set angle(value: number);
  57088. /**
  57089. * Only used in gltf falloff mode, this defines the angle where
  57090. * the directional falloff will start before cutting at angle which could be seen
  57091. * as outer angle.
  57092. */
  57093. get innerAngle(): number;
  57094. /**
  57095. * Only used in gltf falloff mode, this defines the angle where
  57096. * the directional falloff will start before cutting at angle which could be seen
  57097. * as outer angle.
  57098. */
  57099. set innerAngle(value: number);
  57100. private _shadowAngleScale;
  57101. /**
  57102. * Allows scaling the angle of the light for shadow generation only.
  57103. */
  57104. get shadowAngleScale(): number;
  57105. /**
  57106. * Allows scaling the angle of the light for shadow generation only.
  57107. */
  57108. set shadowAngleScale(value: number);
  57109. /**
  57110. * The light decay speed with the distance from the emission spot.
  57111. */
  57112. exponent: number;
  57113. private _projectionTextureMatrix;
  57114. /**
  57115. * Allows reading the projecton texture
  57116. */
  57117. get projectionTextureMatrix(): Matrix;
  57118. protected _projectionTextureLightNear: number;
  57119. /**
  57120. * Gets the near clip of the Spotlight for texture projection.
  57121. */
  57122. get projectionTextureLightNear(): number;
  57123. /**
  57124. * Sets the near clip of the Spotlight for texture projection.
  57125. */
  57126. set projectionTextureLightNear(value: number);
  57127. protected _projectionTextureLightFar: number;
  57128. /**
  57129. * Gets the far clip of the Spotlight for texture projection.
  57130. */
  57131. get projectionTextureLightFar(): number;
  57132. /**
  57133. * Sets the far clip of the Spotlight for texture projection.
  57134. */
  57135. set projectionTextureLightFar(value: number);
  57136. protected _projectionTextureUpDirection: Vector3;
  57137. /**
  57138. * Gets the Up vector of the Spotlight for texture projection.
  57139. */
  57140. get projectionTextureUpDirection(): Vector3;
  57141. /**
  57142. * Sets the Up vector of the Spotlight for texture projection.
  57143. */
  57144. set projectionTextureUpDirection(value: Vector3);
  57145. private _projectionTexture;
  57146. /**
  57147. * Gets the projection texture of the light.
  57148. */
  57149. get projectionTexture(): Nullable<BaseTexture>;
  57150. /**
  57151. * Sets the projection texture of the light.
  57152. */
  57153. set projectionTexture(value: Nullable<BaseTexture>);
  57154. private _projectionTextureViewLightDirty;
  57155. private _projectionTextureProjectionLightDirty;
  57156. private _projectionTextureDirty;
  57157. private _projectionTextureViewTargetVector;
  57158. private _projectionTextureViewLightMatrix;
  57159. private _projectionTextureProjectionLightMatrix;
  57160. private _projectionTextureScalingMatrix;
  57161. /**
  57162. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57163. * It can cast shadows.
  57164. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57165. * @param name The light friendly name
  57166. * @param position The position of the spot light in the scene
  57167. * @param direction The direction of the light in the scene
  57168. * @param angle The cone angle of the light in Radians
  57169. * @param exponent The light decay speed with the distance from the emission spot
  57170. * @param scene The scene the lights belongs to
  57171. */
  57172. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57173. /**
  57174. * Returns the string "SpotLight".
  57175. * @returns the class name
  57176. */
  57177. getClassName(): string;
  57178. /**
  57179. * Returns the integer 2.
  57180. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57181. */
  57182. getTypeID(): number;
  57183. /**
  57184. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57185. */
  57186. protected _setDirection(value: Vector3): void;
  57187. /**
  57188. * Overrides the position setter to recompute the projection texture view light Matrix.
  57189. */
  57190. protected _setPosition(value: Vector3): void;
  57191. /**
  57192. * 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.
  57193. * Returns the SpotLight.
  57194. */
  57195. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57196. protected _computeProjectionTextureViewLightMatrix(): void;
  57197. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57198. /**
  57199. * Main function for light texture projection matrix computing.
  57200. */
  57201. protected _computeProjectionTextureMatrix(): void;
  57202. protected _buildUniformLayout(): void;
  57203. private _computeAngleValues;
  57204. /**
  57205. * Sets the passed Effect "effect" with the Light textures.
  57206. * @param effect The effect to update
  57207. * @param lightIndex The index of the light in the effect to update
  57208. * @returns The light
  57209. */
  57210. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57211. /**
  57212. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57213. * @param effect The effect to update
  57214. * @param lightIndex The index of the light in the effect to update
  57215. * @returns The spot light
  57216. */
  57217. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57218. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57219. /**
  57220. * Disposes the light and the associated resources.
  57221. */
  57222. dispose(): void;
  57223. /**
  57224. * Prepares the list of defines specific to the light type.
  57225. * @param defines the list of defines
  57226. * @param lightIndex defines the index of the light for the effect
  57227. */
  57228. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57229. }
  57230. }
  57231. declare module BABYLON {
  57232. /**
  57233. * Gizmo that enables viewing a light
  57234. */
  57235. export class LightGizmo extends Gizmo {
  57236. private _lightMesh;
  57237. private _material;
  57238. private _cachedPosition;
  57239. private _cachedForward;
  57240. private _attachedMeshParent;
  57241. private _pointerObserver;
  57242. /**
  57243. * Event that fires each time the gizmo is clicked
  57244. */
  57245. onClickedObservable: Observable<Light>;
  57246. /**
  57247. * Creates a LightGizmo
  57248. * @param gizmoLayer The utility layer the gizmo will be added to
  57249. */
  57250. constructor(gizmoLayer?: UtilityLayerRenderer);
  57251. private _light;
  57252. /**
  57253. * The light that the gizmo is attached to
  57254. */
  57255. set light(light: Nullable<Light>);
  57256. get light(): Nullable<Light>;
  57257. /**
  57258. * Gets the material used to render the light gizmo
  57259. */
  57260. get material(): StandardMaterial;
  57261. /**
  57262. * @hidden
  57263. * Updates the gizmo to match the attached mesh's position/rotation
  57264. */
  57265. protected _update(): void;
  57266. private static _Scale;
  57267. /**
  57268. * Creates the lines for a light mesh
  57269. */
  57270. private static _CreateLightLines;
  57271. /**
  57272. * Disposes of the light gizmo
  57273. */
  57274. dispose(): void;
  57275. private static _CreateHemisphericLightMesh;
  57276. private static _CreatePointLightMesh;
  57277. private static _CreateSpotLightMesh;
  57278. private static _CreateDirectionalLightMesh;
  57279. }
  57280. }
  57281. declare module BABYLON {
  57282. /**
  57283. * Gizmo that enables viewing a camera
  57284. */
  57285. export class CameraGizmo extends Gizmo {
  57286. private _cameraMesh;
  57287. private _cameraLinesMesh;
  57288. private _material;
  57289. private _pointerObserver;
  57290. /**
  57291. * Event that fires each time the gizmo is clicked
  57292. */
  57293. onClickedObservable: Observable<Camera>;
  57294. /**
  57295. * Creates a CameraGizmo
  57296. * @param gizmoLayer The utility layer the gizmo will be added to
  57297. */
  57298. constructor(gizmoLayer?: UtilityLayerRenderer);
  57299. private _camera;
  57300. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  57301. get displayFrustum(): boolean;
  57302. set displayFrustum(value: boolean);
  57303. /**
  57304. * The camera that the gizmo is attached to
  57305. */
  57306. set camera(camera: Nullable<Camera>);
  57307. get camera(): Nullable<Camera>;
  57308. /**
  57309. * Gets the material used to render the camera gizmo
  57310. */
  57311. get material(): StandardMaterial;
  57312. /**
  57313. * @hidden
  57314. * Updates the gizmo to match the attached mesh's position/rotation
  57315. */
  57316. protected _update(): void;
  57317. private static _Scale;
  57318. private _invProjection;
  57319. /**
  57320. * Disposes of the camera gizmo
  57321. */
  57322. dispose(): void;
  57323. private static _CreateCameraMesh;
  57324. private static _CreateCameraFrustum;
  57325. }
  57326. }
  57327. declare module BABYLON {
  57328. /** @hidden */
  57329. export var backgroundFragmentDeclaration: {
  57330. name: string;
  57331. shader: string;
  57332. };
  57333. }
  57334. declare module BABYLON {
  57335. /** @hidden */
  57336. export var backgroundUboDeclaration: {
  57337. name: string;
  57338. shader: string;
  57339. };
  57340. }
  57341. declare module BABYLON {
  57342. /** @hidden */
  57343. export var backgroundPixelShader: {
  57344. name: string;
  57345. shader: string;
  57346. };
  57347. }
  57348. declare module BABYLON {
  57349. /** @hidden */
  57350. export var backgroundVertexDeclaration: {
  57351. name: string;
  57352. shader: string;
  57353. };
  57354. }
  57355. declare module BABYLON {
  57356. /** @hidden */
  57357. export var backgroundVertexShader: {
  57358. name: string;
  57359. shader: string;
  57360. };
  57361. }
  57362. declare module BABYLON {
  57363. /**
  57364. * Background material used to create an efficient environement around your scene.
  57365. */
  57366. export class BackgroundMaterial extends PushMaterial {
  57367. /**
  57368. * Standard reflectance value at parallel view angle.
  57369. */
  57370. static StandardReflectance0: number;
  57371. /**
  57372. * Standard reflectance value at grazing angle.
  57373. */
  57374. static StandardReflectance90: number;
  57375. protected _primaryColor: Color3;
  57376. /**
  57377. * Key light Color (multiply against the environement texture)
  57378. */
  57379. primaryColor: Color3;
  57380. protected __perceptualColor: Nullable<Color3>;
  57381. /**
  57382. * Experimental Internal Use Only.
  57383. *
  57384. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57385. * This acts as a helper to set the primary color to a more "human friendly" value.
  57386. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57387. * output color as close as possible from the chosen value.
  57388. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57389. * part of lighting setup.)
  57390. */
  57391. get _perceptualColor(): Nullable<Color3>;
  57392. set _perceptualColor(value: Nullable<Color3>);
  57393. protected _primaryColorShadowLevel: float;
  57394. /**
  57395. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57396. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57397. */
  57398. get primaryColorShadowLevel(): float;
  57399. set primaryColorShadowLevel(value: float);
  57400. protected _primaryColorHighlightLevel: float;
  57401. /**
  57402. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57403. * The primary color is used at the level chosen to define what the white area would look.
  57404. */
  57405. get primaryColorHighlightLevel(): float;
  57406. set primaryColorHighlightLevel(value: float);
  57407. protected _reflectionTexture: Nullable<BaseTexture>;
  57408. /**
  57409. * Reflection Texture used in the material.
  57410. * Should be author in a specific way for the best result (refer to the documentation).
  57411. */
  57412. reflectionTexture: Nullable<BaseTexture>;
  57413. protected _reflectionBlur: float;
  57414. /**
  57415. * Reflection Texture level of blur.
  57416. *
  57417. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57418. * texture twice.
  57419. */
  57420. reflectionBlur: float;
  57421. protected _diffuseTexture: Nullable<BaseTexture>;
  57422. /**
  57423. * Diffuse Texture used in the material.
  57424. * Should be author in a specific way for the best result (refer to the documentation).
  57425. */
  57426. diffuseTexture: Nullable<BaseTexture>;
  57427. protected _shadowLights: Nullable<IShadowLight[]>;
  57428. /**
  57429. * Specify the list of lights casting shadow on the material.
  57430. * All scene shadow lights will be included if null.
  57431. */
  57432. shadowLights: Nullable<IShadowLight[]>;
  57433. protected _shadowLevel: float;
  57434. /**
  57435. * Helps adjusting the shadow to a softer level if required.
  57436. * 0 means black shadows and 1 means no shadows.
  57437. */
  57438. shadowLevel: float;
  57439. protected _sceneCenter: Vector3;
  57440. /**
  57441. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57442. * It is usually zero but might be interesting to modify according to your setup.
  57443. */
  57444. sceneCenter: Vector3;
  57445. protected _opacityFresnel: boolean;
  57446. /**
  57447. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57448. * This helps ensuring a nice transition when the camera goes under the ground.
  57449. */
  57450. opacityFresnel: boolean;
  57451. protected _reflectionFresnel: boolean;
  57452. /**
  57453. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57454. * This helps adding a mirror texture on the ground.
  57455. */
  57456. reflectionFresnel: boolean;
  57457. protected _reflectionFalloffDistance: number;
  57458. /**
  57459. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57460. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57461. */
  57462. reflectionFalloffDistance: number;
  57463. protected _reflectionAmount: number;
  57464. /**
  57465. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57466. */
  57467. reflectionAmount: number;
  57468. protected _reflectionReflectance0: number;
  57469. /**
  57470. * This specifies the weight of the reflection at grazing angle.
  57471. */
  57472. reflectionReflectance0: number;
  57473. protected _reflectionReflectance90: number;
  57474. /**
  57475. * This specifies the weight of the reflection at a perpendicular point of view.
  57476. */
  57477. reflectionReflectance90: number;
  57478. /**
  57479. * Sets the reflection reflectance fresnel values according to the default standard
  57480. * empirically know to work well :-)
  57481. */
  57482. set reflectionStandardFresnelWeight(value: number);
  57483. protected _useRGBColor: boolean;
  57484. /**
  57485. * Helps to directly use the maps channels instead of their level.
  57486. */
  57487. useRGBColor: boolean;
  57488. protected _enableNoise: boolean;
  57489. /**
  57490. * This helps reducing the banding effect that could occur on the background.
  57491. */
  57492. enableNoise: boolean;
  57493. /**
  57494. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57495. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57496. * Recommended to be keep at 1.0 except for special cases.
  57497. */
  57498. get fovMultiplier(): number;
  57499. set fovMultiplier(value: number);
  57500. private _fovMultiplier;
  57501. /**
  57502. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57503. */
  57504. useEquirectangularFOV: boolean;
  57505. private _maxSimultaneousLights;
  57506. /**
  57507. * Number of Simultaneous lights allowed on the material.
  57508. */
  57509. maxSimultaneousLights: int;
  57510. private _shadowOnly;
  57511. /**
  57512. * Make the material only render shadows
  57513. */
  57514. shadowOnly: boolean;
  57515. /**
  57516. * Default configuration related to image processing available in the Background Material.
  57517. */
  57518. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57519. /**
  57520. * Keep track of the image processing observer to allow dispose and replace.
  57521. */
  57522. private _imageProcessingObserver;
  57523. /**
  57524. * Attaches a new image processing configuration to the PBR Material.
  57525. * @param configuration (if null the scene configuration will be use)
  57526. */
  57527. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57528. /**
  57529. * Gets the image processing configuration used either in this material.
  57530. */
  57531. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57532. /**
  57533. * Sets the Default image processing configuration used either in the this material.
  57534. *
  57535. * If sets to null, the scene one is in use.
  57536. */
  57537. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57538. /**
  57539. * Gets wether the color curves effect is enabled.
  57540. */
  57541. get cameraColorCurvesEnabled(): boolean;
  57542. /**
  57543. * Sets wether the color curves effect is enabled.
  57544. */
  57545. set cameraColorCurvesEnabled(value: boolean);
  57546. /**
  57547. * Gets wether the color grading effect is enabled.
  57548. */
  57549. get cameraColorGradingEnabled(): boolean;
  57550. /**
  57551. * Gets wether the color grading effect is enabled.
  57552. */
  57553. set cameraColorGradingEnabled(value: boolean);
  57554. /**
  57555. * Gets wether tonemapping is enabled or not.
  57556. */
  57557. get cameraToneMappingEnabled(): boolean;
  57558. /**
  57559. * Sets wether tonemapping is enabled or not
  57560. */
  57561. set cameraToneMappingEnabled(value: boolean);
  57562. /**
  57563. * The camera exposure used on this material.
  57564. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57565. * This corresponds to a photographic exposure.
  57566. */
  57567. get cameraExposure(): float;
  57568. /**
  57569. * The camera exposure used on this material.
  57570. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57571. * This corresponds to a photographic exposure.
  57572. */
  57573. set cameraExposure(value: float);
  57574. /**
  57575. * Gets The camera contrast used on this material.
  57576. */
  57577. get cameraContrast(): float;
  57578. /**
  57579. * Sets The camera contrast used on this material.
  57580. */
  57581. set cameraContrast(value: float);
  57582. /**
  57583. * Gets the Color Grading 2D Lookup Texture.
  57584. */
  57585. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57586. /**
  57587. * Sets the Color Grading 2D Lookup Texture.
  57588. */
  57589. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57590. /**
  57591. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57592. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57593. * 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;
  57594. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57595. */
  57596. get cameraColorCurves(): Nullable<ColorCurves>;
  57597. /**
  57598. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57599. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57600. * 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;
  57601. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57602. */
  57603. set cameraColorCurves(value: Nullable<ColorCurves>);
  57604. /**
  57605. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57606. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57607. */
  57608. switchToBGR: boolean;
  57609. private _renderTargets;
  57610. private _reflectionControls;
  57611. private _white;
  57612. private _primaryShadowColor;
  57613. private _primaryHighlightColor;
  57614. /**
  57615. * Instantiates a Background Material in the given scene
  57616. * @param name The friendly name of the material
  57617. * @param scene The scene to add the material to
  57618. */
  57619. constructor(name: string, scene: Scene);
  57620. /**
  57621. * Gets a boolean indicating that current material needs to register RTT
  57622. */
  57623. get hasRenderTargetTextures(): boolean;
  57624. /**
  57625. * The entire material has been created in order to prevent overdraw.
  57626. * @returns false
  57627. */
  57628. needAlphaTesting(): boolean;
  57629. /**
  57630. * The entire material has been created in order to prevent overdraw.
  57631. * @returns true if blending is enable
  57632. */
  57633. needAlphaBlending(): boolean;
  57634. /**
  57635. * Checks wether the material is ready to be rendered for a given mesh.
  57636. * @param mesh The mesh to render
  57637. * @param subMesh The submesh to check against
  57638. * @param useInstances Specify wether or not the material is used with instances
  57639. * @returns true if all the dependencies are ready (Textures, Effects...)
  57640. */
  57641. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57642. /**
  57643. * Compute the primary color according to the chosen perceptual color.
  57644. */
  57645. private _computePrimaryColorFromPerceptualColor;
  57646. /**
  57647. * Compute the highlights and shadow colors according to their chosen levels.
  57648. */
  57649. private _computePrimaryColors;
  57650. /**
  57651. * Build the uniform buffer used in the material.
  57652. */
  57653. buildUniformLayout(): void;
  57654. /**
  57655. * Unbind the material.
  57656. */
  57657. unbind(): void;
  57658. /**
  57659. * Bind only the world matrix to the material.
  57660. * @param world The world matrix to bind.
  57661. */
  57662. bindOnlyWorldMatrix(world: Matrix): void;
  57663. /**
  57664. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57665. * @param world The world matrix to bind.
  57666. * @param subMesh The submesh to bind for.
  57667. */
  57668. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57669. /**
  57670. * Checks to see if a texture is used in the material.
  57671. * @param texture - Base texture to use.
  57672. * @returns - Boolean specifying if a texture is used in the material.
  57673. */
  57674. hasTexture(texture: BaseTexture): boolean;
  57675. /**
  57676. * Dispose the material.
  57677. * @param forceDisposeEffect Force disposal of the associated effect.
  57678. * @param forceDisposeTextures Force disposal of the associated textures.
  57679. */
  57680. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57681. /**
  57682. * Clones the material.
  57683. * @param name The cloned name.
  57684. * @returns The cloned material.
  57685. */
  57686. clone(name: string): BackgroundMaterial;
  57687. /**
  57688. * Serializes the current material to its JSON representation.
  57689. * @returns The JSON representation.
  57690. */
  57691. serialize(): any;
  57692. /**
  57693. * Gets the class name of the material
  57694. * @returns "BackgroundMaterial"
  57695. */
  57696. getClassName(): string;
  57697. /**
  57698. * Parse a JSON input to create back a background material.
  57699. * @param source The JSON data to parse
  57700. * @param scene The scene to create the parsed material in
  57701. * @param rootUrl The root url of the assets the material depends upon
  57702. * @returns the instantiated BackgroundMaterial.
  57703. */
  57704. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57705. }
  57706. }
  57707. declare module BABYLON {
  57708. /**
  57709. * Represents the different options available during the creation of
  57710. * a Environment helper.
  57711. *
  57712. * This can control the default ground, skybox and image processing setup of your scene.
  57713. */
  57714. export interface IEnvironmentHelperOptions {
  57715. /**
  57716. * Specifies whether or not to create a ground.
  57717. * True by default.
  57718. */
  57719. createGround: boolean;
  57720. /**
  57721. * Specifies the ground size.
  57722. * 15 by default.
  57723. */
  57724. groundSize: number;
  57725. /**
  57726. * The texture used on the ground for the main color.
  57727. * Comes from the BabylonJS CDN by default.
  57728. *
  57729. * Remarks: Can be either a texture or a url.
  57730. */
  57731. groundTexture: string | BaseTexture;
  57732. /**
  57733. * The color mixed in the ground texture by default.
  57734. * BabylonJS clearColor by default.
  57735. */
  57736. groundColor: Color3;
  57737. /**
  57738. * Specifies the ground opacity.
  57739. * 1 by default.
  57740. */
  57741. groundOpacity: number;
  57742. /**
  57743. * Enables the ground to receive shadows.
  57744. * True by default.
  57745. */
  57746. enableGroundShadow: boolean;
  57747. /**
  57748. * Helps preventing the shadow to be fully black on the ground.
  57749. * 0.5 by default.
  57750. */
  57751. groundShadowLevel: number;
  57752. /**
  57753. * Creates a mirror texture attach to the ground.
  57754. * false by default.
  57755. */
  57756. enableGroundMirror: boolean;
  57757. /**
  57758. * Specifies the ground mirror size ratio.
  57759. * 0.3 by default as the default kernel is 64.
  57760. */
  57761. groundMirrorSizeRatio: number;
  57762. /**
  57763. * Specifies the ground mirror blur kernel size.
  57764. * 64 by default.
  57765. */
  57766. groundMirrorBlurKernel: number;
  57767. /**
  57768. * Specifies the ground mirror visibility amount.
  57769. * 1 by default
  57770. */
  57771. groundMirrorAmount: number;
  57772. /**
  57773. * Specifies the ground mirror reflectance weight.
  57774. * This uses the standard weight of the background material to setup the fresnel effect
  57775. * of the mirror.
  57776. * 1 by default.
  57777. */
  57778. groundMirrorFresnelWeight: number;
  57779. /**
  57780. * Specifies the ground mirror Falloff distance.
  57781. * This can helps reducing the size of the reflection.
  57782. * 0 by Default.
  57783. */
  57784. groundMirrorFallOffDistance: number;
  57785. /**
  57786. * Specifies the ground mirror texture type.
  57787. * Unsigned Int by Default.
  57788. */
  57789. groundMirrorTextureType: number;
  57790. /**
  57791. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57792. * the shown objects.
  57793. */
  57794. groundYBias: number;
  57795. /**
  57796. * Specifies whether or not to create a skybox.
  57797. * True by default.
  57798. */
  57799. createSkybox: boolean;
  57800. /**
  57801. * Specifies the skybox size.
  57802. * 20 by default.
  57803. */
  57804. skyboxSize: number;
  57805. /**
  57806. * The texture used on the skybox for the main color.
  57807. * Comes from the BabylonJS CDN by default.
  57808. *
  57809. * Remarks: Can be either a texture or a url.
  57810. */
  57811. skyboxTexture: string | BaseTexture;
  57812. /**
  57813. * The color mixed in the skybox texture by default.
  57814. * BabylonJS clearColor by default.
  57815. */
  57816. skyboxColor: Color3;
  57817. /**
  57818. * The background rotation around the Y axis of the scene.
  57819. * This helps aligning the key lights of your scene with the background.
  57820. * 0 by default.
  57821. */
  57822. backgroundYRotation: number;
  57823. /**
  57824. * Compute automatically the size of the elements to best fit with the scene.
  57825. */
  57826. sizeAuto: boolean;
  57827. /**
  57828. * Default position of the rootMesh if autoSize is not true.
  57829. */
  57830. rootPosition: Vector3;
  57831. /**
  57832. * Sets up the image processing in the scene.
  57833. * true by default.
  57834. */
  57835. setupImageProcessing: boolean;
  57836. /**
  57837. * The texture used as your environment texture in the scene.
  57838. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57839. *
  57840. * Remarks: Can be either a texture or a url.
  57841. */
  57842. environmentTexture: string | BaseTexture;
  57843. /**
  57844. * The value of the exposure to apply to the scene.
  57845. * 0.6 by default if setupImageProcessing is true.
  57846. */
  57847. cameraExposure: number;
  57848. /**
  57849. * The value of the contrast to apply to the scene.
  57850. * 1.6 by default if setupImageProcessing is true.
  57851. */
  57852. cameraContrast: number;
  57853. /**
  57854. * Specifies whether or not tonemapping should be enabled in the scene.
  57855. * true by default if setupImageProcessing is true.
  57856. */
  57857. toneMappingEnabled: boolean;
  57858. }
  57859. /**
  57860. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57861. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57862. * It also helps with the default setup of your imageProcessing configuration.
  57863. */
  57864. export class EnvironmentHelper {
  57865. /**
  57866. * Default ground texture URL.
  57867. */
  57868. private static _groundTextureCDNUrl;
  57869. /**
  57870. * Default skybox texture URL.
  57871. */
  57872. private static _skyboxTextureCDNUrl;
  57873. /**
  57874. * Default environment texture URL.
  57875. */
  57876. private static _environmentTextureCDNUrl;
  57877. /**
  57878. * Creates the default options for the helper.
  57879. */
  57880. private static _getDefaultOptions;
  57881. private _rootMesh;
  57882. /**
  57883. * Gets the root mesh created by the helper.
  57884. */
  57885. get rootMesh(): Mesh;
  57886. private _skybox;
  57887. /**
  57888. * Gets the skybox created by the helper.
  57889. */
  57890. get skybox(): Nullable<Mesh>;
  57891. private _skyboxTexture;
  57892. /**
  57893. * Gets the skybox texture created by the helper.
  57894. */
  57895. get skyboxTexture(): Nullable<BaseTexture>;
  57896. private _skyboxMaterial;
  57897. /**
  57898. * Gets the skybox material created by the helper.
  57899. */
  57900. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57901. private _ground;
  57902. /**
  57903. * Gets the ground mesh created by the helper.
  57904. */
  57905. get ground(): Nullable<Mesh>;
  57906. private _groundTexture;
  57907. /**
  57908. * Gets the ground texture created by the helper.
  57909. */
  57910. get groundTexture(): Nullable<BaseTexture>;
  57911. private _groundMirror;
  57912. /**
  57913. * Gets the ground mirror created by the helper.
  57914. */
  57915. get groundMirror(): Nullable<MirrorTexture>;
  57916. /**
  57917. * Gets the ground mirror render list to helps pushing the meshes
  57918. * you wish in the ground reflection.
  57919. */
  57920. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57921. private _groundMaterial;
  57922. /**
  57923. * Gets the ground material created by the helper.
  57924. */
  57925. get groundMaterial(): Nullable<BackgroundMaterial>;
  57926. /**
  57927. * Stores the creation options.
  57928. */
  57929. private readonly _scene;
  57930. private _options;
  57931. /**
  57932. * This observable will be notified with any error during the creation of the environment,
  57933. * mainly texture creation errors.
  57934. */
  57935. onErrorObservable: Observable<{
  57936. message?: string;
  57937. exception?: any;
  57938. }>;
  57939. /**
  57940. * constructor
  57941. * @param options Defines the options we want to customize the helper
  57942. * @param scene The scene to add the material to
  57943. */
  57944. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57945. /**
  57946. * Updates the background according to the new options
  57947. * @param options
  57948. */
  57949. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57950. /**
  57951. * Sets the primary color of all the available elements.
  57952. * @param color the main color to affect to the ground and the background
  57953. */
  57954. setMainColor(color: Color3): void;
  57955. /**
  57956. * Setup the image processing according to the specified options.
  57957. */
  57958. private _setupImageProcessing;
  57959. /**
  57960. * Setup the environment texture according to the specified options.
  57961. */
  57962. private _setupEnvironmentTexture;
  57963. /**
  57964. * Setup the background according to the specified options.
  57965. */
  57966. private _setupBackground;
  57967. /**
  57968. * Get the scene sizes according to the setup.
  57969. */
  57970. private _getSceneSize;
  57971. /**
  57972. * Setup the ground according to the specified options.
  57973. */
  57974. private _setupGround;
  57975. /**
  57976. * Setup the ground material according to the specified options.
  57977. */
  57978. private _setupGroundMaterial;
  57979. /**
  57980. * Setup the ground diffuse texture according to the specified options.
  57981. */
  57982. private _setupGroundDiffuseTexture;
  57983. /**
  57984. * Setup the ground mirror texture according to the specified options.
  57985. */
  57986. private _setupGroundMirrorTexture;
  57987. /**
  57988. * Setup the ground to receive the mirror texture.
  57989. */
  57990. private _setupMirrorInGroundMaterial;
  57991. /**
  57992. * Setup the skybox according to the specified options.
  57993. */
  57994. private _setupSkybox;
  57995. /**
  57996. * Setup the skybox material according to the specified options.
  57997. */
  57998. private _setupSkyboxMaterial;
  57999. /**
  58000. * Setup the skybox reflection texture according to the specified options.
  58001. */
  58002. private _setupSkyboxReflectionTexture;
  58003. private _errorHandler;
  58004. /**
  58005. * Dispose all the elements created by the Helper.
  58006. */
  58007. dispose(): void;
  58008. }
  58009. }
  58010. declare module BABYLON {
  58011. /**
  58012. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58013. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58014. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58015. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58016. */
  58017. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58018. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58019. /**
  58020. * Define the source as a Monoscopic panoramic 360/180.
  58021. */
  58022. static readonly MODE_MONOSCOPIC: number;
  58023. /**
  58024. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58025. */
  58026. static readonly MODE_TOPBOTTOM: number;
  58027. /**
  58028. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58029. */
  58030. static readonly MODE_SIDEBYSIDE: number;
  58031. private _halfDome;
  58032. private _crossEye;
  58033. protected _useDirectMapping: boolean;
  58034. /**
  58035. * The texture being displayed on the sphere
  58036. */
  58037. protected _texture: T;
  58038. /**
  58039. * Gets the texture being displayed on the sphere
  58040. */
  58041. get texture(): T;
  58042. /**
  58043. * Sets the texture being displayed on the sphere
  58044. */
  58045. set texture(newTexture: T);
  58046. /**
  58047. * The skybox material
  58048. */
  58049. protected _material: BackgroundMaterial;
  58050. /**
  58051. * The surface used for the dome
  58052. */
  58053. protected _mesh: Mesh;
  58054. /**
  58055. * Gets the mesh used for the dome.
  58056. */
  58057. get mesh(): Mesh;
  58058. /**
  58059. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58060. */
  58061. private _halfDomeMask;
  58062. /**
  58063. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58064. * Also see the options.resolution property.
  58065. */
  58066. get fovMultiplier(): number;
  58067. set fovMultiplier(value: number);
  58068. protected _textureMode: number;
  58069. /**
  58070. * Gets or set the current texture mode for the texture. It can be:
  58071. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58072. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58073. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58074. */
  58075. get textureMode(): number;
  58076. /**
  58077. * Sets the current texture mode for the texture. It can be:
  58078. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58079. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58080. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58081. */
  58082. set textureMode(value: number);
  58083. /**
  58084. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58085. */
  58086. get halfDome(): boolean;
  58087. /**
  58088. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58089. */
  58090. set halfDome(enabled: boolean);
  58091. /**
  58092. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58093. */
  58094. set crossEye(enabled: boolean);
  58095. /**
  58096. * Is it a cross-eye texture?
  58097. */
  58098. get crossEye(): boolean;
  58099. /**
  58100. * Oberserver used in Stereoscopic VR Mode.
  58101. */
  58102. private _onBeforeCameraRenderObserver;
  58103. /**
  58104. * Observable raised when an error occured while loading the 360 image
  58105. */
  58106. onLoadErrorObservable: Observable<string>;
  58107. /**
  58108. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58109. * @param name Element's name, child elements will append suffixes for their own names.
  58110. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58111. * @param options An object containing optional or exposed sub element properties
  58112. */
  58113. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58114. resolution?: number;
  58115. clickToPlay?: boolean;
  58116. autoPlay?: boolean;
  58117. loop?: boolean;
  58118. size?: number;
  58119. poster?: string;
  58120. faceForward?: boolean;
  58121. useDirectMapping?: boolean;
  58122. halfDomeMode?: boolean;
  58123. crossEyeMode?: boolean;
  58124. generateMipMaps?: boolean;
  58125. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58126. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58127. protected _changeTextureMode(value: number): void;
  58128. /**
  58129. * Releases resources associated with this node.
  58130. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58131. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58132. */
  58133. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58134. }
  58135. }
  58136. declare module BABYLON {
  58137. /**
  58138. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58139. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58140. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58141. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58142. */
  58143. export class PhotoDome extends TextureDome<Texture> {
  58144. /**
  58145. * Define the image as a Monoscopic panoramic 360 image.
  58146. */
  58147. static readonly MODE_MONOSCOPIC: number;
  58148. /**
  58149. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58150. */
  58151. static readonly MODE_TOPBOTTOM: number;
  58152. /**
  58153. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58154. */
  58155. static readonly MODE_SIDEBYSIDE: number;
  58156. /**
  58157. * Gets or sets the texture being displayed on the sphere
  58158. */
  58159. get photoTexture(): Texture;
  58160. /**
  58161. * sets the texture being displayed on the sphere
  58162. */
  58163. set photoTexture(value: Texture);
  58164. /**
  58165. * Gets the current video mode for the video. It can be:
  58166. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58167. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58168. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58169. */
  58170. get imageMode(): number;
  58171. /**
  58172. * Sets the current video mode for the video. It can be:
  58173. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58174. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58175. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58176. */
  58177. set imageMode(value: number);
  58178. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58179. }
  58180. }
  58181. declare module BABYLON {
  58182. /**
  58183. * Direct draw surface info
  58184. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58185. */
  58186. export interface DDSInfo {
  58187. /**
  58188. * Width of the texture
  58189. */
  58190. width: number;
  58191. /**
  58192. * Width of the texture
  58193. */
  58194. height: number;
  58195. /**
  58196. * Number of Mipmaps for the texture
  58197. * @see https://en.wikipedia.org/wiki/Mipmap
  58198. */
  58199. mipmapCount: number;
  58200. /**
  58201. * If the textures format is a known fourCC format
  58202. * @see https://www.fourcc.org/
  58203. */
  58204. isFourCC: boolean;
  58205. /**
  58206. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58207. */
  58208. isRGB: boolean;
  58209. /**
  58210. * If the texture is a lumincance format
  58211. */
  58212. isLuminance: boolean;
  58213. /**
  58214. * If this is a cube texture
  58215. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58216. */
  58217. isCube: boolean;
  58218. /**
  58219. * If the texture is a compressed format eg. FOURCC_DXT1
  58220. */
  58221. isCompressed: boolean;
  58222. /**
  58223. * The dxgiFormat of the texture
  58224. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58225. */
  58226. dxgiFormat: number;
  58227. /**
  58228. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58229. */
  58230. textureType: number;
  58231. /**
  58232. * Sphericle polynomial created for the dds texture
  58233. */
  58234. sphericalPolynomial?: SphericalPolynomial;
  58235. }
  58236. /**
  58237. * Class used to provide DDS decompression tools
  58238. */
  58239. export class DDSTools {
  58240. /**
  58241. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58242. */
  58243. static StoreLODInAlphaChannel: boolean;
  58244. /**
  58245. * Gets DDS information from an array buffer
  58246. * @param data defines the array buffer view to read data from
  58247. * @returns the DDS information
  58248. */
  58249. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58250. private static _FloatView;
  58251. private static _Int32View;
  58252. private static _ToHalfFloat;
  58253. private static _FromHalfFloat;
  58254. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58255. private static _GetHalfFloatRGBAArrayBuffer;
  58256. private static _GetFloatRGBAArrayBuffer;
  58257. private static _GetFloatAsUIntRGBAArrayBuffer;
  58258. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58259. private static _GetRGBAArrayBuffer;
  58260. private static _ExtractLongWordOrder;
  58261. private static _GetRGBArrayBuffer;
  58262. private static _GetLuminanceArrayBuffer;
  58263. /**
  58264. * Uploads DDS Levels to a Babylon Texture
  58265. * @hidden
  58266. */
  58267. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58268. }
  58269. interface ThinEngine {
  58270. /**
  58271. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58272. * @param rootUrl defines the url where the file to load is located
  58273. * @param scene defines the current scene
  58274. * @param lodScale defines scale to apply to the mip map selection
  58275. * @param lodOffset defines offset to apply to the mip map selection
  58276. * @param onLoad defines an optional callback raised when the texture is loaded
  58277. * @param onError defines an optional callback raised if there is an issue to load the texture
  58278. * @param format defines the format of the data
  58279. * @param forcedExtension defines the extension to use to pick the right loader
  58280. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58281. * @returns the cube texture as an InternalTexture
  58282. */
  58283. 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;
  58284. }
  58285. }
  58286. declare module BABYLON {
  58287. /**
  58288. * Implementation of the DDS Texture Loader.
  58289. * @hidden
  58290. */
  58291. export class _DDSTextureLoader implements IInternalTextureLoader {
  58292. /**
  58293. * Defines wether the loader supports cascade loading the different faces.
  58294. */
  58295. readonly supportCascades: boolean;
  58296. /**
  58297. * This returns if the loader support the current file information.
  58298. * @param extension defines the file extension of the file being loaded
  58299. * @returns true if the loader can load the specified file
  58300. */
  58301. canLoad(extension: string): boolean;
  58302. /**
  58303. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58304. * @param data contains the texture data
  58305. * @param texture defines the BabylonJS internal texture
  58306. * @param createPolynomials will be true if polynomials have been requested
  58307. * @param onLoad defines the callback to trigger once the texture is ready
  58308. * @param onError defines the callback to trigger in case of error
  58309. */
  58310. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58311. /**
  58312. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58313. * @param data contains the texture data
  58314. * @param texture defines the BabylonJS internal texture
  58315. * @param callback defines the method to call once ready to upload
  58316. */
  58317. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58318. }
  58319. }
  58320. declare module BABYLON {
  58321. /**
  58322. * Implementation of the ENV Texture Loader.
  58323. * @hidden
  58324. */
  58325. export class _ENVTextureLoader implements IInternalTextureLoader {
  58326. /**
  58327. * Defines wether the loader supports cascade loading the different faces.
  58328. */
  58329. readonly supportCascades: boolean;
  58330. /**
  58331. * This returns if the loader support the current file information.
  58332. * @param extension defines the file extension of the file being loaded
  58333. * @returns true if the loader can load the specified file
  58334. */
  58335. canLoad(extension: string): boolean;
  58336. /**
  58337. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58338. * @param data contains the texture data
  58339. * @param texture defines the BabylonJS internal texture
  58340. * @param createPolynomials will be true if polynomials have been requested
  58341. * @param onLoad defines the callback to trigger once the texture is ready
  58342. * @param onError defines the callback to trigger in case of error
  58343. */
  58344. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58345. /**
  58346. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58347. * @param data contains the texture data
  58348. * @param texture defines the BabylonJS internal texture
  58349. * @param callback defines the method to call once ready to upload
  58350. */
  58351. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58352. }
  58353. }
  58354. declare module BABYLON {
  58355. /**
  58356. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58357. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58358. */
  58359. export class KhronosTextureContainer {
  58360. /** contents of the KTX container file */
  58361. data: ArrayBufferView;
  58362. private static HEADER_LEN;
  58363. private static COMPRESSED_2D;
  58364. private static COMPRESSED_3D;
  58365. private static TEX_2D;
  58366. private static TEX_3D;
  58367. /**
  58368. * Gets the openGL type
  58369. */
  58370. glType: number;
  58371. /**
  58372. * Gets the openGL type size
  58373. */
  58374. glTypeSize: number;
  58375. /**
  58376. * Gets the openGL format
  58377. */
  58378. glFormat: number;
  58379. /**
  58380. * Gets the openGL internal format
  58381. */
  58382. glInternalFormat: number;
  58383. /**
  58384. * Gets the base internal format
  58385. */
  58386. glBaseInternalFormat: number;
  58387. /**
  58388. * Gets image width in pixel
  58389. */
  58390. pixelWidth: number;
  58391. /**
  58392. * Gets image height in pixel
  58393. */
  58394. pixelHeight: number;
  58395. /**
  58396. * Gets image depth in pixels
  58397. */
  58398. pixelDepth: number;
  58399. /**
  58400. * Gets the number of array elements
  58401. */
  58402. numberOfArrayElements: number;
  58403. /**
  58404. * Gets the number of faces
  58405. */
  58406. numberOfFaces: number;
  58407. /**
  58408. * Gets the number of mipmap levels
  58409. */
  58410. numberOfMipmapLevels: number;
  58411. /**
  58412. * Gets the bytes of key value data
  58413. */
  58414. bytesOfKeyValueData: number;
  58415. /**
  58416. * Gets the load type
  58417. */
  58418. loadType: number;
  58419. /**
  58420. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58421. */
  58422. isInvalid: boolean;
  58423. /**
  58424. * Creates a new KhronosTextureContainer
  58425. * @param data contents of the KTX container file
  58426. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58427. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58428. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58429. */
  58430. constructor(
  58431. /** contents of the KTX container file */
  58432. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58433. /**
  58434. * Uploads KTX content to a Babylon Texture.
  58435. * It is assumed that the texture has already been created & is currently bound
  58436. * @hidden
  58437. */
  58438. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58439. private _upload2DCompressedLevels;
  58440. /**
  58441. * Checks if the given data starts with a KTX file identifier.
  58442. * @param data the data to check
  58443. * @returns true if the data is a KTX file or false otherwise
  58444. */
  58445. static IsValid(data: ArrayBufferView): boolean;
  58446. }
  58447. }
  58448. declare module BABYLON {
  58449. /**
  58450. * Helper class to push actions to a pool of workers.
  58451. */
  58452. export class WorkerPool implements IDisposable {
  58453. private _workerInfos;
  58454. private _pendingActions;
  58455. /**
  58456. * Constructor
  58457. * @param workers Array of workers to use for actions
  58458. */
  58459. constructor(workers: Array<Worker>);
  58460. /**
  58461. * Terminates all workers and clears any pending actions.
  58462. */
  58463. dispose(): void;
  58464. /**
  58465. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58466. * pended until a worker has completed its action.
  58467. * @param action The action to perform. Call onComplete when the action is complete.
  58468. */
  58469. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58470. private _execute;
  58471. }
  58472. }
  58473. declare module BABYLON {
  58474. /**
  58475. * Class for loading KTX2 files
  58476. */
  58477. export class KhronosTextureContainer2 {
  58478. private static _WorkerPoolPromise?;
  58479. private static _Initialized;
  58480. private static _Ktx2Decoder;
  58481. /**
  58482. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58483. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58484. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58485. * Urls you can change:
  58486. * URLConfig.jsDecoderModule
  58487. * URLConfig.wasmUASTCToASTC
  58488. * URLConfig.wasmUASTCToBC7
  58489. * URLConfig.jsMSCTranscoder
  58490. * URLConfig.wasmMSCTranscoder
  58491. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58492. */
  58493. static URLConfig: {
  58494. jsDecoderModule: string;
  58495. wasmUASTCToASTC: null;
  58496. wasmUASTCToBC7: null;
  58497. jsMSCTranscoder: null;
  58498. wasmMSCTranscoder: null;
  58499. };
  58500. /**
  58501. * Default number of workers used to handle data decoding
  58502. */
  58503. static DefaultNumWorkers: number;
  58504. private static GetDefaultNumWorkers;
  58505. private _engine;
  58506. private static _CreateWorkerPool;
  58507. /**
  58508. * Constructor
  58509. * @param engine The engine to use
  58510. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58511. */
  58512. constructor(engine: ThinEngine, numWorkers?: number);
  58513. /** @hidden */
  58514. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58515. /**
  58516. * Stop all async operations and release resources.
  58517. */
  58518. dispose(): void;
  58519. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  58520. /**
  58521. * Checks if the given data starts with a KTX2 file identifier.
  58522. * @param data the data to check
  58523. * @returns true if the data is a KTX2 file or false otherwise
  58524. */
  58525. static IsValid(data: ArrayBufferView): boolean;
  58526. }
  58527. }
  58528. declare module BABYLON {
  58529. /**
  58530. * Implementation of the KTX Texture Loader.
  58531. * @hidden
  58532. */
  58533. export class _KTXTextureLoader implements IInternalTextureLoader {
  58534. /**
  58535. * Defines wether the loader supports cascade loading the different faces.
  58536. */
  58537. readonly supportCascades: boolean;
  58538. /**
  58539. * This returns if the loader support the current file information.
  58540. * @param extension defines the file extension of the file being loaded
  58541. * @param mimeType defines the optional mime type of the file being loaded
  58542. * @returns true if the loader can load the specified file
  58543. */
  58544. canLoad(extension: string, mimeType?: string): boolean;
  58545. /**
  58546. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58547. * @param data contains the texture data
  58548. * @param texture defines the BabylonJS internal texture
  58549. * @param createPolynomials will be true if polynomials have been requested
  58550. * @param onLoad defines the callback to trigger once the texture is ready
  58551. * @param onError defines the callback to trigger in case of error
  58552. */
  58553. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58554. /**
  58555. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58556. * @param data contains the texture data
  58557. * @param texture defines the BabylonJS internal texture
  58558. * @param callback defines the method to call once ready to upload
  58559. */
  58560. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58561. }
  58562. }
  58563. declare module BABYLON {
  58564. /** @hidden */
  58565. export var _forceSceneHelpersToBundle: boolean;
  58566. interface Scene {
  58567. /**
  58568. * Creates a default light for the scene.
  58569. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58570. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58571. */
  58572. createDefaultLight(replace?: boolean): void;
  58573. /**
  58574. * Creates a default camera for the scene.
  58575. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58576. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58577. * @param replace has default false, when true replaces the active camera in the scene
  58578. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58579. */
  58580. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58581. /**
  58582. * Creates a default camera and a default light.
  58583. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58584. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58585. * @param replace has the default false, when true replaces the active camera/light in the scene
  58586. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58587. */
  58588. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58589. /**
  58590. * Creates a new sky box
  58591. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58592. * @param environmentTexture defines the texture to use as environment texture
  58593. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58594. * @param scale defines the overall scale of the skybox
  58595. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58596. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58597. * @returns a new mesh holding the sky box
  58598. */
  58599. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58600. /**
  58601. * Creates a new environment
  58602. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58603. * @param options defines the options you can use to configure the environment
  58604. * @returns the new EnvironmentHelper
  58605. */
  58606. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58607. /**
  58608. * Creates a new VREXperienceHelper
  58609. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58610. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58611. * @returns a new VREXperienceHelper
  58612. */
  58613. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58614. /**
  58615. * Creates a new WebXRDefaultExperience
  58616. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58617. * @param options experience options
  58618. * @returns a promise for a new WebXRDefaultExperience
  58619. */
  58620. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58621. }
  58622. }
  58623. declare module BABYLON {
  58624. /**
  58625. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58626. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58627. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58628. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58629. */
  58630. export class VideoDome extends TextureDome<VideoTexture> {
  58631. /**
  58632. * Define the video source as a Monoscopic panoramic 360 video.
  58633. */
  58634. static readonly MODE_MONOSCOPIC: number;
  58635. /**
  58636. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58637. */
  58638. static readonly MODE_TOPBOTTOM: number;
  58639. /**
  58640. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58641. */
  58642. static readonly MODE_SIDEBYSIDE: number;
  58643. /**
  58644. * Get the video texture associated with this video dome
  58645. */
  58646. get videoTexture(): VideoTexture;
  58647. /**
  58648. * Get the video mode of this dome
  58649. */
  58650. get videoMode(): number;
  58651. /**
  58652. * Set the video mode of this dome.
  58653. * @see textureMode
  58654. */
  58655. set videoMode(value: number);
  58656. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58657. }
  58658. }
  58659. declare module BABYLON {
  58660. /**
  58661. * This class can be used to get instrumentation data from a Babylon engine
  58662. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58663. */
  58664. export class EngineInstrumentation implements IDisposable {
  58665. /**
  58666. * Define the instrumented engine.
  58667. */
  58668. engine: Engine;
  58669. private _captureGPUFrameTime;
  58670. private _gpuFrameTimeToken;
  58671. private _gpuFrameTime;
  58672. private _captureShaderCompilationTime;
  58673. private _shaderCompilationTime;
  58674. private _onBeginFrameObserver;
  58675. private _onEndFrameObserver;
  58676. private _onBeforeShaderCompilationObserver;
  58677. private _onAfterShaderCompilationObserver;
  58678. /**
  58679. * Gets the perf counter used for GPU frame time
  58680. */
  58681. get gpuFrameTimeCounter(): PerfCounter;
  58682. /**
  58683. * Gets the GPU frame time capture status
  58684. */
  58685. get captureGPUFrameTime(): boolean;
  58686. /**
  58687. * Enable or disable the GPU frame time capture
  58688. */
  58689. set captureGPUFrameTime(value: boolean);
  58690. /**
  58691. * Gets the perf counter used for shader compilation time
  58692. */
  58693. get shaderCompilationTimeCounter(): PerfCounter;
  58694. /**
  58695. * Gets the shader compilation time capture status
  58696. */
  58697. get captureShaderCompilationTime(): boolean;
  58698. /**
  58699. * Enable or disable the shader compilation time capture
  58700. */
  58701. set captureShaderCompilationTime(value: boolean);
  58702. /**
  58703. * Instantiates a new engine instrumentation.
  58704. * This class can be used to get instrumentation data from a Babylon engine
  58705. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58706. * @param engine Defines the engine to instrument
  58707. */
  58708. constructor(
  58709. /**
  58710. * Define the instrumented engine.
  58711. */
  58712. engine: Engine);
  58713. /**
  58714. * Dispose and release associated resources.
  58715. */
  58716. dispose(): void;
  58717. }
  58718. }
  58719. declare module BABYLON {
  58720. /**
  58721. * This class can be used to get instrumentation data from a Babylon engine
  58722. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58723. */
  58724. export class SceneInstrumentation implements IDisposable {
  58725. /**
  58726. * Defines the scene to instrument
  58727. */
  58728. scene: Scene;
  58729. private _captureActiveMeshesEvaluationTime;
  58730. private _activeMeshesEvaluationTime;
  58731. private _captureRenderTargetsRenderTime;
  58732. private _renderTargetsRenderTime;
  58733. private _captureFrameTime;
  58734. private _frameTime;
  58735. private _captureRenderTime;
  58736. private _renderTime;
  58737. private _captureInterFrameTime;
  58738. private _interFrameTime;
  58739. private _captureParticlesRenderTime;
  58740. private _particlesRenderTime;
  58741. private _captureSpritesRenderTime;
  58742. private _spritesRenderTime;
  58743. private _capturePhysicsTime;
  58744. private _physicsTime;
  58745. private _captureAnimationsTime;
  58746. private _animationsTime;
  58747. private _captureCameraRenderTime;
  58748. private _cameraRenderTime;
  58749. private _onBeforeActiveMeshesEvaluationObserver;
  58750. private _onAfterActiveMeshesEvaluationObserver;
  58751. private _onBeforeRenderTargetsRenderObserver;
  58752. private _onAfterRenderTargetsRenderObserver;
  58753. private _onAfterRenderObserver;
  58754. private _onBeforeDrawPhaseObserver;
  58755. private _onAfterDrawPhaseObserver;
  58756. private _onBeforeAnimationsObserver;
  58757. private _onBeforeParticlesRenderingObserver;
  58758. private _onAfterParticlesRenderingObserver;
  58759. private _onBeforeSpritesRenderingObserver;
  58760. private _onAfterSpritesRenderingObserver;
  58761. private _onBeforePhysicsObserver;
  58762. private _onAfterPhysicsObserver;
  58763. private _onAfterAnimationsObserver;
  58764. private _onBeforeCameraRenderObserver;
  58765. private _onAfterCameraRenderObserver;
  58766. /**
  58767. * Gets the perf counter used for active meshes evaluation time
  58768. */
  58769. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58770. /**
  58771. * Gets the active meshes evaluation time capture status
  58772. */
  58773. get captureActiveMeshesEvaluationTime(): boolean;
  58774. /**
  58775. * Enable or disable the active meshes evaluation time capture
  58776. */
  58777. set captureActiveMeshesEvaluationTime(value: boolean);
  58778. /**
  58779. * Gets the perf counter used for render targets render time
  58780. */
  58781. get renderTargetsRenderTimeCounter(): PerfCounter;
  58782. /**
  58783. * Gets the render targets render time capture status
  58784. */
  58785. get captureRenderTargetsRenderTime(): boolean;
  58786. /**
  58787. * Enable or disable the render targets render time capture
  58788. */
  58789. set captureRenderTargetsRenderTime(value: boolean);
  58790. /**
  58791. * Gets the perf counter used for particles render time
  58792. */
  58793. get particlesRenderTimeCounter(): PerfCounter;
  58794. /**
  58795. * Gets the particles render time capture status
  58796. */
  58797. get captureParticlesRenderTime(): boolean;
  58798. /**
  58799. * Enable or disable the particles render time capture
  58800. */
  58801. set captureParticlesRenderTime(value: boolean);
  58802. /**
  58803. * Gets the perf counter used for sprites render time
  58804. */
  58805. get spritesRenderTimeCounter(): PerfCounter;
  58806. /**
  58807. * Gets the sprites render time capture status
  58808. */
  58809. get captureSpritesRenderTime(): boolean;
  58810. /**
  58811. * Enable or disable the sprites render time capture
  58812. */
  58813. set captureSpritesRenderTime(value: boolean);
  58814. /**
  58815. * Gets the perf counter used for physics time
  58816. */
  58817. get physicsTimeCounter(): PerfCounter;
  58818. /**
  58819. * Gets the physics time capture status
  58820. */
  58821. get capturePhysicsTime(): boolean;
  58822. /**
  58823. * Enable or disable the physics time capture
  58824. */
  58825. set capturePhysicsTime(value: boolean);
  58826. /**
  58827. * Gets the perf counter used for animations time
  58828. */
  58829. get animationsTimeCounter(): PerfCounter;
  58830. /**
  58831. * Gets the animations time capture status
  58832. */
  58833. get captureAnimationsTime(): boolean;
  58834. /**
  58835. * Enable or disable the animations time capture
  58836. */
  58837. set captureAnimationsTime(value: boolean);
  58838. /**
  58839. * Gets the perf counter used for frame time capture
  58840. */
  58841. get frameTimeCounter(): PerfCounter;
  58842. /**
  58843. * Gets the frame time capture status
  58844. */
  58845. get captureFrameTime(): boolean;
  58846. /**
  58847. * Enable or disable the frame time capture
  58848. */
  58849. set captureFrameTime(value: boolean);
  58850. /**
  58851. * Gets the perf counter used for inter-frames time capture
  58852. */
  58853. get interFrameTimeCounter(): PerfCounter;
  58854. /**
  58855. * Gets the inter-frames time capture status
  58856. */
  58857. get captureInterFrameTime(): boolean;
  58858. /**
  58859. * Enable or disable the inter-frames time capture
  58860. */
  58861. set captureInterFrameTime(value: boolean);
  58862. /**
  58863. * Gets the perf counter used for render time capture
  58864. */
  58865. get renderTimeCounter(): PerfCounter;
  58866. /**
  58867. * Gets the render time capture status
  58868. */
  58869. get captureRenderTime(): boolean;
  58870. /**
  58871. * Enable or disable the render time capture
  58872. */
  58873. set captureRenderTime(value: boolean);
  58874. /**
  58875. * Gets the perf counter used for camera render time capture
  58876. */
  58877. get cameraRenderTimeCounter(): PerfCounter;
  58878. /**
  58879. * Gets the camera render time capture status
  58880. */
  58881. get captureCameraRenderTime(): boolean;
  58882. /**
  58883. * Enable or disable the camera render time capture
  58884. */
  58885. set captureCameraRenderTime(value: boolean);
  58886. /**
  58887. * Gets the perf counter used for draw calls
  58888. */
  58889. get drawCallsCounter(): PerfCounter;
  58890. /**
  58891. * Instantiates a new scene instrumentation.
  58892. * This class can be used to get instrumentation data from a Babylon engine
  58893. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58894. * @param scene Defines the scene to instrument
  58895. */
  58896. constructor(
  58897. /**
  58898. * Defines the scene to instrument
  58899. */
  58900. scene: Scene);
  58901. /**
  58902. * Dispose and release associated resources.
  58903. */
  58904. dispose(): void;
  58905. }
  58906. }
  58907. declare module BABYLON {
  58908. /** @hidden */
  58909. export var glowMapGenerationPixelShader: {
  58910. name: string;
  58911. shader: string;
  58912. };
  58913. }
  58914. declare module BABYLON {
  58915. /** @hidden */
  58916. export var glowMapGenerationVertexShader: {
  58917. name: string;
  58918. shader: string;
  58919. };
  58920. }
  58921. declare module BABYLON {
  58922. /**
  58923. * Effect layer options. This helps customizing the behaviour
  58924. * of the effect layer.
  58925. */
  58926. export interface IEffectLayerOptions {
  58927. /**
  58928. * Multiplication factor apply to the canvas size to compute the render target size
  58929. * used to generated the objects (the smaller the faster).
  58930. */
  58931. mainTextureRatio: number;
  58932. /**
  58933. * Enforces a fixed size texture to ensure effect stability across devices.
  58934. */
  58935. mainTextureFixedSize?: number;
  58936. /**
  58937. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58938. */
  58939. alphaBlendingMode: number;
  58940. /**
  58941. * The camera attached to the layer.
  58942. */
  58943. camera: Nullable<Camera>;
  58944. /**
  58945. * The rendering group to draw the layer in.
  58946. */
  58947. renderingGroupId: number;
  58948. }
  58949. /**
  58950. * The effect layer Helps adding post process effect blended with the main pass.
  58951. *
  58952. * This can be for instance use to generate glow or higlight effects on the scene.
  58953. *
  58954. * The effect layer class can not be used directly and is intented to inherited from to be
  58955. * customized per effects.
  58956. */
  58957. export abstract class EffectLayer {
  58958. private _vertexBuffers;
  58959. private _indexBuffer;
  58960. private _cachedDefines;
  58961. private _effectLayerMapGenerationEffect;
  58962. private _effectLayerOptions;
  58963. private _mergeEffect;
  58964. protected _scene: Scene;
  58965. protected _engine: Engine;
  58966. protected _maxSize: number;
  58967. protected _mainTextureDesiredSize: ISize;
  58968. protected _mainTexture: RenderTargetTexture;
  58969. protected _shouldRender: boolean;
  58970. protected _postProcesses: PostProcess[];
  58971. protected _textures: BaseTexture[];
  58972. protected _emissiveTextureAndColor: {
  58973. texture: Nullable<BaseTexture>;
  58974. color: Color4;
  58975. };
  58976. /**
  58977. * The name of the layer
  58978. */
  58979. name: string;
  58980. /**
  58981. * The clear color of the texture used to generate the glow map.
  58982. */
  58983. neutralColor: Color4;
  58984. /**
  58985. * Specifies whether the highlight layer is enabled or not.
  58986. */
  58987. isEnabled: boolean;
  58988. /**
  58989. * Gets the camera attached to the layer.
  58990. */
  58991. get camera(): Nullable<Camera>;
  58992. /**
  58993. * Gets the rendering group id the layer should render in.
  58994. */
  58995. get renderingGroupId(): number;
  58996. set renderingGroupId(renderingGroupId: number);
  58997. /**
  58998. * An event triggered when the effect layer has been disposed.
  58999. */
  59000. onDisposeObservable: Observable<EffectLayer>;
  59001. /**
  59002. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59003. */
  59004. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59005. /**
  59006. * An event triggered when the generated texture is being merged in the scene.
  59007. */
  59008. onBeforeComposeObservable: Observable<EffectLayer>;
  59009. /**
  59010. * An event triggered when the mesh is rendered into the effect render target.
  59011. */
  59012. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59013. /**
  59014. * An event triggered after the mesh has been rendered into the effect render target.
  59015. */
  59016. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59017. /**
  59018. * An event triggered when the generated texture has been merged in the scene.
  59019. */
  59020. onAfterComposeObservable: Observable<EffectLayer>;
  59021. /**
  59022. * An event triggered when the efffect layer changes its size.
  59023. */
  59024. onSizeChangedObservable: Observable<EffectLayer>;
  59025. /** @hidden */
  59026. static _SceneComponentInitialization: (scene: Scene) => void;
  59027. /**
  59028. * Instantiates a new effect Layer and references it in the scene.
  59029. * @param name The name of the layer
  59030. * @param scene The scene to use the layer in
  59031. */
  59032. constructor(
  59033. /** The Friendly of the effect in the scene */
  59034. name: string, scene: Scene);
  59035. /**
  59036. * Get the effect name of the layer.
  59037. * @return The effect name
  59038. */
  59039. abstract getEffectName(): string;
  59040. /**
  59041. * Checks for the readiness of the element composing the layer.
  59042. * @param subMesh the mesh to check for
  59043. * @param useInstances specify whether or not to use instances to render the mesh
  59044. * @return true if ready otherwise, false
  59045. */
  59046. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59047. /**
  59048. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59049. * @returns true if the effect requires stencil during the main canvas render pass.
  59050. */
  59051. abstract needStencil(): boolean;
  59052. /**
  59053. * Create the merge effect. This is the shader use to blit the information back
  59054. * to the main canvas at the end of the scene rendering.
  59055. * @returns The effect containing the shader used to merge the effect on the main canvas
  59056. */
  59057. protected abstract _createMergeEffect(): Effect;
  59058. /**
  59059. * Creates the render target textures and post processes used in the effect layer.
  59060. */
  59061. protected abstract _createTextureAndPostProcesses(): void;
  59062. /**
  59063. * Implementation specific of rendering the generating effect on the main canvas.
  59064. * @param effect The effect used to render through
  59065. */
  59066. protected abstract _internalRender(effect: Effect): void;
  59067. /**
  59068. * Sets the required values for both the emissive texture and and the main color.
  59069. */
  59070. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59071. /**
  59072. * Free any resources and references associated to a mesh.
  59073. * Internal use
  59074. * @param mesh The mesh to free.
  59075. */
  59076. abstract _disposeMesh(mesh: Mesh): void;
  59077. /**
  59078. * Serializes this layer (Glow or Highlight for example)
  59079. * @returns a serialized layer object
  59080. */
  59081. abstract serialize?(): any;
  59082. /**
  59083. * Initializes the effect layer with the required options.
  59084. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59085. */
  59086. protected _init(options: Partial<IEffectLayerOptions>): void;
  59087. /**
  59088. * Generates the index buffer of the full screen quad blending to the main canvas.
  59089. */
  59090. private _generateIndexBuffer;
  59091. /**
  59092. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59093. */
  59094. private _generateVertexBuffer;
  59095. /**
  59096. * Sets the main texture desired size which is the closest power of two
  59097. * of the engine canvas size.
  59098. */
  59099. private _setMainTextureSize;
  59100. /**
  59101. * Creates the main texture for the effect layer.
  59102. */
  59103. protected _createMainTexture(): void;
  59104. /**
  59105. * Adds specific effects defines.
  59106. * @param defines The defines to add specifics to.
  59107. */
  59108. protected _addCustomEffectDefines(defines: string[]): void;
  59109. /**
  59110. * Checks for the readiness of the element composing the layer.
  59111. * @param subMesh the mesh to check for
  59112. * @param useInstances specify whether or not to use instances to render the mesh
  59113. * @param emissiveTexture the associated emissive texture used to generate the glow
  59114. * @return true if ready otherwise, false
  59115. */
  59116. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59117. /**
  59118. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59119. */
  59120. render(): void;
  59121. /**
  59122. * Determine if a given mesh will be used in the current effect.
  59123. * @param mesh mesh to test
  59124. * @returns true if the mesh will be used
  59125. */
  59126. hasMesh(mesh: AbstractMesh): boolean;
  59127. /**
  59128. * Returns true if the layer contains information to display, otherwise false.
  59129. * @returns true if the glow layer should be rendered
  59130. */
  59131. shouldRender(): boolean;
  59132. /**
  59133. * Returns true if the mesh should render, otherwise false.
  59134. * @param mesh The mesh to render
  59135. * @returns true if it should render otherwise false
  59136. */
  59137. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59138. /**
  59139. * Returns true if the mesh can be rendered, otherwise false.
  59140. * @param mesh The mesh to render
  59141. * @param material The material used on the mesh
  59142. * @returns true if it can be rendered otherwise false
  59143. */
  59144. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59145. /**
  59146. * Returns true if the mesh should render, otherwise false.
  59147. * @param mesh The mesh to render
  59148. * @returns true if it should render otherwise false
  59149. */
  59150. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59151. /**
  59152. * Renders the submesh passed in parameter to the generation map.
  59153. */
  59154. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59155. /**
  59156. * Defines whether the current material of the mesh should be use to render the effect.
  59157. * @param mesh defines the current mesh to render
  59158. */
  59159. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59160. /**
  59161. * Rebuild the required buffers.
  59162. * @hidden Internal use only.
  59163. */
  59164. _rebuild(): void;
  59165. /**
  59166. * Dispose only the render target textures and post process.
  59167. */
  59168. private _disposeTextureAndPostProcesses;
  59169. /**
  59170. * Dispose the highlight layer and free resources.
  59171. */
  59172. dispose(): void;
  59173. /**
  59174. * Gets the class name of the effect layer
  59175. * @returns the string with the class name of the effect layer
  59176. */
  59177. getClassName(): string;
  59178. /**
  59179. * Creates an effect layer from parsed effect layer data
  59180. * @param parsedEffectLayer defines effect layer data
  59181. * @param scene defines the current scene
  59182. * @param rootUrl defines the root URL containing the effect layer information
  59183. * @returns a parsed effect Layer
  59184. */
  59185. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59186. }
  59187. }
  59188. declare module BABYLON {
  59189. interface AbstractScene {
  59190. /**
  59191. * The list of effect layers (highlights/glow) added to the scene
  59192. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59193. * @see https://doc.babylonjs.com/how_to/glow_layer
  59194. */
  59195. effectLayers: Array<EffectLayer>;
  59196. /**
  59197. * Removes the given effect layer from this scene.
  59198. * @param toRemove defines the effect layer to remove
  59199. * @returns the index of the removed effect layer
  59200. */
  59201. removeEffectLayer(toRemove: EffectLayer): number;
  59202. /**
  59203. * Adds the given effect layer to this scene
  59204. * @param newEffectLayer defines the effect layer to add
  59205. */
  59206. addEffectLayer(newEffectLayer: EffectLayer): void;
  59207. }
  59208. /**
  59209. * Defines the layer scene component responsible to manage any effect layers
  59210. * in a given scene.
  59211. */
  59212. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59213. /**
  59214. * The component name helpfull to identify the component in the list of scene components.
  59215. */
  59216. readonly name: string;
  59217. /**
  59218. * The scene the component belongs to.
  59219. */
  59220. scene: Scene;
  59221. private _engine;
  59222. private _renderEffects;
  59223. private _needStencil;
  59224. private _previousStencilState;
  59225. /**
  59226. * Creates a new instance of the component for the given scene
  59227. * @param scene Defines the scene to register the component in
  59228. */
  59229. constructor(scene: Scene);
  59230. /**
  59231. * Registers the component in a given scene
  59232. */
  59233. register(): void;
  59234. /**
  59235. * Rebuilds the elements related to this component in case of
  59236. * context lost for instance.
  59237. */
  59238. rebuild(): void;
  59239. /**
  59240. * Serializes the component data to the specified json object
  59241. * @param serializationObject The object to serialize to
  59242. */
  59243. serialize(serializationObject: any): void;
  59244. /**
  59245. * Adds all the elements from the container to the scene
  59246. * @param container the container holding the elements
  59247. */
  59248. addFromContainer(container: AbstractScene): void;
  59249. /**
  59250. * Removes all the elements in the container from the scene
  59251. * @param container contains the elements to remove
  59252. * @param dispose if the removed element should be disposed (default: false)
  59253. */
  59254. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59255. /**
  59256. * Disposes the component and the associated ressources.
  59257. */
  59258. dispose(): void;
  59259. private _isReadyForMesh;
  59260. private _renderMainTexture;
  59261. private _setStencil;
  59262. private _setStencilBack;
  59263. private _draw;
  59264. private _drawCamera;
  59265. private _drawRenderingGroup;
  59266. }
  59267. }
  59268. declare module BABYLON {
  59269. /** @hidden */
  59270. export var glowMapMergePixelShader: {
  59271. name: string;
  59272. shader: string;
  59273. };
  59274. }
  59275. declare module BABYLON {
  59276. /** @hidden */
  59277. export var glowMapMergeVertexShader: {
  59278. name: string;
  59279. shader: string;
  59280. };
  59281. }
  59282. declare module BABYLON {
  59283. interface AbstractScene {
  59284. /**
  59285. * Return a the first highlight layer of the scene with a given name.
  59286. * @param name The name of the highlight layer to look for.
  59287. * @return The highlight layer if found otherwise null.
  59288. */
  59289. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59290. }
  59291. /**
  59292. * Glow layer options. This helps customizing the behaviour
  59293. * of the glow layer.
  59294. */
  59295. export interface IGlowLayerOptions {
  59296. /**
  59297. * Multiplication factor apply to the canvas size to compute the render target size
  59298. * used to generated the glowing objects (the smaller the faster).
  59299. */
  59300. mainTextureRatio: number;
  59301. /**
  59302. * Enforces a fixed size texture to ensure resize independant blur.
  59303. */
  59304. mainTextureFixedSize?: number;
  59305. /**
  59306. * How big is the kernel of the blur texture.
  59307. */
  59308. blurKernelSize: number;
  59309. /**
  59310. * The camera attached to the layer.
  59311. */
  59312. camera: Nullable<Camera>;
  59313. /**
  59314. * Enable MSAA by chosing the number of samples.
  59315. */
  59316. mainTextureSamples?: number;
  59317. /**
  59318. * The rendering group to draw the layer in.
  59319. */
  59320. renderingGroupId: number;
  59321. }
  59322. /**
  59323. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59324. *
  59325. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59326. *
  59327. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59328. */
  59329. export class GlowLayer extends EffectLayer {
  59330. /**
  59331. * Effect Name of the layer.
  59332. */
  59333. static readonly EffectName: string;
  59334. /**
  59335. * The default blur kernel size used for the glow.
  59336. */
  59337. static DefaultBlurKernelSize: number;
  59338. /**
  59339. * The default texture size ratio used for the glow.
  59340. */
  59341. static DefaultTextureRatio: number;
  59342. /**
  59343. * Sets the kernel size of the blur.
  59344. */
  59345. set blurKernelSize(value: number);
  59346. /**
  59347. * Gets the kernel size of the blur.
  59348. */
  59349. get blurKernelSize(): number;
  59350. /**
  59351. * Sets the glow intensity.
  59352. */
  59353. set intensity(value: number);
  59354. /**
  59355. * Gets the glow intensity.
  59356. */
  59357. get intensity(): number;
  59358. private _options;
  59359. private _intensity;
  59360. private _horizontalBlurPostprocess1;
  59361. private _verticalBlurPostprocess1;
  59362. private _horizontalBlurPostprocess2;
  59363. private _verticalBlurPostprocess2;
  59364. private _blurTexture1;
  59365. private _blurTexture2;
  59366. private _postProcesses1;
  59367. private _postProcesses2;
  59368. private _includedOnlyMeshes;
  59369. private _excludedMeshes;
  59370. private _meshesUsingTheirOwnMaterials;
  59371. /**
  59372. * Callback used to let the user override the color selection on a per mesh basis
  59373. */
  59374. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59375. /**
  59376. * Callback used to let the user override the texture selection on a per mesh basis
  59377. */
  59378. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59379. /**
  59380. * Instantiates a new glow Layer and references it to the scene.
  59381. * @param name The name of the layer
  59382. * @param scene The scene to use the layer in
  59383. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59384. */
  59385. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59386. /**
  59387. * Get the effect name of the layer.
  59388. * @return The effect name
  59389. */
  59390. getEffectName(): string;
  59391. /**
  59392. * Create the merge effect. This is the shader use to blit the information back
  59393. * to the main canvas at the end of the scene rendering.
  59394. */
  59395. protected _createMergeEffect(): Effect;
  59396. /**
  59397. * Creates the render target textures and post processes used in the glow layer.
  59398. */
  59399. protected _createTextureAndPostProcesses(): void;
  59400. /**
  59401. * Checks for the readiness of the element composing the layer.
  59402. * @param subMesh the mesh to check for
  59403. * @param useInstances specify wether or not to use instances to render the mesh
  59404. * @param emissiveTexture the associated emissive texture used to generate the glow
  59405. * @return true if ready otherwise, false
  59406. */
  59407. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59408. /**
  59409. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59410. */
  59411. needStencil(): boolean;
  59412. /**
  59413. * Returns true if the mesh can be rendered, otherwise false.
  59414. * @param mesh The mesh to render
  59415. * @param material The material used on the mesh
  59416. * @returns true if it can be rendered otherwise false
  59417. */
  59418. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59419. /**
  59420. * Implementation specific of rendering the generating effect on the main canvas.
  59421. * @param effect The effect used to render through
  59422. */
  59423. protected _internalRender(effect: Effect): void;
  59424. /**
  59425. * Sets the required values for both the emissive texture and and the main color.
  59426. */
  59427. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59428. /**
  59429. * Returns true if the mesh should render, otherwise false.
  59430. * @param mesh The mesh to render
  59431. * @returns true if it should render otherwise false
  59432. */
  59433. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59434. /**
  59435. * Adds specific effects defines.
  59436. * @param defines The defines to add specifics to.
  59437. */
  59438. protected _addCustomEffectDefines(defines: string[]): void;
  59439. /**
  59440. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59441. * @param mesh The mesh to exclude from the glow layer
  59442. */
  59443. addExcludedMesh(mesh: Mesh): void;
  59444. /**
  59445. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59446. * @param mesh The mesh to remove
  59447. */
  59448. removeExcludedMesh(mesh: Mesh): void;
  59449. /**
  59450. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59451. * @param mesh The mesh to include in the glow layer
  59452. */
  59453. addIncludedOnlyMesh(mesh: Mesh): void;
  59454. /**
  59455. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59456. * @param mesh The mesh to remove
  59457. */
  59458. removeIncludedOnlyMesh(mesh: Mesh): void;
  59459. /**
  59460. * Determine if a given mesh will be used in the glow layer
  59461. * @param mesh The mesh to test
  59462. * @returns true if the mesh will be highlighted by the current glow layer
  59463. */
  59464. hasMesh(mesh: AbstractMesh): boolean;
  59465. /**
  59466. * Defines whether the current material of the mesh should be use to render the effect.
  59467. * @param mesh defines the current mesh to render
  59468. */
  59469. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59470. /**
  59471. * Add a mesh to be rendered through its own material and not with emissive only.
  59472. * @param mesh The mesh for which we need to use its material
  59473. */
  59474. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59475. /**
  59476. * Remove a mesh from being rendered through its own material and not with emissive only.
  59477. * @param mesh The mesh for which we need to not use its material
  59478. */
  59479. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59480. /**
  59481. * Free any resources and references associated to a mesh.
  59482. * Internal use
  59483. * @param mesh The mesh to free.
  59484. * @hidden
  59485. */
  59486. _disposeMesh(mesh: Mesh): void;
  59487. /**
  59488. * Gets the class name of the effect layer
  59489. * @returns the string with the class name of the effect layer
  59490. */
  59491. getClassName(): string;
  59492. /**
  59493. * Serializes this glow layer
  59494. * @returns a serialized glow layer object
  59495. */
  59496. serialize(): any;
  59497. /**
  59498. * Creates a Glow Layer from parsed glow layer data
  59499. * @param parsedGlowLayer defines glow layer data
  59500. * @param scene defines the current scene
  59501. * @param rootUrl defines the root URL containing the glow layer information
  59502. * @returns a parsed Glow Layer
  59503. */
  59504. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59505. }
  59506. }
  59507. declare module BABYLON {
  59508. /** @hidden */
  59509. export var glowBlurPostProcessPixelShader: {
  59510. name: string;
  59511. shader: string;
  59512. };
  59513. }
  59514. declare module BABYLON {
  59515. interface AbstractScene {
  59516. /**
  59517. * Return a the first highlight layer of the scene with a given name.
  59518. * @param name The name of the highlight layer to look for.
  59519. * @return The highlight layer if found otherwise null.
  59520. */
  59521. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59522. }
  59523. /**
  59524. * Highlight layer options. This helps customizing the behaviour
  59525. * of the highlight layer.
  59526. */
  59527. export interface IHighlightLayerOptions {
  59528. /**
  59529. * Multiplication factor apply to the canvas size to compute the render target size
  59530. * used to generated the glowing objects (the smaller the faster).
  59531. */
  59532. mainTextureRatio: number;
  59533. /**
  59534. * Enforces a fixed size texture to ensure resize independant blur.
  59535. */
  59536. mainTextureFixedSize?: number;
  59537. /**
  59538. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59539. * of the picture to blur (the smaller the faster).
  59540. */
  59541. blurTextureSizeRatio: number;
  59542. /**
  59543. * How big in texel of the blur texture is the vertical blur.
  59544. */
  59545. blurVerticalSize: number;
  59546. /**
  59547. * How big in texel of the blur texture is the horizontal blur.
  59548. */
  59549. blurHorizontalSize: number;
  59550. /**
  59551. * Alpha blending mode used to apply the blur. Default is combine.
  59552. */
  59553. alphaBlendingMode: number;
  59554. /**
  59555. * The camera attached to the layer.
  59556. */
  59557. camera: Nullable<Camera>;
  59558. /**
  59559. * Should we display highlight as a solid stroke?
  59560. */
  59561. isStroke?: boolean;
  59562. /**
  59563. * The rendering group to draw the layer in.
  59564. */
  59565. renderingGroupId: number;
  59566. }
  59567. /**
  59568. * The highlight layer Helps adding a glow effect around a mesh.
  59569. *
  59570. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59571. * glowy meshes to your scene.
  59572. *
  59573. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59574. */
  59575. export class HighlightLayer extends EffectLayer {
  59576. name: string;
  59577. /**
  59578. * Effect Name of the highlight layer.
  59579. */
  59580. static readonly EffectName: string;
  59581. /**
  59582. * The neutral color used during the preparation of the glow effect.
  59583. * This is black by default as the blend operation is a blend operation.
  59584. */
  59585. static NeutralColor: Color4;
  59586. /**
  59587. * Stencil value used for glowing meshes.
  59588. */
  59589. static GlowingMeshStencilReference: number;
  59590. /**
  59591. * Stencil value used for the other meshes in the scene.
  59592. */
  59593. static NormalMeshStencilReference: number;
  59594. /**
  59595. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59596. */
  59597. innerGlow: boolean;
  59598. /**
  59599. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59600. */
  59601. outerGlow: boolean;
  59602. /**
  59603. * Specifies the horizontal size of the blur.
  59604. */
  59605. set blurHorizontalSize(value: number);
  59606. /**
  59607. * Specifies the vertical size of the blur.
  59608. */
  59609. set blurVerticalSize(value: number);
  59610. /**
  59611. * Gets the horizontal size of the blur.
  59612. */
  59613. get blurHorizontalSize(): number;
  59614. /**
  59615. * Gets the vertical size of the blur.
  59616. */
  59617. get blurVerticalSize(): number;
  59618. /**
  59619. * An event triggered when the highlight layer is being blurred.
  59620. */
  59621. onBeforeBlurObservable: Observable<HighlightLayer>;
  59622. /**
  59623. * An event triggered when the highlight layer has been blurred.
  59624. */
  59625. onAfterBlurObservable: Observable<HighlightLayer>;
  59626. private _instanceGlowingMeshStencilReference;
  59627. private _options;
  59628. private _downSamplePostprocess;
  59629. private _horizontalBlurPostprocess;
  59630. private _verticalBlurPostprocess;
  59631. private _blurTexture;
  59632. private _meshes;
  59633. private _excludedMeshes;
  59634. /**
  59635. * Instantiates a new highlight Layer and references it to the scene..
  59636. * @param name The name of the layer
  59637. * @param scene The scene to use the layer in
  59638. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59639. */
  59640. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59641. /**
  59642. * Get the effect name of the layer.
  59643. * @return The effect name
  59644. */
  59645. getEffectName(): string;
  59646. /**
  59647. * Create the merge effect. This is the shader use to blit the information back
  59648. * to the main canvas at the end of the scene rendering.
  59649. */
  59650. protected _createMergeEffect(): Effect;
  59651. /**
  59652. * Creates the render target textures and post processes used in the highlight layer.
  59653. */
  59654. protected _createTextureAndPostProcesses(): void;
  59655. /**
  59656. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59657. */
  59658. needStencil(): boolean;
  59659. /**
  59660. * Checks for the readiness of the element composing the layer.
  59661. * @param subMesh the mesh to check for
  59662. * @param useInstances specify wether or not to use instances to render the mesh
  59663. * @param emissiveTexture the associated emissive texture used to generate the glow
  59664. * @return true if ready otherwise, false
  59665. */
  59666. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59667. /**
  59668. * Implementation specific of rendering the generating effect on the main canvas.
  59669. * @param effect The effect used to render through
  59670. */
  59671. protected _internalRender(effect: Effect): void;
  59672. /**
  59673. * Returns true if the layer contains information to display, otherwise false.
  59674. */
  59675. shouldRender(): boolean;
  59676. /**
  59677. * Returns true if the mesh should render, otherwise false.
  59678. * @param mesh The mesh to render
  59679. * @returns true if it should render otherwise false
  59680. */
  59681. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59682. /**
  59683. * Returns true if the mesh can be rendered, otherwise false.
  59684. * @param mesh The mesh to render
  59685. * @param material The material used on the mesh
  59686. * @returns true if it can be rendered otherwise false
  59687. */
  59688. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59689. /**
  59690. * Adds specific effects defines.
  59691. * @param defines The defines to add specifics to.
  59692. */
  59693. protected _addCustomEffectDefines(defines: string[]): void;
  59694. /**
  59695. * Sets the required values for both the emissive texture and and the main color.
  59696. */
  59697. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59698. /**
  59699. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59700. * @param mesh The mesh to exclude from the highlight layer
  59701. */
  59702. addExcludedMesh(mesh: Mesh): void;
  59703. /**
  59704. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59705. * @param mesh The mesh to highlight
  59706. */
  59707. removeExcludedMesh(mesh: Mesh): void;
  59708. /**
  59709. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59710. * @param mesh mesh to test
  59711. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59712. */
  59713. hasMesh(mesh: AbstractMesh): boolean;
  59714. /**
  59715. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59716. * @param mesh The mesh to highlight
  59717. * @param color The color of the highlight
  59718. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59719. */
  59720. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59721. /**
  59722. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59723. * @param mesh The mesh to highlight
  59724. */
  59725. removeMesh(mesh: Mesh): void;
  59726. /**
  59727. * Remove all the meshes currently referenced in the highlight layer
  59728. */
  59729. removeAllMeshes(): void;
  59730. /**
  59731. * Force the stencil to the normal expected value for none glowing parts
  59732. */
  59733. private _defaultStencilReference;
  59734. /**
  59735. * Free any resources and references associated to a mesh.
  59736. * Internal use
  59737. * @param mesh The mesh to free.
  59738. * @hidden
  59739. */
  59740. _disposeMesh(mesh: Mesh): void;
  59741. /**
  59742. * Dispose the highlight layer and free resources.
  59743. */
  59744. dispose(): void;
  59745. /**
  59746. * Gets the class name of the effect layer
  59747. * @returns the string with the class name of the effect layer
  59748. */
  59749. getClassName(): string;
  59750. /**
  59751. * Serializes this Highlight layer
  59752. * @returns a serialized Highlight layer object
  59753. */
  59754. serialize(): any;
  59755. /**
  59756. * Creates a Highlight layer from parsed Highlight layer data
  59757. * @param parsedHightlightLayer defines the Highlight layer data
  59758. * @param scene defines the current scene
  59759. * @param rootUrl defines the root URL containing the Highlight layer information
  59760. * @returns a parsed Highlight layer
  59761. */
  59762. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59763. }
  59764. }
  59765. declare module BABYLON {
  59766. interface AbstractScene {
  59767. /**
  59768. * The list of layers (background and foreground) of the scene
  59769. */
  59770. layers: Array<Layer>;
  59771. }
  59772. /**
  59773. * Defines the layer scene component responsible to manage any layers
  59774. * in a given scene.
  59775. */
  59776. export class LayerSceneComponent implements ISceneComponent {
  59777. /**
  59778. * The component name helpfull to identify the component in the list of scene components.
  59779. */
  59780. readonly name: string;
  59781. /**
  59782. * The scene the component belongs to.
  59783. */
  59784. scene: Scene;
  59785. private _engine;
  59786. /**
  59787. * Creates a new instance of the component for the given scene
  59788. * @param scene Defines the scene to register the component in
  59789. */
  59790. constructor(scene: Scene);
  59791. /**
  59792. * Registers the component in a given scene
  59793. */
  59794. register(): void;
  59795. /**
  59796. * Rebuilds the elements related to this component in case of
  59797. * context lost for instance.
  59798. */
  59799. rebuild(): void;
  59800. /**
  59801. * Disposes the component and the associated ressources.
  59802. */
  59803. dispose(): void;
  59804. private _draw;
  59805. private _drawCameraPredicate;
  59806. private _drawCameraBackground;
  59807. private _drawCameraForeground;
  59808. private _drawRenderTargetPredicate;
  59809. private _drawRenderTargetBackground;
  59810. private _drawRenderTargetForeground;
  59811. /**
  59812. * Adds all the elements from the container to the scene
  59813. * @param container the container holding the elements
  59814. */
  59815. addFromContainer(container: AbstractScene): void;
  59816. /**
  59817. * Removes all the elements in the container from the scene
  59818. * @param container contains the elements to remove
  59819. * @param dispose if the removed element should be disposed (default: false)
  59820. */
  59821. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59822. }
  59823. }
  59824. declare module BABYLON {
  59825. /** @hidden */
  59826. export var layerPixelShader: {
  59827. name: string;
  59828. shader: string;
  59829. };
  59830. }
  59831. declare module BABYLON {
  59832. /** @hidden */
  59833. export var layerVertexShader: {
  59834. name: string;
  59835. shader: string;
  59836. };
  59837. }
  59838. declare module BABYLON {
  59839. /**
  59840. * This represents a full screen 2d layer.
  59841. * This can be useful to display a picture in the background of your scene for instance.
  59842. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59843. */
  59844. export class Layer {
  59845. /**
  59846. * Define the name of the layer.
  59847. */
  59848. name: string;
  59849. /**
  59850. * Define the texture the layer should display.
  59851. */
  59852. texture: Nullable<Texture>;
  59853. /**
  59854. * Is the layer in background or foreground.
  59855. */
  59856. isBackground: boolean;
  59857. /**
  59858. * Define the color of the layer (instead of texture).
  59859. */
  59860. color: Color4;
  59861. /**
  59862. * Define the scale of the layer in order to zoom in out of the texture.
  59863. */
  59864. scale: Vector2;
  59865. /**
  59866. * Define an offset for the layer in order to shift the texture.
  59867. */
  59868. offset: Vector2;
  59869. /**
  59870. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59871. */
  59872. alphaBlendingMode: number;
  59873. /**
  59874. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59875. * Alpha test will not mix with the background color in case of transparency.
  59876. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59877. */
  59878. alphaTest: boolean;
  59879. /**
  59880. * Define a mask to restrict the layer to only some of the scene cameras.
  59881. */
  59882. layerMask: number;
  59883. /**
  59884. * Define the list of render target the layer is visible into.
  59885. */
  59886. renderTargetTextures: RenderTargetTexture[];
  59887. /**
  59888. * Define if the layer is only used in renderTarget or if it also
  59889. * renders in the main frame buffer of the canvas.
  59890. */
  59891. renderOnlyInRenderTargetTextures: boolean;
  59892. private _scene;
  59893. private _vertexBuffers;
  59894. private _indexBuffer;
  59895. private _effect;
  59896. private _previousDefines;
  59897. /**
  59898. * An event triggered when the layer is disposed.
  59899. */
  59900. onDisposeObservable: Observable<Layer>;
  59901. private _onDisposeObserver;
  59902. /**
  59903. * Back compatibility with callback before the onDisposeObservable existed.
  59904. * The set callback will be triggered when the layer has been disposed.
  59905. */
  59906. set onDispose(callback: () => void);
  59907. /**
  59908. * An event triggered before rendering the scene
  59909. */
  59910. onBeforeRenderObservable: Observable<Layer>;
  59911. private _onBeforeRenderObserver;
  59912. /**
  59913. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59914. * The set callback will be triggered just before rendering the layer.
  59915. */
  59916. set onBeforeRender(callback: () => void);
  59917. /**
  59918. * An event triggered after rendering the scene
  59919. */
  59920. onAfterRenderObservable: Observable<Layer>;
  59921. private _onAfterRenderObserver;
  59922. /**
  59923. * Back compatibility with callback before the onAfterRenderObservable existed.
  59924. * The set callback will be triggered just after rendering the layer.
  59925. */
  59926. set onAfterRender(callback: () => void);
  59927. /**
  59928. * Instantiates a new layer.
  59929. * This represents a full screen 2d layer.
  59930. * This can be useful to display a picture in the background of your scene for instance.
  59931. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59932. * @param name Define the name of the layer in the scene
  59933. * @param imgUrl Define the url of the texture to display in the layer
  59934. * @param scene Define the scene the layer belongs to
  59935. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59936. * @param color Defines a color for the layer
  59937. */
  59938. constructor(
  59939. /**
  59940. * Define the name of the layer.
  59941. */
  59942. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59943. private _createIndexBuffer;
  59944. /** @hidden */
  59945. _rebuild(): void;
  59946. /**
  59947. * Renders the layer in the scene.
  59948. */
  59949. render(): void;
  59950. /**
  59951. * Disposes and releases the associated ressources.
  59952. */
  59953. dispose(): void;
  59954. }
  59955. }
  59956. declare module BABYLON {
  59957. /** @hidden */
  59958. export var lensFlarePixelShader: {
  59959. name: string;
  59960. shader: string;
  59961. };
  59962. }
  59963. declare module BABYLON {
  59964. /** @hidden */
  59965. export var lensFlareVertexShader: {
  59966. name: string;
  59967. shader: string;
  59968. };
  59969. }
  59970. declare module BABYLON {
  59971. /**
  59972. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59973. * It is usually composed of several `lensFlare`.
  59974. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59975. */
  59976. export class LensFlareSystem {
  59977. /**
  59978. * Define the name of the lens flare system
  59979. */
  59980. name: string;
  59981. /**
  59982. * List of lens flares used in this system.
  59983. */
  59984. lensFlares: LensFlare[];
  59985. /**
  59986. * Define a limit from the border the lens flare can be visible.
  59987. */
  59988. borderLimit: number;
  59989. /**
  59990. * Define a viewport border we do not want to see the lens flare in.
  59991. */
  59992. viewportBorder: number;
  59993. /**
  59994. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59995. */
  59996. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59997. /**
  59998. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59999. */
  60000. layerMask: number;
  60001. /**
  60002. * Define the id of the lens flare system in the scene.
  60003. * (equal to name by default)
  60004. */
  60005. id: string;
  60006. private _scene;
  60007. private _emitter;
  60008. private _vertexBuffers;
  60009. private _indexBuffer;
  60010. private _effect;
  60011. private _positionX;
  60012. private _positionY;
  60013. private _isEnabled;
  60014. /** @hidden */
  60015. static _SceneComponentInitialization: (scene: Scene) => void;
  60016. /**
  60017. * Instantiates a lens flare system.
  60018. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60019. * It is usually composed of several `lensFlare`.
  60020. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60021. * @param name Define the name of the lens flare system in the scene
  60022. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60023. * @param scene Define the scene the lens flare system belongs to
  60024. */
  60025. constructor(
  60026. /**
  60027. * Define the name of the lens flare system
  60028. */
  60029. name: string, emitter: any, scene: Scene);
  60030. /**
  60031. * Define if the lens flare system is enabled.
  60032. */
  60033. get isEnabled(): boolean;
  60034. set isEnabled(value: boolean);
  60035. /**
  60036. * Get the scene the effects belongs to.
  60037. * @returns the scene holding the lens flare system
  60038. */
  60039. getScene(): Scene;
  60040. /**
  60041. * Get the emitter of the lens flare system.
  60042. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60043. * @returns the emitter of the lens flare system
  60044. */
  60045. getEmitter(): any;
  60046. /**
  60047. * Set the emitter of the lens flare system.
  60048. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60049. * @param newEmitter Define the new emitter of the system
  60050. */
  60051. setEmitter(newEmitter: any): void;
  60052. /**
  60053. * Get the lens flare system emitter position.
  60054. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60055. * @returns the position
  60056. */
  60057. getEmitterPosition(): Vector3;
  60058. /**
  60059. * @hidden
  60060. */
  60061. computeEffectivePosition(globalViewport: Viewport): boolean;
  60062. /** @hidden */
  60063. _isVisible(): boolean;
  60064. /**
  60065. * @hidden
  60066. */
  60067. render(): boolean;
  60068. /**
  60069. * Dispose and release the lens flare with its associated resources.
  60070. */
  60071. dispose(): void;
  60072. /**
  60073. * Parse a lens flare system from a JSON repressentation
  60074. * @param parsedLensFlareSystem Define the JSON to parse
  60075. * @param scene Define the scene the parsed system should be instantiated in
  60076. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60077. * @returns the parsed system
  60078. */
  60079. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60080. /**
  60081. * Serialize the current Lens Flare System into a JSON representation.
  60082. * @returns the serialized JSON
  60083. */
  60084. serialize(): any;
  60085. }
  60086. }
  60087. declare module BABYLON {
  60088. /**
  60089. * This represents one of the lens effect in a `lensFlareSystem`.
  60090. * It controls one of the indiviual texture used in the effect.
  60091. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60092. */
  60093. export class LensFlare {
  60094. /**
  60095. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60096. */
  60097. size: number;
  60098. /**
  60099. * 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.
  60100. */
  60101. position: number;
  60102. /**
  60103. * Define the lens color.
  60104. */
  60105. color: Color3;
  60106. /**
  60107. * Define the lens texture.
  60108. */
  60109. texture: Nullable<Texture>;
  60110. /**
  60111. * Define the alpha mode to render this particular lens.
  60112. */
  60113. alphaMode: number;
  60114. private _system;
  60115. /**
  60116. * Creates a new Lens Flare.
  60117. * This represents one of the lens effect in a `lensFlareSystem`.
  60118. * It controls one of the indiviual texture used in the effect.
  60119. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60120. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60121. * @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.
  60122. * @param color Define the lens color
  60123. * @param imgUrl Define the lens texture url
  60124. * @param system Define the `lensFlareSystem` this flare is part of
  60125. * @returns The newly created Lens Flare
  60126. */
  60127. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60128. /**
  60129. * Instantiates a new Lens Flare.
  60130. * This represents one of the lens effect in a `lensFlareSystem`.
  60131. * It controls one of the indiviual texture used in the effect.
  60132. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60133. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60134. * @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.
  60135. * @param color Define the lens color
  60136. * @param imgUrl Define the lens texture url
  60137. * @param system Define the `lensFlareSystem` this flare is part of
  60138. */
  60139. constructor(
  60140. /**
  60141. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60142. */
  60143. size: number,
  60144. /**
  60145. * 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.
  60146. */
  60147. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60148. /**
  60149. * Dispose and release the lens flare with its associated resources.
  60150. */
  60151. dispose(): void;
  60152. }
  60153. }
  60154. declare module BABYLON {
  60155. interface AbstractScene {
  60156. /**
  60157. * The list of lens flare system added to the scene
  60158. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60159. */
  60160. lensFlareSystems: Array<LensFlareSystem>;
  60161. /**
  60162. * Removes the given lens flare system from this scene.
  60163. * @param toRemove The lens flare system to remove
  60164. * @returns The index of the removed lens flare system
  60165. */
  60166. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60167. /**
  60168. * Adds the given lens flare system to this scene
  60169. * @param newLensFlareSystem The lens flare system to add
  60170. */
  60171. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60172. /**
  60173. * Gets a lens flare system using its name
  60174. * @param name defines the name to look for
  60175. * @returns the lens flare system or null if not found
  60176. */
  60177. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60178. /**
  60179. * Gets a lens flare system using its id
  60180. * @param id defines the id to look for
  60181. * @returns the lens flare system or null if not found
  60182. */
  60183. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60184. }
  60185. /**
  60186. * Defines the lens flare scene component responsible to manage any lens flares
  60187. * in a given scene.
  60188. */
  60189. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60190. /**
  60191. * The component name helpfull to identify the component in the list of scene components.
  60192. */
  60193. readonly name: string;
  60194. /**
  60195. * The scene the component belongs to.
  60196. */
  60197. scene: Scene;
  60198. /**
  60199. * Creates a new instance of the component for the given scene
  60200. * @param scene Defines the scene to register the component in
  60201. */
  60202. constructor(scene: Scene);
  60203. /**
  60204. * Registers the component in a given scene
  60205. */
  60206. register(): void;
  60207. /**
  60208. * Rebuilds the elements related to this component in case of
  60209. * context lost for instance.
  60210. */
  60211. rebuild(): void;
  60212. /**
  60213. * Adds all the elements from the container to the scene
  60214. * @param container the container holding the elements
  60215. */
  60216. addFromContainer(container: AbstractScene): void;
  60217. /**
  60218. * Removes all the elements in the container from the scene
  60219. * @param container contains the elements to remove
  60220. * @param dispose if the removed element should be disposed (default: false)
  60221. */
  60222. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60223. /**
  60224. * Serializes the component data to the specified json object
  60225. * @param serializationObject The object to serialize to
  60226. */
  60227. serialize(serializationObject: any): void;
  60228. /**
  60229. * Disposes the component and the associated ressources.
  60230. */
  60231. dispose(): void;
  60232. private _draw;
  60233. }
  60234. }
  60235. declare module BABYLON {
  60236. /** @hidden */
  60237. export var depthPixelShader: {
  60238. name: string;
  60239. shader: string;
  60240. };
  60241. }
  60242. declare module BABYLON {
  60243. /** @hidden */
  60244. export var depthVertexShader: {
  60245. name: string;
  60246. shader: string;
  60247. };
  60248. }
  60249. declare module BABYLON {
  60250. /**
  60251. * This represents a depth renderer in Babylon.
  60252. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60253. */
  60254. export class DepthRenderer {
  60255. private _scene;
  60256. private _depthMap;
  60257. private _effect;
  60258. private readonly _storeNonLinearDepth;
  60259. private readonly _clearColor;
  60260. /** Get if the depth renderer is using packed depth or not */
  60261. readonly isPacked: boolean;
  60262. private _cachedDefines;
  60263. private _camera;
  60264. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60265. enabled: boolean;
  60266. /**
  60267. * Specifiess that the depth renderer will only be used within
  60268. * the camera it is created for.
  60269. * This can help forcing its rendering during the camera processing.
  60270. */
  60271. useOnlyInActiveCamera: boolean;
  60272. /** @hidden */
  60273. static _SceneComponentInitialization: (scene: Scene) => void;
  60274. /**
  60275. * Instantiates a depth renderer
  60276. * @param scene The scene the renderer belongs to
  60277. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60278. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60279. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60280. */
  60281. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60282. /**
  60283. * Creates the depth rendering effect and checks if the effect is ready.
  60284. * @param subMesh The submesh to be used to render the depth map of
  60285. * @param useInstances If multiple world instances should be used
  60286. * @returns if the depth renderer is ready to render the depth map
  60287. */
  60288. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60289. /**
  60290. * Gets the texture which the depth map will be written to.
  60291. * @returns The depth map texture
  60292. */
  60293. getDepthMap(): RenderTargetTexture;
  60294. /**
  60295. * Disposes of the depth renderer.
  60296. */
  60297. dispose(): void;
  60298. }
  60299. }
  60300. declare module BABYLON {
  60301. /** @hidden */
  60302. export var minmaxReduxPixelShader: {
  60303. name: string;
  60304. shader: string;
  60305. };
  60306. }
  60307. declare module BABYLON {
  60308. /**
  60309. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60310. * and maximum values from all values of the texture.
  60311. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60312. * The source values are read from the red channel of the texture.
  60313. */
  60314. export class MinMaxReducer {
  60315. /**
  60316. * Observable triggered when the computation has been performed
  60317. */
  60318. onAfterReductionPerformed: Observable<{
  60319. min: number;
  60320. max: number;
  60321. }>;
  60322. protected _camera: Camera;
  60323. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60324. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60325. protected _postProcessManager: PostProcessManager;
  60326. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60327. protected _forceFullscreenViewport: boolean;
  60328. /**
  60329. * Creates a min/max reducer
  60330. * @param camera The camera to use for the post processes
  60331. */
  60332. constructor(camera: Camera);
  60333. /**
  60334. * Gets the texture used to read the values from.
  60335. */
  60336. get sourceTexture(): Nullable<RenderTargetTexture>;
  60337. /**
  60338. * Sets the source texture to read the values from.
  60339. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60340. * because in such textures '1' value must not be taken into account to compute the maximum
  60341. * as this value is used to clear the texture.
  60342. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60343. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60344. * @param depthRedux Indicates if the texture is a depth texture or not
  60345. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60346. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60347. */
  60348. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60349. /**
  60350. * Defines the refresh rate of the computation.
  60351. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60352. */
  60353. get refreshRate(): number;
  60354. set refreshRate(value: number);
  60355. protected _activated: boolean;
  60356. /**
  60357. * Gets the activation status of the reducer
  60358. */
  60359. get activated(): boolean;
  60360. /**
  60361. * Activates the reduction computation.
  60362. * When activated, the observers registered in onAfterReductionPerformed are
  60363. * called after the compuation is performed
  60364. */
  60365. activate(): void;
  60366. /**
  60367. * Deactivates the reduction computation.
  60368. */
  60369. deactivate(): void;
  60370. /**
  60371. * Disposes the min/max reducer
  60372. * @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.
  60373. */
  60374. dispose(disposeAll?: boolean): void;
  60375. }
  60376. }
  60377. declare module BABYLON {
  60378. /**
  60379. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60380. */
  60381. export class DepthReducer extends MinMaxReducer {
  60382. private _depthRenderer;
  60383. private _depthRendererId;
  60384. /**
  60385. * Gets the depth renderer used for the computation.
  60386. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60387. */
  60388. get depthRenderer(): Nullable<DepthRenderer>;
  60389. /**
  60390. * Creates a depth reducer
  60391. * @param camera The camera used to render the depth texture
  60392. */
  60393. constructor(camera: Camera);
  60394. /**
  60395. * Sets the depth renderer to use to generate the depth map
  60396. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60397. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60398. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60399. */
  60400. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60401. /** @hidden */
  60402. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60403. /**
  60404. * Activates the reduction computation.
  60405. * When activated, the observers registered in onAfterReductionPerformed are
  60406. * called after the compuation is performed
  60407. */
  60408. activate(): void;
  60409. /**
  60410. * Deactivates the reduction computation.
  60411. */
  60412. deactivate(): void;
  60413. /**
  60414. * Disposes the depth reducer
  60415. * @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.
  60416. */
  60417. dispose(disposeAll?: boolean): void;
  60418. }
  60419. }
  60420. declare module BABYLON {
  60421. /**
  60422. * A CSM implementation allowing casting shadows on large scenes.
  60423. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60424. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60425. */
  60426. export class CascadedShadowGenerator extends ShadowGenerator {
  60427. private static readonly frustumCornersNDCSpace;
  60428. /**
  60429. * Name of the CSM class
  60430. */
  60431. static CLASSNAME: string;
  60432. /**
  60433. * Defines the default number of cascades used by the CSM.
  60434. */
  60435. static readonly DEFAULT_CASCADES_COUNT: number;
  60436. /**
  60437. * Defines the minimum number of cascades used by the CSM.
  60438. */
  60439. static readonly MIN_CASCADES_COUNT: number;
  60440. /**
  60441. * Defines the maximum number of cascades used by the CSM.
  60442. */
  60443. static readonly MAX_CASCADES_COUNT: number;
  60444. protected _validateFilter(filter: number): number;
  60445. /**
  60446. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60447. */
  60448. penumbraDarkness: number;
  60449. private _numCascades;
  60450. /**
  60451. * Gets or set the number of cascades used by the CSM.
  60452. */
  60453. get numCascades(): number;
  60454. set numCascades(value: number);
  60455. /**
  60456. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60457. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60458. */
  60459. stabilizeCascades: boolean;
  60460. private _freezeShadowCastersBoundingInfo;
  60461. private _freezeShadowCastersBoundingInfoObservable;
  60462. /**
  60463. * Enables or disables the shadow casters bounding info computation.
  60464. * If your shadow casters don't move, you can disable this feature.
  60465. * If it is enabled, the bounding box computation is done every frame.
  60466. */
  60467. get freezeShadowCastersBoundingInfo(): boolean;
  60468. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60469. private _scbiMin;
  60470. private _scbiMax;
  60471. protected _computeShadowCastersBoundingInfo(): void;
  60472. protected _shadowCastersBoundingInfo: BoundingInfo;
  60473. /**
  60474. * Gets or sets the shadow casters bounding info.
  60475. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60476. * so that the system won't overwrite the bounds you provide
  60477. */
  60478. get shadowCastersBoundingInfo(): BoundingInfo;
  60479. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60480. protected _breaksAreDirty: boolean;
  60481. protected _minDistance: number;
  60482. protected _maxDistance: number;
  60483. /**
  60484. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60485. *
  60486. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60487. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60488. * @param min minimal distance for the breaks (default to 0.)
  60489. * @param max maximal distance for the breaks (default to 1.)
  60490. */
  60491. setMinMaxDistance(min: number, max: number): void;
  60492. /** Gets the minimal distance used in the cascade break computation */
  60493. get minDistance(): number;
  60494. /** Gets the maximal distance used in the cascade break computation */
  60495. get maxDistance(): number;
  60496. /**
  60497. * Gets the class name of that object
  60498. * @returns "CascadedShadowGenerator"
  60499. */
  60500. getClassName(): string;
  60501. private _cascadeMinExtents;
  60502. private _cascadeMaxExtents;
  60503. /**
  60504. * Gets a cascade minimum extents
  60505. * @param cascadeIndex index of the cascade
  60506. * @returns the minimum cascade extents
  60507. */
  60508. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60509. /**
  60510. * Gets a cascade maximum extents
  60511. * @param cascadeIndex index of the cascade
  60512. * @returns the maximum cascade extents
  60513. */
  60514. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60515. private _cascades;
  60516. private _currentLayer;
  60517. private _viewSpaceFrustumsZ;
  60518. private _viewMatrices;
  60519. private _projectionMatrices;
  60520. private _transformMatrices;
  60521. private _transformMatricesAsArray;
  60522. private _frustumLengths;
  60523. private _lightSizeUVCorrection;
  60524. private _depthCorrection;
  60525. private _frustumCornersWorldSpace;
  60526. private _frustumCenter;
  60527. private _shadowCameraPos;
  60528. private _shadowMaxZ;
  60529. /**
  60530. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60531. * It defaults to camera.maxZ
  60532. */
  60533. get shadowMaxZ(): number;
  60534. /**
  60535. * Sets the shadow max z distance.
  60536. */
  60537. set shadowMaxZ(value: number);
  60538. protected _debug: boolean;
  60539. /**
  60540. * Gets or sets the debug flag.
  60541. * When enabled, the cascades are materialized by different colors on the screen.
  60542. */
  60543. get debug(): boolean;
  60544. set debug(dbg: boolean);
  60545. private _depthClamp;
  60546. /**
  60547. * Gets or sets the depth clamping value.
  60548. *
  60549. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60550. * to account for the shadow casters far away.
  60551. *
  60552. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60553. */
  60554. get depthClamp(): boolean;
  60555. set depthClamp(value: boolean);
  60556. private _cascadeBlendPercentage;
  60557. /**
  60558. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60559. * It defaults to 0.1 (10% blending).
  60560. */
  60561. get cascadeBlendPercentage(): number;
  60562. set cascadeBlendPercentage(value: number);
  60563. private _lambda;
  60564. /**
  60565. * Gets or set the lambda parameter.
  60566. * This parameter is used to split the camera frustum and create the cascades.
  60567. * 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.
  60568. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60569. */
  60570. get lambda(): number;
  60571. set lambda(value: number);
  60572. /**
  60573. * Gets the view matrix corresponding to a given cascade
  60574. * @param cascadeNum cascade to retrieve the view matrix from
  60575. * @returns the cascade view matrix
  60576. */
  60577. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60578. /**
  60579. * Gets the projection matrix corresponding to a given cascade
  60580. * @param cascadeNum cascade to retrieve the projection matrix from
  60581. * @returns the cascade projection matrix
  60582. */
  60583. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60584. /**
  60585. * Gets the transformation matrix corresponding to a given cascade
  60586. * @param cascadeNum cascade to retrieve the transformation matrix from
  60587. * @returns the cascade transformation matrix
  60588. */
  60589. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60590. private _depthRenderer;
  60591. /**
  60592. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60593. *
  60594. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60595. *
  60596. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60597. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60598. * @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
  60599. */
  60600. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60601. private _depthReducer;
  60602. private _autoCalcDepthBounds;
  60603. /**
  60604. * Gets or sets the autoCalcDepthBounds property.
  60605. *
  60606. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60607. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60608. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60609. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60610. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60611. */
  60612. get autoCalcDepthBounds(): boolean;
  60613. set autoCalcDepthBounds(value: boolean);
  60614. /**
  60615. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60616. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60617. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60618. * for setting the refresh rate on the renderer yourself!
  60619. */
  60620. get autoCalcDepthBoundsRefreshRate(): number;
  60621. set autoCalcDepthBoundsRefreshRate(value: number);
  60622. /**
  60623. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60624. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60625. * you change the camera near/far planes!
  60626. */
  60627. splitFrustum(): void;
  60628. private _splitFrustum;
  60629. private _computeMatrices;
  60630. private _computeFrustumInWorldSpace;
  60631. private _computeCascadeFrustum;
  60632. /**
  60633. * Support test.
  60634. */
  60635. static get IsSupported(): boolean;
  60636. /** @hidden */
  60637. static _SceneComponentInitialization: (scene: Scene) => void;
  60638. /**
  60639. * Creates a Cascaded Shadow Generator object.
  60640. * A ShadowGenerator is the required tool to use the shadows.
  60641. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60642. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60643. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60644. * @param light The directional light object generating the shadows.
  60645. * @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.
  60646. */
  60647. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60648. protected _initializeGenerator(): void;
  60649. protected _createTargetRenderTexture(): void;
  60650. protected _initializeShadowMap(): void;
  60651. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60652. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60653. /**
  60654. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60655. * @param defines Defines of the material we want to update
  60656. * @param lightIndex Index of the light in the enabled light list of the material
  60657. */
  60658. prepareDefines(defines: any, lightIndex: number): void;
  60659. /**
  60660. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60661. * defined in the generator but impacting the effect).
  60662. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60663. * @param effect The effect we are binfing the information for
  60664. */
  60665. bindShadowLight(lightIndex: string, effect: Effect): void;
  60666. /**
  60667. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60668. * (eq to view projection * shadow projection matrices)
  60669. * @returns The transform matrix used to create the shadow map
  60670. */
  60671. getTransformMatrix(): Matrix;
  60672. /**
  60673. * Disposes the ShadowGenerator.
  60674. * Returns nothing.
  60675. */
  60676. dispose(): void;
  60677. /**
  60678. * Serializes the shadow generator setup to a json object.
  60679. * @returns The serialized JSON object
  60680. */
  60681. serialize(): any;
  60682. /**
  60683. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60684. * @param parsedShadowGenerator The JSON object to parse
  60685. * @param scene The scene to create the shadow map for
  60686. * @returns The parsed shadow generator
  60687. */
  60688. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60689. }
  60690. }
  60691. declare module BABYLON {
  60692. /**
  60693. * Defines the shadow generator component responsible to manage any shadow generators
  60694. * in a given scene.
  60695. */
  60696. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60697. /**
  60698. * The component name helpfull to identify the component in the list of scene components.
  60699. */
  60700. readonly name: string;
  60701. /**
  60702. * The scene the component belongs to.
  60703. */
  60704. scene: Scene;
  60705. /**
  60706. * Creates a new instance of the component for the given scene
  60707. * @param scene Defines the scene to register the component in
  60708. */
  60709. constructor(scene: Scene);
  60710. /**
  60711. * Registers the component in a given scene
  60712. */
  60713. register(): void;
  60714. /**
  60715. * Rebuilds the elements related to this component in case of
  60716. * context lost for instance.
  60717. */
  60718. rebuild(): void;
  60719. /**
  60720. * Serializes the component data to the specified json object
  60721. * @param serializationObject The object to serialize to
  60722. */
  60723. serialize(serializationObject: any): void;
  60724. /**
  60725. * Adds all the elements from the container to the scene
  60726. * @param container the container holding the elements
  60727. */
  60728. addFromContainer(container: AbstractScene): void;
  60729. /**
  60730. * Removes all the elements in the container from the scene
  60731. * @param container contains the elements to remove
  60732. * @param dispose if the removed element should be disposed (default: false)
  60733. */
  60734. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60735. /**
  60736. * Rebuilds the elements related to this component in case of
  60737. * context lost for instance.
  60738. */
  60739. dispose(): void;
  60740. private _gatherRenderTargets;
  60741. }
  60742. }
  60743. declare module BABYLON {
  60744. /**
  60745. * A point light is a light defined by an unique point in world space.
  60746. * The light is emitted in every direction from this point.
  60747. * A good example of a point light is a standard light bulb.
  60748. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60749. */
  60750. export class PointLight extends ShadowLight {
  60751. private _shadowAngle;
  60752. /**
  60753. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60754. * This specifies what angle the shadow will use to be created.
  60755. *
  60756. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60757. */
  60758. get shadowAngle(): number;
  60759. /**
  60760. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60761. * This specifies what angle the shadow will use to be created.
  60762. *
  60763. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60764. */
  60765. set shadowAngle(value: number);
  60766. /**
  60767. * Gets the direction if it has been set.
  60768. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60769. */
  60770. get direction(): Vector3;
  60771. /**
  60772. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60773. */
  60774. set direction(value: Vector3);
  60775. /**
  60776. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60777. * A PointLight emits the light in every direction.
  60778. * It can cast shadows.
  60779. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60780. * ```javascript
  60781. * var pointLight = new PointLight("pl", camera.position, scene);
  60782. * ```
  60783. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60784. * @param name The light friendly name
  60785. * @param position The position of the point light in the scene
  60786. * @param scene The scene the lights belongs to
  60787. */
  60788. constructor(name: string, position: Vector3, scene: Scene);
  60789. /**
  60790. * Returns the string "PointLight"
  60791. * @returns the class name
  60792. */
  60793. getClassName(): string;
  60794. /**
  60795. * Returns the integer 0.
  60796. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60797. */
  60798. getTypeID(): number;
  60799. /**
  60800. * Specifies wether or not the shadowmap should be a cube texture.
  60801. * @returns true if the shadowmap needs to be a cube texture.
  60802. */
  60803. needCube(): boolean;
  60804. /**
  60805. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60806. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60807. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60808. */
  60809. getShadowDirection(faceIndex?: number): Vector3;
  60810. /**
  60811. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60812. * - fov = PI / 2
  60813. * - aspect ratio : 1.0
  60814. * - z-near and far equal to the active camera minZ and maxZ.
  60815. * Returns the PointLight.
  60816. */
  60817. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60818. protected _buildUniformLayout(): void;
  60819. /**
  60820. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60821. * @param effect The effect to update
  60822. * @param lightIndex The index of the light in the effect to update
  60823. * @returns The point light
  60824. */
  60825. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60826. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60827. /**
  60828. * Prepares the list of defines specific to the light type.
  60829. * @param defines the list of defines
  60830. * @param lightIndex defines the index of the light for the effect
  60831. */
  60832. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60833. }
  60834. }
  60835. declare module BABYLON {
  60836. /**
  60837. * Header information of HDR texture files.
  60838. */
  60839. export interface HDRInfo {
  60840. /**
  60841. * The height of the texture in pixels.
  60842. */
  60843. height: number;
  60844. /**
  60845. * The width of the texture in pixels.
  60846. */
  60847. width: number;
  60848. /**
  60849. * The index of the beginning of the data in the binary file.
  60850. */
  60851. dataPosition: number;
  60852. }
  60853. /**
  60854. * This groups tools to convert HDR texture to native colors array.
  60855. */
  60856. export class HDRTools {
  60857. private static Ldexp;
  60858. private static Rgbe2float;
  60859. private static readStringLine;
  60860. /**
  60861. * Reads header information from an RGBE texture stored in a native array.
  60862. * More information on this format are available here:
  60863. * https://en.wikipedia.org/wiki/RGBE_image_format
  60864. *
  60865. * @param uint8array The binary file stored in native array.
  60866. * @return The header information.
  60867. */
  60868. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60869. /**
  60870. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60871. * This RGBE texture needs to store the information as a panorama.
  60872. *
  60873. * More information on this format are available here:
  60874. * https://en.wikipedia.org/wiki/RGBE_image_format
  60875. *
  60876. * @param buffer The binary file stored in an array buffer.
  60877. * @param size The expected size of the extracted cubemap.
  60878. * @return The Cube Map information.
  60879. */
  60880. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60881. /**
  60882. * Returns the pixels data extracted from an RGBE texture.
  60883. * This pixels will be stored left to right up to down in the R G B order in one array.
  60884. *
  60885. * More information on this format are available here:
  60886. * https://en.wikipedia.org/wiki/RGBE_image_format
  60887. *
  60888. * @param uint8array The binary file stored in an array buffer.
  60889. * @param hdrInfo The header information of the file.
  60890. * @return The pixels data in RGB right to left up to down order.
  60891. */
  60892. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60893. private static RGBE_ReadPixels_RLE;
  60894. private static RGBE_ReadPixels_NOT_RLE;
  60895. }
  60896. }
  60897. declare module BABYLON {
  60898. /**
  60899. * Effect Render Options
  60900. */
  60901. export interface IEffectRendererOptions {
  60902. /**
  60903. * Defines the vertices positions.
  60904. */
  60905. positions?: number[];
  60906. /**
  60907. * Defines the indices.
  60908. */
  60909. indices?: number[];
  60910. }
  60911. /**
  60912. * Helper class to render one or more effects.
  60913. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60914. */
  60915. export class EffectRenderer {
  60916. private engine;
  60917. private static _DefaultOptions;
  60918. private _vertexBuffers;
  60919. private _indexBuffer;
  60920. private _fullscreenViewport;
  60921. /**
  60922. * Creates an effect renderer
  60923. * @param engine the engine to use for rendering
  60924. * @param options defines the options of the effect renderer
  60925. */
  60926. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60927. /**
  60928. * Sets the current viewport in normalized coordinates 0-1
  60929. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60930. */
  60931. setViewport(viewport?: Viewport): void;
  60932. /**
  60933. * Binds the embedded attributes buffer to the effect.
  60934. * @param effect Defines the effect to bind the attributes for
  60935. */
  60936. bindBuffers(effect: Effect): void;
  60937. /**
  60938. * Sets the current effect wrapper to use during draw.
  60939. * The effect needs to be ready before calling this api.
  60940. * This also sets the default full screen position attribute.
  60941. * @param effectWrapper Defines the effect to draw with
  60942. */
  60943. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60944. /**
  60945. * Restores engine states
  60946. */
  60947. restoreStates(): void;
  60948. /**
  60949. * Draws a full screen quad.
  60950. */
  60951. draw(): void;
  60952. private isRenderTargetTexture;
  60953. /**
  60954. * renders one or more effects to a specified texture
  60955. * @param effectWrapper the effect to renderer
  60956. * @param outputTexture texture to draw to, if null it will render to the screen.
  60957. */
  60958. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60959. /**
  60960. * Disposes of the effect renderer
  60961. */
  60962. dispose(): void;
  60963. }
  60964. /**
  60965. * Options to create an EffectWrapper
  60966. */
  60967. interface EffectWrapperCreationOptions {
  60968. /**
  60969. * Engine to use to create the effect
  60970. */
  60971. engine: ThinEngine;
  60972. /**
  60973. * Fragment shader for the effect
  60974. */
  60975. fragmentShader: string;
  60976. /**
  60977. * Use the shader store instead of direct source code
  60978. */
  60979. useShaderStore?: boolean;
  60980. /**
  60981. * Vertex shader for the effect
  60982. */
  60983. vertexShader?: string;
  60984. /**
  60985. * Attributes to use in the shader
  60986. */
  60987. attributeNames?: Array<string>;
  60988. /**
  60989. * Uniforms to use in the shader
  60990. */
  60991. uniformNames?: Array<string>;
  60992. /**
  60993. * Texture sampler names to use in the shader
  60994. */
  60995. samplerNames?: Array<string>;
  60996. /**
  60997. * Defines to use in the shader
  60998. */
  60999. defines?: Array<string>;
  61000. /**
  61001. * Callback when effect is compiled
  61002. */
  61003. onCompiled?: Nullable<(effect: Effect) => void>;
  61004. /**
  61005. * The friendly name of the effect displayed in Spector.
  61006. */
  61007. name?: string;
  61008. }
  61009. /**
  61010. * Wraps an effect to be used for rendering
  61011. */
  61012. export class EffectWrapper {
  61013. /**
  61014. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61015. */
  61016. onApplyObservable: Observable<{}>;
  61017. /**
  61018. * The underlying effect
  61019. */
  61020. effect: Effect;
  61021. /**
  61022. * Creates an effect to be renderer
  61023. * @param creationOptions options to create the effect
  61024. */
  61025. constructor(creationOptions: EffectWrapperCreationOptions);
  61026. /**
  61027. * Disposes of the effect wrapper
  61028. */
  61029. dispose(): void;
  61030. }
  61031. }
  61032. declare module BABYLON {
  61033. /** @hidden */
  61034. export var hdrFilteringVertexShader: {
  61035. name: string;
  61036. shader: string;
  61037. };
  61038. }
  61039. declare module BABYLON {
  61040. /** @hidden */
  61041. export var hdrFilteringPixelShader: {
  61042. name: string;
  61043. shader: string;
  61044. };
  61045. }
  61046. declare module BABYLON {
  61047. /**
  61048. * Options for texture filtering
  61049. */
  61050. interface IHDRFilteringOptions {
  61051. /**
  61052. * Scales pixel intensity for the input HDR map.
  61053. */
  61054. hdrScale?: number;
  61055. /**
  61056. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61057. */
  61058. quality?: number;
  61059. }
  61060. /**
  61061. * Filters HDR maps to get correct renderings of PBR reflections
  61062. */
  61063. export class HDRFiltering {
  61064. private _engine;
  61065. private _effectRenderer;
  61066. private _effectWrapper;
  61067. private _lodGenerationOffset;
  61068. private _lodGenerationScale;
  61069. /**
  61070. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61071. * you care about baking speed.
  61072. */
  61073. quality: number;
  61074. /**
  61075. * Scales pixel intensity for the input HDR map.
  61076. */
  61077. hdrScale: number;
  61078. /**
  61079. * Instantiates HDR filter for reflection maps
  61080. *
  61081. * @param engine Thin engine
  61082. * @param options Options
  61083. */
  61084. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61085. private _createRenderTarget;
  61086. private _prefilterInternal;
  61087. private _createEffect;
  61088. /**
  61089. * Get a value indicating if the filter is ready to be used
  61090. * @param texture Texture to filter
  61091. * @returns true if the filter is ready
  61092. */
  61093. isReady(texture: BaseTexture): boolean;
  61094. /**
  61095. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61096. * Prefiltering will be invoked at the end of next rendering pass.
  61097. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61098. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61099. * @param texture Texture to filter
  61100. * @param onFinished Callback when filtering is done
  61101. * @return Promise called when prefiltering is done
  61102. */
  61103. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61104. }
  61105. }
  61106. declare module BABYLON {
  61107. /**
  61108. * This represents a texture coming from an HDR input.
  61109. *
  61110. * The only supported format is currently panorama picture stored in RGBE format.
  61111. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61112. */
  61113. export class HDRCubeTexture extends BaseTexture {
  61114. private static _facesMapping;
  61115. private _generateHarmonics;
  61116. private _noMipmap;
  61117. private _prefilterOnLoad;
  61118. private _textureMatrix;
  61119. private _size;
  61120. private _onLoad;
  61121. private _onError;
  61122. /**
  61123. * The texture URL.
  61124. */
  61125. url: string;
  61126. protected _isBlocking: boolean;
  61127. /**
  61128. * Sets wether or not the texture is blocking during loading.
  61129. */
  61130. set isBlocking(value: boolean);
  61131. /**
  61132. * Gets wether or not the texture is blocking during loading.
  61133. */
  61134. get isBlocking(): boolean;
  61135. protected _rotationY: number;
  61136. /**
  61137. * Sets texture matrix rotation angle around Y axis in radians.
  61138. */
  61139. set rotationY(value: number);
  61140. /**
  61141. * Gets texture matrix rotation angle around Y axis radians.
  61142. */
  61143. get rotationY(): number;
  61144. /**
  61145. * Gets or sets the center of the bounding box associated with the cube texture
  61146. * It must define where the camera used to render the texture was set
  61147. */
  61148. boundingBoxPosition: Vector3;
  61149. private _boundingBoxSize;
  61150. /**
  61151. * Gets or sets the size of the bounding box associated with the cube texture
  61152. * When defined, the cubemap will switch to local mode
  61153. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61154. * @example https://www.babylonjs-playground.com/#RNASML
  61155. */
  61156. set boundingBoxSize(value: Vector3);
  61157. get boundingBoxSize(): Vector3;
  61158. /**
  61159. * Instantiates an HDRTexture from the following parameters.
  61160. *
  61161. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61162. * @param sceneOrEngine The scene or engine the texture will be used in
  61163. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61164. * @param noMipmap Forces to not generate the mipmap if true
  61165. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61166. * @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)
  61167. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61168. */
  61169. 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>);
  61170. /**
  61171. * Get the current class name of the texture useful for serialization or dynamic coding.
  61172. * @returns "HDRCubeTexture"
  61173. */
  61174. getClassName(): string;
  61175. /**
  61176. * Occurs when the file is raw .hdr file.
  61177. */
  61178. private loadTexture;
  61179. clone(): HDRCubeTexture;
  61180. delayLoad(): void;
  61181. /**
  61182. * Get the texture reflection matrix used to rotate/transform the reflection.
  61183. * @returns the reflection matrix
  61184. */
  61185. getReflectionTextureMatrix(): Matrix;
  61186. /**
  61187. * Set the texture reflection matrix used to rotate/transform the reflection.
  61188. * @param value Define the reflection matrix to set
  61189. */
  61190. setReflectionTextureMatrix(value: Matrix): void;
  61191. /**
  61192. * Parses a JSON representation of an HDR Texture in order to create the texture
  61193. * @param parsedTexture Define the JSON representation
  61194. * @param scene Define the scene the texture should be created in
  61195. * @param rootUrl Define the root url in case we need to load relative dependencies
  61196. * @returns the newly created texture after parsing
  61197. */
  61198. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61199. serialize(): any;
  61200. }
  61201. }
  61202. declare module BABYLON {
  61203. /**
  61204. * Class used to control physics engine
  61205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61206. */
  61207. export class PhysicsEngine implements IPhysicsEngine {
  61208. private _physicsPlugin;
  61209. /**
  61210. * Global value used to control the smallest number supported by the simulation
  61211. */
  61212. static Epsilon: number;
  61213. private _impostors;
  61214. private _joints;
  61215. private _subTimeStep;
  61216. /**
  61217. * Gets the gravity vector used by the simulation
  61218. */
  61219. gravity: Vector3;
  61220. /**
  61221. * Factory used to create the default physics plugin.
  61222. * @returns The default physics plugin
  61223. */
  61224. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61225. /**
  61226. * Creates a new Physics Engine
  61227. * @param gravity defines the gravity vector used by the simulation
  61228. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61229. */
  61230. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61231. /**
  61232. * Sets the gravity vector used by the simulation
  61233. * @param gravity defines the gravity vector to use
  61234. */
  61235. setGravity(gravity: Vector3): void;
  61236. /**
  61237. * Set the time step of the physics engine.
  61238. * Default is 1/60.
  61239. * To slow it down, enter 1/600 for example.
  61240. * To speed it up, 1/30
  61241. * @param newTimeStep defines the new timestep to apply to this world.
  61242. */
  61243. setTimeStep(newTimeStep?: number): void;
  61244. /**
  61245. * Get the time step of the physics engine.
  61246. * @returns the current time step
  61247. */
  61248. getTimeStep(): number;
  61249. /**
  61250. * Set the sub time step of the physics engine.
  61251. * Default is 0 meaning there is no sub steps
  61252. * To increase physics resolution precision, set a small value (like 1 ms)
  61253. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61254. */
  61255. setSubTimeStep(subTimeStep?: number): void;
  61256. /**
  61257. * Get the sub time step of the physics engine.
  61258. * @returns the current sub time step
  61259. */
  61260. getSubTimeStep(): number;
  61261. /**
  61262. * Release all resources
  61263. */
  61264. dispose(): void;
  61265. /**
  61266. * Gets the name of the current physics plugin
  61267. * @returns the name of the plugin
  61268. */
  61269. getPhysicsPluginName(): string;
  61270. /**
  61271. * Adding a new impostor for the impostor tracking.
  61272. * This will be done by the impostor itself.
  61273. * @param impostor the impostor to add
  61274. */
  61275. addImpostor(impostor: PhysicsImpostor): void;
  61276. /**
  61277. * Remove an impostor from the engine.
  61278. * This impostor and its mesh will not longer be updated by the physics engine.
  61279. * @param impostor the impostor to remove
  61280. */
  61281. removeImpostor(impostor: PhysicsImpostor): void;
  61282. /**
  61283. * Add a joint to the physics engine
  61284. * @param mainImpostor defines the main impostor to which the joint is added.
  61285. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61286. * @param joint defines the joint that will connect both impostors.
  61287. */
  61288. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61289. /**
  61290. * Removes a joint from the simulation
  61291. * @param mainImpostor defines the impostor used with the joint
  61292. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61293. * @param joint defines the joint to remove
  61294. */
  61295. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61296. /**
  61297. * Called by the scene. No need to call it.
  61298. * @param delta defines the timespam between frames
  61299. */
  61300. _step(delta: number): void;
  61301. /**
  61302. * Gets the current plugin used to run the simulation
  61303. * @returns current plugin
  61304. */
  61305. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61306. /**
  61307. * Gets the list of physic impostors
  61308. * @returns an array of PhysicsImpostor
  61309. */
  61310. getImpostors(): Array<PhysicsImpostor>;
  61311. /**
  61312. * Gets the impostor for a physics enabled object
  61313. * @param object defines the object impersonated by the impostor
  61314. * @returns the PhysicsImpostor or null if not found
  61315. */
  61316. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61317. /**
  61318. * Gets the impostor for a physics body object
  61319. * @param body defines physics body used by the impostor
  61320. * @returns the PhysicsImpostor or null if not found
  61321. */
  61322. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61323. /**
  61324. * Does a raycast in the physics world
  61325. * @param from when should the ray start?
  61326. * @param to when should the ray end?
  61327. * @returns PhysicsRaycastResult
  61328. */
  61329. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61330. }
  61331. }
  61332. declare module BABYLON {
  61333. /** @hidden */
  61334. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61335. private _useDeltaForWorldStep;
  61336. world: any;
  61337. name: string;
  61338. private _physicsMaterials;
  61339. private _fixedTimeStep;
  61340. private _cannonRaycastResult;
  61341. private _raycastResult;
  61342. private _physicsBodysToRemoveAfterStep;
  61343. private _firstFrame;
  61344. BJSCANNON: any;
  61345. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61346. setGravity(gravity: Vector3): void;
  61347. setTimeStep(timeStep: number): void;
  61348. getTimeStep(): number;
  61349. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61350. private _removeMarkedPhysicsBodiesFromWorld;
  61351. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61352. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61353. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61354. private _processChildMeshes;
  61355. removePhysicsBody(impostor: PhysicsImpostor): void;
  61356. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61357. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61358. private _addMaterial;
  61359. private _checkWithEpsilon;
  61360. private _createShape;
  61361. private _createHeightmap;
  61362. private _minus90X;
  61363. private _plus90X;
  61364. private _tmpPosition;
  61365. private _tmpDeltaPosition;
  61366. private _tmpUnityRotation;
  61367. private _updatePhysicsBodyTransformation;
  61368. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61369. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61370. isSupported(): boolean;
  61371. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61372. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61373. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61374. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61375. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61376. getBodyMass(impostor: PhysicsImpostor): number;
  61377. getBodyFriction(impostor: PhysicsImpostor): number;
  61378. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61379. getBodyRestitution(impostor: PhysicsImpostor): number;
  61380. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61381. sleepBody(impostor: PhysicsImpostor): void;
  61382. wakeUpBody(impostor: PhysicsImpostor): void;
  61383. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61384. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61385. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61386. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61387. getRadius(impostor: PhysicsImpostor): number;
  61388. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61389. dispose(): void;
  61390. private _extendNamespace;
  61391. /**
  61392. * Does a raycast in the physics world
  61393. * @param from when should the ray start?
  61394. * @param to when should the ray end?
  61395. * @returns PhysicsRaycastResult
  61396. */
  61397. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61398. }
  61399. }
  61400. declare module BABYLON {
  61401. /** @hidden */
  61402. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61403. private _useDeltaForWorldStep;
  61404. world: any;
  61405. name: string;
  61406. BJSOIMO: any;
  61407. private _raycastResult;
  61408. private _fixedTimeStep;
  61409. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61410. setGravity(gravity: Vector3): void;
  61411. setTimeStep(timeStep: number): void;
  61412. getTimeStep(): number;
  61413. private _tmpImpostorsArray;
  61414. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61415. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61416. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61417. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61418. private _tmpPositionVector;
  61419. removePhysicsBody(impostor: PhysicsImpostor): void;
  61420. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61421. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61422. isSupported(): boolean;
  61423. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61424. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61425. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61426. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61427. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61428. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61429. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61430. getBodyMass(impostor: PhysicsImpostor): number;
  61431. getBodyFriction(impostor: PhysicsImpostor): number;
  61432. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61433. getBodyRestitution(impostor: PhysicsImpostor): number;
  61434. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61435. sleepBody(impostor: PhysicsImpostor): void;
  61436. wakeUpBody(impostor: PhysicsImpostor): void;
  61437. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61438. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61439. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61440. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61441. getRadius(impostor: PhysicsImpostor): number;
  61442. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61443. dispose(): void;
  61444. /**
  61445. * Does a raycast in the physics world
  61446. * @param from when should the ray start?
  61447. * @param to when should the ray end?
  61448. * @returns PhysicsRaycastResult
  61449. */
  61450. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61451. }
  61452. }
  61453. declare module BABYLON {
  61454. /**
  61455. * AmmoJS Physics plugin
  61456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61457. * @see https://github.com/kripken/ammo.js/
  61458. */
  61459. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61460. private _useDeltaForWorldStep;
  61461. /**
  61462. * Reference to the Ammo library
  61463. */
  61464. bjsAMMO: any;
  61465. /**
  61466. * Created ammoJS world which physics bodies are added to
  61467. */
  61468. world: any;
  61469. /**
  61470. * Name of the plugin
  61471. */
  61472. name: string;
  61473. private _timeStep;
  61474. private _fixedTimeStep;
  61475. private _maxSteps;
  61476. private _tmpQuaternion;
  61477. private _tmpAmmoTransform;
  61478. private _tmpAmmoQuaternion;
  61479. private _tmpAmmoConcreteContactResultCallback;
  61480. private _collisionConfiguration;
  61481. private _dispatcher;
  61482. private _overlappingPairCache;
  61483. private _solver;
  61484. private _softBodySolver;
  61485. private _tmpAmmoVectorA;
  61486. private _tmpAmmoVectorB;
  61487. private _tmpAmmoVectorC;
  61488. private _tmpAmmoVectorD;
  61489. private _tmpContactCallbackResult;
  61490. private _tmpAmmoVectorRCA;
  61491. private _tmpAmmoVectorRCB;
  61492. private _raycastResult;
  61493. private static readonly DISABLE_COLLISION_FLAG;
  61494. private static readonly KINEMATIC_FLAG;
  61495. private static readonly DISABLE_DEACTIVATION_FLAG;
  61496. /**
  61497. * Initializes the ammoJS plugin
  61498. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61499. * @param ammoInjection can be used to inject your own ammo reference
  61500. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61501. */
  61502. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61503. /**
  61504. * Sets the gravity of the physics world (m/(s^2))
  61505. * @param gravity Gravity to set
  61506. */
  61507. setGravity(gravity: Vector3): void;
  61508. /**
  61509. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61510. * @param timeStep timestep to use in seconds
  61511. */
  61512. setTimeStep(timeStep: number): void;
  61513. /**
  61514. * 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)
  61515. * @param fixedTimeStep fixedTimeStep to use in seconds
  61516. */
  61517. setFixedTimeStep(fixedTimeStep: number): void;
  61518. /**
  61519. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61520. * @param maxSteps the maximum number of steps by the physics engine per frame
  61521. */
  61522. setMaxSteps(maxSteps: number): void;
  61523. /**
  61524. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61525. * @returns the current timestep in seconds
  61526. */
  61527. getTimeStep(): number;
  61528. /**
  61529. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61530. */
  61531. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61532. private _isImpostorInContact;
  61533. private _isImpostorPairInContact;
  61534. private _stepSimulation;
  61535. /**
  61536. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61537. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61538. * After the step the babylon meshes are set to the position of the physics imposters
  61539. * @param delta amount of time to step forward
  61540. * @param impostors array of imposters to update before/after the step
  61541. */
  61542. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61543. /**
  61544. * Update babylon mesh to match physics world object
  61545. * @param impostor imposter to match
  61546. */
  61547. private _afterSoftStep;
  61548. /**
  61549. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61550. * @param impostor imposter to match
  61551. */
  61552. private _ropeStep;
  61553. /**
  61554. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61555. * @param impostor imposter to match
  61556. */
  61557. private _softbodyOrClothStep;
  61558. private _tmpMatrix;
  61559. /**
  61560. * Applies an impulse on the imposter
  61561. * @param impostor imposter to apply impulse to
  61562. * @param force amount of force to be applied to the imposter
  61563. * @param contactPoint the location to apply the impulse on the imposter
  61564. */
  61565. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61566. /**
  61567. * Applies a force on the imposter
  61568. * @param impostor imposter to apply force
  61569. * @param force amount of force to be applied to the imposter
  61570. * @param contactPoint the location to apply the force on the imposter
  61571. */
  61572. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61573. /**
  61574. * Creates a physics body using the plugin
  61575. * @param impostor the imposter to create the physics body on
  61576. */
  61577. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61578. /**
  61579. * Removes the physics body from the imposter and disposes of the body's memory
  61580. * @param impostor imposter to remove the physics body from
  61581. */
  61582. removePhysicsBody(impostor: PhysicsImpostor): void;
  61583. /**
  61584. * Generates a joint
  61585. * @param impostorJoint the imposter joint to create the joint with
  61586. */
  61587. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61588. /**
  61589. * Removes a joint
  61590. * @param impostorJoint the imposter joint to remove the joint from
  61591. */
  61592. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61593. private _addMeshVerts;
  61594. /**
  61595. * Initialise the soft body vertices to match its object's (mesh) vertices
  61596. * Softbody vertices (nodes) are in world space and to match this
  61597. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61598. * @param impostor to create the softbody for
  61599. */
  61600. private _softVertexData;
  61601. /**
  61602. * Create an impostor's soft body
  61603. * @param impostor to create the softbody for
  61604. */
  61605. private _createSoftbody;
  61606. /**
  61607. * Create cloth for an impostor
  61608. * @param impostor to create the softbody for
  61609. */
  61610. private _createCloth;
  61611. /**
  61612. * Create rope for an impostor
  61613. * @param impostor to create the softbody for
  61614. */
  61615. private _createRope;
  61616. /**
  61617. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61618. * @param impostor to create the custom physics shape for
  61619. */
  61620. private _createCustom;
  61621. private _addHullVerts;
  61622. private _createShape;
  61623. /**
  61624. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61625. * @param impostor imposter containing the physics body and babylon object
  61626. */
  61627. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61628. /**
  61629. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61630. * @param impostor imposter containing the physics body and babylon object
  61631. * @param newPosition new position
  61632. * @param newRotation new rotation
  61633. */
  61634. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61635. /**
  61636. * If this plugin is supported
  61637. * @returns true if its supported
  61638. */
  61639. isSupported(): boolean;
  61640. /**
  61641. * Sets the linear velocity of the physics body
  61642. * @param impostor imposter to set the velocity on
  61643. * @param velocity velocity to set
  61644. */
  61645. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61646. /**
  61647. * Sets the angular velocity of the physics body
  61648. * @param impostor imposter to set the velocity on
  61649. * @param velocity velocity to set
  61650. */
  61651. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61652. /**
  61653. * gets the linear velocity
  61654. * @param impostor imposter to get linear velocity from
  61655. * @returns linear velocity
  61656. */
  61657. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61658. /**
  61659. * gets the angular velocity
  61660. * @param impostor imposter to get angular velocity from
  61661. * @returns angular velocity
  61662. */
  61663. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61664. /**
  61665. * Sets the mass of physics body
  61666. * @param impostor imposter to set the mass on
  61667. * @param mass mass to set
  61668. */
  61669. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61670. /**
  61671. * Gets the mass of the physics body
  61672. * @param impostor imposter to get the mass from
  61673. * @returns mass
  61674. */
  61675. getBodyMass(impostor: PhysicsImpostor): number;
  61676. /**
  61677. * Gets friction of the impostor
  61678. * @param impostor impostor to get friction from
  61679. * @returns friction value
  61680. */
  61681. getBodyFriction(impostor: PhysicsImpostor): number;
  61682. /**
  61683. * Sets friction of the impostor
  61684. * @param impostor impostor to set friction on
  61685. * @param friction friction value
  61686. */
  61687. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61688. /**
  61689. * Gets restitution of the impostor
  61690. * @param impostor impostor to get restitution from
  61691. * @returns restitution value
  61692. */
  61693. getBodyRestitution(impostor: PhysicsImpostor): number;
  61694. /**
  61695. * Sets resitution of the impostor
  61696. * @param impostor impostor to set resitution on
  61697. * @param restitution resitution value
  61698. */
  61699. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61700. /**
  61701. * Gets pressure inside the impostor
  61702. * @param impostor impostor to get pressure from
  61703. * @returns pressure value
  61704. */
  61705. getBodyPressure(impostor: PhysicsImpostor): number;
  61706. /**
  61707. * Sets pressure inside a soft body impostor
  61708. * Cloth and rope must remain 0 pressure
  61709. * @param impostor impostor to set pressure on
  61710. * @param pressure pressure value
  61711. */
  61712. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61713. /**
  61714. * Gets stiffness of the impostor
  61715. * @param impostor impostor to get stiffness from
  61716. * @returns pressure value
  61717. */
  61718. getBodyStiffness(impostor: PhysicsImpostor): number;
  61719. /**
  61720. * Sets stiffness of the impostor
  61721. * @param impostor impostor to set stiffness on
  61722. * @param stiffness stiffness value from 0 to 1
  61723. */
  61724. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61725. /**
  61726. * Gets velocityIterations of the impostor
  61727. * @param impostor impostor to get velocity iterations from
  61728. * @returns velocityIterations value
  61729. */
  61730. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61731. /**
  61732. * Sets velocityIterations of the impostor
  61733. * @param impostor impostor to set velocity iterations on
  61734. * @param velocityIterations velocityIterations value
  61735. */
  61736. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61737. /**
  61738. * Gets positionIterations of the impostor
  61739. * @param impostor impostor to get position iterations from
  61740. * @returns positionIterations value
  61741. */
  61742. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61743. /**
  61744. * Sets positionIterations of the impostor
  61745. * @param impostor impostor to set position on
  61746. * @param positionIterations positionIterations value
  61747. */
  61748. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61749. /**
  61750. * Append an anchor to a cloth object
  61751. * @param impostor is the cloth impostor to add anchor to
  61752. * @param otherImpostor is the rigid impostor to anchor to
  61753. * @param width ratio across width from 0 to 1
  61754. * @param height ratio up height from 0 to 1
  61755. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61756. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61757. */
  61758. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61759. /**
  61760. * Append an hook to a rope object
  61761. * @param impostor is the rope impostor to add hook to
  61762. * @param otherImpostor is the rigid impostor to hook to
  61763. * @param length ratio along the rope from 0 to 1
  61764. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61765. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61766. */
  61767. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61768. /**
  61769. * Sleeps the physics body and stops it from being active
  61770. * @param impostor impostor to sleep
  61771. */
  61772. sleepBody(impostor: PhysicsImpostor): void;
  61773. /**
  61774. * Activates the physics body
  61775. * @param impostor impostor to activate
  61776. */
  61777. wakeUpBody(impostor: PhysicsImpostor): void;
  61778. /**
  61779. * Updates the distance parameters of the joint
  61780. * @param joint joint to update
  61781. * @param maxDistance maximum distance of the joint
  61782. * @param minDistance minimum distance of the joint
  61783. */
  61784. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61785. /**
  61786. * Sets a motor on the joint
  61787. * @param joint joint to set motor on
  61788. * @param speed speed of the motor
  61789. * @param maxForce maximum force of the motor
  61790. * @param motorIndex index of the motor
  61791. */
  61792. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61793. /**
  61794. * Sets the motors limit
  61795. * @param joint joint to set limit on
  61796. * @param upperLimit upper limit
  61797. * @param lowerLimit lower limit
  61798. */
  61799. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61800. /**
  61801. * Syncs the position and rotation of a mesh with the impostor
  61802. * @param mesh mesh to sync
  61803. * @param impostor impostor to update the mesh with
  61804. */
  61805. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61806. /**
  61807. * Gets the radius of the impostor
  61808. * @param impostor impostor to get radius from
  61809. * @returns the radius
  61810. */
  61811. getRadius(impostor: PhysicsImpostor): number;
  61812. /**
  61813. * Gets the box size of the impostor
  61814. * @param impostor impostor to get box size from
  61815. * @param result the resulting box size
  61816. */
  61817. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61818. /**
  61819. * Disposes of the impostor
  61820. */
  61821. dispose(): void;
  61822. /**
  61823. * Does a raycast in the physics world
  61824. * @param from when should the ray start?
  61825. * @param to when should the ray end?
  61826. * @returns PhysicsRaycastResult
  61827. */
  61828. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61829. }
  61830. }
  61831. declare module BABYLON {
  61832. interface AbstractScene {
  61833. /**
  61834. * The list of reflection probes added to the scene
  61835. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61836. */
  61837. reflectionProbes: Array<ReflectionProbe>;
  61838. /**
  61839. * Removes the given reflection probe from this scene.
  61840. * @param toRemove The reflection probe to remove
  61841. * @returns The index of the removed reflection probe
  61842. */
  61843. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61844. /**
  61845. * Adds the given reflection probe to this scene.
  61846. * @param newReflectionProbe The reflection probe to add
  61847. */
  61848. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61849. }
  61850. /**
  61851. * Class used to generate realtime reflection / refraction cube textures
  61852. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61853. */
  61854. export class ReflectionProbe {
  61855. /** defines the name of the probe */
  61856. name: string;
  61857. private _scene;
  61858. private _renderTargetTexture;
  61859. private _projectionMatrix;
  61860. private _viewMatrix;
  61861. private _target;
  61862. private _add;
  61863. private _attachedMesh;
  61864. private _invertYAxis;
  61865. /** Gets or sets probe position (center of the cube map) */
  61866. position: Vector3;
  61867. /**
  61868. * Creates a new reflection probe
  61869. * @param name defines the name of the probe
  61870. * @param size defines the texture resolution (for each face)
  61871. * @param scene defines the hosting scene
  61872. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61873. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61874. */
  61875. constructor(
  61876. /** defines the name of the probe */
  61877. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61878. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61879. get samples(): number;
  61880. set samples(value: number);
  61881. /** Gets or sets the refresh rate to use (on every frame by default) */
  61882. get refreshRate(): number;
  61883. set refreshRate(value: number);
  61884. /**
  61885. * Gets the hosting scene
  61886. * @returns a Scene
  61887. */
  61888. getScene(): Scene;
  61889. /** Gets the internal CubeTexture used to render to */
  61890. get cubeTexture(): RenderTargetTexture;
  61891. /** Gets the list of meshes to render */
  61892. get renderList(): Nullable<AbstractMesh[]>;
  61893. /**
  61894. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61895. * @param mesh defines the mesh to attach to
  61896. */
  61897. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61898. /**
  61899. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61900. * @param renderingGroupId The rendering group id corresponding to its index
  61901. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61902. */
  61903. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61904. /**
  61905. * Clean all associated resources
  61906. */
  61907. dispose(): void;
  61908. /**
  61909. * Converts the reflection probe information to a readable string for debug purpose.
  61910. * @param fullDetails Supports for multiple levels of logging within scene loading
  61911. * @returns the human readable reflection probe info
  61912. */
  61913. toString(fullDetails?: boolean): string;
  61914. /**
  61915. * Get the class name of the relfection probe.
  61916. * @returns "ReflectionProbe"
  61917. */
  61918. getClassName(): string;
  61919. /**
  61920. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61921. * @returns The JSON representation of the texture
  61922. */
  61923. serialize(): any;
  61924. /**
  61925. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61926. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61927. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61928. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61929. * @returns The parsed reflection probe if successful
  61930. */
  61931. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61932. }
  61933. }
  61934. declare module BABYLON {
  61935. /** @hidden */
  61936. export var _BabylonLoaderRegistered: boolean;
  61937. /**
  61938. * Helps setting up some configuration for the babylon file loader.
  61939. */
  61940. export class BabylonFileLoaderConfiguration {
  61941. /**
  61942. * The loader does not allow injecting custom physix engine into the plugins.
  61943. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61944. * So you could set this variable to your engine import to make it work.
  61945. */
  61946. static LoaderInjectedPhysicsEngine: any;
  61947. }
  61948. }
  61949. declare module BABYLON {
  61950. /**
  61951. * The Physically based simple base material of BJS.
  61952. *
  61953. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61954. * It is used as the base class for both the specGloss and metalRough conventions.
  61955. */
  61956. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61957. /**
  61958. * Number of Simultaneous lights allowed on the material.
  61959. */
  61960. maxSimultaneousLights: number;
  61961. /**
  61962. * If sets to true, disables all the lights affecting the material.
  61963. */
  61964. disableLighting: boolean;
  61965. /**
  61966. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61967. */
  61968. environmentTexture: BaseTexture;
  61969. /**
  61970. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61971. */
  61972. invertNormalMapX: boolean;
  61973. /**
  61974. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61975. */
  61976. invertNormalMapY: boolean;
  61977. /**
  61978. * Normal map used in the model.
  61979. */
  61980. normalTexture: BaseTexture;
  61981. /**
  61982. * Emissivie color used to self-illuminate the model.
  61983. */
  61984. emissiveColor: Color3;
  61985. /**
  61986. * Emissivie texture used to self-illuminate the model.
  61987. */
  61988. emissiveTexture: BaseTexture;
  61989. /**
  61990. * Occlusion Channel Strenght.
  61991. */
  61992. occlusionStrength: number;
  61993. /**
  61994. * Occlusion Texture of the material (adding extra occlusion effects).
  61995. */
  61996. occlusionTexture: BaseTexture;
  61997. /**
  61998. * Defines the alpha limits in alpha test mode.
  61999. */
  62000. alphaCutOff: number;
  62001. /**
  62002. * Gets the current double sided mode.
  62003. */
  62004. get doubleSided(): boolean;
  62005. /**
  62006. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62007. */
  62008. set doubleSided(value: boolean);
  62009. /**
  62010. * Stores the pre-calculated light information of a mesh in a texture.
  62011. */
  62012. lightmapTexture: BaseTexture;
  62013. /**
  62014. * If true, the light map contains occlusion information instead of lighting info.
  62015. */
  62016. useLightmapAsShadowmap: boolean;
  62017. /**
  62018. * Instantiates a new PBRMaterial instance.
  62019. *
  62020. * @param name The material name
  62021. * @param scene The scene the material will be use in.
  62022. */
  62023. constructor(name: string, scene: Scene);
  62024. getClassName(): string;
  62025. }
  62026. }
  62027. declare module BABYLON {
  62028. /**
  62029. * The PBR material of BJS following the metal roughness convention.
  62030. *
  62031. * This fits to the PBR convention in the GLTF definition:
  62032. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62033. */
  62034. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62035. /**
  62036. * The base color has two different interpretations depending on the value of metalness.
  62037. * When the material is a metal, the base color is the specific measured reflectance value
  62038. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62039. * of the material.
  62040. */
  62041. baseColor: Color3;
  62042. /**
  62043. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62044. * well as opacity information in the alpha channel.
  62045. */
  62046. baseTexture: BaseTexture;
  62047. /**
  62048. * Specifies the metallic scalar value of the material.
  62049. * Can also be used to scale the metalness values of the metallic texture.
  62050. */
  62051. metallic: number;
  62052. /**
  62053. * Specifies the roughness scalar value of the material.
  62054. * Can also be used to scale the roughness values of the metallic texture.
  62055. */
  62056. roughness: number;
  62057. /**
  62058. * Texture containing both the metallic value in the B channel and the
  62059. * roughness value in the G channel to keep better precision.
  62060. */
  62061. metallicRoughnessTexture: BaseTexture;
  62062. /**
  62063. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62064. *
  62065. * @param name The material name
  62066. * @param scene The scene the material will be use in.
  62067. */
  62068. constructor(name: string, scene: Scene);
  62069. /**
  62070. * Return the currrent class name of the material.
  62071. */
  62072. getClassName(): string;
  62073. /**
  62074. * Makes a duplicate of the current material.
  62075. * @param name - name to use for the new material.
  62076. */
  62077. clone(name: string): PBRMetallicRoughnessMaterial;
  62078. /**
  62079. * Serialize the material to a parsable JSON object.
  62080. */
  62081. serialize(): any;
  62082. /**
  62083. * Parses a JSON object correponding to the serialize function.
  62084. */
  62085. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62086. }
  62087. }
  62088. declare module BABYLON {
  62089. /**
  62090. * The PBR material of BJS following the specular glossiness convention.
  62091. *
  62092. * This fits to the PBR convention in the GLTF definition:
  62093. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62094. */
  62095. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62096. /**
  62097. * Specifies the diffuse color of the material.
  62098. */
  62099. diffuseColor: Color3;
  62100. /**
  62101. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62102. * channel.
  62103. */
  62104. diffuseTexture: BaseTexture;
  62105. /**
  62106. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62107. */
  62108. specularColor: Color3;
  62109. /**
  62110. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62111. */
  62112. glossiness: number;
  62113. /**
  62114. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62115. */
  62116. specularGlossinessTexture: BaseTexture;
  62117. /**
  62118. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62119. *
  62120. * @param name The material name
  62121. * @param scene The scene the material will be use in.
  62122. */
  62123. constructor(name: string, scene: Scene);
  62124. /**
  62125. * Return the currrent class name of the material.
  62126. */
  62127. getClassName(): string;
  62128. /**
  62129. * Makes a duplicate of the current material.
  62130. * @param name - name to use for the new material.
  62131. */
  62132. clone(name: string): PBRSpecularGlossinessMaterial;
  62133. /**
  62134. * Serialize the material to a parsable JSON object.
  62135. */
  62136. serialize(): any;
  62137. /**
  62138. * Parses a JSON object correponding to the serialize function.
  62139. */
  62140. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62141. }
  62142. }
  62143. declare module BABYLON {
  62144. /**
  62145. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62146. * It can help converting any input color in a desired output one. This can then be used to create effects
  62147. * from sepia, black and white to sixties or futuristic rendering...
  62148. *
  62149. * The only supported format is currently 3dl.
  62150. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62151. */
  62152. export class ColorGradingTexture extends BaseTexture {
  62153. /**
  62154. * The texture URL.
  62155. */
  62156. url: string;
  62157. /**
  62158. * Empty line regex stored for GC.
  62159. */
  62160. private static _noneEmptyLineRegex;
  62161. private _textureMatrix;
  62162. private _onLoad;
  62163. /**
  62164. * Instantiates a ColorGradingTexture from the following parameters.
  62165. *
  62166. * @param url The location of the color gradind data (currently only supporting 3dl)
  62167. * @param sceneOrEngine The scene or engine the texture will be used in
  62168. * @param onLoad defines a callback triggered when the texture has been loaded
  62169. */
  62170. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62171. /**
  62172. * Fires the onload event from the constructor if requested.
  62173. */
  62174. private _triggerOnLoad;
  62175. /**
  62176. * Returns the texture matrix used in most of the material.
  62177. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62178. */
  62179. getTextureMatrix(): Matrix;
  62180. /**
  62181. * Occurs when the file being loaded is a .3dl LUT file.
  62182. */
  62183. private load3dlTexture;
  62184. /**
  62185. * Starts the loading process of the texture.
  62186. */
  62187. private loadTexture;
  62188. /**
  62189. * Clones the color gradind texture.
  62190. */
  62191. clone(): ColorGradingTexture;
  62192. /**
  62193. * Called during delayed load for textures.
  62194. */
  62195. delayLoad(): void;
  62196. /**
  62197. * Parses a color grading texture serialized by Babylon.
  62198. * @param parsedTexture The texture information being parsedTexture
  62199. * @param scene The scene to load the texture in
  62200. * @param rootUrl The root url of the data assets to load
  62201. * @return A color gradind texture
  62202. */
  62203. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62204. /**
  62205. * Serializes the LUT texture to json format.
  62206. */
  62207. serialize(): any;
  62208. }
  62209. }
  62210. declare module BABYLON {
  62211. /**
  62212. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62213. */
  62214. export class EquiRectangularCubeTexture extends BaseTexture {
  62215. /** The six faces of the cube. */
  62216. private static _FacesMapping;
  62217. private _noMipmap;
  62218. private _onLoad;
  62219. private _onError;
  62220. /** The size of the cubemap. */
  62221. private _size;
  62222. /** The buffer of the image. */
  62223. private _buffer;
  62224. /** The width of the input image. */
  62225. private _width;
  62226. /** The height of the input image. */
  62227. private _height;
  62228. /** The URL to the image. */
  62229. url: string;
  62230. /**
  62231. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62232. * @param url The location of the image
  62233. * @param scene The scene the texture will be used in
  62234. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62235. * @param noMipmap Forces to not generate the mipmap if true
  62236. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62237. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62238. * @param onLoad — defines a callback called when texture is loaded
  62239. * @param onError — defines a callback called if there is an error
  62240. */
  62241. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62242. /**
  62243. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62244. */
  62245. private loadImage;
  62246. /**
  62247. * Convert the image buffer into a cubemap and create a CubeTexture.
  62248. */
  62249. private loadTexture;
  62250. /**
  62251. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62252. * @param buffer The ArrayBuffer that should be converted.
  62253. * @returns The buffer as Float32Array.
  62254. */
  62255. private getFloat32ArrayFromArrayBuffer;
  62256. /**
  62257. * Get the current class name of the texture useful for serialization or dynamic coding.
  62258. * @returns "EquiRectangularCubeTexture"
  62259. */
  62260. getClassName(): string;
  62261. /**
  62262. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62263. * @returns A clone of the current EquiRectangularCubeTexture.
  62264. */
  62265. clone(): EquiRectangularCubeTexture;
  62266. }
  62267. }
  62268. declare module BABYLON {
  62269. /**
  62270. * Defines the options related to the creation of an HtmlElementTexture
  62271. */
  62272. export interface IHtmlElementTextureOptions {
  62273. /**
  62274. * Defines wether mip maps should be created or not.
  62275. */
  62276. generateMipMaps?: boolean;
  62277. /**
  62278. * Defines the sampling mode of the texture.
  62279. */
  62280. samplingMode?: number;
  62281. /**
  62282. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62283. */
  62284. engine: Nullable<ThinEngine>;
  62285. /**
  62286. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62287. */
  62288. scene: Nullable<Scene>;
  62289. }
  62290. /**
  62291. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62292. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62293. * is automatically managed.
  62294. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62295. * in your application.
  62296. *
  62297. * As the update is not automatic, you need to call them manually.
  62298. */
  62299. export class HtmlElementTexture extends BaseTexture {
  62300. /**
  62301. * The texture URL.
  62302. */
  62303. element: HTMLVideoElement | HTMLCanvasElement;
  62304. private static readonly DefaultOptions;
  62305. private _textureMatrix;
  62306. private _isVideo;
  62307. private _generateMipMaps;
  62308. private _samplingMode;
  62309. /**
  62310. * Instantiates a HtmlElementTexture from the following parameters.
  62311. *
  62312. * @param name Defines the name of the texture
  62313. * @param element Defines the video or canvas the texture is filled with
  62314. * @param options Defines the other none mandatory texture creation options
  62315. */
  62316. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62317. private _createInternalTexture;
  62318. /**
  62319. * Returns the texture matrix used in most of the material.
  62320. */
  62321. getTextureMatrix(): Matrix;
  62322. /**
  62323. * Updates the content of the texture.
  62324. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62325. */
  62326. update(invertY?: Nullable<boolean>): void;
  62327. }
  62328. }
  62329. declare module BABYLON {
  62330. /**
  62331. * Based on jsTGALoader - Javascript loader for TGA file
  62332. * By Vincent Thibault
  62333. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62334. */
  62335. export class TGATools {
  62336. private static _TYPE_INDEXED;
  62337. private static _TYPE_RGB;
  62338. private static _TYPE_GREY;
  62339. private static _TYPE_RLE_INDEXED;
  62340. private static _TYPE_RLE_RGB;
  62341. private static _TYPE_RLE_GREY;
  62342. private static _ORIGIN_MASK;
  62343. private static _ORIGIN_SHIFT;
  62344. private static _ORIGIN_BL;
  62345. private static _ORIGIN_BR;
  62346. private static _ORIGIN_UL;
  62347. private static _ORIGIN_UR;
  62348. /**
  62349. * Gets the header of a TGA file
  62350. * @param data defines the TGA data
  62351. * @returns the header
  62352. */
  62353. static GetTGAHeader(data: Uint8Array): any;
  62354. /**
  62355. * Uploads TGA content to a Babylon Texture
  62356. * @hidden
  62357. */
  62358. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62359. /** @hidden */
  62360. 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;
  62361. /** @hidden */
  62362. 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;
  62363. /** @hidden */
  62364. 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;
  62365. /** @hidden */
  62366. 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;
  62367. /** @hidden */
  62368. 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;
  62369. /** @hidden */
  62370. 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;
  62371. }
  62372. }
  62373. declare module BABYLON {
  62374. /**
  62375. * Implementation of the TGA Texture Loader.
  62376. * @hidden
  62377. */
  62378. export class _TGATextureLoader implements IInternalTextureLoader {
  62379. /**
  62380. * Defines wether the loader supports cascade loading the different faces.
  62381. */
  62382. readonly supportCascades: boolean;
  62383. /**
  62384. * This returns if the loader support the current file information.
  62385. * @param extension defines the file extension of the file being loaded
  62386. * @returns true if the loader can load the specified file
  62387. */
  62388. canLoad(extension: string): boolean;
  62389. /**
  62390. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62391. * @param data contains the texture data
  62392. * @param texture defines the BabylonJS internal texture
  62393. * @param createPolynomials will be true if polynomials have been requested
  62394. * @param onLoad defines the callback to trigger once the texture is ready
  62395. * @param onError defines the callback to trigger in case of error
  62396. */
  62397. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62398. /**
  62399. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62400. * @param data contains the texture data
  62401. * @param texture defines the BabylonJS internal texture
  62402. * @param callback defines the method to call once ready to upload
  62403. */
  62404. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62405. }
  62406. }
  62407. declare module BABYLON {
  62408. /**
  62409. * Info about the .basis files
  62410. */
  62411. class BasisFileInfo {
  62412. /**
  62413. * If the file has alpha
  62414. */
  62415. hasAlpha: boolean;
  62416. /**
  62417. * Info about each image of the basis file
  62418. */
  62419. images: Array<{
  62420. levels: Array<{
  62421. width: number;
  62422. height: number;
  62423. transcodedPixels: ArrayBufferView;
  62424. }>;
  62425. }>;
  62426. }
  62427. /**
  62428. * Result of transcoding a basis file
  62429. */
  62430. class TranscodeResult {
  62431. /**
  62432. * Info about the .basis file
  62433. */
  62434. fileInfo: BasisFileInfo;
  62435. /**
  62436. * Format to use when loading the file
  62437. */
  62438. format: number;
  62439. }
  62440. /**
  62441. * Configuration options for the Basis transcoder
  62442. */
  62443. export class BasisTranscodeConfiguration {
  62444. /**
  62445. * Supported compression formats used to determine the supported output format of the transcoder
  62446. */
  62447. supportedCompressionFormats?: {
  62448. /**
  62449. * etc1 compression format
  62450. */
  62451. etc1?: boolean;
  62452. /**
  62453. * s3tc compression format
  62454. */
  62455. s3tc?: boolean;
  62456. /**
  62457. * pvrtc compression format
  62458. */
  62459. pvrtc?: boolean;
  62460. /**
  62461. * etc2 compression format
  62462. */
  62463. etc2?: boolean;
  62464. };
  62465. /**
  62466. * If mipmap levels should be loaded for transcoded images (Default: true)
  62467. */
  62468. loadMipmapLevels?: boolean;
  62469. /**
  62470. * Index of a single image to load (Default: all images)
  62471. */
  62472. loadSingleImage?: number;
  62473. }
  62474. /**
  62475. * Used to load .Basis files
  62476. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62477. */
  62478. export class BasisTools {
  62479. private static _IgnoreSupportedFormats;
  62480. /**
  62481. * URL to use when loading the basis transcoder
  62482. */
  62483. static JSModuleURL: string;
  62484. /**
  62485. * URL to use when loading the wasm module for the transcoder
  62486. */
  62487. static WasmModuleURL: string;
  62488. /**
  62489. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62490. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62491. * @returns internal format corresponding to the Basis format
  62492. */
  62493. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62494. private static _WorkerPromise;
  62495. private static _Worker;
  62496. private static _actionId;
  62497. private static _CreateWorkerAsync;
  62498. /**
  62499. * Transcodes a loaded image file to compressed pixel data
  62500. * @param data image data to transcode
  62501. * @param config configuration options for the transcoding
  62502. * @returns a promise resulting in the transcoded image
  62503. */
  62504. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62505. /**
  62506. * Loads a texture from the transcode result
  62507. * @param texture texture load to
  62508. * @param transcodeResult the result of transcoding the basis file to load from
  62509. */
  62510. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62511. }
  62512. }
  62513. declare module BABYLON {
  62514. /**
  62515. * Loader for .basis file format
  62516. */
  62517. export class _BasisTextureLoader implements IInternalTextureLoader {
  62518. /**
  62519. * Defines whether the loader supports cascade loading the different faces.
  62520. */
  62521. readonly supportCascades: boolean;
  62522. /**
  62523. * This returns if the loader support the current file information.
  62524. * @param extension defines the file extension of the file being loaded
  62525. * @returns true if the loader can load the specified file
  62526. */
  62527. canLoad(extension: string): boolean;
  62528. /**
  62529. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62530. * @param data contains the texture data
  62531. * @param texture defines the BabylonJS internal texture
  62532. * @param createPolynomials will be true if polynomials have been requested
  62533. * @param onLoad defines the callback to trigger once the texture is ready
  62534. * @param onError defines the callback to trigger in case of error
  62535. */
  62536. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62537. /**
  62538. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62539. * @param data contains the texture data
  62540. * @param texture defines the BabylonJS internal texture
  62541. * @param callback defines the method to call once ready to upload
  62542. */
  62543. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62544. }
  62545. }
  62546. declare module BABYLON {
  62547. /**
  62548. * Defines the basic options interface of a TexturePacker Frame
  62549. */
  62550. export interface ITexturePackerFrame {
  62551. /**
  62552. * The frame ID
  62553. */
  62554. id: number;
  62555. /**
  62556. * The frames Scale
  62557. */
  62558. scale: Vector2;
  62559. /**
  62560. * The Frames offset
  62561. */
  62562. offset: Vector2;
  62563. }
  62564. /**
  62565. * This is a support class for frame Data on texture packer sets.
  62566. */
  62567. export class TexturePackerFrame implements ITexturePackerFrame {
  62568. /**
  62569. * The frame ID
  62570. */
  62571. id: number;
  62572. /**
  62573. * The frames Scale
  62574. */
  62575. scale: Vector2;
  62576. /**
  62577. * The Frames offset
  62578. */
  62579. offset: Vector2;
  62580. /**
  62581. * Initializes a texture package frame.
  62582. * @param id The numerical frame identifier
  62583. * @param scale Scalar Vector2 for UV frame
  62584. * @param offset Vector2 for the frame position in UV units.
  62585. * @returns TexturePackerFrame
  62586. */
  62587. constructor(id: number, scale: Vector2, offset: Vector2);
  62588. }
  62589. }
  62590. declare module BABYLON {
  62591. /**
  62592. * Defines the basic options interface of a TexturePacker
  62593. */
  62594. export interface ITexturePackerOptions {
  62595. /**
  62596. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62597. */
  62598. map?: string[];
  62599. /**
  62600. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62601. */
  62602. uvsIn?: string;
  62603. /**
  62604. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62605. */
  62606. uvsOut?: string;
  62607. /**
  62608. * number representing the layout style. Defaults to LAYOUT_STRIP
  62609. */
  62610. layout?: number;
  62611. /**
  62612. * number of columns if using custom column count layout(2). This defaults to 4.
  62613. */
  62614. colnum?: number;
  62615. /**
  62616. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62617. */
  62618. updateInputMeshes?: boolean;
  62619. /**
  62620. * boolean flag to dispose all the source textures. Defaults to true.
  62621. */
  62622. disposeSources?: boolean;
  62623. /**
  62624. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62625. */
  62626. fillBlanks?: boolean;
  62627. /**
  62628. * string value representing the context fill style color. Defaults to 'black'.
  62629. */
  62630. customFillColor?: string;
  62631. /**
  62632. * Width and Height Value of each Frame in the TexturePacker Sets
  62633. */
  62634. frameSize?: number;
  62635. /**
  62636. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62637. */
  62638. paddingRatio?: number;
  62639. /**
  62640. * Number that declares the fill method for the padding gutter.
  62641. */
  62642. paddingMode?: number;
  62643. /**
  62644. * If in SUBUV_COLOR padding mode what color to use.
  62645. */
  62646. paddingColor?: Color3 | Color4;
  62647. }
  62648. /**
  62649. * Defines the basic interface of a TexturePacker JSON File
  62650. */
  62651. export interface ITexturePackerJSON {
  62652. /**
  62653. * The frame ID
  62654. */
  62655. name: string;
  62656. /**
  62657. * The base64 channel data
  62658. */
  62659. sets: any;
  62660. /**
  62661. * The options of the Packer
  62662. */
  62663. options: ITexturePackerOptions;
  62664. /**
  62665. * The frame data of the Packer
  62666. */
  62667. frames: Array<number>;
  62668. }
  62669. /**
  62670. * This is a support class that generates a series of packed texture sets.
  62671. * @see https://doc.babylonjs.com/babylon101/materials
  62672. */
  62673. export class TexturePacker {
  62674. /** Packer Layout Constant 0 */
  62675. static readonly LAYOUT_STRIP: number;
  62676. /** Packer Layout Constant 1 */
  62677. static readonly LAYOUT_POWER2: number;
  62678. /** Packer Layout Constant 2 */
  62679. static readonly LAYOUT_COLNUM: number;
  62680. /** Packer Layout Constant 0 */
  62681. static readonly SUBUV_WRAP: number;
  62682. /** Packer Layout Constant 1 */
  62683. static readonly SUBUV_EXTEND: number;
  62684. /** Packer Layout Constant 2 */
  62685. static readonly SUBUV_COLOR: number;
  62686. /** The Name of the Texture Package */
  62687. name: string;
  62688. /** The scene scope of the TexturePacker */
  62689. scene: Scene;
  62690. /** The Meshes to target */
  62691. meshes: AbstractMesh[];
  62692. /** Arguments passed with the Constructor */
  62693. options: ITexturePackerOptions;
  62694. /** The promise that is started upon initialization */
  62695. promise: Nullable<Promise<TexturePacker | string>>;
  62696. /** The Container object for the channel sets that are generated */
  62697. sets: object;
  62698. /** The Container array for the frames that are generated */
  62699. frames: TexturePackerFrame[];
  62700. /** The expected number of textures the system is parsing. */
  62701. private _expecting;
  62702. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62703. private _paddingValue;
  62704. /**
  62705. * Initializes a texture package series from an array of meshes or a single mesh.
  62706. * @param name The name of the package
  62707. * @param meshes The target meshes to compose the package from
  62708. * @param options The arguments that texture packer should follow while building.
  62709. * @param scene The scene which the textures are scoped to.
  62710. * @returns TexturePacker
  62711. */
  62712. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62713. /**
  62714. * Starts the package process
  62715. * @param resolve The promises resolution function
  62716. * @returns TexturePacker
  62717. */
  62718. private _createFrames;
  62719. /**
  62720. * Calculates the Size of the Channel Sets
  62721. * @returns Vector2
  62722. */
  62723. private _calculateSize;
  62724. /**
  62725. * Calculates the UV data for the frames.
  62726. * @param baseSize the base frameSize
  62727. * @param padding the base frame padding
  62728. * @param dtSize size of the Dynamic Texture for that channel
  62729. * @param dtUnits is 1/dtSize
  62730. * @param update flag to update the input meshes
  62731. */
  62732. private _calculateMeshUVFrames;
  62733. /**
  62734. * Calculates the frames Offset.
  62735. * @param index of the frame
  62736. * @returns Vector2
  62737. */
  62738. private _getFrameOffset;
  62739. /**
  62740. * Updates a Mesh to the frame data
  62741. * @param mesh that is the target
  62742. * @param frameID or the frame index
  62743. */
  62744. private _updateMeshUV;
  62745. /**
  62746. * Updates a Meshes materials to use the texture packer channels
  62747. * @param m is the mesh to target
  62748. * @param force all channels on the packer to be set.
  62749. */
  62750. private _updateTextureReferences;
  62751. /**
  62752. * Public method to set a Mesh to a frame
  62753. * @param m that is the target
  62754. * @param frameID or the frame index
  62755. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62756. */
  62757. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62758. /**
  62759. * Starts the async promise to compile the texture packer.
  62760. * @returns Promise<void>
  62761. */
  62762. processAsync(): Promise<void>;
  62763. /**
  62764. * Disposes all textures associated with this packer
  62765. */
  62766. dispose(): void;
  62767. /**
  62768. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62769. * @param imageType is the image type to use.
  62770. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62771. */
  62772. download(imageType?: string, quality?: number): void;
  62773. /**
  62774. * Public method to load a texturePacker JSON file.
  62775. * @param data of the JSON file in string format.
  62776. */
  62777. updateFromJSON(data: string): void;
  62778. }
  62779. }
  62780. declare module BABYLON {
  62781. /**
  62782. * 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.
  62783. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62784. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62785. */
  62786. export class CustomProceduralTexture extends ProceduralTexture {
  62787. private _animate;
  62788. private _time;
  62789. private _config;
  62790. private _texturePath;
  62791. /**
  62792. * Instantiates a new Custom Procedural Texture.
  62793. * 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.
  62794. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62795. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62796. * @param name Define the name of the texture
  62797. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62798. * @param size Define the size of the texture to create
  62799. * @param scene Define the scene the texture belongs to
  62800. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62801. * @param generateMipMaps Define if the texture should creates mip maps or not
  62802. */
  62803. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62804. private _loadJson;
  62805. /**
  62806. * Is the texture ready to be used ? (rendered at least once)
  62807. * @returns true if ready, otherwise, false.
  62808. */
  62809. isReady(): boolean;
  62810. /**
  62811. * Render the texture to its associated render target.
  62812. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62813. */
  62814. render(useCameraPostProcess?: boolean): void;
  62815. /**
  62816. * Update the list of dependant textures samplers in the shader.
  62817. */
  62818. updateTextures(): void;
  62819. /**
  62820. * Update the uniform values of the procedural texture in the shader.
  62821. */
  62822. updateShaderUniforms(): void;
  62823. /**
  62824. * Define if the texture animates or not.
  62825. */
  62826. get animate(): boolean;
  62827. set animate(value: boolean);
  62828. }
  62829. }
  62830. declare module BABYLON {
  62831. /** @hidden */
  62832. export var noisePixelShader: {
  62833. name: string;
  62834. shader: string;
  62835. };
  62836. }
  62837. declare module BABYLON {
  62838. /**
  62839. * Class used to generate noise procedural textures
  62840. */
  62841. export class NoiseProceduralTexture extends ProceduralTexture {
  62842. /** Gets or sets the start time (default is 0) */
  62843. time: number;
  62844. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62845. brightness: number;
  62846. /** Defines the number of octaves to process */
  62847. octaves: number;
  62848. /** Defines the level of persistence (0.8 by default) */
  62849. persistence: number;
  62850. /** Gets or sets animation speed factor (default is 1) */
  62851. animationSpeedFactor: number;
  62852. /**
  62853. * Creates a new NoiseProceduralTexture
  62854. * @param name defines the name fo the texture
  62855. * @param size defines the size of the texture (default is 256)
  62856. * @param scene defines the hosting scene
  62857. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62858. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62859. */
  62860. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62861. private _updateShaderUniforms;
  62862. protected _getDefines(): string;
  62863. /** Generate the current state of the procedural texture */
  62864. render(useCameraPostProcess?: boolean): void;
  62865. /**
  62866. * Serializes this noise procedural texture
  62867. * @returns a serialized noise procedural texture object
  62868. */
  62869. serialize(): any;
  62870. /**
  62871. * Clone the texture.
  62872. * @returns the cloned texture
  62873. */
  62874. clone(): NoiseProceduralTexture;
  62875. /**
  62876. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62877. * @param parsedTexture defines parsed texture data
  62878. * @param scene defines the current scene
  62879. * @param rootUrl defines the root URL containing noise procedural texture information
  62880. * @returns a parsed NoiseProceduralTexture
  62881. */
  62882. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62883. }
  62884. }
  62885. declare module BABYLON {
  62886. /**
  62887. * Raw cube texture where the raw buffers are passed in
  62888. */
  62889. export class RawCubeTexture extends CubeTexture {
  62890. /**
  62891. * Creates a cube texture where the raw buffers are passed in.
  62892. * @param scene defines the scene the texture is attached to
  62893. * @param data defines the array of data to use to create each face
  62894. * @param size defines the size of the textures
  62895. * @param format defines the format of the data
  62896. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62897. * @param generateMipMaps defines if the engine should generate the mip levels
  62898. * @param invertY defines if data must be stored with Y axis inverted
  62899. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62900. * @param compression defines the compression used (null by default)
  62901. */
  62902. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62903. /**
  62904. * Updates the raw cube texture.
  62905. * @param data defines the data to store
  62906. * @param format defines the data format
  62907. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62908. * @param invertY defines if data must be stored with Y axis inverted
  62909. * @param compression defines the compression used (null by default)
  62910. * @param level defines which level of the texture to update
  62911. */
  62912. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62913. /**
  62914. * Updates a raw cube texture with RGBD encoded data.
  62915. * @param data defines the array of data [mipmap][face] to use to create each face
  62916. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62917. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62918. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62919. * @returns a promsie that resolves when the operation is complete
  62920. */
  62921. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62922. /**
  62923. * Clones the raw cube texture.
  62924. * @return a new cube texture
  62925. */
  62926. clone(): CubeTexture;
  62927. /** @hidden */
  62928. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62929. }
  62930. }
  62931. declare module BABYLON {
  62932. /**
  62933. * Class used to store 2D array textures containing user data
  62934. */
  62935. export class RawTexture2DArray extends Texture {
  62936. /** Gets or sets the texture format to use */
  62937. format: number;
  62938. /**
  62939. * Create a new RawTexture2DArray
  62940. * @param data defines the data of the texture
  62941. * @param width defines the width of the texture
  62942. * @param height defines the height of the texture
  62943. * @param depth defines the number of layers of the texture
  62944. * @param format defines the texture format to use
  62945. * @param scene defines the hosting scene
  62946. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62947. * @param invertY defines if texture must be stored with Y axis inverted
  62948. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62949. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62950. */
  62951. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62952. /** Gets or sets the texture format to use */
  62953. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62954. /**
  62955. * Update the texture with new data
  62956. * @param data defines the data to store in the texture
  62957. */
  62958. update(data: ArrayBufferView): void;
  62959. }
  62960. }
  62961. declare module BABYLON {
  62962. /**
  62963. * Class used to store 3D textures containing user data
  62964. */
  62965. export class RawTexture3D extends Texture {
  62966. /** Gets or sets the texture format to use */
  62967. format: number;
  62968. /**
  62969. * Create a new RawTexture3D
  62970. * @param data defines the data of the texture
  62971. * @param width defines the width of the texture
  62972. * @param height defines the height of the texture
  62973. * @param depth defines the depth of the texture
  62974. * @param format defines the texture format to use
  62975. * @param scene defines the hosting scene
  62976. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62977. * @param invertY defines if texture must be stored with Y axis inverted
  62978. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62979. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62980. */
  62981. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62982. /** Gets or sets the texture format to use */
  62983. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62984. /**
  62985. * Update the texture with new data
  62986. * @param data defines the data to store in the texture
  62987. */
  62988. update(data: ArrayBufferView): void;
  62989. }
  62990. }
  62991. declare module BABYLON {
  62992. /**
  62993. * Creates a refraction texture used by refraction channel of the standard material.
  62994. * It is like a mirror but to see through a material.
  62995. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62996. */
  62997. export class RefractionTexture extends RenderTargetTexture {
  62998. /**
  62999. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63000. * 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.
  63001. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63002. */
  63003. refractionPlane: Plane;
  63004. /**
  63005. * Define how deep under the surface we should see.
  63006. */
  63007. depth: number;
  63008. /**
  63009. * Creates a refraction texture used by refraction channel of the standard material.
  63010. * It is like a mirror but to see through a material.
  63011. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63012. * @param name Define the texture name
  63013. * @param size Define the size of the underlying texture
  63014. * @param scene Define the scene the refraction belongs to
  63015. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63016. */
  63017. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63018. /**
  63019. * Clone the refraction texture.
  63020. * @returns the cloned texture
  63021. */
  63022. clone(): RefractionTexture;
  63023. /**
  63024. * Serialize the texture to a JSON representation you could use in Parse later on
  63025. * @returns the serialized JSON representation
  63026. */
  63027. serialize(): any;
  63028. }
  63029. }
  63030. declare module BABYLON {
  63031. /**
  63032. * Block used to add support for vertex skinning (bones)
  63033. */
  63034. export class BonesBlock extends NodeMaterialBlock {
  63035. /**
  63036. * Creates a new BonesBlock
  63037. * @param name defines the block name
  63038. */
  63039. constructor(name: string);
  63040. /**
  63041. * Initialize the block and prepare the context for build
  63042. * @param state defines the state that will be used for the build
  63043. */
  63044. initialize(state: NodeMaterialBuildState): void;
  63045. /**
  63046. * Gets the current class name
  63047. * @returns the class name
  63048. */
  63049. getClassName(): string;
  63050. /**
  63051. * Gets the matrix indices input component
  63052. */
  63053. get matricesIndices(): NodeMaterialConnectionPoint;
  63054. /**
  63055. * Gets the matrix weights input component
  63056. */
  63057. get matricesWeights(): NodeMaterialConnectionPoint;
  63058. /**
  63059. * Gets the extra matrix indices input component
  63060. */
  63061. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63062. /**
  63063. * Gets the extra matrix weights input component
  63064. */
  63065. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63066. /**
  63067. * Gets the world input component
  63068. */
  63069. get world(): NodeMaterialConnectionPoint;
  63070. /**
  63071. * Gets the output component
  63072. */
  63073. get output(): NodeMaterialConnectionPoint;
  63074. autoConfigure(material: NodeMaterial): void;
  63075. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63076. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63077. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63078. protected _buildBlock(state: NodeMaterialBuildState): this;
  63079. }
  63080. }
  63081. declare module BABYLON {
  63082. /**
  63083. * Block used to add support for instances
  63084. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63085. */
  63086. export class InstancesBlock extends NodeMaterialBlock {
  63087. /**
  63088. * Creates a new InstancesBlock
  63089. * @param name defines the block name
  63090. */
  63091. constructor(name: string);
  63092. /**
  63093. * Gets the current class name
  63094. * @returns the class name
  63095. */
  63096. getClassName(): string;
  63097. /**
  63098. * Gets the first world row input component
  63099. */
  63100. get world0(): NodeMaterialConnectionPoint;
  63101. /**
  63102. * Gets the second world row input component
  63103. */
  63104. get world1(): NodeMaterialConnectionPoint;
  63105. /**
  63106. * Gets the third world row input component
  63107. */
  63108. get world2(): NodeMaterialConnectionPoint;
  63109. /**
  63110. * Gets the forth world row input component
  63111. */
  63112. get world3(): NodeMaterialConnectionPoint;
  63113. /**
  63114. * Gets the world input component
  63115. */
  63116. get world(): NodeMaterialConnectionPoint;
  63117. /**
  63118. * Gets the output component
  63119. */
  63120. get output(): NodeMaterialConnectionPoint;
  63121. /**
  63122. * Gets the isntanceID component
  63123. */
  63124. get instanceID(): NodeMaterialConnectionPoint;
  63125. autoConfigure(material: NodeMaterial): void;
  63126. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63127. protected _buildBlock(state: NodeMaterialBuildState): this;
  63128. }
  63129. }
  63130. declare module BABYLON {
  63131. /**
  63132. * Block used to add morph targets support to vertex shader
  63133. */
  63134. export class MorphTargetsBlock extends NodeMaterialBlock {
  63135. private _repeatableContentAnchor;
  63136. /**
  63137. * Create a new MorphTargetsBlock
  63138. * @param name defines the block name
  63139. */
  63140. constructor(name: string);
  63141. /**
  63142. * Gets the current class name
  63143. * @returns the class name
  63144. */
  63145. getClassName(): string;
  63146. /**
  63147. * Gets the position input component
  63148. */
  63149. get position(): NodeMaterialConnectionPoint;
  63150. /**
  63151. * Gets the normal input component
  63152. */
  63153. get normal(): NodeMaterialConnectionPoint;
  63154. /**
  63155. * Gets the tangent input component
  63156. */
  63157. get tangent(): NodeMaterialConnectionPoint;
  63158. /**
  63159. * Gets the tangent input component
  63160. */
  63161. get uv(): NodeMaterialConnectionPoint;
  63162. /**
  63163. * Gets the position output component
  63164. */
  63165. get positionOutput(): NodeMaterialConnectionPoint;
  63166. /**
  63167. * Gets the normal output component
  63168. */
  63169. get normalOutput(): NodeMaterialConnectionPoint;
  63170. /**
  63171. * Gets the tangent output component
  63172. */
  63173. get tangentOutput(): NodeMaterialConnectionPoint;
  63174. /**
  63175. * Gets the tangent output component
  63176. */
  63177. get uvOutput(): NodeMaterialConnectionPoint;
  63178. initialize(state: NodeMaterialBuildState): void;
  63179. autoConfigure(material: NodeMaterial): void;
  63180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63181. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63182. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63183. protected _buildBlock(state: NodeMaterialBuildState): this;
  63184. }
  63185. }
  63186. declare module BABYLON {
  63187. /**
  63188. * Block used to get data information from a light
  63189. */
  63190. export class LightInformationBlock extends NodeMaterialBlock {
  63191. private _lightDataUniformName;
  63192. private _lightColorUniformName;
  63193. private _lightTypeDefineName;
  63194. /**
  63195. * Gets or sets the light associated with this block
  63196. */
  63197. light: Nullable<Light>;
  63198. /**
  63199. * Creates a new LightInformationBlock
  63200. * @param name defines the block name
  63201. */
  63202. constructor(name: string);
  63203. /**
  63204. * Gets the current class name
  63205. * @returns the class name
  63206. */
  63207. getClassName(): string;
  63208. /**
  63209. * Gets the world position input component
  63210. */
  63211. get worldPosition(): NodeMaterialConnectionPoint;
  63212. /**
  63213. * Gets the direction output component
  63214. */
  63215. get direction(): NodeMaterialConnectionPoint;
  63216. /**
  63217. * Gets the direction output component
  63218. */
  63219. get color(): NodeMaterialConnectionPoint;
  63220. /**
  63221. * Gets the direction output component
  63222. */
  63223. get intensity(): NodeMaterialConnectionPoint;
  63224. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63225. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63226. protected _buildBlock(state: NodeMaterialBuildState): this;
  63227. serialize(): any;
  63228. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63229. }
  63230. }
  63231. declare module BABYLON {
  63232. /**
  63233. * Block used to add image processing support to fragment shader
  63234. */
  63235. export class ImageProcessingBlock extends NodeMaterialBlock {
  63236. /**
  63237. * Create a new ImageProcessingBlock
  63238. * @param name defines the block name
  63239. */
  63240. constructor(name: string);
  63241. /**
  63242. * Gets the current class name
  63243. * @returns the class name
  63244. */
  63245. getClassName(): string;
  63246. /**
  63247. * Gets the color input component
  63248. */
  63249. get color(): NodeMaterialConnectionPoint;
  63250. /**
  63251. * Gets the output component
  63252. */
  63253. get output(): NodeMaterialConnectionPoint;
  63254. /**
  63255. * Initialize the block and prepare the context for build
  63256. * @param state defines the state that will be used for the build
  63257. */
  63258. initialize(state: NodeMaterialBuildState): void;
  63259. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63260. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63261. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63262. protected _buildBlock(state: NodeMaterialBuildState): this;
  63263. }
  63264. }
  63265. declare module BABYLON {
  63266. /**
  63267. * Block used to pertub normals based on a normal map
  63268. */
  63269. export class PerturbNormalBlock extends NodeMaterialBlock {
  63270. private _tangentSpaceParameterName;
  63271. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63272. invertX: boolean;
  63273. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63274. invertY: boolean;
  63275. /**
  63276. * Create a new PerturbNormalBlock
  63277. * @param name defines the block name
  63278. */
  63279. constructor(name: string);
  63280. /**
  63281. * Gets the current class name
  63282. * @returns the class name
  63283. */
  63284. getClassName(): string;
  63285. /**
  63286. * Gets the world position input component
  63287. */
  63288. get worldPosition(): NodeMaterialConnectionPoint;
  63289. /**
  63290. * Gets the world normal input component
  63291. */
  63292. get worldNormal(): NodeMaterialConnectionPoint;
  63293. /**
  63294. * Gets the world tangent input component
  63295. */
  63296. get worldTangent(): NodeMaterialConnectionPoint;
  63297. /**
  63298. * Gets the uv input component
  63299. */
  63300. get uv(): NodeMaterialConnectionPoint;
  63301. /**
  63302. * Gets the normal map color input component
  63303. */
  63304. get normalMapColor(): NodeMaterialConnectionPoint;
  63305. /**
  63306. * Gets the strength input component
  63307. */
  63308. get strength(): NodeMaterialConnectionPoint;
  63309. /**
  63310. * Gets the output component
  63311. */
  63312. get output(): NodeMaterialConnectionPoint;
  63313. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63314. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63315. autoConfigure(material: NodeMaterial): void;
  63316. protected _buildBlock(state: NodeMaterialBuildState): this;
  63317. protected _dumpPropertiesCode(): string;
  63318. serialize(): any;
  63319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63320. }
  63321. }
  63322. declare module BABYLON {
  63323. /**
  63324. * Block used to discard a pixel if a value is smaller than a cutoff
  63325. */
  63326. export class DiscardBlock extends NodeMaterialBlock {
  63327. /**
  63328. * Create a new DiscardBlock
  63329. * @param name defines the block name
  63330. */
  63331. constructor(name: string);
  63332. /**
  63333. * Gets the current class name
  63334. * @returns the class name
  63335. */
  63336. getClassName(): string;
  63337. /**
  63338. * Gets the color input component
  63339. */
  63340. get value(): NodeMaterialConnectionPoint;
  63341. /**
  63342. * Gets the cutoff input component
  63343. */
  63344. get cutoff(): NodeMaterialConnectionPoint;
  63345. protected _buildBlock(state: NodeMaterialBuildState): this;
  63346. }
  63347. }
  63348. declare module BABYLON {
  63349. /**
  63350. * Block used to test if the fragment shader is front facing
  63351. */
  63352. export class FrontFacingBlock extends NodeMaterialBlock {
  63353. /**
  63354. * Creates a new FrontFacingBlock
  63355. * @param name defines the block name
  63356. */
  63357. constructor(name: string);
  63358. /**
  63359. * Gets the current class name
  63360. * @returns the class name
  63361. */
  63362. getClassName(): string;
  63363. /**
  63364. * Gets the output component
  63365. */
  63366. get output(): NodeMaterialConnectionPoint;
  63367. protected _buildBlock(state: NodeMaterialBuildState): this;
  63368. }
  63369. }
  63370. declare module BABYLON {
  63371. /**
  63372. * Block used to get the derivative value on x and y of a given input
  63373. */
  63374. export class DerivativeBlock extends NodeMaterialBlock {
  63375. /**
  63376. * Create a new DerivativeBlock
  63377. * @param name defines the block name
  63378. */
  63379. constructor(name: string);
  63380. /**
  63381. * Gets the current class name
  63382. * @returns the class name
  63383. */
  63384. getClassName(): string;
  63385. /**
  63386. * Gets the input component
  63387. */
  63388. get input(): NodeMaterialConnectionPoint;
  63389. /**
  63390. * Gets the derivative output on x
  63391. */
  63392. get dx(): NodeMaterialConnectionPoint;
  63393. /**
  63394. * Gets the derivative output on y
  63395. */
  63396. get dy(): NodeMaterialConnectionPoint;
  63397. protected _buildBlock(state: NodeMaterialBuildState): this;
  63398. }
  63399. }
  63400. declare module BABYLON {
  63401. /**
  63402. * Block used to make gl_FragCoord available
  63403. */
  63404. export class FragCoordBlock extends NodeMaterialBlock {
  63405. /**
  63406. * Creates a new FragCoordBlock
  63407. * @param name defines the block name
  63408. */
  63409. constructor(name: string);
  63410. /**
  63411. * Gets the current class name
  63412. * @returns the class name
  63413. */
  63414. getClassName(): string;
  63415. /**
  63416. * Gets the xy component
  63417. */
  63418. get xy(): NodeMaterialConnectionPoint;
  63419. /**
  63420. * Gets the xyz component
  63421. */
  63422. get xyz(): NodeMaterialConnectionPoint;
  63423. /**
  63424. * Gets the xyzw component
  63425. */
  63426. get xyzw(): NodeMaterialConnectionPoint;
  63427. /**
  63428. * Gets the x component
  63429. */
  63430. get x(): NodeMaterialConnectionPoint;
  63431. /**
  63432. * Gets the y component
  63433. */
  63434. get y(): NodeMaterialConnectionPoint;
  63435. /**
  63436. * Gets the z component
  63437. */
  63438. get z(): NodeMaterialConnectionPoint;
  63439. /**
  63440. * Gets the w component
  63441. */
  63442. get output(): NodeMaterialConnectionPoint;
  63443. protected writeOutputs(state: NodeMaterialBuildState): string;
  63444. protected _buildBlock(state: NodeMaterialBuildState): this;
  63445. }
  63446. }
  63447. declare module BABYLON {
  63448. /**
  63449. * Block used to get the screen sizes
  63450. */
  63451. export class ScreenSizeBlock extends NodeMaterialBlock {
  63452. private _varName;
  63453. private _scene;
  63454. /**
  63455. * Creates a new ScreenSizeBlock
  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 xy component
  63466. */
  63467. get xy(): NodeMaterialConnectionPoint;
  63468. /**
  63469. * Gets the x component
  63470. */
  63471. get x(): NodeMaterialConnectionPoint;
  63472. /**
  63473. * Gets the y component
  63474. */
  63475. get y(): NodeMaterialConnectionPoint;
  63476. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63477. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63478. protected _buildBlock(state: NodeMaterialBuildState): this;
  63479. }
  63480. }
  63481. declare module BABYLON {
  63482. /**
  63483. * Block used to add support for scene fog
  63484. */
  63485. export class FogBlock extends NodeMaterialBlock {
  63486. private _fogDistanceName;
  63487. private _fogParameters;
  63488. /**
  63489. * Create a new FogBlock
  63490. * @param name defines the block name
  63491. */
  63492. constructor(name: string);
  63493. /**
  63494. * Gets the current class name
  63495. * @returns the class name
  63496. */
  63497. getClassName(): string;
  63498. /**
  63499. * Gets the world position input component
  63500. */
  63501. get worldPosition(): NodeMaterialConnectionPoint;
  63502. /**
  63503. * Gets the view input component
  63504. */
  63505. get view(): NodeMaterialConnectionPoint;
  63506. /**
  63507. * Gets the color input component
  63508. */
  63509. get input(): NodeMaterialConnectionPoint;
  63510. /**
  63511. * Gets the fog color input component
  63512. */
  63513. get fogColor(): NodeMaterialConnectionPoint;
  63514. /**
  63515. * Gets the output component
  63516. */
  63517. get output(): NodeMaterialConnectionPoint;
  63518. autoConfigure(material: NodeMaterial): void;
  63519. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63520. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63521. protected _buildBlock(state: NodeMaterialBuildState): this;
  63522. }
  63523. }
  63524. declare module BABYLON {
  63525. /**
  63526. * Block used to add light in the fragment shader
  63527. */
  63528. export class LightBlock extends NodeMaterialBlock {
  63529. private _lightId;
  63530. /**
  63531. * Gets or sets the light associated with this block
  63532. */
  63533. light: Nullable<Light>;
  63534. /**
  63535. * Create a new LightBlock
  63536. * @param name defines the block name
  63537. */
  63538. constructor(name: string);
  63539. /**
  63540. * Gets the current class name
  63541. * @returns the class name
  63542. */
  63543. getClassName(): string;
  63544. /**
  63545. * Gets the world position input component
  63546. */
  63547. get worldPosition(): NodeMaterialConnectionPoint;
  63548. /**
  63549. * Gets the world normal input component
  63550. */
  63551. get worldNormal(): NodeMaterialConnectionPoint;
  63552. /**
  63553. * Gets the camera (or eye) position component
  63554. */
  63555. get cameraPosition(): NodeMaterialConnectionPoint;
  63556. /**
  63557. * Gets the glossiness component
  63558. */
  63559. get glossiness(): NodeMaterialConnectionPoint;
  63560. /**
  63561. * Gets the glossinness power component
  63562. */
  63563. get glossPower(): NodeMaterialConnectionPoint;
  63564. /**
  63565. * Gets the diffuse color component
  63566. */
  63567. get diffuseColor(): NodeMaterialConnectionPoint;
  63568. /**
  63569. * Gets the specular color component
  63570. */
  63571. get specularColor(): NodeMaterialConnectionPoint;
  63572. /**
  63573. * Gets the diffuse output component
  63574. */
  63575. get diffuseOutput(): NodeMaterialConnectionPoint;
  63576. /**
  63577. * Gets the specular output component
  63578. */
  63579. get specularOutput(): NodeMaterialConnectionPoint;
  63580. /**
  63581. * Gets the shadow output component
  63582. */
  63583. get shadow(): NodeMaterialConnectionPoint;
  63584. autoConfigure(material: NodeMaterial): void;
  63585. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63586. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63587. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63588. private _injectVertexCode;
  63589. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63590. serialize(): any;
  63591. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63592. }
  63593. }
  63594. declare module BABYLON {
  63595. /**
  63596. * Block used to read a reflection texture from a sampler
  63597. */
  63598. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63599. /**
  63600. * Create a new ReflectionTextureBlock
  63601. * @param name defines the block name
  63602. */
  63603. constructor(name: string);
  63604. /**
  63605. * Gets the current class name
  63606. * @returns the class name
  63607. */
  63608. getClassName(): string;
  63609. /**
  63610. * Gets the world position input component
  63611. */
  63612. get position(): NodeMaterialConnectionPoint;
  63613. /**
  63614. * Gets the world position input component
  63615. */
  63616. get worldPosition(): NodeMaterialConnectionPoint;
  63617. /**
  63618. * Gets the world normal input component
  63619. */
  63620. get worldNormal(): NodeMaterialConnectionPoint;
  63621. /**
  63622. * Gets the world input component
  63623. */
  63624. get world(): NodeMaterialConnectionPoint;
  63625. /**
  63626. * Gets the camera (or eye) position component
  63627. */
  63628. get cameraPosition(): NodeMaterialConnectionPoint;
  63629. /**
  63630. * Gets the view input component
  63631. */
  63632. get view(): NodeMaterialConnectionPoint;
  63633. /**
  63634. * Gets the rgb output component
  63635. */
  63636. get rgb(): NodeMaterialConnectionPoint;
  63637. /**
  63638. * Gets the rgba output component
  63639. */
  63640. get rgba(): NodeMaterialConnectionPoint;
  63641. /**
  63642. * Gets the r output component
  63643. */
  63644. get r(): NodeMaterialConnectionPoint;
  63645. /**
  63646. * Gets the g output component
  63647. */
  63648. get g(): NodeMaterialConnectionPoint;
  63649. /**
  63650. * Gets the b output component
  63651. */
  63652. get b(): NodeMaterialConnectionPoint;
  63653. /**
  63654. * Gets the a output component
  63655. */
  63656. get a(): NodeMaterialConnectionPoint;
  63657. autoConfigure(material: NodeMaterial): void;
  63658. protected _buildBlock(state: NodeMaterialBuildState): this;
  63659. }
  63660. }
  63661. declare module BABYLON {
  63662. /**
  63663. * Block used to add 2 vectors
  63664. */
  63665. export class AddBlock extends NodeMaterialBlock {
  63666. /**
  63667. * Creates a new AddBlock
  63668. * @param name defines the block name
  63669. */
  63670. constructor(name: string);
  63671. /**
  63672. * Gets the current class name
  63673. * @returns the class name
  63674. */
  63675. getClassName(): string;
  63676. /**
  63677. * Gets the left operand input component
  63678. */
  63679. get left(): NodeMaterialConnectionPoint;
  63680. /**
  63681. * Gets the right operand input component
  63682. */
  63683. get right(): NodeMaterialConnectionPoint;
  63684. /**
  63685. * Gets the output component
  63686. */
  63687. get output(): NodeMaterialConnectionPoint;
  63688. protected _buildBlock(state: NodeMaterialBuildState): this;
  63689. }
  63690. }
  63691. declare module BABYLON {
  63692. /**
  63693. * Block used to scale a vector by a float
  63694. */
  63695. export class ScaleBlock extends NodeMaterialBlock {
  63696. /**
  63697. * Creates a new ScaleBlock
  63698. * @param name defines the block name
  63699. */
  63700. constructor(name: string);
  63701. /**
  63702. * Gets the current class name
  63703. * @returns the class name
  63704. */
  63705. getClassName(): string;
  63706. /**
  63707. * Gets the input component
  63708. */
  63709. get input(): NodeMaterialConnectionPoint;
  63710. /**
  63711. * Gets the factor input component
  63712. */
  63713. get factor(): NodeMaterialConnectionPoint;
  63714. /**
  63715. * Gets the output component
  63716. */
  63717. get output(): NodeMaterialConnectionPoint;
  63718. protected _buildBlock(state: NodeMaterialBuildState): this;
  63719. }
  63720. }
  63721. declare module BABYLON {
  63722. /**
  63723. * Block used to clamp a float
  63724. */
  63725. export class ClampBlock extends NodeMaterialBlock {
  63726. /** Gets or sets the minimum range */
  63727. minimum: number;
  63728. /** Gets or sets the maximum range */
  63729. maximum: number;
  63730. /**
  63731. * Creates a new ClampBlock
  63732. * @param name defines the block name
  63733. */
  63734. constructor(name: string);
  63735. /**
  63736. * Gets the current class name
  63737. * @returns the class name
  63738. */
  63739. getClassName(): string;
  63740. /**
  63741. * Gets the value input component
  63742. */
  63743. get value(): NodeMaterialConnectionPoint;
  63744. /**
  63745. * Gets the output component
  63746. */
  63747. get output(): NodeMaterialConnectionPoint;
  63748. protected _buildBlock(state: NodeMaterialBuildState): this;
  63749. protected _dumpPropertiesCode(): string;
  63750. serialize(): any;
  63751. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63752. }
  63753. }
  63754. declare module BABYLON {
  63755. /**
  63756. * Block used to apply a cross product between 2 vectors
  63757. */
  63758. export class CrossBlock extends NodeMaterialBlock {
  63759. /**
  63760. * Creates a new CrossBlock
  63761. * @param name defines the block name
  63762. */
  63763. constructor(name: string);
  63764. /**
  63765. * Gets the current class name
  63766. * @returns the class name
  63767. */
  63768. getClassName(): string;
  63769. /**
  63770. * Gets the left operand input component
  63771. */
  63772. get left(): NodeMaterialConnectionPoint;
  63773. /**
  63774. * Gets the right operand input component
  63775. */
  63776. get right(): NodeMaterialConnectionPoint;
  63777. /**
  63778. * Gets the output component
  63779. */
  63780. get output(): NodeMaterialConnectionPoint;
  63781. protected _buildBlock(state: NodeMaterialBuildState): this;
  63782. }
  63783. }
  63784. declare module BABYLON {
  63785. /**
  63786. * Block used to apply a dot product between 2 vectors
  63787. */
  63788. export class DotBlock extends NodeMaterialBlock {
  63789. /**
  63790. * Creates a new DotBlock
  63791. * @param name defines the block name
  63792. */
  63793. constructor(name: string);
  63794. /**
  63795. * Gets the current class name
  63796. * @returns the class name
  63797. */
  63798. getClassName(): string;
  63799. /**
  63800. * Gets the left operand input component
  63801. */
  63802. get left(): NodeMaterialConnectionPoint;
  63803. /**
  63804. * Gets the right operand input component
  63805. */
  63806. get right(): NodeMaterialConnectionPoint;
  63807. /**
  63808. * Gets the output component
  63809. */
  63810. get output(): NodeMaterialConnectionPoint;
  63811. protected _buildBlock(state: NodeMaterialBuildState): this;
  63812. }
  63813. }
  63814. declare module BABYLON {
  63815. /**
  63816. * Block used to normalize a vector
  63817. */
  63818. export class NormalizeBlock extends NodeMaterialBlock {
  63819. /**
  63820. * Creates a new NormalizeBlock
  63821. * @param name defines the block name
  63822. */
  63823. constructor(name: string);
  63824. /**
  63825. * Gets the current class name
  63826. * @returns the class name
  63827. */
  63828. getClassName(): string;
  63829. /**
  63830. * Gets the input component
  63831. */
  63832. get input(): NodeMaterialConnectionPoint;
  63833. /**
  63834. * Gets the output component
  63835. */
  63836. get output(): NodeMaterialConnectionPoint;
  63837. protected _buildBlock(state: NodeMaterialBuildState): this;
  63838. }
  63839. }
  63840. declare module BABYLON {
  63841. /**
  63842. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63843. */
  63844. export class ColorMergerBlock extends NodeMaterialBlock {
  63845. /**
  63846. * Create a new ColorMergerBlock
  63847. * @param name defines the block name
  63848. */
  63849. constructor(name: string);
  63850. /**
  63851. * Gets the current class name
  63852. * @returns the class name
  63853. */
  63854. getClassName(): string;
  63855. /**
  63856. * Gets the rgb component (input)
  63857. */
  63858. get rgbIn(): NodeMaterialConnectionPoint;
  63859. /**
  63860. * Gets the r component (input)
  63861. */
  63862. get r(): NodeMaterialConnectionPoint;
  63863. /**
  63864. * Gets the g component (input)
  63865. */
  63866. get g(): NodeMaterialConnectionPoint;
  63867. /**
  63868. * Gets the b component (input)
  63869. */
  63870. get b(): NodeMaterialConnectionPoint;
  63871. /**
  63872. * Gets the a component (input)
  63873. */
  63874. get a(): NodeMaterialConnectionPoint;
  63875. /**
  63876. * Gets the rgba component (output)
  63877. */
  63878. get rgba(): NodeMaterialConnectionPoint;
  63879. /**
  63880. * Gets the rgb component (output)
  63881. */
  63882. get rgbOut(): NodeMaterialConnectionPoint;
  63883. /**
  63884. * Gets the rgb component (output)
  63885. * @deprecated Please use rgbOut instead.
  63886. */
  63887. get rgb(): NodeMaterialConnectionPoint;
  63888. protected _buildBlock(state: NodeMaterialBuildState): this;
  63889. }
  63890. }
  63891. declare module BABYLON {
  63892. /**
  63893. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63894. */
  63895. export class VectorSplitterBlock extends NodeMaterialBlock {
  63896. /**
  63897. * Create a new VectorSplitterBlock
  63898. * @param name defines the block name
  63899. */
  63900. constructor(name: string);
  63901. /**
  63902. * Gets the current class name
  63903. * @returns the class name
  63904. */
  63905. getClassName(): string;
  63906. /**
  63907. * Gets the xyzw component (input)
  63908. */
  63909. get xyzw(): NodeMaterialConnectionPoint;
  63910. /**
  63911. * Gets the xyz component (input)
  63912. */
  63913. get xyzIn(): NodeMaterialConnectionPoint;
  63914. /**
  63915. * Gets the xy component (input)
  63916. */
  63917. get xyIn(): NodeMaterialConnectionPoint;
  63918. /**
  63919. * Gets the xyz component (output)
  63920. */
  63921. get xyzOut(): NodeMaterialConnectionPoint;
  63922. /**
  63923. * Gets the xy component (output)
  63924. */
  63925. get xyOut(): NodeMaterialConnectionPoint;
  63926. /**
  63927. * Gets the x component (output)
  63928. */
  63929. get x(): NodeMaterialConnectionPoint;
  63930. /**
  63931. * Gets the y component (output)
  63932. */
  63933. get y(): NodeMaterialConnectionPoint;
  63934. /**
  63935. * Gets the z component (output)
  63936. */
  63937. get z(): NodeMaterialConnectionPoint;
  63938. /**
  63939. * Gets the w component (output)
  63940. */
  63941. get w(): NodeMaterialConnectionPoint;
  63942. protected _inputRename(name: string): string;
  63943. protected _outputRename(name: string): string;
  63944. protected _buildBlock(state: NodeMaterialBuildState): this;
  63945. }
  63946. }
  63947. declare module BABYLON {
  63948. /**
  63949. * Block used to lerp between 2 values
  63950. */
  63951. export class LerpBlock extends NodeMaterialBlock {
  63952. /**
  63953. * Creates a new LerpBlock
  63954. * @param name defines the block name
  63955. */
  63956. constructor(name: string);
  63957. /**
  63958. * Gets the current class name
  63959. * @returns the class name
  63960. */
  63961. getClassName(): string;
  63962. /**
  63963. * Gets the left operand input component
  63964. */
  63965. get left(): NodeMaterialConnectionPoint;
  63966. /**
  63967. * Gets the right operand input component
  63968. */
  63969. get right(): NodeMaterialConnectionPoint;
  63970. /**
  63971. * Gets the gradient operand input component
  63972. */
  63973. get gradient(): NodeMaterialConnectionPoint;
  63974. /**
  63975. * Gets the output component
  63976. */
  63977. get output(): NodeMaterialConnectionPoint;
  63978. protected _buildBlock(state: NodeMaterialBuildState): this;
  63979. }
  63980. }
  63981. declare module BABYLON {
  63982. /**
  63983. * Block used to divide 2 vectors
  63984. */
  63985. export class DivideBlock extends NodeMaterialBlock {
  63986. /**
  63987. * Creates a new DivideBlock
  63988. * @param name defines the block name
  63989. */
  63990. constructor(name: string);
  63991. /**
  63992. * Gets the current class name
  63993. * @returns the class name
  63994. */
  63995. getClassName(): string;
  63996. /**
  63997. * Gets the left operand input component
  63998. */
  63999. get left(): NodeMaterialConnectionPoint;
  64000. /**
  64001. * Gets the right operand input component
  64002. */
  64003. get right(): NodeMaterialConnectionPoint;
  64004. /**
  64005. * Gets the output component
  64006. */
  64007. get output(): NodeMaterialConnectionPoint;
  64008. protected _buildBlock(state: NodeMaterialBuildState): this;
  64009. }
  64010. }
  64011. declare module BABYLON {
  64012. /**
  64013. * Block used to subtract 2 vectors
  64014. */
  64015. export class SubtractBlock extends NodeMaterialBlock {
  64016. /**
  64017. * Creates a new SubtractBlock
  64018. * @param name defines the block name
  64019. */
  64020. constructor(name: string);
  64021. /**
  64022. * Gets the current class name
  64023. * @returns the class name
  64024. */
  64025. getClassName(): string;
  64026. /**
  64027. * Gets the left operand input component
  64028. */
  64029. get left(): NodeMaterialConnectionPoint;
  64030. /**
  64031. * Gets the right operand input component
  64032. */
  64033. get right(): NodeMaterialConnectionPoint;
  64034. /**
  64035. * Gets the output component
  64036. */
  64037. get output(): NodeMaterialConnectionPoint;
  64038. protected _buildBlock(state: NodeMaterialBuildState): this;
  64039. }
  64040. }
  64041. declare module BABYLON {
  64042. /**
  64043. * Block used to step a value
  64044. */
  64045. export class StepBlock extends NodeMaterialBlock {
  64046. /**
  64047. * Creates a new StepBlock
  64048. * @param name defines the block name
  64049. */
  64050. constructor(name: string);
  64051. /**
  64052. * Gets the current class name
  64053. * @returns the class name
  64054. */
  64055. getClassName(): string;
  64056. /**
  64057. * Gets the value operand input component
  64058. */
  64059. get value(): NodeMaterialConnectionPoint;
  64060. /**
  64061. * Gets the edge operand input component
  64062. */
  64063. get edge(): NodeMaterialConnectionPoint;
  64064. /**
  64065. * Gets the output component
  64066. */
  64067. get output(): NodeMaterialConnectionPoint;
  64068. protected _buildBlock(state: NodeMaterialBuildState): this;
  64069. }
  64070. }
  64071. declare module BABYLON {
  64072. /**
  64073. * Block used to get the opposite (1 - x) of a value
  64074. */
  64075. export class OneMinusBlock extends NodeMaterialBlock {
  64076. /**
  64077. * Creates a new OneMinusBlock
  64078. * @param name defines the block name
  64079. */
  64080. constructor(name: string);
  64081. /**
  64082. * Gets the current class name
  64083. * @returns the class name
  64084. */
  64085. getClassName(): string;
  64086. /**
  64087. * Gets the input component
  64088. */
  64089. get input(): NodeMaterialConnectionPoint;
  64090. /**
  64091. * Gets the output component
  64092. */
  64093. get output(): NodeMaterialConnectionPoint;
  64094. protected _buildBlock(state: NodeMaterialBuildState): this;
  64095. }
  64096. }
  64097. declare module BABYLON {
  64098. /**
  64099. * Block used to get the view direction
  64100. */
  64101. export class ViewDirectionBlock extends NodeMaterialBlock {
  64102. /**
  64103. * Creates a new ViewDirectionBlock
  64104. * @param name defines the block name
  64105. */
  64106. constructor(name: string);
  64107. /**
  64108. * Gets the current class name
  64109. * @returns the class name
  64110. */
  64111. getClassName(): string;
  64112. /**
  64113. * Gets the world position component
  64114. */
  64115. get worldPosition(): NodeMaterialConnectionPoint;
  64116. /**
  64117. * Gets the camera position component
  64118. */
  64119. get cameraPosition(): NodeMaterialConnectionPoint;
  64120. /**
  64121. * Gets the output component
  64122. */
  64123. get output(): NodeMaterialConnectionPoint;
  64124. autoConfigure(material: NodeMaterial): void;
  64125. protected _buildBlock(state: NodeMaterialBuildState): this;
  64126. }
  64127. }
  64128. declare module BABYLON {
  64129. /**
  64130. * Block used to compute fresnel value
  64131. */
  64132. export class FresnelBlock extends NodeMaterialBlock {
  64133. /**
  64134. * Create a new FresnelBlock
  64135. * @param name defines the block name
  64136. */
  64137. constructor(name: string);
  64138. /**
  64139. * Gets the current class name
  64140. * @returns the class name
  64141. */
  64142. getClassName(): string;
  64143. /**
  64144. * Gets the world normal input component
  64145. */
  64146. get worldNormal(): NodeMaterialConnectionPoint;
  64147. /**
  64148. * Gets the view direction input component
  64149. */
  64150. get viewDirection(): NodeMaterialConnectionPoint;
  64151. /**
  64152. * Gets the bias input component
  64153. */
  64154. get bias(): NodeMaterialConnectionPoint;
  64155. /**
  64156. * Gets the camera (or eye) position component
  64157. */
  64158. get power(): NodeMaterialConnectionPoint;
  64159. /**
  64160. * Gets the fresnel output component
  64161. */
  64162. get fresnel(): NodeMaterialConnectionPoint;
  64163. autoConfigure(material: NodeMaterial): void;
  64164. protected _buildBlock(state: NodeMaterialBuildState): this;
  64165. }
  64166. }
  64167. declare module BABYLON {
  64168. /**
  64169. * Block used to get the max of 2 values
  64170. */
  64171. export class MaxBlock extends NodeMaterialBlock {
  64172. /**
  64173. * Creates a new MaxBlock
  64174. * @param name defines the block name
  64175. */
  64176. constructor(name: string);
  64177. /**
  64178. * Gets the current class name
  64179. * @returns the class name
  64180. */
  64181. getClassName(): string;
  64182. /**
  64183. * Gets the left operand input component
  64184. */
  64185. get left(): NodeMaterialConnectionPoint;
  64186. /**
  64187. * Gets the right operand input component
  64188. */
  64189. get right(): NodeMaterialConnectionPoint;
  64190. /**
  64191. * Gets the output component
  64192. */
  64193. get output(): NodeMaterialConnectionPoint;
  64194. protected _buildBlock(state: NodeMaterialBuildState): this;
  64195. }
  64196. }
  64197. declare module BABYLON {
  64198. /**
  64199. * Block used to get the min of 2 values
  64200. */
  64201. export class MinBlock extends NodeMaterialBlock {
  64202. /**
  64203. * Creates a new MinBlock
  64204. * @param name defines the block name
  64205. */
  64206. constructor(name: string);
  64207. /**
  64208. * Gets the current class name
  64209. * @returns the class name
  64210. */
  64211. getClassName(): string;
  64212. /**
  64213. * Gets the left operand input component
  64214. */
  64215. get left(): NodeMaterialConnectionPoint;
  64216. /**
  64217. * Gets the right operand input component
  64218. */
  64219. get right(): NodeMaterialConnectionPoint;
  64220. /**
  64221. * Gets the output component
  64222. */
  64223. get output(): NodeMaterialConnectionPoint;
  64224. protected _buildBlock(state: NodeMaterialBuildState): this;
  64225. }
  64226. }
  64227. declare module BABYLON {
  64228. /**
  64229. * Block used to get the distance between 2 values
  64230. */
  64231. export class DistanceBlock extends NodeMaterialBlock {
  64232. /**
  64233. * Creates a new DistanceBlock
  64234. * @param name defines the block name
  64235. */
  64236. constructor(name: string);
  64237. /**
  64238. * Gets the current class name
  64239. * @returns the class name
  64240. */
  64241. getClassName(): string;
  64242. /**
  64243. * Gets the left operand input component
  64244. */
  64245. get left(): NodeMaterialConnectionPoint;
  64246. /**
  64247. * Gets the right operand input component
  64248. */
  64249. get right(): NodeMaterialConnectionPoint;
  64250. /**
  64251. * Gets the output component
  64252. */
  64253. get output(): NodeMaterialConnectionPoint;
  64254. protected _buildBlock(state: NodeMaterialBuildState): this;
  64255. }
  64256. }
  64257. declare module BABYLON {
  64258. /**
  64259. * Block used to get the length of a vector
  64260. */
  64261. export class LengthBlock extends NodeMaterialBlock {
  64262. /**
  64263. * Creates a new LengthBlock
  64264. * @param name defines the block name
  64265. */
  64266. constructor(name: string);
  64267. /**
  64268. * Gets the current class name
  64269. * @returns the class name
  64270. */
  64271. getClassName(): string;
  64272. /**
  64273. * Gets the value input component
  64274. */
  64275. get value(): NodeMaterialConnectionPoint;
  64276. /**
  64277. * Gets the output component
  64278. */
  64279. get output(): NodeMaterialConnectionPoint;
  64280. protected _buildBlock(state: NodeMaterialBuildState): this;
  64281. }
  64282. }
  64283. declare module BABYLON {
  64284. /**
  64285. * Block used to get negative version of a value (i.e. x * -1)
  64286. */
  64287. export class NegateBlock extends NodeMaterialBlock {
  64288. /**
  64289. * Creates a new NegateBlock
  64290. * @param name defines the block name
  64291. */
  64292. constructor(name: string);
  64293. /**
  64294. * Gets the current class name
  64295. * @returns the class name
  64296. */
  64297. getClassName(): string;
  64298. /**
  64299. * Gets the value input component
  64300. */
  64301. get value(): NodeMaterialConnectionPoint;
  64302. /**
  64303. * Gets the output component
  64304. */
  64305. get output(): NodeMaterialConnectionPoint;
  64306. protected _buildBlock(state: NodeMaterialBuildState): this;
  64307. }
  64308. }
  64309. declare module BABYLON {
  64310. /**
  64311. * Block used to get the value of the first parameter raised to the power of the second
  64312. */
  64313. export class PowBlock extends NodeMaterialBlock {
  64314. /**
  64315. * Creates a new PowBlock
  64316. * @param name defines the block name
  64317. */
  64318. constructor(name: string);
  64319. /**
  64320. * Gets the current class name
  64321. * @returns the class name
  64322. */
  64323. getClassName(): string;
  64324. /**
  64325. * Gets the value operand input component
  64326. */
  64327. get value(): NodeMaterialConnectionPoint;
  64328. /**
  64329. * Gets the power operand input component
  64330. */
  64331. get power(): NodeMaterialConnectionPoint;
  64332. /**
  64333. * Gets the output component
  64334. */
  64335. get output(): NodeMaterialConnectionPoint;
  64336. protected _buildBlock(state: NodeMaterialBuildState): this;
  64337. }
  64338. }
  64339. declare module BABYLON {
  64340. /**
  64341. * Block used to get a random number
  64342. */
  64343. export class RandomNumberBlock extends NodeMaterialBlock {
  64344. /**
  64345. * Creates a new RandomNumberBlock
  64346. * @param name defines the block name
  64347. */
  64348. constructor(name: string);
  64349. /**
  64350. * Gets the current class name
  64351. * @returns the class name
  64352. */
  64353. getClassName(): string;
  64354. /**
  64355. * Gets the seed input component
  64356. */
  64357. get seed(): NodeMaterialConnectionPoint;
  64358. /**
  64359. * Gets the output component
  64360. */
  64361. get output(): NodeMaterialConnectionPoint;
  64362. protected _buildBlock(state: NodeMaterialBuildState): this;
  64363. }
  64364. }
  64365. declare module BABYLON {
  64366. /**
  64367. * Block used to compute arc tangent of 2 values
  64368. */
  64369. export class ArcTan2Block extends NodeMaterialBlock {
  64370. /**
  64371. * Creates a new ArcTan2Block
  64372. * @param name defines the block name
  64373. */
  64374. constructor(name: string);
  64375. /**
  64376. * Gets the current class name
  64377. * @returns the class name
  64378. */
  64379. getClassName(): string;
  64380. /**
  64381. * Gets the x operand input component
  64382. */
  64383. get x(): NodeMaterialConnectionPoint;
  64384. /**
  64385. * Gets the y operand input component
  64386. */
  64387. get y(): NodeMaterialConnectionPoint;
  64388. /**
  64389. * Gets the output component
  64390. */
  64391. get output(): NodeMaterialConnectionPoint;
  64392. protected _buildBlock(state: NodeMaterialBuildState): this;
  64393. }
  64394. }
  64395. declare module BABYLON {
  64396. /**
  64397. * Block used to smooth step a value
  64398. */
  64399. export class SmoothStepBlock extends NodeMaterialBlock {
  64400. /**
  64401. * Creates a new SmoothStepBlock
  64402. * @param name defines the block name
  64403. */
  64404. constructor(name: string);
  64405. /**
  64406. * Gets the current class name
  64407. * @returns the class name
  64408. */
  64409. getClassName(): string;
  64410. /**
  64411. * Gets the value operand input component
  64412. */
  64413. get value(): NodeMaterialConnectionPoint;
  64414. /**
  64415. * Gets the first edge operand input component
  64416. */
  64417. get edge0(): NodeMaterialConnectionPoint;
  64418. /**
  64419. * Gets the second edge operand input component
  64420. */
  64421. get edge1(): NodeMaterialConnectionPoint;
  64422. /**
  64423. * Gets the output component
  64424. */
  64425. get output(): NodeMaterialConnectionPoint;
  64426. protected _buildBlock(state: NodeMaterialBuildState): this;
  64427. }
  64428. }
  64429. declare module BABYLON {
  64430. /**
  64431. * Block used to get the reciprocal (1 / x) of a value
  64432. */
  64433. export class ReciprocalBlock extends NodeMaterialBlock {
  64434. /**
  64435. * Creates a new ReciprocalBlock
  64436. * @param name defines the block name
  64437. */
  64438. constructor(name: string);
  64439. /**
  64440. * Gets the current class name
  64441. * @returns the class name
  64442. */
  64443. getClassName(): string;
  64444. /**
  64445. * Gets the input component
  64446. */
  64447. get input(): NodeMaterialConnectionPoint;
  64448. /**
  64449. * Gets the output component
  64450. */
  64451. get output(): NodeMaterialConnectionPoint;
  64452. protected _buildBlock(state: NodeMaterialBuildState): this;
  64453. }
  64454. }
  64455. declare module BABYLON {
  64456. /**
  64457. * Block used to replace a color by another one
  64458. */
  64459. export class ReplaceColorBlock extends NodeMaterialBlock {
  64460. /**
  64461. * Creates a new ReplaceColorBlock
  64462. * @param name defines the block name
  64463. */
  64464. constructor(name: string);
  64465. /**
  64466. * Gets the current class name
  64467. * @returns the class name
  64468. */
  64469. getClassName(): string;
  64470. /**
  64471. * Gets the value input component
  64472. */
  64473. get value(): NodeMaterialConnectionPoint;
  64474. /**
  64475. * Gets the reference input component
  64476. */
  64477. get reference(): NodeMaterialConnectionPoint;
  64478. /**
  64479. * Gets the distance input component
  64480. */
  64481. get distance(): NodeMaterialConnectionPoint;
  64482. /**
  64483. * Gets the replacement input component
  64484. */
  64485. get replacement(): NodeMaterialConnectionPoint;
  64486. /**
  64487. * Gets the output component
  64488. */
  64489. get output(): NodeMaterialConnectionPoint;
  64490. protected _buildBlock(state: NodeMaterialBuildState): this;
  64491. }
  64492. }
  64493. declare module BABYLON {
  64494. /**
  64495. * Block used to posterize a value
  64496. * @see https://en.wikipedia.org/wiki/Posterization
  64497. */
  64498. export class PosterizeBlock extends NodeMaterialBlock {
  64499. /**
  64500. * Creates a new PosterizeBlock
  64501. * @param name defines the block name
  64502. */
  64503. constructor(name: string);
  64504. /**
  64505. * Gets the current class name
  64506. * @returns the class name
  64507. */
  64508. getClassName(): string;
  64509. /**
  64510. * Gets the value input component
  64511. */
  64512. get value(): NodeMaterialConnectionPoint;
  64513. /**
  64514. * Gets the steps input component
  64515. */
  64516. get steps(): NodeMaterialConnectionPoint;
  64517. /**
  64518. * Gets the output component
  64519. */
  64520. get output(): NodeMaterialConnectionPoint;
  64521. protected _buildBlock(state: NodeMaterialBuildState): this;
  64522. }
  64523. }
  64524. declare module BABYLON {
  64525. /**
  64526. * Operations supported by the Wave block
  64527. */
  64528. export enum WaveBlockKind {
  64529. /** SawTooth */
  64530. SawTooth = 0,
  64531. /** Square */
  64532. Square = 1,
  64533. /** Triangle */
  64534. Triangle = 2
  64535. }
  64536. /**
  64537. * Block used to apply wave operation to floats
  64538. */
  64539. export class WaveBlock extends NodeMaterialBlock {
  64540. /**
  64541. * Gets or sets the kibnd of wave to be applied by the block
  64542. */
  64543. kind: WaveBlockKind;
  64544. /**
  64545. * Creates a new WaveBlock
  64546. * @param name defines the block name
  64547. */
  64548. constructor(name: string);
  64549. /**
  64550. * Gets the current class name
  64551. * @returns the class name
  64552. */
  64553. getClassName(): string;
  64554. /**
  64555. * Gets the input component
  64556. */
  64557. get input(): NodeMaterialConnectionPoint;
  64558. /**
  64559. * Gets the output component
  64560. */
  64561. get output(): NodeMaterialConnectionPoint;
  64562. protected _buildBlock(state: NodeMaterialBuildState): this;
  64563. serialize(): any;
  64564. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64565. }
  64566. }
  64567. declare module BABYLON {
  64568. /**
  64569. * Class used to store a color step for the GradientBlock
  64570. */
  64571. export class GradientBlockColorStep {
  64572. private _step;
  64573. /**
  64574. * Gets value indicating which step this color is associated with (between 0 and 1)
  64575. */
  64576. get step(): number;
  64577. /**
  64578. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64579. */
  64580. set step(val: number);
  64581. private _color;
  64582. /**
  64583. * Gets the color associated with this step
  64584. */
  64585. get color(): Color3;
  64586. /**
  64587. * Sets the color associated with this step
  64588. */
  64589. set color(val: Color3);
  64590. /**
  64591. * Creates a new GradientBlockColorStep
  64592. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64593. * @param color defines the color associated with this step
  64594. */
  64595. constructor(step: number, color: Color3);
  64596. }
  64597. /**
  64598. * Block used to return a color from a gradient based on an input value between 0 and 1
  64599. */
  64600. export class GradientBlock extends NodeMaterialBlock {
  64601. /**
  64602. * Gets or sets the list of color steps
  64603. */
  64604. colorSteps: GradientBlockColorStep[];
  64605. /** Gets an observable raised when the value is changed */
  64606. onValueChangedObservable: Observable<GradientBlock>;
  64607. /** calls observable when the value is changed*/
  64608. colorStepsUpdated(): void;
  64609. /**
  64610. * Creates a new GradientBlock
  64611. * @param name defines the block name
  64612. */
  64613. constructor(name: string);
  64614. /**
  64615. * Gets the current class name
  64616. * @returns the class name
  64617. */
  64618. getClassName(): string;
  64619. /**
  64620. * Gets the gradient input component
  64621. */
  64622. get gradient(): NodeMaterialConnectionPoint;
  64623. /**
  64624. * Gets the output component
  64625. */
  64626. get output(): NodeMaterialConnectionPoint;
  64627. private _writeColorConstant;
  64628. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64629. serialize(): any;
  64630. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64631. protected _dumpPropertiesCode(): string;
  64632. }
  64633. }
  64634. declare module BABYLON {
  64635. /**
  64636. * Block used to normalize lerp between 2 values
  64637. */
  64638. export class NLerpBlock extends NodeMaterialBlock {
  64639. /**
  64640. * Creates a new NLerpBlock
  64641. * @param name defines the block name
  64642. */
  64643. constructor(name: string);
  64644. /**
  64645. * Gets the current class name
  64646. * @returns the class name
  64647. */
  64648. getClassName(): string;
  64649. /**
  64650. * Gets the left operand input component
  64651. */
  64652. get left(): NodeMaterialConnectionPoint;
  64653. /**
  64654. * Gets the right operand input component
  64655. */
  64656. get right(): NodeMaterialConnectionPoint;
  64657. /**
  64658. * Gets the gradient operand input component
  64659. */
  64660. get gradient(): NodeMaterialConnectionPoint;
  64661. /**
  64662. * Gets the output component
  64663. */
  64664. get output(): NodeMaterialConnectionPoint;
  64665. protected _buildBlock(state: NodeMaterialBuildState): this;
  64666. }
  64667. }
  64668. declare module BABYLON {
  64669. /**
  64670. * block used to Generate a Worley Noise 3D Noise Pattern
  64671. */
  64672. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64673. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64674. manhattanDistance: boolean;
  64675. /**
  64676. * Creates a new WorleyNoise3DBlock
  64677. * @param name defines the block name
  64678. */
  64679. constructor(name: string);
  64680. /**
  64681. * Gets the current class name
  64682. * @returns the class name
  64683. */
  64684. getClassName(): string;
  64685. /**
  64686. * Gets the seed input component
  64687. */
  64688. get seed(): NodeMaterialConnectionPoint;
  64689. /**
  64690. * Gets the jitter input component
  64691. */
  64692. get jitter(): NodeMaterialConnectionPoint;
  64693. /**
  64694. * Gets the output component
  64695. */
  64696. get output(): NodeMaterialConnectionPoint;
  64697. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64698. /**
  64699. * Exposes the properties to the UI?
  64700. */
  64701. protected _dumpPropertiesCode(): string;
  64702. /**
  64703. * Exposes the properties to the Seralize?
  64704. */
  64705. serialize(): any;
  64706. /**
  64707. * Exposes the properties to the deseralize?
  64708. */
  64709. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64710. }
  64711. }
  64712. declare module BABYLON {
  64713. /**
  64714. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64715. */
  64716. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64717. /**
  64718. * Creates a new SimplexPerlin3DBlock
  64719. * @param name defines the block name
  64720. */
  64721. constructor(name: string);
  64722. /**
  64723. * Gets the current class name
  64724. * @returns the class name
  64725. */
  64726. getClassName(): string;
  64727. /**
  64728. * Gets the seed operand input component
  64729. */
  64730. get seed(): NodeMaterialConnectionPoint;
  64731. /**
  64732. * Gets the output component
  64733. */
  64734. get output(): NodeMaterialConnectionPoint;
  64735. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64736. }
  64737. }
  64738. declare module BABYLON {
  64739. /**
  64740. * Block used to blend normals
  64741. */
  64742. export class NormalBlendBlock extends NodeMaterialBlock {
  64743. /**
  64744. * Creates a new NormalBlendBlock
  64745. * @param name defines the block name
  64746. */
  64747. constructor(name: string);
  64748. /**
  64749. * Gets the current class name
  64750. * @returns the class name
  64751. */
  64752. getClassName(): string;
  64753. /**
  64754. * Gets the first input component
  64755. */
  64756. get normalMap0(): NodeMaterialConnectionPoint;
  64757. /**
  64758. * Gets the second input component
  64759. */
  64760. get normalMap1(): NodeMaterialConnectionPoint;
  64761. /**
  64762. * Gets the output component
  64763. */
  64764. get output(): NodeMaterialConnectionPoint;
  64765. protected _buildBlock(state: NodeMaterialBuildState): this;
  64766. }
  64767. }
  64768. declare module BABYLON {
  64769. /**
  64770. * Block used to rotate a 2d vector by a given angle
  64771. */
  64772. export class Rotate2dBlock extends NodeMaterialBlock {
  64773. /**
  64774. * Creates a new Rotate2dBlock
  64775. * @param name defines the block name
  64776. */
  64777. constructor(name: string);
  64778. /**
  64779. * Gets the current class name
  64780. * @returns the class name
  64781. */
  64782. getClassName(): string;
  64783. /**
  64784. * Gets the input vector
  64785. */
  64786. get input(): NodeMaterialConnectionPoint;
  64787. /**
  64788. * Gets the input angle
  64789. */
  64790. get angle(): NodeMaterialConnectionPoint;
  64791. /**
  64792. * Gets the output component
  64793. */
  64794. get output(): NodeMaterialConnectionPoint;
  64795. autoConfigure(material: NodeMaterial): void;
  64796. protected _buildBlock(state: NodeMaterialBuildState): this;
  64797. }
  64798. }
  64799. declare module BABYLON {
  64800. /**
  64801. * Block used to get the reflected vector from a direction and a normal
  64802. */
  64803. export class ReflectBlock extends NodeMaterialBlock {
  64804. /**
  64805. * Creates a new ReflectBlock
  64806. * @param name defines the block name
  64807. */
  64808. constructor(name: string);
  64809. /**
  64810. * Gets the current class name
  64811. * @returns the class name
  64812. */
  64813. getClassName(): string;
  64814. /**
  64815. * Gets the incident component
  64816. */
  64817. get incident(): NodeMaterialConnectionPoint;
  64818. /**
  64819. * Gets the normal component
  64820. */
  64821. get normal(): NodeMaterialConnectionPoint;
  64822. /**
  64823. * Gets the output component
  64824. */
  64825. get output(): NodeMaterialConnectionPoint;
  64826. protected _buildBlock(state: NodeMaterialBuildState): this;
  64827. }
  64828. }
  64829. declare module BABYLON {
  64830. /**
  64831. * Block used to get the refracted vector from a direction and a normal
  64832. */
  64833. export class RefractBlock extends NodeMaterialBlock {
  64834. /**
  64835. * Creates a new RefractBlock
  64836. * @param name defines the block name
  64837. */
  64838. constructor(name: string);
  64839. /**
  64840. * Gets the current class name
  64841. * @returns the class name
  64842. */
  64843. getClassName(): string;
  64844. /**
  64845. * Gets the incident component
  64846. */
  64847. get incident(): NodeMaterialConnectionPoint;
  64848. /**
  64849. * Gets the normal component
  64850. */
  64851. get normal(): NodeMaterialConnectionPoint;
  64852. /**
  64853. * Gets the index of refraction component
  64854. */
  64855. get ior(): NodeMaterialConnectionPoint;
  64856. /**
  64857. * Gets the output component
  64858. */
  64859. get output(): NodeMaterialConnectionPoint;
  64860. protected _buildBlock(state: NodeMaterialBuildState): this;
  64861. }
  64862. }
  64863. declare module BABYLON {
  64864. /**
  64865. * Block used to desaturate a color
  64866. */
  64867. export class DesaturateBlock extends NodeMaterialBlock {
  64868. /**
  64869. * Creates a new DesaturateBlock
  64870. * @param name defines the block name
  64871. */
  64872. constructor(name: string);
  64873. /**
  64874. * Gets the current class name
  64875. * @returns the class name
  64876. */
  64877. getClassName(): string;
  64878. /**
  64879. * Gets the color operand input component
  64880. */
  64881. get color(): NodeMaterialConnectionPoint;
  64882. /**
  64883. * Gets the level operand input component
  64884. */
  64885. get level(): NodeMaterialConnectionPoint;
  64886. /**
  64887. * Gets the output component
  64888. */
  64889. get output(): NodeMaterialConnectionPoint;
  64890. protected _buildBlock(state: NodeMaterialBuildState): this;
  64891. }
  64892. }
  64893. declare module BABYLON {
  64894. /**
  64895. * Block used to implement the ambient occlusion module of the PBR material
  64896. */
  64897. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64898. /**
  64899. * Create a new AmbientOcclusionBlock
  64900. * @param name defines the block name
  64901. */
  64902. constructor(name: string);
  64903. /**
  64904. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64905. */
  64906. useAmbientInGrayScale: boolean;
  64907. /**
  64908. * Initialize the block and prepare the context for build
  64909. * @param state defines the state that will be used for the build
  64910. */
  64911. initialize(state: NodeMaterialBuildState): void;
  64912. /**
  64913. * Gets the current class name
  64914. * @returns the class name
  64915. */
  64916. getClassName(): string;
  64917. /**
  64918. * Gets the texture input component
  64919. */
  64920. get texture(): NodeMaterialConnectionPoint;
  64921. /**
  64922. * Gets the texture intensity component
  64923. */
  64924. get intensity(): NodeMaterialConnectionPoint;
  64925. /**
  64926. * Gets the direct light intensity input component
  64927. */
  64928. get directLightIntensity(): NodeMaterialConnectionPoint;
  64929. /**
  64930. * Gets the ambient occlusion object output component
  64931. */
  64932. get ambientOcc(): NodeMaterialConnectionPoint;
  64933. /**
  64934. * Gets the main code of the block (fragment side)
  64935. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64936. * @returns the shader code
  64937. */
  64938. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64939. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64940. protected _buildBlock(state: NodeMaterialBuildState): this;
  64941. protected _dumpPropertiesCode(): string;
  64942. serialize(): any;
  64943. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64944. }
  64945. }
  64946. declare module BABYLON {
  64947. /**
  64948. * Block used to implement the reflection module of the PBR material
  64949. */
  64950. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64951. /** @hidden */
  64952. _defineLODReflectionAlpha: string;
  64953. /** @hidden */
  64954. _defineLinearSpecularReflection: string;
  64955. private _vEnvironmentIrradianceName;
  64956. /** @hidden */
  64957. _vReflectionMicrosurfaceInfosName: string;
  64958. /** @hidden */
  64959. _vReflectionInfosName: string;
  64960. /** @hidden */
  64961. _vReflectionFilteringInfoName: string;
  64962. private _scene;
  64963. /**
  64964. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64965. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64966. * It's less burden on the user side in the editor part.
  64967. */
  64968. /** @hidden */
  64969. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64970. /** @hidden */
  64971. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64972. /** @hidden */
  64973. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64974. /**
  64975. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64976. * diffuse part of the IBL.
  64977. */
  64978. useSphericalHarmonics: boolean;
  64979. /**
  64980. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64981. */
  64982. forceIrradianceInFragment: boolean;
  64983. /**
  64984. * Create a new ReflectionBlock
  64985. * @param name defines the block name
  64986. */
  64987. constructor(name: string);
  64988. /**
  64989. * Gets the current class name
  64990. * @returns the class name
  64991. */
  64992. getClassName(): string;
  64993. /**
  64994. * Gets the position input component
  64995. */
  64996. get position(): NodeMaterialConnectionPoint;
  64997. /**
  64998. * Gets the world position input component
  64999. */
  65000. get worldPosition(): NodeMaterialConnectionPoint;
  65001. /**
  65002. * Gets the world normal input component
  65003. */
  65004. get worldNormal(): NodeMaterialConnectionPoint;
  65005. /**
  65006. * Gets the world input component
  65007. */
  65008. get world(): NodeMaterialConnectionPoint;
  65009. /**
  65010. * Gets the camera (or eye) position component
  65011. */
  65012. get cameraPosition(): NodeMaterialConnectionPoint;
  65013. /**
  65014. * Gets the view input component
  65015. */
  65016. get view(): NodeMaterialConnectionPoint;
  65017. /**
  65018. * Gets the color input component
  65019. */
  65020. get color(): NodeMaterialConnectionPoint;
  65021. /**
  65022. * Gets the reflection object output component
  65023. */
  65024. get reflection(): NodeMaterialConnectionPoint;
  65025. /**
  65026. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65027. */
  65028. get hasTexture(): boolean;
  65029. /**
  65030. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65031. */
  65032. get reflectionColor(): string;
  65033. protected _getTexture(): Nullable<BaseTexture>;
  65034. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65035. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65036. /**
  65037. * Gets the code to inject in the vertex shader
  65038. * @param state current state of the node material building
  65039. * @returns the shader code
  65040. */
  65041. handleVertexSide(state: NodeMaterialBuildState): string;
  65042. /**
  65043. * Gets the main code of the block (fragment side)
  65044. * @param state current state of the node material building
  65045. * @param normalVarName name of the existing variable corresponding to the normal
  65046. * @returns the shader code
  65047. */
  65048. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65049. protected _buildBlock(state: NodeMaterialBuildState): this;
  65050. protected _dumpPropertiesCode(): string;
  65051. serialize(): any;
  65052. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65053. }
  65054. }
  65055. declare module BABYLON {
  65056. /**
  65057. * Block used to implement the sheen module of the PBR material
  65058. */
  65059. export class SheenBlock extends NodeMaterialBlock {
  65060. /**
  65061. * Create a new SheenBlock
  65062. * @param name defines the block name
  65063. */
  65064. constructor(name: string);
  65065. /**
  65066. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65067. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65068. * making it easier to setup and tweak the effect
  65069. */
  65070. albedoScaling: boolean;
  65071. /**
  65072. * Defines if the sheen is linked to the sheen color.
  65073. */
  65074. linkSheenWithAlbedo: boolean;
  65075. /**
  65076. * Initialize the block and prepare the context for build
  65077. * @param state defines the state that will be used for the build
  65078. */
  65079. initialize(state: NodeMaterialBuildState): void;
  65080. /**
  65081. * Gets the current class name
  65082. * @returns the class name
  65083. */
  65084. getClassName(): string;
  65085. /**
  65086. * Gets the intensity input component
  65087. */
  65088. get intensity(): NodeMaterialConnectionPoint;
  65089. /**
  65090. * Gets the color input component
  65091. */
  65092. get color(): NodeMaterialConnectionPoint;
  65093. /**
  65094. * Gets the roughness input component
  65095. */
  65096. get roughness(): NodeMaterialConnectionPoint;
  65097. /**
  65098. * Gets the sheen object output component
  65099. */
  65100. get sheen(): NodeMaterialConnectionPoint;
  65101. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65102. /**
  65103. * Gets the main code of the block (fragment side)
  65104. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65105. * @returns the shader code
  65106. */
  65107. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65108. protected _buildBlock(state: NodeMaterialBuildState): this;
  65109. protected _dumpPropertiesCode(): string;
  65110. serialize(): any;
  65111. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65112. }
  65113. }
  65114. declare module BABYLON {
  65115. /**
  65116. * Block used to implement the reflectivity module of the PBR material
  65117. */
  65118. export class ReflectivityBlock extends NodeMaterialBlock {
  65119. private _metallicReflectanceColor;
  65120. private _metallicF0Factor;
  65121. /** @hidden */
  65122. _vMetallicReflectanceFactorsName: string;
  65123. /**
  65124. * The property below is set by the main PBR block prior to calling methods of this class.
  65125. */
  65126. /** @hidden */
  65127. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  65128. /**
  65129. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65130. */
  65131. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65132. /**
  65133. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65134. */
  65135. useMetallnessFromMetallicTextureBlue: boolean;
  65136. /**
  65137. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65138. */
  65139. useRoughnessFromMetallicTextureAlpha: boolean;
  65140. /**
  65141. * Specifies if the metallic texture contains the roughness information in its green channel.
  65142. */
  65143. useRoughnessFromMetallicTextureGreen: boolean;
  65144. /**
  65145. * Create a new ReflectivityBlock
  65146. * @param name defines the block name
  65147. */
  65148. constructor(name: string);
  65149. /**
  65150. * Initialize the block and prepare the context for build
  65151. * @param state defines the state that will be used for the build
  65152. */
  65153. initialize(state: NodeMaterialBuildState): void;
  65154. /**
  65155. * Gets the current class name
  65156. * @returns the class name
  65157. */
  65158. getClassName(): string;
  65159. /**
  65160. * Gets the metallic input component
  65161. */
  65162. get metallic(): NodeMaterialConnectionPoint;
  65163. /**
  65164. * Gets the roughness input component
  65165. */
  65166. get roughness(): NodeMaterialConnectionPoint;
  65167. /**
  65168. * Gets the texture input component
  65169. */
  65170. get texture(): NodeMaterialConnectionPoint;
  65171. /**
  65172. * Gets the reflectivity object output component
  65173. */
  65174. get reflectivity(): NodeMaterialConnectionPoint;
  65175. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65176. /**
  65177. * Gets the main code of the block (fragment side)
  65178. * @param state current state of the node material building
  65179. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65180. * @returns the shader code
  65181. */
  65182. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  65183. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65184. protected _buildBlock(state: NodeMaterialBuildState): this;
  65185. protected _dumpPropertiesCode(): string;
  65186. serialize(): any;
  65187. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65188. }
  65189. }
  65190. declare module BABYLON {
  65191. /**
  65192. * Block used to implement the anisotropy module of the PBR material
  65193. */
  65194. export class AnisotropyBlock extends NodeMaterialBlock {
  65195. /**
  65196. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65197. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65198. * It's less burden on the user side in the editor part.
  65199. */
  65200. /** @hidden */
  65201. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65202. /** @hidden */
  65203. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65204. /**
  65205. * Create a new AnisotropyBlock
  65206. * @param name defines the block name
  65207. */
  65208. constructor(name: string);
  65209. /**
  65210. * Initialize the block and prepare the context for build
  65211. * @param state defines the state that will be used for the build
  65212. */
  65213. initialize(state: NodeMaterialBuildState): void;
  65214. /**
  65215. * Gets the current class name
  65216. * @returns the class name
  65217. */
  65218. getClassName(): string;
  65219. /**
  65220. * Gets the intensity input component
  65221. */
  65222. get intensity(): NodeMaterialConnectionPoint;
  65223. /**
  65224. * Gets the direction input component
  65225. */
  65226. get direction(): NodeMaterialConnectionPoint;
  65227. /**
  65228. * Gets the texture input component
  65229. */
  65230. get texture(): NodeMaterialConnectionPoint;
  65231. /**
  65232. * Gets the uv input component
  65233. */
  65234. get uv(): NodeMaterialConnectionPoint;
  65235. /**
  65236. * Gets the worldTangent input component
  65237. */
  65238. get worldTangent(): NodeMaterialConnectionPoint;
  65239. /**
  65240. * Gets the anisotropy object output component
  65241. */
  65242. get anisotropy(): NodeMaterialConnectionPoint;
  65243. private _generateTBNSpace;
  65244. /**
  65245. * Gets the main code of the block (fragment side)
  65246. * @param state current state of the node material building
  65247. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65248. * @returns the shader code
  65249. */
  65250. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65251. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65252. protected _buildBlock(state: NodeMaterialBuildState): this;
  65253. }
  65254. }
  65255. declare module BABYLON {
  65256. /**
  65257. * Block used to implement the clear coat module of the PBR material
  65258. */
  65259. export class ClearCoatBlock extends NodeMaterialBlock {
  65260. private _scene;
  65261. /**
  65262. * Create a new ClearCoatBlock
  65263. * @param name defines the block name
  65264. */
  65265. constructor(name: string);
  65266. /**
  65267. * Initialize the block and prepare the context for build
  65268. * @param state defines the state that will be used for the build
  65269. */
  65270. initialize(state: NodeMaterialBuildState): void;
  65271. /**
  65272. * Gets the current class name
  65273. * @returns the class name
  65274. */
  65275. getClassName(): string;
  65276. /**
  65277. * Gets the intensity input component
  65278. */
  65279. get intensity(): NodeMaterialConnectionPoint;
  65280. /**
  65281. * Gets the roughness input component
  65282. */
  65283. get roughness(): NodeMaterialConnectionPoint;
  65284. /**
  65285. * Gets the ior input component
  65286. */
  65287. get ior(): NodeMaterialConnectionPoint;
  65288. /**
  65289. * Gets the texture input component
  65290. */
  65291. get texture(): NodeMaterialConnectionPoint;
  65292. /**
  65293. * Gets the bump texture input component
  65294. */
  65295. get bumpTexture(): NodeMaterialConnectionPoint;
  65296. /**
  65297. * Gets the uv input component
  65298. */
  65299. get uv(): NodeMaterialConnectionPoint;
  65300. /**
  65301. * Gets the tint color input component
  65302. */
  65303. get tintColor(): NodeMaterialConnectionPoint;
  65304. /**
  65305. * Gets the tint "at distance" input component
  65306. */
  65307. get tintAtDistance(): NodeMaterialConnectionPoint;
  65308. /**
  65309. * Gets the tint thickness input component
  65310. */
  65311. get tintThickness(): NodeMaterialConnectionPoint;
  65312. /**
  65313. * Gets the world tangent input component
  65314. */
  65315. get worldTangent(): NodeMaterialConnectionPoint;
  65316. /**
  65317. * Gets the clear coat object output component
  65318. */
  65319. get clearcoat(): NodeMaterialConnectionPoint;
  65320. autoConfigure(material: NodeMaterial): void;
  65321. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65322. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65323. private _generateTBNSpace;
  65324. /**
  65325. * Gets the main code of the block (fragment side)
  65326. * @param state current state of the node material building
  65327. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65328. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65329. * @param worldPosVarName name of the variable holding the world position
  65330. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65331. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65332. * @param worldNormalVarName name of the variable holding the world normal
  65333. * @returns the shader code
  65334. */
  65335. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65336. protected _buildBlock(state: NodeMaterialBuildState): this;
  65337. }
  65338. }
  65339. declare module BABYLON {
  65340. /**
  65341. * Block used to implement the sub surface module of the PBR material
  65342. */
  65343. export class SubSurfaceBlock extends NodeMaterialBlock {
  65344. /**
  65345. * Create a new SubSurfaceBlock
  65346. * @param name defines the block name
  65347. */
  65348. constructor(name: string);
  65349. /**
  65350. * Stores the intensity of the different subsurface effects in the thickness texture.
  65351. * * the green channel is the translucency intensity.
  65352. * * the blue channel is the scattering intensity.
  65353. * * the alpha channel is the refraction intensity.
  65354. */
  65355. useMaskFromThicknessTexture: boolean;
  65356. /**
  65357. * Initialize the block and prepare the context for build
  65358. * @param state defines the state that will be used for the build
  65359. */
  65360. initialize(state: NodeMaterialBuildState): void;
  65361. /**
  65362. * Gets the current class name
  65363. * @returns the class name
  65364. */
  65365. getClassName(): string;
  65366. /**
  65367. * Gets the min thickness input component
  65368. */
  65369. get minThickness(): NodeMaterialConnectionPoint;
  65370. /**
  65371. * Gets the max thickness input component
  65372. */
  65373. get maxThickness(): NodeMaterialConnectionPoint;
  65374. /**
  65375. * Gets the thickness texture component
  65376. */
  65377. get thicknessTexture(): NodeMaterialConnectionPoint;
  65378. /**
  65379. * Gets the tint color input component
  65380. */
  65381. get tintColor(): NodeMaterialConnectionPoint;
  65382. /**
  65383. * Gets the translucency intensity input component
  65384. */
  65385. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65386. /**
  65387. * Gets the translucency diffusion distance input component
  65388. */
  65389. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65390. /**
  65391. * Gets the refraction object parameters
  65392. */
  65393. get refraction(): NodeMaterialConnectionPoint;
  65394. /**
  65395. * Gets the sub surface object output component
  65396. */
  65397. get subsurface(): NodeMaterialConnectionPoint;
  65398. autoConfigure(material: NodeMaterial): void;
  65399. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65400. /**
  65401. * Gets the main code of the block (fragment side)
  65402. * @param state current state of the node material building
  65403. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65404. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65405. * @param worldPosVarName name of the variable holding the world position
  65406. * @returns the shader code
  65407. */
  65408. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65409. protected _buildBlock(state: NodeMaterialBuildState): this;
  65410. }
  65411. }
  65412. declare module BABYLON {
  65413. /**
  65414. * Block used to implement the PBR metallic/roughness model
  65415. */
  65416. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65417. /**
  65418. * Gets or sets the light associated with this block
  65419. */
  65420. light: Nullable<Light>;
  65421. private _lightId;
  65422. private _scene;
  65423. private _environmentBRDFTexture;
  65424. private _environmentBrdfSamplerName;
  65425. private _vNormalWName;
  65426. private _invertNormalName;
  65427. /**
  65428. * Create a new ReflectionBlock
  65429. * @param name defines the block name
  65430. */
  65431. constructor(name: string);
  65432. /**
  65433. * Intensity of the direct lights e.g. the four lights available in your scene.
  65434. * This impacts both the direct diffuse and specular highlights.
  65435. */
  65436. directIntensity: number;
  65437. /**
  65438. * Intensity of the environment e.g. how much the environment will light the object
  65439. * either through harmonics for rough material or through the refelction for shiny ones.
  65440. */
  65441. environmentIntensity: number;
  65442. /**
  65443. * This is a special control allowing the reduction of the specular highlights coming from the
  65444. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65445. */
  65446. specularIntensity: number;
  65447. /**
  65448. * Defines the falloff type used in this material.
  65449. * It by default is Physical.
  65450. */
  65451. lightFalloff: number;
  65452. /**
  65453. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65454. */
  65455. useAlphaFromAlbedoTexture: boolean;
  65456. /**
  65457. * Specifies that alpha test should be used
  65458. */
  65459. useAlphaTest: boolean;
  65460. /**
  65461. * Defines the alpha limits in alpha test mode.
  65462. */
  65463. alphaTestCutoff: number;
  65464. /**
  65465. * Specifies that alpha blending should be used
  65466. */
  65467. useAlphaBlending: boolean;
  65468. /**
  65469. * Defines if the alpha value should be determined via the rgb values.
  65470. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65471. */
  65472. opacityRGB: boolean;
  65473. /**
  65474. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65475. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65476. */
  65477. useRadianceOverAlpha: boolean;
  65478. /**
  65479. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65480. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65481. */
  65482. useSpecularOverAlpha: boolean;
  65483. /**
  65484. * Enables specular anti aliasing in the PBR shader.
  65485. * It will both interacts on the Geometry for analytical and IBL lighting.
  65486. * It also prefilter the roughness map based on the bump values.
  65487. */
  65488. enableSpecularAntiAliasing: boolean;
  65489. /**
  65490. * Enables realtime filtering on the texture.
  65491. */
  65492. realTimeFiltering: boolean;
  65493. /**
  65494. * Quality switch for realtime filtering
  65495. */
  65496. realTimeFilteringQuality: number;
  65497. /**
  65498. * Defines if the material uses energy conservation.
  65499. */
  65500. useEnergyConservation: boolean;
  65501. /**
  65502. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65503. * too much the area relying on ambient texture to define their ambient occlusion.
  65504. */
  65505. useRadianceOcclusion: boolean;
  65506. /**
  65507. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65508. * makes the reflect vector face the model (under horizon).
  65509. */
  65510. useHorizonOcclusion: boolean;
  65511. /**
  65512. * If set to true, no lighting calculations will be applied.
  65513. */
  65514. unlit: boolean;
  65515. /**
  65516. * Force normal to face away from face.
  65517. */
  65518. forceNormalForward: boolean;
  65519. /**
  65520. * Defines the material debug mode.
  65521. * It helps seeing only some components of the material while troubleshooting.
  65522. */
  65523. debugMode: number;
  65524. /**
  65525. * Specify from where on screen the debug mode should start.
  65526. * The value goes from -1 (full screen) to 1 (not visible)
  65527. * It helps with side by side comparison against the final render
  65528. * This defaults to 0
  65529. */
  65530. debugLimit: number;
  65531. /**
  65532. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65533. * You can use the factor to better multiply the final value.
  65534. */
  65535. debugFactor: number;
  65536. /**
  65537. * Initialize the block and prepare the context for build
  65538. * @param state defines the state that will be used for the build
  65539. */
  65540. initialize(state: NodeMaterialBuildState): void;
  65541. /**
  65542. * Gets the current class name
  65543. * @returns the class name
  65544. */
  65545. getClassName(): string;
  65546. /**
  65547. * Gets the world position input component
  65548. */
  65549. get worldPosition(): NodeMaterialConnectionPoint;
  65550. /**
  65551. * Gets the world normal input component
  65552. */
  65553. get worldNormal(): NodeMaterialConnectionPoint;
  65554. /**
  65555. * Gets the perturbed normal input component
  65556. */
  65557. get perturbedNormal(): NodeMaterialConnectionPoint;
  65558. /**
  65559. * Gets the camera position input component
  65560. */
  65561. get cameraPosition(): NodeMaterialConnectionPoint;
  65562. /**
  65563. * Gets the base color input component
  65564. */
  65565. get baseColor(): NodeMaterialConnectionPoint;
  65566. /**
  65567. * Gets the opacity texture input component
  65568. */
  65569. get opacityTexture(): NodeMaterialConnectionPoint;
  65570. /**
  65571. * Gets the ambient color input component
  65572. */
  65573. get ambientColor(): NodeMaterialConnectionPoint;
  65574. /**
  65575. * Gets the reflectivity object parameters
  65576. */
  65577. get reflectivity(): NodeMaterialConnectionPoint;
  65578. /**
  65579. * Gets the ambient occlusion object parameters
  65580. */
  65581. get ambientOcc(): NodeMaterialConnectionPoint;
  65582. /**
  65583. * Gets the reflection object parameters
  65584. */
  65585. get reflection(): NodeMaterialConnectionPoint;
  65586. /**
  65587. * Gets the sheen object parameters
  65588. */
  65589. get sheen(): NodeMaterialConnectionPoint;
  65590. /**
  65591. * Gets the clear coat object parameters
  65592. */
  65593. get clearcoat(): NodeMaterialConnectionPoint;
  65594. /**
  65595. * Gets the sub surface object parameters
  65596. */
  65597. get subsurface(): NodeMaterialConnectionPoint;
  65598. /**
  65599. * Gets the anisotropy object parameters
  65600. */
  65601. get anisotropy(): NodeMaterialConnectionPoint;
  65602. /**
  65603. * Gets the ambient output component
  65604. */
  65605. get ambient(): NodeMaterialConnectionPoint;
  65606. /**
  65607. * Gets the diffuse output component
  65608. */
  65609. get diffuse(): NodeMaterialConnectionPoint;
  65610. /**
  65611. * Gets the specular output component
  65612. */
  65613. get specular(): NodeMaterialConnectionPoint;
  65614. /**
  65615. * Gets the sheen output component
  65616. */
  65617. get sheenDir(): NodeMaterialConnectionPoint;
  65618. /**
  65619. * Gets the clear coat output component
  65620. */
  65621. get clearcoatDir(): NodeMaterialConnectionPoint;
  65622. /**
  65623. * Gets the indirect diffuse output component
  65624. */
  65625. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65626. /**
  65627. * Gets the indirect specular output component
  65628. */
  65629. get specularIndirect(): NodeMaterialConnectionPoint;
  65630. /**
  65631. * Gets the indirect sheen output component
  65632. */
  65633. get sheenIndirect(): NodeMaterialConnectionPoint;
  65634. /**
  65635. * Gets the indirect clear coat output component
  65636. */
  65637. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65638. /**
  65639. * Gets the refraction output component
  65640. */
  65641. get refraction(): NodeMaterialConnectionPoint;
  65642. /**
  65643. * Gets the global lighting output component
  65644. */
  65645. get lighting(): NodeMaterialConnectionPoint;
  65646. /**
  65647. * Gets the shadow output component
  65648. */
  65649. get shadow(): NodeMaterialConnectionPoint;
  65650. /**
  65651. * Gets the alpha output component
  65652. */
  65653. get alpha(): NodeMaterialConnectionPoint;
  65654. autoConfigure(material: NodeMaterial): void;
  65655. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65656. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65657. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65658. private _injectVertexCode;
  65659. /**
  65660. * Gets the code corresponding to the albedo/opacity module
  65661. * @returns the shader code
  65662. */
  65663. getAlbedoOpacityCode(): string;
  65664. protected _buildBlock(state: NodeMaterialBuildState): this;
  65665. protected _dumpPropertiesCode(): string;
  65666. serialize(): any;
  65667. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65668. }
  65669. }
  65670. declare module BABYLON {
  65671. /**
  65672. * Block used to compute value of one parameter modulo another
  65673. */
  65674. export class ModBlock extends NodeMaterialBlock {
  65675. /**
  65676. * Creates a new ModBlock
  65677. * @param name defines the block name
  65678. */
  65679. constructor(name: string);
  65680. /**
  65681. * Gets the current class name
  65682. * @returns the class name
  65683. */
  65684. getClassName(): string;
  65685. /**
  65686. * Gets the left operand input component
  65687. */
  65688. get left(): NodeMaterialConnectionPoint;
  65689. /**
  65690. * Gets the right operand input component
  65691. */
  65692. get right(): NodeMaterialConnectionPoint;
  65693. /**
  65694. * Gets the output component
  65695. */
  65696. get output(): NodeMaterialConnectionPoint;
  65697. protected _buildBlock(state: NodeMaterialBuildState): this;
  65698. }
  65699. }
  65700. declare module BABYLON {
  65701. /**
  65702. * Configuration for Draco compression
  65703. */
  65704. export interface IDracoCompressionConfiguration {
  65705. /**
  65706. * Configuration for the decoder.
  65707. */
  65708. decoder: {
  65709. /**
  65710. * The url to the WebAssembly module.
  65711. */
  65712. wasmUrl?: string;
  65713. /**
  65714. * The url to the WebAssembly binary.
  65715. */
  65716. wasmBinaryUrl?: string;
  65717. /**
  65718. * The url to the fallback JavaScript module.
  65719. */
  65720. fallbackUrl?: string;
  65721. };
  65722. }
  65723. /**
  65724. * Draco compression (https://google.github.io/draco/)
  65725. *
  65726. * This class wraps the Draco module.
  65727. *
  65728. * **Encoder**
  65729. *
  65730. * The encoder is not currently implemented.
  65731. *
  65732. * **Decoder**
  65733. *
  65734. * 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.
  65735. *
  65736. * To update the configuration, use the following code:
  65737. * ```javascript
  65738. * DracoCompression.Configuration = {
  65739. * decoder: {
  65740. * wasmUrl: "<url to the WebAssembly library>",
  65741. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65742. * fallbackUrl: "<url to the fallback JavaScript library>",
  65743. * }
  65744. * };
  65745. * ```
  65746. *
  65747. * 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.
  65748. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65749. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65750. *
  65751. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65752. * ```javascript
  65753. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65754. * ```
  65755. *
  65756. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65757. */
  65758. export class DracoCompression implements IDisposable {
  65759. private _workerPoolPromise?;
  65760. private _decoderModulePromise?;
  65761. /**
  65762. * The configuration. Defaults to the following urls:
  65763. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65764. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65765. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65766. */
  65767. static Configuration: IDracoCompressionConfiguration;
  65768. /**
  65769. * Returns true if the decoder configuration is available.
  65770. */
  65771. static get DecoderAvailable(): boolean;
  65772. /**
  65773. * Default number of workers to create when creating the draco compression object.
  65774. */
  65775. static DefaultNumWorkers: number;
  65776. private static GetDefaultNumWorkers;
  65777. private static _Default;
  65778. /**
  65779. * Default instance for the draco compression object.
  65780. */
  65781. static get Default(): DracoCompression;
  65782. /**
  65783. * Constructor
  65784. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65785. */
  65786. constructor(numWorkers?: number);
  65787. /**
  65788. * Stop all async operations and release resources.
  65789. */
  65790. dispose(): void;
  65791. /**
  65792. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65793. * @returns a promise that resolves when ready
  65794. */
  65795. whenReadyAsync(): Promise<void>;
  65796. /**
  65797. * Decode Draco compressed mesh data to vertex data.
  65798. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65799. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65800. * @returns A promise that resolves with the decoded vertex data
  65801. */
  65802. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65803. [kind: string]: number;
  65804. }): Promise<VertexData>;
  65805. }
  65806. }
  65807. declare module BABYLON {
  65808. /**
  65809. * Class for building Constructive Solid Geometry
  65810. */
  65811. export class CSG {
  65812. private polygons;
  65813. /**
  65814. * The world matrix
  65815. */
  65816. matrix: Matrix;
  65817. /**
  65818. * Stores the position
  65819. */
  65820. position: Vector3;
  65821. /**
  65822. * Stores the rotation
  65823. */
  65824. rotation: Vector3;
  65825. /**
  65826. * Stores the rotation quaternion
  65827. */
  65828. rotationQuaternion: Nullable<Quaternion>;
  65829. /**
  65830. * Stores the scaling vector
  65831. */
  65832. scaling: Vector3;
  65833. /**
  65834. * Convert the Mesh to CSG
  65835. * @param mesh The Mesh to convert to CSG
  65836. * @returns A new CSG from the Mesh
  65837. */
  65838. static FromMesh(mesh: Mesh): CSG;
  65839. /**
  65840. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65841. * @param polygons Polygons used to construct a CSG solid
  65842. */
  65843. private static FromPolygons;
  65844. /**
  65845. * Clones, or makes a deep copy, of the CSG
  65846. * @returns A new CSG
  65847. */
  65848. clone(): CSG;
  65849. /**
  65850. * Unions this CSG with another CSG
  65851. * @param csg The CSG to union against this CSG
  65852. * @returns The unioned CSG
  65853. */
  65854. union(csg: CSG): CSG;
  65855. /**
  65856. * Unions this CSG with another CSG in place
  65857. * @param csg The CSG to union against this CSG
  65858. */
  65859. unionInPlace(csg: CSG): void;
  65860. /**
  65861. * Subtracts this CSG with another CSG
  65862. * @param csg The CSG to subtract against this CSG
  65863. * @returns A new CSG
  65864. */
  65865. subtract(csg: CSG): CSG;
  65866. /**
  65867. * Subtracts this CSG with another CSG in place
  65868. * @param csg The CSG to subtact against this CSG
  65869. */
  65870. subtractInPlace(csg: CSG): void;
  65871. /**
  65872. * Intersect this CSG with another CSG
  65873. * @param csg The CSG to intersect against this CSG
  65874. * @returns A new CSG
  65875. */
  65876. intersect(csg: CSG): CSG;
  65877. /**
  65878. * Intersects this CSG with another CSG in place
  65879. * @param csg The CSG to intersect against this CSG
  65880. */
  65881. intersectInPlace(csg: CSG): void;
  65882. /**
  65883. * Return a new CSG solid with solid and empty space switched. This solid is
  65884. * not modified.
  65885. * @returns A new CSG solid with solid and empty space switched
  65886. */
  65887. inverse(): CSG;
  65888. /**
  65889. * Inverses the CSG in place
  65890. */
  65891. inverseInPlace(): void;
  65892. /**
  65893. * This is used to keep meshes transformations so they can be restored
  65894. * when we build back a Babylon Mesh
  65895. * NB : All CSG operations are performed in world coordinates
  65896. * @param csg The CSG to copy the transform attributes from
  65897. * @returns This CSG
  65898. */
  65899. copyTransformAttributes(csg: CSG): CSG;
  65900. /**
  65901. * Build Raw mesh from CSG
  65902. * Coordinates here are in world space
  65903. * @param name The name of the mesh geometry
  65904. * @param scene The Scene
  65905. * @param keepSubMeshes Specifies if the submeshes should be kept
  65906. * @returns A new Mesh
  65907. */
  65908. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65909. /**
  65910. * Build Mesh from CSG taking material and transforms into account
  65911. * @param name The name of the Mesh
  65912. * @param material The material of the Mesh
  65913. * @param scene The Scene
  65914. * @param keepSubMeshes Specifies if submeshes should be kept
  65915. * @returns The new Mesh
  65916. */
  65917. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65918. }
  65919. }
  65920. declare module BABYLON {
  65921. /**
  65922. * Class used to create a trail following a mesh
  65923. */
  65924. export class TrailMesh extends Mesh {
  65925. private _generator;
  65926. private _autoStart;
  65927. private _running;
  65928. private _diameter;
  65929. private _length;
  65930. private _sectionPolygonPointsCount;
  65931. private _sectionVectors;
  65932. private _sectionNormalVectors;
  65933. private _beforeRenderObserver;
  65934. /**
  65935. * @constructor
  65936. * @param name The value used by scene.getMeshByName() to do a lookup.
  65937. * @param generator The mesh or transform node to generate a trail.
  65938. * @param scene The scene to add this mesh to.
  65939. * @param diameter Diameter of trailing mesh. Default is 1.
  65940. * @param length Length of trailing mesh. Default is 60.
  65941. * @param autoStart Automatically start trailing mesh. Default true.
  65942. */
  65943. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65944. /**
  65945. * "TrailMesh"
  65946. * @returns "TrailMesh"
  65947. */
  65948. getClassName(): string;
  65949. private _createMesh;
  65950. /**
  65951. * Start trailing mesh.
  65952. */
  65953. start(): void;
  65954. /**
  65955. * Stop trailing mesh.
  65956. */
  65957. stop(): void;
  65958. /**
  65959. * Update trailing mesh geometry.
  65960. */
  65961. update(): void;
  65962. /**
  65963. * Returns a new TrailMesh object.
  65964. * @param name is a string, the name given to the new mesh
  65965. * @param newGenerator use new generator object for cloned trail mesh
  65966. * @returns a new mesh
  65967. */
  65968. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65969. /**
  65970. * Serializes this trail mesh
  65971. * @param serializationObject object to write serialization to
  65972. */
  65973. serialize(serializationObject: any): void;
  65974. /**
  65975. * Parses a serialized trail mesh
  65976. * @param parsedMesh the serialized mesh
  65977. * @param scene the scene to create the trail mesh in
  65978. * @returns the created trail mesh
  65979. */
  65980. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65981. }
  65982. }
  65983. declare module BABYLON {
  65984. /**
  65985. * Class containing static functions to help procedurally build meshes
  65986. */
  65987. export class TiledBoxBuilder {
  65988. /**
  65989. * Creates a box mesh
  65990. * 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)
  65991. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65993. * * 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
  65994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65995. * @param name defines the name of the mesh
  65996. * @param options defines the options used to create the mesh
  65997. * @param scene defines the hosting scene
  65998. * @returns the box mesh
  65999. */
  66000. static CreateTiledBox(name: string, options: {
  66001. pattern?: number;
  66002. width?: number;
  66003. height?: number;
  66004. depth?: number;
  66005. tileSize?: number;
  66006. tileWidth?: number;
  66007. tileHeight?: number;
  66008. alignHorizontal?: number;
  66009. alignVertical?: number;
  66010. faceUV?: Vector4[];
  66011. faceColors?: Color4[];
  66012. sideOrientation?: number;
  66013. updatable?: boolean;
  66014. }, scene?: Nullable<Scene>): Mesh;
  66015. }
  66016. }
  66017. declare module BABYLON {
  66018. /**
  66019. * Class containing static functions to help procedurally build meshes
  66020. */
  66021. export class TorusKnotBuilder {
  66022. /**
  66023. * Creates a torus knot mesh
  66024. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66025. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66026. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66027. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66029. * * 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
  66030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66031. * @param name defines the name of the mesh
  66032. * @param options defines the options used to create the mesh
  66033. * @param scene defines the hosting scene
  66034. * @returns the torus knot mesh
  66035. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66036. */
  66037. static CreateTorusKnot(name: string, options: {
  66038. radius?: number;
  66039. tube?: number;
  66040. radialSegments?: number;
  66041. tubularSegments?: number;
  66042. p?: number;
  66043. q?: number;
  66044. updatable?: boolean;
  66045. sideOrientation?: number;
  66046. frontUVs?: Vector4;
  66047. backUVs?: Vector4;
  66048. }, scene: any): Mesh;
  66049. }
  66050. }
  66051. declare module BABYLON {
  66052. /**
  66053. * Polygon
  66054. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66055. */
  66056. export class Polygon {
  66057. /**
  66058. * Creates a rectangle
  66059. * @param xmin bottom X coord
  66060. * @param ymin bottom Y coord
  66061. * @param xmax top X coord
  66062. * @param ymax top Y coord
  66063. * @returns points that make the resulting rectation
  66064. */
  66065. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66066. /**
  66067. * Creates a circle
  66068. * @param radius radius of circle
  66069. * @param cx scale in x
  66070. * @param cy scale in y
  66071. * @param numberOfSides number of sides that make up the circle
  66072. * @returns points that make the resulting circle
  66073. */
  66074. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66075. /**
  66076. * Creates a polygon from input string
  66077. * @param input Input polygon data
  66078. * @returns the parsed points
  66079. */
  66080. static Parse(input: string): Vector2[];
  66081. /**
  66082. * Starts building a polygon from x and y coordinates
  66083. * @param x x coordinate
  66084. * @param y y coordinate
  66085. * @returns the started path2
  66086. */
  66087. static StartingAt(x: number, y: number): Path2;
  66088. }
  66089. /**
  66090. * Builds a polygon
  66091. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66092. */
  66093. export class PolygonMeshBuilder {
  66094. private _points;
  66095. private _outlinepoints;
  66096. private _holes;
  66097. private _name;
  66098. private _scene;
  66099. private _epoints;
  66100. private _eholes;
  66101. private _addToepoint;
  66102. /**
  66103. * Babylon reference to the earcut plugin.
  66104. */
  66105. bjsEarcut: any;
  66106. /**
  66107. * Creates a PolygonMeshBuilder
  66108. * @param name name of the builder
  66109. * @param contours Path of the polygon
  66110. * @param scene scene to add to when creating the mesh
  66111. * @param earcutInjection can be used to inject your own earcut reference
  66112. */
  66113. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66114. /**
  66115. * Adds a whole within the polygon
  66116. * @param hole Array of points defining the hole
  66117. * @returns this
  66118. */
  66119. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66120. /**
  66121. * Creates the polygon
  66122. * @param updatable If the mesh should be updatable
  66123. * @param depth The depth of the mesh created
  66124. * @returns the created mesh
  66125. */
  66126. build(updatable?: boolean, depth?: number): Mesh;
  66127. /**
  66128. * Creates the polygon
  66129. * @param depth The depth of the mesh created
  66130. * @returns the created VertexData
  66131. */
  66132. buildVertexData(depth?: number): VertexData;
  66133. /**
  66134. * Adds a side to the polygon
  66135. * @param positions points that make the polygon
  66136. * @param normals normals of the polygon
  66137. * @param uvs uvs of the polygon
  66138. * @param indices indices of the polygon
  66139. * @param bounds bounds of the polygon
  66140. * @param points points of the polygon
  66141. * @param depth depth of the polygon
  66142. * @param flip flip of the polygon
  66143. */
  66144. private addSide;
  66145. }
  66146. }
  66147. declare module BABYLON {
  66148. /**
  66149. * Class containing static functions to help procedurally build meshes
  66150. */
  66151. export class PolygonBuilder {
  66152. /**
  66153. * Creates a polygon mesh
  66154. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66155. * * 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
  66156. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66158. * * 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)
  66159. * * Remember you can only change the shape positions, not their number when updating a polygon
  66160. * @param name defines the name of the mesh
  66161. * @param options defines the options used to create the mesh
  66162. * @param scene defines the hosting scene
  66163. * @param earcutInjection can be used to inject your own earcut reference
  66164. * @returns the polygon mesh
  66165. */
  66166. static CreatePolygon(name: string, options: {
  66167. shape: Vector3[];
  66168. holes?: Vector3[][];
  66169. depth?: number;
  66170. faceUV?: Vector4[];
  66171. faceColors?: Color4[];
  66172. updatable?: boolean;
  66173. sideOrientation?: number;
  66174. frontUVs?: Vector4;
  66175. backUVs?: Vector4;
  66176. wrap?: boolean;
  66177. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66178. /**
  66179. * Creates an extruded polygon mesh, with depth in the Y direction.
  66180. * * 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)
  66181. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66182. * @param name defines the name of the mesh
  66183. * @param options defines the options used to create the mesh
  66184. * @param scene defines the hosting scene
  66185. * @param earcutInjection can be used to inject your own earcut reference
  66186. * @returns the polygon mesh
  66187. */
  66188. static ExtrudePolygon(name: string, options: {
  66189. shape: Vector3[];
  66190. holes?: Vector3[][];
  66191. depth?: number;
  66192. faceUV?: Vector4[];
  66193. faceColors?: Color4[];
  66194. updatable?: boolean;
  66195. sideOrientation?: number;
  66196. frontUVs?: Vector4;
  66197. backUVs?: Vector4;
  66198. wrap?: boolean;
  66199. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66200. }
  66201. }
  66202. declare module BABYLON {
  66203. /**
  66204. * Class containing static functions to help procedurally build meshes
  66205. */
  66206. export class LatheBuilder {
  66207. /**
  66208. * Creates lathe mesh.
  66209. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66210. * * 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
  66211. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66212. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66213. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66214. * * 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
  66215. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66216. * * 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
  66217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66218. * * 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
  66219. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66221. * @param name defines the name of the mesh
  66222. * @param options defines the options used to create the mesh
  66223. * @param scene defines the hosting scene
  66224. * @returns the lathe mesh
  66225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66226. */
  66227. static CreateLathe(name: string, options: {
  66228. shape: Vector3[];
  66229. radius?: number;
  66230. tessellation?: number;
  66231. clip?: number;
  66232. arc?: number;
  66233. closed?: boolean;
  66234. updatable?: boolean;
  66235. sideOrientation?: number;
  66236. frontUVs?: Vector4;
  66237. backUVs?: Vector4;
  66238. cap?: number;
  66239. invertUV?: boolean;
  66240. }, scene?: Nullable<Scene>): Mesh;
  66241. }
  66242. }
  66243. declare module BABYLON {
  66244. /**
  66245. * Class containing static functions to help procedurally build meshes
  66246. */
  66247. export class TiledPlaneBuilder {
  66248. /**
  66249. * Creates a tiled plane mesh
  66250. * * The parameter `pattern` will, depending on value, do nothing or
  66251. * * * flip (reflect about central vertical) alternate tiles across and up
  66252. * * * flip every tile on alternate rows
  66253. * * * rotate (180 degs) alternate tiles across and up
  66254. * * * rotate every tile on alternate rows
  66255. * * * flip and rotate alternate tiles across and up
  66256. * * * flip and rotate every tile on alternate rows
  66257. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66258. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66259. * * 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
  66260. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66261. * * 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)
  66262. * * 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)
  66263. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66264. * @param name defines the name of the mesh
  66265. * @param options defines the options used to create the mesh
  66266. * @param scene defines the hosting scene
  66267. * @returns the box mesh
  66268. */
  66269. static CreateTiledPlane(name: string, options: {
  66270. pattern?: number;
  66271. tileSize?: number;
  66272. tileWidth?: number;
  66273. tileHeight?: number;
  66274. size?: number;
  66275. width?: number;
  66276. height?: number;
  66277. alignHorizontal?: number;
  66278. alignVertical?: number;
  66279. sideOrientation?: number;
  66280. frontUVs?: Vector4;
  66281. backUVs?: Vector4;
  66282. updatable?: boolean;
  66283. }, scene?: Nullable<Scene>): Mesh;
  66284. }
  66285. }
  66286. declare module BABYLON {
  66287. /**
  66288. * Class containing static functions to help procedurally build meshes
  66289. */
  66290. export class TubeBuilder {
  66291. /**
  66292. * Creates a tube mesh.
  66293. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66294. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66295. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66296. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66297. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66298. * * 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)
  66299. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66300. * * 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
  66301. * * 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
  66302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66303. * * 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
  66304. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66306. * @param name defines the name of the mesh
  66307. * @param options defines the options used to create the mesh
  66308. * @param scene defines the hosting scene
  66309. * @returns the tube mesh
  66310. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66311. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66312. */
  66313. static CreateTube(name: string, options: {
  66314. path: Vector3[];
  66315. radius?: number;
  66316. tessellation?: number;
  66317. radiusFunction?: {
  66318. (i: number, distance: number): number;
  66319. };
  66320. cap?: number;
  66321. arc?: number;
  66322. updatable?: boolean;
  66323. sideOrientation?: number;
  66324. frontUVs?: Vector4;
  66325. backUVs?: Vector4;
  66326. instance?: Mesh;
  66327. invertUV?: boolean;
  66328. }, scene?: Nullable<Scene>): Mesh;
  66329. }
  66330. }
  66331. declare module BABYLON {
  66332. /**
  66333. * Class containing static functions to help procedurally build meshes
  66334. */
  66335. export class IcoSphereBuilder {
  66336. /**
  66337. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66338. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66339. * * 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`)
  66340. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66341. * * 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
  66342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66343. * * 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
  66344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66345. * @param name defines the name of the mesh
  66346. * @param options defines the options used to create the mesh
  66347. * @param scene defines the hosting scene
  66348. * @returns the icosahedron mesh
  66349. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66350. */
  66351. static CreateIcoSphere(name: string, options: {
  66352. radius?: number;
  66353. radiusX?: number;
  66354. radiusY?: number;
  66355. radiusZ?: number;
  66356. flat?: boolean;
  66357. subdivisions?: number;
  66358. sideOrientation?: number;
  66359. frontUVs?: Vector4;
  66360. backUVs?: Vector4;
  66361. updatable?: boolean;
  66362. }, scene?: Nullable<Scene>): Mesh;
  66363. }
  66364. }
  66365. declare module BABYLON {
  66366. /**
  66367. * Class containing static functions to help procedurally build meshes
  66368. */
  66369. export class DecalBuilder {
  66370. /**
  66371. * Creates a decal mesh.
  66372. * 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
  66373. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66374. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66375. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66376. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66377. * @param name defines the name of the mesh
  66378. * @param sourceMesh defines the mesh where the decal must be applied
  66379. * @param options defines the options used to create the mesh
  66380. * @param scene defines the hosting scene
  66381. * @returns the decal mesh
  66382. * @see https://doc.babylonjs.com/how_to/decals
  66383. */
  66384. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66385. position?: Vector3;
  66386. normal?: Vector3;
  66387. size?: Vector3;
  66388. angle?: number;
  66389. }): Mesh;
  66390. }
  66391. }
  66392. declare module BABYLON {
  66393. /**
  66394. * Class containing static functions to help procedurally build meshes
  66395. */
  66396. export class MeshBuilder {
  66397. /**
  66398. * Creates a box mesh
  66399. * * The parameter `size` sets the size (float) of each box side (default 1)
  66400. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66401. * * 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)
  66402. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66404. * * 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
  66405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66406. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66407. * @param name defines the name of the mesh
  66408. * @param options defines the options used to create the mesh
  66409. * @param scene defines the hosting scene
  66410. * @returns the box mesh
  66411. */
  66412. static CreateBox(name: string, options: {
  66413. size?: number;
  66414. width?: number;
  66415. height?: number;
  66416. depth?: number;
  66417. faceUV?: Vector4[];
  66418. faceColors?: Color4[];
  66419. sideOrientation?: number;
  66420. frontUVs?: Vector4;
  66421. backUVs?: Vector4;
  66422. wrap?: boolean;
  66423. topBaseAt?: number;
  66424. bottomBaseAt?: number;
  66425. updatable?: boolean;
  66426. }, scene?: Nullable<Scene>): Mesh;
  66427. /**
  66428. * Creates a tiled box mesh
  66429. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66431. * @param name defines the name of the mesh
  66432. * @param options defines the options used to create the mesh
  66433. * @param scene defines the hosting scene
  66434. * @returns the tiled box mesh
  66435. */
  66436. static CreateTiledBox(name: string, options: {
  66437. pattern?: number;
  66438. size?: number;
  66439. width?: number;
  66440. height?: number;
  66441. depth: number;
  66442. tileSize?: number;
  66443. tileWidth?: number;
  66444. tileHeight?: number;
  66445. faceUV?: Vector4[];
  66446. faceColors?: Color4[];
  66447. alignHorizontal?: number;
  66448. alignVertical?: number;
  66449. sideOrientation?: number;
  66450. updatable?: boolean;
  66451. }, scene?: Nullable<Scene>): Mesh;
  66452. /**
  66453. * Creates a sphere mesh
  66454. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66455. * * 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`)
  66456. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66457. * * 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
  66458. * * 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)
  66459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66460. * * 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
  66461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66462. * @param name defines the name of the mesh
  66463. * @param options defines the options used to create the mesh
  66464. * @param scene defines the hosting scene
  66465. * @returns the sphere mesh
  66466. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66467. */
  66468. static CreateSphere(name: string, options: {
  66469. segments?: number;
  66470. diameter?: number;
  66471. diameterX?: number;
  66472. diameterY?: number;
  66473. diameterZ?: number;
  66474. arc?: number;
  66475. slice?: number;
  66476. sideOrientation?: number;
  66477. frontUVs?: Vector4;
  66478. backUVs?: Vector4;
  66479. updatable?: boolean;
  66480. }, scene?: Nullable<Scene>): Mesh;
  66481. /**
  66482. * Creates a plane polygonal mesh. By default, this is a disc
  66483. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66484. * * 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
  66485. * * 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
  66486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66487. * * 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
  66488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66489. * @param name defines the name of the mesh
  66490. * @param options defines the options used to create the mesh
  66491. * @param scene defines the hosting scene
  66492. * @returns the plane polygonal mesh
  66493. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66494. */
  66495. static CreateDisc(name: string, options: {
  66496. radius?: number;
  66497. tessellation?: number;
  66498. arc?: number;
  66499. updatable?: boolean;
  66500. sideOrientation?: number;
  66501. frontUVs?: Vector4;
  66502. backUVs?: Vector4;
  66503. }, scene?: Nullable<Scene>): Mesh;
  66504. /**
  66505. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66506. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66507. * * 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`)
  66508. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66509. * * 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
  66510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66511. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66513. * @param name defines the name of the mesh
  66514. * @param options defines the options used to create the mesh
  66515. * @param scene defines the hosting scene
  66516. * @returns the icosahedron mesh
  66517. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66518. */
  66519. static CreateIcoSphere(name: string, options: {
  66520. radius?: number;
  66521. radiusX?: number;
  66522. radiusY?: number;
  66523. radiusZ?: number;
  66524. flat?: boolean;
  66525. subdivisions?: number;
  66526. sideOrientation?: number;
  66527. frontUVs?: Vector4;
  66528. backUVs?: Vector4;
  66529. updatable?: boolean;
  66530. }, scene?: Nullable<Scene>): Mesh;
  66531. /**
  66532. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66533. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66534. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66535. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66536. * * 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
  66537. * * 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
  66538. * * 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
  66539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66540. * * 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
  66541. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66542. * * 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
  66543. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66544. * * 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
  66545. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66547. * @param name defines the name of the mesh
  66548. * @param options defines the options used to create the mesh
  66549. * @param scene defines the hosting scene
  66550. * @returns the ribbon mesh
  66551. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66552. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66553. */
  66554. static CreateRibbon(name: string, options: {
  66555. pathArray: Vector3[][];
  66556. closeArray?: boolean;
  66557. closePath?: boolean;
  66558. offset?: number;
  66559. updatable?: boolean;
  66560. sideOrientation?: number;
  66561. frontUVs?: Vector4;
  66562. backUVs?: Vector4;
  66563. instance?: Mesh;
  66564. invertUV?: boolean;
  66565. uvs?: Vector2[];
  66566. colors?: Color4[];
  66567. }, scene?: Nullable<Scene>): Mesh;
  66568. /**
  66569. * Creates a cylinder or a cone mesh
  66570. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66571. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66572. * * 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.
  66573. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66574. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66575. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66576. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66577. * * 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).
  66578. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66579. * * 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).
  66580. * * 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
  66581. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66582. * * 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
  66583. * * 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.
  66584. * * If `enclose` is false, a ring surface is one element.
  66585. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66586. * * 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
  66587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66588. * * 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
  66589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66590. * @param name defines the name of the mesh
  66591. * @param options defines the options used to create the mesh
  66592. * @param scene defines the hosting scene
  66593. * @returns the cylinder mesh
  66594. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66595. */
  66596. static CreateCylinder(name: string, options: {
  66597. height?: number;
  66598. diameterTop?: number;
  66599. diameterBottom?: number;
  66600. diameter?: number;
  66601. tessellation?: number;
  66602. subdivisions?: number;
  66603. arc?: number;
  66604. faceColors?: Color4[];
  66605. faceUV?: Vector4[];
  66606. updatable?: boolean;
  66607. hasRings?: boolean;
  66608. enclose?: boolean;
  66609. cap?: number;
  66610. sideOrientation?: number;
  66611. frontUVs?: Vector4;
  66612. backUVs?: Vector4;
  66613. }, scene?: Nullable<Scene>): Mesh;
  66614. /**
  66615. * Creates a torus mesh
  66616. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66617. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66618. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  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 torus mesh
  66626. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66627. */
  66628. static CreateTorus(name: string, options: {
  66629. diameter?: number;
  66630. thickness?: number;
  66631. tessellation?: number;
  66632. updatable?: boolean;
  66633. sideOrientation?: number;
  66634. frontUVs?: Vector4;
  66635. backUVs?: Vector4;
  66636. }, scene?: Nullable<Scene>): Mesh;
  66637. /**
  66638. * Creates a torus knot mesh
  66639. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66640. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66641. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66642. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66644. * * 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
  66645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66646. * @param name defines the name of the mesh
  66647. * @param options defines the options used to create the mesh
  66648. * @param scene defines the hosting scene
  66649. * @returns the torus knot mesh
  66650. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66651. */
  66652. static CreateTorusKnot(name: string, options: {
  66653. radius?: number;
  66654. tube?: number;
  66655. radialSegments?: number;
  66656. tubularSegments?: number;
  66657. p?: number;
  66658. q?: number;
  66659. updatable?: boolean;
  66660. sideOrientation?: number;
  66661. frontUVs?: Vector4;
  66662. backUVs?: Vector4;
  66663. }, scene?: Nullable<Scene>): Mesh;
  66664. /**
  66665. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66666. * * 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
  66667. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66668. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66669. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66670. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66671. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66672. * * 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
  66673. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66675. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66676. * @param name defines the name of the new line system
  66677. * @param options defines the options used to create the line system
  66678. * @param scene defines the hosting scene
  66679. * @returns a new line system mesh
  66680. */
  66681. static CreateLineSystem(name: string, options: {
  66682. lines: Vector3[][];
  66683. updatable?: boolean;
  66684. instance?: Nullable<LinesMesh>;
  66685. colors?: Nullable<Color4[][]>;
  66686. useVertexAlpha?: boolean;
  66687. }, scene: Nullable<Scene>): LinesMesh;
  66688. /**
  66689. * Creates a line mesh
  66690. * 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
  66691. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66692. * * The parameter `points` is an array successive Vector3
  66693. * * 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
  66694. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66695. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66696. * * When updating an instance, remember that only point positions can change, not the number of points
  66697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66698. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66699. * @param name defines the name of the new line system
  66700. * @param options defines the options used to create the line system
  66701. * @param scene defines the hosting scene
  66702. * @returns a new line mesh
  66703. */
  66704. static CreateLines(name: string, options: {
  66705. points: Vector3[];
  66706. updatable?: boolean;
  66707. instance?: Nullable<LinesMesh>;
  66708. colors?: Color4[];
  66709. useVertexAlpha?: boolean;
  66710. }, scene?: Nullable<Scene>): LinesMesh;
  66711. /**
  66712. * Creates a dashed line mesh
  66713. * * 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
  66714. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66715. * * The parameter `points` is an array successive Vector3
  66716. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66717. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66718. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66719. * * 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
  66720. * * When updating an instance, remember that only point positions can change, not the number of points
  66721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66722. * @param name defines the name of the mesh
  66723. * @param options defines the options used to create the mesh
  66724. * @param scene defines the hosting scene
  66725. * @returns the dashed line mesh
  66726. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66727. */
  66728. static CreateDashedLines(name: string, options: {
  66729. points: Vector3[];
  66730. dashSize?: number;
  66731. gapSize?: number;
  66732. dashNb?: number;
  66733. updatable?: boolean;
  66734. instance?: LinesMesh;
  66735. }, scene?: Nullable<Scene>): LinesMesh;
  66736. /**
  66737. * 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.
  66738. * * 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.
  66739. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66740. * * 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.
  66741. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66742. * * 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
  66743. * * 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
  66744. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66746. * * 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
  66747. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66749. * @param name defines the name of the mesh
  66750. * @param options defines the options used to create the mesh
  66751. * @param scene defines the hosting scene
  66752. * @returns the extruded shape mesh
  66753. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66754. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66755. */
  66756. static ExtrudeShape(name: string, options: {
  66757. shape: Vector3[];
  66758. path: Vector3[];
  66759. scale?: number;
  66760. rotation?: number;
  66761. cap?: number;
  66762. updatable?: boolean;
  66763. sideOrientation?: number;
  66764. frontUVs?: Vector4;
  66765. backUVs?: Vector4;
  66766. instance?: Mesh;
  66767. invertUV?: boolean;
  66768. }, scene?: Nullable<Scene>): Mesh;
  66769. /**
  66770. * Creates an custom extruded shape mesh.
  66771. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66772. * * 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.
  66773. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66774. * * 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
  66775. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66776. * * 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
  66777. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66778. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66779. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66780. * * 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
  66781. * * 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
  66782. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66784. * * 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
  66785. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66787. * @param name defines the name of the mesh
  66788. * @param options defines the options used to create the mesh
  66789. * @param scene defines the hosting scene
  66790. * @returns the custom extruded shape mesh
  66791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66792. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66793. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66794. */
  66795. static ExtrudeShapeCustom(name: string, options: {
  66796. shape: Vector3[];
  66797. path: Vector3[];
  66798. scaleFunction?: any;
  66799. rotationFunction?: any;
  66800. ribbonCloseArray?: boolean;
  66801. ribbonClosePath?: boolean;
  66802. cap?: number;
  66803. updatable?: boolean;
  66804. sideOrientation?: number;
  66805. frontUVs?: Vector4;
  66806. backUVs?: Vector4;
  66807. instance?: Mesh;
  66808. invertUV?: boolean;
  66809. }, scene?: Nullable<Scene>): Mesh;
  66810. /**
  66811. * Creates lathe mesh.
  66812. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66813. * * 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
  66814. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66815. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66816. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66817. * * 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
  66818. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66819. * * 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
  66820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66821. * * 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
  66822. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66824. * @param name defines the name of the mesh
  66825. * @param options defines the options used to create the mesh
  66826. * @param scene defines the hosting scene
  66827. * @returns the lathe mesh
  66828. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66829. */
  66830. static CreateLathe(name: string, options: {
  66831. shape: Vector3[];
  66832. radius?: number;
  66833. tessellation?: number;
  66834. clip?: number;
  66835. arc?: number;
  66836. closed?: boolean;
  66837. updatable?: boolean;
  66838. sideOrientation?: number;
  66839. frontUVs?: Vector4;
  66840. backUVs?: Vector4;
  66841. cap?: number;
  66842. invertUV?: boolean;
  66843. }, scene?: Nullable<Scene>): Mesh;
  66844. /**
  66845. * Creates a tiled plane mesh
  66846. * * You can set a limited pattern arrangement with the tiles
  66847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66848. * * 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
  66849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66850. * @param name defines the name of the mesh
  66851. * @param options defines the options used to create the mesh
  66852. * @param scene defines the hosting scene
  66853. * @returns the plane mesh
  66854. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66855. */
  66856. static CreateTiledPlane(name: string, options: {
  66857. pattern?: number;
  66858. tileSize?: number;
  66859. tileWidth?: number;
  66860. tileHeight?: number;
  66861. size?: number;
  66862. width?: number;
  66863. height?: number;
  66864. alignHorizontal?: number;
  66865. alignVertical?: number;
  66866. sideOrientation?: number;
  66867. frontUVs?: Vector4;
  66868. backUVs?: Vector4;
  66869. updatable?: boolean;
  66870. }, scene?: Nullable<Scene>): Mesh;
  66871. /**
  66872. * Creates a plane mesh
  66873. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66874. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66875. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66876. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66877. * * 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
  66878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66879. * @param name defines the name of the mesh
  66880. * @param options defines the options used to create the mesh
  66881. * @param scene defines the hosting scene
  66882. * @returns the plane mesh
  66883. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66884. */
  66885. static CreatePlane(name: string, options: {
  66886. size?: number;
  66887. width?: number;
  66888. height?: number;
  66889. sideOrientation?: number;
  66890. frontUVs?: Vector4;
  66891. backUVs?: Vector4;
  66892. updatable?: boolean;
  66893. sourcePlane?: Plane;
  66894. }, scene?: Nullable<Scene>): Mesh;
  66895. /**
  66896. * Creates a ground mesh
  66897. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66898. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66900. * @param name defines the name of the mesh
  66901. * @param options defines the options used to create the mesh
  66902. * @param scene defines the hosting scene
  66903. * @returns the ground mesh
  66904. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66905. */
  66906. static CreateGround(name: string, options: {
  66907. width?: number;
  66908. height?: number;
  66909. subdivisions?: number;
  66910. subdivisionsX?: number;
  66911. subdivisionsY?: number;
  66912. updatable?: boolean;
  66913. }, scene?: Nullable<Scene>): Mesh;
  66914. /**
  66915. * Creates a tiled ground mesh
  66916. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66917. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66918. * * 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
  66919. * * 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
  66920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66921. * @param name defines the name of the mesh
  66922. * @param options defines the options used to create the mesh
  66923. * @param scene defines the hosting scene
  66924. * @returns the tiled ground mesh
  66925. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66926. */
  66927. static CreateTiledGround(name: string, options: {
  66928. xmin: number;
  66929. zmin: number;
  66930. xmax: number;
  66931. zmax: number;
  66932. subdivisions?: {
  66933. w: number;
  66934. h: number;
  66935. };
  66936. precision?: {
  66937. w: number;
  66938. h: number;
  66939. };
  66940. updatable?: boolean;
  66941. }, scene?: Nullable<Scene>): Mesh;
  66942. /**
  66943. * Creates a ground mesh from a height map
  66944. * * The parameter `url` sets the URL of the height map image resource.
  66945. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66946. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66947. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66948. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66949. * * 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.
  66950. * * 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).
  66951. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66953. * @param name defines the name of the mesh
  66954. * @param url defines the url to the height map
  66955. * @param options defines the options used to create the mesh
  66956. * @param scene defines the hosting scene
  66957. * @returns the ground mesh
  66958. * @see https://doc.babylonjs.com/babylon101/height_map
  66959. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66960. */
  66961. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66962. width?: number;
  66963. height?: number;
  66964. subdivisions?: number;
  66965. minHeight?: number;
  66966. maxHeight?: number;
  66967. colorFilter?: Color3;
  66968. alphaFilter?: number;
  66969. updatable?: boolean;
  66970. onReady?: (mesh: GroundMesh) => void;
  66971. }, scene?: Nullable<Scene>): GroundMesh;
  66972. /**
  66973. * Creates a polygon mesh
  66974. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66975. * * 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
  66976. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66978. * * 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)
  66979. * * Remember you can only change the shape positions, not their number when updating a polygon
  66980. * @param name defines the name of the mesh
  66981. * @param options defines the options used to create the mesh
  66982. * @param scene defines the hosting scene
  66983. * @param earcutInjection can be used to inject your own earcut reference
  66984. * @returns the polygon mesh
  66985. */
  66986. static CreatePolygon(name: string, options: {
  66987. shape: Vector3[];
  66988. holes?: Vector3[][];
  66989. depth?: number;
  66990. faceUV?: Vector4[];
  66991. faceColors?: Color4[];
  66992. updatable?: boolean;
  66993. sideOrientation?: number;
  66994. frontUVs?: Vector4;
  66995. backUVs?: Vector4;
  66996. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66997. /**
  66998. * Creates an extruded polygon mesh, with depth in the Y direction.
  66999. * * 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)
  67000. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67001. * @param name defines the name of the mesh
  67002. * @param options defines the options used to create the mesh
  67003. * @param scene defines the hosting scene
  67004. * @param earcutInjection can be used to inject your own earcut reference
  67005. * @returns the polygon mesh
  67006. */
  67007. static ExtrudePolygon(name: string, options: {
  67008. shape: Vector3[];
  67009. holes?: Vector3[][];
  67010. depth?: number;
  67011. faceUV?: Vector4[];
  67012. faceColors?: Color4[];
  67013. updatable?: boolean;
  67014. sideOrientation?: number;
  67015. frontUVs?: Vector4;
  67016. backUVs?: Vector4;
  67017. wrap?: boolean;
  67018. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67019. /**
  67020. * Creates a tube mesh.
  67021. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67022. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67023. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67024. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67025. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67026. * * 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)
  67027. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67028. * * 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
  67029. * * 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
  67030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67031. * * 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
  67032. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67034. * @param name defines the name of the mesh
  67035. * @param options defines the options used to create the mesh
  67036. * @param scene defines the hosting scene
  67037. * @returns the tube mesh
  67038. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67039. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67040. */
  67041. static CreateTube(name: string, options: {
  67042. path: Vector3[];
  67043. radius?: number;
  67044. tessellation?: number;
  67045. radiusFunction?: {
  67046. (i: number, distance: number): number;
  67047. };
  67048. cap?: number;
  67049. arc?: number;
  67050. updatable?: boolean;
  67051. sideOrientation?: number;
  67052. frontUVs?: Vector4;
  67053. backUVs?: Vector4;
  67054. instance?: Mesh;
  67055. invertUV?: boolean;
  67056. }, scene?: Nullable<Scene>): Mesh;
  67057. /**
  67058. * Creates a polyhedron mesh
  67059. * * 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
  67060. * * The parameter `size` (positive float, default 1) sets the polygon size
  67061. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67062. * * 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`
  67063. * * 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
  67064. * * 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)`)
  67065. * * 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
  67066. * * 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
  67067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67068. * * 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
  67069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67070. * @param name defines the name of the mesh
  67071. * @param options defines the options used to create the mesh
  67072. * @param scene defines the hosting scene
  67073. * @returns the polyhedron mesh
  67074. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67075. */
  67076. static CreatePolyhedron(name: string, options: {
  67077. type?: number;
  67078. size?: number;
  67079. sizeX?: number;
  67080. sizeY?: number;
  67081. sizeZ?: number;
  67082. custom?: any;
  67083. faceUV?: Vector4[];
  67084. faceColors?: Color4[];
  67085. flat?: boolean;
  67086. updatable?: boolean;
  67087. sideOrientation?: number;
  67088. frontUVs?: Vector4;
  67089. backUVs?: Vector4;
  67090. }, scene?: Nullable<Scene>): Mesh;
  67091. /**
  67092. * Creates a decal mesh.
  67093. * 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
  67094. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67095. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67096. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67097. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67098. * @param name defines the name of the mesh
  67099. * @param sourceMesh defines the mesh where the decal must be applied
  67100. * @param options defines the options used to create the mesh
  67101. * @param scene defines the hosting scene
  67102. * @returns the decal mesh
  67103. * @see https://doc.babylonjs.com/how_to/decals
  67104. */
  67105. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67106. position?: Vector3;
  67107. normal?: Vector3;
  67108. size?: Vector3;
  67109. angle?: number;
  67110. }): Mesh;
  67111. /**
  67112. * Creates a Capsule Mesh
  67113. * @param name defines the name of the mesh.
  67114. * @param options the constructors options used to shape the mesh.
  67115. * @param scene defines the scene the mesh is scoped to.
  67116. * @returns the capsule mesh
  67117. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67118. */
  67119. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67120. }
  67121. }
  67122. declare module BABYLON {
  67123. /**
  67124. * A simplifier interface for future simplification implementations
  67125. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67126. */
  67127. export interface ISimplifier {
  67128. /**
  67129. * Simplification of a given mesh according to the given settings.
  67130. * Since this requires computation, it is assumed that the function runs async.
  67131. * @param settings The settings of the simplification, including quality and distance
  67132. * @param successCallback A callback that will be called after the mesh was simplified.
  67133. * @param errorCallback in case of an error, this callback will be called. optional.
  67134. */
  67135. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67136. }
  67137. /**
  67138. * Expected simplification settings.
  67139. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67140. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67141. */
  67142. export interface ISimplificationSettings {
  67143. /**
  67144. * Gets or sets the expected quality
  67145. */
  67146. quality: number;
  67147. /**
  67148. * Gets or sets the distance when this optimized version should be used
  67149. */
  67150. distance: number;
  67151. /**
  67152. * Gets an already optimized mesh
  67153. */
  67154. optimizeMesh?: boolean;
  67155. }
  67156. /**
  67157. * Class used to specify simplification options
  67158. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67159. */
  67160. export class SimplificationSettings implements ISimplificationSettings {
  67161. /** expected quality */
  67162. quality: number;
  67163. /** distance when this optimized version should be used */
  67164. distance: number;
  67165. /** already optimized mesh */
  67166. optimizeMesh?: boolean | undefined;
  67167. /**
  67168. * Creates a SimplificationSettings
  67169. * @param quality expected quality
  67170. * @param distance distance when this optimized version should be used
  67171. * @param optimizeMesh already optimized mesh
  67172. */
  67173. constructor(
  67174. /** expected quality */
  67175. quality: number,
  67176. /** distance when this optimized version should be used */
  67177. distance: number,
  67178. /** already optimized mesh */
  67179. optimizeMesh?: boolean | undefined);
  67180. }
  67181. /**
  67182. * Interface used to define a simplification task
  67183. */
  67184. export interface ISimplificationTask {
  67185. /**
  67186. * Array of settings
  67187. */
  67188. settings: Array<ISimplificationSettings>;
  67189. /**
  67190. * Simplification type
  67191. */
  67192. simplificationType: SimplificationType;
  67193. /**
  67194. * Mesh to simplify
  67195. */
  67196. mesh: Mesh;
  67197. /**
  67198. * Callback called on success
  67199. */
  67200. successCallback?: () => void;
  67201. /**
  67202. * Defines if parallel processing can be used
  67203. */
  67204. parallelProcessing: boolean;
  67205. }
  67206. /**
  67207. * Queue used to order the simplification tasks
  67208. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67209. */
  67210. export class SimplificationQueue {
  67211. private _simplificationArray;
  67212. /**
  67213. * Gets a boolean indicating that the process is still running
  67214. */
  67215. running: boolean;
  67216. /**
  67217. * Creates a new queue
  67218. */
  67219. constructor();
  67220. /**
  67221. * Adds a new simplification task
  67222. * @param task defines a task to add
  67223. */
  67224. addTask(task: ISimplificationTask): void;
  67225. /**
  67226. * Execute next task
  67227. */
  67228. executeNext(): void;
  67229. /**
  67230. * Execute a simplification task
  67231. * @param task defines the task to run
  67232. */
  67233. runSimplification(task: ISimplificationTask): void;
  67234. private getSimplifier;
  67235. }
  67236. /**
  67237. * The implemented types of simplification
  67238. * At the moment only Quadratic Error Decimation is implemented
  67239. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67240. */
  67241. export enum SimplificationType {
  67242. /** Quadratic error decimation */
  67243. QUADRATIC = 0
  67244. }
  67245. /**
  67246. * An implementation of the Quadratic Error simplification algorithm.
  67247. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67248. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67249. * @author RaananW
  67250. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67251. */
  67252. export class QuadraticErrorSimplification implements ISimplifier {
  67253. private _mesh;
  67254. private triangles;
  67255. private vertices;
  67256. private references;
  67257. private _reconstructedMesh;
  67258. /** Gets or sets the number pf sync interations */
  67259. syncIterations: number;
  67260. /** Gets or sets the aggressiveness of the simplifier */
  67261. aggressiveness: number;
  67262. /** Gets or sets the number of allowed iterations for decimation */
  67263. decimationIterations: number;
  67264. /** Gets or sets the espilon to use for bounding box computation */
  67265. boundingBoxEpsilon: number;
  67266. /**
  67267. * Creates a new QuadraticErrorSimplification
  67268. * @param _mesh defines the target mesh
  67269. */
  67270. constructor(_mesh: Mesh);
  67271. /**
  67272. * Simplification of a given mesh according to the given settings.
  67273. * Since this requires computation, it is assumed that the function runs async.
  67274. * @param settings The settings of the simplification, including quality and distance
  67275. * @param successCallback A callback that will be called after the mesh was simplified.
  67276. */
  67277. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67278. private runDecimation;
  67279. private initWithMesh;
  67280. private init;
  67281. private reconstructMesh;
  67282. private initDecimatedMesh;
  67283. private isFlipped;
  67284. private updateTriangles;
  67285. private identifyBorder;
  67286. private updateMesh;
  67287. private vertexError;
  67288. private calculateError;
  67289. }
  67290. }
  67291. declare module BABYLON {
  67292. interface Scene {
  67293. /** @hidden (Backing field) */
  67294. _simplificationQueue: SimplificationQueue;
  67295. /**
  67296. * Gets or sets the simplification queue attached to the scene
  67297. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67298. */
  67299. simplificationQueue: SimplificationQueue;
  67300. }
  67301. interface Mesh {
  67302. /**
  67303. * Simplify the mesh according to the given array of settings.
  67304. * Function will return immediately and will simplify async
  67305. * @param settings a collection of simplification settings
  67306. * @param parallelProcessing should all levels calculate parallel or one after the other
  67307. * @param simplificationType the type of simplification to run
  67308. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67309. * @returns the current mesh
  67310. */
  67311. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67312. }
  67313. /**
  67314. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67315. * created in a scene
  67316. */
  67317. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67318. /**
  67319. * The component name helpfull to identify the component in the list of scene components.
  67320. */
  67321. readonly name: string;
  67322. /**
  67323. * The scene the component belongs to.
  67324. */
  67325. scene: Scene;
  67326. /**
  67327. * Creates a new instance of the component for the given scene
  67328. * @param scene Defines the scene to register the component in
  67329. */
  67330. constructor(scene: Scene);
  67331. /**
  67332. * Registers the component in a given scene
  67333. */
  67334. register(): void;
  67335. /**
  67336. * Rebuilds the elements related to this component in case of
  67337. * context lost for instance.
  67338. */
  67339. rebuild(): void;
  67340. /**
  67341. * Disposes the component and the associated ressources
  67342. */
  67343. dispose(): void;
  67344. private _beforeCameraUpdate;
  67345. }
  67346. }
  67347. declare module BABYLON {
  67348. interface Mesh {
  67349. /**
  67350. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67351. */
  67352. thinInstanceEnablePicking: boolean;
  67353. /**
  67354. * Creates a new thin instance
  67355. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67356. * @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
  67357. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67358. */
  67359. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67360. /**
  67361. * Adds the transformation (matrix) of the current mesh as a thin instance
  67362. * @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
  67363. * @returns the thin instance index number
  67364. */
  67365. thinInstanceAddSelf(refresh: boolean): number;
  67366. /**
  67367. * Registers a custom attribute to be used with thin instances
  67368. * @param kind name of the attribute
  67369. * @param stride size in floats of the attribute
  67370. */
  67371. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67372. /**
  67373. * Sets the matrix of a thin instance
  67374. * @param index index of the thin instance
  67375. * @param matrix matrix to set
  67376. * @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
  67377. */
  67378. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67379. /**
  67380. * Sets the value of a custom attribute for a thin instance
  67381. * @param kind name of the attribute
  67382. * @param index index of the thin instance
  67383. * @param value value to set
  67384. * @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
  67385. */
  67386. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67387. /**
  67388. * 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.
  67389. */
  67390. thinInstanceCount: number;
  67391. /**
  67392. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67393. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67394. * @param buffer buffer to set
  67395. * @param stride size in floats of each value of the buffer
  67396. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67397. */
  67398. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67399. /**
  67400. * Gets the list of world matrices
  67401. * @return an array containing all the world matrices from the thin instances
  67402. */
  67403. thinInstanceGetWorldMatrices(): Matrix[];
  67404. /**
  67405. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67406. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67407. */
  67408. thinInstanceBufferUpdated(kind: string): void;
  67409. /**
  67410. * Applies a partial update to a buffer directly on the GPU
  67411. * 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
  67412. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67413. * @param data the data to set in the GPU buffer
  67414. * @param offset the offset in the GPU buffer where to update the data
  67415. */
  67416. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67417. /**
  67418. * Refreshes the bounding info, taking into account all the thin instances defined
  67419. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67420. */
  67421. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67422. /** @hidden */
  67423. _thinInstanceInitializeUserStorage(): void;
  67424. /** @hidden */
  67425. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67426. /** @hidden */
  67427. _userThinInstanceBuffersStorage: {
  67428. data: {
  67429. [key: string]: Float32Array;
  67430. };
  67431. sizes: {
  67432. [key: string]: number;
  67433. };
  67434. vertexBuffers: {
  67435. [key: string]: Nullable<VertexBuffer>;
  67436. };
  67437. strides: {
  67438. [key: string]: number;
  67439. };
  67440. };
  67441. }
  67442. }
  67443. declare module BABYLON {
  67444. /**
  67445. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67446. */
  67447. export interface INavigationEnginePlugin {
  67448. /**
  67449. * plugin name
  67450. */
  67451. name: string;
  67452. /**
  67453. * Creates a navigation mesh
  67454. * @param meshes array of all the geometry used to compute the navigatio mesh
  67455. * @param parameters bunch of parameters used to filter geometry
  67456. */
  67457. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67458. /**
  67459. * Create a navigation mesh debug mesh
  67460. * @param scene is where the mesh will be added
  67461. * @returns debug display mesh
  67462. */
  67463. createDebugNavMesh(scene: Scene): Mesh;
  67464. /**
  67465. * Get a navigation mesh constrained position, closest to the parameter position
  67466. * @param position world position
  67467. * @returns the closest point to position constrained by the navigation mesh
  67468. */
  67469. getClosestPoint(position: Vector3): Vector3;
  67470. /**
  67471. * Get a navigation mesh constrained position, closest to the parameter position
  67472. * @param position world position
  67473. * @param result output the closest point to position constrained by the navigation mesh
  67474. */
  67475. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67476. /**
  67477. * Get a navigation mesh constrained position, within a particular radius
  67478. * @param position world position
  67479. * @param maxRadius the maximum distance to the constrained world position
  67480. * @returns the closest point to position constrained by the navigation mesh
  67481. */
  67482. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67483. /**
  67484. * Get a navigation mesh constrained position, within a particular radius
  67485. * @param position world position
  67486. * @param maxRadius the maximum distance to the constrained world position
  67487. * @param result output the closest point to position constrained by the navigation mesh
  67488. */
  67489. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67490. /**
  67491. * Compute the final position from a segment made of destination-position
  67492. * @param position world position
  67493. * @param destination world position
  67494. * @returns the resulting point along the navmesh
  67495. */
  67496. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67497. /**
  67498. * Compute the final position from a segment made of destination-position
  67499. * @param position world position
  67500. * @param destination world position
  67501. * @param result output the resulting point along the navmesh
  67502. */
  67503. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67504. /**
  67505. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67506. * @param start world position
  67507. * @param end world position
  67508. * @returns array containing world position composing the path
  67509. */
  67510. computePath(start: Vector3, end: Vector3): Vector3[];
  67511. /**
  67512. * If this plugin is supported
  67513. * @returns true if plugin is supported
  67514. */
  67515. isSupported(): boolean;
  67516. /**
  67517. * Create a new Crowd so you can add agents
  67518. * @param maxAgents the maximum agent count in the crowd
  67519. * @param maxAgentRadius the maximum radius an agent can have
  67520. * @param scene to attach the crowd to
  67521. * @returns the crowd you can add agents to
  67522. */
  67523. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67524. /**
  67525. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67526. * The queries will try to find a solution within those bounds
  67527. * default is (1,1,1)
  67528. * @param extent x,y,z value that define the extent around the queries point of reference
  67529. */
  67530. setDefaultQueryExtent(extent: Vector3): void;
  67531. /**
  67532. * Get the Bounding box extent specified by setDefaultQueryExtent
  67533. * @returns the box extent values
  67534. */
  67535. getDefaultQueryExtent(): Vector3;
  67536. /**
  67537. * build the navmesh from a previously saved state using getNavmeshData
  67538. * @param data the Uint8Array returned by getNavmeshData
  67539. */
  67540. buildFromNavmeshData(data: Uint8Array): void;
  67541. /**
  67542. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67543. * @returns data the Uint8Array that can be saved and reused
  67544. */
  67545. getNavmeshData(): Uint8Array;
  67546. /**
  67547. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67548. * @param result output the box extent values
  67549. */
  67550. getDefaultQueryExtentToRef(result: Vector3): void;
  67551. /**
  67552. * Release all resources
  67553. */
  67554. dispose(): void;
  67555. }
  67556. /**
  67557. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67558. */
  67559. export interface ICrowd {
  67560. /**
  67561. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67562. * You can attach anything to that node. The node position is updated in the scene update tick.
  67563. * @param pos world position that will be constrained by the navigation mesh
  67564. * @param parameters agent parameters
  67565. * @param transform hooked to the agent that will be update by the scene
  67566. * @returns agent index
  67567. */
  67568. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67569. /**
  67570. * Returns the agent position in world space
  67571. * @param index agent index returned by addAgent
  67572. * @returns world space position
  67573. */
  67574. getAgentPosition(index: number): Vector3;
  67575. /**
  67576. * Gets the agent position result in world space
  67577. * @param index agent index returned by addAgent
  67578. * @param result output world space position
  67579. */
  67580. getAgentPositionToRef(index: number, result: Vector3): void;
  67581. /**
  67582. * Gets the agent velocity in world space
  67583. * @param index agent index returned by addAgent
  67584. * @returns world space velocity
  67585. */
  67586. getAgentVelocity(index: number): Vector3;
  67587. /**
  67588. * Gets the agent velocity result in world space
  67589. * @param index agent index returned by addAgent
  67590. * @param result output world space velocity
  67591. */
  67592. getAgentVelocityToRef(index: number, result: Vector3): void;
  67593. /**
  67594. * remove a particular agent previously created
  67595. * @param index agent index returned by addAgent
  67596. */
  67597. removeAgent(index: number): void;
  67598. /**
  67599. * get the list of all agents attached to this crowd
  67600. * @returns list of agent indices
  67601. */
  67602. getAgents(): number[];
  67603. /**
  67604. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67605. * @param deltaTime in seconds
  67606. */
  67607. update(deltaTime: number): void;
  67608. /**
  67609. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67610. * @param index agent index returned by addAgent
  67611. * @param destination targeted world position
  67612. */
  67613. agentGoto(index: number, destination: Vector3): void;
  67614. /**
  67615. * Teleport the agent to a new position
  67616. * @param index agent index returned by addAgent
  67617. * @param destination targeted world position
  67618. */
  67619. agentTeleport(index: number, destination: Vector3): void;
  67620. /**
  67621. * Update agent parameters
  67622. * @param index agent index returned by addAgent
  67623. * @param parameters agent parameters
  67624. */
  67625. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67626. /**
  67627. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67628. * The queries will try to find a solution within those bounds
  67629. * default is (1,1,1)
  67630. * @param extent x,y,z value that define the extent around the queries point of reference
  67631. */
  67632. setDefaultQueryExtent(extent: Vector3): void;
  67633. /**
  67634. * Get the Bounding box extent specified by setDefaultQueryExtent
  67635. * @returns the box extent values
  67636. */
  67637. getDefaultQueryExtent(): Vector3;
  67638. /**
  67639. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67640. * @param result output the box extent values
  67641. */
  67642. getDefaultQueryExtentToRef(result: Vector3): void;
  67643. /**
  67644. * Release all resources
  67645. */
  67646. dispose(): void;
  67647. }
  67648. /**
  67649. * Configures an agent
  67650. */
  67651. export interface IAgentParameters {
  67652. /**
  67653. * Agent radius. [Limit: >= 0]
  67654. */
  67655. radius: number;
  67656. /**
  67657. * Agent height. [Limit: > 0]
  67658. */
  67659. height: number;
  67660. /**
  67661. * Maximum allowed acceleration. [Limit: >= 0]
  67662. */
  67663. maxAcceleration: number;
  67664. /**
  67665. * Maximum allowed speed. [Limit: >= 0]
  67666. */
  67667. maxSpeed: number;
  67668. /**
  67669. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67670. */
  67671. collisionQueryRange: number;
  67672. /**
  67673. * The path visibility optimization range. [Limit: > 0]
  67674. */
  67675. pathOptimizationRange: number;
  67676. /**
  67677. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67678. */
  67679. separationWeight: number;
  67680. }
  67681. /**
  67682. * Configures the navigation mesh creation
  67683. */
  67684. export interface INavMeshParameters {
  67685. /**
  67686. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67687. */
  67688. cs: number;
  67689. /**
  67690. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67691. */
  67692. ch: number;
  67693. /**
  67694. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67695. */
  67696. walkableSlopeAngle: number;
  67697. /**
  67698. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67699. * be considered walkable. [Limit: >= 3] [Units: vx]
  67700. */
  67701. walkableHeight: number;
  67702. /**
  67703. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67704. */
  67705. walkableClimb: number;
  67706. /**
  67707. * The distance to erode/shrink the walkable area of the heightfield away from
  67708. * obstructions. [Limit: >=0] [Units: vx]
  67709. */
  67710. walkableRadius: number;
  67711. /**
  67712. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67713. */
  67714. maxEdgeLen: number;
  67715. /**
  67716. * The maximum distance a simplfied contour's border edges should deviate
  67717. * the original raw contour. [Limit: >=0] [Units: vx]
  67718. */
  67719. maxSimplificationError: number;
  67720. /**
  67721. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67722. */
  67723. minRegionArea: number;
  67724. /**
  67725. * Any regions with a span count smaller than this value will, if possible,
  67726. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67727. */
  67728. mergeRegionArea: number;
  67729. /**
  67730. * The maximum number of vertices allowed for polygons generated during the
  67731. * contour to polygon conversion process. [Limit: >= 3]
  67732. */
  67733. maxVertsPerPoly: number;
  67734. /**
  67735. * Sets the sampling distance to use when generating the detail mesh.
  67736. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67737. */
  67738. detailSampleDist: number;
  67739. /**
  67740. * The maximum distance the detail mesh surface should deviate from heightfield
  67741. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67742. */
  67743. detailSampleMaxError: number;
  67744. }
  67745. }
  67746. declare module BABYLON {
  67747. /**
  67748. * RecastJS navigation plugin
  67749. */
  67750. export class RecastJSPlugin implements INavigationEnginePlugin {
  67751. /**
  67752. * Reference to the Recast library
  67753. */
  67754. bjsRECAST: any;
  67755. /**
  67756. * plugin name
  67757. */
  67758. name: string;
  67759. /**
  67760. * the first navmesh created. We might extend this to support multiple navmeshes
  67761. */
  67762. navMesh: any;
  67763. /**
  67764. * Initializes the recastJS plugin
  67765. * @param recastInjection can be used to inject your own recast reference
  67766. */
  67767. constructor(recastInjection?: any);
  67768. /**
  67769. * Creates a navigation mesh
  67770. * @param meshes array of all the geometry used to compute the navigatio mesh
  67771. * @param parameters bunch of parameters used to filter geometry
  67772. */
  67773. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67774. /**
  67775. * Create a navigation mesh debug mesh
  67776. * @param scene is where the mesh will be added
  67777. * @returns debug display mesh
  67778. */
  67779. createDebugNavMesh(scene: Scene): Mesh;
  67780. /**
  67781. * Get a navigation mesh constrained position, closest to the parameter position
  67782. * @param position world position
  67783. * @returns the closest point to position constrained by the navigation mesh
  67784. */
  67785. getClosestPoint(position: Vector3): Vector3;
  67786. /**
  67787. * Get a navigation mesh constrained position, closest to the parameter position
  67788. * @param position world position
  67789. * @param result output the closest point to position constrained by the navigation mesh
  67790. */
  67791. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67792. /**
  67793. * Get a navigation mesh constrained position, within a particular radius
  67794. * @param position world position
  67795. * @param maxRadius the maximum distance to the constrained world position
  67796. * @returns the closest point to position constrained by the navigation mesh
  67797. */
  67798. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67799. /**
  67800. * Get a navigation mesh constrained position, within a particular radius
  67801. * @param position world position
  67802. * @param maxRadius the maximum distance to the constrained world position
  67803. * @param result output the closest point to position constrained by the navigation mesh
  67804. */
  67805. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67806. /**
  67807. * Compute the final position from a segment made of destination-position
  67808. * @param position world position
  67809. * @param destination world position
  67810. * @returns the resulting point along the navmesh
  67811. */
  67812. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67813. /**
  67814. * Compute the final position from a segment made of destination-position
  67815. * @param position world position
  67816. * @param destination world position
  67817. * @param result output the resulting point along the navmesh
  67818. */
  67819. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67820. /**
  67821. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67822. * @param start world position
  67823. * @param end world position
  67824. * @returns array containing world position composing the path
  67825. */
  67826. computePath(start: Vector3, end: Vector3): Vector3[];
  67827. /**
  67828. * Create a new Crowd so you can add agents
  67829. * @param maxAgents the maximum agent count in the crowd
  67830. * @param maxAgentRadius the maximum radius an agent can have
  67831. * @param scene to attach the crowd to
  67832. * @returns the crowd you can add agents to
  67833. */
  67834. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67835. /**
  67836. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67837. * The queries will try to find a solution within those bounds
  67838. * default is (1,1,1)
  67839. * @param extent x,y,z value that define the extent around the queries point of reference
  67840. */
  67841. setDefaultQueryExtent(extent: Vector3): void;
  67842. /**
  67843. * Get the Bounding box extent specified by setDefaultQueryExtent
  67844. * @returns the box extent values
  67845. */
  67846. getDefaultQueryExtent(): Vector3;
  67847. /**
  67848. * build the navmesh from a previously saved state using getNavmeshData
  67849. * @param data the Uint8Array returned by getNavmeshData
  67850. */
  67851. buildFromNavmeshData(data: Uint8Array): void;
  67852. /**
  67853. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67854. * @returns data the Uint8Array that can be saved and reused
  67855. */
  67856. getNavmeshData(): Uint8Array;
  67857. /**
  67858. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67859. * @param result output the box extent values
  67860. */
  67861. getDefaultQueryExtentToRef(result: Vector3): void;
  67862. /**
  67863. * Disposes
  67864. */
  67865. dispose(): void;
  67866. /**
  67867. * If this plugin is supported
  67868. * @returns true if plugin is supported
  67869. */
  67870. isSupported(): boolean;
  67871. }
  67872. /**
  67873. * Recast detour crowd implementation
  67874. */
  67875. export class RecastJSCrowd implements ICrowd {
  67876. /**
  67877. * Recast/detour plugin
  67878. */
  67879. bjsRECASTPlugin: RecastJSPlugin;
  67880. /**
  67881. * Link to the detour crowd
  67882. */
  67883. recastCrowd: any;
  67884. /**
  67885. * One transform per agent
  67886. */
  67887. transforms: TransformNode[];
  67888. /**
  67889. * All agents created
  67890. */
  67891. agents: number[];
  67892. /**
  67893. * Link to the scene is kept to unregister the crowd from the scene
  67894. */
  67895. private _scene;
  67896. /**
  67897. * Observer for crowd updates
  67898. */
  67899. private _onBeforeAnimationsObserver;
  67900. /**
  67901. * Constructor
  67902. * @param plugin recastJS plugin
  67903. * @param maxAgents the maximum agent count in the crowd
  67904. * @param maxAgentRadius the maximum radius an agent can have
  67905. * @param scene to attach the crowd to
  67906. * @returns the crowd you can add agents to
  67907. */
  67908. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67909. /**
  67910. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67911. * You can attach anything to that node. The node position is updated in the scene update tick.
  67912. * @param pos world position that will be constrained by the navigation mesh
  67913. * @param parameters agent parameters
  67914. * @param transform hooked to the agent that will be update by the scene
  67915. * @returns agent index
  67916. */
  67917. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67918. /**
  67919. * Returns the agent position in world space
  67920. * @param index agent index returned by addAgent
  67921. * @returns world space position
  67922. */
  67923. getAgentPosition(index: number): Vector3;
  67924. /**
  67925. * Returns the agent position result in world space
  67926. * @param index agent index returned by addAgent
  67927. * @param result output world space position
  67928. */
  67929. getAgentPositionToRef(index: number, result: Vector3): void;
  67930. /**
  67931. * Returns the agent velocity in world space
  67932. * @param index agent index returned by addAgent
  67933. * @returns world space velocity
  67934. */
  67935. getAgentVelocity(index: number): Vector3;
  67936. /**
  67937. * Returns the agent velocity result in world space
  67938. * @param index agent index returned by addAgent
  67939. * @param result output world space velocity
  67940. */
  67941. getAgentVelocityToRef(index: number, result: Vector3): void;
  67942. /**
  67943. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67944. * @param index agent index returned by addAgent
  67945. * @param destination targeted world position
  67946. */
  67947. agentGoto(index: number, destination: Vector3): void;
  67948. /**
  67949. * Teleport the agent to a new position
  67950. * @param index agent index returned by addAgent
  67951. * @param destination targeted world position
  67952. */
  67953. agentTeleport(index: number, destination: Vector3): void;
  67954. /**
  67955. * Update agent parameters
  67956. * @param index agent index returned by addAgent
  67957. * @param parameters agent parameters
  67958. */
  67959. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67960. /**
  67961. * remove a particular agent previously created
  67962. * @param index agent index returned by addAgent
  67963. */
  67964. removeAgent(index: number): void;
  67965. /**
  67966. * get the list of all agents attached to this crowd
  67967. * @returns list of agent indices
  67968. */
  67969. getAgents(): number[];
  67970. /**
  67971. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67972. * @param deltaTime in seconds
  67973. */
  67974. update(deltaTime: number): void;
  67975. /**
  67976. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67977. * The queries will try to find a solution within those bounds
  67978. * default is (1,1,1)
  67979. * @param extent x,y,z value that define the extent around the queries point of reference
  67980. */
  67981. setDefaultQueryExtent(extent: Vector3): void;
  67982. /**
  67983. * Get the Bounding box extent specified by setDefaultQueryExtent
  67984. * @returns the box extent values
  67985. */
  67986. getDefaultQueryExtent(): Vector3;
  67987. /**
  67988. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67989. * @param result output the box extent values
  67990. */
  67991. getDefaultQueryExtentToRef(result: Vector3): void;
  67992. /**
  67993. * Release all resources
  67994. */
  67995. dispose(): void;
  67996. }
  67997. }
  67998. declare module BABYLON {
  67999. /**
  68000. * Class used to enable access to IndexedDB
  68001. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68002. */
  68003. export class Database implements IOfflineProvider {
  68004. private _callbackManifestChecked;
  68005. private _currentSceneUrl;
  68006. private _db;
  68007. private _enableSceneOffline;
  68008. private _enableTexturesOffline;
  68009. private _manifestVersionFound;
  68010. private _mustUpdateRessources;
  68011. private _hasReachedQuota;
  68012. private _isSupported;
  68013. private _idbFactory;
  68014. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68015. private static IsUASupportingBlobStorage;
  68016. /**
  68017. * Gets a boolean indicating if Database storate is enabled (off by default)
  68018. */
  68019. static IDBStorageEnabled: boolean;
  68020. /**
  68021. * Gets a boolean indicating if scene must be saved in the database
  68022. */
  68023. get enableSceneOffline(): boolean;
  68024. /**
  68025. * Gets a boolean indicating if textures must be saved in the database
  68026. */
  68027. get enableTexturesOffline(): boolean;
  68028. /**
  68029. * Creates a new Database
  68030. * @param urlToScene defines the url to load the scene
  68031. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68032. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68033. */
  68034. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68035. private static _ParseURL;
  68036. private static _ReturnFullUrlLocation;
  68037. private _checkManifestFile;
  68038. /**
  68039. * Open the database and make it available
  68040. * @param successCallback defines the callback to call on success
  68041. * @param errorCallback defines the callback to call on error
  68042. */
  68043. open(successCallback: () => void, errorCallback: () => void): void;
  68044. /**
  68045. * Loads an image from the database
  68046. * @param url defines the url to load from
  68047. * @param image defines the target DOM image
  68048. */
  68049. loadImage(url: string, image: HTMLImageElement): void;
  68050. private _loadImageFromDBAsync;
  68051. private _saveImageIntoDBAsync;
  68052. private _checkVersionFromDB;
  68053. private _loadVersionFromDBAsync;
  68054. private _saveVersionIntoDBAsync;
  68055. /**
  68056. * Loads a file from database
  68057. * @param url defines the URL to load from
  68058. * @param sceneLoaded defines a callback to call on success
  68059. * @param progressCallBack defines a callback to call when progress changed
  68060. * @param errorCallback defines a callback to call on error
  68061. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68062. */
  68063. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68064. private _loadFileAsync;
  68065. private _saveFileAsync;
  68066. /**
  68067. * Validates if xhr data is correct
  68068. * @param xhr defines the request to validate
  68069. * @param dataType defines the expected data type
  68070. * @returns true if data is correct
  68071. */
  68072. private static _ValidateXHRData;
  68073. }
  68074. }
  68075. declare module BABYLON {
  68076. /** @hidden */
  68077. export var gpuUpdateParticlesPixelShader: {
  68078. name: string;
  68079. shader: string;
  68080. };
  68081. }
  68082. declare module BABYLON {
  68083. /** @hidden */
  68084. export var gpuUpdateParticlesVertexShader: {
  68085. name: string;
  68086. shader: string;
  68087. };
  68088. }
  68089. declare module BABYLON {
  68090. /** @hidden */
  68091. export var clipPlaneFragmentDeclaration2: {
  68092. name: string;
  68093. shader: string;
  68094. };
  68095. }
  68096. declare module BABYLON {
  68097. /** @hidden */
  68098. export var gpuRenderParticlesPixelShader: {
  68099. name: string;
  68100. shader: string;
  68101. };
  68102. }
  68103. declare module BABYLON {
  68104. /** @hidden */
  68105. export var clipPlaneVertexDeclaration2: {
  68106. name: string;
  68107. shader: string;
  68108. };
  68109. }
  68110. declare module BABYLON {
  68111. /** @hidden */
  68112. export var gpuRenderParticlesVertexShader: {
  68113. name: string;
  68114. shader: string;
  68115. };
  68116. }
  68117. declare module BABYLON {
  68118. /**
  68119. * This represents a GPU particle system in Babylon
  68120. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68121. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68122. */
  68123. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68124. /**
  68125. * The layer mask we are rendering the particles through.
  68126. */
  68127. layerMask: number;
  68128. private _capacity;
  68129. private _activeCount;
  68130. private _currentActiveCount;
  68131. private _accumulatedCount;
  68132. private _renderEffect;
  68133. private _updateEffect;
  68134. private _buffer0;
  68135. private _buffer1;
  68136. private _spriteBuffer;
  68137. private _updateVAO;
  68138. private _renderVAO;
  68139. private _targetIndex;
  68140. private _sourceBuffer;
  68141. private _targetBuffer;
  68142. private _currentRenderId;
  68143. private _started;
  68144. private _stopped;
  68145. private _timeDelta;
  68146. private _randomTexture;
  68147. private _randomTexture2;
  68148. private _attributesStrideSize;
  68149. private _updateEffectOptions;
  68150. private _randomTextureSize;
  68151. private _actualFrame;
  68152. private _customEffect;
  68153. private readonly _rawTextureWidth;
  68154. /**
  68155. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68156. */
  68157. static get IsSupported(): boolean;
  68158. /**
  68159. * An event triggered when the system is disposed.
  68160. */
  68161. onDisposeObservable: Observable<IParticleSystem>;
  68162. /**
  68163. * An event triggered when the system is stopped
  68164. */
  68165. onStoppedObservable: Observable<IParticleSystem>;
  68166. /**
  68167. * Gets the maximum number of particles active at the same time.
  68168. * @returns The max number of active particles.
  68169. */
  68170. getCapacity(): number;
  68171. /**
  68172. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68173. * to override the particles.
  68174. */
  68175. forceDepthWrite: boolean;
  68176. /**
  68177. * Gets or set the number of active particles
  68178. */
  68179. get activeParticleCount(): number;
  68180. set activeParticleCount(value: number);
  68181. private _preWarmDone;
  68182. /**
  68183. * Specifies if the particles are updated in emitter local space or world space.
  68184. */
  68185. isLocal: boolean;
  68186. /** Gets or sets a matrix to use to compute projection */
  68187. defaultProjectionMatrix: Matrix;
  68188. /**
  68189. * Is this system ready to be used/rendered
  68190. * @return true if the system is ready
  68191. */
  68192. isReady(): boolean;
  68193. /**
  68194. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68195. * @returns True if it has been started, otherwise false.
  68196. */
  68197. isStarted(): boolean;
  68198. /**
  68199. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68200. * @returns True if it has been stopped, otherwise false.
  68201. */
  68202. isStopped(): boolean;
  68203. /**
  68204. * Gets a boolean indicating that the system is stopping
  68205. * @returns true if the system is currently stopping
  68206. */
  68207. isStopping(): boolean;
  68208. /**
  68209. * Gets the number of particles active at the same time.
  68210. * @returns The number of active particles.
  68211. */
  68212. getActiveCount(): number;
  68213. /**
  68214. * Starts the particle system and begins to emit
  68215. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68216. */
  68217. start(delay?: number): void;
  68218. /**
  68219. * Stops the particle system.
  68220. */
  68221. stop(): void;
  68222. /**
  68223. * Remove all active particles
  68224. */
  68225. reset(): void;
  68226. /**
  68227. * Returns the string "GPUParticleSystem"
  68228. * @returns a string containing the class name
  68229. */
  68230. getClassName(): string;
  68231. /**
  68232. * Gets the custom effect used to render the particles
  68233. * @param blendMode Blend mode for which the effect should be retrieved
  68234. * @returns The effect
  68235. */
  68236. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68237. /**
  68238. * Sets the custom effect used to render the particles
  68239. * @param effect The effect to set
  68240. * @param blendMode Blend mode for which the effect should be set
  68241. */
  68242. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68243. /** @hidden */
  68244. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68245. /**
  68246. * Observable that will be called just before the particles are drawn
  68247. */
  68248. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68249. /**
  68250. * Gets the name of the particle vertex shader
  68251. */
  68252. get vertexShaderName(): string;
  68253. private _colorGradientsTexture;
  68254. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68255. /**
  68256. * Adds a new color gradient
  68257. * @param gradient defines the gradient to use (between 0 and 1)
  68258. * @param color1 defines the color to affect to the specified gradient
  68259. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68260. * @returns the current particle system
  68261. */
  68262. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68263. private _refreshColorGradient;
  68264. /** Force the system to rebuild all gradients that need to be resync */
  68265. forceRefreshGradients(): void;
  68266. /**
  68267. * Remove a specific color gradient
  68268. * @param gradient defines the gradient to remove
  68269. * @returns the current particle system
  68270. */
  68271. removeColorGradient(gradient: number): GPUParticleSystem;
  68272. private _angularSpeedGradientsTexture;
  68273. private _sizeGradientsTexture;
  68274. private _velocityGradientsTexture;
  68275. private _limitVelocityGradientsTexture;
  68276. private _dragGradientsTexture;
  68277. private _addFactorGradient;
  68278. /**
  68279. * Adds a new size gradient
  68280. * @param gradient defines the gradient to use (between 0 and 1)
  68281. * @param factor defines the size factor to affect to the specified gradient
  68282. * @returns the current particle system
  68283. */
  68284. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68285. /**
  68286. * Remove a specific size gradient
  68287. * @param gradient defines the gradient to remove
  68288. * @returns the current particle system
  68289. */
  68290. removeSizeGradient(gradient: number): GPUParticleSystem;
  68291. private _refreshFactorGradient;
  68292. /**
  68293. * Adds a new angular speed gradient
  68294. * @param gradient defines the gradient to use (between 0 and 1)
  68295. * @param factor defines the angular speed to affect to the specified gradient
  68296. * @returns the current particle system
  68297. */
  68298. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68299. /**
  68300. * Remove a specific angular speed gradient
  68301. * @param gradient defines the gradient to remove
  68302. * @returns the current particle system
  68303. */
  68304. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68305. /**
  68306. * Adds a new velocity gradient
  68307. * @param gradient defines the gradient to use (between 0 and 1)
  68308. * @param factor defines the velocity to affect to the specified gradient
  68309. * @returns the current particle system
  68310. */
  68311. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68312. /**
  68313. * Remove a specific velocity gradient
  68314. * @param gradient defines the gradient to remove
  68315. * @returns the current particle system
  68316. */
  68317. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68318. /**
  68319. * Adds a new limit velocity gradient
  68320. * @param gradient defines the gradient to use (between 0 and 1)
  68321. * @param factor defines the limit velocity value to affect to the specified gradient
  68322. * @returns the current particle system
  68323. */
  68324. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68325. /**
  68326. * Remove a specific limit velocity gradient
  68327. * @param gradient defines the gradient to remove
  68328. * @returns the current particle system
  68329. */
  68330. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68331. /**
  68332. * Adds a new drag gradient
  68333. * @param gradient defines the gradient to use (between 0 and 1)
  68334. * @param factor defines the drag value to affect to the specified gradient
  68335. * @returns the current particle system
  68336. */
  68337. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68338. /**
  68339. * Remove a specific drag gradient
  68340. * @param gradient defines the gradient to remove
  68341. * @returns the current particle system
  68342. */
  68343. removeDragGradient(gradient: number): GPUParticleSystem;
  68344. /**
  68345. * Not supported by GPUParticleSystem
  68346. * @param gradient defines the gradient to use (between 0 and 1)
  68347. * @param factor defines the emit rate value to affect to the specified gradient
  68348. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68349. * @returns the current particle system
  68350. */
  68351. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68352. /**
  68353. * Not supported by GPUParticleSystem
  68354. * @param gradient defines the gradient to remove
  68355. * @returns the current particle system
  68356. */
  68357. removeEmitRateGradient(gradient: number): IParticleSystem;
  68358. /**
  68359. * Not supported by GPUParticleSystem
  68360. * @param gradient defines the gradient to use (between 0 and 1)
  68361. * @param factor defines the start size value to affect to the specified gradient
  68362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68363. * @returns the current particle system
  68364. */
  68365. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68366. /**
  68367. * Not supported by GPUParticleSystem
  68368. * @param gradient defines the gradient to remove
  68369. * @returns the current particle system
  68370. */
  68371. removeStartSizeGradient(gradient: number): IParticleSystem;
  68372. /**
  68373. * Not supported by GPUParticleSystem
  68374. * @param gradient defines the gradient to use (between 0 and 1)
  68375. * @param min defines the color remap minimal range
  68376. * @param max defines the color remap maximal range
  68377. * @returns the current particle system
  68378. */
  68379. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68380. /**
  68381. * Not supported by GPUParticleSystem
  68382. * @param gradient defines the gradient to remove
  68383. * @returns the current particle system
  68384. */
  68385. removeColorRemapGradient(): IParticleSystem;
  68386. /**
  68387. * Not supported by GPUParticleSystem
  68388. * @param gradient defines the gradient to use (between 0 and 1)
  68389. * @param min defines the alpha remap minimal range
  68390. * @param max defines the alpha remap maximal range
  68391. * @returns the current particle system
  68392. */
  68393. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68394. /**
  68395. * Not supported by GPUParticleSystem
  68396. * @param gradient defines the gradient to remove
  68397. * @returns the current particle system
  68398. */
  68399. removeAlphaRemapGradient(): IParticleSystem;
  68400. /**
  68401. * Not supported by GPUParticleSystem
  68402. * @param gradient defines the gradient to use (between 0 and 1)
  68403. * @param color defines the color to affect to the specified gradient
  68404. * @returns the current particle system
  68405. */
  68406. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68407. /**
  68408. * Not supported by GPUParticleSystem
  68409. * @param gradient defines the gradient to remove
  68410. * @returns the current particle system
  68411. */
  68412. removeRampGradient(): IParticleSystem;
  68413. /**
  68414. * Not supported by GPUParticleSystem
  68415. * @returns the list of ramp gradients
  68416. */
  68417. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68418. /**
  68419. * Not supported by GPUParticleSystem
  68420. * Gets or sets a boolean indicating that ramp gradients must be used
  68421. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68422. */
  68423. get useRampGradients(): boolean;
  68424. set useRampGradients(value: boolean);
  68425. /**
  68426. * Not supported by GPUParticleSystem
  68427. * @param gradient defines the gradient to use (between 0 and 1)
  68428. * @param factor defines the life time factor to affect to the specified gradient
  68429. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68430. * @returns the current particle system
  68431. */
  68432. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68433. /**
  68434. * Not supported by GPUParticleSystem
  68435. * @param gradient defines the gradient to remove
  68436. * @returns the current particle system
  68437. */
  68438. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68439. /**
  68440. * Instantiates a GPU particle system.
  68441. * 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.
  68442. * @param name The name of the particle system
  68443. * @param options The options used to create the system
  68444. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68445. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68446. * @param customEffect a custom effect used to change the way particles are rendered by default
  68447. */
  68448. constructor(name: string, options: Partial<{
  68449. capacity: number;
  68450. randomTextureSize: number;
  68451. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68452. protected _reset(): void;
  68453. private _createUpdateVAO;
  68454. private _createRenderVAO;
  68455. private _initialize;
  68456. /** @hidden */
  68457. _recreateUpdateEffect(): void;
  68458. private _getEffect;
  68459. /**
  68460. * Fill the defines array according to the current settings of the particle system
  68461. * @param defines Array to be updated
  68462. * @param blendMode blend mode to take into account when updating the array
  68463. */
  68464. fillDefines(defines: Array<string>, blendMode?: number): void;
  68465. /**
  68466. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68467. * @param uniforms Uniforms array to fill
  68468. * @param attributes Attributes array to fill
  68469. * @param samplers Samplers array to fill
  68470. */
  68471. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68472. /** @hidden */
  68473. _recreateRenderEffect(): Effect;
  68474. /**
  68475. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68476. * @param preWarm defines if we are in the pre-warmimg phase
  68477. */
  68478. animate(preWarm?: boolean): void;
  68479. private _createFactorGradientTexture;
  68480. private _createSizeGradientTexture;
  68481. private _createAngularSpeedGradientTexture;
  68482. private _createVelocityGradientTexture;
  68483. private _createLimitVelocityGradientTexture;
  68484. private _createDragGradientTexture;
  68485. private _createColorGradientTexture;
  68486. /**
  68487. * Renders the particle system in its current state
  68488. * @param preWarm defines if the system should only update the particles but not render them
  68489. * @returns the current number of particles
  68490. */
  68491. render(preWarm?: boolean): number;
  68492. /**
  68493. * Rebuilds the particle system
  68494. */
  68495. rebuild(): void;
  68496. private _releaseBuffers;
  68497. private _releaseVAOs;
  68498. /**
  68499. * Disposes the particle system and free the associated resources
  68500. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68501. */
  68502. dispose(disposeTexture?: boolean): void;
  68503. /**
  68504. * Clones the particle system.
  68505. * @param name The name of the cloned object
  68506. * @param newEmitter The new emitter to use
  68507. * @returns the cloned particle system
  68508. */
  68509. clone(name: string, newEmitter: any): GPUParticleSystem;
  68510. /**
  68511. * Serializes the particle system to a JSON object
  68512. * @param serializeTexture defines if the texture must be serialized as well
  68513. * @returns the JSON object
  68514. */
  68515. serialize(serializeTexture?: boolean): any;
  68516. /**
  68517. * Parses a JSON object to create a GPU particle system.
  68518. * @param parsedParticleSystem The JSON object to parse
  68519. * @param sceneOrEngine The scene or the engine to create the particle system in
  68520. * @param rootUrl The root url to use to load external dependencies like texture
  68521. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68522. * @returns the parsed GPU particle system
  68523. */
  68524. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68525. }
  68526. }
  68527. declare module BABYLON {
  68528. /**
  68529. * Represents a set of particle systems working together to create a specific effect
  68530. */
  68531. export class ParticleSystemSet implements IDisposable {
  68532. /**
  68533. * Gets or sets base Assets URL
  68534. */
  68535. static BaseAssetsUrl: string;
  68536. private _emitterCreationOptions;
  68537. private _emitterNode;
  68538. /**
  68539. * Gets the particle system list
  68540. */
  68541. systems: IParticleSystem[];
  68542. /**
  68543. * Gets the emitter node used with this set
  68544. */
  68545. get emitterNode(): Nullable<TransformNode>;
  68546. /**
  68547. * Creates a new emitter mesh as a sphere
  68548. * @param options defines the options used to create the sphere
  68549. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68550. * @param scene defines the hosting scene
  68551. */
  68552. setEmitterAsSphere(options: {
  68553. diameter: number;
  68554. segments: number;
  68555. color: Color3;
  68556. }, renderingGroupId: number, scene: Scene): void;
  68557. /**
  68558. * Starts all particle systems of the set
  68559. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68560. */
  68561. start(emitter?: AbstractMesh): void;
  68562. /**
  68563. * Release all associated resources
  68564. */
  68565. dispose(): void;
  68566. /**
  68567. * Serialize the set into a JSON compatible object
  68568. * @param serializeTexture defines if the texture must be serialized as well
  68569. * @returns a JSON compatible representation of the set
  68570. */
  68571. serialize(serializeTexture?: boolean): any;
  68572. /**
  68573. * Parse a new ParticleSystemSet from a serialized source
  68574. * @param data defines a JSON compatible representation of the set
  68575. * @param scene defines the hosting scene
  68576. * @param gpu defines if we want GPU particles or CPU particles
  68577. * @returns a new ParticleSystemSet
  68578. */
  68579. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68580. }
  68581. }
  68582. declare module BABYLON {
  68583. /**
  68584. * This class is made for on one-liner static method to help creating particle system set.
  68585. */
  68586. export class ParticleHelper {
  68587. /**
  68588. * Gets or sets base Assets URL
  68589. */
  68590. static BaseAssetsUrl: string;
  68591. /** Define the Url to load snippets */
  68592. static SnippetUrl: string;
  68593. /**
  68594. * Create a default particle system that you can tweak
  68595. * @param emitter defines the emitter to use
  68596. * @param capacity defines the system capacity (default is 500 particles)
  68597. * @param scene defines the hosting scene
  68598. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68599. * @returns the new Particle system
  68600. */
  68601. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68602. /**
  68603. * This is the main static method (one-liner) of this helper to create different particle systems
  68604. * @param type This string represents the type to the particle system to create
  68605. * @param scene The scene where the particle system should live
  68606. * @param gpu If the system will use gpu
  68607. * @returns the ParticleSystemSet created
  68608. */
  68609. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68610. /**
  68611. * Static function used to export a particle system to a ParticleSystemSet variable.
  68612. * Please note that the emitter shape is not exported
  68613. * @param systems defines the particle systems to export
  68614. * @returns the created particle system set
  68615. */
  68616. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68617. /**
  68618. * Creates a particle system from a snippet saved in a remote file
  68619. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68620. * @param url defines the url to load from
  68621. * @param scene defines the hosting scene
  68622. * @param gpu If the system will use gpu
  68623. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68624. * @returns a promise that will resolve to the new particle system
  68625. */
  68626. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68627. /**
  68628. * Creates a particle system from a snippet saved by the particle system editor
  68629. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68630. * @param scene defines the hosting scene
  68631. * @param gpu If the system will use gpu
  68632. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68633. * @returns a promise that will resolve to the new particle system
  68634. */
  68635. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68636. }
  68637. }
  68638. declare module BABYLON {
  68639. interface Engine {
  68640. /**
  68641. * Create an effect to use with particle systems.
  68642. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68643. * the particle system for which you want to create a custom effect in the last parameter
  68644. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68645. * @param uniformsNames defines a list of attribute names
  68646. * @param samplers defines an array of string used to represent textures
  68647. * @param defines defines the string containing the defines to use to compile the shaders
  68648. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68649. * @param onCompiled defines a function to call when the effect creation is successful
  68650. * @param onError defines a function to call when the effect creation has failed
  68651. * @param particleSystem the particle system you want to create the effect for
  68652. * @returns the new Effect
  68653. */
  68654. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68655. }
  68656. interface Mesh {
  68657. /**
  68658. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68659. * @returns an array of IParticleSystem
  68660. */
  68661. getEmittedParticleSystems(): IParticleSystem[];
  68662. /**
  68663. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68664. * @returns an array of IParticleSystem
  68665. */
  68666. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68667. }
  68668. }
  68669. declare module BABYLON {
  68670. /** Defines the 4 color options */
  68671. export enum PointColor {
  68672. /** color value */
  68673. Color = 2,
  68674. /** uv value */
  68675. UV = 1,
  68676. /** random value */
  68677. Random = 0,
  68678. /** stated value */
  68679. Stated = 3
  68680. }
  68681. /**
  68682. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68683. * 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.
  68684. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68685. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68686. *
  68687. * Full documentation here : TO BE ENTERED
  68688. */
  68689. export class PointsCloudSystem implements IDisposable {
  68690. /**
  68691. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68692. * Example : var p = SPS.particles[i];
  68693. */
  68694. particles: CloudPoint[];
  68695. /**
  68696. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68697. */
  68698. nbParticles: number;
  68699. /**
  68700. * This a counter for your own usage. It's not set by any SPS functions.
  68701. */
  68702. counter: number;
  68703. /**
  68704. * The PCS name. This name is also given to the underlying mesh.
  68705. */
  68706. name: string;
  68707. /**
  68708. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68709. */
  68710. mesh: Mesh;
  68711. /**
  68712. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68713. * Please read :
  68714. */
  68715. vars: any;
  68716. /**
  68717. * @hidden
  68718. */
  68719. _size: number;
  68720. private _scene;
  68721. private _promises;
  68722. private _positions;
  68723. private _indices;
  68724. private _normals;
  68725. private _colors;
  68726. private _uvs;
  68727. private _indices32;
  68728. private _positions32;
  68729. private _colors32;
  68730. private _uvs32;
  68731. private _updatable;
  68732. private _isVisibilityBoxLocked;
  68733. private _alwaysVisible;
  68734. private _groups;
  68735. private _groupCounter;
  68736. private _computeParticleColor;
  68737. private _computeParticleTexture;
  68738. private _computeParticleRotation;
  68739. private _computeBoundingBox;
  68740. private _isReady;
  68741. /**
  68742. * Creates a PCS (Points Cloud System) object
  68743. * @param name (String) is the PCS name, this will be the underlying mesh name
  68744. * @param pointSize (number) is the size for each point
  68745. * @param scene (Scene) is the scene in which the PCS is added
  68746. * @param options defines the options of the PCS e.g.
  68747. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68748. */
  68749. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68750. updatable?: boolean;
  68751. });
  68752. /**
  68753. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68754. * If no points were added to the PCS, the returned mesh is just a single point.
  68755. * @returns a promise for the created mesh
  68756. */
  68757. buildMeshAsync(): Promise<Mesh>;
  68758. /**
  68759. * @hidden
  68760. */
  68761. private _buildMesh;
  68762. private _addParticle;
  68763. private _randomUnitVector;
  68764. private _getColorIndicesForCoord;
  68765. private _setPointsColorOrUV;
  68766. private _colorFromTexture;
  68767. private _calculateDensity;
  68768. /**
  68769. * Adds points to the PCS in random positions within a unit sphere
  68770. * @param nb (positive integer) the number of particles to be created from this model
  68771. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68772. * @returns the number of groups in the system
  68773. */
  68774. addPoints(nb: number, pointFunction?: any): number;
  68775. /**
  68776. * Adds points to the PCS from the surface of the model shape
  68777. * @param mesh is any Mesh object that will be used as a surface model for the points
  68778. * @param nb (positive integer) the number of particles to be created from this model
  68779. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68780. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68781. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68782. * @returns the number of groups in the system
  68783. */
  68784. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68785. /**
  68786. * Adds points to the PCS inside the model shape
  68787. * @param mesh is any Mesh object that will be used as a surface model for the points
  68788. * @param nb (positive integer) the number of particles to be created from this model
  68789. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68790. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68791. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68792. * @returns the number of groups in the system
  68793. */
  68794. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68795. /**
  68796. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68797. * This method calls `updateParticle()` for each particle of the SPS.
  68798. * For an animated SPS, it is usually called within the render loop.
  68799. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68800. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68801. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68802. * @returns the PCS.
  68803. */
  68804. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68805. /**
  68806. * Disposes the PCS.
  68807. */
  68808. dispose(): void;
  68809. /**
  68810. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68811. * doc :
  68812. * @returns the PCS.
  68813. */
  68814. refreshVisibleSize(): PointsCloudSystem;
  68815. /**
  68816. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68817. * @param size the size (float) of the visibility box
  68818. * note : this doesn't lock the PCS mesh bounding box.
  68819. * doc :
  68820. */
  68821. setVisibilityBox(size: number): void;
  68822. /**
  68823. * Gets whether the PCS is always visible or not
  68824. * doc :
  68825. */
  68826. get isAlwaysVisible(): boolean;
  68827. /**
  68828. * Sets the PCS as always visible or not
  68829. * doc :
  68830. */
  68831. set isAlwaysVisible(val: boolean);
  68832. /**
  68833. * Tells to `setParticles()` to compute the particle rotations or not
  68834. * Default value : false. The PCS is faster when it's set to false
  68835. * Note : particle rotations are only applied to parent particles
  68836. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68837. */
  68838. set computeParticleRotation(val: boolean);
  68839. /**
  68840. * Tells to `setParticles()` to compute the particle colors or not.
  68841. * Default value : true. The PCS is faster when it's set to false.
  68842. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68843. */
  68844. set computeParticleColor(val: boolean);
  68845. set computeParticleTexture(val: boolean);
  68846. /**
  68847. * Gets if `setParticles()` computes the particle colors or not.
  68848. * Default value : false. The PCS is faster when it's set to false.
  68849. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68850. */
  68851. get computeParticleColor(): boolean;
  68852. /**
  68853. * Gets if `setParticles()` computes the particle textures or not.
  68854. * Default value : false. The PCS is faster when it's set to false.
  68855. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68856. */
  68857. get computeParticleTexture(): boolean;
  68858. /**
  68859. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68860. */
  68861. set computeBoundingBox(val: boolean);
  68862. /**
  68863. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68864. */
  68865. get computeBoundingBox(): boolean;
  68866. /**
  68867. * This function does nothing. It may be overwritten to set all the particle first values.
  68868. * The PCS doesn't call this function, you may have to call it by your own.
  68869. * doc :
  68870. */
  68871. initParticles(): void;
  68872. /**
  68873. * This function does nothing. It may be overwritten to recycle a particle
  68874. * The PCS doesn't call this function, you can to call it
  68875. * doc :
  68876. * @param particle The particle to recycle
  68877. * @returns the recycled particle
  68878. */
  68879. recycleParticle(particle: CloudPoint): CloudPoint;
  68880. /**
  68881. * Updates a particle : this function should be overwritten by the user.
  68882. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68883. * doc :
  68884. * @example : just set a particle position or velocity and recycle conditions
  68885. * @param particle The particle to update
  68886. * @returns the updated particle
  68887. */
  68888. updateParticle(particle: CloudPoint): CloudPoint;
  68889. /**
  68890. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68891. * This does nothing and may be overwritten by the user.
  68892. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68893. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68894. * @param update the boolean update value actually passed to setParticles()
  68895. */
  68896. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68897. /**
  68898. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68899. * This will be passed three parameters.
  68900. * This does nothing and may be overwritten by the user.
  68901. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68902. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68903. * @param update the boolean update value actually passed to setParticles()
  68904. */
  68905. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68906. }
  68907. }
  68908. declare module BABYLON {
  68909. /**
  68910. * Represents one particle of a points cloud system.
  68911. */
  68912. export class CloudPoint {
  68913. /**
  68914. * particle global index
  68915. */
  68916. idx: number;
  68917. /**
  68918. * The color of the particle
  68919. */
  68920. color: Nullable<Color4>;
  68921. /**
  68922. * The world space position of the particle.
  68923. */
  68924. position: Vector3;
  68925. /**
  68926. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68927. */
  68928. rotation: Vector3;
  68929. /**
  68930. * The world space rotation quaternion of the particle.
  68931. */
  68932. rotationQuaternion: Nullable<Quaternion>;
  68933. /**
  68934. * The uv of the particle.
  68935. */
  68936. uv: Nullable<Vector2>;
  68937. /**
  68938. * The current speed of the particle.
  68939. */
  68940. velocity: Vector3;
  68941. /**
  68942. * The pivot point in the particle local space.
  68943. */
  68944. pivot: Vector3;
  68945. /**
  68946. * Must the particle be translated from its pivot point in its local space ?
  68947. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68948. * Default : false
  68949. */
  68950. translateFromPivot: boolean;
  68951. /**
  68952. * Index of this particle in the global "positions" array (Internal use)
  68953. * @hidden
  68954. */
  68955. _pos: number;
  68956. /**
  68957. * @hidden Index of this particle in the global "indices" array (Internal use)
  68958. */
  68959. _ind: number;
  68960. /**
  68961. * Group this particle belongs to
  68962. */
  68963. _group: PointsGroup;
  68964. /**
  68965. * Group id of this particle
  68966. */
  68967. groupId: number;
  68968. /**
  68969. * Index of the particle in its group id (Internal use)
  68970. */
  68971. idxInGroup: number;
  68972. /**
  68973. * @hidden Particle BoundingInfo object (Internal use)
  68974. */
  68975. _boundingInfo: BoundingInfo;
  68976. /**
  68977. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68978. */
  68979. _pcs: PointsCloudSystem;
  68980. /**
  68981. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68982. */
  68983. _stillInvisible: boolean;
  68984. /**
  68985. * @hidden Last computed particle rotation matrix
  68986. */
  68987. _rotationMatrix: number[];
  68988. /**
  68989. * Parent particle Id, if any.
  68990. * Default null.
  68991. */
  68992. parentId: Nullable<number>;
  68993. /**
  68994. * @hidden Internal global position in the PCS.
  68995. */
  68996. _globalPosition: Vector3;
  68997. /**
  68998. * Creates a Point Cloud object.
  68999. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69000. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69001. * @param group (PointsGroup) is the group the particle belongs to
  69002. * @param groupId (integer) is the group identifier in the PCS.
  69003. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69004. * @param pcs defines the PCS it is associated to
  69005. */
  69006. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69007. /**
  69008. * get point size
  69009. */
  69010. get size(): Vector3;
  69011. /**
  69012. * Set point size
  69013. */
  69014. set size(scale: Vector3);
  69015. /**
  69016. * Legacy support, changed quaternion to rotationQuaternion
  69017. */
  69018. get quaternion(): Nullable<Quaternion>;
  69019. /**
  69020. * Legacy support, changed quaternion to rotationQuaternion
  69021. */
  69022. set quaternion(q: Nullable<Quaternion>);
  69023. /**
  69024. * Returns a boolean. True if the particle intersects a mesh, else false
  69025. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69026. * @param target is the object (point or mesh) what the intersection is computed against
  69027. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69028. * @returns true if it intersects
  69029. */
  69030. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69031. /**
  69032. * get the rotation matrix of the particle
  69033. * @hidden
  69034. */
  69035. getRotationMatrix(m: Matrix): void;
  69036. }
  69037. /**
  69038. * Represents a group of points in a points cloud system
  69039. * * PCS internal tool, don't use it manually.
  69040. */
  69041. export class PointsGroup {
  69042. /**
  69043. * The group id
  69044. * @hidden
  69045. */
  69046. groupID: number;
  69047. /**
  69048. * image data for group (internal use)
  69049. * @hidden
  69050. */
  69051. _groupImageData: Nullable<ArrayBufferView>;
  69052. /**
  69053. * Image Width (internal use)
  69054. * @hidden
  69055. */
  69056. _groupImgWidth: number;
  69057. /**
  69058. * Image Height (internal use)
  69059. * @hidden
  69060. */
  69061. _groupImgHeight: number;
  69062. /**
  69063. * Custom position function (internal use)
  69064. * @hidden
  69065. */
  69066. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69067. /**
  69068. * density per facet for surface points
  69069. * @hidden
  69070. */
  69071. _groupDensity: number[];
  69072. /**
  69073. * Only when points are colored by texture carries pointer to texture list array
  69074. * @hidden
  69075. */
  69076. _textureNb: number;
  69077. /**
  69078. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69079. * PCS internal tool, don't use it manually.
  69080. * @hidden
  69081. */
  69082. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69083. }
  69084. }
  69085. declare module BABYLON {
  69086. interface Scene {
  69087. /** @hidden (Backing field) */
  69088. _physicsEngine: Nullable<IPhysicsEngine>;
  69089. /** @hidden */
  69090. _physicsTimeAccumulator: number;
  69091. /**
  69092. * Gets the current physics engine
  69093. * @returns a IPhysicsEngine or null if none attached
  69094. */
  69095. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69096. /**
  69097. * Enables physics to the current scene
  69098. * @param gravity defines the scene's gravity for the physics engine
  69099. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69100. * @return a boolean indicating if the physics engine was initialized
  69101. */
  69102. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69103. /**
  69104. * Disables and disposes the physics engine associated with the scene
  69105. */
  69106. disablePhysicsEngine(): void;
  69107. /**
  69108. * Gets a boolean indicating if there is an active physics engine
  69109. * @returns a boolean indicating if there is an active physics engine
  69110. */
  69111. isPhysicsEnabled(): boolean;
  69112. /**
  69113. * Deletes a physics compound impostor
  69114. * @param compound defines the compound to delete
  69115. */
  69116. deleteCompoundImpostor(compound: any): void;
  69117. /**
  69118. * An event triggered when physic simulation is about to be run
  69119. */
  69120. onBeforePhysicsObservable: Observable<Scene>;
  69121. /**
  69122. * An event triggered when physic simulation has been done
  69123. */
  69124. onAfterPhysicsObservable: Observable<Scene>;
  69125. }
  69126. interface AbstractMesh {
  69127. /** @hidden */
  69128. _physicsImpostor: Nullable<PhysicsImpostor>;
  69129. /**
  69130. * Gets or sets impostor used for physic simulation
  69131. * @see https://doc.babylonjs.com/features/physics_engine
  69132. */
  69133. physicsImpostor: Nullable<PhysicsImpostor>;
  69134. /**
  69135. * Gets the current physics impostor
  69136. * @see https://doc.babylonjs.com/features/physics_engine
  69137. * @returns a physics impostor or null
  69138. */
  69139. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69140. /** Apply a physic impulse to the mesh
  69141. * @param force defines the force to apply
  69142. * @param contactPoint defines where to apply the force
  69143. * @returns the current mesh
  69144. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69145. */
  69146. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69147. /**
  69148. * Creates a physic joint between two meshes
  69149. * @param otherMesh defines the other mesh to use
  69150. * @param pivot1 defines the pivot to use on this mesh
  69151. * @param pivot2 defines the pivot to use on the other mesh
  69152. * @param options defines additional options (can be plugin dependent)
  69153. * @returns the current mesh
  69154. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69155. */
  69156. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69157. /** @hidden */
  69158. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69159. }
  69160. /**
  69161. * Defines the physics engine scene component responsible to manage a physics engine
  69162. */
  69163. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69164. /**
  69165. * The component name helpful to identify the component in the list of scene components.
  69166. */
  69167. readonly name: string;
  69168. /**
  69169. * The scene the component belongs to.
  69170. */
  69171. scene: Scene;
  69172. /**
  69173. * Creates a new instance of the component for the given scene
  69174. * @param scene Defines the scene to register the component in
  69175. */
  69176. constructor(scene: Scene);
  69177. /**
  69178. * Registers the component in a given scene
  69179. */
  69180. register(): void;
  69181. /**
  69182. * Rebuilds the elements related to this component in case of
  69183. * context lost for instance.
  69184. */
  69185. rebuild(): void;
  69186. /**
  69187. * Disposes the component and the associated ressources
  69188. */
  69189. dispose(): void;
  69190. }
  69191. }
  69192. declare module BABYLON {
  69193. /**
  69194. * A helper for physics simulations
  69195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69196. */
  69197. export class PhysicsHelper {
  69198. private _scene;
  69199. private _physicsEngine;
  69200. /**
  69201. * Initializes the Physics helper
  69202. * @param scene Babylon.js scene
  69203. */
  69204. constructor(scene: Scene);
  69205. /**
  69206. * Applies a radial explosion impulse
  69207. * @param origin the origin of the explosion
  69208. * @param radiusOrEventOptions the radius or the options of radial explosion
  69209. * @param strength the explosion strength
  69210. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69211. * @returns A physics radial explosion event, or null
  69212. */
  69213. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69214. /**
  69215. * Applies a radial explosion force
  69216. * @param origin the origin of the explosion
  69217. * @param radiusOrEventOptions the radius or the options of radial explosion
  69218. * @param strength the explosion strength
  69219. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69220. * @returns A physics radial explosion event, or null
  69221. */
  69222. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69223. /**
  69224. * Creates a gravitational field
  69225. * @param origin the origin of the explosion
  69226. * @param radiusOrEventOptions the radius or the options of radial explosion
  69227. * @param strength the explosion strength
  69228. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69229. * @returns A physics gravitational field event, or null
  69230. */
  69231. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69232. /**
  69233. * Creates a physics updraft event
  69234. * @param origin the origin of the updraft
  69235. * @param radiusOrEventOptions the radius or the options of the updraft
  69236. * @param strength the strength of the updraft
  69237. * @param height the height of the updraft
  69238. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69239. * @returns A physics updraft event, or null
  69240. */
  69241. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69242. /**
  69243. * Creates a physics vortex event
  69244. * @param origin the of the vortex
  69245. * @param radiusOrEventOptions the radius or the options of the vortex
  69246. * @param strength the strength of the vortex
  69247. * @param height the height of the vortex
  69248. * @returns a Physics vortex event, or null
  69249. * A physics vortex event or null
  69250. */
  69251. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69252. }
  69253. /**
  69254. * Represents a physics radial explosion event
  69255. */
  69256. class PhysicsRadialExplosionEvent {
  69257. private _scene;
  69258. private _options;
  69259. private _sphere;
  69260. private _dataFetched;
  69261. /**
  69262. * Initializes a radial explosioin event
  69263. * @param _scene BabylonJS scene
  69264. * @param _options The options for the vortex event
  69265. */
  69266. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69267. /**
  69268. * Returns the data related to the radial explosion event (sphere).
  69269. * @returns The radial explosion event data
  69270. */
  69271. getData(): PhysicsRadialExplosionEventData;
  69272. /**
  69273. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69274. * @param impostor A physics imposter
  69275. * @param origin the origin of the explosion
  69276. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69277. */
  69278. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69279. /**
  69280. * Triggers affecterd impostors callbacks
  69281. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69282. */
  69283. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69284. /**
  69285. * Disposes the sphere.
  69286. * @param force Specifies if the sphere should be disposed by force
  69287. */
  69288. dispose(force?: boolean): void;
  69289. /*** Helpers ***/
  69290. private _prepareSphere;
  69291. private _intersectsWithSphere;
  69292. }
  69293. /**
  69294. * Represents a gravitational field event
  69295. */
  69296. class PhysicsGravitationalFieldEvent {
  69297. private _physicsHelper;
  69298. private _scene;
  69299. private _origin;
  69300. private _options;
  69301. private _tickCallback;
  69302. private _sphere;
  69303. private _dataFetched;
  69304. /**
  69305. * Initializes the physics gravitational field event
  69306. * @param _physicsHelper A physics helper
  69307. * @param _scene BabylonJS scene
  69308. * @param _origin The origin position of the gravitational field event
  69309. * @param _options The options for the vortex event
  69310. */
  69311. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69312. /**
  69313. * Returns the data related to the gravitational field event (sphere).
  69314. * @returns A gravitational field event
  69315. */
  69316. getData(): PhysicsGravitationalFieldEventData;
  69317. /**
  69318. * Enables the gravitational field.
  69319. */
  69320. enable(): void;
  69321. /**
  69322. * Disables the gravitational field.
  69323. */
  69324. disable(): void;
  69325. /**
  69326. * Disposes the sphere.
  69327. * @param force The force to dispose from the gravitational field event
  69328. */
  69329. dispose(force?: boolean): void;
  69330. private _tick;
  69331. }
  69332. /**
  69333. * Represents a physics updraft event
  69334. */
  69335. class PhysicsUpdraftEvent {
  69336. private _scene;
  69337. private _origin;
  69338. private _options;
  69339. private _physicsEngine;
  69340. private _originTop;
  69341. private _originDirection;
  69342. private _tickCallback;
  69343. private _cylinder;
  69344. private _cylinderPosition;
  69345. private _dataFetched;
  69346. /**
  69347. * Initializes the physics updraft event
  69348. * @param _scene BabylonJS scene
  69349. * @param _origin The origin position of the updraft
  69350. * @param _options The options for the updraft event
  69351. */
  69352. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69353. /**
  69354. * Returns the data related to the updraft event (cylinder).
  69355. * @returns A physics updraft event
  69356. */
  69357. getData(): PhysicsUpdraftEventData;
  69358. /**
  69359. * Enables the updraft.
  69360. */
  69361. enable(): void;
  69362. /**
  69363. * Disables the updraft.
  69364. */
  69365. disable(): void;
  69366. /**
  69367. * Disposes the cylinder.
  69368. * @param force Specifies if the updraft should be disposed by force
  69369. */
  69370. dispose(force?: boolean): void;
  69371. private getImpostorHitData;
  69372. private _tick;
  69373. /*** Helpers ***/
  69374. private _prepareCylinder;
  69375. private _intersectsWithCylinder;
  69376. }
  69377. /**
  69378. * Represents a physics vortex event
  69379. */
  69380. class PhysicsVortexEvent {
  69381. private _scene;
  69382. private _origin;
  69383. private _options;
  69384. private _physicsEngine;
  69385. private _originTop;
  69386. private _tickCallback;
  69387. private _cylinder;
  69388. private _cylinderPosition;
  69389. private _dataFetched;
  69390. /**
  69391. * Initializes the physics vortex event
  69392. * @param _scene The BabylonJS scene
  69393. * @param _origin The origin position of the vortex
  69394. * @param _options The options for the vortex event
  69395. */
  69396. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69397. /**
  69398. * Returns the data related to the vortex event (cylinder).
  69399. * @returns The physics vortex event data
  69400. */
  69401. getData(): PhysicsVortexEventData;
  69402. /**
  69403. * Enables the vortex.
  69404. */
  69405. enable(): void;
  69406. /**
  69407. * Disables the cortex.
  69408. */
  69409. disable(): void;
  69410. /**
  69411. * Disposes the sphere.
  69412. * @param force
  69413. */
  69414. dispose(force?: boolean): void;
  69415. private getImpostorHitData;
  69416. private _tick;
  69417. /*** Helpers ***/
  69418. private _prepareCylinder;
  69419. private _intersectsWithCylinder;
  69420. }
  69421. /**
  69422. * Options fot the radial explosion event
  69423. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69424. */
  69425. export class PhysicsRadialExplosionEventOptions {
  69426. /**
  69427. * The radius of the sphere for the radial explosion.
  69428. */
  69429. radius: number;
  69430. /**
  69431. * The strenth of the explosion.
  69432. */
  69433. strength: number;
  69434. /**
  69435. * The strenght of the force in correspondence to the distance of the affected object
  69436. */
  69437. falloff: PhysicsRadialImpulseFalloff;
  69438. /**
  69439. * Sphere options for the radial explosion.
  69440. */
  69441. sphere: {
  69442. segments: number;
  69443. diameter: number;
  69444. };
  69445. /**
  69446. * Sphere options for the radial explosion.
  69447. */
  69448. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69449. }
  69450. /**
  69451. * Options fot the updraft event
  69452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69453. */
  69454. export class PhysicsUpdraftEventOptions {
  69455. /**
  69456. * The radius of the cylinder for the vortex
  69457. */
  69458. radius: number;
  69459. /**
  69460. * The strenth of the updraft.
  69461. */
  69462. strength: number;
  69463. /**
  69464. * The height of the cylinder for the updraft.
  69465. */
  69466. height: number;
  69467. /**
  69468. * The mode for the the updraft.
  69469. */
  69470. updraftMode: PhysicsUpdraftMode;
  69471. }
  69472. /**
  69473. * Options fot the vortex event
  69474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69475. */
  69476. export class PhysicsVortexEventOptions {
  69477. /**
  69478. * The radius of the cylinder for the vortex
  69479. */
  69480. radius: number;
  69481. /**
  69482. * The strenth of the vortex.
  69483. */
  69484. strength: number;
  69485. /**
  69486. * The height of the cylinder for the vortex.
  69487. */
  69488. height: number;
  69489. /**
  69490. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69491. */
  69492. centripetalForceThreshold: number;
  69493. /**
  69494. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69495. */
  69496. centripetalForceMultiplier: number;
  69497. /**
  69498. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69499. */
  69500. centrifugalForceMultiplier: number;
  69501. /**
  69502. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69503. */
  69504. updraftForceMultiplier: number;
  69505. }
  69506. /**
  69507. * The strenght of the force in correspondence to the distance of the affected object
  69508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69509. */
  69510. export enum PhysicsRadialImpulseFalloff {
  69511. /** Defines that impulse is constant in strength across it's whole radius */
  69512. Constant = 0,
  69513. /** Defines that impulse gets weaker if it's further from the origin */
  69514. Linear = 1
  69515. }
  69516. /**
  69517. * The strength of the force in correspondence to the distance of the affected object
  69518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69519. */
  69520. export enum PhysicsUpdraftMode {
  69521. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69522. Center = 0,
  69523. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69524. Perpendicular = 1
  69525. }
  69526. /**
  69527. * Interface for a physics hit data
  69528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69529. */
  69530. export interface PhysicsHitData {
  69531. /**
  69532. * The force applied at the contact point
  69533. */
  69534. force: Vector3;
  69535. /**
  69536. * The contact point
  69537. */
  69538. contactPoint: Vector3;
  69539. /**
  69540. * The distance from the origin to the contact point
  69541. */
  69542. distanceFromOrigin: number;
  69543. }
  69544. /**
  69545. * Interface for radial explosion event data
  69546. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69547. */
  69548. export interface PhysicsRadialExplosionEventData {
  69549. /**
  69550. * A sphere used for the radial explosion event
  69551. */
  69552. sphere: Mesh;
  69553. }
  69554. /**
  69555. * Interface for gravitational field event data
  69556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69557. */
  69558. export interface PhysicsGravitationalFieldEventData {
  69559. /**
  69560. * A sphere mesh used for the gravitational field event
  69561. */
  69562. sphere: Mesh;
  69563. }
  69564. /**
  69565. * Interface for updraft event data
  69566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69567. */
  69568. export interface PhysicsUpdraftEventData {
  69569. /**
  69570. * A cylinder used for the updraft event
  69571. */
  69572. cylinder: Mesh;
  69573. }
  69574. /**
  69575. * Interface for vortex event data
  69576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69577. */
  69578. export interface PhysicsVortexEventData {
  69579. /**
  69580. * A cylinder used for the vortex event
  69581. */
  69582. cylinder: Mesh;
  69583. }
  69584. /**
  69585. * Interface for an affected physics impostor
  69586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69587. */
  69588. export interface PhysicsAffectedImpostorWithData {
  69589. /**
  69590. * The impostor affected by the effect
  69591. */
  69592. impostor: PhysicsImpostor;
  69593. /**
  69594. * The data about the hit/horce from the explosion
  69595. */
  69596. hitData: PhysicsHitData;
  69597. }
  69598. }
  69599. declare module BABYLON {
  69600. /** @hidden */
  69601. export var blackAndWhitePixelShader: {
  69602. name: string;
  69603. shader: string;
  69604. };
  69605. }
  69606. declare module BABYLON {
  69607. /**
  69608. * Post process used to render in black and white
  69609. */
  69610. export class BlackAndWhitePostProcess extends PostProcess {
  69611. /**
  69612. * Linear about to convert he result to black and white (default: 1)
  69613. */
  69614. degree: number;
  69615. /**
  69616. * Gets a string identifying the name of the class
  69617. * @returns "BlackAndWhitePostProcess" string
  69618. */
  69619. getClassName(): string;
  69620. /**
  69621. * Creates a black and white post process
  69622. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69623. * @param name The name of the effect.
  69624. * @param options The required width/height ratio to downsize to before computing the render pass.
  69625. * @param camera The camera to apply the render pass to.
  69626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69627. * @param engine The engine which the post process will be applied. (default: current engine)
  69628. * @param reusable If the post process can be reused on the same frame. (default: false)
  69629. */
  69630. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69631. /** @hidden */
  69632. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69633. }
  69634. }
  69635. declare module BABYLON {
  69636. /**
  69637. * This represents a set of one or more post processes in Babylon.
  69638. * A post process can be used to apply a shader to a texture after it is rendered.
  69639. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69640. */
  69641. export class PostProcessRenderEffect {
  69642. private _postProcesses;
  69643. private _getPostProcesses;
  69644. private _singleInstance;
  69645. private _cameras;
  69646. private _indicesForCamera;
  69647. /**
  69648. * Name of the effect
  69649. * @hidden
  69650. */
  69651. _name: string;
  69652. /**
  69653. * Instantiates a post process render effect.
  69654. * A post process can be used to apply a shader to a texture after it is rendered.
  69655. * @param engine The engine the effect is tied to
  69656. * @param name The name of the effect
  69657. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69658. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69659. */
  69660. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69661. /**
  69662. * Checks if all the post processes in the effect are supported.
  69663. */
  69664. get isSupported(): boolean;
  69665. /**
  69666. * Updates the current state of the effect
  69667. * @hidden
  69668. */
  69669. _update(): void;
  69670. /**
  69671. * Attaches the effect on cameras
  69672. * @param cameras The camera to attach to.
  69673. * @hidden
  69674. */
  69675. _attachCameras(cameras: Camera): void;
  69676. /**
  69677. * Attaches the effect on cameras
  69678. * @param cameras The camera to attach to.
  69679. * @hidden
  69680. */
  69681. _attachCameras(cameras: Camera[]): void;
  69682. /**
  69683. * Detaches the effect on cameras
  69684. * @param cameras The camera to detatch from.
  69685. * @hidden
  69686. */
  69687. _detachCameras(cameras: Camera): void;
  69688. /**
  69689. * Detatches the effect on cameras
  69690. * @param cameras The camera to detatch from.
  69691. * @hidden
  69692. */
  69693. _detachCameras(cameras: Camera[]): void;
  69694. /**
  69695. * Enables the effect on given cameras
  69696. * @param cameras The camera to enable.
  69697. * @hidden
  69698. */
  69699. _enable(cameras: Camera): void;
  69700. /**
  69701. * Enables the effect on given cameras
  69702. * @param cameras The camera to enable.
  69703. * @hidden
  69704. */
  69705. _enable(cameras: Nullable<Camera[]>): void;
  69706. /**
  69707. * Disables the effect on the given cameras
  69708. * @param cameras The camera to disable.
  69709. * @hidden
  69710. */
  69711. _disable(cameras: Camera): void;
  69712. /**
  69713. * Disables the effect on the given cameras
  69714. * @param cameras The camera to disable.
  69715. * @hidden
  69716. */
  69717. _disable(cameras: Nullable<Camera[]>): void;
  69718. /**
  69719. * Gets a list of the post processes contained in the effect.
  69720. * @param camera The camera to get the post processes on.
  69721. * @returns The list of the post processes in the effect.
  69722. */
  69723. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69724. }
  69725. }
  69726. declare module BABYLON {
  69727. /** @hidden */
  69728. export var extractHighlightsPixelShader: {
  69729. name: string;
  69730. shader: string;
  69731. };
  69732. }
  69733. declare module BABYLON {
  69734. /**
  69735. * 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.
  69736. */
  69737. export class ExtractHighlightsPostProcess extends PostProcess {
  69738. /**
  69739. * The luminance threshold, pixels below this value will be set to black.
  69740. */
  69741. threshold: number;
  69742. /** @hidden */
  69743. _exposure: number;
  69744. /**
  69745. * Post process which has the input texture to be used when performing highlight extraction
  69746. * @hidden
  69747. */
  69748. _inputPostProcess: Nullable<PostProcess>;
  69749. /**
  69750. * Gets a string identifying the name of the class
  69751. * @returns "ExtractHighlightsPostProcess" string
  69752. */
  69753. getClassName(): string;
  69754. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69755. }
  69756. }
  69757. declare module BABYLON {
  69758. /** @hidden */
  69759. export var bloomMergePixelShader: {
  69760. name: string;
  69761. shader: string;
  69762. };
  69763. }
  69764. declare module BABYLON {
  69765. /**
  69766. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69767. */
  69768. export class BloomMergePostProcess extends PostProcess {
  69769. /** Weight of the bloom to be added to the original input. */
  69770. weight: number;
  69771. /**
  69772. * Gets a string identifying the name of the class
  69773. * @returns "BloomMergePostProcess" string
  69774. */
  69775. getClassName(): string;
  69776. /**
  69777. * Creates a new instance of @see BloomMergePostProcess
  69778. * @param name The name of the effect.
  69779. * @param originalFromInput Post process which's input will be used for the merge.
  69780. * @param blurred Blurred highlights post process which's output will be used.
  69781. * @param weight Weight of the bloom to be added to the original input.
  69782. * @param options The required width/height ratio to downsize to before computing the render pass.
  69783. * @param camera The camera to apply the render pass to.
  69784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69785. * @param engine The engine which the post process will be applied. (default: current engine)
  69786. * @param reusable If the post process can be reused on the same frame. (default: false)
  69787. * @param textureType Type of textures used when performing the post process. (default: 0)
  69788. * @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)
  69789. */
  69790. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69791. /** Weight of the bloom to be added to the original input. */
  69792. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69793. }
  69794. }
  69795. declare module BABYLON {
  69796. /**
  69797. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69798. */
  69799. export class BloomEffect extends PostProcessRenderEffect {
  69800. private bloomScale;
  69801. /**
  69802. * @hidden Internal
  69803. */
  69804. _effects: Array<PostProcess>;
  69805. /**
  69806. * @hidden Internal
  69807. */
  69808. _downscale: ExtractHighlightsPostProcess;
  69809. private _blurX;
  69810. private _blurY;
  69811. private _merge;
  69812. /**
  69813. * The luminance threshold to find bright areas of the image to bloom.
  69814. */
  69815. get threshold(): number;
  69816. set threshold(value: number);
  69817. /**
  69818. * The strength of the bloom.
  69819. */
  69820. get weight(): number;
  69821. set weight(value: number);
  69822. /**
  69823. * Specifies the size of the bloom blur kernel, relative to the final output size
  69824. */
  69825. get kernel(): number;
  69826. set kernel(value: number);
  69827. /**
  69828. * Creates a new instance of @see BloomEffect
  69829. * @param scene The scene the effect belongs to.
  69830. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69831. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69832. * @param bloomWeight The the strength of bloom.
  69833. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69834. * @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)
  69835. */
  69836. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69837. /**
  69838. * Disposes each of the internal effects for a given camera.
  69839. * @param camera The camera to dispose the effect on.
  69840. */
  69841. disposeEffects(camera: Camera): void;
  69842. /**
  69843. * @hidden Internal
  69844. */
  69845. _updateEffects(): void;
  69846. /**
  69847. * Internal
  69848. * @returns if all the contained post processes are ready.
  69849. * @hidden
  69850. */
  69851. _isReady(): boolean;
  69852. }
  69853. }
  69854. declare module BABYLON {
  69855. /** @hidden */
  69856. export var chromaticAberrationPixelShader: {
  69857. name: string;
  69858. shader: string;
  69859. };
  69860. }
  69861. declare module BABYLON {
  69862. /**
  69863. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69864. */
  69865. export class ChromaticAberrationPostProcess extends PostProcess {
  69866. /**
  69867. * The amount of seperation of rgb channels (default: 30)
  69868. */
  69869. aberrationAmount: number;
  69870. /**
  69871. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69872. */
  69873. radialIntensity: number;
  69874. /**
  69875. * 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))
  69876. */
  69877. direction: Vector2;
  69878. /**
  69879. * 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))
  69880. */
  69881. centerPosition: Vector2;
  69882. /** The width of the screen to apply the effect on */
  69883. screenWidth: number;
  69884. /** The height of the screen to apply the effect on */
  69885. screenHeight: number;
  69886. /**
  69887. * Gets a string identifying the name of the class
  69888. * @returns "ChromaticAberrationPostProcess" string
  69889. */
  69890. getClassName(): string;
  69891. /**
  69892. * Creates a new instance ChromaticAberrationPostProcess
  69893. * @param name The name of the effect.
  69894. * @param screenWidth The width of the screen to apply the effect on.
  69895. * @param screenHeight The height of the screen to apply the effect on.
  69896. * @param options The required width/height ratio to downsize to before computing the render pass.
  69897. * @param camera The camera to apply the render pass to.
  69898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69899. * @param engine The engine which the post process will be applied. (default: current engine)
  69900. * @param reusable If the post process can be reused on the same frame. (default: false)
  69901. * @param textureType Type of textures used when performing the post process. (default: 0)
  69902. * @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)
  69903. */
  69904. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69905. /** @hidden */
  69906. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69907. }
  69908. }
  69909. declare module BABYLON {
  69910. /** @hidden */
  69911. export var circleOfConfusionPixelShader: {
  69912. name: string;
  69913. shader: string;
  69914. };
  69915. }
  69916. declare module BABYLON {
  69917. /**
  69918. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69919. */
  69920. export class CircleOfConfusionPostProcess extends PostProcess {
  69921. /**
  69922. * 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.
  69923. */
  69924. lensSize: number;
  69925. /**
  69926. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69927. */
  69928. fStop: number;
  69929. /**
  69930. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69931. */
  69932. focusDistance: number;
  69933. /**
  69934. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69935. */
  69936. focalLength: number;
  69937. /**
  69938. * Gets a string identifying the name of the class
  69939. * @returns "CircleOfConfusionPostProcess" string
  69940. */
  69941. getClassName(): string;
  69942. private _depthTexture;
  69943. /**
  69944. * Creates a new instance CircleOfConfusionPostProcess
  69945. * @param name The name of the effect.
  69946. * @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.
  69947. * @param options The required width/height ratio to downsize to before computing the render pass.
  69948. * @param camera The camera to apply the render pass to.
  69949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69950. * @param engine The engine which the post process will be applied. (default: current engine)
  69951. * @param reusable If the post process can be reused on the same frame. (default: false)
  69952. * @param textureType Type of textures used when performing the post process. (default: 0)
  69953. * @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)
  69954. */
  69955. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69956. /**
  69957. * 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.
  69958. */
  69959. set depthTexture(value: RenderTargetTexture);
  69960. }
  69961. }
  69962. declare module BABYLON {
  69963. /** @hidden */
  69964. export var colorCorrectionPixelShader: {
  69965. name: string;
  69966. shader: string;
  69967. };
  69968. }
  69969. declare module BABYLON {
  69970. /**
  69971. *
  69972. * This post-process allows the modification of rendered colors by using
  69973. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69974. *
  69975. * The object needs to be provided an url to a texture containing the color
  69976. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69977. * Use an image editing software to tweak the LUT to match your needs.
  69978. *
  69979. * For an example of a color LUT, see here:
  69980. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69981. * For explanations on color grading, see here:
  69982. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69983. *
  69984. */
  69985. export class ColorCorrectionPostProcess extends PostProcess {
  69986. private _colorTableTexture;
  69987. /**
  69988. * Gets the color table url used to create the LUT texture
  69989. */
  69990. colorTableUrl: string;
  69991. /**
  69992. * Gets a string identifying the name of the class
  69993. * @returns "ColorCorrectionPostProcess" string
  69994. */
  69995. getClassName(): string;
  69996. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69997. /** @hidden */
  69998. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69999. }
  70000. }
  70001. declare module BABYLON {
  70002. /** @hidden */
  70003. export var convolutionPixelShader: {
  70004. name: string;
  70005. shader: string;
  70006. };
  70007. }
  70008. declare module BABYLON {
  70009. /**
  70010. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70011. * input texture to perform effects such as edge detection or sharpening
  70012. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70013. */
  70014. export class ConvolutionPostProcess extends PostProcess {
  70015. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70016. kernel: number[];
  70017. /**
  70018. * Gets a string identifying the name of the class
  70019. * @returns "ConvolutionPostProcess" string
  70020. */
  70021. getClassName(): string;
  70022. /**
  70023. * Creates a new instance ConvolutionPostProcess
  70024. * @param name The name of the effect.
  70025. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70026. * @param options The required width/height ratio to downsize to before computing the render pass.
  70027. * @param camera The camera to apply the render pass to.
  70028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70029. * @param engine The engine which the post process will be applied. (default: current engine)
  70030. * @param reusable If the post process can be reused on the same frame. (default: false)
  70031. * @param textureType Type of textures used when performing the post process. (default: 0)
  70032. */
  70033. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70034. /** @hidden */
  70035. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70036. /**
  70037. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70038. */
  70039. static EdgeDetect0Kernel: number[];
  70040. /**
  70041. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70042. */
  70043. static EdgeDetect1Kernel: number[];
  70044. /**
  70045. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70046. */
  70047. static EdgeDetect2Kernel: number[];
  70048. /**
  70049. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70050. */
  70051. static SharpenKernel: number[];
  70052. /**
  70053. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70054. */
  70055. static EmbossKernel: number[];
  70056. /**
  70057. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70058. */
  70059. static GaussianKernel: number[];
  70060. }
  70061. }
  70062. declare module BABYLON {
  70063. /**
  70064. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70065. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70066. * based on samples that have a large difference in distance than the center pixel.
  70067. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70068. */
  70069. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70070. /**
  70071. * The direction the blur should be applied
  70072. */
  70073. direction: Vector2;
  70074. /**
  70075. * Gets a string identifying the name of the class
  70076. * @returns "DepthOfFieldBlurPostProcess" string
  70077. */
  70078. getClassName(): string;
  70079. /**
  70080. * Creates a new instance CircleOfConfusionPostProcess
  70081. * @param name The name of the effect.
  70082. * @param scene The scene the effect belongs to.
  70083. * @param direction The direction the blur should be applied.
  70084. * @param kernel The size of the kernel used to blur.
  70085. * @param options The required width/height ratio to downsize to before computing the render pass.
  70086. * @param camera The camera to apply the render pass to.
  70087. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70088. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70090. * @param engine The engine which the post process will be applied. (default: current engine)
  70091. * @param reusable If the post process can be reused on the same frame. (default: false)
  70092. * @param textureType Type of textures used when performing the post process. (default: 0)
  70093. * @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)
  70094. */
  70095. 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);
  70096. }
  70097. }
  70098. declare module BABYLON {
  70099. /** @hidden */
  70100. export var depthOfFieldMergePixelShader: {
  70101. name: string;
  70102. shader: string;
  70103. };
  70104. }
  70105. declare module BABYLON {
  70106. /**
  70107. * Options to be set when merging outputs from the default pipeline.
  70108. */
  70109. export class DepthOfFieldMergePostProcessOptions {
  70110. /**
  70111. * The original image to merge on top of
  70112. */
  70113. originalFromInput: PostProcess;
  70114. /**
  70115. * Parameters to perform the merge of the depth of field effect
  70116. */
  70117. depthOfField?: {
  70118. circleOfConfusion: PostProcess;
  70119. blurSteps: Array<PostProcess>;
  70120. };
  70121. /**
  70122. * Parameters to perform the merge of bloom effect
  70123. */
  70124. bloom?: {
  70125. blurred: PostProcess;
  70126. weight: number;
  70127. };
  70128. }
  70129. /**
  70130. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70131. */
  70132. export class DepthOfFieldMergePostProcess extends PostProcess {
  70133. private blurSteps;
  70134. /**
  70135. * Gets a string identifying the name of the class
  70136. * @returns "DepthOfFieldMergePostProcess" string
  70137. */
  70138. getClassName(): string;
  70139. /**
  70140. * Creates a new instance of DepthOfFieldMergePostProcess
  70141. * @param name The name of the effect.
  70142. * @param originalFromInput Post process which's input will be used for the merge.
  70143. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70144. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70145. * @param options The required width/height ratio to downsize to before computing the render pass.
  70146. * @param camera The camera to apply the render pass to.
  70147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70148. * @param engine The engine which the post process will be applied. (default: current engine)
  70149. * @param reusable If the post process can be reused on the same frame. (default: false)
  70150. * @param textureType Type of textures used when performing the post process. (default: 0)
  70151. * @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)
  70152. */
  70153. 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);
  70154. /**
  70155. * Updates the effect with the current post process compile time values and recompiles the shader.
  70156. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70157. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70158. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70159. * @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
  70160. * @param onCompiled Called when the shader has been compiled.
  70161. * @param onError Called if there is an error when compiling a shader.
  70162. */
  70163. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70164. }
  70165. }
  70166. declare module BABYLON {
  70167. /**
  70168. * Specifies the level of max blur that should be applied when using the depth of field effect
  70169. */
  70170. export enum DepthOfFieldEffectBlurLevel {
  70171. /**
  70172. * Subtle blur
  70173. */
  70174. Low = 0,
  70175. /**
  70176. * Medium blur
  70177. */
  70178. Medium = 1,
  70179. /**
  70180. * Large blur
  70181. */
  70182. High = 2
  70183. }
  70184. /**
  70185. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70186. */
  70187. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70188. private _circleOfConfusion;
  70189. /**
  70190. * @hidden Internal, blurs from high to low
  70191. */
  70192. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70193. private _depthOfFieldBlurY;
  70194. private _dofMerge;
  70195. /**
  70196. * @hidden Internal post processes in depth of field effect
  70197. */
  70198. _effects: Array<PostProcess>;
  70199. /**
  70200. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70201. */
  70202. set focalLength(value: number);
  70203. get focalLength(): number;
  70204. /**
  70205. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70206. */
  70207. set fStop(value: number);
  70208. get fStop(): number;
  70209. /**
  70210. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70211. */
  70212. set focusDistance(value: number);
  70213. get focusDistance(): number;
  70214. /**
  70215. * 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.
  70216. */
  70217. set lensSize(value: number);
  70218. get lensSize(): number;
  70219. /**
  70220. * Creates a new instance DepthOfFieldEffect
  70221. * @param scene The scene the effect belongs to.
  70222. * @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.
  70223. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70224. * @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)
  70225. */
  70226. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70227. /**
  70228. * Get the current class name of the current effet
  70229. * @returns "DepthOfFieldEffect"
  70230. */
  70231. getClassName(): string;
  70232. /**
  70233. * 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.
  70234. */
  70235. set depthTexture(value: RenderTargetTexture);
  70236. /**
  70237. * Disposes each of the internal effects for a given camera.
  70238. * @param camera The camera to dispose the effect on.
  70239. */
  70240. disposeEffects(camera: Camera): void;
  70241. /**
  70242. * @hidden Internal
  70243. */
  70244. _updateEffects(): void;
  70245. /**
  70246. * Internal
  70247. * @returns if all the contained post processes are ready.
  70248. * @hidden
  70249. */
  70250. _isReady(): boolean;
  70251. }
  70252. }
  70253. declare module BABYLON {
  70254. /** @hidden */
  70255. export var displayPassPixelShader: {
  70256. name: string;
  70257. shader: string;
  70258. };
  70259. }
  70260. declare module BABYLON {
  70261. /**
  70262. * DisplayPassPostProcess which produces an output the same as it's input
  70263. */
  70264. export class DisplayPassPostProcess extends PostProcess {
  70265. /**
  70266. * Gets a string identifying the name of the class
  70267. * @returns "DisplayPassPostProcess" string
  70268. */
  70269. getClassName(): string;
  70270. /**
  70271. * Creates the DisplayPassPostProcess
  70272. * @param name The name of the effect.
  70273. * @param options The required width/height ratio to downsize to before computing the render pass.
  70274. * @param camera The camera to apply the render pass to.
  70275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70276. * @param engine The engine which the post process will be applied. (default: current engine)
  70277. * @param reusable If the post process can be reused on the same frame. (default: false)
  70278. */
  70279. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70280. /** @hidden */
  70281. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70282. }
  70283. }
  70284. declare module BABYLON {
  70285. /** @hidden */
  70286. export var filterPixelShader: {
  70287. name: string;
  70288. shader: string;
  70289. };
  70290. }
  70291. declare module BABYLON {
  70292. /**
  70293. * Applies a kernel filter to the image
  70294. */
  70295. export class FilterPostProcess extends PostProcess {
  70296. /** The matrix to be applied to the image */
  70297. kernelMatrix: Matrix;
  70298. /**
  70299. * Gets a string identifying the name of the class
  70300. * @returns "FilterPostProcess" string
  70301. */
  70302. getClassName(): string;
  70303. /**
  70304. *
  70305. * @param name The name of the effect.
  70306. * @param kernelMatrix The matrix to be applied to the image
  70307. * @param options The required width/height ratio to downsize to before computing the render pass.
  70308. * @param camera The camera to apply the render pass to.
  70309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70310. * @param engine The engine which the post process will be applied. (default: current engine)
  70311. * @param reusable If the post process can be reused on the same frame. (default: false)
  70312. */
  70313. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70314. /** @hidden */
  70315. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70316. }
  70317. }
  70318. declare module BABYLON {
  70319. /** @hidden */
  70320. export var fxaaPixelShader: {
  70321. name: string;
  70322. shader: string;
  70323. };
  70324. }
  70325. declare module BABYLON {
  70326. /** @hidden */
  70327. export var fxaaVertexShader: {
  70328. name: string;
  70329. shader: string;
  70330. };
  70331. }
  70332. declare module BABYLON {
  70333. /**
  70334. * Fxaa post process
  70335. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70336. */
  70337. export class FxaaPostProcess extends PostProcess {
  70338. /**
  70339. * Gets a string identifying the name of the class
  70340. * @returns "FxaaPostProcess" string
  70341. */
  70342. getClassName(): string;
  70343. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70344. private _getDefines;
  70345. /** @hidden */
  70346. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70347. }
  70348. }
  70349. declare module BABYLON {
  70350. /** @hidden */
  70351. export var grainPixelShader: {
  70352. name: string;
  70353. shader: string;
  70354. };
  70355. }
  70356. declare module BABYLON {
  70357. /**
  70358. * The GrainPostProcess adds noise to the image at mid luminance levels
  70359. */
  70360. export class GrainPostProcess extends PostProcess {
  70361. /**
  70362. * The intensity of the grain added (default: 30)
  70363. */
  70364. intensity: number;
  70365. /**
  70366. * If the grain should be randomized on every frame
  70367. */
  70368. animated: boolean;
  70369. /**
  70370. * Gets a string identifying the name of the class
  70371. * @returns "GrainPostProcess" string
  70372. */
  70373. getClassName(): string;
  70374. /**
  70375. * Creates a new instance of @see GrainPostProcess
  70376. * @param name The name of the effect.
  70377. * @param options The required width/height ratio to downsize to before computing the render pass.
  70378. * @param camera The camera to apply the render pass to.
  70379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70380. * @param engine The engine which the post process will be applied. (default: current engine)
  70381. * @param reusable If the post process can be reused on the same frame. (default: false)
  70382. * @param textureType Type of textures used when performing the post process. (default: 0)
  70383. * @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)
  70384. */
  70385. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70386. /** @hidden */
  70387. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70388. }
  70389. }
  70390. declare module BABYLON {
  70391. /** @hidden */
  70392. export var highlightsPixelShader: {
  70393. name: string;
  70394. shader: string;
  70395. };
  70396. }
  70397. declare module BABYLON {
  70398. /**
  70399. * Extracts highlights from the image
  70400. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70401. */
  70402. export class HighlightsPostProcess extends PostProcess {
  70403. /**
  70404. * Gets a string identifying the name of the class
  70405. * @returns "HighlightsPostProcess" string
  70406. */
  70407. getClassName(): string;
  70408. /**
  70409. * Extracts highlights from the image
  70410. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70411. * @param name The name of the effect.
  70412. * @param options The required width/height ratio to downsize to before computing the render pass.
  70413. * @param camera The camera to apply the render pass to.
  70414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70415. * @param engine The engine which the post process will be applied. (default: current engine)
  70416. * @param reusable If the post process can be reused on the same frame. (default: false)
  70417. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70418. */
  70419. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70420. }
  70421. }
  70422. declare module BABYLON {
  70423. /**
  70424. * Contains all parameters needed for the prepass to perform
  70425. * motion blur
  70426. */
  70427. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70428. /**
  70429. * Is motion blur enabled
  70430. */
  70431. enabled: boolean;
  70432. /**
  70433. * Name of the configuration
  70434. */
  70435. name: string;
  70436. /**
  70437. * Textures that should be present in the MRT for this effect to work
  70438. */
  70439. readonly texturesRequired: number[];
  70440. }
  70441. }
  70442. declare module BABYLON {
  70443. interface Scene {
  70444. /** @hidden (Backing field) */
  70445. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70446. /**
  70447. * Gets or Sets the current geometry buffer associated to the scene.
  70448. */
  70449. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70450. /**
  70451. * Enables a GeometryBufferRender and associates it with the scene
  70452. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70453. * @returns the GeometryBufferRenderer
  70454. */
  70455. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70456. /**
  70457. * Disables the GeometryBufferRender associated with the scene
  70458. */
  70459. disableGeometryBufferRenderer(): void;
  70460. }
  70461. /**
  70462. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70463. * in several rendering techniques.
  70464. */
  70465. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70466. /**
  70467. * The component name helpful to identify the component in the list of scene components.
  70468. */
  70469. readonly name: string;
  70470. /**
  70471. * The scene the component belongs to.
  70472. */
  70473. scene: Scene;
  70474. /**
  70475. * Creates a new instance of the component for the given scene
  70476. * @param scene Defines the scene to register the component in
  70477. */
  70478. constructor(scene: Scene);
  70479. /**
  70480. * Registers the component in a given scene
  70481. */
  70482. register(): void;
  70483. /**
  70484. * Rebuilds the elements related to this component in case of
  70485. * context lost for instance.
  70486. */
  70487. rebuild(): void;
  70488. /**
  70489. * Disposes the component and the associated ressources
  70490. */
  70491. dispose(): void;
  70492. private _gatherRenderTargets;
  70493. }
  70494. }
  70495. declare module BABYLON {
  70496. /** @hidden */
  70497. export var motionBlurPixelShader: {
  70498. name: string;
  70499. shader: string;
  70500. };
  70501. }
  70502. declare module BABYLON {
  70503. /**
  70504. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70505. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70506. * As an example, all you have to do is to create the post-process:
  70507. * var mb = new BABYLON.MotionBlurPostProcess(
  70508. * 'mb', // The name of the effect.
  70509. * scene, // The scene containing the objects to blur according to their velocity.
  70510. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70511. * camera // The camera to apply the render pass to.
  70512. * );
  70513. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70514. */
  70515. export class MotionBlurPostProcess extends PostProcess {
  70516. /**
  70517. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70518. */
  70519. motionStrength: number;
  70520. /**
  70521. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70522. */
  70523. get motionBlurSamples(): number;
  70524. /**
  70525. * Sets the number of iterations to be used for motion blur quality
  70526. */
  70527. set motionBlurSamples(samples: number);
  70528. private _motionBlurSamples;
  70529. private _forceGeometryBuffer;
  70530. private _geometryBufferRenderer;
  70531. private _prePassRenderer;
  70532. /**
  70533. * Gets a string identifying the name of the class
  70534. * @returns "MotionBlurPostProcess" string
  70535. */
  70536. getClassName(): string;
  70537. /**
  70538. * Creates a new instance MotionBlurPostProcess
  70539. * @param name The name of the effect.
  70540. * @param scene The scene containing the objects to blur according to their velocity.
  70541. * @param options The required width/height ratio to downsize to before computing the render pass.
  70542. * @param camera The camera to apply the render pass to.
  70543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70544. * @param engine The engine which the post process will be applied. (default: current engine)
  70545. * @param reusable If the post process can be reused on the same frame. (default: false)
  70546. * @param textureType Type of textures used when performing the post process. (default: 0)
  70547. * @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)
  70548. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  70549. */
  70550. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  70551. /**
  70552. * Excludes the given skinned mesh from computing bones velocities.
  70553. * 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.
  70554. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70555. */
  70556. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70557. /**
  70558. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70559. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70560. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70561. */
  70562. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70563. /**
  70564. * Disposes the post process.
  70565. * @param camera The camera to dispose the post process on.
  70566. */
  70567. dispose(camera?: Camera): void;
  70568. /** @hidden */
  70569. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70570. }
  70571. }
  70572. declare module BABYLON {
  70573. /** @hidden */
  70574. export var refractionPixelShader: {
  70575. name: string;
  70576. shader: string;
  70577. };
  70578. }
  70579. declare module BABYLON {
  70580. /**
  70581. * Post process which applies a refractin texture
  70582. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70583. */
  70584. export class RefractionPostProcess extends PostProcess {
  70585. private _refTexture;
  70586. private _ownRefractionTexture;
  70587. /** the base color of the refraction (used to taint the rendering) */
  70588. color: Color3;
  70589. /** simulated refraction depth */
  70590. depth: number;
  70591. /** the coefficient of the base color (0 to remove base color tainting) */
  70592. colorLevel: number;
  70593. /** Gets the url used to load the refraction texture */
  70594. refractionTextureUrl: string;
  70595. /**
  70596. * Gets or sets the refraction texture
  70597. * Please note that you are responsible for disposing the texture if you set it manually
  70598. */
  70599. get refractionTexture(): Texture;
  70600. set refractionTexture(value: Texture);
  70601. /**
  70602. * Gets a string identifying the name of the class
  70603. * @returns "RefractionPostProcess" string
  70604. */
  70605. getClassName(): string;
  70606. /**
  70607. * Initializes the RefractionPostProcess
  70608. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70609. * @param name The name of the effect.
  70610. * @param refractionTextureUrl Url of the refraction texture to use
  70611. * @param color the base color of the refraction (used to taint the rendering)
  70612. * @param depth simulated refraction depth
  70613. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70614. * @param camera The camera to apply the render pass to.
  70615. * @param options The required width/height ratio to downsize to before computing the render pass.
  70616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70617. * @param engine The engine which the post process will be applied. (default: current engine)
  70618. * @param reusable If the post process can be reused on the same frame. (default: false)
  70619. */
  70620. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70621. /**
  70622. * Disposes of the post process
  70623. * @param camera Camera to dispose post process on
  70624. */
  70625. dispose(camera: Camera): void;
  70626. /** @hidden */
  70627. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70628. }
  70629. }
  70630. declare module BABYLON {
  70631. /** @hidden */
  70632. export var sharpenPixelShader: {
  70633. name: string;
  70634. shader: string;
  70635. };
  70636. }
  70637. declare module BABYLON {
  70638. /**
  70639. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70640. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70641. */
  70642. export class SharpenPostProcess extends PostProcess {
  70643. /**
  70644. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70645. */
  70646. colorAmount: number;
  70647. /**
  70648. * How much sharpness should be applied (default: 0.3)
  70649. */
  70650. edgeAmount: number;
  70651. /**
  70652. * Gets a string identifying the name of the class
  70653. * @returns "SharpenPostProcess" string
  70654. */
  70655. getClassName(): string;
  70656. /**
  70657. * Creates a new instance ConvolutionPostProcess
  70658. * @param name The name of the effect.
  70659. * @param options The required width/height ratio to downsize to before computing the render pass.
  70660. * @param camera The camera to apply the render pass to.
  70661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70662. * @param engine The engine which the post process will be applied. (default: current engine)
  70663. * @param reusable If the post process can be reused on the same frame. (default: false)
  70664. * @param textureType Type of textures used when performing the post process. (default: 0)
  70665. * @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)
  70666. */
  70667. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70668. /** @hidden */
  70669. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70670. }
  70671. }
  70672. declare module BABYLON {
  70673. /**
  70674. * PostProcessRenderPipeline
  70675. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70676. */
  70677. export class PostProcessRenderPipeline {
  70678. private engine;
  70679. private _renderEffects;
  70680. private _renderEffectsForIsolatedPass;
  70681. /**
  70682. * List of inspectable custom properties (used by the Inspector)
  70683. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70684. */
  70685. inspectableCustomProperties: IInspectable[];
  70686. /**
  70687. * @hidden
  70688. */
  70689. protected _cameras: Camera[];
  70690. /** @hidden */
  70691. _name: string;
  70692. /**
  70693. * Gets pipeline name
  70694. */
  70695. get name(): string;
  70696. /** Gets the list of attached cameras */
  70697. get cameras(): Camera[];
  70698. /**
  70699. * Initializes a PostProcessRenderPipeline
  70700. * @param engine engine to add the pipeline to
  70701. * @param name name of the pipeline
  70702. */
  70703. constructor(engine: Engine, name: string);
  70704. /**
  70705. * Gets the class name
  70706. * @returns "PostProcessRenderPipeline"
  70707. */
  70708. getClassName(): string;
  70709. /**
  70710. * If all the render effects in the pipeline are supported
  70711. */
  70712. get isSupported(): boolean;
  70713. /**
  70714. * Adds an effect to the pipeline
  70715. * @param renderEffect the effect to add
  70716. */
  70717. addEffect(renderEffect: PostProcessRenderEffect): void;
  70718. /** @hidden */
  70719. _rebuild(): void;
  70720. /** @hidden */
  70721. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70722. /** @hidden */
  70723. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70724. /** @hidden */
  70725. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70726. /** @hidden */
  70727. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70728. /** @hidden */
  70729. _attachCameras(cameras: Camera, unique: boolean): void;
  70730. /** @hidden */
  70731. _attachCameras(cameras: Camera[], unique: boolean): void;
  70732. /** @hidden */
  70733. _detachCameras(cameras: Camera): void;
  70734. /** @hidden */
  70735. _detachCameras(cameras: Nullable<Camera[]>): void;
  70736. /** @hidden */
  70737. _update(): void;
  70738. /** @hidden */
  70739. _reset(): void;
  70740. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70741. /**
  70742. * Sets the required values to the prepass renderer.
  70743. * @param prePassRenderer defines the prepass renderer to setup.
  70744. * @returns true if the pre pass is needed.
  70745. */
  70746. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70747. /**
  70748. * Disposes of the pipeline
  70749. */
  70750. dispose(): void;
  70751. }
  70752. }
  70753. declare module BABYLON {
  70754. /**
  70755. * PostProcessRenderPipelineManager class
  70756. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70757. */
  70758. export class PostProcessRenderPipelineManager {
  70759. private _renderPipelines;
  70760. /**
  70761. * Initializes a PostProcessRenderPipelineManager
  70762. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70763. */
  70764. constructor();
  70765. /**
  70766. * Gets the list of supported render pipelines
  70767. */
  70768. get supportedPipelines(): PostProcessRenderPipeline[];
  70769. /**
  70770. * Adds a pipeline to the manager
  70771. * @param renderPipeline The pipeline to add
  70772. */
  70773. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70774. /**
  70775. * Attaches a camera to the pipeline
  70776. * @param renderPipelineName The name of the pipeline to attach to
  70777. * @param cameras the camera to attach
  70778. * @param unique if the camera can be attached multiple times to the pipeline
  70779. */
  70780. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70781. /**
  70782. * Detaches a camera from the pipeline
  70783. * @param renderPipelineName The name of the pipeline to detach from
  70784. * @param cameras the camera to detach
  70785. */
  70786. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70787. /**
  70788. * Enables an effect by name on a pipeline
  70789. * @param renderPipelineName the name of the pipeline to enable the effect in
  70790. * @param renderEffectName the name of the effect to enable
  70791. * @param cameras the cameras that the effect should be enabled on
  70792. */
  70793. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70794. /**
  70795. * Disables an effect by name on a pipeline
  70796. * @param renderPipelineName the name of the pipeline to disable the effect in
  70797. * @param renderEffectName the name of the effect to disable
  70798. * @param cameras the cameras that the effect should be disabled on
  70799. */
  70800. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70801. /**
  70802. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70803. */
  70804. update(): void;
  70805. /** @hidden */
  70806. _rebuild(): void;
  70807. /**
  70808. * Disposes of the manager and pipelines
  70809. */
  70810. dispose(): void;
  70811. }
  70812. }
  70813. declare module BABYLON {
  70814. interface Scene {
  70815. /** @hidden (Backing field) */
  70816. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70817. /**
  70818. * Gets the postprocess render pipeline manager
  70819. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70820. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70821. */
  70822. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70823. }
  70824. /**
  70825. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70826. */
  70827. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70828. /**
  70829. * The component name helpfull to identify the component in the list of scene components.
  70830. */
  70831. readonly name: string;
  70832. /**
  70833. * The scene the component belongs to.
  70834. */
  70835. scene: Scene;
  70836. /**
  70837. * Creates a new instance of the component for the given scene
  70838. * @param scene Defines the scene to register the component in
  70839. */
  70840. constructor(scene: Scene);
  70841. /**
  70842. * Registers the component in a given scene
  70843. */
  70844. register(): void;
  70845. /**
  70846. * Rebuilds the elements related to this component in case of
  70847. * context lost for instance.
  70848. */
  70849. rebuild(): void;
  70850. /**
  70851. * Disposes the component and the associated ressources
  70852. */
  70853. dispose(): void;
  70854. private _gatherRenderTargets;
  70855. }
  70856. }
  70857. declare module BABYLON {
  70858. /**
  70859. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70860. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70861. */
  70862. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70863. private _scene;
  70864. private _camerasToBeAttached;
  70865. /**
  70866. * ID of the sharpen post process,
  70867. */
  70868. private readonly SharpenPostProcessId;
  70869. /**
  70870. * @ignore
  70871. * ID of the image processing post process;
  70872. */
  70873. readonly ImageProcessingPostProcessId: string;
  70874. /**
  70875. * @ignore
  70876. * ID of the Fast Approximate Anti-Aliasing post process;
  70877. */
  70878. readonly FxaaPostProcessId: string;
  70879. /**
  70880. * ID of the chromatic aberration post process,
  70881. */
  70882. private readonly ChromaticAberrationPostProcessId;
  70883. /**
  70884. * ID of the grain post process
  70885. */
  70886. private readonly GrainPostProcessId;
  70887. /**
  70888. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70889. */
  70890. sharpen: SharpenPostProcess;
  70891. private _sharpenEffect;
  70892. private bloom;
  70893. /**
  70894. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70895. */
  70896. depthOfField: DepthOfFieldEffect;
  70897. /**
  70898. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70899. */
  70900. fxaa: FxaaPostProcess;
  70901. /**
  70902. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70903. */
  70904. imageProcessing: ImageProcessingPostProcess;
  70905. /**
  70906. * Chromatic aberration post process which will shift rgb colors in the image
  70907. */
  70908. chromaticAberration: ChromaticAberrationPostProcess;
  70909. private _chromaticAberrationEffect;
  70910. /**
  70911. * Grain post process which add noise to the image
  70912. */
  70913. grain: GrainPostProcess;
  70914. private _grainEffect;
  70915. /**
  70916. * Glow post process which adds a glow to emissive areas of the image
  70917. */
  70918. private _glowLayer;
  70919. /**
  70920. * Animations which can be used to tweak settings over a period of time
  70921. */
  70922. animations: Animation[];
  70923. private _imageProcessingConfigurationObserver;
  70924. private _sharpenEnabled;
  70925. private _bloomEnabled;
  70926. private _depthOfFieldEnabled;
  70927. private _depthOfFieldBlurLevel;
  70928. private _fxaaEnabled;
  70929. private _imageProcessingEnabled;
  70930. private _defaultPipelineTextureType;
  70931. private _bloomScale;
  70932. private _chromaticAberrationEnabled;
  70933. private _grainEnabled;
  70934. private _buildAllowed;
  70935. /**
  70936. * Gets active scene
  70937. */
  70938. get scene(): Scene;
  70939. /**
  70940. * Enable or disable the sharpen process from the pipeline
  70941. */
  70942. set sharpenEnabled(enabled: boolean);
  70943. get sharpenEnabled(): boolean;
  70944. private _resizeObserver;
  70945. private _hardwareScaleLevel;
  70946. private _bloomKernel;
  70947. /**
  70948. * Specifies the size of the bloom blur kernel, relative to the final output size
  70949. */
  70950. get bloomKernel(): number;
  70951. set bloomKernel(value: number);
  70952. /**
  70953. * Specifies the weight of the bloom in the final rendering
  70954. */
  70955. private _bloomWeight;
  70956. /**
  70957. * Specifies the luma threshold for the area that will be blurred by the bloom
  70958. */
  70959. private _bloomThreshold;
  70960. private _hdr;
  70961. /**
  70962. * The strength of the bloom.
  70963. */
  70964. set bloomWeight(value: number);
  70965. get bloomWeight(): number;
  70966. /**
  70967. * The strength of the bloom.
  70968. */
  70969. set bloomThreshold(value: number);
  70970. get bloomThreshold(): number;
  70971. /**
  70972. * The scale of the bloom, lower value will provide better performance.
  70973. */
  70974. set bloomScale(value: number);
  70975. get bloomScale(): number;
  70976. /**
  70977. * Enable or disable the bloom from the pipeline
  70978. */
  70979. set bloomEnabled(enabled: boolean);
  70980. get bloomEnabled(): boolean;
  70981. private _rebuildBloom;
  70982. /**
  70983. * If the depth of field is enabled.
  70984. */
  70985. get depthOfFieldEnabled(): boolean;
  70986. set depthOfFieldEnabled(enabled: boolean);
  70987. /**
  70988. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70989. */
  70990. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70991. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70992. /**
  70993. * If the anti aliasing is enabled.
  70994. */
  70995. set fxaaEnabled(enabled: boolean);
  70996. get fxaaEnabled(): boolean;
  70997. private _samples;
  70998. /**
  70999. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71000. */
  71001. set samples(sampleCount: number);
  71002. get samples(): number;
  71003. /**
  71004. * If image processing is enabled.
  71005. */
  71006. set imageProcessingEnabled(enabled: boolean);
  71007. get imageProcessingEnabled(): boolean;
  71008. /**
  71009. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71010. */
  71011. set glowLayerEnabled(enabled: boolean);
  71012. get glowLayerEnabled(): boolean;
  71013. /**
  71014. * Gets the glow layer (or null if not defined)
  71015. */
  71016. get glowLayer(): Nullable<GlowLayer>;
  71017. /**
  71018. * Enable or disable the chromaticAberration process from the pipeline
  71019. */
  71020. set chromaticAberrationEnabled(enabled: boolean);
  71021. get chromaticAberrationEnabled(): boolean;
  71022. /**
  71023. * Enable or disable the grain process from the pipeline
  71024. */
  71025. set grainEnabled(enabled: boolean);
  71026. get grainEnabled(): boolean;
  71027. /**
  71028. * @constructor
  71029. * @param name - The rendering pipeline name (default: "")
  71030. * @param hdr - If high dynamic range textures should be used (default: true)
  71031. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71032. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71033. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71034. */
  71035. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71036. /**
  71037. * Get the class name
  71038. * @returns "DefaultRenderingPipeline"
  71039. */
  71040. getClassName(): string;
  71041. /**
  71042. * Force the compilation of the entire pipeline.
  71043. */
  71044. prepare(): void;
  71045. private _hasCleared;
  71046. private _prevPostProcess;
  71047. private _prevPrevPostProcess;
  71048. private _setAutoClearAndTextureSharing;
  71049. private _depthOfFieldSceneObserver;
  71050. private _buildPipeline;
  71051. private _disposePostProcesses;
  71052. /**
  71053. * Adds a camera to the pipeline
  71054. * @param camera the camera to be added
  71055. */
  71056. addCamera(camera: Camera): void;
  71057. /**
  71058. * Removes a camera from the pipeline
  71059. * @param camera the camera to remove
  71060. */
  71061. removeCamera(camera: Camera): void;
  71062. /**
  71063. * Dispose of the pipeline and stop all post processes
  71064. */
  71065. dispose(): void;
  71066. /**
  71067. * Serialize the rendering pipeline (Used when exporting)
  71068. * @returns the serialized object
  71069. */
  71070. serialize(): any;
  71071. /**
  71072. * Parse the serialized pipeline
  71073. * @param source Source pipeline.
  71074. * @param scene The scene to load the pipeline to.
  71075. * @param rootUrl The URL of the serialized pipeline.
  71076. * @returns An instantiated pipeline from the serialized object.
  71077. */
  71078. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71079. }
  71080. }
  71081. declare module BABYLON {
  71082. /** @hidden */
  71083. export var lensHighlightsPixelShader: {
  71084. name: string;
  71085. shader: string;
  71086. };
  71087. }
  71088. declare module BABYLON {
  71089. /** @hidden */
  71090. export var depthOfFieldPixelShader: {
  71091. name: string;
  71092. shader: string;
  71093. };
  71094. }
  71095. declare module BABYLON {
  71096. /**
  71097. * BABYLON.JS Chromatic Aberration GLSL Shader
  71098. * Author: Olivier Guyot
  71099. * Separates very slightly R, G and B colors on the edges of the screen
  71100. * Inspired by Francois Tarlier & Martins Upitis
  71101. */
  71102. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71103. /**
  71104. * @ignore
  71105. * The chromatic aberration PostProcess id in the pipeline
  71106. */
  71107. LensChromaticAberrationEffect: string;
  71108. /**
  71109. * @ignore
  71110. * The highlights enhancing PostProcess id in the pipeline
  71111. */
  71112. HighlightsEnhancingEffect: string;
  71113. /**
  71114. * @ignore
  71115. * The depth-of-field PostProcess id in the pipeline
  71116. */
  71117. LensDepthOfFieldEffect: string;
  71118. private _scene;
  71119. private _depthTexture;
  71120. private _grainTexture;
  71121. private _chromaticAberrationPostProcess;
  71122. private _highlightsPostProcess;
  71123. private _depthOfFieldPostProcess;
  71124. private _edgeBlur;
  71125. private _grainAmount;
  71126. private _chromaticAberration;
  71127. private _distortion;
  71128. private _highlightsGain;
  71129. private _highlightsThreshold;
  71130. private _dofDistance;
  71131. private _dofAperture;
  71132. private _dofDarken;
  71133. private _dofPentagon;
  71134. private _blurNoise;
  71135. /**
  71136. * @constructor
  71137. *
  71138. * Effect parameters are as follow:
  71139. * {
  71140. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71141. * edge_blur: number; // from 0 to x (1 for realism)
  71142. * distortion: number; // from 0 to x (1 for realism)
  71143. * grain_amount: number; // from 0 to 1
  71144. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71145. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71146. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71147. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71148. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71149. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71150. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71151. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71152. * }
  71153. * Note: if an effect parameter is unset, effect is disabled
  71154. *
  71155. * @param name The rendering pipeline name
  71156. * @param parameters - An object containing all parameters (see above)
  71157. * @param scene The scene linked to this pipeline
  71158. * @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)
  71159. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71160. */
  71161. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71162. /**
  71163. * Get the class name
  71164. * @returns "LensRenderingPipeline"
  71165. */
  71166. getClassName(): string;
  71167. /**
  71168. * Gets associated scene
  71169. */
  71170. get scene(): Scene;
  71171. /**
  71172. * Gets or sets the edge blur
  71173. */
  71174. get edgeBlur(): number;
  71175. set edgeBlur(value: number);
  71176. /**
  71177. * Gets or sets the grain amount
  71178. */
  71179. get grainAmount(): number;
  71180. set grainAmount(value: number);
  71181. /**
  71182. * Gets or sets the chromatic aberration amount
  71183. */
  71184. get chromaticAberration(): number;
  71185. set chromaticAberration(value: number);
  71186. /**
  71187. * Gets or sets the depth of field aperture
  71188. */
  71189. get dofAperture(): number;
  71190. set dofAperture(value: number);
  71191. /**
  71192. * Gets or sets the edge distortion
  71193. */
  71194. get edgeDistortion(): number;
  71195. set edgeDistortion(value: number);
  71196. /**
  71197. * Gets or sets the depth of field distortion
  71198. */
  71199. get dofDistortion(): number;
  71200. set dofDistortion(value: number);
  71201. /**
  71202. * Gets or sets the darken out of focus amount
  71203. */
  71204. get darkenOutOfFocus(): number;
  71205. set darkenOutOfFocus(value: number);
  71206. /**
  71207. * Gets or sets a boolean indicating if blur noise is enabled
  71208. */
  71209. get blurNoise(): boolean;
  71210. set blurNoise(value: boolean);
  71211. /**
  71212. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71213. */
  71214. get pentagonBokeh(): boolean;
  71215. set pentagonBokeh(value: boolean);
  71216. /**
  71217. * Gets or sets the highlight grain amount
  71218. */
  71219. get highlightsGain(): number;
  71220. set highlightsGain(value: number);
  71221. /**
  71222. * Gets or sets the highlight threshold
  71223. */
  71224. get highlightsThreshold(): number;
  71225. set highlightsThreshold(value: number);
  71226. /**
  71227. * Sets the amount of blur at the edges
  71228. * @param amount blur amount
  71229. */
  71230. setEdgeBlur(amount: number): void;
  71231. /**
  71232. * Sets edge blur to 0
  71233. */
  71234. disableEdgeBlur(): void;
  71235. /**
  71236. * Sets the amout of grain
  71237. * @param amount Amount of grain
  71238. */
  71239. setGrainAmount(amount: number): void;
  71240. /**
  71241. * Set grain amount to 0
  71242. */
  71243. disableGrain(): void;
  71244. /**
  71245. * Sets the chromatic aberration amount
  71246. * @param amount amount of chromatic aberration
  71247. */
  71248. setChromaticAberration(amount: number): void;
  71249. /**
  71250. * Sets chromatic aberration amount to 0
  71251. */
  71252. disableChromaticAberration(): void;
  71253. /**
  71254. * Sets the EdgeDistortion amount
  71255. * @param amount amount of EdgeDistortion
  71256. */
  71257. setEdgeDistortion(amount: number): void;
  71258. /**
  71259. * Sets edge distortion to 0
  71260. */
  71261. disableEdgeDistortion(): void;
  71262. /**
  71263. * Sets the FocusDistance amount
  71264. * @param amount amount of FocusDistance
  71265. */
  71266. setFocusDistance(amount: number): void;
  71267. /**
  71268. * Disables depth of field
  71269. */
  71270. disableDepthOfField(): void;
  71271. /**
  71272. * Sets the Aperture amount
  71273. * @param amount amount of Aperture
  71274. */
  71275. setAperture(amount: number): void;
  71276. /**
  71277. * Sets the DarkenOutOfFocus amount
  71278. * @param amount amount of DarkenOutOfFocus
  71279. */
  71280. setDarkenOutOfFocus(amount: number): void;
  71281. private _pentagonBokehIsEnabled;
  71282. /**
  71283. * Creates a pentagon bokeh effect
  71284. */
  71285. enablePentagonBokeh(): void;
  71286. /**
  71287. * Disables the pentagon bokeh effect
  71288. */
  71289. disablePentagonBokeh(): void;
  71290. /**
  71291. * Enables noise blur
  71292. */
  71293. enableNoiseBlur(): void;
  71294. /**
  71295. * Disables noise blur
  71296. */
  71297. disableNoiseBlur(): void;
  71298. /**
  71299. * Sets the HighlightsGain amount
  71300. * @param amount amount of HighlightsGain
  71301. */
  71302. setHighlightsGain(amount: number): void;
  71303. /**
  71304. * Sets the HighlightsThreshold amount
  71305. * @param amount amount of HighlightsThreshold
  71306. */
  71307. setHighlightsThreshold(amount: number): void;
  71308. /**
  71309. * Disables highlights
  71310. */
  71311. disableHighlights(): void;
  71312. /**
  71313. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71314. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71315. */
  71316. dispose(disableDepthRender?: boolean): void;
  71317. private _createChromaticAberrationPostProcess;
  71318. private _createHighlightsPostProcess;
  71319. private _createDepthOfFieldPostProcess;
  71320. private _createGrainTexture;
  71321. }
  71322. }
  71323. declare module BABYLON {
  71324. /**
  71325. * Contains all parameters needed for the prepass to perform
  71326. * screen space subsurface scattering
  71327. */
  71328. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71329. /**
  71330. * Is subsurface enabled
  71331. */
  71332. enabled: boolean;
  71333. /**
  71334. * Name of the configuration
  71335. */
  71336. name: string;
  71337. /**
  71338. * Textures that should be present in the MRT for this effect to work
  71339. */
  71340. readonly texturesRequired: number[];
  71341. }
  71342. }
  71343. declare module BABYLON {
  71344. /** @hidden */
  71345. export var ssao2PixelShader: {
  71346. name: string;
  71347. shader: string;
  71348. };
  71349. }
  71350. declare module BABYLON {
  71351. /** @hidden */
  71352. export var ssaoCombinePixelShader: {
  71353. name: string;
  71354. shader: string;
  71355. };
  71356. }
  71357. declare module BABYLON {
  71358. /**
  71359. * Render pipeline to produce ssao effect
  71360. */
  71361. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71362. /**
  71363. * @ignore
  71364. * The PassPostProcess id in the pipeline that contains the original scene color
  71365. */
  71366. SSAOOriginalSceneColorEffect: string;
  71367. /**
  71368. * @ignore
  71369. * The SSAO PostProcess id in the pipeline
  71370. */
  71371. SSAORenderEffect: string;
  71372. /**
  71373. * @ignore
  71374. * The horizontal blur PostProcess id in the pipeline
  71375. */
  71376. SSAOBlurHRenderEffect: string;
  71377. /**
  71378. * @ignore
  71379. * The vertical blur PostProcess id in the pipeline
  71380. */
  71381. SSAOBlurVRenderEffect: string;
  71382. /**
  71383. * @ignore
  71384. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71385. */
  71386. SSAOCombineRenderEffect: string;
  71387. /**
  71388. * The output strength of the SSAO post-process. Default value is 1.0.
  71389. */
  71390. totalStrength: number;
  71391. /**
  71392. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71393. */
  71394. maxZ: number;
  71395. /**
  71396. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71397. */
  71398. minZAspect: number;
  71399. private _samples;
  71400. /**
  71401. * Number of samples used for the SSAO calculations. Default value is 8
  71402. */
  71403. set samples(n: number);
  71404. get samples(): number;
  71405. private _textureSamples;
  71406. /**
  71407. * Number of samples to use for antialiasing
  71408. */
  71409. set textureSamples(n: number);
  71410. get textureSamples(): number;
  71411. /**
  71412. * Force rendering the geometry through geometry buffer
  71413. */
  71414. private _forceGeometryBuffer;
  71415. /**
  71416. * Ratio object used for SSAO ratio and blur ratio
  71417. */
  71418. private _ratio;
  71419. /**
  71420. * Dynamically generated sphere sampler.
  71421. */
  71422. private _sampleSphere;
  71423. /**
  71424. * Blur filter offsets
  71425. */
  71426. private _samplerOffsets;
  71427. private _expensiveBlur;
  71428. /**
  71429. * If bilateral blur should be used
  71430. */
  71431. set expensiveBlur(b: boolean);
  71432. get expensiveBlur(): boolean;
  71433. /**
  71434. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71435. */
  71436. radius: number;
  71437. /**
  71438. * The base color of the SSAO post-process
  71439. * The final result is "base + ssao" between [0, 1]
  71440. */
  71441. base: number;
  71442. /**
  71443. * Support test.
  71444. */
  71445. static get IsSupported(): boolean;
  71446. private _scene;
  71447. private _randomTexture;
  71448. private _originalColorPostProcess;
  71449. private _ssaoPostProcess;
  71450. private _blurHPostProcess;
  71451. private _blurVPostProcess;
  71452. private _ssaoCombinePostProcess;
  71453. private _prePassRenderer;
  71454. /**
  71455. * Gets active scene
  71456. */
  71457. get scene(): Scene;
  71458. /**
  71459. * @constructor
  71460. * @param name The rendering pipeline name
  71461. * @param scene The scene linked to this pipeline
  71462. * @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 }
  71463. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71464. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71465. */
  71466. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71467. /**
  71468. * Get the class name
  71469. * @returns "SSAO2RenderingPipeline"
  71470. */
  71471. getClassName(): string;
  71472. /**
  71473. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71474. */
  71475. dispose(disableGeometryBufferRenderer?: boolean): void;
  71476. private _createBlurPostProcess;
  71477. /** @hidden */
  71478. _rebuild(): void;
  71479. private _bits;
  71480. private _radicalInverse_VdC;
  71481. private _hammersley;
  71482. private _hemisphereSample_uniform;
  71483. private _generateHemisphere;
  71484. private _getDefinesForSSAO;
  71485. private _createSSAOPostProcess;
  71486. private _createSSAOCombinePostProcess;
  71487. private _createRandomTexture;
  71488. /**
  71489. * Serialize the rendering pipeline (Used when exporting)
  71490. * @returns the serialized object
  71491. */
  71492. serialize(): any;
  71493. /**
  71494. * Parse the serialized pipeline
  71495. * @param source Source pipeline.
  71496. * @param scene The scene to load the pipeline to.
  71497. * @param rootUrl The URL of the serialized pipeline.
  71498. * @returns An instantiated pipeline from the serialized object.
  71499. */
  71500. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71501. }
  71502. }
  71503. declare module BABYLON {
  71504. /** @hidden */
  71505. export var ssaoPixelShader: {
  71506. name: string;
  71507. shader: string;
  71508. };
  71509. }
  71510. declare module BABYLON {
  71511. /**
  71512. * Render pipeline to produce ssao effect
  71513. */
  71514. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71515. /**
  71516. * @ignore
  71517. * The PassPostProcess id in the pipeline that contains the original scene color
  71518. */
  71519. SSAOOriginalSceneColorEffect: string;
  71520. /**
  71521. * @ignore
  71522. * The SSAO PostProcess id in the pipeline
  71523. */
  71524. SSAORenderEffect: string;
  71525. /**
  71526. * @ignore
  71527. * The horizontal blur PostProcess id in the pipeline
  71528. */
  71529. SSAOBlurHRenderEffect: string;
  71530. /**
  71531. * @ignore
  71532. * The vertical blur PostProcess id in the pipeline
  71533. */
  71534. SSAOBlurVRenderEffect: string;
  71535. /**
  71536. * @ignore
  71537. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71538. */
  71539. SSAOCombineRenderEffect: string;
  71540. /**
  71541. * The output strength of the SSAO post-process. Default value is 1.0.
  71542. */
  71543. totalStrength: number;
  71544. /**
  71545. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71546. */
  71547. radius: number;
  71548. /**
  71549. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71550. * Must not be equal to fallOff and superior to fallOff.
  71551. * Default value is 0.0075
  71552. */
  71553. area: number;
  71554. /**
  71555. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71556. * Must not be equal to area and inferior to area.
  71557. * Default value is 0.000001
  71558. */
  71559. fallOff: number;
  71560. /**
  71561. * The base color of the SSAO post-process
  71562. * The final result is "base + ssao" between [0, 1]
  71563. */
  71564. base: number;
  71565. private _scene;
  71566. private _depthTexture;
  71567. private _randomTexture;
  71568. private _originalColorPostProcess;
  71569. private _ssaoPostProcess;
  71570. private _blurHPostProcess;
  71571. private _blurVPostProcess;
  71572. private _ssaoCombinePostProcess;
  71573. private _firstUpdate;
  71574. /**
  71575. * Gets active scene
  71576. */
  71577. get scene(): Scene;
  71578. /**
  71579. * @constructor
  71580. * @param name - The rendering pipeline name
  71581. * @param scene - The scene linked to this pipeline
  71582. * @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 }
  71583. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71584. */
  71585. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71586. /**
  71587. * Get the class name
  71588. * @returns "SSAORenderingPipeline"
  71589. */
  71590. getClassName(): string;
  71591. /**
  71592. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71593. */
  71594. dispose(disableDepthRender?: boolean): void;
  71595. private _createBlurPostProcess;
  71596. /** @hidden */
  71597. _rebuild(): void;
  71598. private _createSSAOPostProcess;
  71599. private _createSSAOCombinePostProcess;
  71600. private _createRandomTexture;
  71601. }
  71602. }
  71603. declare module BABYLON {
  71604. /**
  71605. * Contains all parameters needed for the prepass to perform
  71606. * screen space reflections
  71607. */
  71608. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  71609. /**
  71610. * Is ssr enabled
  71611. */
  71612. enabled: boolean;
  71613. /**
  71614. * Name of the configuration
  71615. */
  71616. name: string;
  71617. /**
  71618. * Textures that should be present in the MRT for this effect to work
  71619. */
  71620. readonly texturesRequired: number[];
  71621. }
  71622. }
  71623. declare module BABYLON {
  71624. /** @hidden */
  71625. export var screenSpaceReflectionPixelShader: {
  71626. name: string;
  71627. shader: string;
  71628. };
  71629. }
  71630. declare module BABYLON {
  71631. /**
  71632. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71633. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71634. */
  71635. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71636. /**
  71637. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71638. */
  71639. threshold: number;
  71640. /**
  71641. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71642. */
  71643. strength: number;
  71644. /**
  71645. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71646. */
  71647. reflectionSpecularFalloffExponent: number;
  71648. /**
  71649. * 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]
  71650. */
  71651. step: number;
  71652. /**
  71653. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71654. */
  71655. roughnessFactor: number;
  71656. private _forceGeometryBuffer;
  71657. private _geometryBufferRenderer;
  71658. private _prePassRenderer;
  71659. private _enableSmoothReflections;
  71660. private _reflectionSamples;
  71661. private _smoothSteps;
  71662. /**
  71663. * Gets a string identifying the name of the class
  71664. * @returns "ScreenSpaceReflectionPostProcess" string
  71665. */
  71666. getClassName(): string;
  71667. /**
  71668. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71669. * @param name The name of the effect.
  71670. * @param scene The scene containing the objects to calculate reflections.
  71671. * @param options The required width/height ratio to downsize to before computing the render pass.
  71672. * @param camera The camera to apply the render pass to.
  71673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71674. * @param engine The engine which the post process will be applied. (default: current engine)
  71675. * @param reusable If the post process can be reused on the same frame. (default: false)
  71676. * @param textureType Type of textures used when performing the post process. (default: 0)
  71677. * @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)
  71678. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71679. */
  71680. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71681. /**
  71682. * Gets wether or not smoothing reflections is enabled.
  71683. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71684. */
  71685. get enableSmoothReflections(): boolean;
  71686. /**
  71687. * Sets wether or not smoothing reflections is enabled.
  71688. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71689. */
  71690. set enableSmoothReflections(enabled: boolean);
  71691. /**
  71692. * Gets the number of samples taken while computing reflections. More samples count is high,
  71693. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71694. */
  71695. get reflectionSamples(): number;
  71696. /**
  71697. * Sets the number of samples taken while computing reflections. More samples count is high,
  71698. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71699. */
  71700. set reflectionSamples(samples: number);
  71701. /**
  71702. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71703. * more the post-process will require GPU power and can generate a drop in FPS.
  71704. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71705. */
  71706. get smoothSteps(): number;
  71707. set smoothSteps(steps: number);
  71708. private _updateEffectDefines;
  71709. /** @hidden */
  71710. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71711. }
  71712. }
  71713. declare module BABYLON {
  71714. /** @hidden */
  71715. export var standardPixelShader: {
  71716. name: string;
  71717. shader: string;
  71718. };
  71719. }
  71720. declare module BABYLON {
  71721. /**
  71722. * Standard rendering pipeline
  71723. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71724. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71725. */
  71726. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71727. /**
  71728. * Public members
  71729. */
  71730. /**
  71731. * Post-process which contains the original scene color before the pipeline applies all the effects
  71732. */
  71733. originalPostProcess: Nullable<PostProcess>;
  71734. /**
  71735. * Post-process used to down scale an image x4
  71736. */
  71737. downSampleX4PostProcess: Nullable<PostProcess>;
  71738. /**
  71739. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71740. */
  71741. brightPassPostProcess: Nullable<PostProcess>;
  71742. /**
  71743. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71744. */
  71745. blurHPostProcesses: PostProcess[];
  71746. /**
  71747. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71748. */
  71749. blurVPostProcesses: PostProcess[];
  71750. /**
  71751. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71752. */
  71753. textureAdderPostProcess: Nullable<PostProcess>;
  71754. /**
  71755. * Post-process used to create volumetric lighting effect
  71756. */
  71757. volumetricLightPostProcess: Nullable<PostProcess>;
  71758. /**
  71759. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71760. */
  71761. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71762. /**
  71763. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71764. */
  71765. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71766. /**
  71767. * Post-process used to merge the volumetric light effect and the real scene color
  71768. */
  71769. volumetricLightMergePostProces: Nullable<PostProcess>;
  71770. /**
  71771. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71772. */
  71773. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71774. /**
  71775. * Base post-process used to calculate the average luminance of the final image for HDR
  71776. */
  71777. luminancePostProcess: Nullable<PostProcess>;
  71778. /**
  71779. * Post-processes used to create down sample post-processes in order to get
  71780. * the average luminance of the final image for HDR
  71781. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71782. */
  71783. luminanceDownSamplePostProcesses: PostProcess[];
  71784. /**
  71785. * Post-process used to create a HDR effect (light adaptation)
  71786. */
  71787. hdrPostProcess: Nullable<PostProcess>;
  71788. /**
  71789. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71790. */
  71791. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71792. /**
  71793. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71794. */
  71795. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71796. /**
  71797. * Post-process used to merge the final HDR post-process and the real scene color
  71798. */
  71799. hdrFinalPostProcess: Nullable<PostProcess>;
  71800. /**
  71801. * Post-process used to create a lens flare effect
  71802. */
  71803. lensFlarePostProcess: Nullable<PostProcess>;
  71804. /**
  71805. * Post-process that merges the result of the lens flare post-process and the real scene color
  71806. */
  71807. lensFlareComposePostProcess: Nullable<PostProcess>;
  71808. /**
  71809. * Post-process used to create a motion blur effect
  71810. */
  71811. motionBlurPostProcess: Nullable<PostProcess>;
  71812. /**
  71813. * Post-process used to create a depth of field effect
  71814. */
  71815. depthOfFieldPostProcess: Nullable<PostProcess>;
  71816. /**
  71817. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71818. */
  71819. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71820. /**
  71821. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71822. */
  71823. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71824. /**
  71825. * Represents the brightness threshold in order to configure the illuminated surfaces
  71826. */
  71827. brightThreshold: number;
  71828. /**
  71829. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71830. */
  71831. blurWidth: number;
  71832. /**
  71833. * Sets if the blur for highlighted surfaces must be only horizontal
  71834. */
  71835. horizontalBlur: boolean;
  71836. /**
  71837. * Gets the overall exposure used by the pipeline
  71838. */
  71839. get exposure(): number;
  71840. /**
  71841. * Sets the overall exposure used by the pipeline
  71842. */
  71843. set exposure(value: number);
  71844. /**
  71845. * Texture used typically to simulate "dirty" on camera lens
  71846. */
  71847. lensTexture: Nullable<Texture>;
  71848. /**
  71849. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71850. */
  71851. volumetricLightCoefficient: number;
  71852. /**
  71853. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71854. */
  71855. volumetricLightPower: number;
  71856. /**
  71857. * Used the set the blur intensity to smooth the volumetric lights
  71858. */
  71859. volumetricLightBlurScale: number;
  71860. /**
  71861. * Light (spot or directional) used to generate the volumetric lights rays
  71862. * The source light must have a shadow generate so the pipeline can get its
  71863. * depth map
  71864. */
  71865. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71866. /**
  71867. * For eye adaptation, represents the minimum luminance the eye can see
  71868. */
  71869. hdrMinimumLuminance: number;
  71870. /**
  71871. * For eye adaptation, represents the decrease luminance speed
  71872. */
  71873. hdrDecreaseRate: number;
  71874. /**
  71875. * For eye adaptation, represents the increase luminance speed
  71876. */
  71877. hdrIncreaseRate: number;
  71878. /**
  71879. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71880. */
  71881. get hdrAutoExposure(): boolean;
  71882. /**
  71883. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71884. */
  71885. set hdrAutoExposure(value: boolean);
  71886. /**
  71887. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71888. */
  71889. lensColorTexture: Nullable<Texture>;
  71890. /**
  71891. * The overall strengh for the lens flare effect
  71892. */
  71893. lensFlareStrength: number;
  71894. /**
  71895. * Dispersion coefficient for lens flare ghosts
  71896. */
  71897. lensFlareGhostDispersal: number;
  71898. /**
  71899. * Main lens flare halo width
  71900. */
  71901. lensFlareHaloWidth: number;
  71902. /**
  71903. * Based on the lens distortion effect, defines how much the lens flare result
  71904. * is distorted
  71905. */
  71906. lensFlareDistortionStrength: number;
  71907. /**
  71908. * Configures the blur intensity used for for lens flare (halo)
  71909. */
  71910. lensFlareBlurWidth: number;
  71911. /**
  71912. * Lens star texture must be used to simulate rays on the flares and is available
  71913. * in the documentation
  71914. */
  71915. lensStarTexture: Nullable<Texture>;
  71916. /**
  71917. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71918. * flare effect by taking account of the dirt texture
  71919. */
  71920. lensFlareDirtTexture: Nullable<Texture>;
  71921. /**
  71922. * Represents the focal length for the depth of field effect
  71923. */
  71924. depthOfFieldDistance: number;
  71925. /**
  71926. * Represents the blur intensity for the blurred part of the depth of field effect
  71927. */
  71928. depthOfFieldBlurWidth: number;
  71929. /**
  71930. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71931. */
  71932. get motionStrength(): number;
  71933. /**
  71934. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71935. */
  71936. set motionStrength(strength: number);
  71937. /**
  71938. * Gets wether or not the motion blur post-process is object based or screen based.
  71939. */
  71940. get objectBasedMotionBlur(): boolean;
  71941. /**
  71942. * Sets wether or not the motion blur post-process should be object based or screen based
  71943. */
  71944. set objectBasedMotionBlur(value: boolean);
  71945. /**
  71946. * List of animations for the pipeline (IAnimatable implementation)
  71947. */
  71948. animations: Animation[];
  71949. /**
  71950. * Private members
  71951. */
  71952. private _scene;
  71953. private _currentDepthOfFieldSource;
  71954. private _basePostProcess;
  71955. private _fixedExposure;
  71956. private _currentExposure;
  71957. private _hdrAutoExposure;
  71958. private _hdrCurrentLuminance;
  71959. private _motionStrength;
  71960. private _isObjectBasedMotionBlur;
  71961. private _floatTextureType;
  71962. private _camerasToBeAttached;
  71963. private _ratio;
  71964. private _bloomEnabled;
  71965. private _depthOfFieldEnabled;
  71966. private _vlsEnabled;
  71967. private _lensFlareEnabled;
  71968. private _hdrEnabled;
  71969. private _motionBlurEnabled;
  71970. private _fxaaEnabled;
  71971. private _screenSpaceReflectionsEnabled;
  71972. private _motionBlurSamples;
  71973. private _volumetricLightStepsCount;
  71974. private _samples;
  71975. /**
  71976. * @ignore
  71977. * Specifies if the bloom pipeline is enabled
  71978. */
  71979. get BloomEnabled(): boolean;
  71980. set BloomEnabled(enabled: boolean);
  71981. /**
  71982. * @ignore
  71983. * Specifies if the depth of field pipeline is enabed
  71984. */
  71985. get DepthOfFieldEnabled(): boolean;
  71986. set DepthOfFieldEnabled(enabled: boolean);
  71987. /**
  71988. * @ignore
  71989. * Specifies if the lens flare pipeline is enabed
  71990. */
  71991. get LensFlareEnabled(): boolean;
  71992. set LensFlareEnabled(enabled: boolean);
  71993. /**
  71994. * @ignore
  71995. * Specifies if the HDR pipeline is enabled
  71996. */
  71997. get HDREnabled(): boolean;
  71998. set HDREnabled(enabled: boolean);
  71999. /**
  72000. * @ignore
  72001. * Specifies if the volumetric lights scattering effect is enabled
  72002. */
  72003. get VLSEnabled(): boolean;
  72004. set VLSEnabled(enabled: boolean);
  72005. /**
  72006. * @ignore
  72007. * Specifies if the motion blur effect is enabled
  72008. */
  72009. get MotionBlurEnabled(): boolean;
  72010. set MotionBlurEnabled(enabled: boolean);
  72011. /**
  72012. * Specifies if anti-aliasing is enabled
  72013. */
  72014. get fxaaEnabled(): boolean;
  72015. set fxaaEnabled(enabled: boolean);
  72016. /**
  72017. * Specifies if screen space reflections are enabled.
  72018. */
  72019. get screenSpaceReflectionsEnabled(): boolean;
  72020. set screenSpaceReflectionsEnabled(enabled: boolean);
  72021. /**
  72022. * Specifies the number of steps used to calculate the volumetric lights
  72023. * Typically in interval [50, 200]
  72024. */
  72025. get volumetricLightStepsCount(): number;
  72026. set volumetricLightStepsCount(count: number);
  72027. /**
  72028. * Specifies the number of samples used for the motion blur effect
  72029. * Typically in interval [16, 64]
  72030. */
  72031. get motionBlurSamples(): number;
  72032. set motionBlurSamples(samples: number);
  72033. /**
  72034. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72035. */
  72036. get samples(): number;
  72037. set samples(sampleCount: number);
  72038. /**
  72039. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72040. * @constructor
  72041. * @param name The rendering pipeline name
  72042. * @param scene The scene linked to this pipeline
  72043. * @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)
  72044. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72045. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72046. */
  72047. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72048. private _buildPipeline;
  72049. private _createDownSampleX4PostProcess;
  72050. private _createBrightPassPostProcess;
  72051. private _createBlurPostProcesses;
  72052. private _createTextureAdderPostProcess;
  72053. private _createVolumetricLightPostProcess;
  72054. private _createLuminancePostProcesses;
  72055. private _createHdrPostProcess;
  72056. private _createLensFlarePostProcess;
  72057. private _createDepthOfFieldPostProcess;
  72058. private _createMotionBlurPostProcess;
  72059. private _getDepthTexture;
  72060. private _disposePostProcesses;
  72061. /**
  72062. * Dispose of the pipeline and stop all post processes
  72063. */
  72064. dispose(): void;
  72065. /**
  72066. * Serialize the rendering pipeline (Used when exporting)
  72067. * @returns the serialized object
  72068. */
  72069. serialize(): any;
  72070. /**
  72071. * Parse the serialized pipeline
  72072. * @param source Source pipeline.
  72073. * @param scene The scene to load the pipeline to.
  72074. * @param rootUrl The URL of the serialized pipeline.
  72075. * @returns An instantiated pipeline from the serialized object.
  72076. */
  72077. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72078. /**
  72079. * Luminance steps
  72080. */
  72081. static LuminanceSteps: number;
  72082. }
  72083. }
  72084. declare module BABYLON {
  72085. /** @hidden */
  72086. export var stereoscopicInterlacePixelShader: {
  72087. name: string;
  72088. shader: string;
  72089. };
  72090. }
  72091. declare module BABYLON {
  72092. /**
  72093. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72094. */
  72095. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72096. private _stepSize;
  72097. private _passedProcess;
  72098. /**
  72099. * Gets a string identifying the name of the class
  72100. * @returns "StereoscopicInterlacePostProcessI" string
  72101. */
  72102. getClassName(): string;
  72103. /**
  72104. * Initializes a StereoscopicInterlacePostProcessI
  72105. * @param name The name of the effect.
  72106. * @param rigCameras The rig cameras to be appled to the post process
  72107. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72108. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72110. * @param engine The engine which the post process will be applied. (default: current engine)
  72111. * @param reusable If the post process can be reused on the same frame. (default: false)
  72112. */
  72113. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72114. }
  72115. /**
  72116. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72117. */
  72118. export class StereoscopicInterlacePostProcess extends PostProcess {
  72119. private _stepSize;
  72120. private _passedProcess;
  72121. /**
  72122. * Gets a string identifying the name of the class
  72123. * @returns "StereoscopicInterlacePostProcess" string
  72124. */
  72125. getClassName(): string;
  72126. /**
  72127. * Initializes a StereoscopicInterlacePostProcess
  72128. * @param name The name of the effect.
  72129. * @param rigCameras The rig cameras to be appled to the post process
  72130. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72131. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72132. * @param engine The engine which the post process will be applied. (default: current engine)
  72133. * @param reusable If the post process can be reused on the same frame. (default: false)
  72134. */
  72135. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72136. }
  72137. }
  72138. declare module BABYLON {
  72139. /** @hidden */
  72140. export var tonemapPixelShader: {
  72141. name: string;
  72142. shader: string;
  72143. };
  72144. }
  72145. declare module BABYLON {
  72146. /** Defines operator used for tonemapping */
  72147. export enum TonemappingOperator {
  72148. /** Hable */
  72149. Hable = 0,
  72150. /** Reinhard */
  72151. Reinhard = 1,
  72152. /** HejiDawson */
  72153. HejiDawson = 2,
  72154. /** Photographic */
  72155. Photographic = 3
  72156. }
  72157. /**
  72158. * Defines a post process to apply tone mapping
  72159. */
  72160. export class TonemapPostProcess extends PostProcess {
  72161. private _operator;
  72162. /** Defines the required exposure adjustement */
  72163. exposureAdjustment: number;
  72164. /**
  72165. * Gets a string identifying the name of the class
  72166. * @returns "TonemapPostProcess" string
  72167. */
  72168. getClassName(): string;
  72169. /**
  72170. * Creates a new TonemapPostProcess
  72171. * @param name defines the name of the postprocess
  72172. * @param _operator defines the operator to use
  72173. * @param exposureAdjustment defines the required exposure adjustement
  72174. * @param camera defines the camera to use (can be null)
  72175. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72176. * @param engine defines the hosting engine (can be ignore if camera is set)
  72177. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72178. */
  72179. constructor(name: string, _operator: TonemappingOperator,
  72180. /** Defines the required exposure adjustement */
  72181. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72182. }
  72183. }
  72184. declare module BABYLON {
  72185. /** @hidden */
  72186. export var volumetricLightScatteringPixelShader: {
  72187. name: string;
  72188. shader: string;
  72189. };
  72190. }
  72191. declare module BABYLON {
  72192. /** @hidden */
  72193. export var volumetricLightScatteringPassVertexShader: {
  72194. name: string;
  72195. shader: string;
  72196. };
  72197. }
  72198. declare module BABYLON {
  72199. /** @hidden */
  72200. export var volumetricLightScatteringPassPixelShader: {
  72201. name: string;
  72202. shader: string;
  72203. };
  72204. }
  72205. declare module BABYLON {
  72206. /**
  72207. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72208. */
  72209. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72210. private _volumetricLightScatteringPass;
  72211. private _volumetricLightScatteringRTT;
  72212. private _viewPort;
  72213. private _screenCoordinates;
  72214. private _cachedDefines;
  72215. /**
  72216. * If not undefined, the mesh position is computed from the attached node position
  72217. */
  72218. attachedNode: {
  72219. position: Vector3;
  72220. };
  72221. /**
  72222. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72223. */
  72224. customMeshPosition: Vector3;
  72225. /**
  72226. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72227. */
  72228. useCustomMeshPosition: boolean;
  72229. /**
  72230. * If the post-process should inverse the light scattering direction
  72231. */
  72232. invert: boolean;
  72233. /**
  72234. * The internal mesh used by the post-process
  72235. */
  72236. mesh: Mesh;
  72237. /**
  72238. * @hidden
  72239. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72240. */
  72241. get useDiffuseColor(): boolean;
  72242. set useDiffuseColor(useDiffuseColor: boolean);
  72243. /**
  72244. * Array containing the excluded meshes not rendered in the internal pass
  72245. */
  72246. excludedMeshes: AbstractMesh[];
  72247. /**
  72248. * Controls the overall intensity of the post-process
  72249. */
  72250. exposure: number;
  72251. /**
  72252. * Dissipates each sample's contribution in range [0, 1]
  72253. */
  72254. decay: number;
  72255. /**
  72256. * Controls the overall intensity of each sample
  72257. */
  72258. weight: number;
  72259. /**
  72260. * Controls the density of each sample
  72261. */
  72262. density: number;
  72263. /**
  72264. * @constructor
  72265. * @param name The post-process name
  72266. * @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)
  72267. * @param camera The camera that the post-process will be attached to
  72268. * @param mesh The mesh used to create the light scattering
  72269. * @param samples The post-process quality, default 100
  72270. * @param samplingModeThe post-process filtering mode
  72271. * @param engine The babylon engine
  72272. * @param reusable If the post-process is reusable
  72273. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72274. */
  72275. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72276. /**
  72277. * Returns the string "VolumetricLightScatteringPostProcess"
  72278. * @returns "VolumetricLightScatteringPostProcess"
  72279. */
  72280. getClassName(): string;
  72281. private _isReady;
  72282. /**
  72283. * Sets the new light position for light scattering effect
  72284. * @param position The new custom light position
  72285. */
  72286. setCustomMeshPosition(position: Vector3): void;
  72287. /**
  72288. * Returns the light position for light scattering effect
  72289. * @return Vector3 The custom light position
  72290. */
  72291. getCustomMeshPosition(): Vector3;
  72292. /**
  72293. * Disposes the internal assets and detaches the post-process from the camera
  72294. */
  72295. dispose(camera: Camera): void;
  72296. /**
  72297. * Returns the render target texture used by the post-process
  72298. * @return the render target texture used by the post-process
  72299. */
  72300. getPass(): RenderTargetTexture;
  72301. private _meshExcluded;
  72302. private _createPass;
  72303. private _updateMeshScreenCoordinates;
  72304. /**
  72305. * Creates a default mesh for the Volumeric Light Scattering post-process
  72306. * @param name The mesh name
  72307. * @param scene The scene where to create the mesh
  72308. * @return the default mesh
  72309. */
  72310. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72311. }
  72312. }
  72313. declare module BABYLON {
  72314. /** @hidden */
  72315. export var screenSpaceCurvaturePixelShader: {
  72316. name: string;
  72317. shader: string;
  72318. };
  72319. }
  72320. declare module BABYLON {
  72321. /**
  72322. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72323. */
  72324. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72325. /**
  72326. * Defines how much ridge the curvature effect displays.
  72327. */
  72328. ridge: number;
  72329. /**
  72330. * Defines how much valley the curvature effect displays.
  72331. */
  72332. valley: number;
  72333. private _geometryBufferRenderer;
  72334. /**
  72335. * Gets a string identifying the name of the class
  72336. * @returns "ScreenSpaceCurvaturePostProcess" string
  72337. */
  72338. getClassName(): string;
  72339. /**
  72340. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72341. * @param name The name of the effect.
  72342. * @param scene The scene containing the objects to blur according to their velocity.
  72343. * @param options The required width/height ratio to downsize to before computing the render pass.
  72344. * @param camera The camera to apply the render pass to.
  72345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72346. * @param engine The engine which the post process will be applied. (default: current engine)
  72347. * @param reusable If the post process can be reused on the same frame. (default: false)
  72348. * @param textureType Type of textures used when performing the post process. (default: 0)
  72349. * @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)
  72350. */
  72351. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72352. /**
  72353. * Support test.
  72354. */
  72355. static get IsSupported(): boolean;
  72356. /** @hidden */
  72357. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72358. }
  72359. }
  72360. declare module BABYLON {
  72361. interface Scene {
  72362. /** @hidden (Backing field) */
  72363. _boundingBoxRenderer: BoundingBoxRenderer;
  72364. /** @hidden (Backing field) */
  72365. _forceShowBoundingBoxes: boolean;
  72366. /**
  72367. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72368. */
  72369. forceShowBoundingBoxes: boolean;
  72370. /**
  72371. * Gets the bounding box renderer associated with the scene
  72372. * @returns a BoundingBoxRenderer
  72373. */
  72374. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72375. }
  72376. interface AbstractMesh {
  72377. /** @hidden (Backing field) */
  72378. _showBoundingBox: boolean;
  72379. /**
  72380. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72381. */
  72382. showBoundingBox: boolean;
  72383. }
  72384. /**
  72385. * Component responsible of rendering the bounding box of the meshes in a scene.
  72386. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72387. */
  72388. export class BoundingBoxRenderer implements ISceneComponent {
  72389. /**
  72390. * The component name helpfull to identify the component in the list of scene components.
  72391. */
  72392. readonly name: string;
  72393. /**
  72394. * The scene the component belongs to.
  72395. */
  72396. scene: Scene;
  72397. /**
  72398. * Color of the bounding box lines placed in front of an object
  72399. */
  72400. frontColor: Color3;
  72401. /**
  72402. * Color of the bounding box lines placed behind an object
  72403. */
  72404. backColor: Color3;
  72405. /**
  72406. * Defines if the renderer should show the back lines or not
  72407. */
  72408. showBackLines: boolean;
  72409. /**
  72410. * Observable raised before rendering a bounding box
  72411. */
  72412. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72413. /**
  72414. * Observable raised after rendering a bounding box
  72415. */
  72416. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72417. /**
  72418. * @hidden
  72419. */
  72420. renderList: SmartArray<BoundingBox>;
  72421. private _colorShader;
  72422. private _vertexBuffers;
  72423. private _indexBuffer;
  72424. private _fillIndexBuffer;
  72425. private _fillIndexData;
  72426. /**
  72427. * Instantiates a new bounding box renderer in a scene.
  72428. * @param scene the scene the renderer renders in
  72429. */
  72430. constructor(scene: Scene);
  72431. /**
  72432. * Registers the component in a given scene
  72433. */
  72434. register(): void;
  72435. private _evaluateSubMesh;
  72436. private _activeMesh;
  72437. private _prepareRessources;
  72438. private _createIndexBuffer;
  72439. /**
  72440. * Rebuilds the elements related to this component in case of
  72441. * context lost for instance.
  72442. */
  72443. rebuild(): void;
  72444. /**
  72445. * @hidden
  72446. */
  72447. reset(): void;
  72448. /**
  72449. * Render the bounding boxes of a specific rendering group
  72450. * @param renderingGroupId defines the rendering group to render
  72451. */
  72452. render(renderingGroupId: number): void;
  72453. /**
  72454. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72455. * @param mesh Define the mesh to render the occlusion bounding box for
  72456. */
  72457. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72458. /**
  72459. * Dispose and release the resources attached to this renderer.
  72460. */
  72461. dispose(): void;
  72462. }
  72463. }
  72464. declare module BABYLON {
  72465. interface Scene {
  72466. /** @hidden (Backing field) */
  72467. _depthRenderer: {
  72468. [id: string]: DepthRenderer;
  72469. };
  72470. /**
  72471. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72472. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72473. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72474. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72475. * @returns the created depth renderer
  72476. */
  72477. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72478. /**
  72479. * Disables a depth renderer for a given camera
  72480. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72481. */
  72482. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72483. }
  72484. /**
  72485. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72486. * in several rendering techniques.
  72487. */
  72488. export class DepthRendererSceneComponent implements ISceneComponent {
  72489. /**
  72490. * The component name helpfull to identify the component in the list of scene components.
  72491. */
  72492. readonly name: string;
  72493. /**
  72494. * The scene the component belongs to.
  72495. */
  72496. scene: Scene;
  72497. /**
  72498. * Creates a new instance of the component for the given scene
  72499. * @param scene Defines the scene to register the component in
  72500. */
  72501. constructor(scene: Scene);
  72502. /**
  72503. * Registers the component in a given scene
  72504. */
  72505. register(): void;
  72506. /**
  72507. * Rebuilds the elements related to this component in case of
  72508. * context lost for instance.
  72509. */
  72510. rebuild(): void;
  72511. /**
  72512. * Disposes the component and the associated ressources
  72513. */
  72514. dispose(): void;
  72515. private _gatherRenderTargets;
  72516. private _gatherActiveCameraRenderTargets;
  72517. }
  72518. }
  72519. declare module BABYLON {
  72520. interface AbstractScene {
  72521. /** @hidden (Backing field) */
  72522. _prePassRenderer: Nullable<PrePassRenderer>;
  72523. /**
  72524. * Gets or Sets the current prepass renderer associated to the scene.
  72525. */
  72526. prePassRenderer: Nullable<PrePassRenderer>;
  72527. /**
  72528. * Enables the prepass and associates it with the scene
  72529. * @returns the PrePassRenderer
  72530. */
  72531. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72532. /**
  72533. * Disables the prepass associated with the scene
  72534. */
  72535. disablePrePassRenderer(): void;
  72536. }
  72537. /**
  72538. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72539. * in several rendering techniques.
  72540. */
  72541. export class PrePassRendererSceneComponent implements ISceneComponent {
  72542. /**
  72543. * The component name helpful to identify the component in the list of scene components.
  72544. */
  72545. readonly name: string;
  72546. /**
  72547. * The scene the component belongs to.
  72548. */
  72549. scene: Scene;
  72550. /**
  72551. * Creates a new instance of the component for the given scene
  72552. * @param scene Defines the scene to register the component in
  72553. */
  72554. constructor(scene: Scene);
  72555. /**
  72556. * Registers the component in a given scene
  72557. */
  72558. register(): void;
  72559. private _beforeCameraDraw;
  72560. private _afterCameraDraw;
  72561. private _beforeClearStage;
  72562. /**
  72563. * Rebuilds the elements related to this component in case of
  72564. * context lost for instance.
  72565. */
  72566. rebuild(): void;
  72567. /**
  72568. * Disposes the component and the associated ressources
  72569. */
  72570. dispose(): void;
  72571. }
  72572. }
  72573. declare module BABYLON {
  72574. /** @hidden */
  72575. export var fibonacci: {
  72576. name: string;
  72577. shader: string;
  72578. };
  72579. }
  72580. declare module BABYLON {
  72581. /** @hidden */
  72582. export var diffusionProfile: {
  72583. name: string;
  72584. shader: string;
  72585. };
  72586. }
  72587. declare module BABYLON {
  72588. /** @hidden */
  72589. export var subSurfaceScatteringPixelShader: {
  72590. name: string;
  72591. shader: string;
  72592. };
  72593. }
  72594. declare module BABYLON {
  72595. /**
  72596. * Sub surface scattering post process
  72597. */
  72598. export class SubSurfaceScatteringPostProcess extends PostProcess {
  72599. /**
  72600. * Gets a string identifying the name of the class
  72601. * @returns "SubSurfaceScatteringPostProcess" string
  72602. */
  72603. getClassName(): string;
  72604. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72605. }
  72606. }
  72607. declare module BABYLON {
  72608. /**
  72609. * Contains all parameters needed for the prepass to perform
  72610. * screen space subsurface scattering
  72611. */
  72612. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  72613. /** @hidden */
  72614. static _SceneComponentInitialization: (scene: Scene) => void;
  72615. private _ssDiffusionS;
  72616. private _ssFilterRadii;
  72617. private _ssDiffusionD;
  72618. /**
  72619. * Post process to attach for screen space subsurface scattering
  72620. */
  72621. postProcess: SubSurfaceScatteringPostProcess;
  72622. /**
  72623. * Diffusion profile color for subsurface scattering
  72624. */
  72625. get ssDiffusionS(): number[];
  72626. /**
  72627. * Diffusion profile max color channel value for subsurface scattering
  72628. */
  72629. get ssDiffusionD(): number[];
  72630. /**
  72631. * Diffusion profile filter radius for subsurface scattering
  72632. */
  72633. get ssFilterRadii(): number[];
  72634. /**
  72635. * Is subsurface enabled
  72636. */
  72637. enabled: boolean;
  72638. /**
  72639. * Name of the configuration
  72640. */
  72641. name: string;
  72642. /**
  72643. * Diffusion profile colors for subsurface scattering
  72644. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  72645. * See ...
  72646. * Note that you can only store up to 5 of them
  72647. */
  72648. ssDiffusionProfileColors: Color3[];
  72649. /**
  72650. * Defines the ratio real world => scene units.
  72651. * Used for subsurface scattering
  72652. */
  72653. metersPerUnit: number;
  72654. /**
  72655. * Textures that should be present in the MRT for this effect to work
  72656. */
  72657. readonly texturesRequired: number[];
  72658. private _scene;
  72659. /**
  72660. * Builds a subsurface configuration object
  72661. * @param scene The scene
  72662. */
  72663. constructor(scene: Scene);
  72664. /**
  72665. * Adds a new diffusion profile.
  72666. * Useful for more realistic subsurface scattering on diverse materials.
  72667. * @param color The color of the diffusion profile. Should be the average color of the material.
  72668. * @return The index of the diffusion profile for the material subsurface configuration
  72669. */
  72670. addDiffusionProfile(color: Color3): number;
  72671. /**
  72672. * Creates the sss post process
  72673. * @return The created post process
  72674. */
  72675. createPostProcess(): SubSurfaceScatteringPostProcess;
  72676. /**
  72677. * Deletes all diffusion profiles.
  72678. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  72679. */
  72680. clearAllDiffusionProfiles(): void;
  72681. /**
  72682. * Disposes this object
  72683. */
  72684. dispose(): void;
  72685. /**
  72686. * @hidden
  72687. * https://zero-radiance.github.io/post/sampling-diffusion/
  72688. *
  72689. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  72690. * ------------------------------------------------------------------------------------
  72691. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  72692. * PDF[r, phi, s] = r * R[r, phi, s]
  72693. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  72694. * ------------------------------------------------------------------------------------
  72695. * We importance sample the color channel with the widest scattering distance.
  72696. */
  72697. getDiffusionProfileParameters(color: Color3): number;
  72698. /**
  72699. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  72700. * 'u' is the random number (the value of the CDF): [0, 1).
  72701. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  72702. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  72703. */
  72704. private _sampleBurleyDiffusionProfile;
  72705. }
  72706. }
  72707. declare module BABYLON {
  72708. interface AbstractScene {
  72709. /** @hidden (Backing field) */
  72710. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72711. /**
  72712. * Gets or Sets the current prepass renderer associated to the scene.
  72713. */
  72714. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72715. /**
  72716. * Enables the subsurface effect for prepass
  72717. * @returns the SubSurfaceConfiguration
  72718. */
  72719. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  72720. /**
  72721. * Disables the subsurface effect for prepass
  72722. */
  72723. disableSubSurfaceForPrePass(): void;
  72724. }
  72725. /**
  72726. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72727. * in several rendering techniques.
  72728. */
  72729. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  72730. /**
  72731. * The component name helpful to identify the component in the list of scene components.
  72732. */
  72733. readonly name: string;
  72734. /**
  72735. * The scene the component belongs to.
  72736. */
  72737. scene: Scene;
  72738. /**
  72739. * Creates a new instance of the component for the given scene
  72740. * @param scene Defines the scene to register the component in
  72741. */
  72742. constructor(scene: Scene);
  72743. /**
  72744. * Registers the component in a given scene
  72745. */
  72746. register(): void;
  72747. /**
  72748. * Serializes the component data to the specified json object
  72749. * @param serializationObject The object to serialize to
  72750. */
  72751. serialize(serializationObject: any): void;
  72752. /**
  72753. * Adds all the elements from the container to the scene
  72754. * @param container the container holding the elements
  72755. */
  72756. addFromContainer(container: AbstractScene): void;
  72757. /**
  72758. * Removes all the elements in the container from the scene
  72759. * @param container contains the elements to remove
  72760. * @param dispose if the removed element should be disposed (default: false)
  72761. */
  72762. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72763. /**
  72764. * Rebuilds the elements related to this component in case of
  72765. * context lost for instance.
  72766. */
  72767. rebuild(): void;
  72768. /**
  72769. * Disposes the component and the associated ressources
  72770. */
  72771. dispose(): void;
  72772. }
  72773. }
  72774. declare module BABYLON {
  72775. /** @hidden */
  72776. export var outlinePixelShader: {
  72777. name: string;
  72778. shader: string;
  72779. };
  72780. }
  72781. declare module BABYLON {
  72782. /** @hidden */
  72783. export var outlineVertexShader: {
  72784. name: string;
  72785. shader: string;
  72786. };
  72787. }
  72788. declare module BABYLON {
  72789. interface Scene {
  72790. /** @hidden */
  72791. _outlineRenderer: OutlineRenderer;
  72792. /**
  72793. * Gets the outline renderer associated with the scene
  72794. * @returns a OutlineRenderer
  72795. */
  72796. getOutlineRenderer(): OutlineRenderer;
  72797. }
  72798. interface AbstractMesh {
  72799. /** @hidden (Backing field) */
  72800. _renderOutline: boolean;
  72801. /**
  72802. * Gets or sets a boolean indicating if the outline must be rendered as well
  72803. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72804. */
  72805. renderOutline: boolean;
  72806. /** @hidden (Backing field) */
  72807. _renderOverlay: boolean;
  72808. /**
  72809. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72810. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72811. */
  72812. renderOverlay: boolean;
  72813. }
  72814. /**
  72815. * This class is responsible to draw bothe outline/overlay of meshes.
  72816. * It should not be used directly but through the available method on mesh.
  72817. */
  72818. export class OutlineRenderer implements ISceneComponent {
  72819. /**
  72820. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72821. */
  72822. private static _StencilReference;
  72823. /**
  72824. * The name of the component. Each component must have a unique name.
  72825. */
  72826. name: string;
  72827. /**
  72828. * The scene the component belongs to.
  72829. */
  72830. scene: Scene;
  72831. /**
  72832. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72833. */
  72834. zOffset: number;
  72835. private _engine;
  72836. private _effect;
  72837. private _cachedDefines;
  72838. private _savedDepthWrite;
  72839. /**
  72840. * Instantiates a new outline renderer. (There could be only one per scene).
  72841. * @param scene Defines the scene it belongs to
  72842. */
  72843. constructor(scene: Scene);
  72844. /**
  72845. * Register the component to one instance of a scene.
  72846. */
  72847. register(): void;
  72848. /**
  72849. * Rebuilds the elements related to this component in case of
  72850. * context lost for instance.
  72851. */
  72852. rebuild(): void;
  72853. /**
  72854. * Disposes the component and the associated ressources.
  72855. */
  72856. dispose(): void;
  72857. /**
  72858. * Renders the outline in the canvas.
  72859. * @param subMesh Defines the sumesh to render
  72860. * @param batch Defines the batch of meshes in case of instances
  72861. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72862. */
  72863. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72864. /**
  72865. * Returns whether or not the outline renderer is ready for a given submesh.
  72866. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72867. * @param subMesh Defines the submesh to check readyness for
  72868. * @param useInstances Defines wheter wee are trying to render instances or not
  72869. * @returns true if ready otherwise false
  72870. */
  72871. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72872. private _beforeRenderingMesh;
  72873. private _afterRenderingMesh;
  72874. }
  72875. }
  72876. declare module BABYLON {
  72877. /**
  72878. * Defines the basic options interface of a Sprite Frame Source Size.
  72879. */
  72880. export interface ISpriteJSONSpriteSourceSize {
  72881. /**
  72882. * number of the original width of the Frame
  72883. */
  72884. w: number;
  72885. /**
  72886. * number of the original height of the Frame
  72887. */
  72888. h: number;
  72889. }
  72890. /**
  72891. * Defines the basic options interface of a Sprite Frame Data.
  72892. */
  72893. export interface ISpriteJSONSpriteFrameData {
  72894. /**
  72895. * number of the x offset of the Frame
  72896. */
  72897. x: number;
  72898. /**
  72899. * number of the y offset of the Frame
  72900. */
  72901. y: number;
  72902. /**
  72903. * number of the width of the Frame
  72904. */
  72905. w: number;
  72906. /**
  72907. * number of the height of the Frame
  72908. */
  72909. h: number;
  72910. }
  72911. /**
  72912. * Defines the basic options interface of a JSON Sprite.
  72913. */
  72914. export interface ISpriteJSONSprite {
  72915. /**
  72916. * string name of the Frame
  72917. */
  72918. filename: string;
  72919. /**
  72920. * ISpriteJSONSpriteFrame basic object of the frame data
  72921. */
  72922. frame: ISpriteJSONSpriteFrameData;
  72923. /**
  72924. * boolean to flag is the frame was rotated.
  72925. */
  72926. rotated: boolean;
  72927. /**
  72928. * boolean to flag is the frame was trimmed.
  72929. */
  72930. trimmed: boolean;
  72931. /**
  72932. * ISpriteJSONSpriteFrame basic object of the source data
  72933. */
  72934. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72935. /**
  72936. * ISpriteJSONSpriteFrame basic object of the source data
  72937. */
  72938. sourceSize: ISpriteJSONSpriteSourceSize;
  72939. }
  72940. /**
  72941. * Defines the basic options interface of a JSON atlas.
  72942. */
  72943. export interface ISpriteJSONAtlas {
  72944. /**
  72945. * Array of objects that contain the frame data.
  72946. */
  72947. frames: Array<ISpriteJSONSprite>;
  72948. /**
  72949. * object basic object containing the sprite meta data.
  72950. */
  72951. meta?: object;
  72952. }
  72953. }
  72954. declare module BABYLON {
  72955. /** @hidden */
  72956. export var spriteMapPixelShader: {
  72957. name: string;
  72958. shader: string;
  72959. };
  72960. }
  72961. declare module BABYLON {
  72962. /** @hidden */
  72963. export var spriteMapVertexShader: {
  72964. name: string;
  72965. shader: string;
  72966. };
  72967. }
  72968. declare module BABYLON {
  72969. /**
  72970. * Defines the basic options interface of a SpriteMap
  72971. */
  72972. export interface ISpriteMapOptions {
  72973. /**
  72974. * Vector2 of the number of cells in the grid.
  72975. */
  72976. stageSize?: Vector2;
  72977. /**
  72978. * Vector2 of the size of the output plane in World Units.
  72979. */
  72980. outputSize?: Vector2;
  72981. /**
  72982. * Vector3 of the position of the output plane in World Units.
  72983. */
  72984. outputPosition?: Vector3;
  72985. /**
  72986. * Vector3 of the rotation of the output plane.
  72987. */
  72988. outputRotation?: Vector3;
  72989. /**
  72990. * number of layers that the system will reserve in resources.
  72991. */
  72992. layerCount?: number;
  72993. /**
  72994. * number of max animation frames a single cell will reserve in resources.
  72995. */
  72996. maxAnimationFrames?: number;
  72997. /**
  72998. * number cell index of the base tile when the system compiles.
  72999. */
  73000. baseTile?: number;
  73001. /**
  73002. * boolean flip the sprite after its been repositioned by the framing data.
  73003. */
  73004. flipU?: boolean;
  73005. /**
  73006. * Vector3 scalar of the global RGB values of the SpriteMap.
  73007. */
  73008. colorMultiply?: Vector3;
  73009. }
  73010. /**
  73011. * Defines the IDisposable interface in order to be cleanable from resources.
  73012. */
  73013. export interface ISpriteMap extends IDisposable {
  73014. /**
  73015. * String name of the SpriteMap.
  73016. */
  73017. name: string;
  73018. /**
  73019. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73020. */
  73021. atlasJSON: ISpriteJSONAtlas;
  73022. /**
  73023. * Texture of the SpriteMap.
  73024. */
  73025. spriteSheet: Texture;
  73026. /**
  73027. * The parameters to initialize the SpriteMap with.
  73028. */
  73029. options: ISpriteMapOptions;
  73030. }
  73031. /**
  73032. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73033. */
  73034. export class SpriteMap implements ISpriteMap {
  73035. /** The Name of the spriteMap */
  73036. name: string;
  73037. /** The JSON file with the frame and meta data */
  73038. atlasJSON: ISpriteJSONAtlas;
  73039. /** The systems Sprite Sheet Texture */
  73040. spriteSheet: Texture;
  73041. /** Arguments passed with the Constructor */
  73042. options: ISpriteMapOptions;
  73043. /** Public Sprite Storage array, parsed from atlasJSON */
  73044. sprites: Array<ISpriteJSONSprite>;
  73045. /** Returns the Number of Sprites in the System */
  73046. get spriteCount(): number;
  73047. /** Returns the Position of Output Plane*/
  73048. get position(): Vector3;
  73049. /** Returns the Position of Output Plane*/
  73050. set position(v: Vector3);
  73051. /** Returns the Rotation of Output Plane*/
  73052. get rotation(): Vector3;
  73053. /** Returns the Rotation of Output Plane*/
  73054. set rotation(v: Vector3);
  73055. /** Sets the AnimationMap*/
  73056. get animationMap(): RawTexture;
  73057. /** Sets the AnimationMap*/
  73058. set animationMap(v: RawTexture);
  73059. /** Scene that the SpriteMap was created in */
  73060. private _scene;
  73061. /** Texture Buffer of Float32 that holds tile frame data*/
  73062. private _frameMap;
  73063. /** Texture Buffers of Float32 that holds tileMap data*/
  73064. private _tileMaps;
  73065. /** Texture Buffer of Float32 that holds Animation Data*/
  73066. private _animationMap;
  73067. /** Custom ShaderMaterial Central to the System*/
  73068. private _material;
  73069. /** Custom ShaderMaterial Central to the System*/
  73070. private _output;
  73071. /** Systems Time Ticker*/
  73072. private _time;
  73073. /**
  73074. * Creates a new SpriteMap
  73075. * @param name defines the SpriteMaps Name
  73076. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73077. * @param spriteSheet is the Texture that the Sprites are on.
  73078. * @param options a basic deployment configuration
  73079. * @param scene The Scene that the map is deployed on
  73080. */
  73081. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73082. /**
  73083. * Returns tileID location
  73084. * @returns Vector2 the cell position ID
  73085. */
  73086. getTileID(): Vector2;
  73087. /**
  73088. * Gets the UV location of the mouse over the SpriteMap.
  73089. * @returns Vector2 the UV position of the mouse interaction
  73090. */
  73091. getMousePosition(): Vector2;
  73092. /**
  73093. * Creates the "frame" texture Buffer
  73094. * -------------------------------------
  73095. * Structure of frames
  73096. * "filename": "Falling-Water-2.png",
  73097. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73098. * "rotated": true,
  73099. * "trimmed": true,
  73100. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73101. * "sourceSize": {"w":32,"h":32}
  73102. * @returns RawTexture of the frameMap
  73103. */
  73104. private _createFrameBuffer;
  73105. /**
  73106. * Creates the tileMap texture Buffer
  73107. * @param buffer normally and array of numbers, or a false to generate from scratch
  73108. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73109. * @returns RawTexture of the tileMap
  73110. */
  73111. private _createTileBuffer;
  73112. /**
  73113. * Modifies the data of the tileMaps
  73114. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73115. * @param pos is the iVector2 Coordinates of the Tile
  73116. * @param tile The SpriteIndex of the new Tile
  73117. */
  73118. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73119. /**
  73120. * Creates the animationMap texture Buffer
  73121. * @param buffer normally and array of numbers, or a false to generate from scratch
  73122. * @returns RawTexture of the animationMap
  73123. */
  73124. private _createTileAnimationBuffer;
  73125. /**
  73126. * Modifies the data of the animationMap
  73127. * @param cellID is the Index of the Sprite
  73128. * @param _frame is the target Animation frame
  73129. * @param toCell is the Target Index of the next frame of the animation
  73130. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73131. * @param speed is a global scalar of the time variable on the map.
  73132. */
  73133. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73134. /**
  73135. * Exports the .tilemaps file
  73136. */
  73137. saveTileMaps(): void;
  73138. /**
  73139. * Imports the .tilemaps file
  73140. * @param url of the .tilemaps file
  73141. */
  73142. loadTileMaps(url: string): void;
  73143. /**
  73144. * Release associated resources
  73145. */
  73146. dispose(): void;
  73147. }
  73148. }
  73149. declare module BABYLON {
  73150. /**
  73151. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73152. * @see https://doc.babylonjs.com/babylon101/sprites
  73153. */
  73154. export class SpritePackedManager extends SpriteManager {
  73155. /** defines the packed manager's name */
  73156. name: string;
  73157. /**
  73158. * Creates a new sprite manager from a packed sprite sheet
  73159. * @param name defines the manager's name
  73160. * @param imgUrl defines the sprite sheet url
  73161. * @param capacity defines the maximum allowed number of sprites
  73162. * @param scene defines the hosting scene
  73163. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73164. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73165. * @param samplingMode defines the smapling mode to use with spritesheet
  73166. * @param fromPacked set to true; do not alter
  73167. */
  73168. constructor(
  73169. /** defines the packed manager's name */
  73170. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73171. }
  73172. }
  73173. declare module BABYLON {
  73174. /**
  73175. * Defines the list of states available for a task inside a AssetsManager
  73176. */
  73177. export enum AssetTaskState {
  73178. /**
  73179. * Initialization
  73180. */
  73181. INIT = 0,
  73182. /**
  73183. * Running
  73184. */
  73185. RUNNING = 1,
  73186. /**
  73187. * Done
  73188. */
  73189. DONE = 2,
  73190. /**
  73191. * Error
  73192. */
  73193. ERROR = 3
  73194. }
  73195. /**
  73196. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73197. */
  73198. export abstract class AbstractAssetTask {
  73199. /**
  73200. * Task name
  73201. */ name: string;
  73202. /**
  73203. * Callback called when the task is successful
  73204. */
  73205. onSuccess: (task: any) => void;
  73206. /**
  73207. * Callback called when the task is not successful
  73208. */
  73209. onError: (task: any, message?: string, exception?: any) => void;
  73210. /**
  73211. * Creates a new AssetsManager
  73212. * @param name defines the name of the task
  73213. */
  73214. constructor(
  73215. /**
  73216. * Task name
  73217. */ name: string);
  73218. private _isCompleted;
  73219. private _taskState;
  73220. private _errorObject;
  73221. /**
  73222. * Get if the task is completed
  73223. */
  73224. get isCompleted(): boolean;
  73225. /**
  73226. * Gets the current state of the task
  73227. */
  73228. get taskState(): AssetTaskState;
  73229. /**
  73230. * Gets the current error object (if task is in error)
  73231. */
  73232. get errorObject(): {
  73233. message?: string;
  73234. exception?: any;
  73235. };
  73236. /**
  73237. * Internal only
  73238. * @hidden
  73239. */
  73240. _setErrorObject(message?: string, exception?: any): void;
  73241. /**
  73242. * Execute the current task
  73243. * @param scene defines the scene where you want your assets to be loaded
  73244. * @param onSuccess is a callback called when the task is successfully executed
  73245. * @param onError is a callback called if an error occurs
  73246. */
  73247. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73248. /**
  73249. * Execute the current task
  73250. * @param scene defines the scene where you want your assets to be loaded
  73251. * @param onSuccess is a callback called when the task is successfully executed
  73252. * @param onError is a callback called if an error occurs
  73253. */
  73254. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73255. /**
  73256. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73257. * This can be used with failed tasks that have the reason for failure fixed.
  73258. */
  73259. reset(): void;
  73260. private onErrorCallback;
  73261. private onDoneCallback;
  73262. }
  73263. /**
  73264. * Define the interface used by progress events raised during assets loading
  73265. */
  73266. export interface IAssetsProgressEvent {
  73267. /**
  73268. * Defines the number of remaining tasks to process
  73269. */
  73270. remainingCount: number;
  73271. /**
  73272. * Defines the total number of tasks
  73273. */
  73274. totalCount: number;
  73275. /**
  73276. * Defines the task that was just processed
  73277. */
  73278. task: AbstractAssetTask;
  73279. }
  73280. /**
  73281. * Class used to share progress information about assets loading
  73282. */
  73283. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73284. /**
  73285. * Defines the number of remaining tasks to process
  73286. */
  73287. remainingCount: number;
  73288. /**
  73289. * Defines the total number of tasks
  73290. */
  73291. totalCount: number;
  73292. /**
  73293. * Defines the task that was just processed
  73294. */
  73295. task: AbstractAssetTask;
  73296. /**
  73297. * Creates a AssetsProgressEvent
  73298. * @param remainingCount defines the number of remaining tasks to process
  73299. * @param totalCount defines the total number of tasks
  73300. * @param task defines the task that was just processed
  73301. */
  73302. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73303. }
  73304. /**
  73305. * Define a task used by AssetsManager to load assets into a container
  73306. */
  73307. export class ContainerAssetTask extends AbstractAssetTask {
  73308. /**
  73309. * Defines the name of the task
  73310. */
  73311. name: string;
  73312. /**
  73313. * Defines the list of mesh's names you want to load
  73314. */
  73315. meshesNames: any;
  73316. /**
  73317. * Defines the root url to use as a base to load your meshes and associated resources
  73318. */
  73319. rootUrl: string;
  73320. /**
  73321. * Defines the filename or File of the scene to load from
  73322. */
  73323. sceneFilename: string | File;
  73324. /**
  73325. * Get the loaded asset container
  73326. */
  73327. loadedContainer: AssetContainer;
  73328. /**
  73329. * Gets the list of loaded meshes
  73330. */
  73331. loadedMeshes: Array<AbstractMesh>;
  73332. /**
  73333. * Gets the list of loaded particle systems
  73334. */
  73335. loadedParticleSystems: Array<IParticleSystem>;
  73336. /**
  73337. * Gets the list of loaded skeletons
  73338. */
  73339. loadedSkeletons: Array<Skeleton>;
  73340. /**
  73341. * Gets the list of loaded animation groups
  73342. */
  73343. loadedAnimationGroups: Array<AnimationGroup>;
  73344. /**
  73345. * Callback called when the task is successful
  73346. */
  73347. onSuccess: (task: ContainerAssetTask) => void;
  73348. /**
  73349. * Callback called when the task is successful
  73350. */
  73351. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73352. /**
  73353. * Creates a new ContainerAssetTask
  73354. * @param name defines the name of the task
  73355. * @param meshesNames defines the list of mesh's names you want to load
  73356. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73357. * @param sceneFilename defines the filename or File of the scene to load from
  73358. */
  73359. constructor(
  73360. /**
  73361. * Defines the name of the task
  73362. */
  73363. name: string,
  73364. /**
  73365. * Defines the list of mesh's names you want to load
  73366. */
  73367. meshesNames: any,
  73368. /**
  73369. * Defines the root url to use as a base to load your meshes and associated resources
  73370. */
  73371. rootUrl: string,
  73372. /**
  73373. * Defines the filename or File of the scene to load from
  73374. */
  73375. sceneFilename: string | File);
  73376. /**
  73377. * Execute the current task
  73378. * @param scene defines the scene where you want your assets to be loaded
  73379. * @param onSuccess is a callback called when the task is successfully executed
  73380. * @param onError is a callback called if an error occurs
  73381. */
  73382. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73383. }
  73384. /**
  73385. * Define a task used by AssetsManager to load meshes
  73386. */
  73387. export class MeshAssetTask extends AbstractAssetTask {
  73388. /**
  73389. * Defines the name of the task
  73390. */
  73391. name: string;
  73392. /**
  73393. * Defines the list of mesh's names you want to load
  73394. */
  73395. meshesNames: any;
  73396. /**
  73397. * Defines the root url to use as a base to load your meshes and associated resources
  73398. */
  73399. rootUrl: string;
  73400. /**
  73401. * Defines the filename or File of the scene to load from
  73402. */
  73403. sceneFilename: string | File;
  73404. /**
  73405. * Gets the list of loaded meshes
  73406. */
  73407. loadedMeshes: Array<AbstractMesh>;
  73408. /**
  73409. * Gets the list of loaded particle systems
  73410. */
  73411. loadedParticleSystems: Array<IParticleSystem>;
  73412. /**
  73413. * Gets the list of loaded skeletons
  73414. */
  73415. loadedSkeletons: Array<Skeleton>;
  73416. /**
  73417. * Gets the list of loaded animation groups
  73418. */
  73419. loadedAnimationGroups: Array<AnimationGroup>;
  73420. /**
  73421. * Callback called when the task is successful
  73422. */
  73423. onSuccess: (task: MeshAssetTask) => void;
  73424. /**
  73425. * Callback called when the task is successful
  73426. */
  73427. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73428. /**
  73429. * Creates a new MeshAssetTask
  73430. * @param name defines the name of the task
  73431. * @param meshesNames defines the list of mesh's names you want to load
  73432. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73433. * @param sceneFilename defines the filename or File of the scene to load from
  73434. */
  73435. constructor(
  73436. /**
  73437. * Defines the name of the task
  73438. */
  73439. name: string,
  73440. /**
  73441. * Defines the list of mesh's names you want to load
  73442. */
  73443. meshesNames: any,
  73444. /**
  73445. * Defines the root url to use as a base to load your meshes and associated resources
  73446. */
  73447. rootUrl: string,
  73448. /**
  73449. * Defines the filename or File of the scene to load from
  73450. */
  73451. sceneFilename: string | File);
  73452. /**
  73453. * Execute the current task
  73454. * @param scene defines the scene where you want your assets to be loaded
  73455. * @param onSuccess is a callback called when the task is successfully executed
  73456. * @param onError is a callback called if an error occurs
  73457. */
  73458. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73459. }
  73460. /**
  73461. * Define a task used by AssetsManager to load text content
  73462. */
  73463. export class TextFileAssetTask extends AbstractAssetTask {
  73464. /**
  73465. * Defines the name of the task
  73466. */
  73467. name: string;
  73468. /**
  73469. * Defines the location of the file to load
  73470. */
  73471. url: string;
  73472. /**
  73473. * Gets the loaded text string
  73474. */
  73475. text: string;
  73476. /**
  73477. * Callback called when the task is successful
  73478. */
  73479. onSuccess: (task: TextFileAssetTask) => void;
  73480. /**
  73481. * Callback called when the task is successful
  73482. */
  73483. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73484. /**
  73485. * Creates a new TextFileAssetTask object
  73486. * @param name defines the name of the task
  73487. * @param url defines the location of the file to load
  73488. */
  73489. constructor(
  73490. /**
  73491. * Defines the name of the task
  73492. */
  73493. name: string,
  73494. /**
  73495. * Defines the location of the file to load
  73496. */
  73497. url: string);
  73498. /**
  73499. * Execute the current task
  73500. * @param scene defines the scene where you want your assets to be loaded
  73501. * @param onSuccess is a callback called when the task is successfully executed
  73502. * @param onError is a callback called if an error occurs
  73503. */
  73504. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73505. }
  73506. /**
  73507. * Define a task used by AssetsManager to load binary data
  73508. */
  73509. export class BinaryFileAssetTask extends AbstractAssetTask {
  73510. /**
  73511. * Defines the name of the task
  73512. */
  73513. name: string;
  73514. /**
  73515. * Defines the location of the file to load
  73516. */
  73517. url: string;
  73518. /**
  73519. * Gets the lodaded data (as an array buffer)
  73520. */
  73521. data: ArrayBuffer;
  73522. /**
  73523. * Callback called when the task is successful
  73524. */
  73525. onSuccess: (task: BinaryFileAssetTask) => void;
  73526. /**
  73527. * Callback called when the task is successful
  73528. */
  73529. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73530. /**
  73531. * Creates a new BinaryFileAssetTask object
  73532. * @param name defines the name of the new task
  73533. * @param url defines the location of the file to load
  73534. */
  73535. constructor(
  73536. /**
  73537. * Defines the name of the task
  73538. */
  73539. name: string,
  73540. /**
  73541. * Defines the location of the file to load
  73542. */
  73543. url: string);
  73544. /**
  73545. * Execute the current task
  73546. * @param scene defines the scene where you want your assets to be loaded
  73547. * @param onSuccess is a callback called when the task is successfully executed
  73548. * @param onError is a callback called if an error occurs
  73549. */
  73550. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73551. }
  73552. /**
  73553. * Define a task used by AssetsManager to load images
  73554. */
  73555. export class ImageAssetTask extends AbstractAssetTask {
  73556. /**
  73557. * Defines the name of the task
  73558. */
  73559. name: string;
  73560. /**
  73561. * Defines the location of the image to load
  73562. */
  73563. url: string;
  73564. /**
  73565. * Gets the loaded images
  73566. */
  73567. image: HTMLImageElement;
  73568. /**
  73569. * Callback called when the task is successful
  73570. */
  73571. onSuccess: (task: ImageAssetTask) => void;
  73572. /**
  73573. * Callback called when the task is successful
  73574. */
  73575. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73576. /**
  73577. * Creates a new ImageAssetTask
  73578. * @param name defines the name of the task
  73579. * @param url defines the location of the image to load
  73580. */
  73581. constructor(
  73582. /**
  73583. * Defines the name of the task
  73584. */
  73585. name: string,
  73586. /**
  73587. * Defines the location of the image to load
  73588. */
  73589. url: string);
  73590. /**
  73591. * Execute the current task
  73592. * @param scene defines the scene where you want your assets to be loaded
  73593. * @param onSuccess is a callback called when the task is successfully executed
  73594. * @param onError is a callback called if an error occurs
  73595. */
  73596. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73597. }
  73598. /**
  73599. * Defines the interface used by texture loading tasks
  73600. */
  73601. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73602. /**
  73603. * Gets the loaded texture
  73604. */
  73605. texture: TEX;
  73606. }
  73607. /**
  73608. * Define a task used by AssetsManager to load 2D textures
  73609. */
  73610. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73611. /**
  73612. * Defines the name of the task
  73613. */
  73614. name: string;
  73615. /**
  73616. * Defines the location of the file to load
  73617. */
  73618. url: string;
  73619. /**
  73620. * Defines if mipmap should not be generated (default is false)
  73621. */
  73622. noMipmap?: boolean | undefined;
  73623. /**
  73624. * Defines if texture must be inverted on Y axis (default is true)
  73625. */
  73626. invertY: boolean;
  73627. /**
  73628. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73629. */
  73630. samplingMode: number;
  73631. /**
  73632. * Gets the loaded texture
  73633. */
  73634. texture: Texture;
  73635. /**
  73636. * Callback called when the task is successful
  73637. */
  73638. onSuccess: (task: TextureAssetTask) => void;
  73639. /**
  73640. * Callback called when the task is successful
  73641. */
  73642. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73643. /**
  73644. * Creates a new TextureAssetTask object
  73645. * @param name defines the name of the task
  73646. * @param url defines the location of the file to load
  73647. * @param noMipmap defines if mipmap should not be generated (default is false)
  73648. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73649. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73650. */
  73651. constructor(
  73652. /**
  73653. * Defines the name of the task
  73654. */
  73655. name: string,
  73656. /**
  73657. * Defines the location of the file to load
  73658. */
  73659. url: string,
  73660. /**
  73661. * Defines if mipmap should not be generated (default is false)
  73662. */
  73663. noMipmap?: boolean | undefined,
  73664. /**
  73665. * Defines if texture must be inverted on Y axis (default is true)
  73666. */
  73667. invertY?: boolean,
  73668. /**
  73669. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73670. */
  73671. samplingMode?: number);
  73672. /**
  73673. * Execute the current task
  73674. * @param scene defines the scene where you want your assets to be loaded
  73675. * @param onSuccess is a callback called when the task is successfully executed
  73676. * @param onError is a callback called if an error occurs
  73677. */
  73678. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73679. }
  73680. /**
  73681. * Define a task used by AssetsManager to load cube textures
  73682. */
  73683. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73684. /**
  73685. * Defines the name of the task
  73686. */
  73687. name: string;
  73688. /**
  73689. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73690. */
  73691. url: string;
  73692. /**
  73693. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73694. */
  73695. extensions?: string[] | undefined;
  73696. /**
  73697. * Defines if mipmaps should not be generated (default is false)
  73698. */
  73699. noMipmap?: boolean | undefined;
  73700. /**
  73701. * Defines the explicit list of files (undefined by default)
  73702. */
  73703. files?: string[] | undefined;
  73704. /**
  73705. * Gets the loaded texture
  73706. */
  73707. texture: CubeTexture;
  73708. /**
  73709. * Callback called when the task is successful
  73710. */
  73711. onSuccess: (task: CubeTextureAssetTask) => void;
  73712. /**
  73713. * Callback called when the task is successful
  73714. */
  73715. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73716. /**
  73717. * Creates a new CubeTextureAssetTask
  73718. * @param name defines the name of the task
  73719. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73720. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73721. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73722. * @param files defines the explicit list of files (undefined by default)
  73723. */
  73724. constructor(
  73725. /**
  73726. * Defines the name of the task
  73727. */
  73728. name: string,
  73729. /**
  73730. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73731. */
  73732. url: string,
  73733. /**
  73734. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73735. */
  73736. extensions?: string[] | undefined,
  73737. /**
  73738. * Defines if mipmaps should not be generated (default is false)
  73739. */
  73740. noMipmap?: boolean | undefined,
  73741. /**
  73742. * Defines the explicit list of files (undefined by default)
  73743. */
  73744. files?: string[] | undefined);
  73745. /**
  73746. * Execute the current task
  73747. * @param scene defines the scene where you want your assets to be loaded
  73748. * @param onSuccess is a callback called when the task is successfully executed
  73749. * @param onError is a callback called if an error occurs
  73750. */
  73751. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73752. }
  73753. /**
  73754. * Define a task used by AssetsManager to load HDR cube textures
  73755. */
  73756. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73757. /**
  73758. * Defines the name of the task
  73759. */
  73760. name: string;
  73761. /**
  73762. * Defines the location of the file to load
  73763. */
  73764. url: string;
  73765. /**
  73766. * Defines the desired size (the more it increases the longer the generation will be)
  73767. */
  73768. size: number;
  73769. /**
  73770. * Defines if mipmaps should not be generated (default is false)
  73771. */
  73772. noMipmap: boolean;
  73773. /**
  73774. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73775. */
  73776. generateHarmonics: boolean;
  73777. /**
  73778. * 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)
  73779. */
  73780. gammaSpace: boolean;
  73781. /**
  73782. * Internal Use Only
  73783. */
  73784. reserved: boolean;
  73785. /**
  73786. * Gets the loaded texture
  73787. */
  73788. texture: HDRCubeTexture;
  73789. /**
  73790. * Callback called when the task is successful
  73791. */
  73792. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73793. /**
  73794. * Callback called when the task is successful
  73795. */
  73796. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73797. /**
  73798. * Creates a new HDRCubeTextureAssetTask object
  73799. * @param name defines the name of the task
  73800. * @param url defines the location of the file to load
  73801. * @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.
  73802. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73803. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73804. * @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)
  73805. * @param reserved Internal use only
  73806. */
  73807. constructor(
  73808. /**
  73809. * Defines the name of the task
  73810. */
  73811. name: string,
  73812. /**
  73813. * Defines the location of the file to load
  73814. */
  73815. url: string,
  73816. /**
  73817. * Defines the desired size (the more it increases the longer the generation will be)
  73818. */
  73819. size: number,
  73820. /**
  73821. * Defines if mipmaps should not be generated (default is false)
  73822. */
  73823. noMipmap?: boolean,
  73824. /**
  73825. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73826. */
  73827. generateHarmonics?: boolean,
  73828. /**
  73829. * 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)
  73830. */
  73831. gammaSpace?: boolean,
  73832. /**
  73833. * Internal Use Only
  73834. */
  73835. reserved?: boolean);
  73836. /**
  73837. * Execute the current task
  73838. * @param scene defines the scene where you want your assets to be loaded
  73839. * @param onSuccess is a callback called when the task is successfully executed
  73840. * @param onError is a callback called if an error occurs
  73841. */
  73842. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73843. }
  73844. /**
  73845. * Define a task used by AssetsManager to load Equirectangular cube textures
  73846. */
  73847. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73848. /**
  73849. * Defines the name of the task
  73850. */
  73851. name: string;
  73852. /**
  73853. * Defines the location of the file to load
  73854. */
  73855. url: string;
  73856. /**
  73857. * Defines the desired size (the more it increases the longer the generation will be)
  73858. */
  73859. size: number;
  73860. /**
  73861. * Defines if mipmaps should not be generated (default is false)
  73862. */
  73863. noMipmap: boolean;
  73864. /**
  73865. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73866. * but the standard material would require them in Gamma space) (default is true)
  73867. */
  73868. gammaSpace: boolean;
  73869. /**
  73870. * Gets the loaded texture
  73871. */
  73872. texture: EquiRectangularCubeTexture;
  73873. /**
  73874. * Callback called when the task is successful
  73875. */
  73876. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73877. /**
  73878. * Callback called when the task is successful
  73879. */
  73880. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73881. /**
  73882. * Creates a new EquiRectangularCubeTextureAssetTask object
  73883. * @param name defines the name of the task
  73884. * @param url defines the location of the file to load
  73885. * @param size defines the desired size (the more it increases the longer the generation will be)
  73886. * If the size is omitted this implies you are using a preprocessed cubemap.
  73887. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73888. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73889. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73890. * (default is true)
  73891. */
  73892. constructor(
  73893. /**
  73894. * Defines the name of the task
  73895. */
  73896. name: string,
  73897. /**
  73898. * Defines the location of the file to load
  73899. */
  73900. url: string,
  73901. /**
  73902. * Defines the desired size (the more it increases the longer the generation will be)
  73903. */
  73904. size: number,
  73905. /**
  73906. * Defines if mipmaps should not be generated (default is false)
  73907. */
  73908. noMipmap?: boolean,
  73909. /**
  73910. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73911. * but the standard material would require them in Gamma space) (default is true)
  73912. */
  73913. gammaSpace?: boolean);
  73914. /**
  73915. * Execute the current task
  73916. * @param scene defines the scene where you want your assets to be loaded
  73917. * @param onSuccess is a callback called when the task is successfully executed
  73918. * @param onError is a callback called if an error occurs
  73919. */
  73920. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73921. }
  73922. /**
  73923. * This class can be used to easily import assets into a scene
  73924. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73925. */
  73926. export class AssetsManager {
  73927. private _scene;
  73928. private _isLoading;
  73929. protected _tasks: AbstractAssetTask[];
  73930. protected _waitingTasksCount: number;
  73931. protected _totalTasksCount: number;
  73932. /**
  73933. * Callback called when all tasks are processed
  73934. */
  73935. onFinish: (tasks: AbstractAssetTask[]) => void;
  73936. /**
  73937. * Callback called when a task is successful
  73938. */
  73939. onTaskSuccess: (task: AbstractAssetTask) => void;
  73940. /**
  73941. * Callback called when a task had an error
  73942. */
  73943. onTaskError: (task: AbstractAssetTask) => void;
  73944. /**
  73945. * Callback called when a task is done (whatever the result is)
  73946. */
  73947. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73948. /**
  73949. * Observable called when all tasks are processed
  73950. */
  73951. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73952. /**
  73953. * Observable called when a task had an error
  73954. */
  73955. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73956. /**
  73957. * Observable called when all tasks were executed
  73958. */
  73959. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73960. /**
  73961. * Observable called when a task is done (whatever the result is)
  73962. */
  73963. onProgressObservable: Observable<IAssetsProgressEvent>;
  73964. /**
  73965. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73966. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73967. */
  73968. useDefaultLoadingScreen: boolean;
  73969. /**
  73970. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73971. * when all assets have been downloaded.
  73972. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73973. */
  73974. autoHideLoadingUI: boolean;
  73975. /**
  73976. * Creates a new AssetsManager
  73977. * @param scene defines the scene to work on
  73978. */
  73979. constructor(scene: Scene);
  73980. /**
  73981. * Add a ContainerAssetTask to the list of active tasks
  73982. * @param taskName defines the name of the new task
  73983. * @param meshesNames defines the name of meshes to load
  73984. * @param rootUrl defines the root url to use to locate files
  73985. * @param sceneFilename defines the filename of the scene file
  73986. * @returns a new ContainerAssetTask object
  73987. */
  73988. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73989. /**
  73990. * Add a MeshAssetTask to the list of active tasks
  73991. * @param taskName defines the name of the new task
  73992. * @param meshesNames defines the name of meshes to load
  73993. * @param rootUrl defines the root url to use to locate files
  73994. * @param sceneFilename defines the filename of the scene file
  73995. * @returns a new MeshAssetTask object
  73996. */
  73997. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73998. /**
  73999. * Add a TextFileAssetTask to the list of active tasks
  74000. * @param taskName defines the name of the new task
  74001. * @param url defines the url of the file to load
  74002. * @returns a new TextFileAssetTask object
  74003. */
  74004. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74005. /**
  74006. * Add a BinaryFileAssetTask to the list of active tasks
  74007. * @param taskName defines the name of the new task
  74008. * @param url defines the url of the file to load
  74009. * @returns a new BinaryFileAssetTask object
  74010. */
  74011. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74012. /**
  74013. * Add a ImageAssetTask to the list of active tasks
  74014. * @param taskName defines the name of the new task
  74015. * @param url defines the url of the file to load
  74016. * @returns a new ImageAssetTask object
  74017. */
  74018. addImageTask(taskName: string, url: string): ImageAssetTask;
  74019. /**
  74020. * Add a TextureAssetTask to the list of active tasks
  74021. * @param taskName defines the name of the new task
  74022. * @param url defines the url of the file to load
  74023. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74024. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74025. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74026. * @returns a new TextureAssetTask object
  74027. */
  74028. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74029. /**
  74030. * Add a CubeTextureAssetTask to the list of active tasks
  74031. * @param taskName defines the name of the new task
  74032. * @param url defines the url of the file to load
  74033. * @param extensions defines the extension to use to load the cube map (can be null)
  74034. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74035. * @param files defines the list of files to load (can be null)
  74036. * @returns a new CubeTextureAssetTask object
  74037. */
  74038. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74039. /**
  74040. *
  74041. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74042. * @param taskName defines the name of the new task
  74043. * @param url defines the url of the file to load
  74044. * @param size defines the size you want for the cubemap (can be null)
  74045. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74046. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74047. * @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)
  74048. * @param reserved Internal use only
  74049. * @returns a new HDRCubeTextureAssetTask object
  74050. */
  74051. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74052. /**
  74053. *
  74054. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74055. * @param taskName defines the name of the new task
  74056. * @param url defines the url of the file to load
  74057. * @param size defines the size you want for the cubemap (can be null)
  74058. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74059. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74060. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74061. * @returns a new EquiRectangularCubeTextureAssetTask object
  74062. */
  74063. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74064. /**
  74065. * Remove a task from the assets manager.
  74066. * @param task the task to remove
  74067. */
  74068. removeTask(task: AbstractAssetTask): void;
  74069. private _decreaseWaitingTasksCount;
  74070. private _runTask;
  74071. /**
  74072. * Reset the AssetsManager and remove all tasks
  74073. * @return the current instance of the AssetsManager
  74074. */
  74075. reset(): AssetsManager;
  74076. /**
  74077. * Start the loading process
  74078. * @return the current instance of the AssetsManager
  74079. */
  74080. load(): AssetsManager;
  74081. /**
  74082. * Start the loading process as an async operation
  74083. * @return a promise returning the list of failed tasks
  74084. */
  74085. loadAsync(): Promise<void>;
  74086. }
  74087. }
  74088. declare module BABYLON {
  74089. /**
  74090. * Wrapper class for promise with external resolve and reject.
  74091. */
  74092. export class Deferred<T> {
  74093. /**
  74094. * The promise associated with this deferred object.
  74095. */
  74096. readonly promise: Promise<T>;
  74097. private _resolve;
  74098. private _reject;
  74099. /**
  74100. * The resolve method of the promise associated with this deferred object.
  74101. */
  74102. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74103. /**
  74104. * The reject method of the promise associated with this deferred object.
  74105. */
  74106. get reject(): (reason?: any) => void;
  74107. /**
  74108. * Constructor for this deferred object.
  74109. */
  74110. constructor();
  74111. }
  74112. }
  74113. declare module BABYLON {
  74114. /**
  74115. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74116. */
  74117. export class MeshExploder {
  74118. private _centerMesh;
  74119. private _meshes;
  74120. private _meshesOrigins;
  74121. private _toCenterVectors;
  74122. private _scaledDirection;
  74123. private _newPosition;
  74124. private _centerPosition;
  74125. /**
  74126. * Explodes meshes from a center mesh.
  74127. * @param meshes The meshes to explode.
  74128. * @param centerMesh The mesh to be center of explosion.
  74129. */
  74130. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74131. private _setCenterMesh;
  74132. /**
  74133. * Get class name
  74134. * @returns "MeshExploder"
  74135. */
  74136. getClassName(): string;
  74137. /**
  74138. * "Exploded meshes"
  74139. * @returns Array of meshes with the centerMesh at index 0.
  74140. */
  74141. getMeshes(): Array<Mesh>;
  74142. /**
  74143. * Explodes meshes giving a specific direction
  74144. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74145. */
  74146. explode(direction?: number): void;
  74147. }
  74148. }
  74149. declare module BABYLON {
  74150. /**
  74151. * Class used to help managing file picking and drag'n'drop
  74152. */
  74153. export class FilesInput {
  74154. /**
  74155. * List of files ready to be loaded
  74156. */
  74157. static get FilesToLoad(): {
  74158. [key: string]: File;
  74159. };
  74160. /**
  74161. * Callback called when a file is processed
  74162. */
  74163. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74164. private _engine;
  74165. private _currentScene;
  74166. private _sceneLoadedCallback;
  74167. private _progressCallback;
  74168. private _additionalRenderLoopLogicCallback;
  74169. private _textureLoadingCallback;
  74170. private _startingProcessingFilesCallback;
  74171. private _onReloadCallback;
  74172. private _errorCallback;
  74173. private _elementToMonitor;
  74174. private _sceneFileToLoad;
  74175. private _filesToLoad;
  74176. /**
  74177. * Creates a new FilesInput
  74178. * @param engine defines the rendering engine
  74179. * @param scene defines the hosting scene
  74180. * @param sceneLoadedCallback callback called when scene is loaded
  74181. * @param progressCallback callback called to track progress
  74182. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74183. * @param textureLoadingCallback callback called when a texture is loading
  74184. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74185. * @param onReloadCallback callback called when a reload is requested
  74186. * @param errorCallback callback call if an error occurs
  74187. */
  74188. 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>);
  74189. private _dragEnterHandler;
  74190. private _dragOverHandler;
  74191. private _dropHandler;
  74192. /**
  74193. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74194. * @param elementToMonitor defines the DOM element to track
  74195. */
  74196. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74197. /** Gets the current list of files to load */
  74198. get filesToLoad(): File[];
  74199. /**
  74200. * Release all associated resources
  74201. */
  74202. dispose(): void;
  74203. private renderFunction;
  74204. private drag;
  74205. private drop;
  74206. private _traverseFolder;
  74207. private _processFiles;
  74208. /**
  74209. * Load files from a drop event
  74210. * @param event defines the drop event to use as source
  74211. */
  74212. loadFiles(event: any): void;
  74213. private _processReload;
  74214. /**
  74215. * Reload the current scene from the loaded files
  74216. */
  74217. reload(): void;
  74218. }
  74219. }
  74220. declare module BABYLON {
  74221. /**
  74222. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74223. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74224. */
  74225. export class SceneOptimization {
  74226. /**
  74227. * Defines the priority of this optimization (0 by default which means first in the list)
  74228. */
  74229. priority: number;
  74230. /**
  74231. * Gets a string describing the action executed by the current optimization
  74232. * @returns description string
  74233. */
  74234. getDescription(): string;
  74235. /**
  74236. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74237. * @param scene defines the current scene where to apply this optimization
  74238. * @param optimizer defines the current optimizer
  74239. * @returns true if everything that can be done was applied
  74240. */
  74241. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74242. /**
  74243. * Creates the SceneOptimization object
  74244. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74245. * @param desc defines the description associated with the optimization
  74246. */
  74247. constructor(
  74248. /**
  74249. * Defines the priority of this optimization (0 by default which means first in the list)
  74250. */
  74251. priority?: number);
  74252. }
  74253. /**
  74254. * Defines an optimization used to reduce the size of render target textures
  74255. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74256. */
  74257. export class TextureOptimization extends SceneOptimization {
  74258. /**
  74259. * Defines the priority of this optimization (0 by default which means first in the list)
  74260. */
  74261. priority: number;
  74262. /**
  74263. * 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
  74264. */
  74265. maximumSize: number;
  74266. /**
  74267. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74268. */
  74269. step: number;
  74270. /**
  74271. * Gets a string describing the action executed by the current optimization
  74272. * @returns description string
  74273. */
  74274. getDescription(): string;
  74275. /**
  74276. * Creates the TextureOptimization object
  74277. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74278. * @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
  74279. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74280. */
  74281. constructor(
  74282. /**
  74283. * Defines the priority of this optimization (0 by default which means first in the list)
  74284. */
  74285. priority?: number,
  74286. /**
  74287. * 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
  74288. */
  74289. maximumSize?: number,
  74290. /**
  74291. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74292. */
  74293. step?: number);
  74294. /**
  74295. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74296. * @param scene defines the current scene where to apply this optimization
  74297. * @param optimizer defines the current optimizer
  74298. * @returns true if everything that can be done was applied
  74299. */
  74300. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74301. }
  74302. /**
  74303. * Defines an optimization used to increase or decrease the rendering resolution
  74304. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74305. */
  74306. export class HardwareScalingOptimization extends SceneOptimization {
  74307. /**
  74308. * Defines the priority of this optimization (0 by default which means first in the list)
  74309. */
  74310. priority: number;
  74311. /**
  74312. * Defines the maximum scale to use (2 by default)
  74313. */
  74314. maximumScale: number;
  74315. /**
  74316. * Defines the step to use between two passes (0.5 by default)
  74317. */
  74318. step: number;
  74319. private _currentScale;
  74320. private _directionOffset;
  74321. /**
  74322. * Gets a string describing the action executed by the current optimization
  74323. * @return description string
  74324. */
  74325. getDescription(): string;
  74326. /**
  74327. * Creates the HardwareScalingOptimization object
  74328. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74329. * @param maximumScale defines the maximum scale to use (2 by default)
  74330. * @param step defines the step to use between two passes (0.5 by default)
  74331. */
  74332. constructor(
  74333. /**
  74334. * Defines the priority of this optimization (0 by default which means first in the list)
  74335. */
  74336. priority?: number,
  74337. /**
  74338. * Defines the maximum scale to use (2 by default)
  74339. */
  74340. maximumScale?: number,
  74341. /**
  74342. * Defines the step to use between two passes (0.5 by default)
  74343. */
  74344. step?: number);
  74345. /**
  74346. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74347. * @param scene defines the current scene where to apply this optimization
  74348. * @param optimizer defines the current optimizer
  74349. * @returns true if everything that can be done was applied
  74350. */
  74351. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74352. }
  74353. /**
  74354. * Defines an optimization used to remove shadows
  74355. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74356. */
  74357. export class ShadowsOptimization extends SceneOptimization {
  74358. /**
  74359. * Gets a string describing the action executed by the current optimization
  74360. * @return description string
  74361. */
  74362. getDescription(): string;
  74363. /**
  74364. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74365. * @param scene defines the current scene where to apply this optimization
  74366. * @param optimizer defines the current optimizer
  74367. * @returns true if everything that can be done was applied
  74368. */
  74369. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74370. }
  74371. /**
  74372. * Defines an optimization used to turn post-processes off
  74373. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74374. */
  74375. export class PostProcessesOptimization extends SceneOptimization {
  74376. /**
  74377. * Gets a string describing the action executed by the current optimization
  74378. * @return description string
  74379. */
  74380. getDescription(): string;
  74381. /**
  74382. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74383. * @param scene defines the current scene where to apply this optimization
  74384. * @param optimizer defines the current optimizer
  74385. * @returns true if everything that can be done was applied
  74386. */
  74387. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74388. }
  74389. /**
  74390. * Defines an optimization used to turn lens flares off
  74391. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74392. */
  74393. export class LensFlaresOptimization extends SceneOptimization {
  74394. /**
  74395. * Gets a string describing the action executed by the current optimization
  74396. * @return description string
  74397. */
  74398. getDescription(): string;
  74399. /**
  74400. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74401. * @param scene defines the current scene where to apply this optimization
  74402. * @param optimizer defines the current optimizer
  74403. * @returns true if everything that can be done was applied
  74404. */
  74405. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74406. }
  74407. /**
  74408. * Defines an optimization based on user defined callback.
  74409. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74410. */
  74411. export class CustomOptimization extends SceneOptimization {
  74412. /**
  74413. * Callback called to apply the custom optimization.
  74414. */
  74415. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74416. /**
  74417. * Callback called to get custom description
  74418. */
  74419. onGetDescription: () => string;
  74420. /**
  74421. * Gets a string describing the action executed by the current optimization
  74422. * @returns description string
  74423. */
  74424. getDescription(): string;
  74425. /**
  74426. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74427. * @param scene defines the current scene where to apply this optimization
  74428. * @param optimizer defines the current optimizer
  74429. * @returns true if everything that can be done was applied
  74430. */
  74431. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74432. }
  74433. /**
  74434. * Defines an optimization used to turn particles off
  74435. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74436. */
  74437. export class ParticlesOptimization extends SceneOptimization {
  74438. /**
  74439. * Gets a string describing the action executed by the current optimization
  74440. * @return description string
  74441. */
  74442. getDescription(): string;
  74443. /**
  74444. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74445. * @param scene defines the current scene where to apply this optimization
  74446. * @param optimizer defines the current optimizer
  74447. * @returns true if everything that can be done was applied
  74448. */
  74449. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74450. }
  74451. /**
  74452. * Defines an optimization used to turn render targets off
  74453. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74454. */
  74455. export class RenderTargetsOptimization extends SceneOptimization {
  74456. /**
  74457. * Gets a string describing the action executed by the current optimization
  74458. * @return description string
  74459. */
  74460. getDescription(): string;
  74461. /**
  74462. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74463. * @param scene defines the current scene where to apply this optimization
  74464. * @param optimizer defines the current optimizer
  74465. * @returns true if everything that can be done was applied
  74466. */
  74467. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74468. }
  74469. /**
  74470. * Defines an optimization used to merge meshes with compatible materials
  74471. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74472. */
  74473. export class MergeMeshesOptimization extends SceneOptimization {
  74474. private static _UpdateSelectionTree;
  74475. /**
  74476. * Gets or sets a boolean which defines if optimization octree has to be updated
  74477. */
  74478. static get UpdateSelectionTree(): boolean;
  74479. /**
  74480. * Gets or sets a boolean which defines if optimization octree has to be updated
  74481. */
  74482. static set UpdateSelectionTree(value: boolean);
  74483. /**
  74484. * Gets a string describing the action executed by the current optimization
  74485. * @return description string
  74486. */
  74487. getDescription(): string;
  74488. private _canBeMerged;
  74489. /**
  74490. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74491. * @param scene defines the current scene where to apply this optimization
  74492. * @param optimizer defines the current optimizer
  74493. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74494. * @returns true if everything that can be done was applied
  74495. */
  74496. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74497. }
  74498. /**
  74499. * Defines a list of options used by SceneOptimizer
  74500. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74501. */
  74502. export class SceneOptimizerOptions {
  74503. /**
  74504. * Defines the target frame rate to reach (60 by default)
  74505. */
  74506. targetFrameRate: number;
  74507. /**
  74508. * Defines the interval between two checkes (2000ms by default)
  74509. */
  74510. trackerDuration: number;
  74511. /**
  74512. * Gets the list of optimizations to apply
  74513. */
  74514. optimizations: SceneOptimization[];
  74515. /**
  74516. * Creates a new list of options used by SceneOptimizer
  74517. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74518. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74519. */
  74520. constructor(
  74521. /**
  74522. * Defines the target frame rate to reach (60 by default)
  74523. */
  74524. targetFrameRate?: number,
  74525. /**
  74526. * Defines the interval between two checkes (2000ms by default)
  74527. */
  74528. trackerDuration?: number);
  74529. /**
  74530. * Add a new optimization
  74531. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74532. * @returns the current SceneOptimizerOptions
  74533. */
  74534. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74535. /**
  74536. * Add a new custom optimization
  74537. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74538. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74539. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74540. * @returns the current SceneOptimizerOptions
  74541. */
  74542. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74543. /**
  74544. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74545. * @param targetFrameRate defines the target frame rate (60 by default)
  74546. * @returns a SceneOptimizerOptions object
  74547. */
  74548. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74549. /**
  74550. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74551. * @param targetFrameRate defines the target frame rate (60 by default)
  74552. * @returns a SceneOptimizerOptions object
  74553. */
  74554. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74555. /**
  74556. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74557. * @param targetFrameRate defines the target frame rate (60 by default)
  74558. * @returns a SceneOptimizerOptions object
  74559. */
  74560. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74561. }
  74562. /**
  74563. * Class used to run optimizations in order to reach a target frame rate
  74564. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74565. */
  74566. export class SceneOptimizer implements IDisposable {
  74567. private _isRunning;
  74568. private _options;
  74569. private _scene;
  74570. private _currentPriorityLevel;
  74571. private _targetFrameRate;
  74572. private _trackerDuration;
  74573. private _currentFrameRate;
  74574. private _sceneDisposeObserver;
  74575. private _improvementMode;
  74576. /**
  74577. * Defines an observable called when the optimizer reaches the target frame rate
  74578. */
  74579. onSuccessObservable: Observable<SceneOptimizer>;
  74580. /**
  74581. * Defines an observable called when the optimizer enables an optimization
  74582. */
  74583. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74584. /**
  74585. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74586. */
  74587. onFailureObservable: Observable<SceneOptimizer>;
  74588. /**
  74589. * Gets a boolean indicating if the optimizer is in improvement mode
  74590. */
  74591. get isInImprovementMode(): boolean;
  74592. /**
  74593. * Gets the current priority level (0 at start)
  74594. */
  74595. get currentPriorityLevel(): number;
  74596. /**
  74597. * Gets the current frame rate checked by the SceneOptimizer
  74598. */
  74599. get currentFrameRate(): number;
  74600. /**
  74601. * Gets or sets the current target frame rate (60 by default)
  74602. */
  74603. get targetFrameRate(): number;
  74604. /**
  74605. * Gets or sets the current target frame rate (60 by default)
  74606. */
  74607. set targetFrameRate(value: number);
  74608. /**
  74609. * Gets or sets the current interval between two checks (every 2000ms by default)
  74610. */
  74611. get trackerDuration(): number;
  74612. /**
  74613. * Gets or sets the current interval between two checks (every 2000ms by default)
  74614. */
  74615. set trackerDuration(value: number);
  74616. /**
  74617. * Gets the list of active optimizations
  74618. */
  74619. get optimizations(): SceneOptimization[];
  74620. /**
  74621. * Creates a new SceneOptimizer
  74622. * @param scene defines the scene to work on
  74623. * @param options defines the options to use with the SceneOptimizer
  74624. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74625. * @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)
  74626. */
  74627. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74628. /**
  74629. * Stops the current optimizer
  74630. */
  74631. stop(): void;
  74632. /**
  74633. * Reset the optimizer to initial step (current priority level = 0)
  74634. */
  74635. reset(): void;
  74636. /**
  74637. * Start the optimizer. By default it will try to reach a specific framerate
  74638. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74639. */
  74640. start(): void;
  74641. private _checkCurrentState;
  74642. /**
  74643. * Release all resources
  74644. */
  74645. dispose(): void;
  74646. /**
  74647. * Helper function to create a SceneOptimizer with one single line of code
  74648. * @param scene defines the scene to work on
  74649. * @param options defines the options to use with the SceneOptimizer
  74650. * @param onSuccess defines a callback to call on success
  74651. * @param onFailure defines a callback to call on failure
  74652. * @returns the new SceneOptimizer object
  74653. */
  74654. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74655. }
  74656. }
  74657. declare module BABYLON {
  74658. /**
  74659. * Class used to serialize a scene into a string
  74660. */
  74661. export class SceneSerializer {
  74662. /**
  74663. * Clear cache used by a previous serialization
  74664. */
  74665. static ClearCache(): void;
  74666. /**
  74667. * Serialize a scene into a JSON compatible object
  74668. * @param scene defines the scene to serialize
  74669. * @returns a JSON compatible object
  74670. */
  74671. static Serialize(scene: Scene): any;
  74672. /**
  74673. * Serialize a mesh into a JSON compatible object
  74674. * @param toSerialize defines the mesh to serialize
  74675. * @param withParents defines if parents must be serialized as well
  74676. * @param withChildren defines if children must be serialized as well
  74677. * @returns a JSON compatible object
  74678. */
  74679. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74680. }
  74681. }
  74682. declare module BABYLON {
  74683. /**
  74684. * Class used to host texture specific utilities
  74685. */
  74686. export class TextureTools {
  74687. /**
  74688. * Uses the GPU to create a copy texture rescaled at a given size
  74689. * @param texture Texture to copy from
  74690. * @param width defines the desired width
  74691. * @param height defines the desired height
  74692. * @param useBilinearMode defines if bilinear mode has to be used
  74693. * @return the generated texture
  74694. */
  74695. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74696. }
  74697. }
  74698. declare module BABYLON {
  74699. /**
  74700. * This represents the different options available for the video capture.
  74701. */
  74702. export interface VideoRecorderOptions {
  74703. /** Defines the mime type of the video. */
  74704. mimeType: string;
  74705. /** Defines the FPS the video should be recorded at. */
  74706. fps: number;
  74707. /** Defines the chunk size for the recording data. */
  74708. recordChunckSize: number;
  74709. /** The audio tracks to attach to the recording. */
  74710. audioTracks?: MediaStreamTrack[];
  74711. }
  74712. /**
  74713. * This can help with recording videos from BabylonJS.
  74714. * This is based on the available WebRTC functionalities of the browser.
  74715. *
  74716. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74717. */
  74718. export class VideoRecorder {
  74719. private static readonly _defaultOptions;
  74720. /**
  74721. * Returns whether or not the VideoRecorder is available in your browser.
  74722. * @param engine Defines the Babylon Engine.
  74723. * @returns true if supported otherwise false.
  74724. */
  74725. static IsSupported(engine: Engine): boolean;
  74726. private readonly _options;
  74727. private _canvas;
  74728. private _mediaRecorder;
  74729. private _recordedChunks;
  74730. private _fileName;
  74731. private _resolve;
  74732. private _reject;
  74733. /**
  74734. * True when a recording is already in progress.
  74735. */
  74736. get isRecording(): boolean;
  74737. /**
  74738. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74739. * @param engine Defines the BabylonJS Engine you wish to record.
  74740. * @param options Defines options that can be used to customize the capture.
  74741. */
  74742. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74743. /**
  74744. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74745. */
  74746. stopRecording(): void;
  74747. /**
  74748. * Starts recording the canvas for a max duration specified in parameters.
  74749. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74750. * If null no automatic download will start and you can rely on the promise to get the data back.
  74751. * @param maxDuration Defines the maximum recording time in seconds.
  74752. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74753. * @return A promise callback at the end of the recording with the video data in Blob.
  74754. */
  74755. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74756. /**
  74757. * Releases internal resources used during the recording.
  74758. */
  74759. dispose(): void;
  74760. private _handleDataAvailable;
  74761. private _handleError;
  74762. private _handleStop;
  74763. }
  74764. }
  74765. declare module BABYLON {
  74766. /**
  74767. * Class containing a set of static utilities functions for screenshots
  74768. */
  74769. export class ScreenshotTools {
  74770. /**
  74771. * Captures a screenshot of the current rendering
  74772. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74773. * @param engine defines the rendering engine
  74774. * @param camera defines the source camera
  74775. * @param size This parameter can be set to a single number or to an object with the
  74776. * following (optional) properties: precision, width, height. If a single number is passed,
  74777. * it will be used for both width and height. If an object is passed, the screenshot size
  74778. * will be derived from the parameters. The precision property is a multiplier allowing
  74779. * rendering at a higher or lower resolution
  74780. * @param successCallback defines the callback receives a single parameter which contains the
  74781. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74782. * src parameter of an <img> to display it
  74783. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74784. * Check your browser for supported MIME types
  74785. */
  74786. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74787. /**
  74788. * Captures a screenshot of the current rendering
  74789. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74790. * @param engine defines the rendering engine
  74791. * @param camera defines the source camera
  74792. * @param size This parameter can be set to a single number or to an object with the
  74793. * following (optional) properties: precision, width, height. If a single number is passed,
  74794. * it will be used for both width and height. If an object is passed, the screenshot size
  74795. * will be derived from the parameters. The precision property is a multiplier allowing
  74796. * rendering at a higher or lower resolution
  74797. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74798. * Check your browser for supported MIME types
  74799. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74800. * to the src parameter of an <img> to display it
  74801. */
  74802. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74803. /**
  74804. * Generates an image screenshot from the specified camera.
  74805. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74806. * @param engine The engine to use for rendering
  74807. * @param camera The camera to use for rendering
  74808. * @param size This parameter can be set to a single number or to an object with the
  74809. * following (optional) properties: precision, width, height. If a single number is passed,
  74810. * it will be used for both width and height. If an object is passed, the screenshot size
  74811. * will be derived from the parameters. The precision property is a multiplier allowing
  74812. * rendering at a higher or lower resolution
  74813. * @param successCallback The callback receives a single parameter which contains the
  74814. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74815. * src parameter of an <img> to display it
  74816. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74817. * Check your browser for supported MIME types
  74818. * @param samples Texture samples (default: 1)
  74819. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74820. * @param fileName A name for for the downloaded file.
  74821. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74822. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74823. */
  74824. 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;
  74825. /**
  74826. * Generates an image screenshot from the specified camera.
  74827. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74828. * @param engine The engine to use for rendering
  74829. * @param camera The camera to use for rendering
  74830. * @param size This parameter can be set to a single number or to an object with the
  74831. * following (optional) properties: precision, width, height. If a single number is passed,
  74832. * it will be used for both width and height. If an object is passed, the screenshot size
  74833. * will be derived from the parameters. The precision property is a multiplier allowing
  74834. * rendering at a higher or lower resolution
  74835. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74836. * Check your browser for supported MIME types
  74837. * @param samples Texture samples (default: 1)
  74838. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74839. * @param fileName A name for for the downloaded file.
  74840. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74841. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74842. * to the src parameter of an <img> to display it
  74843. */
  74844. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74845. /**
  74846. * Gets height and width for screenshot size
  74847. * @private
  74848. */
  74849. private static _getScreenshotSize;
  74850. }
  74851. }
  74852. declare module BABYLON {
  74853. /**
  74854. * Interface for a data buffer
  74855. */
  74856. export interface IDataBuffer {
  74857. /**
  74858. * Reads bytes from the data buffer.
  74859. * @param byteOffset The byte offset to read
  74860. * @param byteLength The byte length to read
  74861. * @returns A promise that resolves when the bytes are read
  74862. */
  74863. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74864. /**
  74865. * The byte length of the buffer.
  74866. */
  74867. readonly byteLength: number;
  74868. }
  74869. /**
  74870. * Utility class for reading from a data buffer
  74871. */
  74872. export class DataReader {
  74873. /**
  74874. * The data buffer associated with this data reader.
  74875. */
  74876. readonly buffer: IDataBuffer;
  74877. /**
  74878. * The current byte offset from the beginning of the data buffer.
  74879. */
  74880. byteOffset: number;
  74881. private _dataView;
  74882. private _dataByteOffset;
  74883. /**
  74884. * Constructor
  74885. * @param buffer The buffer to read
  74886. */
  74887. constructor(buffer: IDataBuffer);
  74888. /**
  74889. * Loads the given byte length.
  74890. * @param byteLength The byte length to load
  74891. * @returns A promise that resolves when the load is complete
  74892. */
  74893. loadAsync(byteLength: number): Promise<void>;
  74894. /**
  74895. * Read a unsigned 32-bit integer from the currently loaded data range.
  74896. * @returns The 32-bit integer read
  74897. */
  74898. readUint32(): number;
  74899. /**
  74900. * Read a byte array from the currently loaded data range.
  74901. * @param byteLength The byte length to read
  74902. * @returns The byte array read
  74903. */
  74904. readUint8Array(byteLength: number): Uint8Array;
  74905. /**
  74906. * Read a string from the currently loaded data range.
  74907. * @param byteLength The byte length to read
  74908. * @returns The string read
  74909. */
  74910. readString(byteLength: number): string;
  74911. /**
  74912. * Skips the given byte length the currently loaded data range.
  74913. * @param byteLength The byte length to skip
  74914. */
  74915. skipBytes(byteLength: number): void;
  74916. }
  74917. }
  74918. declare module BABYLON {
  74919. /**
  74920. * Class for storing data to local storage if available or in-memory storage otherwise
  74921. */
  74922. export class DataStorage {
  74923. private static _Storage;
  74924. private static _GetStorage;
  74925. /**
  74926. * Reads a string from the data storage
  74927. * @param key The key to read
  74928. * @param defaultValue The value if the key doesn't exist
  74929. * @returns The string value
  74930. */
  74931. static ReadString(key: string, defaultValue: string): string;
  74932. /**
  74933. * Writes a string to the data storage
  74934. * @param key The key to write
  74935. * @param value The value to write
  74936. */
  74937. static WriteString(key: string, value: string): void;
  74938. /**
  74939. * Reads a boolean from the data storage
  74940. * @param key The key to read
  74941. * @param defaultValue The value if the key doesn't exist
  74942. * @returns The boolean value
  74943. */
  74944. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74945. /**
  74946. * Writes a boolean to the data storage
  74947. * @param key The key to write
  74948. * @param value The value to write
  74949. */
  74950. static WriteBoolean(key: string, value: boolean): void;
  74951. /**
  74952. * Reads a number from the data storage
  74953. * @param key The key to read
  74954. * @param defaultValue The value if the key doesn't exist
  74955. * @returns The number value
  74956. */
  74957. static ReadNumber(key: string, defaultValue: number): number;
  74958. /**
  74959. * Writes a number to the data storage
  74960. * @param key The key to write
  74961. * @param value The value to write
  74962. */
  74963. static WriteNumber(key: string, value: number): void;
  74964. }
  74965. }
  74966. declare module BABYLON {
  74967. /**
  74968. * Class used to record delta files between 2 scene states
  74969. */
  74970. export class SceneRecorder {
  74971. private _trackedScene;
  74972. private _savedJSON;
  74973. /**
  74974. * Track a given scene. This means the current scene state will be considered the original state
  74975. * @param scene defines the scene to track
  74976. */
  74977. track(scene: Scene): void;
  74978. /**
  74979. * Get the delta between current state and original state
  74980. * @returns a string containing the delta
  74981. */
  74982. getDelta(): any;
  74983. private _compareArray;
  74984. private _compareObjects;
  74985. private _compareCollections;
  74986. private static GetShadowGeneratorById;
  74987. /**
  74988. * Apply a given delta to a given scene
  74989. * @param deltaJSON defines the JSON containing the delta
  74990. * @param scene defines the scene to apply the delta to
  74991. */
  74992. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74993. private static _ApplyPropertiesToEntity;
  74994. private static _ApplyDeltaForEntity;
  74995. }
  74996. }
  74997. declare module BABYLON {
  74998. /**
  74999. * A 3D trajectory consisting of an order list of vectors describing a
  75000. * path of motion through 3D space.
  75001. */
  75002. export class Trajectory {
  75003. private _points;
  75004. private readonly _segmentLength;
  75005. /**
  75006. * Serialize to JSON.
  75007. * @returns serialized JSON string
  75008. */
  75009. serialize(): string;
  75010. /**
  75011. * Deserialize from JSON.
  75012. * @param json serialized JSON string
  75013. * @returns deserialized Trajectory
  75014. */
  75015. static Deserialize(json: string): Trajectory;
  75016. /**
  75017. * Create a new empty Trajectory.
  75018. * @param segmentLength radius of discretization for Trajectory points
  75019. */
  75020. constructor(segmentLength?: number);
  75021. /**
  75022. * Get the length of the Trajectory.
  75023. * @returns length of the Trajectory
  75024. */
  75025. getLength(): number;
  75026. /**
  75027. * Append a new point to the Trajectory.
  75028. * NOTE: This implementation has many allocations.
  75029. * @param point point to append to the Trajectory
  75030. */
  75031. add(point: DeepImmutable<Vector3>): void;
  75032. /**
  75033. * Create a new Trajectory with a segment length chosen to make it
  75034. * probable that the new Trajectory will have a specified number of
  75035. * segments. This operation is imprecise.
  75036. * @param targetResolution number of segments desired
  75037. * @returns new Trajectory with approximately the requested number of segments
  75038. */
  75039. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75040. /**
  75041. * Convert Trajectory segments into tokenized representation. This
  75042. * representation is an array of numbers where each nth number is the
  75043. * index of the token which is most similar to the nth segment of the
  75044. * Trajectory.
  75045. * @param tokens list of vectors which serve as discrete tokens
  75046. * @returns list of indices of most similar token per segment
  75047. */
  75048. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75049. private static _forwardDir;
  75050. private static _inverseFromVec;
  75051. private static _upDir;
  75052. private static _fromToVec;
  75053. private static _lookMatrix;
  75054. /**
  75055. * Transform the rotation (i.e., direction) of a segment to isolate
  75056. * the relative transformation represented by the segment. This operation
  75057. * may or may not succeed due to singularities in the equations that define
  75058. * motion relativity in this context.
  75059. * @param priorVec the origin of the prior segment
  75060. * @param fromVec the origin of the current segment
  75061. * @param toVec the destination of the current segment
  75062. * @param result reference to output variable
  75063. * @returns whether or not transformation was successful
  75064. */
  75065. private static _transformSegmentDirToRef;
  75066. private static _bestMatch;
  75067. private static _score;
  75068. private static _bestScore;
  75069. /**
  75070. * Determine which token vector is most similar to the
  75071. * segment vector.
  75072. * @param segment segment vector
  75073. * @param tokens token vector list
  75074. * @returns index of the most similar token to the segment
  75075. */
  75076. private static _tokenizeSegment;
  75077. }
  75078. /**
  75079. * Class representing a set of known, named trajectories to which Trajectories can be
  75080. * added and using which Trajectories can be recognized.
  75081. */
  75082. export class TrajectoryClassifier {
  75083. private _maximumAllowableMatchCost;
  75084. private _vector3Alphabet;
  75085. private _levenshteinAlphabet;
  75086. private _nameToDescribedTrajectory;
  75087. /**
  75088. * Serialize to JSON.
  75089. * @returns JSON serialization
  75090. */
  75091. serialize(): string;
  75092. /**
  75093. * Deserialize from JSON.
  75094. * @param json JSON serialization
  75095. * @returns deserialized TrajectorySet
  75096. */
  75097. static Deserialize(json: string): TrajectoryClassifier;
  75098. /**
  75099. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75100. * VERY naive, need to be generating these things from known
  75101. * sets. Better version later, probably eliminating this one.
  75102. * @returns auto-generated TrajectorySet
  75103. */
  75104. static Generate(): TrajectoryClassifier;
  75105. private constructor();
  75106. /**
  75107. * Add a new Trajectory to the set with a given name.
  75108. * @param trajectory new Trajectory to be added
  75109. * @param classification name to which to add the Trajectory
  75110. */
  75111. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75112. /**
  75113. * Remove a known named trajectory and all Trajectories associated with it.
  75114. * @param classification name to remove
  75115. * @returns whether anything was removed
  75116. */
  75117. deleteClassification(classification: string): boolean;
  75118. /**
  75119. * Attempt to recognize a Trajectory from among all the classifications
  75120. * already known to the classifier.
  75121. * @param trajectory Trajectory to be recognized
  75122. * @returns classification of Trajectory if recognized, null otherwise
  75123. */
  75124. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75125. }
  75126. }
  75127. declare module BABYLON {
  75128. /**
  75129. * An interface for all Hit test features
  75130. */
  75131. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75132. /**
  75133. * Triggered when new babylon (transformed) hit test results are available
  75134. */
  75135. onHitTestResultObservable: Observable<T[]>;
  75136. }
  75137. /**
  75138. * Options used for hit testing
  75139. */
  75140. export interface IWebXRLegacyHitTestOptions {
  75141. /**
  75142. * Only test when user interacted with the scene. Default - hit test every frame
  75143. */
  75144. testOnPointerDownOnly?: boolean;
  75145. /**
  75146. * The node to use to transform the local results to world coordinates
  75147. */
  75148. worldParentNode?: TransformNode;
  75149. }
  75150. /**
  75151. * Interface defining the babylon result of raycasting/hit-test
  75152. */
  75153. export interface IWebXRLegacyHitResult {
  75154. /**
  75155. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75156. */
  75157. transformationMatrix: Matrix;
  75158. /**
  75159. * The native hit test result
  75160. */
  75161. xrHitResult: XRHitResult | XRHitTestResult;
  75162. }
  75163. /**
  75164. * The currently-working hit-test module.
  75165. * Hit test (or Ray-casting) is used to interact with the real world.
  75166. * For further information read here - https://github.com/immersive-web/hit-test
  75167. */
  75168. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75169. /**
  75170. * options to use when constructing this feature
  75171. */
  75172. readonly options: IWebXRLegacyHitTestOptions;
  75173. private _direction;
  75174. private _mat;
  75175. private _onSelectEnabled;
  75176. private _origin;
  75177. /**
  75178. * The module's name
  75179. */
  75180. static readonly Name: string;
  75181. /**
  75182. * The (Babylon) version of this module.
  75183. * This is an integer representing the implementation version.
  75184. * This number does not correspond to the WebXR specs version
  75185. */
  75186. static readonly Version: number;
  75187. /**
  75188. * Populated with the last native XR Hit Results
  75189. */
  75190. lastNativeXRHitResults: XRHitResult[];
  75191. /**
  75192. * Triggered when new babylon (transformed) hit test results are available
  75193. */
  75194. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75195. /**
  75196. * Creates a new instance of the (legacy version) hit test feature
  75197. * @param _xrSessionManager an instance of WebXRSessionManager
  75198. * @param options options to use when constructing this feature
  75199. */
  75200. constructor(_xrSessionManager: WebXRSessionManager,
  75201. /**
  75202. * options to use when constructing this feature
  75203. */
  75204. options?: IWebXRLegacyHitTestOptions);
  75205. /**
  75206. * execute a hit test with an XR Ray
  75207. *
  75208. * @param xrSession a native xrSession that will execute this hit test
  75209. * @param xrRay the ray (position and direction) to use for ray-casting
  75210. * @param referenceSpace native XR reference space to use for the hit-test
  75211. * @param filter filter function that will filter the results
  75212. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75213. */
  75214. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75215. /**
  75216. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75217. * @param event the (select) event to use to select with
  75218. * @param referenceSpace the reference space to use for this hit test
  75219. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75220. */
  75221. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75222. /**
  75223. * attach this feature
  75224. * Will usually be called by the features manager
  75225. *
  75226. * @returns true if successful.
  75227. */
  75228. attach(): boolean;
  75229. /**
  75230. * detach this feature.
  75231. * Will usually be called by the features manager
  75232. *
  75233. * @returns true if successful.
  75234. */
  75235. detach(): boolean;
  75236. /**
  75237. * Dispose this feature and all of the resources attached
  75238. */
  75239. dispose(): void;
  75240. protected _onXRFrame(frame: XRFrame): void;
  75241. private _onHitTestResults;
  75242. private _onSelect;
  75243. }
  75244. }
  75245. declare module BABYLON {
  75246. /**
  75247. * Options used for hit testing (version 2)
  75248. */
  75249. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75250. /**
  75251. * Do not create a permanent hit test. Will usually be used when only
  75252. * transient inputs are needed.
  75253. */
  75254. disablePermanentHitTest?: boolean;
  75255. /**
  75256. * Enable transient (for example touch-based) hit test inspections
  75257. */
  75258. enableTransientHitTest?: boolean;
  75259. /**
  75260. * Offset ray for the permanent hit test
  75261. */
  75262. offsetRay?: Vector3;
  75263. /**
  75264. * Offset ray for the transient hit test
  75265. */
  75266. transientOffsetRay?: Vector3;
  75267. /**
  75268. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75269. */
  75270. useReferenceSpace?: boolean;
  75271. /**
  75272. * Override the default entity type(s) of the hit-test result
  75273. */
  75274. entityTypes?: XRHitTestTrackableType[];
  75275. }
  75276. /**
  75277. * Interface defining the babylon result of hit-test
  75278. */
  75279. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75280. /**
  75281. * The input source that generated this hit test (if transient)
  75282. */
  75283. inputSource?: XRInputSource;
  75284. /**
  75285. * Is this a transient hit test
  75286. */
  75287. isTransient?: boolean;
  75288. /**
  75289. * Position of the hit test result
  75290. */
  75291. position: Vector3;
  75292. /**
  75293. * Rotation of the hit test result
  75294. */
  75295. rotationQuaternion: Quaternion;
  75296. /**
  75297. * The native hit test result
  75298. */
  75299. xrHitResult: XRHitTestResult;
  75300. }
  75301. /**
  75302. * The currently-working hit-test module.
  75303. * Hit test (or Ray-casting) is used to interact with the real world.
  75304. * For further information read here - https://github.com/immersive-web/hit-test
  75305. *
  75306. * Tested on chrome (mobile) 80.
  75307. */
  75308. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75309. /**
  75310. * options to use when constructing this feature
  75311. */
  75312. readonly options: IWebXRHitTestOptions;
  75313. private _tmpMat;
  75314. private _tmpPos;
  75315. private _tmpQuat;
  75316. private _transientXrHitTestSource;
  75317. private _xrHitTestSource;
  75318. private initHitTestSource;
  75319. /**
  75320. * The module's name
  75321. */
  75322. static readonly Name: string;
  75323. /**
  75324. * The (Babylon) version of this module.
  75325. * This is an integer representing the implementation version.
  75326. * This number does not correspond to the WebXR specs version
  75327. */
  75328. static readonly Version: number;
  75329. /**
  75330. * When set to true, each hit test will have its own position/rotation objects
  75331. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75332. * the developers will clone them or copy them as they see fit.
  75333. */
  75334. autoCloneTransformation: boolean;
  75335. /**
  75336. * Triggered when new babylon (transformed) hit test results are available
  75337. * Note - this will be called when results come back from the device. It can be an empty array!!
  75338. */
  75339. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75340. /**
  75341. * Use this to temporarily pause hit test checks.
  75342. */
  75343. paused: boolean;
  75344. /**
  75345. * Creates a new instance of the hit test feature
  75346. * @param _xrSessionManager an instance of WebXRSessionManager
  75347. * @param options options to use when constructing this feature
  75348. */
  75349. constructor(_xrSessionManager: WebXRSessionManager,
  75350. /**
  75351. * options to use when constructing this feature
  75352. */
  75353. options?: IWebXRHitTestOptions);
  75354. /**
  75355. * attach this feature
  75356. * Will usually be called by the features manager
  75357. *
  75358. * @returns true if successful.
  75359. */
  75360. attach(): boolean;
  75361. /**
  75362. * detach this feature.
  75363. * Will usually be called by the features manager
  75364. *
  75365. * @returns true if successful.
  75366. */
  75367. detach(): boolean;
  75368. /**
  75369. * Dispose this feature and all of the resources attached
  75370. */
  75371. dispose(): void;
  75372. protected _onXRFrame(frame: XRFrame): void;
  75373. private _processWebXRHitTestResult;
  75374. }
  75375. }
  75376. declare module BABYLON {
  75377. /**
  75378. * Configuration options of the anchor system
  75379. */
  75380. export interface IWebXRAnchorSystemOptions {
  75381. /**
  75382. * a node that will be used to convert local to world coordinates
  75383. */
  75384. worldParentNode?: TransformNode;
  75385. /**
  75386. * If set to true a reference of the created anchors will be kept until the next session starts
  75387. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75388. */
  75389. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75390. }
  75391. /**
  75392. * A babylon container for an XR Anchor
  75393. */
  75394. export interface IWebXRAnchor {
  75395. /**
  75396. * A babylon-assigned ID for this anchor
  75397. */
  75398. id: number;
  75399. /**
  75400. * Transformation matrix to apply to an object attached to this anchor
  75401. */
  75402. transformationMatrix: Matrix;
  75403. /**
  75404. * The native anchor object
  75405. */
  75406. xrAnchor: XRAnchor;
  75407. /**
  75408. * if defined, this object will be constantly updated by the anchor's position and rotation
  75409. */
  75410. attachedNode?: TransformNode;
  75411. }
  75412. /**
  75413. * An implementation of the anchor system for WebXR.
  75414. * For further information see https://github.com/immersive-web/anchors/
  75415. */
  75416. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75417. private _options;
  75418. private _lastFrameDetected;
  75419. private _trackedAnchors;
  75420. private _referenceSpaceForFrameAnchors;
  75421. private _futureAnchors;
  75422. /**
  75423. * The module's name
  75424. */
  75425. static readonly Name: string;
  75426. /**
  75427. * The (Babylon) version of this module.
  75428. * This is an integer representing the implementation version.
  75429. * This number does not correspond to the WebXR specs version
  75430. */
  75431. static readonly Version: number;
  75432. /**
  75433. * Observers registered here will be executed when a new anchor was added to the session
  75434. */
  75435. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75436. /**
  75437. * Observers registered here will be executed when an anchor was removed from the session
  75438. */
  75439. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75440. /**
  75441. * Observers registered here will be executed when an existing anchor updates
  75442. * This can execute N times every frame
  75443. */
  75444. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75445. /**
  75446. * Set the reference space to use for anchor creation, when not using a hit test.
  75447. * Will default to the session's reference space if not defined
  75448. */
  75449. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75450. /**
  75451. * constructs a new anchor system
  75452. * @param _xrSessionManager an instance of WebXRSessionManager
  75453. * @param _options configuration object for this feature
  75454. */
  75455. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75456. private _tmpVector;
  75457. private _tmpQuaternion;
  75458. private _populateTmpTransformation;
  75459. /**
  75460. * Create a new anchor point using a hit test result at a specific point in the scene
  75461. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75462. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75463. *
  75464. * @param hitTestResult The hit test result to use for this anchor creation
  75465. * @param position an optional position offset for this anchor
  75466. * @param rotationQuaternion an optional rotation offset for this anchor
  75467. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75468. */
  75469. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75470. /**
  75471. * Add a new anchor at a specific position and rotation
  75472. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75473. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75474. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75475. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75476. *
  75477. * @param position the position in which to add an anchor
  75478. * @param rotationQuaternion an optional rotation for the anchor transformation
  75479. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75480. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75481. */
  75482. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75483. /**
  75484. * detach this feature.
  75485. * Will usually be called by the features manager
  75486. *
  75487. * @returns true if successful.
  75488. */
  75489. detach(): boolean;
  75490. /**
  75491. * Dispose this feature and all of the resources attached
  75492. */
  75493. dispose(): void;
  75494. protected _onXRFrame(frame: XRFrame): void;
  75495. /**
  75496. * avoiding using Array.find for global support.
  75497. * @param xrAnchor the plane to find in the array
  75498. */
  75499. private _findIndexInAnchorArray;
  75500. private _updateAnchorWithXRFrame;
  75501. private _createAnchorAtTransformation;
  75502. }
  75503. }
  75504. declare module BABYLON {
  75505. /**
  75506. * Options used in the plane detector module
  75507. */
  75508. export interface IWebXRPlaneDetectorOptions {
  75509. /**
  75510. * The node to use to transform the local results to world coordinates
  75511. */
  75512. worldParentNode?: TransformNode;
  75513. /**
  75514. * If set to true a reference of the created planes will be kept until the next session starts
  75515. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75516. */
  75517. doNotRemovePlanesOnSessionEnded?: boolean;
  75518. }
  75519. /**
  75520. * A babylon interface for a WebXR plane.
  75521. * A Plane is actually a polygon, built from N points in space
  75522. *
  75523. * Supported in chrome 79, not supported in canary 81 ATM
  75524. */
  75525. export interface IWebXRPlane {
  75526. /**
  75527. * a babylon-assigned ID for this polygon
  75528. */
  75529. id: number;
  75530. /**
  75531. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75532. */
  75533. polygonDefinition: Array<Vector3>;
  75534. /**
  75535. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75536. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75537. */
  75538. transformationMatrix: Matrix;
  75539. /**
  75540. * the native xr-plane object
  75541. */
  75542. xrPlane: XRPlane;
  75543. }
  75544. /**
  75545. * The plane detector is used to detect planes in the real world when in AR
  75546. * For more information see https://github.com/immersive-web/real-world-geometry/
  75547. */
  75548. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75549. private _options;
  75550. private _detectedPlanes;
  75551. private _enabled;
  75552. private _lastFrameDetected;
  75553. /**
  75554. * The module's name
  75555. */
  75556. static readonly Name: string;
  75557. /**
  75558. * The (Babylon) version of this module.
  75559. * This is an integer representing the implementation version.
  75560. * This number does not correspond to the WebXR specs version
  75561. */
  75562. static readonly Version: number;
  75563. /**
  75564. * Observers registered here will be executed when a new plane was added to the session
  75565. */
  75566. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75567. /**
  75568. * Observers registered here will be executed when a plane is no longer detected in the session
  75569. */
  75570. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75571. /**
  75572. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75573. * This can execute N times every frame
  75574. */
  75575. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75576. /**
  75577. * construct a new Plane Detector
  75578. * @param _xrSessionManager an instance of xr Session manager
  75579. * @param _options configuration to use when constructing this feature
  75580. */
  75581. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75582. /**
  75583. * detach this feature.
  75584. * Will usually be called by the features manager
  75585. *
  75586. * @returns true if successful.
  75587. */
  75588. detach(): boolean;
  75589. /**
  75590. * Dispose this feature and all of the resources attached
  75591. */
  75592. dispose(): void;
  75593. protected _onXRFrame(frame: XRFrame): void;
  75594. private _init;
  75595. private _updatePlaneWithXRPlane;
  75596. /**
  75597. * avoiding using Array.find for global support.
  75598. * @param xrPlane the plane to find in the array
  75599. */
  75600. private findIndexInPlaneArray;
  75601. }
  75602. }
  75603. declare module BABYLON {
  75604. /**
  75605. * Options interface for the background remover plugin
  75606. */
  75607. export interface IWebXRBackgroundRemoverOptions {
  75608. /**
  75609. * Further background meshes to disable when entering AR
  75610. */
  75611. backgroundMeshes?: AbstractMesh[];
  75612. /**
  75613. * flags to configure the removal of the environment helper.
  75614. * If not set, the entire background will be removed. If set, flags should be set as well.
  75615. */
  75616. environmentHelperRemovalFlags?: {
  75617. /**
  75618. * Should the skybox be removed (default false)
  75619. */
  75620. skyBox?: boolean;
  75621. /**
  75622. * Should the ground be removed (default false)
  75623. */
  75624. ground?: boolean;
  75625. };
  75626. /**
  75627. * don't disable the environment helper
  75628. */
  75629. ignoreEnvironmentHelper?: boolean;
  75630. }
  75631. /**
  75632. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75633. */
  75634. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75635. /**
  75636. * read-only options to be used in this module
  75637. */
  75638. readonly options: IWebXRBackgroundRemoverOptions;
  75639. /**
  75640. * The module's name
  75641. */
  75642. static readonly Name: string;
  75643. /**
  75644. * The (Babylon) version of this module.
  75645. * This is an integer representing the implementation version.
  75646. * This number does not correspond to the WebXR specs version
  75647. */
  75648. static readonly Version: number;
  75649. /**
  75650. * registered observers will be triggered when the background state changes
  75651. */
  75652. onBackgroundStateChangedObservable: Observable<boolean>;
  75653. /**
  75654. * constructs a new background remover module
  75655. * @param _xrSessionManager the session manager for this module
  75656. * @param options read-only options to be used in this module
  75657. */
  75658. constructor(_xrSessionManager: WebXRSessionManager,
  75659. /**
  75660. * read-only options to be used in this module
  75661. */
  75662. options?: IWebXRBackgroundRemoverOptions);
  75663. /**
  75664. * attach this feature
  75665. * Will usually be called by the features manager
  75666. *
  75667. * @returns true if successful.
  75668. */
  75669. attach(): boolean;
  75670. /**
  75671. * detach this feature.
  75672. * Will usually be called by the features manager
  75673. *
  75674. * @returns true if successful.
  75675. */
  75676. detach(): boolean;
  75677. /**
  75678. * Dispose this feature and all of the resources attached
  75679. */
  75680. dispose(): void;
  75681. protected _onXRFrame(_xrFrame: XRFrame): void;
  75682. private _setBackgroundState;
  75683. }
  75684. }
  75685. declare module BABYLON {
  75686. /**
  75687. * Options for the controller physics feature
  75688. */
  75689. export class IWebXRControllerPhysicsOptions {
  75690. /**
  75691. * Should the headset get its own impostor
  75692. */
  75693. enableHeadsetImpostor?: boolean;
  75694. /**
  75695. * Optional parameters for the headset impostor
  75696. */
  75697. headsetImpostorParams?: {
  75698. /**
  75699. * The type of impostor to create. Default is sphere
  75700. */
  75701. impostorType: number;
  75702. /**
  75703. * the size of the impostor. Defaults to 10cm
  75704. */
  75705. impostorSize?: number | {
  75706. width: number;
  75707. height: number;
  75708. depth: number;
  75709. };
  75710. /**
  75711. * Friction definitions
  75712. */
  75713. friction?: number;
  75714. /**
  75715. * Restitution
  75716. */
  75717. restitution?: number;
  75718. };
  75719. /**
  75720. * The physics properties of the future impostors
  75721. */
  75722. physicsProperties?: {
  75723. /**
  75724. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75725. * Note that this requires a physics engine that supports mesh impostors!
  75726. */
  75727. useControllerMesh?: boolean;
  75728. /**
  75729. * The type of impostor to create. Default is sphere
  75730. */
  75731. impostorType?: number;
  75732. /**
  75733. * the size of the impostor. Defaults to 10cm
  75734. */
  75735. impostorSize?: number | {
  75736. width: number;
  75737. height: number;
  75738. depth: number;
  75739. };
  75740. /**
  75741. * Friction definitions
  75742. */
  75743. friction?: number;
  75744. /**
  75745. * Restitution
  75746. */
  75747. restitution?: number;
  75748. };
  75749. /**
  75750. * the xr input to use with this pointer selection
  75751. */
  75752. xrInput: WebXRInput;
  75753. }
  75754. /**
  75755. * Add physics impostor to your webxr controllers,
  75756. * including naive calculation of their linear and angular velocity
  75757. */
  75758. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75759. private readonly _options;
  75760. private _attachController;
  75761. private _controllers;
  75762. private _debugMode;
  75763. private _delta;
  75764. private _headsetImpostor?;
  75765. private _headsetMesh?;
  75766. private _lastTimestamp;
  75767. private _tmpQuaternion;
  75768. private _tmpVector;
  75769. /**
  75770. * The module's name
  75771. */
  75772. static readonly Name: string;
  75773. /**
  75774. * The (Babylon) version of this module.
  75775. * This is an integer representing the implementation version.
  75776. * This number does not correspond to the webxr specs version
  75777. */
  75778. static readonly Version: number;
  75779. /**
  75780. * Construct a new Controller Physics Feature
  75781. * @param _xrSessionManager the corresponding xr session manager
  75782. * @param _options options to create this feature with
  75783. */
  75784. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75785. /**
  75786. * @hidden
  75787. * enable debugging - will show console outputs and the impostor mesh
  75788. */
  75789. _enablePhysicsDebug(): void;
  75790. /**
  75791. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75792. * @param xrController the controller to add
  75793. */
  75794. addController(xrController: WebXRInputSource): void;
  75795. /**
  75796. * attach this feature
  75797. * Will usually be called by the features manager
  75798. *
  75799. * @returns true if successful.
  75800. */
  75801. attach(): boolean;
  75802. /**
  75803. * detach this feature.
  75804. * Will usually be called by the features manager
  75805. *
  75806. * @returns true if successful.
  75807. */
  75808. detach(): boolean;
  75809. /**
  75810. * Get the headset impostor, if enabled
  75811. * @returns the impostor
  75812. */
  75813. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75814. /**
  75815. * Get the physics impostor of a specific controller.
  75816. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75817. * @param controller the controller or the controller id of which to get the impostor
  75818. * @returns the impostor or null
  75819. */
  75820. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75821. /**
  75822. * Update the physics properties provided in the constructor
  75823. * @param newProperties the new properties object
  75824. */
  75825. setPhysicsProperties(newProperties: {
  75826. impostorType?: number;
  75827. impostorSize?: number | {
  75828. width: number;
  75829. height: number;
  75830. depth: number;
  75831. };
  75832. friction?: number;
  75833. restitution?: number;
  75834. }): void;
  75835. protected _onXRFrame(_xrFrame: any): void;
  75836. private _detachController;
  75837. }
  75838. }
  75839. declare module BABYLON {
  75840. /**
  75841. * A babylon interface for a "WebXR" feature point.
  75842. * Represents the position and confidence value of a given feature point.
  75843. */
  75844. export interface IWebXRFeaturePoint {
  75845. /**
  75846. * Represents the position of the feature point in world space.
  75847. */
  75848. position: Vector3;
  75849. /**
  75850. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75851. */
  75852. confidenceValue: number;
  75853. }
  75854. /**
  75855. * The feature point system is used to detect feature points from real world geometry.
  75856. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75857. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75858. */
  75859. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75860. private _enabled;
  75861. private _featurePointCloud;
  75862. /**
  75863. * The module's name
  75864. */
  75865. static readonly Name: string;
  75866. /**
  75867. * The (Babylon) version of this module.
  75868. * This is an integer representing the implementation version.
  75869. * This number does not correspond to the WebXR specs version
  75870. */
  75871. static readonly Version: number;
  75872. /**
  75873. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75874. * Will notify the observers about which feature points have been added.
  75875. */
  75876. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75877. /**
  75878. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75879. * Will notify the observers about which feature points have been updated.
  75880. */
  75881. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75882. /**
  75883. * The current feature point cloud maintained across frames.
  75884. */
  75885. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75886. /**
  75887. * construct the feature point system
  75888. * @param _xrSessionManager an instance of xr Session manager
  75889. */
  75890. constructor(_xrSessionManager: WebXRSessionManager);
  75891. /**
  75892. * Detach this feature.
  75893. * Will usually be called by the features manager
  75894. *
  75895. * @returns true if successful.
  75896. */
  75897. detach(): boolean;
  75898. /**
  75899. * Dispose this feature and all of the resources attached
  75900. */
  75901. dispose(): void;
  75902. /**
  75903. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75904. */
  75905. protected _onXRFrame(frame: XRFrame): void;
  75906. /**
  75907. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75908. */
  75909. private _init;
  75910. }
  75911. }
  75912. declare module BABYLON {
  75913. /**
  75914. * Configuration interface for the hand tracking feature
  75915. */
  75916. export interface IWebXRHandTrackingOptions {
  75917. /**
  75918. * The xrInput that will be used as source for new hands
  75919. */
  75920. xrInput: WebXRInput;
  75921. /**
  75922. * Configuration object for the joint meshes
  75923. */
  75924. jointMeshes?: {
  75925. /**
  75926. * Should the meshes created be invisible (defaults to false)
  75927. */
  75928. invisible?: boolean;
  75929. /**
  75930. * A source mesh to be used to create instances. Defaults to a sphere.
  75931. * This mesh will be the source for all other (25) meshes.
  75932. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75933. */
  75934. sourceMesh?: Mesh;
  75935. /**
  75936. * This function will be called after a mesh was created for a specific joint.
  75937. * Using this function you can either manipulate the instance or return a new mesh.
  75938. * When returning a new mesh the instance created before will be disposed
  75939. */
  75940. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  75941. /**
  75942. * Should the source mesh stay visible. Defaults to false
  75943. */
  75944. keepOriginalVisible?: boolean;
  75945. /**
  75946. * Scale factor for all instances (defaults to 2)
  75947. */
  75948. scaleFactor?: number;
  75949. /**
  75950. * Should each instance have its own physics impostor
  75951. */
  75952. enablePhysics?: boolean;
  75953. /**
  75954. * If enabled, override default physics properties
  75955. */
  75956. physicsProps?: {
  75957. friction?: number;
  75958. restitution?: number;
  75959. impostorType?: number;
  75960. };
  75961. /**
  75962. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  75963. */
  75964. handMesh?: AbstractMesh;
  75965. };
  75966. }
  75967. /**
  75968. * Parts of the hands divided to writs and finger names
  75969. */
  75970. export const enum HandPart {
  75971. /**
  75972. * HandPart - Wrist
  75973. */
  75974. WRIST = "wrist",
  75975. /**
  75976. * HandPart - The THumb
  75977. */
  75978. THUMB = "thumb",
  75979. /**
  75980. * HandPart - Index finger
  75981. */
  75982. INDEX = "index",
  75983. /**
  75984. * HandPart - Middle finger
  75985. */
  75986. MIDDLE = "middle",
  75987. /**
  75988. * HandPart - Ring finger
  75989. */
  75990. RING = "ring",
  75991. /**
  75992. * HandPart - Little finger
  75993. */
  75994. LITTLE = "little"
  75995. }
  75996. /**
  75997. * Representing a single hand (with its corresponding native XRHand object)
  75998. */
  75999. export class WebXRHand implements IDisposable {
  76000. /** the controller to which the hand correlates */
  76001. readonly xrController: WebXRInputSource;
  76002. /** the meshes to be used to track the hand joints */
  76003. readonly trackedMeshes: AbstractMesh[];
  76004. /**
  76005. * Hand-parts definition (key is HandPart)
  76006. */
  76007. handPartsDefinition: {
  76008. [key: string]: number[];
  76009. };
  76010. /**
  76011. * Populate the HandPartsDefinition object.
  76012. * This is called as a side effect since certain browsers don't have XRHand defined.
  76013. */
  76014. private generateHandPartsDefinition;
  76015. /**
  76016. * Construct a new hand object
  76017. * @param xrController the controller to which the hand correlates
  76018. * @param trackedMeshes the meshes to be used to track the hand joints
  76019. */
  76020. constructor(
  76021. /** the controller to which the hand correlates */
  76022. xrController: WebXRInputSource,
  76023. /** the meshes to be used to track the hand joints */
  76024. trackedMeshes: AbstractMesh[]);
  76025. /**
  76026. * Update this hand from the latest xr frame
  76027. * @param xrFrame xrFrame to update from
  76028. * @param referenceSpace The current viewer reference space
  76029. * @param scaleFactor optional scale factor for the meshes
  76030. */
  76031. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76032. /**
  76033. * Get meshes of part of the hand
  76034. * @param part the part of hand to get
  76035. * @returns An array of meshes that correlate to the hand part requested
  76036. */
  76037. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76038. /**
  76039. * Dispose this Hand object
  76040. */
  76041. dispose(): void;
  76042. }
  76043. /**
  76044. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76045. */
  76046. export class WebXRHandTracking extends WebXRAbstractFeature {
  76047. /**
  76048. * options to use when constructing this feature
  76049. */
  76050. readonly options: IWebXRHandTrackingOptions;
  76051. private static _idCounter;
  76052. /**
  76053. * The module's name
  76054. */
  76055. static readonly Name: string;
  76056. /**
  76057. * The (Babylon) version of this module.
  76058. * This is an integer representing the implementation version.
  76059. * This number does not correspond to the WebXR specs version
  76060. */
  76061. static readonly Version: number;
  76062. /**
  76063. * This observable will notify registered observers when a new hand object was added and initialized
  76064. */
  76065. onHandAddedObservable: Observable<WebXRHand>;
  76066. /**
  76067. * This observable will notify its observers right before the hand object is disposed
  76068. */
  76069. onHandRemovedObservable: Observable<WebXRHand>;
  76070. private _hands;
  76071. /**
  76072. * Creates a new instance of the hit test feature
  76073. * @param _xrSessionManager an instance of WebXRSessionManager
  76074. * @param options options to use when constructing this feature
  76075. */
  76076. constructor(_xrSessionManager: WebXRSessionManager,
  76077. /**
  76078. * options to use when constructing this feature
  76079. */
  76080. options: IWebXRHandTrackingOptions);
  76081. /**
  76082. * Check if the needed objects are defined.
  76083. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76084. */
  76085. isCompatible(): boolean;
  76086. /**
  76087. * attach this feature
  76088. * Will usually be called by the features manager
  76089. *
  76090. * @returns true if successful.
  76091. */
  76092. attach(): boolean;
  76093. /**
  76094. * detach this feature.
  76095. * Will usually be called by the features manager
  76096. *
  76097. * @returns true if successful.
  76098. */
  76099. detach(): boolean;
  76100. /**
  76101. * Dispose this feature and all of the resources attached
  76102. */
  76103. dispose(): void;
  76104. /**
  76105. * Get the hand object according to the controller id
  76106. * @param controllerId the controller id to which we want to get the hand
  76107. * @returns null if not found or the WebXRHand object if found
  76108. */
  76109. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76110. /**
  76111. * Get a hand object according to the requested handedness
  76112. * @param handedness the handedness to request
  76113. * @returns null if not found or the WebXRHand object if found
  76114. */
  76115. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76116. protected _onXRFrame(_xrFrame: XRFrame): void;
  76117. private _attachHand;
  76118. private _detachHand;
  76119. }
  76120. }
  76121. declare module BABYLON {
  76122. /**
  76123. * The motion controller class for all microsoft mixed reality controllers
  76124. */
  76125. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76126. protected readonly _mapping: {
  76127. defaultButton: {
  76128. valueNodeName: string;
  76129. unpressedNodeName: string;
  76130. pressedNodeName: string;
  76131. };
  76132. defaultAxis: {
  76133. valueNodeName: string;
  76134. minNodeName: string;
  76135. maxNodeName: string;
  76136. };
  76137. buttons: {
  76138. "xr-standard-trigger": {
  76139. rootNodeName: string;
  76140. componentProperty: string;
  76141. states: string[];
  76142. };
  76143. "xr-standard-squeeze": {
  76144. rootNodeName: string;
  76145. componentProperty: string;
  76146. states: string[];
  76147. };
  76148. "xr-standard-touchpad": {
  76149. rootNodeName: string;
  76150. labelAnchorNodeName: string;
  76151. touchPointNodeName: string;
  76152. };
  76153. "xr-standard-thumbstick": {
  76154. rootNodeName: string;
  76155. componentProperty: string;
  76156. states: string[];
  76157. };
  76158. };
  76159. axes: {
  76160. "xr-standard-touchpad": {
  76161. "x-axis": {
  76162. rootNodeName: string;
  76163. };
  76164. "y-axis": {
  76165. rootNodeName: string;
  76166. };
  76167. };
  76168. "xr-standard-thumbstick": {
  76169. "x-axis": {
  76170. rootNodeName: string;
  76171. };
  76172. "y-axis": {
  76173. rootNodeName: string;
  76174. };
  76175. };
  76176. };
  76177. };
  76178. /**
  76179. * The base url used to load the left and right controller models
  76180. */
  76181. static MODEL_BASE_URL: string;
  76182. /**
  76183. * The name of the left controller model file
  76184. */
  76185. static MODEL_LEFT_FILENAME: string;
  76186. /**
  76187. * The name of the right controller model file
  76188. */
  76189. static MODEL_RIGHT_FILENAME: string;
  76190. profileId: string;
  76191. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76192. protected _getFilenameAndPath(): {
  76193. filename: string;
  76194. path: string;
  76195. };
  76196. protected _getModelLoadingConstraints(): boolean;
  76197. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76198. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76199. protected _updateModel(): void;
  76200. }
  76201. }
  76202. declare module BABYLON {
  76203. /**
  76204. * The motion controller class for oculus touch (quest, rift).
  76205. * This class supports legacy mapping as well the standard xr mapping
  76206. */
  76207. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76208. private _forceLegacyControllers;
  76209. private _modelRootNode;
  76210. /**
  76211. * The base url used to load the left and right controller models
  76212. */
  76213. static MODEL_BASE_URL: string;
  76214. /**
  76215. * The name of the left controller model file
  76216. */
  76217. static MODEL_LEFT_FILENAME: string;
  76218. /**
  76219. * The name of the right controller model file
  76220. */
  76221. static MODEL_RIGHT_FILENAME: string;
  76222. /**
  76223. * Base Url for the Quest controller model.
  76224. */
  76225. static QUEST_MODEL_BASE_URL: string;
  76226. profileId: string;
  76227. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76228. protected _getFilenameAndPath(): {
  76229. filename: string;
  76230. path: string;
  76231. };
  76232. protected _getModelLoadingConstraints(): boolean;
  76233. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76234. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76235. protected _updateModel(): void;
  76236. /**
  76237. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76238. * between the touch and touch 2.
  76239. */
  76240. private _isQuest;
  76241. }
  76242. }
  76243. declare module BABYLON {
  76244. /**
  76245. * The motion controller class for the standard HTC-Vive controllers
  76246. */
  76247. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76248. private _modelRootNode;
  76249. /**
  76250. * The base url used to load the left and right controller models
  76251. */
  76252. static MODEL_BASE_URL: string;
  76253. /**
  76254. * File name for the controller model.
  76255. */
  76256. static MODEL_FILENAME: string;
  76257. profileId: string;
  76258. /**
  76259. * Create a new Vive motion controller object
  76260. * @param scene the scene to use to create this controller
  76261. * @param gamepadObject the corresponding gamepad object
  76262. * @param handedness the handedness of the controller
  76263. */
  76264. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76265. protected _getFilenameAndPath(): {
  76266. filename: string;
  76267. path: string;
  76268. };
  76269. protected _getModelLoadingConstraints(): boolean;
  76270. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76271. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76272. protected _updateModel(): void;
  76273. }
  76274. }
  76275. declare module BABYLON {
  76276. /**
  76277. * A cursor which tracks a point on a path
  76278. */
  76279. export class PathCursor {
  76280. private path;
  76281. /**
  76282. * Stores path cursor callbacks for when an onchange event is triggered
  76283. */
  76284. private _onchange;
  76285. /**
  76286. * The value of the path cursor
  76287. */
  76288. value: number;
  76289. /**
  76290. * The animation array of the path cursor
  76291. */
  76292. animations: Animation[];
  76293. /**
  76294. * Initializes the path cursor
  76295. * @param path The path to track
  76296. */
  76297. constructor(path: Path2);
  76298. /**
  76299. * Gets the cursor point on the path
  76300. * @returns A point on the path cursor at the cursor location
  76301. */
  76302. getPoint(): Vector3;
  76303. /**
  76304. * Moves the cursor ahead by the step amount
  76305. * @param step The amount to move the cursor forward
  76306. * @returns This path cursor
  76307. */
  76308. moveAhead(step?: number): PathCursor;
  76309. /**
  76310. * Moves the cursor behind by the step amount
  76311. * @param step The amount to move the cursor back
  76312. * @returns This path cursor
  76313. */
  76314. moveBack(step?: number): PathCursor;
  76315. /**
  76316. * Moves the cursor by the step amount
  76317. * If the step amount is greater than one, an exception is thrown
  76318. * @param step The amount to move the cursor
  76319. * @returns This path cursor
  76320. */
  76321. move(step: number): PathCursor;
  76322. /**
  76323. * Ensures that the value is limited between zero and one
  76324. * @returns This path cursor
  76325. */
  76326. private ensureLimits;
  76327. /**
  76328. * Runs onchange callbacks on change (used by the animation engine)
  76329. * @returns This path cursor
  76330. */
  76331. private raiseOnChange;
  76332. /**
  76333. * Executes a function on change
  76334. * @param f A path cursor onchange callback
  76335. * @returns This path cursor
  76336. */
  76337. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76338. }
  76339. }
  76340. declare module BABYLON {
  76341. /** @hidden */
  76342. export var blurPixelShader: {
  76343. name: string;
  76344. shader: string;
  76345. };
  76346. }
  76347. declare module BABYLON {
  76348. /** @hidden */
  76349. export var pointCloudVertexDeclaration: {
  76350. name: string;
  76351. shader: string;
  76352. };
  76353. }
  76354. // Mixins
  76355. interface Window {
  76356. mozIndexedDB: IDBFactory;
  76357. webkitIndexedDB: IDBFactory;
  76358. msIndexedDB: IDBFactory;
  76359. webkitURL: typeof URL;
  76360. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76361. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76362. WebGLRenderingContext: WebGLRenderingContext;
  76363. MSGesture: MSGesture;
  76364. CANNON: any;
  76365. AudioContext: AudioContext;
  76366. webkitAudioContext: AudioContext;
  76367. PointerEvent: any;
  76368. Math: Math;
  76369. Uint8Array: Uint8ArrayConstructor;
  76370. Float32Array: Float32ArrayConstructor;
  76371. mozURL: typeof URL;
  76372. msURL: typeof URL;
  76373. VRFrameData: any; // WebVR, from specs 1.1
  76374. DracoDecoderModule: any;
  76375. setImmediate(handler: (...args: any[]) => void): number;
  76376. }
  76377. interface HTMLCanvasElement {
  76378. requestPointerLock(): void;
  76379. msRequestPointerLock?(): void;
  76380. mozRequestPointerLock?(): void;
  76381. webkitRequestPointerLock?(): void;
  76382. /** Track wether a record is in progress */
  76383. isRecording: boolean;
  76384. /** Capture Stream method defined by some browsers */
  76385. captureStream(fps?: number): MediaStream;
  76386. }
  76387. interface CanvasRenderingContext2D {
  76388. msImageSmoothingEnabled: boolean;
  76389. }
  76390. interface MouseEvent {
  76391. mozMovementX: number;
  76392. mozMovementY: number;
  76393. webkitMovementX: number;
  76394. webkitMovementY: number;
  76395. msMovementX: number;
  76396. msMovementY: number;
  76397. }
  76398. interface Navigator {
  76399. mozGetVRDevices: (any: any) => any;
  76400. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76401. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76402. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76403. webkitGetGamepads(): Gamepad[];
  76404. msGetGamepads(): Gamepad[];
  76405. webkitGamepads(): Gamepad[];
  76406. }
  76407. interface HTMLVideoElement {
  76408. mozSrcObject: any;
  76409. }
  76410. interface Math {
  76411. fround(x: number): number;
  76412. imul(a: number, b: number): number;
  76413. }
  76414. interface WebGLRenderingContext {
  76415. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76416. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76417. vertexAttribDivisor(index: number, divisor: number): void;
  76418. createVertexArray(): any;
  76419. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76420. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76421. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76422. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76423. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76424. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76425. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76426. // Queries
  76427. createQuery(): WebGLQuery;
  76428. deleteQuery(query: WebGLQuery): void;
  76429. beginQuery(target: number, query: WebGLQuery): void;
  76430. endQuery(target: number): void;
  76431. getQueryParameter(query: WebGLQuery, pname: number): any;
  76432. getQuery(target: number, pname: number): any;
  76433. MAX_SAMPLES: number;
  76434. RGBA8: number;
  76435. READ_FRAMEBUFFER: number;
  76436. DRAW_FRAMEBUFFER: number;
  76437. UNIFORM_BUFFER: number;
  76438. HALF_FLOAT_OES: number;
  76439. RGBA16F: number;
  76440. RGBA32F: number;
  76441. R32F: number;
  76442. RG32F: number;
  76443. RGB32F: number;
  76444. R16F: number;
  76445. RG16F: number;
  76446. RGB16F: number;
  76447. RED: number;
  76448. RG: number;
  76449. R8: number;
  76450. RG8: number;
  76451. UNSIGNED_INT_24_8: number;
  76452. DEPTH24_STENCIL8: number;
  76453. MIN: number;
  76454. MAX: number;
  76455. /* Multiple Render Targets */
  76456. drawBuffers(buffers: number[]): void;
  76457. readBuffer(src: number): void;
  76458. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76459. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76460. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76461. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76462. // Occlusion Query
  76463. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76464. ANY_SAMPLES_PASSED: number;
  76465. QUERY_RESULT_AVAILABLE: number;
  76466. QUERY_RESULT: number;
  76467. }
  76468. interface WebGLProgram {
  76469. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76470. }
  76471. interface EXT_disjoint_timer_query {
  76472. QUERY_COUNTER_BITS_EXT: number;
  76473. TIME_ELAPSED_EXT: number;
  76474. TIMESTAMP_EXT: number;
  76475. GPU_DISJOINT_EXT: number;
  76476. QUERY_RESULT_EXT: number;
  76477. QUERY_RESULT_AVAILABLE_EXT: number;
  76478. queryCounterEXT(query: WebGLQuery, target: number): void;
  76479. createQueryEXT(): WebGLQuery;
  76480. beginQueryEXT(target: number, query: WebGLQuery): void;
  76481. endQueryEXT(target: number): void;
  76482. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76483. deleteQueryEXT(query: WebGLQuery): void;
  76484. }
  76485. interface WebGLUniformLocation {
  76486. _currentState: any;
  76487. }
  76488. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76489. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76490. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76491. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76492. interface WebGLRenderingContext {
  76493. readonly RASTERIZER_DISCARD: number;
  76494. readonly DEPTH_COMPONENT24: number;
  76495. readonly TEXTURE_3D: number;
  76496. readonly TEXTURE_2D_ARRAY: number;
  76497. readonly TEXTURE_COMPARE_FUNC: number;
  76498. readonly TEXTURE_COMPARE_MODE: number;
  76499. readonly COMPARE_REF_TO_TEXTURE: number;
  76500. readonly TEXTURE_WRAP_R: number;
  76501. readonly HALF_FLOAT: number;
  76502. readonly RGB8: number;
  76503. readonly RED_INTEGER: number;
  76504. readonly RG_INTEGER: number;
  76505. readonly RGB_INTEGER: number;
  76506. readonly RGBA_INTEGER: number;
  76507. readonly R8_SNORM: number;
  76508. readonly RG8_SNORM: number;
  76509. readonly RGB8_SNORM: number;
  76510. readonly RGBA8_SNORM: number;
  76511. readonly R8I: number;
  76512. readonly RG8I: number;
  76513. readonly RGB8I: number;
  76514. readonly RGBA8I: number;
  76515. readonly R8UI: number;
  76516. readonly RG8UI: number;
  76517. readonly RGB8UI: number;
  76518. readonly RGBA8UI: number;
  76519. readonly R16I: number;
  76520. readonly RG16I: number;
  76521. readonly RGB16I: number;
  76522. readonly RGBA16I: number;
  76523. readonly R16UI: number;
  76524. readonly RG16UI: number;
  76525. readonly RGB16UI: number;
  76526. readonly RGBA16UI: number;
  76527. readonly R32I: number;
  76528. readonly RG32I: number;
  76529. readonly RGB32I: number;
  76530. readonly RGBA32I: number;
  76531. readonly R32UI: number;
  76532. readonly RG32UI: number;
  76533. readonly RGB32UI: number;
  76534. readonly RGBA32UI: number;
  76535. readonly RGB10_A2UI: number;
  76536. readonly R11F_G11F_B10F: number;
  76537. readonly RGB9_E5: number;
  76538. readonly RGB10_A2: number;
  76539. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76540. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76541. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76542. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76543. readonly DEPTH_COMPONENT32F: number;
  76544. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76545. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76546. 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;
  76547. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76548. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76549. readonly TRANSFORM_FEEDBACK: number;
  76550. readonly INTERLEAVED_ATTRIBS: number;
  76551. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76552. createTransformFeedback(): WebGLTransformFeedback;
  76553. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76554. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76555. beginTransformFeedback(primitiveMode: number): void;
  76556. endTransformFeedback(): void;
  76557. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76558. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76559. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76560. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76561. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  76562. }
  76563. interface ImageBitmap {
  76564. readonly width: number;
  76565. readonly height: number;
  76566. close(): void;
  76567. }
  76568. interface WebGLQuery extends WebGLObject {
  76569. }
  76570. declare var WebGLQuery: {
  76571. prototype: WebGLQuery;
  76572. new(): WebGLQuery;
  76573. };
  76574. interface WebGLSampler extends WebGLObject {
  76575. }
  76576. declare var WebGLSampler: {
  76577. prototype: WebGLSampler;
  76578. new(): WebGLSampler;
  76579. };
  76580. interface WebGLSync extends WebGLObject {
  76581. }
  76582. declare var WebGLSync: {
  76583. prototype: WebGLSync;
  76584. new(): WebGLSync;
  76585. };
  76586. interface WebGLTransformFeedback extends WebGLObject {
  76587. }
  76588. declare var WebGLTransformFeedback: {
  76589. prototype: WebGLTransformFeedback;
  76590. new(): WebGLTransformFeedback;
  76591. };
  76592. interface WebGLVertexArrayObject extends WebGLObject {
  76593. }
  76594. declare var WebGLVertexArrayObject: {
  76595. prototype: WebGLVertexArrayObject;
  76596. new(): WebGLVertexArrayObject;
  76597. };
  76598. // Type definitions for WebVR API
  76599. // Project: https://w3c.github.io/webvr/
  76600. // Definitions by: six a <https://github.com/lostfictions>
  76601. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76602. interface VRDisplay extends EventTarget {
  76603. /**
  76604. * Dictionary of capabilities describing the VRDisplay.
  76605. */
  76606. readonly capabilities: VRDisplayCapabilities;
  76607. /**
  76608. * z-depth defining the far plane of the eye view frustum
  76609. * enables mapping of values in the render target depth
  76610. * attachment to scene coordinates. Initially set to 10000.0.
  76611. */
  76612. depthFar: number;
  76613. /**
  76614. * z-depth defining the near plane of the eye view frustum
  76615. * enables mapping of values in the render target depth
  76616. * attachment to scene coordinates. Initially set to 0.01.
  76617. */
  76618. depthNear: number;
  76619. /**
  76620. * An identifier for this distinct VRDisplay. Used as an
  76621. * association point in the Gamepad API.
  76622. */
  76623. readonly displayId: number;
  76624. /**
  76625. * A display name, a user-readable name identifying it.
  76626. */
  76627. readonly displayName: string;
  76628. readonly isConnected: boolean;
  76629. readonly isPresenting: boolean;
  76630. /**
  76631. * If this VRDisplay supports room-scale experiences, the optional
  76632. * stage attribute contains details on the room-scale parameters.
  76633. */
  76634. readonly stageParameters: VRStageParameters | null;
  76635. /**
  76636. * Passing the value returned by `requestAnimationFrame` to
  76637. * `cancelAnimationFrame` will unregister the callback.
  76638. * @param handle Define the hanle of the request to cancel
  76639. */
  76640. cancelAnimationFrame(handle: number): void;
  76641. /**
  76642. * Stops presenting to the VRDisplay.
  76643. * @returns a promise to know when it stopped
  76644. */
  76645. exitPresent(): Promise<void>;
  76646. /**
  76647. * Return the current VREyeParameters for the given eye.
  76648. * @param whichEye Define the eye we want the parameter for
  76649. * @returns the eye parameters
  76650. */
  76651. getEyeParameters(whichEye: string): VREyeParameters;
  76652. /**
  76653. * Populates the passed VRFrameData with the information required to render
  76654. * the current frame.
  76655. * @param frameData Define the data structure to populate
  76656. * @returns true if ok otherwise false
  76657. */
  76658. getFrameData(frameData: VRFrameData): boolean;
  76659. /**
  76660. * Get the layers currently being presented.
  76661. * @returns the list of VR layers
  76662. */
  76663. getLayers(): VRLayer[];
  76664. /**
  76665. * Return a VRPose containing the future predicted pose of the VRDisplay
  76666. * when the current frame will be presented. The value returned will not
  76667. * change until JavaScript has returned control to the browser.
  76668. *
  76669. * The VRPose will contain the position, orientation, velocity,
  76670. * and acceleration of each of these properties.
  76671. * @returns the pose object
  76672. */
  76673. getPose(): VRPose;
  76674. /**
  76675. * Return the current instantaneous pose of the VRDisplay, with no
  76676. * prediction applied.
  76677. * @returns the current instantaneous pose
  76678. */
  76679. getImmediatePose(): VRPose;
  76680. /**
  76681. * The callback passed to `requestAnimationFrame` will be called
  76682. * any time a new frame should be rendered. When the VRDisplay is
  76683. * presenting the callback will be called at the native refresh
  76684. * rate of the HMD. When not presenting this function acts
  76685. * identically to how window.requestAnimationFrame acts. Content should
  76686. * make no assumptions of frame rate or vsync behavior as the HMD runs
  76687. * asynchronously from other displays and at differing refresh rates.
  76688. * @param callback Define the eaction to run next frame
  76689. * @returns the request handle it
  76690. */
  76691. requestAnimationFrame(callback: FrameRequestCallback): number;
  76692. /**
  76693. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  76694. * Repeat calls while already presenting will update the VRLayers being displayed.
  76695. * @param layers Define the list of layer to present
  76696. * @returns a promise to know when the request has been fulfilled
  76697. */
  76698. requestPresent(layers: VRLayer[]): Promise<void>;
  76699. /**
  76700. * Reset the pose for this display, treating its current position and
  76701. * orientation as the "origin/zero" values. VRPose.position,
  76702. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  76703. * updated when calling resetPose(). This should be called in only
  76704. * sitting-space experiences.
  76705. */
  76706. resetPose(): void;
  76707. /**
  76708. * The VRLayer provided to the VRDisplay will be captured and presented
  76709. * in the HMD. Calling this function has the same effect on the source
  76710. * canvas as any other operation that uses its source image, and canvases
  76711. * created without preserveDrawingBuffer set to true will be cleared.
  76712. * @param pose Define the pose to submit
  76713. */
  76714. submitFrame(pose?: VRPose): void;
  76715. }
  76716. declare var VRDisplay: {
  76717. prototype: VRDisplay;
  76718. new(): VRDisplay;
  76719. };
  76720. interface VRLayer {
  76721. leftBounds?: number[] | Float32Array | null;
  76722. rightBounds?: number[] | Float32Array | null;
  76723. source?: HTMLCanvasElement | null;
  76724. }
  76725. interface VRDisplayCapabilities {
  76726. readonly canPresent: boolean;
  76727. readonly hasExternalDisplay: boolean;
  76728. readonly hasOrientation: boolean;
  76729. readonly hasPosition: boolean;
  76730. readonly maxLayers: number;
  76731. }
  76732. interface VREyeParameters {
  76733. /** @deprecated */
  76734. readonly fieldOfView: VRFieldOfView;
  76735. readonly offset: Float32Array;
  76736. readonly renderHeight: number;
  76737. readonly renderWidth: number;
  76738. }
  76739. interface VRFieldOfView {
  76740. readonly downDegrees: number;
  76741. readonly leftDegrees: number;
  76742. readonly rightDegrees: number;
  76743. readonly upDegrees: number;
  76744. }
  76745. interface VRFrameData {
  76746. readonly leftProjectionMatrix: Float32Array;
  76747. readonly leftViewMatrix: Float32Array;
  76748. readonly pose: VRPose;
  76749. readonly rightProjectionMatrix: Float32Array;
  76750. readonly rightViewMatrix: Float32Array;
  76751. readonly timestamp: number;
  76752. }
  76753. interface VRPose {
  76754. readonly angularAcceleration: Float32Array | null;
  76755. readonly angularVelocity: Float32Array | null;
  76756. readonly linearAcceleration: Float32Array | null;
  76757. readonly linearVelocity: Float32Array | null;
  76758. readonly orientation: Float32Array | null;
  76759. readonly position: Float32Array | null;
  76760. readonly timestamp: number;
  76761. }
  76762. interface VRStageParameters {
  76763. sittingToStandingTransform?: Float32Array;
  76764. sizeX?: number;
  76765. sizeY?: number;
  76766. }
  76767. interface Navigator {
  76768. getVRDisplays(): Promise<VRDisplay[]>;
  76769. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  76770. }
  76771. interface Window {
  76772. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  76773. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  76774. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  76775. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76776. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76777. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  76778. }
  76779. interface Gamepad {
  76780. readonly displayId: number;
  76781. }
  76782. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  76783. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  76784. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  76785. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  76786. type XRHandedness = "none" | "left" | "right";
  76787. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  76788. type XREye = "none" | "left" | "right";
  76789. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  76790. interface XRSpace extends EventTarget {}
  76791. interface XRRenderState {
  76792. depthNear?: number;
  76793. depthFar?: number;
  76794. inlineVerticalFieldOfView?: number;
  76795. baseLayer?: XRWebGLLayer;
  76796. }
  76797. interface XRInputSource {
  76798. handedness: XRHandedness;
  76799. targetRayMode: XRTargetRayMode;
  76800. targetRaySpace: XRSpace;
  76801. gripSpace: XRSpace | undefined;
  76802. gamepad: Gamepad | undefined;
  76803. profiles: Array<string>;
  76804. hand: XRHand | undefined;
  76805. }
  76806. interface XRSessionInit {
  76807. optionalFeatures?: string[];
  76808. requiredFeatures?: string[];
  76809. }
  76810. interface XRSession {
  76811. addEventListener: Function;
  76812. removeEventListener: Function;
  76813. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76814. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76815. requestAnimationFrame: Function;
  76816. end(): Promise<void>;
  76817. renderState: XRRenderState;
  76818. inputSources: Array<XRInputSource>;
  76819. // hit test
  76820. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76821. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76822. // legacy AR hit test
  76823. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76824. // legacy plane detection
  76825. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76826. }
  76827. interface XRReferenceSpace extends XRSpace {
  76828. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76829. onreset: any;
  76830. }
  76831. type XRPlaneSet = Set<XRPlane>;
  76832. type XRAnchorSet = Set<XRAnchor>;
  76833. interface XRFrame {
  76834. session: XRSession;
  76835. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76836. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76837. // AR
  76838. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76839. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76840. // Anchors
  76841. trackedAnchors?: XRAnchorSet;
  76842. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76843. // Planes
  76844. worldInformation: {
  76845. detectedPlanes?: XRPlaneSet;
  76846. };
  76847. // Hand tracking
  76848. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76849. }
  76850. interface XRViewerPose extends XRPose {
  76851. views: Array<XRView>;
  76852. }
  76853. interface XRPose {
  76854. transform: XRRigidTransform;
  76855. emulatedPosition: boolean;
  76856. }
  76857. interface XRWebGLLayerOptions {
  76858. antialias?: boolean;
  76859. depth?: boolean;
  76860. stencil?: boolean;
  76861. alpha?: boolean;
  76862. multiview?: boolean;
  76863. framebufferScaleFactor?: number;
  76864. }
  76865. declare var XRWebGLLayer: {
  76866. prototype: XRWebGLLayer;
  76867. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76868. };
  76869. interface XRWebGLLayer {
  76870. framebuffer: WebGLFramebuffer;
  76871. framebufferWidth: number;
  76872. framebufferHeight: number;
  76873. getViewport: Function;
  76874. }
  76875. declare class XRRigidTransform {
  76876. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76877. position: DOMPointReadOnly;
  76878. orientation: DOMPointReadOnly;
  76879. matrix: Float32Array;
  76880. inverse: XRRigidTransform;
  76881. }
  76882. interface XRView {
  76883. eye: XREye;
  76884. projectionMatrix: Float32Array;
  76885. transform: XRRigidTransform;
  76886. }
  76887. interface XRInputSourceChangeEvent {
  76888. session: XRSession;
  76889. removed: Array<XRInputSource>;
  76890. added: Array<XRInputSource>;
  76891. }
  76892. interface XRInputSourceEvent extends Event {
  76893. readonly frame: XRFrame;
  76894. readonly inputSource: XRInputSource;
  76895. }
  76896. // Experimental(er) features
  76897. declare class XRRay {
  76898. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76899. origin: DOMPointReadOnly;
  76900. direction: DOMPointReadOnly;
  76901. matrix: Float32Array;
  76902. }
  76903. declare enum XRHitTestTrackableType {
  76904. "point",
  76905. "plane",
  76906. "mesh",
  76907. }
  76908. interface XRHitResult {
  76909. hitMatrix: Float32Array;
  76910. }
  76911. interface XRTransientInputHitTestResult {
  76912. readonly inputSource: XRInputSource;
  76913. readonly results: Array<XRHitTestResult>;
  76914. }
  76915. interface XRHitTestResult {
  76916. getPose(baseSpace: XRSpace): XRPose | undefined;
  76917. // When anchor system is enabled
  76918. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76919. }
  76920. interface XRHitTestSource {
  76921. cancel(): void;
  76922. }
  76923. interface XRTransientInputHitTestSource {
  76924. cancel(): void;
  76925. }
  76926. interface XRHitTestOptionsInit {
  76927. space: XRSpace;
  76928. entityTypes?: Array<XRHitTestTrackableType>;
  76929. offsetRay?: XRRay;
  76930. }
  76931. interface XRTransientInputHitTestOptionsInit {
  76932. profile: string;
  76933. entityTypes?: Array<XRHitTestTrackableType>;
  76934. offsetRay?: XRRay;
  76935. }
  76936. interface XRAnchor {
  76937. anchorSpace: XRSpace;
  76938. delete(): void;
  76939. }
  76940. interface XRPlane {
  76941. orientation: "Horizontal" | "Vertical";
  76942. planeSpace: XRSpace;
  76943. polygon: Array<DOMPointReadOnly>;
  76944. lastChangedTime: number;
  76945. }
  76946. interface XRJointSpace extends XRSpace {}
  76947. interface XRJointPose extends XRPose {
  76948. radius: number | undefined;
  76949. }
  76950. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  76951. readonly length: number;
  76952. [index: number]: XRJointSpace;
  76953. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  76954. readonly WRIST: number;
  76955. readonly THUMB_METACARPAL: number;
  76956. readonly THUMB_PHALANX_PROXIMAL: number;
  76957. readonly THUMB_PHALANX_DISTAL: number;
  76958. readonly THUMB_PHALANX_TIP: number;
  76959. readonly INDEX_METACARPAL: number;
  76960. readonly INDEX_PHALANX_PROXIMAL: number;
  76961. readonly INDEX_PHALANX_INTERMEDIATE: number;
  76962. readonly INDEX_PHALANX_DISTAL: number;
  76963. readonly INDEX_PHALANX_TIP: number;
  76964. readonly MIDDLE_METACARPAL: number;
  76965. readonly MIDDLE_PHALANX_PROXIMAL: number;
  76966. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  76967. readonly MIDDLE_PHALANX_DISTAL: number;
  76968. readonly MIDDLE_PHALANX_TIP: number;
  76969. readonly RING_METACARPAL: number;
  76970. readonly RING_PHALANX_PROXIMAL: number;
  76971. readonly RING_PHALANX_INTERMEDIATE: number;
  76972. readonly RING_PHALANX_DISTAL: number;
  76973. readonly RING_PHALANX_TIP: number;
  76974. readonly LITTLE_METACARPAL: number;
  76975. readonly LITTLE_PHALANX_PROXIMAL: number;
  76976. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  76977. readonly LITTLE_PHALANX_DISTAL: number;
  76978. readonly LITTLE_PHALANX_TIP: number;
  76979. }
  76980. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  76981. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  76982. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  76983. interface XRSession {
  76984. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  76985. }
  76986. interface XRFrame {
  76987. featurePointCloud? : Array<number>;
  76988. }
  76989. /**
  76990. * @ignore
  76991. */
  76992. declare module BABYLON.GLTF2.Exporter {
  76993. }
  76994. /**
  76995. * @ignore
  76996. */
  76997. declare module BABYLON.GLTF1 {
  76998. }
  76999. declare module BABYLON.GUI {
  77000. /**
  77001. * Class used to specific a value and its associated unit
  77002. */
  77003. export class ValueAndUnit {
  77004. /** defines the unit to store */
  77005. unit: number;
  77006. /** defines a boolean indicating if the value can be negative */
  77007. negativeValueAllowed: boolean;
  77008. private _value;
  77009. private _originalUnit;
  77010. /**
  77011. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77012. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77013. */
  77014. ignoreAdaptiveScaling: boolean;
  77015. /**
  77016. * Creates a new ValueAndUnit
  77017. * @param value defines the value to store
  77018. * @param unit defines the unit to store
  77019. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77020. */
  77021. constructor(value: number,
  77022. /** defines the unit to store */
  77023. unit?: number,
  77024. /** defines a boolean indicating if the value can be negative */
  77025. negativeValueAllowed?: boolean);
  77026. /** Gets a boolean indicating if the value is a percentage */
  77027. get isPercentage(): boolean;
  77028. /** Gets a boolean indicating if the value is store as pixel */
  77029. get isPixel(): boolean;
  77030. /** Gets direct internal value */
  77031. get internalValue(): number;
  77032. /**
  77033. * Gets value as pixel
  77034. * @param host defines the root host
  77035. * @param refValue defines the reference value for percentages
  77036. * @returns the value as pixel
  77037. */
  77038. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77039. /**
  77040. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77041. * @param value defines the value to store
  77042. * @param unit defines the unit to store
  77043. * @returns the current ValueAndUnit
  77044. */
  77045. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77046. /**
  77047. * Gets the value accordingly to its unit
  77048. * @param host defines the root host
  77049. * @returns the value
  77050. */
  77051. getValue(host: AdvancedDynamicTexture): number;
  77052. /**
  77053. * Gets a string representation of the value
  77054. * @param host defines the root host
  77055. * @param decimals defines an optional number of decimals to display
  77056. * @returns a string
  77057. */
  77058. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77059. /**
  77060. * Store a value parsed from a string
  77061. * @param source defines the source string
  77062. * @returns true if the value was successfully parsed
  77063. */
  77064. fromString(source: string | number): boolean;
  77065. private static _Regex;
  77066. private static _UNITMODE_PERCENTAGE;
  77067. private static _UNITMODE_PIXEL;
  77068. /** UNITMODE_PERCENTAGE */
  77069. static get UNITMODE_PERCENTAGE(): number;
  77070. /** UNITMODE_PIXEL */
  77071. static get UNITMODE_PIXEL(): number;
  77072. }
  77073. }
  77074. declare module BABYLON.GUI {
  77075. /**
  77076. * Define a style used by control to automatically setup properties based on a template.
  77077. * Only support font related properties so far
  77078. */
  77079. export class Style implements BABYLON.IDisposable {
  77080. private _fontFamily;
  77081. private _fontStyle;
  77082. private _fontWeight;
  77083. /** @hidden */
  77084. _host: AdvancedDynamicTexture;
  77085. /** @hidden */
  77086. _fontSize: ValueAndUnit;
  77087. /**
  77088. * BABYLON.Observable raised when the style values are changed
  77089. */
  77090. onChangedObservable: BABYLON.Observable<Style>;
  77091. /**
  77092. * Creates a new style object
  77093. * @param host defines the AdvancedDynamicTexture which hosts this style
  77094. */
  77095. constructor(host: AdvancedDynamicTexture);
  77096. /**
  77097. * Gets or sets the font size
  77098. */
  77099. get fontSize(): string | number;
  77100. set fontSize(value: string | number);
  77101. /**
  77102. * Gets or sets the font family
  77103. */
  77104. get fontFamily(): string;
  77105. set fontFamily(value: string);
  77106. /**
  77107. * Gets or sets the font style
  77108. */
  77109. get fontStyle(): string;
  77110. set fontStyle(value: string);
  77111. /** Gets or sets font weight */
  77112. get fontWeight(): string;
  77113. set fontWeight(value: string);
  77114. /** Dispose all associated resources */
  77115. dispose(): void;
  77116. }
  77117. }
  77118. declare module BABYLON.GUI {
  77119. /**
  77120. * Class used to transport BABYLON.Vector2 information for pointer events
  77121. */
  77122. export class Vector2WithInfo extends BABYLON.Vector2 {
  77123. /** defines the current mouse button index */
  77124. buttonIndex: number;
  77125. /**
  77126. * Creates a new Vector2WithInfo
  77127. * @param source defines the vector2 data to transport
  77128. * @param buttonIndex defines the current mouse button index
  77129. */
  77130. constructor(source: BABYLON.Vector2,
  77131. /** defines the current mouse button index */
  77132. buttonIndex?: number);
  77133. }
  77134. /** Class used to provide 2D matrix features */
  77135. export class Matrix2D {
  77136. /** Gets the internal array of 6 floats used to store matrix data */
  77137. m: Float32Array;
  77138. /**
  77139. * Creates a new matrix
  77140. * @param m00 defines value for (0, 0)
  77141. * @param m01 defines value for (0, 1)
  77142. * @param m10 defines value for (1, 0)
  77143. * @param m11 defines value for (1, 1)
  77144. * @param m20 defines value for (2, 0)
  77145. * @param m21 defines value for (2, 1)
  77146. */
  77147. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77148. /**
  77149. * Fills the matrix from direct values
  77150. * @param m00 defines value for (0, 0)
  77151. * @param m01 defines value for (0, 1)
  77152. * @param m10 defines value for (1, 0)
  77153. * @param m11 defines value for (1, 1)
  77154. * @param m20 defines value for (2, 0)
  77155. * @param m21 defines value for (2, 1)
  77156. * @returns the current modified matrix
  77157. */
  77158. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77159. /**
  77160. * Gets matrix determinant
  77161. * @returns the determinant
  77162. */
  77163. determinant(): number;
  77164. /**
  77165. * Inverses the matrix and stores it in a target matrix
  77166. * @param result defines the target matrix
  77167. * @returns the current matrix
  77168. */
  77169. invertToRef(result: Matrix2D): Matrix2D;
  77170. /**
  77171. * Multiplies the current matrix with another one
  77172. * @param other defines the second operand
  77173. * @param result defines the target matrix
  77174. * @returns the current matrix
  77175. */
  77176. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77177. /**
  77178. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77179. * @param x defines the x coordinate to transform
  77180. * @param y defines the x coordinate to transform
  77181. * @param result defines the target vector2
  77182. * @returns the current matrix
  77183. */
  77184. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77185. /**
  77186. * Creates an identity matrix
  77187. * @returns a new matrix
  77188. */
  77189. static Identity(): Matrix2D;
  77190. /**
  77191. * Creates a translation matrix and stores it in a target matrix
  77192. * @param x defines the x coordinate of the translation
  77193. * @param y defines the y coordinate of the translation
  77194. * @param result defines the target matrix
  77195. */
  77196. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77197. /**
  77198. * Creates a scaling matrix and stores it in a target matrix
  77199. * @param x defines the x coordinate of the scaling
  77200. * @param y defines the y coordinate of the scaling
  77201. * @param result defines the target matrix
  77202. */
  77203. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77204. /**
  77205. * Creates a rotation matrix and stores it in a target matrix
  77206. * @param angle defines the rotation angle
  77207. * @param result defines the target matrix
  77208. */
  77209. static RotationToRef(angle: number, result: Matrix2D): void;
  77210. private static _TempPreTranslationMatrix;
  77211. private static _TempPostTranslationMatrix;
  77212. private static _TempRotationMatrix;
  77213. private static _TempScalingMatrix;
  77214. private static _TempCompose0;
  77215. private static _TempCompose1;
  77216. private static _TempCompose2;
  77217. /**
  77218. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77219. * @param tx defines the x coordinate of the translation
  77220. * @param ty defines the y coordinate of the translation
  77221. * @param angle defines the rotation angle
  77222. * @param scaleX defines the x coordinate of the scaling
  77223. * @param scaleY defines the y coordinate of the scaling
  77224. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77225. * @param result defines the target matrix
  77226. */
  77227. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77228. }
  77229. }
  77230. declare module BABYLON.GUI {
  77231. /**
  77232. * Class used to store 2D control sizes
  77233. */
  77234. export class Measure {
  77235. /** defines left coordinate */
  77236. left: number;
  77237. /** defines top coordinate */
  77238. top: number;
  77239. /** defines width dimension */
  77240. width: number;
  77241. /** defines height dimension */
  77242. height: number;
  77243. /**
  77244. * Creates a new measure
  77245. * @param left defines left coordinate
  77246. * @param top defines top coordinate
  77247. * @param width defines width dimension
  77248. * @param height defines height dimension
  77249. */
  77250. constructor(
  77251. /** defines left coordinate */
  77252. left: number,
  77253. /** defines top coordinate */
  77254. top: number,
  77255. /** defines width dimension */
  77256. width: number,
  77257. /** defines height dimension */
  77258. height: number);
  77259. /**
  77260. * Copy from another measure
  77261. * @param other defines the other measure to copy from
  77262. */
  77263. copyFrom(other: Measure): void;
  77264. /**
  77265. * Copy from a group of 4 floats
  77266. * @param left defines left coordinate
  77267. * @param top defines top coordinate
  77268. * @param width defines width dimension
  77269. * @param height defines height dimension
  77270. */
  77271. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77272. /**
  77273. * Computes the axis aligned bounding box measure for two given measures
  77274. * @param a Input measure
  77275. * @param b Input measure
  77276. * @param result the resulting bounding measure
  77277. */
  77278. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77279. /**
  77280. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77281. * @param transform the matrix to transform the measure before computing the AABB
  77282. * @param addX number to add to left
  77283. * @param addY number to add to top
  77284. * @param addWidth number to add to width
  77285. * @param addHeight number to add to height
  77286. * @param result the resulting AABB
  77287. */
  77288. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77289. /**
  77290. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77291. * @param transform the matrix to transform the measure before computing the AABB
  77292. * @param result the resulting AABB
  77293. */
  77294. transformToRef(transform: Matrix2D, result: Measure): void;
  77295. /**
  77296. * Check equality between this measure and another one
  77297. * @param other defines the other measures
  77298. * @returns true if both measures are equals
  77299. */
  77300. isEqualsTo(other: Measure): boolean;
  77301. /**
  77302. * Creates an empty measure
  77303. * @returns a new measure
  77304. */
  77305. static Empty(): Measure;
  77306. }
  77307. }
  77308. declare module BABYLON.GUI {
  77309. /**
  77310. * Interface used to define a control that can receive focus
  77311. */
  77312. export interface IFocusableControl {
  77313. /**
  77314. * Function called when the control receives the focus
  77315. */
  77316. onFocus(): void;
  77317. /**
  77318. * Function called when the control loses the focus
  77319. */
  77320. onBlur(): void;
  77321. /**
  77322. * Function called to let the control handle keyboard events
  77323. * @param evt defines the current keyboard event
  77324. */
  77325. processKeyboard(evt: KeyboardEvent): void;
  77326. /**
  77327. * Function called to get the list of controls that should not steal the focus from this control
  77328. * @returns an array of controls
  77329. */
  77330. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77331. }
  77332. /**
  77333. * Class used to create texture to support 2D GUI elements
  77334. * @see https://doc.babylonjs.com/how_to/gui
  77335. */
  77336. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77337. private _isDirty;
  77338. private _renderObserver;
  77339. private _resizeObserver;
  77340. private _preKeyboardObserver;
  77341. private _pointerMoveObserver;
  77342. private _pointerObserver;
  77343. private _canvasPointerOutObserver;
  77344. private _canvasBlurObserver;
  77345. private _background;
  77346. /** @hidden */
  77347. _rootContainer: Container;
  77348. /** @hidden */
  77349. _lastPickedControl: Control;
  77350. /** @hidden */
  77351. _lastControlOver: {
  77352. [pointerId: number]: Control;
  77353. };
  77354. /** @hidden */
  77355. _lastControlDown: {
  77356. [pointerId: number]: Control;
  77357. };
  77358. /** @hidden */
  77359. _capturingControl: {
  77360. [pointerId: number]: Control;
  77361. };
  77362. /** @hidden */
  77363. _shouldBlockPointer: boolean;
  77364. /** @hidden */
  77365. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77366. /** @hidden */
  77367. _linkedControls: Control[];
  77368. private _isFullscreen;
  77369. private _fullscreenViewport;
  77370. private _idealWidth;
  77371. private _idealHeight;
  77372. private _useSmallestIdeal;
  77373. private _renderAtIdealSize;
  77374. private _focusedControl;
  77375. private _blockNextFocusCheck;
  77376. private _renderScale;
  77377. private _rootElement;
  77378. private _cursorChanged;
  77379. private _defaultMousePointerId;
  77380. /** @hidden */
  77381. _numLayoutCalls: number;
  77382. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77383. get numLayoutCalls(): number;
  77384. /** @hidden */
  77385. _numRenderCalls: number;
  77386. /** Gets the number of render calls made the last time the ADT has been rendered */
  77387. get numRenderCalls(): number;
  77388. /**
  77389. * Define type to string to ensure compatibility across browsers
  77390. * Safari doesn't support DataTransfer constructor
  77391. */
  77392. private _clipboardData;
  77393. /**
  77394. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77395. */
  77396. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77397. /**
  77398. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77399. */
  77400. onControlPickedObservable: BABYLON.Observable<Control>;
  77401. /**
  77402. * BABYLON.Observable event triggered before layout is evaluated
  77403. */
  77404. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77405. /**
  77406. * BABYLON.Observable event triggered after the layout was evaluated
  77407. */
  77408. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77409. /**
  77410. * BABYLON.Observable event triggered before the texture is rendered
  77411. */
  77412. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77413. /**
  77414. * BABYLON.Observable event triggered after the texture was rendered
  77415. */
  77416. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77417. /**
  77418. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77419. */
  77420. premulAlpha: boolean;
  77421. /**
  77422. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77423. * Useful when you want more antialiasing
  77424. */
  77425. get renderScale(): number;
  77426. set renderScale(value: number);
  77427. /** Gets or sets the background color */
  77428. get background(): string;
  77429. set background(value: string);
  77430. /**
  77431. * Gets or sets the ideal width used to design controls.
  77432. * The GUI will then rescale everything accordingly
  77433. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77434. */
  77435. get idealWidth(): number;
  77436. set idealWidth(value: number);
  77437. /**
  77438. * Gets or sets the ideal height used to design controls.
  77439. * The GUI will then rescale everything accordingly
  77440. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77441. */
  77442. get idealHeight(): number;
  77443. set idealHeight(value: number);
  77444. /**
  77445. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77446. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77447. */
  77448. get useSmallestIdeal(): boolean;
  77449. set useSmallestIdeal(value: boolean);
  77450. /**
  77451. * Gets or sets a boolean indicating if adaptive scaling must be used
  77452. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77453. */
  77454. get renderAtIdealSize(): boolean;
  77455. set renderAtIdealSize(value: boolean);
  77456. /**
  77457. * Gets the ratio used when in "ideal mode"
  77458. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77459. * */
  77460. get idealRatio(): number;
  77461. /**
  77462. * Gets the underlying layer used to render the texture when in fullscreen mode
  77463. */
  77464. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77465. /**
  77466. * Gets the root container control
  77467. */
  77468. get rootContainer(): Container;
  77469. /**
  77470. * Returns an array containing the root container.
  77471. * This is mostly used to let the Inspector introspects the ADT
  77472. * @returns an array containing the rootContainer
  77473. */
  77474. getChildren(): Array<Container>;
  77475. /**
  77476. * Will return all controls that are inside this texture
  77477. * @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
  77478. * @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
  77479. * @return all child controls
  77480. */
  77481. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77482. /**
  77483. * Gets or sets the current focused control
  77484. */
  77485. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  77486. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  77487. /**
  77488. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  77489. */
  77490. get isForeground(): boolean;
  77491. set isForeground(value: boolean);
  77492. /**
  77493. * Gets or set information about clipboardData
  77494. */
  77495. get clipboardData(): string;
  77496. set clipboardData(value: string);
  77497. /**
  77498. * Creates a new AdvancedDynamicTexture
  77499. * @param name defines the name of the texture
  77500. * @param width defines the width of the texture
  77501. * @param height defines the height of the texture
  77502. * @param scene defines the hosting scene
  77503. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  77504. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77505. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77506. */
  77507. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  77508. /**
  77509. * Get the current class name of the texture useful for serialization or dynamic coding.
  77510. * @returns "AdvancedDynamicTexture"
  77511. */
  77512. getClassName(): string;
  77513. /**
  77514. * Function used to execute a function on all controls
  77515. * @param func defines the function to execute
  77516. * @param container defines the container where controls belong. If null the root container will be used
  77517. */
  77518. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  77519. private _useInvalidateRectOptimization;
  77520. /**
  77521. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  77522. */
  77523. get useInvalidateRectOptimization(): boolean;
  77524. set useInvalidateRectOptimization(value: boolean);
  77525. private _invalidatedRectangle;
  77526. /**
  77527. * Invalidates a rectangle area on the gui texture
  77528. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  77529. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  77530. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  77531. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  77532. */
  77533. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  77534. /**
  77535. * Marks the texture as dirty forcing a complete update
  77536. */
  77537. markAsDirty(): void;
  77538. /**
  77539. * Helper function used to create a new style
  77540. * @returns a new style
  77541. * @see https://doc.babylonjs.com/how_to/gui#styles
  77542. */
  77543. createStyle(): Style;
  77544. /**
  77545. * Adds a new control to the root container
  77546. * @param control defines the control to add
  77547. * @returns the current texture
  77548. */
  77549. addControl(control: Control): AdvancedDynamicTexture;
  77550. /**
  77551. * Removes a control from the root container
  77552. * @param control defines the control to remove
  77553. * @returns the current texture
  77554. */
  77555. removeControl(control: Control): AdvancedDynamicTexture;
  77556. /**
  77557. * Release all resources
  77558. */
  77559. dispose(): void;
  77560. private _onResize;
  77561. /** @hidden */
  77562. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  77563. /**
  77564. * Get screen coordinates for a vector3
  77565. * @param position defines the position to project
  77566. * @param worldMatrix defines the world matrix to use
  77567. * @returns the projected position
  77568. */
  77569. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  77570. private _checkUpdate;
  77571. private _clearMeasure;
  77572. private _render;
  77573. /** @hidden */
  77574. _changeCursor(cursor: string): void;
  77575. /** @hidden */
  77576. _registerLastControlDown(control: Control, pointerId: number): void;
  77577. private _doPicking;
  77578. /** @hidden */
  77579. _cleanControlAfterRemovalFromList(list: {
  77580. [pointerId: number]: Control;
  77581. }, control: Control): void;
  77582. /** @hidden */
  77583. _cleanControlAfterRemoval(control: Control): void;
  77584. /** Attach to all scene events required to support pointer events */
  77585. attach(): void;
  77586. /** @hidden */
  77587. private onClipboardCopy;
  77588. /** @hidden */
  77589. private onClipboardCut;
  77590. /** @hidden */
  77591. private onClipboardPaste;
  77592. /**
  77593. * Register the clipboard Events onto the canvas
  77594. */
  77595. registerClipboardEvents(): void;
  77596. /**
  77597. * Unregister the clipboard Events from the canvas
  77598. */
  77599. unRegisterClipboardEvents(): void;
  77600. /**
  77601. * Connect the texture to a hosting mesh to enable interactions
  77602. * @param mesh defines the mesh to attach to
  77603. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  77604. */
  77605. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  77606. /**
  77607. * Move the focus to a specific control
  77608. * @param control defines the control which will receive the focus
  77609. */
  77610. moveFocusToControl(control: IFocusableControl): void;
  77611. private _manageFocus;
  77612. private _attachToOnPointerOut;
  77613. private _attachToOnBlur;
  77614. /**
  77615. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  77616. * @param mesh defines the mesh which will receive the texture
  77617. * @param width defines the texture width (1024 by default)
  77618. * @param height defines the texture height (1024 by default)
  77619. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  77620. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  77621. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77622. * @returns a new AdvancedDynamicTexture
  77623. */
  77624. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  77625. /**
  77626. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  77627. * In this mode the texture will rely on a layer for its rendering.
  77628. * This allows it to be treated like any other layer.
  77629. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  77630. * LayerMask is set through advancedTexture.layer.layerMask
  77631. * @param name defines name for the texture
  77632. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  77633. * @param scene defines the hsoting scene
  77634. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  77635. * @returns a new AdvancedDynamicTexture
  77636. */
  77637. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  77638. }
  77639. }
  77640. declare module BABYLON.GUI {
  77641. /**
  77642. * Root class used for all 2D controls
  77643. * @see https://doc.babylonjs.com/how_to/gui#controls
  77644. */
  77645. export class Control {
  77646. /** defines the name of the control */
  77647. name?: string | undefined;
  77648. /**
  77649. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  77650. */
  77651. static AllowAlphaInheritance: boolean;
  77652. private _alpha;
  77653. private _alphaSet;
  77654. private _zIndex;
  77655. /** @hidden */
  77656. _host: AdvancedDynamicTexture;
  77657. /** Gets or sets the control parent */
  77658. parent: BABYLON.Nullable<Container>;
  77659. /** @hidden */
  77660. _currentMeasure: Measure;
  77661. private _fontFamily;
  77662. private _fontStyle;
  77663. private _fontWeight;
  77664. private _fontSize;
  77665. private _font;
  77666. /** @hidden */
  77667. _width: ValueAndUnit;
  77668. /** @hidden */
  77669. _height: ValueAndUnit;
  77670. /** @hidden */
  77671. protected _fontOffset: {
  77672. ascent: number;
  77673. height: number;
  77674. descent: number;
  77675. };
  77676. private _color;
  77677. private _style;
  77678. private _styleObserver;
  77679. /** @hidden */
  77680. protected _horizontalAlignment: number;
  77681. /** @hidden */
  77682. protected _verticalAlignment: number;
  77683. /** @hidden */
  77684. protected _isDirty: boolean;
  77685. /** @hidden */
  77686. protected _wasDirty: boolean;
  77687. /** @hidden */
  77688. _tempParentMeasure: Measure;
  77689. /** @hidden */
  77690. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  77691. /** @hidden */
  77692. protected _cachedParentMeasure: Measure;
  77693. private _paddingLeft;
  77694. private _paddingRight;
  77695. private _paddingTop;
  77696. private _paddingBottom;
  77697. /** @hidden */
  77698. _left: ValueAndUnit;
  77699. /** @hidden */
  77700. _top: ValueAndUnit;
  77701. private _scaleX;
  77702. private _scaleY;
  77703. private _rotation;
  77704. private _transformCenterX;
  77705. private _transformCenterY;
  77706. /** @hidden */
  77707. _transformMatrix: Matrix2D;
  77708. /** @hidden */
  77709. protected _invertTransformMatrix: Matrix2D;
  77710. /** @hidden */
  77711. protected _transformedPosition: BABYLON.Vector2;
  77712. private _isMatrixDirty;
  77713. private _cachedOffsetX;
  77714. private _cachedOffsetY;
  77715. private _isVisible;
  77716. private _isHighlighted;
  77717. /** @hidden */
  77718. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  77719. private _fontSet;
  77720. private _dummyVector2;
  77721. private _downCount;
  77722. private _enterCount;
  77723. private _doNotRender;
  77724. private _downPointerIds;
  77725. protected _isEnabled: boolean;
  77726. protected _disabledColor: string;
  77727. protected _disabledColorItem: string;
  77728. /** @hidden */
  77729. protected _rebuildLayout: boolean;
  77730. /** @hidden */
  77731. _customData: any;
  77732. /** @hidden */
  77733. _isClipped: boolean;
  77734. /** @hidden */
  77735. _automaticSize: boolean;
  77736. /** @hidden */
  77737. _tag: any;
  77738. /**
  77739. * 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
  77740. */
  77741. uniqueId: number;
  77742. /**
  77743. * Gets or sets an object used to store user defined information for the node
  77744. */
  77745. metadata: any;
  77746. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  77747. isHitTestVisible: boolean;
  77748. /** Gets or sets a boolean indicating if the control can block pointer events */
  77749. isPointerBlocker: boolean;
  77750. /** Gets or sets a boolean indicating if the control can be focusable */
  77751. isFocusInvisible: boolean;
  77752. /**
  77753. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  77754. * 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
  77755. */
  77756. clipChildren: boolean;
  77757. /**
  77758. * Gets or sets a boolean indicating that control content must be clipped
  77759. * 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
  77760. */
  77761. clipContent: boolean;
  77762. /**
  77763. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  77764. */
  77765. useBitmapCache: boolean;
  77766. private _cacheData;
  77767. private _shadowOffsetX;
  77768. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  77769. get shadowOffsetX(): number;
  77770. set shadowOffsetX(value: number);
  77771. private _shadowOffsetY;
  77772. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  77773. get shadowOffsetY(): number;
  77774. set shadowOffsetY(value: number);
  77775. private _shadowBlur;
  77776. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  77777. get shadowBlur(): number;
  77778. set shadowBlur(value: number);
  77779. private _shadowColor;
  77780. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  77781. get shadowColor(): string;
  77782. set shadowColor(value: string);
  77783. /** Gets or sets the cursor to use when the control is hovered */
  77784. hoverCursor: string;
  77785. /** @hidden */
  77786. protected _linkOffsetX: ValueAndUnit;
  77787. /** @hidden */
  77788. protected _linkOffsetY: ValueAndUnit;
  77789. /** Gets the control type name */
  77790. get typeName(): string;
  77791. /**
  77792. * Get the current class name of the control.
  77793. * @returns current class name
  77794. */
  77795. getClassName(): string;
  77796. /**
  77797. * An event triggered when pointer wheel is scrolled
  77798. */
  77799. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  77800. /**
  77801. * An event triggered when the pointer move over the control.
  77802. */
  77803. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  77804. /**
  77805. * An event triggered when the pointer move out of the control.
  77806. */
  77807. onPointerOutObservable: BABYLON.Observable<Control>;
  77808. /**
  77809. * An event triggered when the pointer taps the control
  77810. */
  77811. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  77812. /**
  77813. * An event triggered when pointer up
  77814. */
  77815. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  77816. /**
  77817. * An event triggered when a control is clicked on
  77818. */
  77819. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  77820. /**
  77821. * An event triggered when pointer enters the control
  77822. */
  77823. onPointerEnterObservable: BABYLON.Observable<Control>;
  77824. /**
  77825. * An event triggered when the control is marked as dirty
  77826. */
  77827. onDirtyObservable: BABYLON.Observable<Control>;
  77828. /**
  77829. * An event triggered before drawing the control
  77830. */
  77831. onBeforeDrawObservable: BABYLON.Observable<Control>;
  77832. /**
  77833. * An event triggered after the control was drawn
  77834. */
  77835. onAfterDrawObservable: BABYLON.Observable<Control>;
  77836. /**
  77837. * An event triggered when the control has been disposed
  77838. */
  77839. onDisposeObservable: BABYLON.Observable<Control>;
  77840. /**
  77841. * Get the hosting AdvancedDynamicTexture
  77842. */
  77843. get host(): AdvancedDynamicTexture;
  77844. /** Gets or set information about font offsets (used to render and align text) */
  77845. get fontOffset(): {
  77846. ascent: number;
  77847. height: number;
  77848. descent: number;
  77849. };
  77850. set fontOffset(offset: {
  77851. ascent: number;
  77852. height: number;
  77853. descent: number;
  77854. });
  77855. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  77856. get alpha(): number;
  77857. set alpha(value: number);
  77858. /**
  77859. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  77860. */
  77861. get isHighlighted(): boolean;
  77862. set isHighlighted(value: boolean);
  77863. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  77864. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77865. */
  77866. get scaleX(): number;
  77867. set scaleX(value: number);
  77868. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  77869. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77870. */
  77871. get scaleY(): number;
  77872. set scaleY(value: number);
  77873. /** Gets or sets the rotation angle (0 by default)
  77874. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77875. */
  77876. get rotation(): number;
  77877. set rotation(value: number);
  77878. /** Gets or sets the transformation center on Y axis (0 by default)
  77879. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77880. */
  77881. get transformCenterY(): number;
  77882. set transformCenterY(value: number);
  77883. /** Gets or sets the transformation center on X axis (0 by default)
  77884. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77885. */
  77886. get transformCenterX(): number;
  77887. set transformCenterX(value: number);
  77888. /**
  77889. * Gets or sets the horizontal alignment
  77890. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77891. */
  77892. get horizontalAlignment(): number;
  77893. set horizontalAlignment(value: number);
  77894. /**
  77895. * Gets or sets the vertical alignment
  77896. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77897. */
  77898. get verticalAlignment(): number;
  77899. set verticalAlignment(value: number);
  77900. /**
  77901. * Gets or sets a fixed ratio for this control.
  77902. * When different from 0, the ratio is used to compute the "second" dimension.
  77903. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  77904. * second dimension is computed as first dimension * fixedRatio
  77905. */
  77906. fixedRatio: number;
  77907. private _fixedRatioMasterIsWidth;
  77908. /**
  77909. * Gets or sets control width
  77910. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77911. */
  77912. get width(): string | number;
  77913. set width(value: string | number);
  77914. /**
  77915. * Gets or sets the control width in pixel
  77916. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77917. */
  77918. get widthInPixels(): number;
  77919. set widthInPixels(value: number);
  77920. /**
  77921. * Gets or sets control height
  77922. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77923. */
  77924. get height(): string | number;
  77925. set height(value: string | number);
  77926. /**
  77927. * Gets or sets control height in pixel
  77928. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77929. */
  77930. get heightInPixels(): number;
  77931. set heightInPixels(value: number);
  77932. /** Gets or set font family */
  77933. get fontFamily(): string;
  77934. set fontFamily(value: string);
  77935. /** Gets or sets font style */
  77936. get fontStyle(): string;
  77937. set fontStyle(value: string);
  77938. /** Gets or sets font weight */
  77939. get fontWeight(): string;
  77940. set fontWeight(value: string);
  77941. /**
  77942. * Gets or sets style
  77943. * @see https://doc.babylonjs.com/how_to/gui#styles
  77944. */
  77945. get style(): BABYLON.Nullable<Style>;
  77946. set style(value: BABYLON.Nullable<Style>);
  77947. /** @hidden */
  77948. get _isFontSizeInPercentage(): boolean;
  77949. /** Gets or sets font size in pixels */
  77950. get fontSizeInPixels(): number;
  77951. set fontSizeInPixels(value: number);
  77952. /** Gets or sets font size */
  77953. get fontSize(): string | number;
  77954. set fontSize(value: string | number);
  77955. /** Gets or sets foreground color */
  77956. get color(): string;
  77957. set color(value: string);
  77958. /** Gets or sets z index which is used to reorder controls on the z axis */
  77959. get zIndex(): number;
  77960. set zIndex(value: number);
  77961. /** Gets or sets a boolean indicating if the control can be rendered */
  77962. get notRenderable(): boolean;
  77963. set notRenderable(value: boolean);
  77964. /** Gets or sets a boolean indicating if the control is visible */
  77965. get isVisible(): boolean;
  77966. set isVisible(value: boolean);
  77967. /** Gets a boolean indicating that the control needs to update its rendering */
  77968. get isDirty(): boolean;
  77969. /**
  77970. * Gets the current linked mesh (or null if none)
  77971. */
  77972. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77973. /**
  77974. * Gets or sets a value indicating the padding to use on the left of the control
  77975. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77976. */
  77977. get paddingLeft(): string | number;
  77978. set paddingLeft(value: string | number);
  77979. /**
  77980. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  77981. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77982. */
  77983. get paddingLeftInPixels(): number;
  77984. set paddingLeftInPixels(value: number);
  77985. /**
  77986. * Gets or sets a value indicating the padding to use on the right of the control
  77987. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77988. */
  77989. get paddingRight(): string | number;
  77990. set paddingRight(value: string | number);
  77991. /**
  77992. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  77993. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77994. */
  77995. get paddingRightInPixels(): number;
  77996. set paddingRightInPixels(value: number);
  77997. /**
  77998. * Gets or sets a value indicating the padding to use on the top of the control
  77999. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78000. */
  78001. get paddingTop(): string | number;
  78002. set paddingTop(value: string | number);
  78003. /**
  78004. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78005. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78006. */
  78007. get paddingTopInPixels(): number;
  78008. set paddingTopInPixels(value: number);
  78009. /**
  78010. * Gets or sets a value indicating the padding to use on the bottom of the control
  78011. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78012. */
  78013. get paddingBottom(): string | number;
  78014. set paddingBottom(value: string | number);
  78015. /**
  78016. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78017. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78018. */
  78019. get paddingBottomInPixels(): number;
  78020. set paddingBottomInPixels(value: number);
  78021. /**
  78022. * Gets or sets a value indicating the left coordinate of the control
  78023. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78024. */
  78025. get left(): string | number;
  78026. set left(value: string | number);
  78027. /**
  78028. * Gets or sets a value indicating the left coordinate in pixels of the control
  78029. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78030. */
  78031. get leftInPixels(): number;
  78032. set leftInPixels(value: number);
  78033. /**
  78034. * Gets or sets a value indicating the top coordinate of the control
  78035. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78036. */
  78037. get top(): string | number;
  78038. set top(value: string | number);
  78039. /**
  78040. * Gets or sets a value indicating the top coordinate in pixels of the control
  78041. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78042. */
  78043. get topInPixels(): number;
  78044. set topInPixels(value: number);
  78045. /**
  78046. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78047. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78048. */
  78049. get linkOffsetX(): string | number;
  78050. set linkOffsetX(value: string | number);
  78051. /**
  78052. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78053. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78054. */
  78055. get linkOffsetXInPixels(): number;
  78056. set linkOffsetXInPixels(value: number);
  78057. /**
  78058. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78059. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78060. */
  78061. get linkOffsetY(): string | number;
  78062. set linkOffsetY(value: string | number);
  78063. /**
  78064. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78065. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78066. */
  78067. get linkOffsetYInPixels(): number;
  78068. set linkOffsetYInPixels(value: number);
  78069. /** Gets the center coordinate on X axis */
  78070. get centerX(): number;
  78071. /** Gets the center coordinate on Y axis */
  78072. get centerY(): number;
  78073. /** Gets or sets if control is Enabled*/
  78074. get isEnabled(): boolean;
  78075. set isEnabled(value: boolean);
  78076. /** Gets or sets background color of control if it's disabled*/
  78077. get disabledColor(): string;
  78078. set disabledColor(value: string);
  78079. /** Gets or sets front color of control if it's disabled*/
  78080. get disabledColorItem(): string;
  78081. set disabledColorItem(value: string);
  78082. /**
  78083. * Creates a new control
  78084. * @param name defines the name of the control
  78085. */
  78086. constructor(
  78087. /** defines the name of the control */
  78088. name?: string | undefined);
  78089. /** @hidden */
  78090. protected _getTypeName(): string;
  78091. /**
  78092. * Gets the first ascendant in the hierarchy of the given type
  78093. * @param className defines the required type
  78094. * @returns the ascendant or null if not found
  78095. */
  78096. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78097. /** @hidden */
  78098. _resetFontCache(): void;
  78099. /**
  78100. * Determines if a container is an ascendant of the current control
  78101. * @param container defines the container to look for
  78102. * @returns true if the container is one of the ascendant of the control
  78103. */
  78104. isAscendant(container: Control): boolean;
  78105. /**
  78106. * Gets coordinates in local control space
  78107. * @param globalCoordinates defines the coordinates to transform
  78108. * @returns the new coordinates in local space
  78109. */
  78110. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78111. /**
  78112. * Gets coordinates in local control space
  78113. * @param globalCoordinates defines the coordinates to transform
  78114. * @param result defines the target vector2 where to store the result
  78115. * @returns the current control
  78116. */
  78117. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78118. /**
  78119. * Gets coordinates in parent local control space
  78120. * @param globalCoordinates defines the coordinates to transform
  78121. * @returns the new coordinates in parent local space
  78122. */
  78123. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78124. /**
  78125. * Move the current control to a vector3 position projected onto the screen.
  78126. * @param position defines the target position
  78127. * @param scene defines the hosting scene
  78128. */
  78129. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78130. /**
  78131. * Will store all controls that have this control as ascendant in a given array
  78132. * @param results defines the array where to store the descendants
  78133. * @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
  78134. * @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
  78135. */
  78136. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78137. /**
  78138. * Will return all controls that have this control as ascendant
  78139. * @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
  78140. * @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
  78141. * @return all child controls
  78142. */
  78143. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78144. /**
  78145. * Link current control with a target mesh
  78146. * @param mesh defines the mesh to link with
  78147. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78148. */
  78149. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  78150. /** @hidden */
  78151. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78152. /** @hidden */
  78153. _offsetLeft(offset: number): void;
  78154. /** @hidden */
  78155. _offsetTop(offset: number): void;
  78156. /** @hidden */
  78157. _markMatrixAsDirty(): void;
  78158. /** @hidden */
  78159. _flagDescendantsAsMatrixDirty(): void;
  78160. /** @hidden */
  78161. _intersectsRect(rect: Measure): boolean;
  78162. /** @hidden */
  78163. protected invalidateRect(): void;
  78164. /** @hidden */
  78165. _markAsDirty(force?: boolean): void;
  78166. /** @hidden */
  78167. _markAllAsDirty(): void;
  78168. /** @hidden */
  78169. _link(host: AdvancedDynamicTexture): void;
  78170. /** @hidden */
  78171. protected _transform(context?: CanvasRenderingContext2D): void;
  78172. /** @hidden */
  78173. _renderHighlight(context: CanvasRenderingContext2D): void;
  78174. /** @hidden */
  78175. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78176. /** @hidden */
  78177. protected _applyStates(context: CanvasRenderingContext2D): void;
  78178. /** @hidden */
  78179. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78180. /** @hidden */
  78181. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78182. protected _evaluateClippingState(parentMeasure: Measure): void;
  78183. /** @hidden */
  78184. _measure(): void;
  78185. /** @hidden */
  78186. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78187. /** @hidden */
  78188. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78189. /** @hidden */
  78190. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78191. /** @hidden */
  78192. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78193. private static _ClipMeasure;
  78194. private _tmpMeasureA;
  78195. private _clip;
  78196. /** @hidden */
  78197. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78198. /** @hidden */
  78199. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78200. /**
  78201. * Tests if a given coordinates belong to the current control
  78202. * @param x defines x coordinate to test
  78203. * @param y defines y coordinate to test
  78204. * @returns true if the coordinates are inside the control
  78205. */
  78206. contains(x: number, y: number): boolean;
  78207. /** @hidden */
  78208. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78209. /** @hidden */
  78210. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  78211. /** @hidden */
  78212. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78213. /** @hidden */
  78214. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  78215. /** @hidden */
  78216. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78217. /** @hidden */
  78218. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  78219. /** @hidden */
  78220. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78221. /** @hidden */
  78222. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78223. /** @hidden */
  78224. _onCanvasBlur(): void;
  78225. /** @hidden */
  78226. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78227. private _prepareFont;
  78228. /** Releases associated resources */
  78229. dispose(): void;
  78230. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78231. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78232. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78233. private static _VERTICAL_ALIGNMENT_TOP;
  78234. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78235. private static _VERTICAL_ALIGNMENT_CENTER;
  78236. /** HORIZONTAL_ALIGNMENT_LEFT */
  78237. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78238. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78239. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78240. /** HORIZONTAL_ALIGNMENT_CENTER */
  78241. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78242. /** VERTICAL_ALIGNMENT_TOP */
  78243. static get VERTICAL_ALIGNMENT_TOP(): number;
  78244. /** VERTICAL_ALIGNMENT_BOTTOM */
  78245. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78246. /** VERTICAL_ALIGNMENT_CENTER */
  78247. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78248. private static _FontHeightSizes;
  78249. /** @hidden */
  78250. static _GetFontOffset(font: string): {
  78251. ascent: number;
  78252. height: number;
  78253. descent: number;
  78254. };
  78255. /**
  78256. * Creates a stack panel that can be used to render headers
  78257. * @param control defines the control to associate with the header
  78258. * @param text defines the text of the header
  78259. * @param size defines the size of the header
  78260. * @param options defines options used to configure the header
  78261. * @returns a new StackPanel
  78262. * @ignore
  78263. * @hidden
  78264. */
  78265. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78266. isHorizontal: boolean;
  78267. controlFirst: boolean;
  78268. }) => any;
  78269. /** @hidden */
  78270. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78271. }
  78272. }
  78273. declare module BABYLON.GUI {
  78274. /**
  78275. * Root class for 2D containers
  78276. * @see https://doc.babylonjs.com/how_to/gui#containers
  78277. */
  78278. export class Container extends Control {
  78279. name?: string | undefined;
  78280. /** @hidden */
  78281. _children: Control[];
  78282. /** @hidden */
  78283. protected _measureForChildren: Measure;
  78284. /** @hidden */
  78285. protected _background: string;
  78286. /** @hidden */
  78287. protected _adaptWidthToChildren: boolean;
  78288. /** @hidden */
  78289. protected _adaptHeightToChildren: boolean;
  78290. /**
  78291. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78292. */
  78293. logLayoutCycleErrors: boolean;
  78294. /**
  78295. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78296. */
  78297. maxLayoutCycle: number;
  78298. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78299. get adaptHeightToChildren(): boolean;
  78300. set adaptHeightToChildren(value: boolean);
  78301. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78302. get adaptWidthToChildren(): boolean;
  78303. set adaptWidthToChildren(value: boolean);
  78304. /** Gets or sets background color */
  78305. get background(): string;
  78306. set background(value: string);
  78307. /** Gets the list of children */
  78308. get children(): Control[];
  78309. /**
  78310. * Creates a new Container
  78311. * @param name defines the name of the container
  78312. */
  78313. constructor(name?: string | undefined);
  78314. protected _getTypeName(): string;
  78315. _flagDescendantsAsMatrixDirty(): void;
  78316. /**
  78317. * Gets a child using its name
  78318. * @param name defines the child name to look for
  78319. * @returns the child control if found
  78320. */
  78321. getChildByName(name: string): BABYLON.Nullable<Control>;
  78322. /**
  78323. * Gets a child using its type and its name
  78324. * @param name defines the child name to look for
  78325. * @param type defines the child type to look for
  78326. * @returns the child control if found
  78327. */
  78328. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78329. /**
  78330. * Search for a specific control in children
  78331. * @param control defines the control to look for
  78332. * @returns true if the control is in child list
  78333. */
  78334. containsControl(control: Control): boolean;
  78335. /**
  78336. * Adds a new control to the current container
  78337. * @param control defines the control to add
  78338. * @returns the current container
  78339. */
  78340. addControl(control: BABYLON.Nullable<Control>): Container;
  78341. /**
  78342. * Removes all controls from the current container
  78343. * @returns the current container
  78344. */
  78345. clearControls(): Container;
  78346. /**
  78347. * Removes a control from the current container
  78348. * @param control defines the control to remove
  78349. * @returns the current container
  78350. */
  78351. removeControl(control: Control): Container;
  78352. /** @hidden */
  78353. _reOrderControl(control: Control): void;
  78354. /** @hidden */
  78355. _offsetLeft(offset: number): void;
  78356. /** @hidden */
  78357. _offsetTop(offset: number): void;
  78358. /** @hidden */
  78359. _markAllAsDirty(): void;
  78360. /** @hidden */
  78361. protected _localDraw(context: CanvasRenderingContext2D): void;
  78362. /** @hidden */
  78363. _link(host: AdvancedDynamicTexture): void;
  78364. /** @hidden */
  78365. protected _beforeLayout(): void;
  78366. /** @hidden */
  78367. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78368. /** @hidden */
  78369. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78370. protected _postMeasure(): void;
  78371. /** @hidden */
  78372. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78373. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78374. /** @hidden */
  78375. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78376. /** @hidden */
  78377. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78378. /** Releases associated resources */
  78379. dispose(): void;
  78380. }
  78381. }
  78382. declare module BABYLON.GUI {
  78383. /** Class used to create rectangle container */
  78384. export class Rectangle extends Container {
  78385. name?: string | undefined;
  78386. private _thickness;
  78387. private _cornerRadius;
  78388. /** Gets or sets border thickness */
  78389. get thickness(): number;
  78390. set thickness(value: number);
  78391. /** Gets or sets the corner radius angle */
  78392. get cornerRadius(): number;
  78393. set cornerRadius(value: number);
  78394. /**
  78395. * Creates a new Rectangle
  78396. * @param name defines the control name
  78397. */
  78398. constructor(name?: string | undefined);
  78399. protected _getTypeName(): string;
  78400. protected _localDraw(context: CanvasRenderingContext2D): void;
  78401. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78402. private _drawRoundedRect;
  78403. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78404. }
  78405. }
  78406. declare module BABYLON.GUI {
  78407. /**
  78408. * Enum that determines the text-wrapping mode to use.
  78409. */
  78410. export enum TextWrapping {
  78411. /**
  78412. * Clip the text when it's larger than Control.width; this is the default mode.
  78413. */
  78414. Clip = 0,
  78415. /**
  78416. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78417. */
  78418. WordWrap = 1,
  78419. /**
  78420. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78421. */
  78422. Ellipsis = 2
  78423. }
  78424. /**
  78425. * Class used to create text block control
  78426. */
  78427. export class TextBlock extends Control {
  78428. /**
  78429. * Defines the name of the control
  78430. */
  78431. name?: string | undefined;
  78432. private _text;
  78433. private _textWrapping;
  78434. private _textHorizontalAlignment;
  78435. private _textVerticalAlignment;
  78436. private _lines;
  78437. private _resizeToFit;
  78438. private _lineSpacing;
  78439. private _outlineWidth;
  78440. private _outlineColor;
  78441. private _underline;
  78442. private _lineThrough;
  78443. /**
  78444. * An event triggered after the text is changed
  78445. */
  78446. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78447. /**
  78448. * An event triggered after the text was broken up into lines
  78449. */
  78450. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78451. /**
  78452. * Function used to split a string into words. By default, a string is split at each space character found
  78453. */
  78454. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78455. /**
  78456. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78457. */
  78458. get lines(): any[];
  78459. /**
  78460. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78461. */
  78462. get resizeToFit(): boolean;
  78463. /**
  78464. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78465. */
  78466. set resizeToFit(value: boolean);
  78467. /**
  78468. * Gets or sets a boolean indicating if text must be wrapped
  78469. */
  78470. get textWrapping(): TextWrapping | boolean;
  78471. /**
  78472. * Gets or sets a boolean indicating if text must be wrapped
  78473. */
  78474. set textWrapping(value: TextWrapping | boolean);
  78475. /**
  78476. * Gets or sets text to display
  78477. */
  78478. get text(): string;
  78479. /**
  78480. * Gets or sets text to display
  78481. */
  78482. set text(value: string);
  78483. /**
  78484. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78485. */
  78486. get textHorizontalAlignment(): number;
  78487. /**
  78488. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78489. */
  78490. set textHorizontalAlignment(value: number);
  78491. /**
  78492. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78493. */
  78494. get textVerticalAlignment(): number;
  78495. /**
  78496. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78497. */
  78498. set textVerticalAlignment(value: number);
  78499. /**
  78500. * Gets or sets line spacing value
  78501. */
  78502. set lineSpacing(value: string | number);
  78503. /**
  78504. * Gets or sets line spacing value
  78505. */
  78506. get lineSpacing(): string | number;
  78507. /**
  78508. * Gets or sets outlineWidth of the text to display
  78509. */
  78510. get outlineWidth(): number;
  78511. /**
  78512. * Gets or sets outlineWidth of the text to display
  78513. */
  78514. set outlineWidth(value: number);
  78515. /**
  78516. * Gets or sets a boolean indicating that text must have underline
  78517. */
  78518. get underline(): boolean;
  78519. /**
  78520. * Gets or sets a boolean indicating that text must have underline
  78521. */
  78522. set underline(value: boolean);
  78523. /**
  78524. * Gets or sets an boolean indicating that text must be crossed out
  78525. */
  78526. get lineThrough(): boolean;
  78527. /**
  78528. * Gets or sets an boolean indicating that text must be crossed out
  78529. */
  78530. set lineThrough(value: boolean);
  78531. /**
  78532. * Gets or sets outlineColor of the text to display
  78533. */
  78534. get outlineColor(): string;
  78535. /**
  78536. * Gets or sets outlineColor of the text to display
  78537. */
  78538. set outlineColor(value: string);
  78539. /**
  78540. * Creates a new TextBlock object
  78541. * @param name defines the name of the control
  78542. * @param text defines the text to display (emptry string by default)
  78543. */
  78544. constructor(
  78545. /**
  78546. * Defines the name of the control
  78547. */
  78548. name?: string | undefined, text?: string);
  78549. protected _getTypeName(): string;
  78550. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78551. private _drawText;
  78552. /** @hidden */
  78553. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78554. protected _applyStates(context: CanvasRenderingContext2D): void;
  78555. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  78556. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  78557. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  78558. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  78559. protected _renderLines(context: CanvasRenderingContext2D): void;
  78560. /**
  78561. * Given a width constraint applied on the text block, find the expected height
  78562. * @returns expected height
  78563. */
  78564. computeExpectedHeight(): number;
  78565. dispose(): void;
  78566. }
  78567. }
  78568. declare module BABYLON.GUI {
  78569. /**
  78570. * Class used to create 2D images
  78571. */
  78572. export class Image extends Control {
  78573. name?: string | undefined;
  78574. private _workingCanvas;
  78575. private _domImage;
  78576. private _imageWidth;
  78577. private _imageHeight;
  78578. private _loaded;
  78579. private _stretch;
  78580. private _source;
  78581. private _autoScale;
  78582. private _sourceLeft;
  78583. private _sourceTop;
  78584. private _sourceWidth;
  78585. private _sourceHeight;
  78586. private _svgAttributesComputationCompleted;
  78587. private _isSVG;
  78588. private _cellWidth;
  78589. private _cellHeight;
  78590. private _cellId;
  78591. private _populateNinePatchSlicesFromImage;
  78592. private _sliceLeft;
  78593. private _sliceRight;
  78594. private _sliceTop;
  78595. private _sliceBottom;
  78596. private _detectPointerOnOpaqueOnly;
  78597. private _imageDataCache;
  78598. /**
  78599. * BABYLON.Observable notified when the content is loaded
  78600. */
  78601. onImageLoadedObservable: BABYLON.Observable<Image>;
  78602. /**
  78603. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  78604. */
  78605. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  78606. /**
  78607. * Gets a boolean indicating that the content is loaded
  78608. */
  78609. get isLoaded(): boolean;
  78610. /**
  78611. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  78612. */
  78613. get populateNinePatchSlicesFromImage(): boolean;
  78614. set populateNinePatchSlicesFromImage(value: boolean);
  78615. /**
  78616. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  78617. * Beware using this as this will comsume more memory as the image has to be stored twice
  78618. */
  78619. get detectPointerOnOpaqueOnly(): boolean;
  78620. set detectPointerOnOpaqueOnly(value: boolean);
  78621. /**
  78622. * Gets or sets the left value for slicing (9-patch)
  78623. */
  78624. get sliceLeft(): number;
  78625. set sliceLeft(value: number);
  78626. /**
  78627. * Gets or sets the right value for slicing (9-patch)
  78628. */
  78629. get sliceRight(): number;
  78630. set sliceRight(value: number);
  78631. /**
  78632. * Gets or sets the top value for slicing (9-patch)
  78633. */
  78634. get sliceTop(): number;
  78635. set sliceTop(value: number);
  78636. /**
  78637. * Gets or sets the bottom value for slicing (9-patch)
  78638. */
  78639. get sliceBottom(): number;
  78640. set sliceBottom(value: number);
  78641. /**
  78642. * Gets or sets the left coordinate in the source image
  78643. */
  78644. get sourceLeft(): number;
  78645. set sourceLeft(value: number);
  78646. /**
  78647. * Gets or sets the top coordinate in the source image
  78648. */
  78649. get sourceTop(): number;
  78650. set sourceTop(value: number);
  78651. /**
  78652. * Gets or sets the width to capture in the source image
  78653. */
  78654. get sourceWidth(): number;
  78655. set sourceWidth(value: number);
  78656. /**
  78657. * Gets or sets the height to capture in the source image
  78658. */
  78659. get sourceHeight(): number;
  78660. set sourceHeight(value: number);
  78661. /** Indicates if the format of the image is SVG */
  78662. get isSVG(): boolean;
  78663. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  78664. get svgAttributesComputationCompleted(): boolean;
  78665. /**
  78666. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  78667. * @see https://doc.babylonjs.com/how_to/gui#image
  78668. */
  78669. get autoScale(): boolean;
  78670. set autoScale(value: boolean);
  78671. /** Gets or sets the streching mode used by the image */
  78672. get stretch(): number;
  78673. set stretch(value: number);
  78674. /** @hidden */
  78675. _rotate90(n: number, preserveProperties?: boolean): Image;
  78676. private _handleRotationForSVGImage;
  78677. private _rotate90SourceProperties;
  78678. /**
  78679. * Gets or sets the internal DOM image used to render the control
  78680. */
  78681. set domImage(value: HTMLImageElement);
  78682. get domImage(): HTMLImageElement;
  78683. private _onImageLoaded;
  78684. private _extractNinePatchSliceDataFromImage;
  78685. /**
  78686. * Gets or sets image source url
  78687. */
  78688. set source(value: BABYLON.Nullable<string>);
  78689. /**
  78690. * Checks for svg document with icon id present
  78691. */
  78692. private _svgCheck;
  78693. /**
  78694. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  78695. * given external svg file and icon id
  78696. */
  78697. private _getSVGAttribs;
  78698. /**
  78699. * Gets or sets the cell width to use when animation sheet is enabled
  78700. * @see https://doc.babylonjs.com/how_to/gui#image
  78701. */
  78702. get cellWidth(): number;
  78703. set cellWidth(value: number);
  78704. /**
  78705. * Gets or sets the cell height to use when animation sheet is enabled
  78706. * @see https://doc.babylonjs.com/how_to/gui#image
  78707. */
  78708. get cellHeight(): number;
  78709. set cellHeight(value: number);
  78710. /**
  78711. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  78712. * @see https://doc.babylonjs.com/how_to/gui#image
  78713. */
  78714. get cellId(): number;
  78715. set cellId(value: number);
  78716. /**
  78717. * Creates a new Image
  78718. * @param name defines the control name
  78719. * @param url defines the image url
  78720. */
  78721. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  78722. /**
  78723. * Tests if a given coordinates belong to the current control
  78724. * @param x defines x coordinate to test
  78725. * @param y defines y coordinate to test
  78726. * @returns true if the coordinates are inside the control
  78727. */
  78728. contains(x: number, y: number): boolean;
  78729. protected _getTypeName(): string;
  78730. /** Force the control to synchronize with its content */
  78731. synchronizeSizeWithContent(): void;
  78732. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78733. private _prepareWorkingCanvasForOpaqueDetection;
  78734. private _drawImage;
  78735. _draw(context: CanvasRenderingContext2D): void;
  78736. private _renderCornerPatch;
  78737. private _renderNinePatch;
  78738. dispose(): void;
  78739. /** STRETCH_NONE */
  78740. static readonly STRETCH_NONE: number;
  78741. /** STRETCH_FILL */
  78742. static readonly STRETCH_FILL: number;
  78743. /** STRETCH_UNIFORM */
  78744. static readonly STRETCH_UNIFORM: number;
  78745. /** STRETCH_EXTEND */
  78746. static readonly STRETCH_EXTEND: number;
  78747. /** NINE_PATCH */
  78748. static readonly STRETCH_NINE_PATCH: number;
  78749. }
  78750. }
  78751. declare module BABYLON.GUI {
  78752. /**
  78753. * Class used to create 2D buttons
  78754. */
  78755. export class Button extends Rectangle {
  78756. name?: string | undefined;
  78757. /**
  78758. * Function called to generate a pointer enter animation
  78759. */
  78760. pointerEnterAnimation: () => void;
  78761. /**
  78762. * Function called to generate a pointer out animation
  78763. */
  78764. pointerOutAnimation: () => void;
  78765. /**
  78766. * Function called to generate a pointer down animation
  78767. */
  78768. pointerDownAnimation: () => void;
  78769. /**
  78770. * Function called to generate a pointer up animation
  78771. */
  78772. pointerUpAnimation: () => void;
  78773. /**
  78774. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  78775. */
  78776. delegatePickingToChildren: boolean;
  78777. private _image;
  78778. /**
  78779. * Returns the image part of the button (if any)
  78780. */
  78781. get image(): BABYLON.Nullable<Image>;
  78782. private _textBlock;
  78783. /**
  78784. * Returns the image part of the button (if any)
  78785. */
  78786. get textBlock(): BABYLON.Nullable<TextBlock>;
  78787. /**
  78788. * Creates a new Button
  78789. * @param name defines the name of the button
  78790. */
  78791. constructor(name?: string | undefined);
  78792. protected _getTypeName(): string;
  78793. /** @hidden */
  78794. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78795. /** @hidden */
  78796. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78797. /** @hidden */
  78798. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  78799. /** @hidden */
  78800. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78801. /** @hidden */
  78802. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  78803. /**
  78804. * Creates a new button made with an image and a text
  78805. * @param name defines the name of the button
  78806. * @param text defines the text of the button
  78807. * @param imageUrl defines the url of the image
  78808. * @returns a new Button
  78809. */
  78810. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  78811. /**
  78812. * Creates a new button made with an image
  78813. * @param name defines the name of the button
  78814. * @param imageUrl defines the url of the image
  78815. * @returns a new Button
  78816. */
  78817. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  78818. /**
  78819. * Creates a new button made with a text
  78820. * @param name defines the name of the button
  78821. * @param text defines the text of the button
  78822. * @returns a new Button
  78823. */
  78824. static CreateSimpleButton(name: string, text: string): Button;
  78825. /**
  78826. * Creates a new button made with an image and a centered text
  78827. * @param name defines the name of the button
  78828. * @param text defines the text of the button
  78829. * @param imageUrl defines the url of the image
  78830. * @returns a new Button
  78831. */
  78832. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  78833. }
  78834. }
  78835. declare module BABYLON.GUI {
  78836. /**
  78837. * Class used to create a 2D stack panel container
  78838. */
  78839. export class StackPanel extends Container {
  78840. name?: string | undefined;
  78841. private _isVertical;
  78842. private _manualWidth;
  78843. private _manualHeight;
  78844. private _doNotTrackManualChanges;
  78845. /**
  78846. * Gets or sets a boolean indicating that layou warnings should be ignored
  78847. */
  78848. ignoreLayoutWarnings: boolean;
  78849. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  78850. get isVertical(): boolean;
  78851. set isVertical(value: boolean);
  78852. /**
  78853. * Gets or sets panel width.
  78854. * This value should not be set when in horizontal mode as it will be computed automatically
  78855. */
  78856. set width(value: string | number);
  78857. get width(): string | number;
  78858. /**
  78859. * Gets or sets panel height.
  78860. * This value should not be set when in vertical mode as it will be computed automatically
  78861. */
  78862. set height(value: string | number);
  78863. get height(): string | number;
  78864. /**
  78865. * Creates a new StackPanel
  78866. * @param name defines control name
  78867. */
  78868. constructor(name?: string | undefined);
  78869. protected _getTypeName(): string;
  78870. /** @hidden */
  78871. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78872. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78873. protected _postMeasure(): void;
  78874. }
  78875. }
  78876. declare module BABYLON.GUI {
  78877. /**
  78878. * Class used to represent a 2D checkbox
  78879. */
  78880. export class Checkbox extends Control {
  78881. name?: string | undefined;
  78882. private _isChecked;
  78883. private _background;
  78884. private _checkSizeRatio;
  78885. private _thickness;
  78886. /** Gets or sets border thickness */
  78887. get thickness(): number;
  78888. set thickness(value: number);
  78889. /**
  78890. * BABYLON.Observable raised when isChecked property changes
  78891. */
  78892. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78893. /** Gets or sets a value indicating the ratio between overall size and check size */
  78894. get checkSizeRatio(): number;
  78895. set checkSizeRatio(value: number);
  78896. /** Gets or sets background color */
  78897. get background(): string;
  78898. set background(value: string);
  78899. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78900. get isChecked(): boolean;
  78901. set isChecked(value: boolean);
  78902. /**
  78903. * Creates a new CheckBox
  78904. * @param name defines the control name
  78905. */
  78906. constructor(name?: string | undefined);
  78907. protected _getTypeName(): string;
  78908. /** @hidden */
  78909. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78910. /** @hidden */
  78911. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78912. /**
  78913. * Utility function to easily create a checkbox with a header
  78914. * @param title defines the label to use for the header
  78915. * @param onValueChanged defines the callback to call when value changes
  78916. * @returns a StackPanel containing the checkbox and a textBlock
  78917. */
  78918. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  78919. }
  78920. }
  78921. declare module BABYLON.GUI {
  78922. /**
  78923. * Class used to store key control properties
  78924. */
  78925. export class KeyPropertySet {
  78926. /** Width */
  78927. width?: string;
  78928. /** Height */
  78929. height?: string;
  78930. /** Left padding */
  78931. paddingLeft?: string;
  78932. /** Right padding */
  78933. paddingRight?: string;
  78934. /** Top padding */
  78935. paddingTop?: string;
  78936. /** Bottom padding */
  78937. paddingBottom?: string;
  78938. /** Foreground color */
  78939. color?: string;
  78940. /** Background color */
  78941. background?: string;
  78942. }
  78943. /**
  78944. * Class used to create virtual keyboard
  78945. */
  78946. export class VirtualKeyboard extends StackPanel {
  78947. /** BABYLON.Observable raised when a key is pressed */
  78948. onKeyPressObservable: BABYLON.Observable<string>;
  78949. /** Gets or sets default key button width */
  78950. defaultButtonWidth: string;
  78951. /** Gets or sets default key button height */
  78952. defaultButtonHeight: string;
  78953. /** Gets or sets default key button left padding */
  78954. defaultButtonPaddingLeft: string;
  78955. /** Gets or sets default key button right padding */
  78956. defaultButtonPaddingRight: string;
  78957. /** Gets or sets default key button top padding */
  78958. defaultButtonPaddingTop: string;
  78959. /** Gets or sets default key button bottom padding */
  78960. defaultButtonPaddingBottom: string;
  78961. /** Gets or sets default key button foreground color */
  78962. defaultButtonColor: string;
  78963. /** Gets or sets default key button background color */
  78964. defaultButtonBackground: string;
  78965. /** Gets or sets shift button foreground color */
  78966. shiftButtonColor: string;
  78967. /** Gets or sets shift button thickness*/
  78968. selectedShiftThickness: number;
  78969. /** Gets shift key state */
  78970. shiftState: number;
  78971. protected _getTypeName(): string;
  78972. private _createKey;
  78973. /**
  78974. * Adds a new row of keys
  78975. * @param keys defines the list of keys to add
  78976. * @param propertySets defines the associated property sets
  78977. */
  78978. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  78979. /**
  78980. * Set the shift key to a specific state
  78981. * @param shiftState defines the new shift state
  78982. */
  78983. applyShiftState(shiftState: number): void;
  78984. private _currentlyConnectedInputText;
  78985. private _connectedInputTexts;
  78986. private _onKeyPressObserver;
  78987. /** Gets the input text control currently attached to the keyboard */
  78988. get connectedInputText(): BABYLON.Nullable<InputText>;
  78989. /**
  78990. * Connects the keyboard with an input text control
  78991. *
  78992. * @param input defines the target control
  78993. */
  78994. connect(input: InputText): void;
  78995. /**
  78996. * Disconnects the keyboard from connected InputText controls
  78997. *
  78998. * @param input optionally defines a target control, otherwise all are disconnected
  78999. */
  79000. disconnect(input?: InputText): void;
  79001. private _removeConnectedInputObservables;
  79002. /**
  79003. * Release all resources
  79004. */
  79005. dispose(): void;
  79006. /**
  79007. * Creates a new keyboard using a default layout
  79008. *
  79009. * @param name defines control name
  79010. * @returns a new VirtualKeyboard
  79011. */
  79012. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79013. }
  79014. }
  79015. declare module BABYLON.GUI {
  79016. /**
  79017. * Class used to create input text control
  79018. */
  79019. export class InputText extends Control implements IFocusableControl {
  79020. name?: string | undefined;
  79021. private _text;
  79022. private _placeholderText;
  79023. private _background;
  79024. private _focusedBackground;
  79025. private _focusedColor;
  79026. private _placeholderColor;
  79027. private _thickness;
  79028. private _margin;
  79029. private _autoStretchWidth;
  79030. private _maxWidth;
  79031. private _isFocused;
  79032. private _blinkTimeout;
  79033. private _blinkIsEven;
  79034. private _cursorOffset;
  79035. private _scrollLeft;
  79036. private _textWidth;
  79037. private _clickedCoordinate;
  79038. private _deadKey;
  79039. private _addKey;
  79040. private _currentKey;
  79041. private _isTextHighlightOn;
  79042. private _textHighlightColor;
  79043. private _highligherOpacity;
  79044. private _highlightedText;
  79045. private _startHighlightIndex;
  79046. private _endHighlightIndex;
  79047. private _cursorIndex;
  79048. private _onFocusSelectAll;
  79049. private _isPointerDown;
  79050. private _onClipboardObserver;
  79051. private _onPointerDblTapObserver;
  79052. /** @hidden */
  79053. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79054. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79055. promptMessage: string;
  79056. /** Force disable prompt on mobile device */
  79057. disableMobilePrompt: boolean;
  79058. /** BABYLON.Observable raised when the text changes */
  79059. onTextChangedObservable: BABYLON.Observable<InputText>;
  79060. /** BABYLON.Observable raised just before an entered character is to be added */
  79061. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79062. /** BABYLON.Observable raised when the control gets the focus */
  79063. onFocusObservable: BABYLON.Observable<InputText>;
  79064. /** BABYLON.Observable raised when the control loses the focus */
  79065. onBlurObservable: BABYLON.Observable<InputText>;
  79066. /**Observable raised when the text is highlighted */
  79067. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79068. /**Observable raised when copy event is triggered */
  79069. onTextCopyObservable: BABYLON.Observable<InputText>;
  79070. /** BABYLON.Observable raised when cut event is triggered */
  79071. onTextCutObservable: BABYLON.Observable<InputText>;
  79072. /** BABYLON.Observable raised when paste event is triggered */
  79073. onTextPasteObservable: BABYLON.Observable<InputText>;
  79074. /** BABYLON.Observable raised when a key event was processed */
  79075. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79076. /** Gets or sets the maximum width allowed by the control */
  79077. get maxWidth(): string | number;
  79078. /** Gets the maximum width allowed by the control in pixels */
  79079. get maxWidthInPixels(): number;
  79080. set maxWidth(value: string | number);
  79081. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79082. get highligherOpacity(): number;
  79083. set highligherOpacity(value: number);
  79084. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79085. get onFocusSelectAll(): boolean;
  79086. set onFocusSelectAll(value: boolean);
  79087. /** Gets or sets the text hightlight color */
  79088. get textHighlightColor(): string;
  79089. set textHighlightColor(value: string);
  79090. /** Gets or sets control margin */
  79091. get margin(): string;
  79092. /** Gets control margin in pixels */
  79093. get marginInPixels(): number;
  79094. set margin(value: string);
  79095. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79096. get autoStretchWidth(): boolean;
  79097. set autoStretchWidth(value: boolean);
  79098. /** Gets or sets border thickness */
  79099. get thickness(): number;
  79100. set thickness(value: number);
  79101. /** Gets or sets the background color when focused */
  79102. get focusedBackground(): string;
  79103. set focusedBackground(value: string);
  79104. /** Gets or sets the background color when focused */
  79105. get focusedColor(): string;
  79106. set focusedColor(value: string);
  79107. /** Gets or sets the background color */
  79108. get background(): string;
  79109. set background(value: string);
  79110. /** Gets or sets the placeholder color */
  79111. get placeholderColor(): string;
  79112. set placeholderColor(value: string);
  79113. /** Gets or sets the text displayed when the control is empty */
  79114. get placeholderText(): string;
  79115. set placeholderText(value: string);
  79116. /** Gets or sets the dead key flag */
  79117. get deadKey(): boolean;
  79118. set deadKey(flag: boolean);
  79119. /** Gets or sets the highlight text */
  79120. get highlightedText(): string;
  79121. set highlightedText(text: string);
  79122. /** Gets or sets if the current key should be added */
  79123. get addKey(): boolean;
  79124. set addKey(flag: boolean);
  79125. /** Gets or sets the value of the current key being entered */
  79126. get currentKey(): string;
  79127. set currentKey(key: string);
  79128. /** Gets or sets the text displayed in the control */
  79129. get text(): string;
  79130. set text(value: string);
  79131. /** Gets or sets control width */
  79132. get width(): string | number;
  79133. set width(value: string | number);
  79134. /**
  79135. * Creates a new InputText
  79136. * @param name defines the control name
  79137. * @param text defines the text of the control
  79138. */
  79139. constructor(name?: string | undefined, text?: string);
  79140. /** @hidden */
  79141. onBlur(): void;
  79142. /** @hidden */
  79143. onFocus(): void;
  79144. protected _getTypeName(): string;
  79145. /**
  79146. * Function called to get the list of controls that should not steal the focus from this control
  79147. * @returns an array of controls
  79148. */
  79149. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79150. /** @hidden */
  79151. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79152. /** @hidden */
  79153. private _updateValueFromCursorIndex;
  79154. /** @hidden */
  79155. private _processDblClick;
  79156. /** @hidden */
  79157. private _selectAllText;
  79158. /**
  79159. * Handles the keyboard event
  79160. * @param evt Defines the KeyboardEvent
  79161. */
  79162. processKeyboard(evt: KeyboardEvent): void;
  79163. /** @hidden */
  79164. private _onCopyText;
  79165. /** @hidden */
  79166. private _onCutText;
  79167. /** @hidden */
  79168. private _onPasteText;
  79169. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79170. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79171. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79172. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79173. protected _beforeRenderText(text: string): string;
  79174. dispose(): void;
  79175. }
  79176. }
  79177. declare module BABYLON.GUI {
  79178. /**
  79179. * Class used to create a 2D grid container
  79180. */
  79181. export class Grid extends Container {
  79182. name?: string | undefined;
  79183. private _rowDefinitions;
  79184. private _columnDefinitions;
  79185. private _cells;
  79186. private _childControls;
  79187. /**
  79188. * Gets the number of columns
  79189. */
  79190. get columnCount(): number;
  79191. /**
  79192. * Gets the number of rows
  79193. */
  79194. get rowCount(): number;
  79195. /** Gets the list of children */
  79196. get children(): Control[];
  79197. /** Gets the list of cells (e.g. the containers) */
  79198. get cells(): {
  79199. [key: string]: Container;
  79200. };
  79201. /**
  79202. * Gets the definition of a specific row
  79203. * @param index defines the index of the row
  79204. * @returns the row definition
  79205. */
  79206. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79207. /**
  79208. * Gets the definition of a specific column
  79209. * @param index defines the index of the column
  79210. * @returns the column definition
  79211. */
  79212. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79213. /**
  79214. * Adds a new row to the grid
  79215. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79216. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79217. * @returns the current grid
  79218. */
  79219. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79220. /**
  79221. * Adds a new column to the grid
  79222. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79223. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79224. * @returns the current grid
  79225. */
  79226. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79227. /**
  79228. * Update a row definition
  79229. * @param index defines the index of the row to update
  79230. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79231. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79232. * @returns the current grid
  79233. */
  79234. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79235. /**
  79236. * Update a column definition
  79237. * @param index defines the index of the column to update
  79238. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79239. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79240. * @returns the current grid
  79241. */
  79242. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79243. /**
  79244. * Gets the list of children stored in a specific cell
  79245. * @param row defines the row to check
  79246. * @param column defines the column to check
  79247. * @returns the list of controls
  79248. */
  79249. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79250. /**
  79251. * Gets a string representing the child cell info (row x column)
  79252. * @param child defines the control to get info from
  79253. * @returns a string containing the child cell info (row x column)
  79254. */
  79255. getChildCellInfo(child: Control): string;
  79256. private _removeCell;
  79257. private _offsetCell;
  79258. /**
  79259. * Remove a column definition at specified index
  79260. * @param index defines the index of the column to remove
  79261. * @returns the current grid
  79262. */
  79263. removeColumnDefinition(index: number): Grid;
  79264. /**
  79265. * Remove a row definition at specified index
  79266. * @param index defines the index of the row to remove
  79267. * @returns the current grid
  79268. */
  79269. removeRowDefinition(index: number): Grid;
  79270. /**
  79271. * Adds a new control to the current grid
  79272. * @param control defines the control to add
  79273. * @param row defines the row where to add the control (0 by default)
  79274. * @param column defines the column where to add the control (0 by default)
  79275. * @returns the current grid
  79276. */
  79277. addControl(control: Control, row?: number, column?: number): Grid;
  79278. /**
  79279. * Removes a control from the current container
  79280. * @param control defines the control to remove
  79281. * @returns the current container
  79282. */
  79283. removeControl(control: Control): Container;
  79284. /**
  79285. * Creates a new Grid
  79286. * @param name defines control name
  79287. */
  79288. constructor(name?: string | undefined);
  79289. protected _getTypeName(): string;
  79290. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79291. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79292. _flagDescendantsAsMatrixDirty(): void;
  79293. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79294. /** Releases associated resources */
  79295. dispose(): void;
  79296. }
  79297. }
  79298. declare module BABYLON.GUI {
  79299. /** Class used to create color pickers */
  79300. export class ColorPicker extends Control {
  79301. name?: string | undefined;
  79302. private static _Epsilon;
  79303. private _colorWheelCanvas;
  79304. private _value;
  79305. private _tmpColor;
  79306. private _pointerStartedOnSquare;
  79307. private _pointerStartedOnWheel;
  79308. private _squareLeft;
  79309. private _squareTop;
  79310. private _squareSize;
  79311. private _h;
  79312. private _s;
  79313. private _v;
  79314. private _lastPointerDownID;
  79315. /**
  79316. * BABYLON.Observable raised when the value changes
  79317. */
  79318. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79319. /** Gets or sets the color of the color picker */
  79320. get value(): BABYLON.Color3;
  79321. set value(value: BABYLON.Color3);
  79322. /**
  79323. * Gets or sets control width
  79324. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79325. */
  79326. get width(): string | number;
  79327. set width(value: string | number);
  79328. /**
  79329. * Gets or sets control height
  79330. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79331. */
  79332. get height(): string | number;
  79333. /** Gets or sets control height */
  79334. set height(value: string | number);
  79335. /** Gets or sets control size */
  79336. get size(): string | number;
  79337. set size(value: string | number);
  79338. /**
  79339. * Creates a new ColorPicker
  79340. * @param name defines the control name
  79341. */
  79342. constructor(name?: string | undefined);
  79343. protected _getTypeName(): string;
  79344. /** @hidden */
  79345. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79346. private _updateSquareProps;
  79347. private _drawGradientSquare;
  79348. private _drawCircle;
  79349. private _createColorWheelCanvas;
  79350. /** @hidden */
  79351. _draw(context: CanvasRenderingContext2D): void;
  79352. private _pointerIsDown;
  79353. private _updateValueFromPointer;
  79354. private _isPointOnSquare;
  79355. private _isPointOnWheel;
  79356. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79357. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79358. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79359. _onCanvasBlur(): void;
  79360. /**
  79361. * This function expands the color picker by creating a color picker dialog with manual
  79362. * color value input and the ability to save colors into an array to be used later in
  79363. * subsequent launches of the dialogue.
  79364. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79365. * @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.
  79366. * @returns picked color as a hex string and the saved colors array as hex strings.
  79367. */
  79368. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79369. pickerWidth?: string;
  79370. pickerHeight?: string;
  79371. headerHeight?: string;
  79372. lastColor?: string;
  79373. swatchLimit?: number;
  79374. numSwatchesPerLine?: number;
  79375. savedColors?: Array<string>;
  79376. }): Promise<{
  79377. savedColors?: string[];
  79378. pickedColor: string;
  79379. }>;
  79380. }
  79381. }
  79382. declare module BABYLON.GUI {
  79383. /** Class used to create 2D ellipse containers */
  79384. export class Ellipse extends Container {
  79385. name?: string | undefined;
  79386. private _thickness;
  79387. /** Gets or sets border thickness */
  79388. get thickness(): number;
  79389. set thickness(value: number);
  79390. /**
  79391. * Creates a new Ellipse
  79392. * @param name defines the control name
  79393. */
  79394. constructor(name?: string | undefined);
  79395. protected _getTypeName(): string;
  79396. protected _localDraw(context: CanvasRenderingContext2D): void;
  79397. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79398. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79399. }
  79400. }
  79401. declare module BABYLON.GUI {
  79402. /**
  79403. * Class used to create a password control
  79404. */
  79405. export class InputPassword extends InputText {
  79406. protected _beforeRenderText(text: string): string;
  79407. }
  79408. }
  79409. declare module BABYLON.GUI {
  79410. /** Class used to render 2D lines */
  79411. export class Line extends Control {
  79412. name?: string | undefined;
  79413. private _lineWidth;
  79414. private _x1;
  79415. private _y1;
  79416. private _x2;
  79417. private _y2;
  79418. private _dash;
  79419. private _connectedControl;
  79420. private _connectedControlDirtyObserver;
  79421. /** Gets or sets the dash pattern */
  79422. get dash(): Array<number>;
  79423. set dash(value: Array<number>);
  79424. /** Gets or sets the control connected with the line end */
  79425. get connectedControl(): Control;
  79426. set connectedControl(value: Control);
  79427. /** Gets or sets start coordinates on X axis */
  79428. get x1(): string | number;
  79429. set x1(value: string | number);
  79430. /** Gets or sets start coordinates on Y axis */
  79431. get y1(): string | number;
  79432. set y1(value: string | number);
  79433. /** Gets or sets end coordinates on X axis */
  79434. get x2(): string | number;
  79435. set x2(value: string | number);
  79436. /** Gets or sets end coordinates on Y axis */
  79437. get y2(): string | number;
  79438. set y2(value: string | number);
  79439. /** Gets or sets line width */
  79440. get lineWidth(): number;
  79441. set lineWidth(value: number);
  79442. /** Gets or sets horizontal alignment */
  79443. set horizontalAlignment(value: number);
  79444. /** Gets or sets vertical alignment */
  79445. set verticalAlignment(value: number);
  79446. private get _effectiveX2();
  79447. private get _effectiveY2();
  79448. /**
  79449. * Creates a new Line
  79450. * @param name defines the control name
  79451. */
  79452. constructor(name?: string | undefined);
  79453. protected _getTypeName(): string;
  79454. _draw(context: CanvasRenderingContext2D): void;
  79455. _measure(): void;
  79456. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79457. /**
  79458. * Move one end of the line given 3D cartesian coordinates.
  79459. * @param position Targeted world position
  79460. * @param scene BABYLON.Scene
  79461. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79462. */
  79463. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79464. /**
  79465. * Move one end of the line to a position in screen absolute space.
  79466. * @param projectedPosition Position in screen absolute space (X, Y)
  79467. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79468. */
  79469. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79470. }
  79471. }
  79472. declare module BABYLON.GUI {
  79473. /**
  79474. * Class used to store a point for a MultiLine object.
  79475. * The point can be pure 2D coordinates, a mesh or a control
  79476. */
  79477. export class MultiLinePoint {
  79478. private _multiLine;
  79479. private _x;
  79480. private _y;
  79481. private _control;
  79482. private _mesh;
  79483. private _controlObserver;
  79484. private _meshObserver;
  79485. /** @hidden */
  79486. _point: BABYLON.Vector2;
  79487. /**
  79488. * Creates a new MultiLinePoint
  79489. * @param multiLine defines the source MultiLine object
  79490. */
  79491. constructor(multiLine: MultiLine);
  79492. /** Gets or sets x coordinate */
  79493. get x(): string | number;
  79494. set x(value: string | number);
  79495. /** Gets or sets y coordinate */
  79496. get y(): string | number;
  79497. set y(value: string | number);
  79498. /** Gets or sets the control associated with this point */
  79499. get control(): BABYLON.Nullable<Control>;
  79500. set control(value: BABYLON.Nullable<Control>);
  79501. /** Gets or sets the mesh associated with this point */
  79502. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79503. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  79504. /** Resets links */
  79505. resetLinks(): void;
  79506. /**
  79507. * Gets a translation vector
  79508. * @returns the translation vector
  79509. */
  79510. translate(): BABYLON.Vector2;
  79511. private _translatePoint;
  79512. /** Release associated resources */
  79513. dispose(): void;
  79514. }
  79515. }
  79516. declare module BABYLON.GUI {
  79517. /**
  79518. * Class used to create multi line control
  79519. */
  79520. export class MultiLine extends Control {
  79521. name?: string | undefined;
  79522. private _lineWidth;
  79523. private _dash;
  79524. private _points;
  79525. private _minX;
  79526. private _minY;
  79527. private _maxX;
  79528. private _maxY;
  79529. /**
  79530. * Creates a new MultiLine
  79531. * @param name defines the control name
  79532. */
  79533. constructor(name?: string | undefined);
  79534. /** Gets or sets dash pattern */
  79535. get dash(): Array<number>;
  79536. set dash(value: Array<number>);
  79537. /**
  79538. * Gets point stored at specified index
  79539. * @param index defines the index to look for
  79540. * @returns the requested point if found
  79541. */
  79542. getAt(index: number): MultiLinePoint;
  79543. /** Function called when a point is updated */
  79544. onPointUpdate: () => void;
  79545. /**
  79546. * Adds new points to the point collection
  79547. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  79548. * @returns the list of created MultiLinePoint
  79549. */
  79550. add(...items: (AbstractMesh | Control | {
  79551. x: string | number;
  79552. y: string | number;
  79553. })[]): MultiLinePoint[];
  79554. /**
  79555. * Adds a new point to the point collection
  79556. * @param item defines the item (mesh, control or 2d coordiantes) to add
  79557. * @returns the created MultiLinePoint
  79558. */
  79559. push(item?: (AbstractMesh | Control | {
  79560. x: string | number;
  79561. y: string | number;
  79562. })): MultiLinePoint;
  79563. /**
  79564. * Remove a specific value or point from the active point collection
  79565. * @param value defines the value or point to remove
  79566. */
  79567. remove(value: number | MultiLinePoint): void;
  79568. /**
  79569. * Resets this object to initial state (no point)
  79570. */
  79571. reset(): void;
  79572. /**
  79573. * Resets all links
  79574. */
  79575. resetLinks(): void;
  79576. /** Gets or sets line width */
  79577. get lineWidth(): number;
  79578. set lineWidth(value: number);
  79579. set horizontalAlignment(value: number);
  79580. set verticalAlignment(value: number);
  79581. protected _getTypeName(): string;
  79582. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79583. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79584. _measure(): void;
  79585. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79586. dispose(): void;
  79587. }
  79588. }
  79589. declare module BABYLON.GUI {
  79590. /**
  79591. * Class used to create radio button controls
  79592. */
  79593. export class RadioButton extends Control {
  79594. name?: string | undefined;
  79595. private _isChecked;
  79596. private _background;
  79597. private _checkSizeRatio;
  79598. private _thickness;
  79599. /** Gets or sets border thickness */
  79600. get thickness(): number;
  79601. set thickness(value: number);
  79602. /** Gets or sets group name */
  79603. group: string;
  79604. /** BABYLON.Observable raised when isChecked is changed */
  79605. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79606. /** Gets or sets a value indicating the ratio between overall size and check size */
  79607. get checkSizeRatio(): number;
  79608. set checkSizeRatio(value: number);
  79609. /** Gets or sets background color */
  79610. get background(): string;
  79611. set background(value: string);
  79612. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79613. get isChecked(): boolean;
  79614. set isChecked(value: boolean);
  79615. /**
  79616. * Creates a new RadioButton
  79617. * @param name defines the control name
  79618. */
  79619. constructor(name?: string | undefined);
  79620. protected _getTypeName(): string;
  79621. _draw(context: CanvasRenderingContext2D): void;
  79622. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79623. /**
  79624. * Utility function to easily create a radio button with a header
  79625. * @param title defines the label to use for the header
  79626. * @param group defines the group to use for the radio button
  79627. * @param isChecked defines the initial state of the radio button
  79628. * @param onValueChanged defines the callback to call when value changes
  79629. * @returns a StackPanel containing the radio button and a textBlock
  79630. */
  79631. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  79632. }
  79633. }
  79634. declare module BABYLON.GUI {
  79635. /**
  79636. * Class used to create slider controls
  79637. */
  79638. export class BaseSlider extends Control {
  79639. name?: string | undefined;
  79640. protected _thumbWidth: ValueAndUnit;
  79641. private _minimum;
  79642. private _maximum;
  79643. private _value;
  79644. private _isVertical;
  79645. protected _barOffset: ValueAndUnit;
  79646. private _isThumbClamped;
  79647. protected _displayThumb: boolean;
  79648. private _step;
  79649. private _lastPointerDownID;
  79650. protected _effectiveBarOffset: number;
  79651. protected _renderLeft: number;
  79652. protected _renderTop: number;
  79653. protected _renderWidth: number;
  79654. protected _renderHeight: number;
  79655. protected _backgroundBoxLength: number;
  79656. protected _backgroundBoxThickness: number;
  79657. protected _effectiveThumbThickness: number;
  79658. /** BABYLON.Observable raised when the sldier value changes */
  79659. onValueChangedObservable: BABYLON.Observable<number>;
  79660. /** Gets or sets a boolean indicating if the thumb must be rendered */
  79661. get displayThumb(): boolean;
  79662. set displayThumb(value: boolean);
  79663. /** Gets or sets a step to apply to values (0 by default) */
  79664. get step(): number;
  79665. set step(value: number);
  79666. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  79667. get barOffset(): string | number;
  79668. /** Gets main bar offset in pixels*/
  79669. get barOffsetInPixels(): number;
  79670. set barOffset(value: string | number);
  79671. /** Gets or sets thumb width */
  79672. get thumbWidth(): string | number;
  79673. /** Gets thumb width in pixels */
  79674. get thumbWidthInPixels(): number;
  79675. set thumbWidth(value: string | number);
  79676. /** Gets or sets minimum value */
  79677. get minimum(): number;
  79678. set minimum(value: number);
  79679. /** Gets or sets maximum value */
  79680. get maximum(): number;
  79681. set maximum(value: number);
  79682. /** Gets or sets current value */
  79683. get value(): number;
  79684. set value(value: number);
  79685. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  79686. get isVertical(): boolean;
  79687. set isVertical(value: boolean);
  79688. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  79689. get isThumbClamped(): boolean;
  79690. set isThumbClamped(value: boolean);
  79691. /**
  79692. * Creates a new BaseSlider
  79693. * @param name defines the control name
  79694. */
  79695. constructor(name?: string | undefined);
  79696. protected _getTypeName(): string;
  79697. protected _getThumbPosition(): number;
  79698. protected _getThumbThickness(type: string): number;
  79699. protected _prepareRenderingData(type: string): void;
  79700. private _pointerIsDown;
  79701. /** @hidden */
  79702. protected _updateValueFromPointer(x: number, y: number): void;
  79703. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79704. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79705. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79706. _onCanvasBlur(): void;
  79707. }
  79708. }
  79709. declare module BABYLON.GUI {
  79710. /**
  79711. * Class used to create slider controls
  79712. */
  79713. export class Slider extends BaseSlider {
  79714. name?: string | undefined;
  79715. private _background;
  79716. private _borderColor;
  79717. private _thumbColor;
  79718. private _isThumbCircle;
  79719. protected _displayValueBar: boolean;
  79720. /** Gets or sets a boolean indicating if the value bar must be rendered */
  79721. get displayValueBar(): boolean;
  79722. set displayValueBar(value: boolean);
  79723. /** Gets or sets border color */
  79724. get borderColor(): string;
  79725. set borderColor(value: string);
  79726. /** Gets or sets background color */
  79727. get background(): string;
  79728. set background(value: string);
  79729. /** Gets or sets thumb's color */
  79730. get thumbColor(): string;
  79731. set thumbColor(value: string);
  79732. /** Gets or sets a boolean indicating if the thumb should be round or square */
  79733. get isThumbCircle(): boolean;
  79734. set isThumbCircle(value: boolean);
  79735. /**
  79736. * Creates a new Slider
  79737. * @param name defines the control name
  79738. */
  79739. constructor(name?: string | undefined);
  79740. protected _getTypeName(): string;
  79741. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79742. }
  79743. }
  79744. declare module BABYLON.GUI {
  79745. /** Class used to create a RadioGroup
  79746. * which contains groups of radio buttons
  79747. */
  79748. export class SelectorGroup {
  79749. /** name of SelectorGroup */
  79750. name: string;
  79751. private _groupPanel;
  79752. private _selectors;
  79753. private _groupHeader;
  79754. /**
  79755. * Creates a new SelectorGroup
  79756. * @param name of group, used as a group heading
  79757. */
  79758. constructor(
  79759. /** name of SelectorGroup */
  79760. name: string);
  79761. /** Gets the groupPanel of the SelectorGroup */
  79762. get groupPanel(): StackPanel;
  79763. /** Gets the selectors array */
  79764. get selectors(): StackPanel[];
  79765. /** Gets and sets the group header */
  79766. get header(): string;
  79767. set header(label: string);
  79768. /** @hidden */
  79769. private _addGroupHeader;
  79770. /** @hidden*/
  79771. _getSelector(selectorNb: number): StackPanel | undefined;
  79772. /** Removes the selector at the given position
  79773. * @param selectorNb the position of the selector within the group
  79774. */
  79775. removeSelector(selectorNb: number): void;
  79776. }
  79777. /** Class used to create a CheckboxGroup
  79778. * which contains groups of checkbox buttons
  79779. */
  79780. export class CheckboxGroup extends SelectorGroup {
  79781. /** Adds a checkbox as a control
  79782. * @param text is the label for the selector
  79783. * @param func is the function called when the Selector is checked
  79784. * @param checked is true when Selector is checked
  79785. */
  79786. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  79787. /** @hidden */
  79788. _setSelectorLabel(selectorNb: number, label: string): void;
  79789. /** @hidden */
  79790. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79791. /** @hidden */
  79792. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79793. /** @hidden */
  79794. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79795. }
  79796. /** Class used to create a RadioGroup
  79797. * which contains groups of radio buttons
  79798. */
  79799. export class RadioGroup extends SelectorGroup {
  79800. private _selectNb;
  79801. /** Adds a radio button as a control
  79802. * @param label is the label for the selector
  79803. * @param func is the function called when the Selector is checked
  79804. * @param checked is true when Selector is checked
  79805. */
  79806. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  79807. /** @hidden */
  79808. _setSelectorLabel(selectorNb: number, label: string): void;
  79809. /** @hidden */
  79810. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79811. /** @hidden */
  79812. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79813. /** @hidden */
  79814. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79815. }
  79816. /** Class used to create a SliderGroup
  79817. * which contains groups of slider buttons
  79818. */
  79819. export class SliderGroup extends SelectorGroup {
  79820. /**
  79821. * Adds a slider to the SelectorGroup
  79822. * @param label is the label for the SliderBar
  79823. * @param func is the function called when the Slider moves
  79824. * @param unit is a string describing the units used, eg degrees or metres
  79825. * @param min is the minimum value for the Slider
  79826. * @param max is the maximum value for the Slider
  79827. * @param value is the start value for the Slider between min and max
  79828. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  79829. */
  79830. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  79831. /** @hidden */
  79832. _setSelectorLabel(selectorNb: number, label: string): void;
  79833. /** @hidden */
  79834. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79835. /** @hidden */
  79836. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79837. /** @hidden */
  79838. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79839. }
  79840. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  79841. * @see https://doc.babylonjs.com/how_to/selector
  79842. */
  79843. export class SelectionPanel extends Rectangle {
  79844. /** name of SelectionPanel */
  79845. name: string;
  79846. /** an array of SelectionGroups */
  79847. groups: SelectorGroup[];
  79848. private _panel;
  79849. private _buttonColor;
  79850. private _buttonBackground;
  79851. private _headerColor;
  79852. private _barColor;
  79853. private _barHeight;
  79854. private _spacerHeight;
  79855. private _labelColor;
  79856. private _groups;
  79857. private _bars;
  79858. /**
  79859. * Creates a new SelectionPanel
  79860. * @param name of SelectionPanel
  79861. * @param groups is an array of SelectionGroups
  79862. */
  79863. constructor(
  79864. /** name of SelectionPanel */
  79865. name: string,
  79866. /** an array of SelectionGroups */
  79867. groups?: SelectorGroup[]);
  79868. protected _getTypeName(): string;
  79869. /** Gets the (stack) panel of the SelectionPanel */
  79870. get panel(): StackPanel;
  79871. /** Gets or sets the headerColor */
  79872. get headerColor(): string;
  79873. set headerColor(color: string);
  79874. private _setHeaderColor;
  79875. /** Gets or sets the button color */
  79876. get buttonColor(): string;
  79877. set buttonColor(color: string);
  79878. private _setbuttonColor;
  79879. /** Gets or sets the label color */
  79880. get labelColor(): string;
  79881. set labelColor(color: string);
  79882. private _setLabelColor;
  79883. /** Gets or sets the button background */
  79884. get buttonBackground(): string;
  79885. set buttonBackground(color: string);
  79886. private _setButtonBackground;
  79887. /** Gets or sets the color of separator bar */
  79888. get barColor(): string;
  79889. set barColor(color: string);
  79890. private _setBarColor;
  79891. /** Gets or sets the height of separator bar */
  79892. get barHeight(): string;
  79893. set barHeight(value: string);
  79894. private _setBarHeight;
  79895. /** Gets or sets the height of spacers*/
  79896. get spacerHeight(): string;
  79897. set spacerHeight(value: string);
  79898. private _setSpacerHeight;
  79899. /** Adds a bar between groups */
  79900. private _addSpacer;
  79901. /** Add a group to the selection panel
  79902. * @param group is the selector group to add
  79903. */
  79904. addGroup(group: SelectorGroup): void;
  79905. /** Remove the group from the given position
  79906. * @param groupNb is the position of the group in the list
  79907. */
  79908. removeGroup(groupNb: number): void;
  79909. /** Change a group header label
  79910. * @param label is the new group header label
  79911. * @param groupNb is the number of the group to relabel
  79912. * */
  79913. setHeaderName(label: string, groupNb: number): void;
  79914. /** Change selector label to the one given
  79915. * @param label is the new selector label
  79916. * @param groupNb is the number of the groupcontaining the selector
  79917. * @param selectorNb is the number of the selector within a group to relabel
  79918. * */
  79919. relabel(label: string, groupNb: number, selectorNb: number): void;
  79920. /** For a given group position remove the selector at the given position
  79921. * @param groupNb is the number of the group to remove the selector from
  79922. * @param selectorNb is the number of the selector within the group
  79923. */
  79924. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  79925. /** For a given group position of correct type add a checkbox button
  79926. * @param groupNb is the number of the group to remove the selector from
  79927. * @param label is the label for the selector
  79928. * @param func is the function called when the Selector is checked
  79929. * @param checked is true when Selector is checked
  79930. */
  79931. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79932. /** For a given group position of correct type add a radio button
  79933. * @param groupNb is the number of the group to remove the selector from
  79934. * @param label is the label for the selector
  79935. * @param func is the function called when the Selector is checked
  79936. * @param checked is true when Selector is checked
  79937. */
  79938. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79939. /**
  79940. * For a given slider group add a slider
  79941. * @param groupNb is the number of the group to add the slider to
  79942. * @param label is the label for the Slider
  79943. * @param func is the function called when the Slider moves
  79944. * @param unit is a string describing the units used, eg degrees or metres
  79945. * @param min is the minimum value for the Slider
  79946. * @param max is the maximum value for the Slider
  79947. * @param value is the start value for the Slider between min and max
  79948. * @param onVal is the function used to format the value displayed, eg radians to degrees
  79949. */
  79950. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  79951. }
  79952. }
  79953. declare module BABYLON.GUI {
  79954. /**
  79955. * Class used to hold a the container for ScrollViewer
  79956. * @hidden
  79957. */
  79958. export class _ScrollViewerWindow extends Container {
  79959. parentClientWidth: number;
  79960. parentClientHeight: number;
  79961. private _freezeControls;
  79962. private _parentMeasure;
  79963. private _oldLeft;
  79964. private _oldTop;
  79965. get freezeControls(): boolean;
  79966. set freezeControls(value: boolean);
  79967. private _bucketWidth;
  79968. private _bucketHeight;
  79969. private _buckets;
  79970. private _bucketLen;
  79971. get bucketWidth(): number;
  79972. get bucketHeight(): number;
  79973. setBucketSizes(width: number, height: number): void;
  79974. private _useBuckets;
  79975. private _makeBuckets;
  79976. private _dispatchInBuckets;
  79977. private _updateMeasures;
  79978. private _updateChildrenMeasures;
  79979. private _restoreMeasures;
  79980. /**
  79981. * Creates a new ScrollViewerWindow
  79982. * @param name of ScrollViewerWindow
  79983. */
  79984. constructor(name?: string);
  79985. protected _getTypeName(): string;
  79986. /** @hidden */
  79987. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79988. /** @hidden */
  79989. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79990. private _scrollChildren;
  79991. private _scrollChildrenWithBuckets;
  79992. /** @hidden */
  79993. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79994. protected _postMeasure(): void;
  79995. }
  79996. }
  79997. declare module BABYLON.GUI {
  79998. /**
  79999. * Class used to create slider controls
  80000. */
  80001. export class ScrollBar extends BaseSlider {
  80002. name?: string | undefined;
  80003. private _background;
  80004. private _borderColor;
  80005. private _tempMeasure;
  80006. /** Gets or sets border color */
  80007. get borderColor(): string;
  80008. set borderColor(value: string);
  80009. /** Gets or sets background color */
  80010. get background(): string;
  80011. set background(value: string);
  80012. /**
  80013. * Creates a new Slider
  80014. * @param name defines the control name
  80015. */
  80016. constructor(name?: string | undefined);
  80017. protected _getTypeName(): string;
  80018. protected _getThumbThickness(): number;
  80019. _draw(context: CanvasRenderingContext2D): void;
  80020. private _first;
  80021. private _originX;
  80022. private _originY;
  80023. /** @hidden */
  80024. protected _updateValueFromPointer(x: number, y: number): void;
  80025. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80026. }
  80027. }
  80028. declare module BABYLON.GUI {
  80029. /**
  80030. * Class used to create slider controls
  80031. */
  80032. export class ImageScrollBar extends BaseSlider {
  80033. name?: string | undefined;
  80034. private _backgroundBaseImage;
  80035. private _backgroundImage;
  80036. private _thumbImage;
  80037. private _thumbBaseImage;
  80038. private _thumbLength;
  80039. private _thumbHeight;
  80040. private _barImageHeight;
  80041. private _tempMeasure;
  80042. /** Number of 90° rotation to apply on the images when in vertical mode */
  80043. num90RotationInVerticalMode: number;
  80044. /**
  80045. * Gets or sets the image used to render the background for horizontal bar
  80046. */
  80047. get backgroundImage(): Image;
  80048. set backgroundImage(value: Image);
  80049. /**
  80050. * Gets or sets the image used to render the thumb
  80051. */
  80052. get thumbImage(): Image;
  80053. set thumbImage(value: Image);
  80054. /**
  80055. * Gets or sets the length of the thumb
  80056. */
  80057. get thumbLength(): number;
  80058. set thumbLength(value: number);
  80059. /**
  80060. * Gets or sets the height of the thumb
  80061. */
  80062. get thumbHeight(): number;
  80063. set thumbHeight(value: number);
  80064. /**
  80065. * Gets or sets the height of the bar image
  80066. */
  80067. get barImageHeight(): number;
  80068. set barImageHeight(value: number);
  80069. /**
  80070. * Creates a new ImageScrollBar
  80071. * @param name defines the control name
  80072. */
  80073. constructor(name?: string | undefined);
  80074. protected _getTypeName(): string;
  80075. protected _getThumbThickness(): number;
  80076. _draw(context: CanvasRenderingContext2D): void;
  80077. private _first;
  80078. private _originX;
  80079. private _originY;
  80080. /** @hidden */
  80081. protected _updateValueFromPointer(x: number, y: number): void;
  80082. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80083. }
  80084. }
  80085. declare module BABYLON.GUI {
  80086. /**
  80087. * Class used to hold a viewer window and sliders in a grid
  80088. */
  80089. export class ScrollViewer extends Rectangle {
  80090. private _grid;
  80091. private _horizontalBarSpace;
  80092. private _verticalBarSpace;
  80093. private _dragSpace;
  80094. private _horizontalBar;
  80095. private _verticalBar;
  80096. private _barColor;
  80097. private _barBackground;
  80098. private _barImage;
  80099. private _horizontalBarImage;
  80100. private _verticalBarImage;
  80101. private _barBackgroundImage;
  80102. private _horizontalBarBackgroundImage;
  80103. private _verticalBarBackgroundImage;
  80104. private _barSize;
  80105. private _window;
  80106. private _pointerIsOver;
  80107. private _wheelPrecision;
  80108. private _onWheelObserver;
  80109. private _clientWidth;
  80110. private _clientHeight;
  80111. private _useImageBar;
  80112. private _thumbLength;
  80113. private _thumbHeight;
  80114. private _barImageHeight;
  80115. private _horizontalBarImageHeight;
  80116. private _verticalBarImageHeight;
  80117. private _oldWindowContentsWidth;
  80118. private _oldWindowContentsHeight;
  80119. /**
  80120. * Gets the horizontal scrollbar
  80121. */
  80122. get horizontalBar(): ScrollBar | ImageScrollBar;
  80123. /**
  80124. * Gets the vertical scrollbar
  80125. */
  80126. get verticalBar(): ScrollBar | ImageScrollBar;
  80127. /**
  80128. * Adds a new control to the current container
  80129. * @param control defines the control to add
  80130. * @returns the current container
  80131. */
  80132. addControl(control: BABYLON.Nullable<Control>): Container;
  80133. /**
  80134. * Removes a control from the current container
  80135. * @param control defines the control to remove
  80136. * @returns the current container
  80137. */
  80138. removeControl(control: Control): Container;
  80139. /** Gets the list of children */
  80140. get children(): Control[];
  80141. _flagDescendantsAsMatrixDirty(): void;
  80142. /**
  80143. * Freezes or unfreezes the controls in the window.
  80144. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80145. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80146. */
  80147. get freezeControls(): boolean;
  80148. set freezeControls(value: boolean);
  80149. /** Gets the bucket width */
  80150. get bucketWidth(): number;
  80151. /** Gets the bucket height */
  80152. get bucketHeight(): number;
  80153. /**
  80154. * Sets the bucket sizes.
  80155. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80156. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80157. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80158. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80159. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80160. * used), that's why it is not enabled by default.
  80161. * @param width width of the bucket
  80162. * @param height height of the bucket
  80163. */
  80164. setBucketSizes(width: number, height: number): void;
  80165. private _forceHorizontalBar;
  80166. private _forceVerticalBar;
  80167. /**
  80168. * Forces the horizontal scroll bar to be displayed
  80169. */
  80170. get forceHorizontalBar(): boolean;
  80171. set forceHorizontalBar(value: boolean);
  80172. /**
  80173. * Forces the vertical scroll bar to be displayed
  80174. */
  80175. get forceVerticalBar(): boolean;
  80176. set forceVerticalBar(value: boolean);
  80177. /**
  80178. * Creates a new ScrollViewer
  80179. * @param name of ScrollViewer
  80180. */
  80181. constructor(name?: string, isImageBased?: boolean);
  80182. /** Reset the scroll viewer window to initial size */
  80183. resetWindow(): void;
  80184. protected _getTypeName(): string;
  80185. private _buildClientSizes;
  80186. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80187. protected _postMeasure(): void;
  80188. /**
  80189. * Gets or sets the mouse wheel precision
  80190. * from 0 to 1 with a default value of 0.05
  80191. * */
  80192. get wheelPrecision(): number;
  80193. set wheelPrecision(value: number);
  80194. /** Gets or sets the scroll bar container background color */
  80195. get scrollBackground(): string;
  80196. set scrollBackground(color: string);
  80197. /** Gets or sets the bar color */
  80198. get barColor(): string;
  80199. set barColor(color: string);
  80200. /** Gets or sets the bar image */
  80201. get thumbImage(): Image;
  80202. set thumbImage(value: Image);
  80203. /** Gets or sets the horizontal bar image */
  80204. get horizontalThumbImage(): Image;
  80205. set horizontalThumbImage(value: Image);
  80206. /** Gets or sets the vertical bar image */
  80207. get verticalThumbImage(): Image;
  80208. set verticalThumbImage(value: Image);
  80209. /** Gets or sets the size of the bar */
  80210. get barSize(): number;
  80211. set barSize(value: number);
  80212. /** Gets or sets the length of the thumb */
  80213. get thumbLength(): number;
  80214. set thumbLength(value: number);
  80215. /** Gets or sets the height of the thumb */
  80216. get thumbHeight(): number;
  80217. set thumbHeight(value: number);
  80218. /** Gets or sets the height of the bar image */
  80219. get barImageHeight(): number;
  80220. set barImageHeight(value: number);
  80221. /** Gets or sets the height of the horizontal bar image */
  80222. get horizontalBarImageHeight(): number;
  80223. set horizontalBarImageHeight(value: number);
  80224. /** Gets or sets the height of the vertical bar image */
  80225. get verticalBarImageHeight(): number;
  80226. set verticalBarImageHeight(value: number);
  80227. /** Gets or sets the bar background */
  80228. get barBackground(): string;
  80229. set barBackground(color: string);
  80230. /** Gets or sets the bar background image */
  80231. get barImage(): Image;
  80232. set barImage(value: Image);
  80233. /** Gets or sets the horizontal bar background image */
  80234. get horizontalBarImage(): Image;
  80235. set horizontalBarImage(value: Image);
  80236. /** Gets or sets the vertical bar background image */
  80237. get verticalBarImage(): Image;
  80238. set verticalBarImage(value: Image);
  80239. private _setWindowPosition;
  80240. /** @hidden */
  80241. private _updateScroller;
  80242. _link(host: AdvancedDynamicTexture): void;
  80243. /** @hidden */
  80244. private _addBar;
  80245. /** @hidden */
  80246. private _attachWheel;
  80247. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80248. /** Releases associated resources */
  80249. dispose(): void;
  80250. }
  80251. }
  80252. declare module BABYLON.GUI {
  80253. /** Class used to render a grid */
  80254. export class DisplayGrid extends Control {
  80255. name?: string | undefined;
  80256. private _cellWidth;
  80257. private _cellHeight;
  80258. private _minorLineTickness;
  80259. private _minorLineColor;
  80260. private _majorLineTickness;
  80261. private _majorLineColor;
  80262. private _majorLineFrequency;
  80263. private _background;
  80264. private _displayMajorLines;
  80265. private _displayMinorLines;
  80266. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80267. get displayMinorLines(): boolean;
  80268. set displayMinorLines(value: boolean);
  80269. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80270. get displayMajorLines(): boolean;
  80271. set displayMajorLines(value: boolean);
  80272. /** Gets or sets background color (Black by default) */
  80273. get background(): string;
  80274. set background(value: string);
  80275. /** Gets or sets the width of each cell (20 by default) */
  80276. get cellWidth(): number;
  80277. set cellWidth(value: number);
  80278. /** Gets or sets the height of each cell (20 by default) */
  80279. get cellHeight(): number;
  80280. set cellHeight(value: number);
  80281. /** Gets or sets the tickness of minor lines (1 by default) */
  80282. get minorLineTickness(): number;
  80283. set minorLineTickness(value: number);
  80284. /** Gets or sets the color of minor lines (DarkGray by default) */
  80285. get minorLineColor(): string;
  80286. set minorLineColor(value: string);
  80287. /** Gets or sets the tickness of major lines (2 by default) */
  80288. get majorLineTickness(): number;
  80289. set majorLineTickness(value: number);
  80290. /** Gets or sets the color of major lines (White by default) */
  80291. get majorLineColor(): string;
  80292. set majorLineColor(value: string);
  80293. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80294. get majorLineFrequency(): number;
  80295. set majorLineFrequency(value: number);
  80296. /**
  80297. * Creates a new GridDisplayRectangle
  80298. * @param name defines the control name
  80299. */
  80300. constructor(name?: string | undefined);
  80301. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80302. protected _getTypeName(): string;
  80303. }
  80304. }
  80305. declare module BABYLON.GUI {
  80306. /**
  80307. * Class used to create slider controls based on images
  80308. */
  80309. export class ImageBasedSlider extends BaseSlider {
  80310. name?: string | undefined;
  80311. private _backgroundImage;
  80312. private _thumbImage;
  80313. private _valueBarImage;
  80314. private _tempMeasure;
  80315. get displayThumb(): boolean;
  80316. set displayThumb(value: boolean);
  80317. /**
  80318. * Gets or sets the image used to render the background
  80319. */
  80320. get backgroundImage(): Image;
  80321. set backgroundImage(value: Image);
  80322. /**
  80323. * Gets or sets the image used to render the value bar
  80324. */
  80325. get valueBarImage(): Image;
  80326. set valueBarImage(value: Image);
  80327. /**
  80328. * Gets or sets the image used to render the thumb
  80329. */
  80330. get thumbImage(): Image;
  80331. set thumbImage(value: Image);
  80332. /**
  80333. * Creates a new ImageBasedSlider
  80334. * @param name defines the control name
  80335. */
  80336. constructor(name?: string | undefined);
  80337. protected _getTypeName(): string;
  80338. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80339. }
  80340. }
  80341. declare module BABYLON.GUI {
  80342. /**
  80343. * Forcing an export so that this code will execute
  80344. * @hidden
  80345. */
  80346. const name = "Statics";
  80347. }
  80348. declare module BABYLON.GUI {
  80349. /**
  80350. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80351. */
  80352. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80353. /**
  80354. * Define the instrumented AdvancedDynamicTexture.
  80355. */
  80356. texture: AdvancedDynamicTexture;
  80357. private _captureRenderTime;
  80358. private _renderTime;
  80359. private _captureLayoutTime;
  80360. private _layoutTime;
  80361. private _onBeginRenderObserver;
  80362. private _onEndRenderObserver;
  80363. private _onBeginLayoutObserver;
  80364. private _onEndLayoutObserver;
  80365. /**
  80366. * Gets the perf counter used to capture render time
  80367. */
  80368. get renderTimeCounter(): BABYLON.PerfCounter;
  80369. /**
  80370. * Gets the perf counter used to capture layout time
  80371. */
  80372. get layoutTimeCounter(): BABYLON.PerfCounter;
  80373. /**
  80374. * Enable or disable the render time capture
  80375. */
  80376. get captureRenderTime(): boolean;
  80377. set captureRenderTime(value: boolean);
  80378. /**
  80379. * Enable or disable the layout time capture
  80380. */
  80381. get captureLayoutTime(): boolean;
  80382. set captureLayoutTime(value: boolean);
  80383. /**
  80384. * Instantiates a new advanced dynamic texture instrumentation.
  80385. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80386. * @param texture Defines the AdvancedDynamicTexture to instrument
  80387. */
  80388. constructor(
  80389. /**
  80390. * Define the instrumented AdvancedDynamicTexture.
  80391. */
  80392. texture: AdvancedDynamicTexture);
  80393. /**
  80394. * Dispose and release associated resources.
  80395. */
  80396. dispose(): void;
  80397. }
  80398. }
  80399. declare module BABYLON.GUI {
  80400. /**
  80401. * Class used to load GUI via XML.
  80402. */
  80403. export class XmlLoader {
  80404. private _nodes;
  80405. private _nodeTypes;
  80406. private _isLoaded;
  80407. private _objectAttributes;
  80408. private _parentClass;
  80409. /**
  80410. * Create a new xml loader
  80411. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80412. */
  80413. constructor(parentClass?: null);
  80414. private _getChainElement;
  80415. private _getClassAttribute;
  80416. private _createGuiElement;
  80417. private _parseGrid;
  80418. private _parseElement;
  80419. private _prepareSourceElement;
  80420. private _parseElementsFromSource;
  80421. private _parseXml;
  80422. /**
  80423. * Gets if the loading has finished.
  80424. * @returns whether the loading has finished or not
  80425. */
  80426. isLoaded(): boolean;
  80427. /**
  80428. * Gets a loaded node / control by id.
  80429. * @param id the Controls id set in the xml
  80430. * @returns element of type Control
  80431. */
  80432. getNodeById(id: string): any;
  80433. /**
  80434. * Gets all loaded nodes / controls
  80435. * @returns Array of controls
  80436. */
  80437. getNodes(): any;
  80438. /**
  80439. * Initiates the xml layout loading
  80440. * @param xmlFile defines the xml layout to load
  80441. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80442. * @param callback defines the callback called on layout load.
  80443. */
  80444. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80445. }
  80446. }
  80447. declare module BABYLON.GUI {
  80448. /**
  80449. * Class used to create containers for controls
  80450. */
  80451. export class Container3D extends Control3D {
  80452. private _blockLayout;
  80453. /**
  80454. * Gets the list of child controls
  80455. */
  80456. protected _children: Control3D[];
  80457. /**
  80458. * Gets the list of child controls
  80459. */
  80460. get children(): Array<Control3D>;
  80461. /**
  80462. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80463. * This is helpful to optimize layout operation when adding multiple children in a row
  80464. */
  80465. get blockLayout(): boolean;
  80466. set blockLayout(value: boolean);
  80467. /**
  80468. * Creates a new container
  80469. * @param name defines the container name
  80470. */
  80471. constructor(name?: string);
  80472. /**
  80473. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  80474. * @returns the current container
  80475. */
  80476. updateLayout(): Container3D;
  80477. /**
  80478. * Gets a boolean indicating if the given control is in the children of this control
  80479. * @param control defines the control to check
  80480. * @returns true if the control is in the child list
  80481. */
  80482. containsControl(control: Control3D): boolean;
  80483. /**
  80484. * Adds a control to the children of this control
  80485. * @param control defines the control to add
  80486. * @returns the current container
  80487. */
  80488. addControl(control: Control3D): Container3D;
  80489. /**
  80490. * This function will be called everytime a new control is added
  80491. */
  80492. protected _arrangeChildren(): void;
  80493. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80494. /**
  80495. * Removes a control from the children of this control
  80496. * @param control defines the control to remove
  80497. * @returns the current container
  80498. */
  80499. removeControl(control: Control3D): Container3D;
  80500. protected _getTypeName(): string;
  80501. /**
  80502. * Releases all associated resources
  80503. */
  80504. dispose(): void;
  80505. /** Control rotation will remain unchanged */
  80506. static readonly UNSET_ORIENTATION: number;
  80507. /** Control will rotate to make it look at sphere central axis */
  80508. static readonly FACEORIGIN_ORIENTATION: number;
  80509. /** Control will rotate to make it look back at sphere central axis */
  80510. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  80511. /** Control will rotate to look at z axis (0, 0, 1) */
  80512. static readonly FACEFORWARD_ORIENTATION: number;
  80513. /** Control will rotate to look at negative z axis (0, 0, -1) */
  80514. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  80515. }
  80516. }
  80517. declare module BABYLON.GUI {
  80518. /**
  80519. * Class used to manage 3D user interface
  80520. * @see https://doc.babylonjs.com/how_to/gui3d
  80521. */
  80522. export class GUI3DManager implements BABYLON.IDisposable {
  80523. private _scene;
  80524. private _sceneDisposeObserver;
  80525. private _utilityLayer;
  80526. private _rootContainer;
  80527. private _pointerObserver;
  80528. private _pointerOutObserver;
  80529. /** @hidden */
  80530. _lastPickedControl: Control3D;
  80531. /** @hidden */
  80532. _lastControlOver: {
  80533. [pointerId: number]: Control3D;
  80534. };
  80535. /** @hidden */
  80536. _lastControlDown: {
  80537. [pointerId: number]: Control3D;
  80538. };
  80539. /**
  80540. * BABYLON.Observable raised when the point picked by the pointer events changed
  80541. */
  80542. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  80543. /** @hidden */
  80544. _sharedMaterials: {
  80545. [key: string]: BABYLON.Material;
  80546. };
  80547. /** Gets the hosting scene */
  80548. get scene(): BABYLON.Scene;
  80549. /** Gets associated utility layer */
  80550. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  80551. /**
  80552. * Creates a new GUI3DManager
  80553. * @param scene
  80554. */
  80555. constructor(scene?: BABYLON.Scene);
  80556. private _handlePointerOut;
  80557. private _doPicking;
  80558. /**
  80559. * Gets the root container
  80560. */
  80561. get rootContainer(): Container3D;
  80562. /**
  80563. * Gets a boolean indicating if the given control is in the root child list
  80564. * @param control defines the control to check
  80565. * @returns true if the control is in the root child list
  80566. */
  80567. containsControl(control: Control3D): boolean;
  80568. /**
  80569. * Adds a control to the root child list
  80570. * @param control defines the control to add
  80571. * @returns the current manager
  80572. */
  80573. addControl(control: Control3D): GUI3DManager;
  80574. /**
  80575. * Removes a control from the root child list
  80576. * @param control defines the control to remove
  80577. * @returns the current container
  80578. */
  80579. removeControl(control: Control3D): GUI3DManager;
  80580. /**
  80581. * Releases all associated resources
  80582. */
  80583. dispose(): void;
  80584. }
  80585. }
  80586. declare module BABYLON.GUI {
  80587. /**
  80588. * Class used to transport BABYLON.Vector3 information for pointer events
  80589. */
  80590. export class Vector3WithInfo extends BABYLON.Vector3 {
  80591. /** defines the current mouse button index */
  80592. buttonIndex: number;
  80593. /**
  80594. * Creates a new Vector3WithInfo
  80595. * @param source defines the vector3 data to transport
  80596. * @param buttonIndex defines the current mouse button index
  80597. */
  80598. constructor(source: BABYLON.Vector3,
  80599. /** defines the current mouse button index */
  80600. buttonIndex?: number);
  80601. }
  80602. }
  80603. declare module BABYLON.GUI {
  80604. /**
  80605. * Class used as base class for controls
  80606. */
  80607. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  80608. /** Defines the control name */
  80609. name?: string | undefined;
  80610. /** @hidden */
  80611. _host: GUI3DManager;
  80612. private _node;
  80613. private _downCount;
  80614. private _enterCount;
  80615. private _downPointerIds;
  80616. private _isVisible;
  80617. /** Gets or sets the control position in world space */
  80618. get position(): BABYLON.Vector3;
  80619. set position(value: BABYLON.Vector3);
  80620. /** Gets or sets the control scaling in world space */
  80621. get scaling(): BABYLON.Vector3;
  80622. set scaling(value: BABYLON.Vector3);
  80623. /** Callback used to start pointer enter animation */
  80624. pointerEnterAnimation: () => void;
  80625. /** Callback used to start pointer out animation */
  80626. pointerOutAnimation: () => void;
  80627. /** Callback used to start pointer down animation */
  80628. pointerDownAnimation: () => void;
  80629. /** Callback used to start pointer up animation */
  80630. pointerUpAnimation: () => void;
  80631. /**
  80632. * An event triggered when the pointer move over the control
  80633. */
  80634. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  80635. /**
  80636. * An event triggered when the pointer move out of the control
  80637. */
  80638. onPointerOutObservable: BABYLON.Observable<Control3D>;
  80639. /**
  80640. * An event triggered when the pointer taps the control
  80641. */
  80642. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  80643. /**
  80644. * An event triggered when pointer is up
  80645. */
  80646. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  80647. /**
  80648. * An event triggered when a control is clicked on (with a mouse)
  80649. */
  80650. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  80651. /**
  80652. * An event triggered when pointer enters the control
  80653. */
  80654. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  80655. /**
  80656. * Gets or sets the parent container
  80657. */
  80658. parent: BABYLON.Nullable<Container3D>;
  80659. private _behaviors;
  80660. /**
  80661. * Gets the list of attached behaviors
  80662. * @see https://doc.babylonjs.com/features/behaviour
  80663. */
  80664. get behaviors(): BABYLON.Behavior<Control3D>[];
  80665. /**
  80666. * Attach a behavior to the control
  80667. * @see https://doc.babylonjs.com/features/behaviour
  80668. * @param behavior defines the behavior to attach
  80669. * @returns the current control
  80670. */
  80671. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80672. /**
  80673. * Remove an attached behavior
  80674. * @see https://doc.babylonjs.com/features/behaviour
  80675. * @param behavior defines the behavior to attach
  80676. * @returns the current control
  80677. */
  80678. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80679. /**
  80680. * Gets an attached behavior by name
  80681. * @param name defines the name of the behavior to look for
  80682. * @see https://doc.babylonjs.com/features/behaviour
  80683. * @returns null if behavior was not found else the requested behavior
  80684. */
  80685. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  80686. /** Gets or sets a boolean indicating if the control is visible */
  80687. get isVisible(): boolean;
  80688. set isVisible(value: boolean);
  80689. /**
  80690. * Creates a new control
  80691. * @param name defines the control name
  80692. */
  80693. constructor(
  80694. /** Defines the control name */
  80695. name?: string | undefined);
  80696. /**
  80697. * Gets a string representing the class name
  80698. */
  80699. get typeName(): string;
  80700. /**
  80701. * Get the current class name of the control.
  80702. * @returns current class name
  80703. */
  80704. getClassName(): string;
  80705. protected _getTypeName(): string;
  80706. /**
  80707. * Gets the transform node used by this control
  80708. */
  80709. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  80710. /**
  80711. * Gets the mesh used to render this control
  80712. */
  80713. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80714. /**
  80715. * Link the control as child of the given node
  80716. * @param node defines the node to link to. Use null to unlink the control
  80717. * @returns the current control
  80718. */
  80719. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  80720. /** @hidden **/
  80721. _prepareNode(scene: BABYLON.Scene): void;
  80722. /**
  80723. * Node creation.
  80724. * Can be overriden by children
  80725. * @param scene defines the scene where the node must be attached
  80726. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  80727. */
  80728. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80729. /**
  80730. * Affect a material to the given mesh
  80731. * @param mesh defines the mesh which will represent the control
  80732. */
  80733. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80734. /** @hidden */
  80735. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  80736. /** @hidden */
  80737. _onPointerEnter(target: Control3D): boolean;
  80738. /** @hidden */
  80739. _onPointerOut(target: Control3D): void;
  80740. /** @hidden */
  80741. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80742. /** @hidden */
  80743. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80744. /** @hidden */
  80745. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  80746. /** @hidden */
  80747. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80748. /** @hidden */
  80749. _disposeNode(): void;
  80750. /**
  80751. * Releases all associated resources
  80752. */
  80753. dispose(): void;
  80754. }
  80755. }
  80756. declare module BABYLON.GUI {
  80757. /**
  80758. * Class used as a root to all buttons
  80759. */
  80760. export class AbstractButton3D extends Control3D {
  80761. /**
  80762. * Creates a new button
  80763. * @param name defines the control name
  80764. */
  80765. constructor(name?: string);
  80766. protected _getTypeName(): string;
  80767. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80768. }
  80769. }
  80770. declare module BABYLON.GUI {
  80771. /**
  80772. * Class used to create a button in 3D
  80773. */
  80774. export class Button3D extends AbstractButton3D {
  80775. /** @hidden */
  80776. protected _currentMaterial: BABYLON.Material;
  80777. private _facadeTexture;
  80778. private _content;
  80779. private _contentResolution;
  80780. private _contentScaleRatio;
  80781. /**
  80782. * Gets or sets the texture resolution used to render content (512 by default)
  80783. */
  80784. get contentResolution(): BABYLON.int;
  80785. set contentResolution(value: BABYLON.int);
  80786. /**
  80787. * Gets or sets the texture scale ratio used to render content (2 by default)
  80788. */
  80789. get contentScaleRatio(): number;
  80790. set contentScaleRatio(value: number);
  80791. protected _disposeFacadeTexture(): void;
  80792. protected _resetContent(): void;
  80793. /**
  80794. * Creates a new button
  80795. * @param name defines the control name
  80796. */
  80797. constructor(name?: string);
  80798. /**
  80799. * Gets or sets the GUI 2D content used to display the button's facade
  80800. */
  80801. get content(): Control;
  80802. set content(value: Control);
  80803. /**
  80804. * Apply the facade texture (created from the content property).
  80805. * This function can be overloaded by child classes
  80806. * @param facadeTexture defines the AdvancedDynamicTexture to use
  80807. */
  80808. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80809. protected _getTypeName(): string;
  80810. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80811. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80812. /**
  80813. * Releases all associated resources
  80814. */
  80815. dispose(): void;
  80816. }
  80817. }
  80818. declare module BABYLON.GUI {
  80819. /**
  80820. * Abstract class used to create a container panel deployed on the surface of a volume
  80821. */
  80822. export abstract class VolumeBasedPanel extends Container3D {
  80823. private _columns;
  80824. private _rows;
  80825. private _rowThenColum;
  80826. private _orientation;
  80827. protected _cellWidth: number;
  80828. protected _cellHeight: number;
  80829. /**
  80830. * Gets or sets the distance between elements
  80831. */
  80832. margin: number;
  80833. /**
  80834. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  80835. * | Value | Type | Description |
  80836. * | ----- | ----------------------------------- | ----------- |
  80837. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  80838. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  80839. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  80840. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  80841. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  80842. */
  80843. get orientation(): number;
  80844. set orientation(value: number);
  80845. /**
  80846. * Gets or sets the number of columns requested (10 by default).
  80847. * The panel will automatically compute the number of rows based on number of child controls.
  80848. */
  80849. get columns(): BABYLON.int;
  80850. set columns(value: BABYLON.int);
  80851. /**
  80852. * Gets or sets a the number of rows requested.
  80853. * The panel will automatically compute the number of columns based on number of child controls.
  80854. */
  80855. get rows(): BABYLON.int;
  80856. set rows(value: BABYLON.int);
  80857. /**
  80858. * Creates new VolumeBasedPanel
  80859. */
  80860. constructor();
  80861. protected _arrangeChildren(): void;
  80862. /** Child classes must implement this function to provide correct control positioning */
  80863. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80864. /** Child classes can implement this function to provide additional processing */
  80865. protected _finalProcessing(): void;
  80866. }
  80867. }
  80868. declare module BABYLON.GUI {
  80869. /**
  80870. * Class used to create a container panel deployed on the surface of a cylinder
  80871. */
  80872. export class CylinderPanel extends VolumeBasedPanel {
  80873. private _radius;
  80874. /**
  80875. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  80876. */
  80877. get radius(): BABYLON.float;
  80878. set radius(value: BABYLON.float);
  80879. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80880. private _cylindricalMapping;
  80881. }
  80882. }
  80883. declare module BABYLON.GUI {
  80884. /** @hidden */
  80885. export var fluentVertexShader: {
  80886. name: string;
  80887. shader: string;
  80888. };
  80889. }
  80890. declare module BABYLON.GUI {
  80891. /** @hidden */
  80892. export var fluentPixelShader: {
  80893. name: string;
  80894. shader: string;
  80895. };
  80896. }
  80897. declare module BABYLON.GUI {
  80898. /** @hidden */
  80899. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  80900. INNERGLOW: boolean;
  80901. BORDER: boolean;
  80902. HOVERLIGHT: boolean;
  80903. TEXTURE: boolean;
  80904. constructor();
  80905. }
  80906. /**
  80907. * Class used to render controls with fluent desgin
  80908. */
  80909. export class FluentMaterial extends BABYLON.PushMaterial {
  80910. /**
  80911. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  80912. */
  80913. innerGlowColorIntensity: number;
  80914. /**
  80915. * Gets or sets the inner glow color (white by default)
  80916. */
  80917. innerGlowColor: BABYLON.Color3;
  80918. /**
  80919. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  80920. */
  80921. albedoColor: BABYLON.Color3;
  80922. /**
  80923. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  80924. */
  80925. renderBorders: boolean;
  80926. /**
  80927. * Gets or sets border width (default is 0.5)
  80928. */
  80929. borderWidth: number;
  80930. /**
  80931. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  80932. */
  80933. edgeSmoothingValue: number;
  80934. /**
  80935. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  80936. */
  80937. borderMinValue: number;
  80938. /**
  80939. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  80940. */
  80941. renderHoverLight: boolean;
  80942. /**
  80943. * Gets or sets the radius used to render the hover light (default is 1.0)
  80944. */
  80945. hoverRadius: number;
  80946. /**
  80947. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  80948. */
  80949. hoverColor: BABYLON.Color4;
  80950. /**
  80951. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  80952. */
  80953. hoverPosition: BABYLON.Vector3;
  80954. private _albedoTexture;
  80955. /** Gets or sets the texture to use for albedo color */
  80956. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80957. /**
  80958. * Creates a new Fluent material
  80959. * @param name defines the name of the material
  80960. * @param scene defines the hosting scene
  80961. */
  80962. constructor(name: string, scene: BABYLON.Scene);
  80963. needAlphaBlending(): boolean;
  80964. needAlphaTesting(): boolean;
  80965. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80966. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80967. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80968. getActiveTextures(): BABYLON.BaseTexture[];
  80969. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80970. dispose(forceDisposeEffect?: boolean): void;
  80971. clone(name: string): FluentMaterial;
  80972. serialize(): any;
  80973. getClassName(): string;
  80974. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  80975. }
  80976. }
  80977. declare module BABYLON.GUI {
  80978. /**
  80979. * Class used to create a holographic button in 3D
  80980. */
  80981. export class HolographicButton extends Button3D {
  80982. private _backPlate;
  80983. private _textPlate;
  80984. private _frontPlate;
  80985. private _text;
  80986. private _imageUrl;
  80987. private _shareMaterials;
  80988. private _frontMaterial;
  80989. private _backMaterial;
  80990. private _plateMaterial;
  80991. private _pickedPointObserver;
  80992. private _tooltipFade;
  80993. private _tooltipTextBlock;
  80994. private _tooltipTexture;
  80995. private _tooltipMesh;
  80996. private _tooltipHoverObserver;
  80997. private _tooltipOutObserver;
  80998. private _disposeTooltip;
  80999. /**
  81000. * Rendering ground id of all the mesh in the button
  81001. */
  81002. set renderingGroupId(id: number);
  81003. get renderingGroupId(): number;
  81004. /**
  81005. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81006. */
  81007. set tooltipText(text: BABYLON.Nullable<string>);
  81008. get tooltipText(): BABYLON.Nullable<string>;
  81009. /**
  81010. * Gets or sets text for the button
  81011. */
  81012. get text(): string;
  81013. set text(value: string);
  81014. /**
  81015. * Gets or sets the image url for the button
  81016. */
  81017. get imageUrl(): string;
  81018. set imageUrl(value: string);
  81019. /**
  81020. * Gets the back material used by this button
  81021. */
  81022. get backMaterial(): FluentMaterial;
  81023. /**
  81024. * Gets the front material used by this button
  81025. */
  81026. get frontMaterial(): FluentMaterial;
  81027. /**
  81028. * Gets the plate material used by this button
  81029. */
  81030. get plateMaterial(): BABYLON.StandardMaterial;
  81031. /**
  81032. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81033. */
  81034. get shareMaterials(): boolean;
  81035. /**
  81036. * Creates a new button
  81037. * @param name defines the control name
  81038. */
  81039. constructor(name?: string, shareMaterials?: boolean);
  81040. protected _getTypeName(): string;
  81041. private _rebuildContent;
  81042. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81043. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81044. private _createBackMaterial;
  81045. private _createFrontMaterial;
  81046. private _createPlateMaterial;
  81047. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81048. /**
  81049. * Releases all associated resources
  81050. */
  81051. dispose(): void;
  81052. }
  81053. }
  81054. declare module BABYLON.GUI {
  81055. /**
  81056. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81057. */
  81058. export class MeshButton3D extends Button3D {
  81059. /** @hidden */
  81060. protected _currentMesh: BABYLON.Mesh;
  81061. /**
  81062. * Creates a new 3D button based on a mesh
  81063. * @param mesh mesh to become a 3D button
  81064. * @param name defines the control name
  81065. */
  81066. constructor(mesh: BABYLON.Mesh, name?: string);
  81067. protected _getTypeName(): string;
  81068. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81069. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81070. }
  81071. }
  81072. declare module BABYLON.GUI {
  81073. /**
  81074. * Class used to create a container panel deployed on the surface of a plane
  81075. */
  81076. export class PlanePanel extends VolumeBasedPanel {
  81077. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81078. }
  81079. }
  81080. declare module BABYLON.GUI {
  81081. /**
  81082. * Class used to create a container panel where items get randomized planar mapping
  81083. */
  81084. export class ScatterPanel extends VolumeBasedPanel {
  81085. private _iteration;
  81086. /**
  81087. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81088. */
  81089. get iteration(): BABYLON.float;
  81090. set iteration(value: BABYLON.float);
  81091. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81092. private _scatterMapping;
  81093. protected _finalProcessing(): void;
  81094. }
  81095. }
  81096. declare module BABYLON.GUI {
  81097. /**
  81098. * Class used to create a container panel deployed on the surface of a sphere
  81099. */
  81100. export class SpherePanel extends VolumeBasedPanel {
  81101. private _radius;
  81102. /**
  81103. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81104. */
  81105. get radius(): BABYLON.float;
  81106. set radius(value: BABYLON.float);
  81107. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81108. private _sphericalMapping;
  81109. }
  81110. }
  81111. declare module BABYLON.GUI {
  81112. /**
  81113. * Class used to create a stack panel in 3D on XY plane
  81114. */
  81115. export class StackPanel3D extends Container3D {
  81116. private _isVertical;
  81117. /**
  81118. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81119. */
  81120. get isVertical(): boolean;
  81121. set isVertical(value: boolean);
  81122. /**
  81123. * Gets or sets the distance between elements
  81124. */
  81125. margin: number;
  81126. /**
  81127. * Creates new StackPanel
  81128. * @param isVertical
  81129. */
  81130. constructor(isVertical?: boolean);
  81131. protected _arrangeChildren(): void;
  81132. }
  81133. }
  81134. declare module BABYLON {
  81135. /**
  81136. * Configuration for glTF validation
  81137. */
  81138. export interface IGLTFValidationConfiguration {
  81139. /**
  81140. * The url of the glTF validator.
  81141. */
  81142. url: string;
  81143. }
  81144. /**
  81145. * glTF validation
  81146. */
  81147. export class GLTFValidation {
  81148. /**
  81149. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81150. */
  81151. static Configuration: IGLTFValidationConfiguration;
  81152. private static _LoadScriptPromise;
  81153. /**
  81154. * Validate a glTF asset using the glTF-Validator.
  81155. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81156. * @param rootUrl The root url for the glTF
  81157. * @param fileName The file name for the glTF
  81158. * @param getExternalResource The callback to get external resources for the glTF validator
  81159. * @returns A promise that resolves with the glTF validation results once complete
  81160. */
  81161. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81162. }
  81163. }
  81164. declare module BABYLON {
  81165. /**
  81166. * Mode that determines the coordinate system to use.
  81167. */
  81168. export enum GLTFLoaderCoordinateSystemMode {
  81169. /**
  81170. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81171. */
  81172. AUTO = 0,
  81173. /**
  81174. * Sets the useRightHandedSystem flag on the scene.
  81175. */
  81176. FORCE_RIGHT_HANDED = 1
  81177. }
  81178. /**
  81179. * Mode that determines what animations will start.
  81180. */
  81181. export enum GLTFLoaderAnimationStartMode {
  81182. /**
  81183. * No animation will start.
  81184. */
  81185. NONE = 0,
  81186. /**
  81187. * The first animation will start.
  81188. */
  81189. FIRST = 1,
  81190. /**
  81191. * All animations will start.
  81192. */
  81193. ALL = 2
  81194. }
  81195. /**
  81196. * Interface that contains the data for the glTF asset.
  81197. */
  81198. export interface IGLTFLoaderData {
  81199. /**
  81200. * The object that represents the glTF JSON.
  81201. */
  81202. json: Object;
  81203. /**
  81204. * The BIN chunk of a binary glTF.
  81205. */
  81206. bin: Nullable<IDataBuffer>;
  81207. }
  81208. /**
  81209. * Interface for extending the loader.
  81210. */
  81211. export interface IGLTFLoaderExtension {
  81212. /**
  81213. * The name of this extension.
  81214. */
  81215. readonly name: string;
  81216. /**
  81217. * Defines whether this extension is enabled.
  81218. */
  81219. enabled: boolean;
  81220. /**
  81221. * Defines the order of this extension.
  81222. * The loader sorts the extensions using these values when loading.
  81223. */
  81224. order?: number;
  81225. }
  81226. /**
  81227. * Loader state.
  81228. */
  81229. export enum GLTFLoaderState {
  81230. /**
  81231. * The asset is loading.
  81232. */
  81233. LOADING = 0,
  81234. /**
  81235. * The asset is ready for rendering.
  81236. */
  81237. READY = 1,
  81238. /**
  81239. * The asset is completely loaded.
  81240. */
  81241. COMPLETE = 2
  81242. }
  81243. /** @hidden */
  81244. export interface IImportMeshAsyncOutput {
  81245. meshes: AbstractMesh[];
  81246. particleSystems: IParticleSystem[];
  81247. skeletons: Skeleton[];
  81248. animationGroups: AnimationGroup[];
  81249. lights: Light[];
  81250. transformNodes: TransformNode[];
  81251. }
  81252. /** @hidden */
  81253. export interface IGLTFLoader extends IDisposable {
  81254. readonly state: Nullable<GLTFLoaderState>;
  81255. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81256. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81257. }
  81258. /**
  81259. * File loader for loading glTF files into a scene.
  81260. */
  81261. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81262. /** @hidden */
  81263. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81264. /** @hidden */
  81265. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81266. /**
  81267. * Raised when the asset has been parsed
  81268. */
  81269. onParsedObservable: Observable<IGLTFLoaderData>;
  81270. private _onParsedObserver;
  81271. /**
  81272. * Raised when the asset has been parsed
  81273. */
  81274. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81275. /**
  81276. * 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.
  81277. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81278. * Defaults to true.
  81279. * @hidden
  81280. */
  81281. static IncrementalLoading: boolean;
  81282. /**
  81283. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81284. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81285. * @hidden
  81286. */
  81287. static HomogeneousCoordinates: boolean;
  81288. /**
  81289. * The coordinate system mode. Defaults to AUTO.
  81290. */
  81291. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81292. /**
  81293. * The animation start mode. Defaults to FIRST.
  81294. */
  81295. animationStartMode: GLTFLoaderAnimationStartMode;
  81296. /**
  81297. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81298. */
  81299. compileMaterials: boolean;
  81300. /**
  81301. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81302. */
  81303. useClipPlane: boolean;
  81304. /**
  81305. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81306. */
  81307. compileShadowGenerators: boolean;
  81308. /**
  81309. * Defines if the Alpha blended materials are only applied as coverage.
  81310. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81311. * If true, no extra effects are applied to transparent pixels.
  81312. */
  81313. transparencyAsCoverage: boolean;
  81314. /**
  81315. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81316. * Enabling will disable offline support and glTF validator.
  81317. * Defaults to false.
  81318. */
  81319. useRangeRequests: boolean;
  81320. /**
  81321. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81322. */
  81323. createInstances: boolean;
  81324. /**
  81325. * 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.
  81326. */
  81327. alwaysComputeBoundingBox: boolean;
  81328. /**
  81329. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81330. */
  81331. loadAllMaterials: boolean;
  81332. /**
  81333. * Function called before loading a url referenced by the asset.
  81334. */
  81335. preprocessUrlAsync: (url: string) => Promise<string>;
  81336. /**
  81337. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81338. * 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, ...)
  81339. */
  81340. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81341. private _onMeshLoadedObserver;
  81342. /**
  81343. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81344. * 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, ...)
  81345. */
  81346. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81347. /**
  81348. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81349. */
  81350. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81351. private _onTextureLoadedObserver;
  81352. /**
  81353. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81354. */
  81355. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81356. /**
  81357. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81358. */
  81359. readonly onMaterialLoadedObservable: Observable<Material>;
  81360. private _onMaterialLoadedObserver;
  81361. /**
  81362. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81363. */
  81364. set onMaterialLoaded(callback: (material: Material) => void);
  81365. /**
  81366. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81367. */
  81368. readonly onCameraLoadedObservable: Observable<Camera>;
  81369. private _onCameraLoadedObserver;
  81370. /**
  81371. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81372. */
  81373. set onCameraLoaded(callback: (camera: Camera) => void);
  81374. /**
  81375. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81376. * For assets with LODs, raised when all of the LODs are complete.
  81377. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81378. */
  81379. readonly onCompleteObservable: Observable<void>;
  81380. private _onCompleteObserver;
  81381. /**
  81382. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81383. * For assets with LODs, raised when all of the LODs are complete.
  81384. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81385. */
  81386. set onComplete(callback: () => void);
  81387. /**
  81388. * Observable raised when an error occurs.
  81389. */
  81390. readonly onErrorObservable: Observable<any>;
  81391. private _onErrorObserver;
  81392. /**
  81393. * Callback raised when an error occurs.
  81394. */
  81395. set onError(callback: (reason: any) => void);
  81396. /**
  81397. * Observable raised after the loader is disposed.
  81398. */
  81399. readonly onDisposeObservable: Observable<void>;
  81400. private _onDisposeObserver;
  81401. /**
  81402. * Callback raised after the loader is disposed.
  81403. */
  81404. set onDispose(callback: () => void);
  81405. /**
  81406. * Observable raised after a loader extension is created.
  81407. * Set additional options for a loader extension in this event.
  81408. */
  81409. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81410. private _onExtensionLoadedObserver;
  81411. /**
  81412. * Callback raised after a loader extension is created.
  81413. */
  81414. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81415. /**
  81416. * Defines if the loader logging is enabled.
  81417. */
  81418. get loggingEnabled(): boolean;
  81419. set loggingEnabled(value: boolean);
  81420. /**
  81421. * Defines if the loader should capture performance counters.
  81422. */
  81423. get capturePerformanceCounters(): boolean;
  81424. set capturePerformanceCounters(value: boolean);
  81425. /**
  81426. * Defines if the loader should validate the asset.
  81427. */
  81428. validate: boolean;
  81429. /**
  81430. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81431. */
  81432. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81433. private _onValidatedObserver;
  81434. /**
  81435. * Callback raised after a loader extension is created.
  81436. */
  81437. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81438. private _loader;
  81439. private _progressCallback?;
  81440. private _requests;
  81441. private static magicBase64Encoded;
  81442. /**
  81443. * Name of the loader ("gltf")
  81444. */
  81445. name: string;
  81446. /** @hidden */
  81447. extensions: ISceneLoaderPluginExtensions;
  81448. /**
  81449. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81450. */
  81451. dispose(): void;
  81452. /** @hidden */
  81453. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81454. /** @hidden */
  81455. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81456. /** @hidden */
  81457. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81458. meshes: AbstractMesh[];
  81459. particleSystems: IParticleSystem[];
  81460. skeletons: Skeleton[];
  81461. animationGroups: AnimationGroup[];
  81462. }>;
  81463. /** @hidden */
  81464. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81465. /** @hidden */
  81466. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81467. /** @hidden */
  81468. canDirectLoad(data: string): boolean;
  81469. /** @hidden */
  81470. directLoad(scene: Scene, data: string): Promise<any>;
  81471. /**
  81472. * The callback that allows custom handling of the root url based on the response url.
  81473. * @param rootUrl the original root url
  81474. * @param responseURL the response url if available
  81475. * @returns the new root url
  81476. */
  81477. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  81478. /** @hidden */
  81479. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  81480. /**
  81481. * The loader state or null if the loader is not active.
  81482. */
  81483. get loaderState(): Nullable<GLTFLoaderState>;
  81484. /**
  81485. * Returns a promise that resolves when the asset is completely loaded.
  81486. * @returns a promise that resolves when the asset is completely loaded.
  81487. */
  81488. whenCompleteAsync(): Promise<void>;
  81489. /** @hidden */
  81490. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  81491. /** @hidden */
  81492. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  81493. private _onProgress;
  81494. private _validate;
  81495. private _getLoader;
  81496. private _parseJson;
  81497. private _unpackBinaryAsync;
  81498. private _unpackBinaryV1Async;
  81499. private _unpackBinaryV2Async;
  81500. private static _parseVersion;
  81501. private static _compareVersion;
  81502. private static readonly _logSpaces;
  81503. private _logIndentLevel;
  81504. private _loggingEnabled;
  81505. /** @hidden */
  81506. _log: (message: string) => void;
  81507. /** @hidden */
  81508. _logOpen(message: string): void;
  81509. /** @hidden */
  81510. _logClose(): void;
  81511. private _logEnabled;
  81512. private _logDisabled;
  81513. private _capturePerformanceCounters;
  81514. /** @hidden */
  81515. _startPerformanceCounter: (counterName: string) => void;
  81516. /** @hidden */
  81517. _endPerformanceCounter: (counterName: string) => void;
  81518. private _startPerformanceCounterEnabled;
  81519. private _startPerformanceCounterDisabled;
  81520. private _endPerformanceCounterEnabled;
  81521. private _endPerformanceCounterDisabled;
  81522. }
  81523. }
  81524. declare module BABYLON.GLTF1 {
  81525. /**
  81526. * Enums
  81527. * @hidden
  81528. */
  81529. export enum EComponentType {
  81530. BYTE = 5120,
  81531. UNSIGNED_BYTE = 5121,
  81532. SHORT = 5122,
  81533. UNSIGNED_SHORT = 5123,
  81534. FLOAT = 5126
  81535. }
  81536. /** @hidden */
  81537. export enum EShaderType {
  81538. FRAGMENT = 35632,
  81539. VERTEX = 35633
  81540. }
  81541. /** @hidden */
  81542. export enum EParameterType {
  81543. BYTE = 5120,
  81544. UNSIGNED_BYTE = 5121,
  81545. SHORT = 5122,
  81546. UNSIGNED_SHORT = 5123,
  81547. INT = 5124,
  81548. UNSIGNED_INT = 5125,
  81549. FLOAT = 5126,
  81550. FLOAT_VEC2 = 35664,
  81551. FLOAT_VEC3 = 35665,
  81552. FLOAT_VEC4 = 35666,
  81553. INT_VEC2 = 35667,
  81554. INT_VEC3 = 35668,
  81555. INT_VEC4 = 35669,
  81556. BOOL = 35670,
  81557. BOOL_VEC2 = 35671,
  81558. BOOL_VEC3 = 35672,
  81559. BOOL_VEC4 = 35673,
  81560. FLOAT_MAT2 = 35674,
  81561. FLOAT_MAT3 = 35675,
  81562. FLOAT_MAT4 = 35676,
  81563. SAMPLER_2D = 35678
  81564. }
  81565. /** @hidden */
  81566. export enum ETextureWrapMode {
  81567. CLAMP_TO_EDGE = 33071,
  81568. MIRRORED_REPEAT = 33648,
  81569. REPEAT = 10497
  81570. }
  81571. /** @hidden */
  81572. export enum ETextureFilterType {
  81573. NEAREST = 9728,
  81574. LINEAR = 9728,
  81575. NEAREST_MIPMAP_NEAREST = 9984,
  81576. LINEAR_MIPMAP_NEAREST = 9985,
  81577. NEAREST_MIPMAP_LINEAR = 9986,
  81578. LINEAR_MIPMAP_LINEAR = 9987
  81579. }
  81580. /** @hidden */
  81581. export enum ETextureFormat {
  81582. ALPHA = 6406,
  81583. RGB = 6407,
  81584. RGBA = 6408,
  81585. LUMINANCE = 6409,
  81586. LUMINANCE_ALPHA = 6410
  81587. }
  81588. /** @hidden */
  81589. export enum ECullingType {
  81590. FRONT = 1028,
  81591. BACK = 1029,
  81592. FRONT_AND_BACK = 1032
  81593. }
  81594. /** @hidden */
  81595. export enum EBlendingFunction {
  81596. ZERO = 0,
  81597. ONE = 1,
  81598. SRC_COLOR = 768,
  81599. ONE_MINUS_SRC_COLOR = 769,
  81600. DST_COLOR = 774,
  81601. ONE_MINUS_DST_COLOR = 775,
  81602. SRC_ALPHA = 770,
  81603. ONE_MINUS_SRC_ALPHA = 771,
  81604. DST_ALPHA = 772,
  81605. ONE_MINUS_DST_ALPHA = 773,
  81606. CONSTANT_COLOR = 32769,
  81607. ONE_MINUS_CONSTANT_COLOR = 32770,
  81608. CONSTANT_ALPHA = 32771,
  81609. ONE_MINUS_CONSTANT_ALPHA = 32772,
  81610. SRC_ALPHA_SATURATE = 776
  81611. }
  81612. /** @hidden */
  81613. export interface IGLTFProperty {
  81614. extensions?: {
  81615. [key: string]: any;
  81616. };
  81617. extras?: Object;
  81618. }
  81619. /** @hidden */
  81620. export interface IGLTFChildRootProperty extends IGLTFProperty {
  81621. name?: string;
  81622. }
  81623. /** @hidden */
  81624. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  81625. bufferView: string;
  81626. byteOffset: number;
  81627. byteStride: number;
  81628. count: number;
  81629. type: string;
  81630. componentType: EComponentType;
  81631. max?: number[];
  81632. min?: number[];
  81633. name?: string;
  81634. }
  81635. /** @hidden */
  81636. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  81637. buffer: string;
  81638. byteOffset: number;
  81639. byteLength: number;
  81640. byteStride: number;
  81641. target?: number;
  81642. }
  81643. /** @hidden */
  81644. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  81645. uri: string;
  81646. byteLength?: number;
  81647. type?: string;
  81648. }
  81649. /** @hidden */
  81650. export interface IGLTFShader extends IGLTFChildRootProperty {
  81651. uri: string;
  81652. type: EShaderType;
  81653. }
  81654. /** @hidden */
  81655. export interface IGLTFProgram extends IGLTFChildRootProperty {
  81656. attributes: string[];
  81657. fragmentShader: string;
  81658. vertexShader: string;
  81659. }
  81660. /** @hidden */
  81661. export interface IGLTFTechniqueParameter {
  81662. type: number;
  81663. count?: number;
  81664. semantic?: string;
  81665. node?: string;
  81666. value?: number | boolean | string | Array<any>;
  81667. source?: string;
  81668. babylonValue?: any;
  81669. }
  81670. /** @hidden */
  81671. export interface IGLTFTechniqueCommonProfile {
  81672. lightingModel: string;
  81673. texcoordBindings: Object;
  81674. parameters?: Array<any>;
  81675. }
  81676. /** @hidden */
  81677. export interface IGLTFTechniqueStatesFunctions {
  81678. blendColor?: number[];
  81679. blendEquationSeparate?: number[];
  81680. blendFuncSeparate?: number[];
  81681. colorMask: boolean[];
  81682. cullFace: number[];
  81683. }
  81684. /** @hidden */
  81685. export interface IGLTFTechniqueStates {
  81686. enable: number[];
  81687. functions: IGLTFTechniqueStatesFunctions;
  81688. }
  81689. /** @hidden */
  81690. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  81691. parameters: {
  81692. [key: string]: IGLTFTechniqueParameter;
  81693. };
  81694. program: string;
  81695. attributes: {
  81696. [key: string]: string;
  81697. };
  81698. uniforms: {
  81699. [key: string]: string;
  81700. };
  81701. states: IGLTFTechniqueStates;
  81702. }
  81703. /** @hidden */
  81704. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  81705. technique?: string;
  81706. values: string[];
  81707. }
  81708. /** @hidden */
  81709. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  81710. attributes: {
  81711. [key: string]: string;
  81712. };
  81713. indices: string;
  81714. material: string;
  81715. mode?: number;
  81716. }
  81717. /** @hidden */
  81718. export interface IGLTFMesh extends IGLTFChildRootProperty {
  81719. primitives: IGLTFMeshPrimitive[];
  81720. }
  81721. /** @hidden */
  81722. export interface IGLTFImage extends IGLTFChildRootProperty {
  81723. uri: string;
  81724. }
  81725. /** @hidden */
  81726. export interface IGLTFSampler extends IGLTFChildRootProperty {
  81727. magFilter?: number;
  81728. minFilter?: number;
  81729. wrapS?: number;
  81730. wrapT?: number;
  81731. }
  81732. /** @hidden */
  81733. export interface IGLTFTexture extends IGLTFChildRootProperty {
  81734. sampler: string;
  81735. source: string;
  81736. format?: ETextureFormat;
  81737. internalFormat?: ETextureFormat;
  81738. target?: number;
  81739. type?: number;
  81740. babylonTexture?: Texture;
  81741. }
  81742. /** @hidden */
  81743. export interface IGLTFAmbienLight {
  81744. color?: number[];
  81745. }
  81746. /** @hidden */
  81747. export interface IGLTFDirectionalLight {
  81748. color?: number[];
  81749. }
  81750. /** @hidden */
  81751. export interface IGLTFPointLight {
  81752. color?: number[];
  81753. constantAttenuation?: number;
  81754. linearAttenuation?: number;
  81755. quadraticAttenuation?: number;
  81756. }
  81757. /** @hidden */
  81758. export interface IGLTFSpotLight {
  81759. color?: number[];
  81760. constantAttenuation?: number;
  81761. fallOfAngle?: number;
  81762. fallOffExponent?: number;
  81763. linearAttenuation?: number;
  81764. quadraticAttenuation?: number;
  81765. }
  81766. /** @hidden */
  81767. export interface IGLTFLight extends IGLTFChildRootProperty {
  81768. type: string;
  81769. }
  81770. /** @hidden */
  81771. export interface IGLTFCameraOrthographic {
  81772. xmag: number;
  81773. ymag: number;
  81774. zfar: number;
  81775. znear: number;
  81776. }
  81777. /** @hidden */
  81778. export interface IGLTFCameraPerspective {
  81779. aspectRatio: number;
  81780. yfov: number;
  81781. zfar: number;
  81782. znear: number;
  81783. }
  81784. /** @hidden */
  81785. export interface IGLTFCamera extends IGLTFChildRootProperty {
  81786. type: string;
  81787. }
  81788. /** @hidden */
  81789. export interface IGLTFAnimationChannelTarget {
  81790. id: string;
  81791. path: string;
  81792. }
  81793. /** @hidden */
  81794. export interface IGLTFAnimationChannel {
  81795. sampler: string;
  81796. target: IGLTFAnimationChannelTarget;
  81797. }
  81798. /** @hidden */
  81799. export interface IGLTFAnimationSampler {
  81800. input: string;
  81801. output: string;
  81802. interpolation?: string;
  81803. }
  81804. /** @hidden */
  81805. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  81806. channels?: IGLTFAnimationChannel[];
  81807. parameters?: {
  81808. [key: string]: string;
  81809. };
  81810. samplers?: {
  81811. [key: string]: IGLTFAnimationSampler;
  81812. };
  81813. }
  81814. /** @hidden */
  81815. export interface IGLTFNodeInstanceSkin {
  81816. skeletons: string[];
  81817. skin: string;
  81818. meshes: string[];
  81819. }
  81820. /** @hidden */
  81821. export interface IGLTFSkins extends IGLTFChildRootProperty {
  81822. bindShapeMatrix: number[];
  81823. inverseBindMatrices: string;
  81824. jointNames: string[];
  81825. babylonSkeleton?: Skeleton;
  81826. }
  81827. /** @hidden */
  81828. export interface IGLTFNode extends IGLTFChildRootProperty {
  81829. camera?: string;
  81830. children: string[];
  81831. skin?: string;
  81832. jointName?: string;
  81833. light?: string;
  81834. matrix: number[];
  81835. mesh?: string;
  81836. meshes?: string[];
  81837. rotation?: number[];
  81838. scale?: number[];
  81839. translation?: number[];
  81840. babylonNode?: Node;
  81841. }
  81842. /** @hidden */
  81843. export interface IGLTFScene extends IGLTFChildRootProperty {
  81844. nodes: string[];
  81845. }
  81846. /** @hidden */
  81847. export interface IGLTFRuntime {
  81848. extensions: {
  81849. [key: string]: any;
  81850. };
  81851. accessors: {
  81852. [key: string]: IGLTFAccessor;
  81853. };
  81854. buffers: {
  81855. [key: string]: IGLTFBuffer;
  81856. };
  81857. bufferViews: {
  81858. [key: string]: IGLTFBufferView;
  81859. };
  81860. meshes: {
  81861. [key: string]: IGLTFMesh;
  81862. };
  81863. lights: {
  81864. [key: string]: IGLTFLight;
  81865. };
  81866. cameras: {
  81867. [key: string]: IGLTFCamera;
  81868. };
  81869. nodes: {
  81870. [key: string]: IGLTFNode;
  81871. };
  81872. images: {
  81873. [key: string]: IGLTFImage;
  81874. };
  81875. textures: {
  81876. [key: string]: IGLTFTexture;
  81877. };
  81878. shaders: {
  81879. [key: string]: IGLTFShader;
  81880. };
  81881. programs: {
  81882. [key: string]: IGLTFProgram;
  81883. };
  81884. samplers: {
  81885. [key: string]: IGLTFSampler;
  81886. };
  81887. techniques: {
  81888. [key: string]: IGLTFTechnique;
  81889. };
  81890. materials: {
  81891. [key: string]: IGLTFMaterial;
  81892. };
  81893. animations: {
  81894. [key: string]: IGLTFAnimation;
  81895. };
  81896. skins: {
  81897. [key: string]: IGLTFSkins;
  81898. };
  81899. currentScene?: Object;
  81900. scenes: {
  81901. [key: string]: IGLTFScene;
  81902. };
  81903. extensionsUsed: string[];
  81904. extensionsRequired?: string[];
  81905. buffersCount: number;
  81906. shaderscount: number;
  81907. scene: Scene;
  81908. rootUrl: string;
  81909. loadedBufferCount: number;
  81910. loadedBufferViews: {
  81911. [name: string]: ArrayBufferView;
  81912. };
  81913. loadedShaderCount: number;
  81914. importOnlyMeshes: boolean;
  81915. importMeshesNames?: string[];
  81916. dummyNodes: Node[];
  81917. forAssetContainer: boolean;
  81918. }
  81919. /** @hidden */
  81920. export interface INodeToRoot {
  81921. bone: Bone;
  81922. node: IGLTFNode;
  81923. id: string;
  81924. }
  81925. /** @hidden */
  81926. export interface IJointNode {
  81927. node: IGLTFNode;
  81928. id: string;
  81929. }
  81930. }
  81931. declare module BABYLON.GLTF1 {
  81932. /**
  81933. * Utils functions for GLTF
  81934. * @hidden
  81935. */
  81936. export class GLTFUtils {
  81937. /**
  81938. * Sets the given "parameter" matrix
  81939. * @param scene: the Scene object
  81940. * @param source: the source node where to pick the matrix
  81941. * @param parameter: the GLTF technique parameter
  81942. * @param uniformName: the name of the shader's uniform
  81943. * @param shaderMaterial: the shader material
  81944. */
  81945. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  81946. /**
  81947. * Sets the given "parameter" matrix
  81948. * @param shaderMaterial: the shader material
  81949. * @param uniform: the name of the shader's uniform
  81950. * @param value: the value of the uniform
  81951. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  81952. */
  81953. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  81954. /**
  81955. * Returns the wrap mode of the texture
  81956. * @param mode: the mode value
  81957. */
  81958. static GetWrapMode(mode: number): number;
  81959. /**
  81960. * Returns the byte stride giving an accessor
  81961. * @param accessor: the GLTF accessor objet
  81962. */
  81963. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  81964. /**
  81965. * Returns the texture filter mode giving a mode value
  81966. * @param mode: the filter mode value
  81967. */
  81968. static GetTextureFilterMode(mode: number): ETextureFilterType;
  81969. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  81970. /**
  81971. * Returns a buffer from its accessor
  81972. * @param gltfRuntime: the GLTF runtime
  81973. * @param accessor: the GLTF accessor
  81974. */
  81975. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  81976. /**
  81977. * Decodes a buffer view into a string
  81978. * @param view: the buffer view
  81979. */
  81980. static DecodeBufferToText(view: ArrayBufferView): string;
  81981. /**
  81982. * Returns the default material of gltf. Related to
  81983. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  81984. * @param scene: the Babylon.js scene
  81985. */
  81986. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  81987. private static _DefaultMaterial;
  81988. }
  81989. }
  81990. declare module BABYLON.GLTF1 {
  81991. /**
  81992. * Implementation of the base glTF spec
  81993. * @hidden
  81994. */
  81995. export class GLTFLoaderBase {
  81996. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  81997. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81998. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  81999. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82000. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82001. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82002. }
  82003. /**
  82004. * glTF V1 Loader
  82005. * @hidden
  82006. */
  82007. export class GLTFLoader implements IGLTFLoader {
  82008. static Extensions: {
  82009. [name: string]: GLTFLoaderExtension;
  82010. };
  82011. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82012. state: Nullable<GLTFLoaderState>;
  82013. dispose(): void;
  82014. private _importMeshAsync;
  82015. /**
  82016. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82017. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82018. * @param scene the scene the meshes should be added to
  82019. * @param forAssetContainer defines if the entities must be stored in the scene
  82020. * @param data gltf data containing information of the meshes in a loaded file
  82021. * @param rootUrl root url to load from
  82022. * @param onProgress event that fires when loading progress has occured
  82023. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82024. */
  82025. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  82026. private _loadAsync;
  82027. /**
  82028. * Imports all objects from a loaded gltf file and adds them to the scene
  82029. * @param scene the scene the objects should be added to
  82030. * @param data gltf data containing information of the meshes in a loaded file
  82031. * @param rootUrl root url to load from
  82032. * @param onProgress event that fires when loading progress has occured
  82033. * @returns a promise which completes when objects have been loaded to the scene
  82034. */
  82035. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82036. private _loadShadersAsync;
  82037. private _loadBuffersAsync;
  82038. private _createNodes;
  82039. }
  82040. /** @hidden */
  82041. export abstract class GLTFLoaderExtension {
  82042. private _name;
  82043. constructor(name: string);
  82044. get name(): string;
  82045. /**
  82046. * Defines an override for loading the runtime
  82047. * Return true to stop further extensions from loading the runtime
  82048. */
  82049. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82050. /**
  82051. * Defines an onverride for creating gltf runtime
  82052. * Return true to stop further extensions from creating the runtime
  82053. */
  82054. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82055. /**
  82056. * Defines an override for loading buffers
  82057. * Return true to stop further extensions from loading this buffer
  82058. */
  82059. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82060. /**
  82061. * Defines an override for loading texture buffers
  82062. * Return true to stop further extensions from loading this texture data
  82063. */
  82064. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82065. /**
  82066. * Defines an override for creating textures
  82067. * Return true to stop further extensions from loading this texture
  82068. */
  82069. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82070. /**
  82071. * Defines an override for loading shader strings
  82072. * Return true to stop further extensions from loading this shader data
  82073. */
  82074. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82075. /**
  82076. * Defines an override for loading materials
  82077. * Return true to stop further extensions from loading this material
  82078. */
  82079. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82080. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82081. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82082. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82083. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82084. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82085. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82086. private static LoadTextureBufferAsync;
  82087. private static CreateTextureAsync;
  82088. private static ApplyExtensions;
  82089. }
  82090. }
  82091. declare module BABYLON.GLTF1 {
  82092. /** @hidden */
  82093. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82094. private _bin;
  82095. constructor();
  82096. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82097. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82098. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82099. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82100. }
  82101. }
  82102. declare module BABYLON.GLTF1 {
  82103. /** @hidden */
  82104. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82105. constructor();
  82106. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82107. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82108. private _loadTexture;
  82109. }
  82110. }
  82111. declare module BABYLON.GLTF2.Loader {
  82112. /**
  82113. * Loader interface with an index field.
  82114. */
  82115. export interface IArrayItem {
  82116. /**
  82117. * The index of this item in the array.
  82118. */
  82119. index: number;
  82120. }
  82121. /**
  82122. * Loader interface with additional members.
  82123. */
  82124. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82125. /** @hidden */
  82126. _data?: Promise<ArrayBufferView>;
  82127. /** @hidden */
  82128. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82129. }
  82130. /**
  82131. * Loader interface with additional members.
  82132. */
  82133. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82134. }
  82135. /** @hidden */
  82136. export interface _IAnimationSamplerData {
  82137. input: Float32Array;
  82138. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82139. output: Float32Array;
  82140. }
  82141. /**
  82142. * Loader interface with additional members.
  82143. */
  82144. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82145. /** @hidden */
  82146. _data?: Promise<_IAnimationSamplerData>;
  82147. }
  82148. /**
  82149. * Loader interface with additional members.
  82150. */
  82151. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82152. channels: IAnimationChannel[];
  82153. samplers: IAnimationSampler[];
  82154. /** @hidden */
  82155. _babylonAnimationGroup?: AnimationGroup;
  82156. }
  82157. /**
  82158. * Loader interface with additional members.
  82159. */
  82160. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82161. /** @hidden */
  82162. _data?: Promise<ArrayBufferView>;
  82163. }
  82164. /**
  82165. * Loader interface with additional members.
  82166. */
  82167. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82168. /** @hidden */
  82169. _data?: Promise<ArrayBufferView>;
  82170. /** @hidden */
  82171. _babylonBuffer?: Promise<Buffer>;
  82172. }
  82173. /**
  82174. * Loader interface with additional members.
  82175. */
  82176. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82177. }
  82178. /**
  82179. * Loader interface with additional members.
  82180. */
  82181. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82182. /** @hidden */
  82183. _data?: Promise<ArrayBufferView>;
  82184. }
  82185. /**
  82186. * Loader interface with additional members.
  82187. */
  82188. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82189. }
  82190. /**
  82191. * Loader interface with additional members.
  82192. */
  82193. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82194. }
  82195. /**
  82196. * Loader interface with additional members.
  82197. */
  82198. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82199. baseColorTexture?: ITextureInfo;
  82200. metallicRoughnessTexture?: ITextureInfo;
  82201. }
  82202. /**
  82203. * Loader interface with additional members.
  82204. */
  82205. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82206. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82207. normalTexture?: IMaterialNormalTextureInfo;
  82208. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82209. emissiveTexture?: ITextureInfo;
  82210. /** @hidden */
  82211. _data?: {
  82212. [babylonDrawMode: number]: {
  82213. babylonMaterial: Material;
  82214. babylonMeshes: AbstractMesh[];
  82215. promise: Promise<void>;
  82216. };
  82217. };
  82218. }
  82219. /**
  82220. * Loader interface with additional members.
  82221. */
  82222. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82223. primitives: IMeshPrimitive[];
  82224. }
  82225. /**
  82226. * Loader interface with additional members.
  82227. */
  82228. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82229. /** @hidden */
  82230. _instanceData?: {
  82231. babylonSourceMesh: Mesh;
  82232. promise: Promise<any>;
  82233. };
  82234. }
  82235. /**
  82236. * Loader interface with additional members.
  82237. */
  82238. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82239. /**
  82240. * The parent glTF node.
  82241. */
  82242. parent?: INode;
  82243. /** @hidden */
  82244. _babylonTransformNode?: TransformNode;
  82245. /** @hidden */
  82246. _primitiveBabylonMeshes?: AbstractMesh[];
  82247. /** @hidden */
  82248. _babylonBones?: Bone[];
  82249. /** @hidden */
  82250. _numMorphTargets?: number;
  82251. }
  82252. /** @hidden */
  82253. export interface _ISamplerData {
  82254. noMipMaps: boolean;
  82255. samplingMode: number;
  82256. wrapU: number;
  82257. wrapV: number;
  82258. }
  82259. /**
  82260. * Loader interface with additional members.
  82261. */
  82262. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82263. /** @hidden */
  82264. _data?: _ISamplerData;
  82265. }
  82266. /**
  82267. * Loader interface with additional members.
  82268. */
  82269. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82270. }
  82271. /**
  82272. * Loader interface with additional members.
  82273. */
  82274. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82275. /** @hidden */
  82276. _data?: {
  82277. babylonSkeleton: Skeleton;
  82278. promise: Promise<void>;
  82279. };
  82280. }
  82281. /**
  82282. * Loader interface with additional members.
  82283. */
  82284. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82285. }
  82286. /**
  82287. * Loader interface with additional members.
  82288. */
  82289. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82290. }
  82291. /**
  82292. * Loader interface with additional members.
  82293. */
  82294. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82295. accessors?: IAccessor[];
  82296. animations?: IAnimation[];
  82297. buffers?: IBuffer[];
  82298. bufferViews?: IBufferView[];
  82299. cameras?: ICamera[];
  82300. images?: IImage[];
  82301. materials?: IMaterial[];
  82302. meshes?: IMesh[];
  82303. nodes?: INode[];
  82304. samplers?: ISampler[];
  82305. scenes?: IScene[];
  82306. skins?: ISkin[];
  82307. textures?: ITexture[];
  82308. }
  82309. }
  82310. declare module BABYLON.GLTF2 {
  82311. /**
  82312. * Interface for a glTF loader extension.
  82313. */
  82314. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82315. /**
  82316. * Called after the loader state changes to LOADING.
  82317. */
  82318. onLoading?(): void;
  82319. /**
  82320. * Called after the loader state changes to READY.
  82321. */
  82322. onReady?(): void;
  82323. /**
  82324. * Define this method to modify the default behavior when loading scenes.
  82325. * @param context The context when loading the asset
  82326. * @param scene The glTF scene property
  82327. * @returns A promise that resolves when the load is complete or null if not handled
  82328. */
  82329. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82330. /**
  82331. * Define this method to modify the default behavior when loading nodes.
  82332. * @param context The context when loading the asset
  82333. * @param node The glTF node property
  82334. * @param assign A function called synchronously after parsing the glTF properties
  82335. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82336. */
  82337. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82338. /**
  82339. * Define this method to modify the default behavior when loading cameras.
  82340. * @param context The context when loading the asset
  82341. * @param camera The glTF camera property
  82342. * @param assign A function called synchronously after parsing the glTF properties
  82343. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82344. */
  82345. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82346. /**
  82347. * @hidden
  82348. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82349. * @param context The context when loading the asset
  82350. * @param primitive The glTF mesh primitive property
  82351. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82352. */
  82353. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82354. /**
  82355. * @hidden
  82356. * Define this method to modify the default behavior when loading data for mesh primitives.
  82357. * @param context The context when loading the asset
  82358. * @param name The mesh name when loading the asset
  82359. * @param node The glTF node when loading the asset
  82360. * @param mesh The glTF mesh when loading the asset
  82361. * @param primitive The glTF mesh primitive property
  82362. * @param assign A function called synchronously after parsing the glTF properties
  82363. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82364. */
  82365. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82366. /**
  82367. * @hidden
  82368. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82369. * @param context The context when loading the asset
  82370. * @param material The glTF material property
  82371. * @param assign A function called synchronously after parsing the glTF properties
  82372. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82373. */
  82374. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82375. /**
  82376. * Define this method to modify the default behavior when creating materials.
  82377. * @param context The context when loading the asset
  82378. * @param material The glTF material property
  82379. * @param babylonDrawMode The draw mode for the Babylon material
  82380. * @returns The Babylon material or null if not handled
  82381. */
  82382. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82383. /**
  82384. * Define this method to modify the default behavior when loading material properties.
  82385. * @param context The context when loading the asset
  82386. * @param material The glTF material property
  82387. * @param babylonMaterial The Babylon material
  82388. * @returns A promise that resolves when the load is complete or null if not handled
  82389. */
  82390. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82391. /**
  82392. * Define this method to modify the default behavior when loading texture infos.
  82393. * @param context The context when loading the asset
  82394. * @param textureInfo The glTF texture info property
  82395. * @param assign A function called synchronously after parsing the glTF properties
  82396. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82397. */
  82398. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82399. /**
  82400. * @hidden
  82401. * Define this method to modify the default behavior when loading textures.
  82402. * @param context The context when loading the asset
  82403. * @param texture The glTF texture property
  82404. * @param assign A function called synchronously after parsing the glTF properties
  82405. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82406. */
  82407. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82408. /**
  82409. * Define this method to modify the default behavior when loading animations.
  82410. * @param context The context when loading the asset
  82411. * @param animation The glTF animation property
  82412. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82413. */
  82414. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82415. /**
  82416. * @hidden
  82417. * Define this method to modify the default behavior when loading skins.
  82418. * @param context The context when loading the asset
  82419. * @param node The glTF node property
  82420. * @param skin The glTF skin property
  82421. * @returns A promise that resolves when the load is complete or null if not handled
  82422. */
  82423. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82424. /**
  82425. * @hidden
  82426. * Define this method to modify the default behavior when loading uris.
  82427. * @param context The context when loading the asset
  82428. * @param property The glTF property associated with the uri
  82429. * @param uri The uri to load
  82430. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82431. */
  82432. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82433. /**
  82434. * Define this method to modify the default behavior when loading buffer views.
  82435. * @param context The context when loading the asset
  82436. * @param bufferView The glTF buffer view property
  82437. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82438. */
  82439. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82440. /**
  82441. * Define this method to modify the default behavior when loading buffers.
  82442. * @param context The context when loading the asset
  82443. * @param buffer The glTF buffer property
  82444. * @param byteOffset The byte offset to load
  82445. * @param byteLength The byte length to load
  82446. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82447. */
  82448. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82449. }
  82450. }
  82451. declare module BABYLON.GLTF2 {
  82452. /**
  82453. * Helper class for working with arrays when loading the glTF asset
  82454. */
  82455. export class ArrayItem {
  82456. /**
  82457. * Gets an item from the given array.
  82458. * @param context The context when loading the asset
  82459. * @param array The array to get the item from
  82460. * @param index The index to the array
  82461. * @returns The array item
  82462. */
  82463. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82464. /**
  82465. * Assign an `index` field to each item of the given array.
  82466. * @param array The array of items
  82467. */
  82468. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  82469. }
  82470. /**
  82471. * The glTF 2.0 loader
  82472. */
  82473. export class GLTFLoader implements IGLTFLoader {
  82474. /** @hidden */
  82475. _completePromises: Promise<any>[];
  82476. /** @hidden */
  82477. _forAssetContainer: boolean;
  82478. /** Storage */
  82479. _babylonLights: Light[];
  82480. /** @hidden */
  82481. _disableInstancedMesh: number;
  82482. private _disposed;
  82483. private _parent;
  82484. private _state;
  82485. private _extensions;
  82486. private _rootUrl;
  82487. private _fileName;
  82488. private _uniqueRootUrl;
  82489. private _gltf;
  82490. private _bin;
  82491. private _babylonScene;
  82492. private _rootBabylonMesh;
  82493. private _defaultBabylonMaterialData;
  82494. private static _RegisteredExtensions;
  82495. /**
  82496. * The default glTF sampler.
  82497. */
  82498. static readonly DefaultSampler: ISampler;
  82499. /**
  82500. * Registers a loader extension.
  82501. * @param name The name of the loader extension.
  82502. * @param factory The factory function that creates the loader extension.
  82503. */
  82504. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  82505. /**
  82506. * Unregisters a loader extension.
  82507. * @param name The name of the loader extension.
  82508. * @returns A boolean indicating whether the extension has been unregistered
  82509. */
  82510. static UnregisterExtension(name: string): boolean;
  82511. /**
  82512. * The loader state.
  82513. */
  82514. get state(): Nullable<GLTFLoaderState>;
  82515. /**
  82516. * The object that represents the glTF JSON.
  82517. */
  82518. get gltf(): IGLTF;
  82519. /**
  82520. * The BIN chunk of a binary glTF.
  82521. */
  82522. get bin(): Nullable<IDataBuffer>;
  82523. /**
  82524. * The parent file loader.
  82525. */
  82526. get parent(): GLTFFileLoader;
  82527. /**
  82528. * The Babylon scene when loading the asset.
  82529. */
  82530. get babylonScene(): Scene;
  82531. /**
  82532. * The root Babylon mesh when loading the asset.
  82533. */
  82534. get rootBabylonMesh(): Mesh;
  82535. /** @hidden */
  82536. constructor(parent: GLTFFileLoader);
  82537. /** @hidden */
  82538. dispose(): void;
  82539. /** @hidden */
  82540. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  82541. /** @hidden */
  82542. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82543. private _loadAsync;
  82544. private _loadData;
  82545. private _setupData;
  82546. private _loadExtensions;
  82547. private _checkExtensions;
  82548. private _setState;
  82549. private _createRootNode;
  82550. /**
  82551. * Loads a glTF scene.
  82552. * @param context The context when loading the asset
  82553. * @param scene The glTF scene property
  82554. * @returns A promise that resolves when the load is complete
  82555. */
  82556. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  82557. private _forEachPrimitive;
  82558. private _getMeshes;
  82559. private _getTransformNodes;
  82560. private _getSkeletons;
  82561. private _getAnimationGroups;
  82562. private _startAnimations;
  82563. /**
  82564. * Loads a glTF node.
  82565. * @param context The context when loading the asset
  82566. * @param node The glTF node property
  82567. * @param assign A function called synchronously after parsing the glTF properties
  82568. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  82569. */
  82570. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  82571. private _loadMeshAsync;
  82572. /**
  82573. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  82574. * @param context The context when loading the asset
  82575. * @param name The mesh name when loading the asset
  82576. * @param node The glTF node when loading the asset
  82577. * @param mesh The glTF mesh when loading the asset
  82578. * @param primitive The glTF mesh primitive property
  82579. * @param assign A function called synchronously after parsing the glTF properties
  82580. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82581. */
  82582. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  82583. private _loadVertexDataAsync;
  82584. private _createMorphTargets;
  82585. private _loadMorphTargetsAsync;
  82586. private _loadMorphTargetVertexDataAsync;
  82587. private static _LoadTransform;
  82588. private _loadSkinAsync;
  82589. private _loadBones;
  82590. private _loadBone;
  82591. private _loadSkinInverseBindMatricesDataAsync;
  82592. private _updateBoneMatrices;
  82593. private _getNodeMatrix;
  82594. /**
  82595. * Loads a glTF camera.
  82596. * @param context The context when loading the asset
  82597. * @param camera The glTF camera property
  82598. * @param assign A function called synchronously after parsing the glTF properties
  82599. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  82600. */
  82601. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  82602. private _loadAnimationsAsync;
  82603. /**
  82604. * Loads a glTF animation.
  82605. * @param context The context when loading the asset
  82606. * @param animation The glTF animation property
  82607. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  82608. */
  82609. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  82610. /**
  82611. * @hidden Loads a glTF animation channel.
  82612. * @param context The context when loading the asset
  82613. * @param animationContext The context of the animation when loading the asset
  82614. * @param animation The glTF animation property
  82615. * @param channel The glTF animation channel property
  82616. * @param babylonAnimationGroup The babylon animation group property
  82617. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  82618. * @returns A void promise when the channel load is complete
  82619. */
  82620. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  82621. private _loadAnimationSamplerAsync;
  82622. private _loadBufferAsync;
  82623. /**
  82624. * Loads a glTF buffer view.
  82625. * @param context The context when loading the asset
  82626. * @param bufferView The glTF buffer view property
  82627. * @returns A promise that resolves with the loaded data when the load is complete
  82628. */
  82629. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  82630. private _loadAccessorAsync;
  82631. /** @hidden */
  82632. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  82633. private _loadIndicesAccessorAsync;
  82634. private _loadVertexBufferViewAsync;
  82635. private _loadVertexAccessorAsync;
  82636. private _loadMaterialMetallicRoughnessPropertiesAsync;
  82637. /** @hidden */
  82638. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  82639. private _createDefaultMaterial;
  82640. /**
  82641. * Creates a Babylon material from a glTF material.
  82642. * @param context The context when loading the asset
  82643. * @param material The glTF material property
  82644. * @param babylonDrawMode The draw mode for the Babylon material
  82645. * @returns The Babylon material
  82646. */
  82647. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  82648. /**
  82649. * Loads properties from a glTF material into a Babylon material.
  82650. * @param context The context when loading the asset
  82651. * @param material The glTF material property
  82652. * @param babylonMaterial The Babylon material
  82653. * @returns A promise that resolves when the load is complete
  82654. */
  82655. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82656. /**
  82657. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  82658. * @param context The context when loading the asset
  82659. * @param material The glTF material property
  82660. * @param babylonMaterial The Babylon material
  82661. * @returns A promise that resolves when the load is complete
  82662. */
  82663. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82664. /**
  82665. * Loads the alpha properties from a glTF material into a Babylon material.
  82666. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  82667. * @param context The context when loading the asset
  82668. * @param material The glTF material property
  82669. * @param babylonMaterial The Babylon material
  82670. */
  82671. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  82672. /**
  82673. * Loads a glTF texture info.
  82674. * @param context The context when loading the asset
  82675. * @param textureInfo The glTF texture info property
  82676. * @param assign A function called synchronously after parsing the glTF properties
  82677. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  82678. */
  82679. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82680. /** @hidden */
  82681. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82682. /** @hidden */
  82683. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82684. private _loadSampler;
  82685. /**
  82686. * Loads a glTF image.
  82687. * @param context The context when loading the asset
  82688. * @param image The glTF image property
  82689. * @returns A promise that resolves with the loaded data when the load is complete
  82690. */
  82691. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  82692. /**
  82693. * Loads a glTF uri.
  82694. * @param context The context when loading the asset
  82695. * @param property The glTF property associated with the uri
  82696. * @param uri The base64 or relative uri
  82697. * @returns A promise that resolves with the loaded data when the load is complete
  82698. */
  82699. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  82700. /**
  82701. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  82702. * @param babylonObject the Babylon object with metadata
  82703. * @param pointer the JSON pointer
  82704. */
  82705. static AddPointerMetadata(babylonObject: {
  82706. metadata: any;
  82707. }, pointer: string): void;
  82708. private static _GetTextureWrapMode;
  82709. private static _GetTextureSamplingMode;
  82710. private static _GetTypedArrayConstructor;
  82711. private static _GetTypedArray;
  82712. private static _GetNumComponents;
  82713. private static _ValidateUri;
  82714. /** @hidden */
  82715. static _GetDrawMode(context: string, mode: number | undefined): number;
  82716. private _compileMaterialsAsync;
  82717. private _compileShadowGeneratorsAsync;
  82718. private _forEachExtensions;
  82719. private _applyExtensions;
  82720. private _extensionsOnLoading;
  82721. private _extensionsOnReady;
  82722. private _extensionsLoadSceneAsync;
  82723. private _extensionsLoadNodeAsync;
  82724. private _extensionsLoadCameraAsync;
  82725. private _extensionsLoadVertexDataAsync;
  82726. private _extensionsLoadMeshPrimitiveAsync;
  82727. private _extensionsLoadMaterialAsync;
  82728. private _extensionsCreateMaterial;
  82729. private _extensionsLoadMaterialPropertiesAsync;
  82730. private _extensionsLoadTextureInfoAsync;
  82731. private _extensionsLoadTextureAsync;
  82732. private _extensionsLoadAnimationAsync;
  82733. private _extensionsLoadSkinAsync;
  82734. private _extensionsLoadUriAsync;
  82735. private _extensionsLoadBufferViewAsync;
  82736. private _extensionsLoadBufferAsync;
  82737. /**
  82738. * Helper method called by a loader extension to load an glTF extension.
  82739. * @param context The context when loading the asset
  82740. * @param property The glTF property to load the extension from
  82741. * @param extensionName The name of the extension to load
  82742. * @param actionAsync The action to run
  82743. * @returns The promise returned by actionAsync or null if the extension does not exist
  82744. */
  82745. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82746. /**
  82747. * Helper method called by a loader extension to load a glTF extra.
  82748. * @param context The context when loading the asset
  82749. * @param property The glTF property to load the extra from
  82750. * @param extensionName The name of the extension to load
  82751. * @param actionAsync The action to run
  82752. * @returns The promise returned by actionAsync or null if the extra does not exist
  82753. */
  82754. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82755. /**
  82756. * Checks for presence of an extension.
  82757. * @param name The name of the extension to check
  82758. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  82759. */
  82760. isExtensionUsed(name: string): boolean;
  82761. /**
  82762. * Increments the indentation level and logs a message.
  82763. * @param message The message to log
  82764. */
  82765. logOpen(message: string): void;
  82766. /**
  82767. * Decrements the indentation level.
  82768. */
  82769. logClose(): void;
  82770. /**
  82771. * Logs a message
  82772. * @param message The message to log
  82773. */
  82774. log(message: string): void;
  82775. /**
  82776. * Starts a performance counter.
  82777. * @param counterName The name of the performance counter
  82778. */
  82779. startPerformanceCounter(counterName: string): void;
  82780. /**
  82781. * Ends a performance counter.
  82782. * @param counterName The name of the performance counter
  82783. */
  82784. endPerformanceCounter(counterName: string): void;
  82785. }
  82786. }
  82787. declare module BABYLON.GLTF2.Loader.Extensions {
  82788. /** @hidden */
  82789. interface IEXTLightsImageBased_LightImageBased {
  82790. _babylonTexture?: BaseTexture;
  82791. _loaded?: Promise<void>;
  82792. }
  82793. /**
  82794. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  82795. */
  82796. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  82797. /**
  82798. * The name of this extension.
  82799. */
  82800. readonly name: string;
  82801. /**
  82802. * Defines whether this extension is enabled.
  82803. */
  82804. enabled: boolean;
  82805. private _loader;
  82806. private _lights?;
  82807. /** @hidden */
  82808. constructor(loader: GLTFLoader);
  82809. /** @hidden */
  82810. dispose(): void;
  82811. /** @hidden */
  82812. onLoading(): void;
  82813. /** @hidden */
  82814. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82815. private _loadLightAsync;
  82816. }
  82817. }
  82818. declare module BABYLON.GLTF2.Loader.Extensions {
  82819. /**
  82820. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  82821. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  82822. * !!! Experimental Extension Subject to Changes !!!
  82823. */
  82824. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  82825. /**
  82826. * The name of this extension.
  82827. */
  82828. readonly name: string;
  82829. /**
  82830. * Defines whether this extension is enabled.
  82831. */
  82832. enabled: boolean;
  82833. private _loader;
  82834. /** @hidden */
  82835. constructor(loader: GLTFLoader);
  82836. /** @hidden */
  82837. dispose(): void;
  82838. /** @hidden */
  82839. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82840. }
  82841. }
  82842. declare module BABYLON.GLTF2.Loader.Extensions {
  82843. /**
  82844. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  82845. */
  82846. export class EXT_texture_webp implements IGLTFLoaderExtension {
  82847. /** The name of this extension. */
  82848. readonly name: string;
  82849. /** Defines whether this extension is enabled. */
  82850. enabled: boolean;
  82851. private _loader;
  82852. /** @hidden */
  82853. constructor(loader: GLTFLoader);
  82854. /** @hidden */
  82855. dispose(): void;
  82856. /** @hidden */
  82857. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82858. }
  82859. }
  82860. declare module BABYLON.GLTF2.Loader.Extensions {
  82861. /**
  82862. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  82863. */
  82864. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  82865. /**
  82866. * The name of this extension.
  82867. */
  82868. readonly name: string;
  82869. /**
  82870. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  82871. */
  82872. dracoCompression?: DracoCompression;
  82873. /**
  82874. * Defines whether this extension is enabled.
  82875. */
  82876. enabled: boolean;
  82877. private _loader;
  82878. /** @hidden */
  82879. constructor(loader: GLTFLoader);
  82880. /** @hidden */
  82881. dispose(): void;
  82882. /** @hidden */
  82883. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82884. }
  82885. }
  82886. declare module BABYLON.GLTF2.Loader.Extensions {
  82887. /**
  82888. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  82889. */
  82890. export class KHR_lights implements IGLTFLoaderExtension {
  82891. /**
  82892. * The name of this extension.
  82893. */
  82894. readonly name: string;
  82895. /**
  82896. * Defines whether this extension is enabled.
  82897. */
  82898. enabled: boolean;
  82899. private _loader;
  82900. private _lights?;
  82901. /** @hidden */
  82902. constructor(loader: GLTFLoader);
  82903. /** @hidden */
  82904. dispose(): void;
  82905. /** @hidden */
  82906. onLoading(): void;
  82907. /** @hidden */
  82908. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82909. }
  82910. }
  82911. declare module BABYLON.GLTF2.Loader.Extensions {
  82912. /**
  82913. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  82914. */
  82915. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  82916. /**
  82917. * The name of this extension.
  82918. */
  82919. readonly name: string;
  82920. /**
  82921. * Defines whether this extension is enabled.
  82922. */
  82923. enabled: boolean;
  82924. /**
  82925. * Defines a number that determines the order the extensions are applied.
  82926. */
  82927. order: number;
  82928. private _loader;
  82929. /** @hidden */
  82930. constructor(loader: GLTFLoader);
  82931. /** @hidden */
  82932. dispose(): void;
  82933. /** @hidden */
  82934. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82935. private _loadSpecularGlossinessPropertiesAsync;
  82936. }
  82937. }
  82938. declare module BABYLON.GLTF2.Loader.Extensions {
  82939. /**
  82940. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  82941. */
  82942. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  82943. /**
  82944. * The name of this extension.
  82945. */
  82946. readonly name: string;
  82947. /**
  82948. * Defines whether this extension is enabled.
  82949. */
  82950. enabled: boolean;
  82951. /**
  82952. * Defines a number that determines the order the extensions are applied.
  82953. */
  82954. order: number;
  82955. private _loader;
  82956. /** @hidden */
  82957. constructor(loader: GLTFLoader);
  82958. /** @hidden */
  82959. dispose(): void;
  82960. /** @hidden */
  82961. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82962. private _loadUnlitPropertiesAsync;
  82963. }
  82964. }
  82965. declare module BABYLON.GLTF2.Loader.Extensions {
  82966. /**
  82967. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  82968. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  82969. * !!! Experimental Extension Subject to Changes !!!
  82970. */
  82971. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  82972. /**
  82973. * The name of this extension.
  82974. */
  82975. readonly name: string;
  82976. /**
  82977. * Defines whether this extension is enabled.
  82978. */
  82979. enabled: boolean;
  82980. /**
  82981. * Defines a number that determines the order the extensions are applied.
  82982. */
  82983. order: number;
  82984. private _loader;
  82985. /** @hidden */
  82986. constructor(loader: GLTFLoader);
  82987. /** @hidden */
  82988. dispose(): void;
  82989. /** @hidden */
  82990. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82991. private _loadClearCoatPropertiesAsync;
  82992. }
  82993. }
  82994. declare module BABYLON.GLTF2.Loader.Extensions {
  82995. /**
  82996. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  82997. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  82998. * !!! Experimental Extension Subject to Changes !!!
  82999. */
  83000. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83001. /**
  83002. * The name of this extension.
  83003. */
  83004. readonly name: string;
  83005. /**
  83006. * Defines whether this extension is enabled.
  83007. */
  83008. enabled: boolean;
  83009. /**
  83010. * Defines a number that determines the order the extensions are applied.
  83011. */
  83012. order: number;
  83013. private _loader;
  83014. /** @hidden */
  83015. constructor(loader: GLTFLoader);
  83016. /** @hidden */
  83017. dispose(): void;
  83018. /** @hidden */
  83019. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83020. private _loadSheenPropertiesAsync;
  83021. }
  83022. }
  83023. declare module BABYLON.GLTF2.Loader.Extensions {
  83024. /**
  83025. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83026. * !!! Experimental Extension Subject to Changes !!!
  83027. */
  83028. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83029. /**
  83030. * The name of this extension.
  83031. */
  83032. readonly name: string;
  83033. /**
  83034. * Defines whether this extension is enabled.
  83035. */
  83036. enabled: boolean;
  83037. /**
  83038. * Defines a number that determines the order the extensions are applied.
  83039. */
  83040. order: number;
  83041. private _loader;
  83042. /** @hidden */
  83043. constructor(loader: GLTFLoader);
  83044. /** @hidden */
  83045. dispose(): void;
  83046. /** @hidden */
  83047. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83048. private _loadSpecularPropertiesAsync;
  83049. }
  83050. }
  83051. declare module BABYLON.GLTF2.Loader.Extensions {
  83052. /**
  83053. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83054. * !!! Experimental Extension Subject to Changes !!!
  83055. */
  83056. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83057. /**
  83058. * Default ior Value from the spec.
  83059. */
  83060. private static readonly _DEFAULT_IOR;
  83061. /**
  83062. * The name of this extension.
  83063. */
  83064. readonly name: string;
  83065. /**
  83066. * Defines whether this extension is enabled.
  83067. */
  83068. enabled: boolean;
  83069. /**
  83070. * Defines a number that determines the order the extensions are applied.
  83071. */
  83072. order: number;
  83073. private _loader;
  83074. /** @hidden */
  83075. constructor(loader: GLTFLoader);
  83076. /** @hidden */
  83077. dispose(): void;
  83078. /** @hidden */
  83079. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83080. private _loadIorPropertiesAsync;
  83081. }
  83082. }
  83083. declare module BABYLON.GLTF2.Loader.Extensions {
  83084. /**
  83085. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83086. * !!! Experimental Extension Subject to Changes !!!
  83087. */
  83088. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83089. /**
  83090. * The name of this extension.
  83091. */
  83092. readonly name: string;
  83093. /**
  83094. * Defines whether this extension is enabled.
  83095. */
  83096. enabled: boolean;
  83097. private _loader;
  83098. private _variants?;
  83099. /** @hidden */
  83100. constructor(loader: GLTFLoader);
  83101. /** @hidden */
  83102. dispose(): void;
  83103. /**
  83104. * Gets the list of available variant names for this asset.
  83105. * @param rootMesh The glTF root mesh
  83106. * @returns the list of all the variant names for this model
  83107. */
  83108. static GetAvailableVariants(rootMesh: Mesh): string[];
  83109. /**
  83110. * Gets the list of available variant names for this asset.
  83111. * @param rootMesh The glTF root mesh
  83112. * @returns the list of all the variant names for this model
  83113. */
  83114. getAvailableVariants(rootMesh: Mesh): string[];
  83115. /**
  83116. * Select a variant given a variant name or a list of variant names.
  83117. * @param rootMesh The glTF root mesh
  83118. * @param variantName The variant name(s) to select.
  83119. */
  83120. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83121. /**
  83122. * Select a variant given a variant name or a list of variant names.
  83123. * @param rootMesh The glTF root mesh
  83124. * @param variantName The variant name(s) to select.
  83125. */
  83126. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83127. /**
  83128. * Reset back to the original before selecting a variant.
  83129. * @param rootMesh The glTF root mesh
  83130. */
  83131. static Reset(rootMesh: Mesh): void;
  83132. /**
  83133. * Reset back to the original before selecting a variant.
  83134. * @param rootMesh The glTF root mesh
  83135. */
  83136. reset(rootMesh: Mesh): void;
  83137. /**
  83138. * Gets the last selected variant name(s) or null if original.
  83139. * @param rootMesh The glTF root mesh
  83140. * @returns The selected variant name(s).
  83141. */
  83142. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83143. /**
  83144. * Gets the last selected variant name(s) or null if original.
  83145. * @param rootMesh The glTF root mesh
  83146. * @returns The selected variant name(s).
  83147. */
  83148. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83149. private static _GetExtensionMetadata;
  83150. /** @hidden */
  83151. onLoading(): void;
  83152. /** @hidden */
  83153. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83154. }
  83155. }
  83156. declare module BABYLON.GLTF2.Loader.Extensions {
  83157. /**
  83158. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83159. * !!! Experimental Extension Subject to Changes !!!
  83160. */
  83161. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83162. /**
  83163. * The name of this extension.
  83164. */
  83165. readonly name: string;
  83166. /**
  83167. * Defines whether this extension is enabled.
  83168. */
  83169. enabled: boolean;
  83170. /**
  83171. * Defines a number that determines the order the extensions are applied.
  83172. */
  83173. order: number;
  83174. private _loader;
  83175. /** @hidden */
  83176. constructor(loader: GLTFLoader);
  83177. /** @hidden */
  83178. dispose(): void;
  83179. /** @hidden */
  83180. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83181. private _loadTransparentPropertiesAsync;
  83182. }
  83183. }
  83184. declare module BABYLON.GLTF2.Loader.Extensions {
  83185. /**
  83186. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83187. */
  83188. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83189. /**
  83190. * The name of this extension.
  83191. */
  83192. readonly name: string;
  83193. /**
  83194. * Defines whether this extension is enabled.
  83195. */
  83196. enabled: boolean;
  83197. /** @hidden */
  83198. constructor(loader: GLTFLoader);
  83199. /** @hidden */
  83200. dispose(): void;
  83201. }
  83202. }
  83203. declare module BABYLON.GLTF2.Loader.Extensions {
  83204. /**
  83205. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83206. * !!! Experimental Extension Subject to Changes !!!
  83207. */
  83208. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83209. /** The name of this extension. */
  83210. readonly name: string;
  83211. /** Defines whether this extension is enabled. */
  83212. enabled: boolean;
  83213. private _loader;
  83214. /** @hidden */
  83215. constructor(loader: GLTFLoader);
  83216. /** @hidden */
  83217. dispose(): void;
  83218. /** @hidden */
  83219. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83220. }
  83221. }
  83222. declare module BABYLON.GLTF2.Loader.Extensions {
  83223. /**
  83224. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83225. */
  83226. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83227. /**
  83228. * The name of this extension.
  83229. */
  83230. readonly name: string;
  83231. /**
  83232. * Defines whether this extension is enabled.
  83233. */
  83234. enabled: boolean;
  83235. private _loader;
  83236. /** @hidden */
  83237. constructor(loader: GLTFLoader);
  83238. /** @hidden */
  83239. dispose(): void;
  83240. /** @hidden */
  83241. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83242. }
  83243. }
  83244. declare module BABYLON.GLTF2.Loader.Extensions {
  83245. /**
  83246. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83247. * !!! Experimental Extension Subject to Changes !!!
  83248. */
  83249. export class KHR_xmp implements IGLTFLoaderExtension {
  83250. /**
  83251. * The name of this extension.
  83252. */
  83253. readonly name: string;
  83254. /**
  83255. * Defines whether this extension is enabled.
  83256. */
  83257. enabled: boolean;
  83258. /**
  83259. * Defines a number that determines the order the extensions are applied.
  83260. */
  83261. order: number;
  83262. private _loader;
  83263. /** @hidden */
  83264. constructor(loader: GLTFLoader);
  83265. /** @hidden */
  83266. dispose(): void;
  83267. /**
  83268. * Called after the loader state changes to LOADING.
  83269. */
  83270. onLoading(): void;
  83271. }
  83272. }
  83273. declare module BABYLON.GLTF2.Loader.Extensions {
  83274. /**
  83275. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83276. */
  83277. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83278. /**
  83279. * The name of this extension.
  83280. */
  83281. readonly name: string;
  83282. /**
  83283. * Defines whether this extension is enabled.
  83284. */
  83285. enabled: boolean;
  83286. private _loader;
  83287. private _clips;
  83288. private _emitters;
  83289. /** @hidden */
  83290. constructor(loader: GLTFLoader);
  83291. /** @hidden */
  83292. dispose(): void;
  83293. /** @hidden */
  83294. onLoading(): void;
  83295. /** @hidden */
  83296. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83297. /** @hidden */
  83298. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83299. /** @hidden */
  83300. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83301. private _loadClipAsync;
  83302. private _loadEmitterAsync;
  83303. private _getEventAction;
  83304. private _loadAnimationEventAsync;
  83305. }
  83306. }
  83307. declare module BABYLON.GLTF2.Loader.Extensions {
  83308. /**
  83309. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83310. */
  83311. export class MSFT_lod implements IGLTFLoaderExtension {
  83312. /**
  83313. * The name of this extension.
  83314. */
  83315. readonly name: string;
  83316. /**
  83317. * Defines whether this extension is enabled.
  83318. */
  83319. enabled: boolean;
  83320. /**
  83321. * Defines a number that determines the order the extensions are applied.
  83322. */
  83323. order: number;
  83324. /**
  83325. * Maximum number of LODs to load, starting from the lowest LOD.
  83326. */
  83327. maxLODsToLoad: number;
  83328. /**
  83329. * Observable raised when all node LODs of one level are loaded.
  83330. * The event data is the index of the loaded LOD starting from zero.
  83331. * Dispose the loader to cancel the loading of the next level of LODs.
  83332. */
  83333. onNodeLODsLoadedObservable: Observable<number>;
  83334. /**
  83335. * Observable raised when all material LODs of one level are loaded.
  83336. * The event data is the index of the loaded LOD starting from zero.
  83337. * Dispose the loader to cancel the loading of the next level of LODs.
  83338. */
  83339. onMaterialLODsLoadedObservable: Observable<number>;
  83340. private _loader;
  83341. private _bufferLODs;
  83342. private _nodeIndexLOD;
  83343. private _nodeSignalLODs;
  83344. private _nodePromiseLODs;
  83345. private _nodeBufferLODs;
  83346. private _materialIndexLOD;
  83347. private _materialSignalLODs;
  83348. private _materialPromiseLODs;
  83349. private _materialBufferLODs;
  83350. /** @hidden */
  83351. constructor(loader: GLTFLoader);
  83352. /** @hidden */
  83353. dispose(): void;
  83354. /** @hidden */
  83355. onReady(): void;
  83356. /** @hidden */
  83357. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83358. /** @hidden */
  83359. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83360. /** @hidden */
  83361. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83362. /** @hidden */
  83363. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83364. /** @hidden */
  83365. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83366. private _loadBufferLOD;
  83367. /**
  83368. * Gets an array of LOD properties from lowest to highest.
  83369. */
  83370. private _getLODs;
  83371. private _disposeTransformNode;
  83372. private _disposeMaterials;
  83373. }
  83374. }
  83375. declare module BABYLON.GLTF2.Loader.Extensions {
  83376. /** @hidden */
  83377. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83378. readonly name: string;
  83379. enabled: boolean;
  83380. private _loader;
  83381. constructor(loader: GLTFLoader);
  83382. dispose(): void;
  83383. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83384. }
  83385. }
  83386. declare module BABYLON.GLTF2.Loader.Extensions {
  83387. /** @hidden */
  83388. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83389. readonly name: string;
  83390. enabled: boolean;
  83391. private _loader;
  83392. constructor(loader: GLTFLoader);
  83393. dispose(): void;
  83394. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83395. }
  83396. }
  83397. declare module BABYLON.GLTF2.Loader.Extensions {
  83398. /**
  83399. * Store glTF extras (if present) in BJS objects' metadata
  83400. */
  83401. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83402. /**
  83403. * The name of this extension.
  83404. */
  83405. readonly name: string;
  83406. /**
  83407. * Defines whether this extension is enabled.
  83408. */
  83409. enabled: boolean;
  83410. private _loader;
  83411. private _assignExtras;
  83412. /** @hidden */
  83413. constructor(loader: GLTFLoader);
  83414. /** @hidden */
  83415. dispose(): void;
  83416. /** @hidden */
  83417. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83418. /** @hidden */
  83419. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83420. /** @hidden */
  83421. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83422. }
  83423. }
  83424. declare module BABYLON {
  83425. /**
  83426. * Class reading and parsing the MTL file bundled with the obj file.
  83427. */
  83428. export class MTLFileLoader {
  83429. /**
  83430. * Invert Y-Axis of referenced textures on load
  83431. */
  83432. static INVERT_TEXTURE_Y: boolean;
  83433. /**
  83434. * All material loaded from the mtl will be set here
  83435. */
  83436. materials: StandardMaterial[];
  83437. /**
  83438. * This function will read the mtl file and create each material described inside
  83439. * This function could be improve by adding :
  83440. * -some component missing (Ni, Tf...)
  83441. * -including the specific options available
  83442. *
  83443. * @param scene defines the scene the material will be created in
  83444. * @param data defines the mtl data to parse
  83445. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83446. * @param forAssetContainer defines if the material should be registered in the scene
  83447. */
  83448. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83449. /**
  83450. * Gets the texture for the material.
  83451. *
  83452. * If the material is imported from input file,
  83453. * We sanitize the url to ensure it takes the textre from aside the material.
  83454. *
  83455. * @param rootUrl The root url to load from
  83456. * @param value The value stored in the mtl
  83457. * @return The Texture
  83458. */
  83459. private static _getTexture;
  83460. }
  83461. }
  83462. declare module BABYLON {
  83463. /**
  83464. * Options for loading OBJ/MTL files
  83465. */
  83466. type MeshLoadOptions = {
  83467. /**
  83468. * Defines if UVs are optimized by default during load.
  83469. */
  83470. OptimizeWithUV: boolean;
  83471. /**
  83472. * Defines custom scaling of UV coordinates of loaded meshes.
  83473. */
  83474. UVScaling: Vector2;
  83475. /**
  83476. * Invert model on y-axis (does a model scaling inversion)
  83477. */
  83478. InvertY: boolean;
  83479. /**
  83480. * Invert Y-Axis of referenced textures on load
  83481. */
  83482. InvertTextureY: boolean;
  83483. /**
  83484. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83485. */
  83486. ImportVertexColors: boolean;
  83487. /**
  83488. * Compute the normals for the model, even if normals are present in the file.
  83489. */
  83490. ComputeNormals: boolean;
  83491. /**
  83492. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83493. */
  83494. SkipMaterials: boolean;
  83495. /**
  83496. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83497. */
  83498. MaterialLoadingFailsSilently: boolean;
  83499. };
  83500. /**
  83501. * OBJ file type loader.
  83502. * This is a babylon scene loader plugin.
  83503. */
  83504. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  83505. /**
  83506. * Defines if UVs are optimized by default during load.
  83507. */
  83508. static OPTIMIZE_WITH_UV: boolean;
  83509. /**
  83510. * Invert model on y-axis (does a model scaling inversion)
  83511. */
  83512. static INVERT_Y: boolean;
  83513. /**
  83514. * Invert Y-Axis of referenced textures on load
  83515. */
  83516. static get INVERT_TEXTURE_Y(): boolean;
  83517. static set INVERT_TEXTURE_Y(value: boolean);
  83518. /**
  83519. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83520. */
  83521. static IMPORT_VERTEX_COLORS: boolean;
  83522. /**
  83523. * Compute the normals for the model, even if normals are present in the file.
  83524. */
  83525. static COMPUTE_NORMALS: boolean;
  83526. /**
  83527. * Defines custom scaling of UV coordinates of loaded meshes.
  83528. */
  83529. static UV_SCALING: Vector2;
  83530. /**
  83531. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83532. */
  83533. static SKIP_MATERIALS: boolean;
  83534. /**
  83535. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83536. *
  83537. * Defaults to true for backwards compatibility.
  83538. */
  83539. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  83540. /**
  83541. * Defines the name of the plugin.
  83542. */
  83543. name: string;
  83544. /**
  83545. * Defines the extension the plugin is able to load.
  83546. */
  83547. extensions: string;
  83548. /** @hidden */
  83549. obj: RegExp;
  83550. /** @hidden */
  83551. group: RegExp;
  83552. /** @hidden */
  83553. mtllib: RegExp;
  83554. /** @hidden */
  83555. usemtl: RegExp;
  83556. /** @hidden */
  83557. smooth: RegExp;
  83558. /** @hidden */
  83559. vertexPattern: RegExp;
  83560. /** @hidden */
  83561. normalPattern: RegExp;
  83562. /** @hidden */
  83563. uvPattern: RegExp;
  83564. /** @hidden */
  83565. facePattern1: RegExp;
  83566. /** @hidden */
  83567. facePattern2: RegExp;
  83568. /** @hidden */
  83569. facePattern3: RegExp;
  83570. /** @hidden */
  83571. facePattern4: RegExp;
  83572. /** @hidden */
  83573. facePattern5: RegExp;
  83574. private _forAssetContainer;
  83575. private _meshLoadOptions;
  83576. /**
  83577. * Creates loader for .OBJ files
  83578. *
  83579. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  83580. */
  83581. constructor(meshLoadOptions?: MeshLoadOptions);
  83582. private static get currentMeshLoadOptions();
  83583. /**
  83584. * Calls synchronously the MTL file attached to this obj.
  83585. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  83586. * Without this function materials are not displayed in the first frame (but displayed after).
  83587. * In consequence it is impossible to get material information in your HTML file
  83588. *
  83589. * @param url The URL of the MTL file
  83590. * @param rootUrl
  83591. * @param onSuccess Callback function to be called when the MTL file is loaded
  83592. * @private
  83593. */
  83594. private _loadMTL;
  83595. /**
  83596. * Instantiates a OBJ file loader plugin.
  83597. * @returns the created plugin
  83598. */
  83599. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  83600. /**
  83601. * If the data string can be loaded directly.
  83602. *
  83603. * @param data string containing the file data
  83604. * @returns if the data can be loaded directly
  83605. */
  83606. canDirectLoad(data: string): boolean;
  83607. /**
  83608. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  83609. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83610. * @param scene the scene the meshes should be added to
  83611. * @param data the OBJ data to load
  83612. * @param rootUrl root url to load from
  83613. * @param onProgress event that fires when loading progress has occured
  83614. * @param fileName Defines the name of the file to load
  83615. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83616. */
  83617. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  83618. meshes: AbstractMesh[];
  83619. particleSystems: IParticleSystem[];
  83620. skeletons: Skeleton[];
  83621. animationGroups: AnimationGroup[];
  83622. }>;
  83623. /**
  83624. * Imports all objects from the loaded OBJ data and adds them to the scene
  83625. * @param scene the scene the objects should be added to
  83626. * @param data the OBJ data to load
  83627. * @param rootUrl root url to load from
  83628. * @param onProgress event that fires when loading progress has occured
  83629. * @param fileName Defines the name of the file to load
  83630. * @returns a promise which completes when objects have been loaded to the scene
  83631. */
  83632. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83633. /**
  83634. * Load into an asset container.
  83635. * @param scene The scene to load into
  83636. * @param data The data to import
  83637. * @param rootUrl The root url for scene and resources
  83638. * @param onProgress The callback when the load progresses
  83639. * @param fileName Defines the name of the file to load
  83640. * @returns The loaded asset container
  83641. */
  83642. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  83643. /**
  83644. * Read the OBJ file and create an Array of meshes.
  83645. * Each mesh contains all information given by the OBJ and the MTL file.
  83646. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  83647. *
  83648. * @param meshesNames
  83649. * @param scene Scene The scene where are displayed the data
  83650. * @param data String The content of the obj file
  83651. * @param rootUrl String The path to the folder
  83652. * @returns Array<AbstractMesh>
  83653. * @private
  83654. */
  83655. private _parseSolid;
  83656. }
  83657. }
  83658. declare module BABYLON {
  83659. /**
  83660. * STL file type loader.
  83661. * This is a babylon scene loader plugin.
  83662. */
  83663. export class STLFileLoader implements ISceneLoaderPlugin {
  83664. /** @hidden */
  83665. solidPattern: RegExp;
  83666. /** @hidden */
  83667. facetsPattern: RegExp;
  83668. /** @hidden */
  83669. normalPattern: RegExp;
  83670. /** @hidden */
  83671. vertexPattern: RegExp;
  83672. /**
  83673. * Defines the name of the plugin.
  83674. */
  83675. name: string;
  83676. /**
  83677. * Defines the extensions the stl loader is able to load.
  83678. * force data to come in as an ArrayBuffer
  83679. * we'll convert to string if it looks like it's an ASCII .stl
  83680. */
  83681. extensions: ISceneLoaderPluginExtensions;
  83682. /**
  83683. * Import meshes into a scene.
  83684. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  83685. * @param scene The scene to import into
  83686. * @param data The data to import
  83687. * @param rootUrl The root url for scene and resources
  83688. * @param meshes The meshes array to import into
  83689. * @param particleSystems The particle systems array to import into
  83690. * @param skeletons The skeletons array to import into
  83691. * @param onError The callback when import fails
  83692. * @returns True if successful or false otherwise
  83693. */
  83694. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  83695. /**
  83696. * Load into a scene.
  83697. * @param scene The scene to load into
  83698. * @param data The data to import
  83699. * @param rootUrl The root url for scene and resources
  83700. * @param onError The callback when import fails
  83701. * @returns true if successful or false otherwise
  83702. */
  83703. load(scene: Scene, data: any, rootUrl: string): boolean;
  83704. /**
  83705. * Load into an asset container.
  83706. * @param scene The scene to load into
  83707. * @param data The data to import
  83708. * @param rootUrl The root url for scene and resources
  83709. * @param onError The callback when import fails
  83710. * @returns The loaded asset container
  83711. */
  83712. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  83713. private _isBinary;
  83714. private _parseBinary;
  83715. private _parseASCII;
  83716. }
  83717. }
  83718. declare module BABYLON {
  83719. /**
  83720. * Class for generating OBJ data from a Babylon scene.
  83721. */
  83722. export class OBJExport {
  83723. /**
  83724. * Exports the geometry of a Mesh array in .OBJ file format (text)
  83725. * @param mesh defines the list of meshes to serialize
  83726. * @param materials defines if materials should be exported
  83727. * @param matlibname defines the name of the associated mtl file
  83728. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  83729. * @returns the OBJ content
  83730. */
  83731. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  83732. /**
  83733. * Exports the material(s) of a mesh in .MTL file format (text)
  83734. * @param mesh defines the mesh to extract the material from
  83735. * @returns the mtl content
  83736. */
  83737. static MTL(mesh: Mesh): string;
  83738. }
  83739. }
  83740. declare module BABYLON {
  83741. /** @hidden */
  83742. export var __IGLTFExporterExtension: number;
  83743. /**
  83744. * Interface for extending the exporter
  83745. * @hidden
  83746. */
  83747. export interface IGLTFExporterExtension {
  83748. /**
  83749. * The name of this extension
  83750. */
  83751. readonly name: string;
  83752. /**
  83753. * Defines whether this extension is enabled
  83754. */
  83755. enabled: boolean;
  83756. /**
  83757. * Defines whether this extension is required
  83758. */
  83759. required: boolean;
  83760. }
  83761. }
  83762. declare module BABYLON.GLTF2.Exporter {
  83763. /** @hidden */
  83764. export var __IGLTFExporterExtensionV2: number;
  83765. /**
  83766. * Interface for a glTF exporter extension
  83767. * @hidden
  83768. */
  83769. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  83770. /**
  83771. * Define this method to modify the default behavior before exporting a texture
  83772. * @param context The context when loading the asset
  83773. * @param babylonTexture The Babylon.js texture
  83774. * @param mimeType The mime-type of the generated image
  83775. * @returns A promise that resolves with the exported texture
  83776. */
  83777. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  83778. /**
  83779. * Define this method to get notified when a texture info is created
  83780. * @param context The context when loading the asset
  83781. * @param textureInfo The glTF texture info
  83782. * @param babylonTexture The Babylon.js texture
  83783. */
  83784. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83785. /**
  83786. * Define this method to modify the default behavior when exporting texture info
  83787. * @param context The context when loading the asset
  83788. * @param meshPrimitive glTF mesh primitive
  83789. * @param babylonSubMesh Babylon submesh
  83790. * @param binaryWriter glTF serializer binary writer instance
  83791. * @returns nullable IMeshPrimitive promise
  83792. */
  83793. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  83794. /**
  83795. * Define this method to modify the default behavior when exporting a node
  83796. * @param context The context when exporting the node
  83797. * @param node glTF node
  83798. * @param babylonNode BabylonJS node
  83799. * @returns nullable INode promise
  83800. */
  83801. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83802. [key: number]: number;
  83803. }): Promise<Nullable<INode>>;
  83804. /**
  83805. * Define this method to modify the default behavior when exporting a material
  83806. * @param material glTF material
  83807. * @param babylonMaterial BabylonJS material
  83808. * @returns nullable IMaterial promise
  83809. */
  83810. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  83811. /**
  83812. * Define this method to return additional textures to export from a material
  83813. * @param material glTF material
  83814. * @param babylonMaterial BabylonJS material
  83815. * @returns List of textures
  83816. */
  83817. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83818. /** Gets a boolean indicating that this extension was used */
  83819. wasUsed: boolean;
  83820. /** Gets a boolean indicating that this extension is required for the file to work */
  83821. required: boolean;
  83822. /**
  83823. * Called after the exporter state changes to EXPORTING
  83824. */
  83825. onExporting?(): void;
  83826. }
  83827. }
  83828. declare module BABYLON.GLTF2.Exporter {
  83829. /**
  83830. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  83831. * @hidden
  83832. */
  83833. export class _GLTFMaterialExporter {
  83834. /**
  83835. * Represents the dielectric specular values for R, G and B
  83836. */
  83837. private static readonly _DielectricSpecular;
  83838. /**
  83839. * Allows the maximum specular power to be defined for material calculations
  83840. */
  83841. private static readonly _MaxSpecularPower;
  83842. /**
  83843. * Mapping to store textures
  83844. */
  83845. private _textureMap;
  83846. /**
  83847. * Numeric tolerance value
  83848. */
  83849. private static readonly _Epsilon;
  83850. /**
  83851. * Reference to the glTF Exporter
  83852. */
  83853. private _exporter;
  83854. constructor(exporter: _Exporter);
  83855. /**
  83856. * Specifies if two colors are approximately equal in value
  83857. * @param color1 first color to compare to
  83858. * @param color2 second color to compare to
  83859. * @param epsilon threshold value
  83860. */
  83861. private static FuzzyEquals;
  83862. /**
  83863. * Gets the materials from a Babylon scene and converts them to glTF materials
  83864. * @param scene babylonjs scene
  83865. * @param mimeType texture mime type
  83866. * @param images array of images
  83867. * @param textures array of textures
  83868. * @param materials array of materials
  83869. * @param imageData mapping of texture names to base64 textures
  83870. * @param hasTextureCoords specifies if texture coordinates are present on the material
  83871. */
  83872. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  83873. /**
  83874. * Makes a copy of the glTF material without the texture parameters
  83875. * @param originalMaterial original glTF material
  83876. * @returns glTF material without texture parameters
  83877. */
  83878. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  83879. /**
  83880. * Specifies if the material has any texture parameters present
  83881. * @param material glTF Material
  83882. * @returns boolean specifying if texture parameters are present
  83883. */
  83884. _hasTexturesPresent(material: IMaterial): boolean;
  83885. /**
  83886. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  83887. * @param babylonStandardMaterial
  83888. * @returns glTF Metallic Roughness Material representation
  83889. */
  83890. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  83891. /**
  83892. * Computes the metallic factor
  83893. * @param diffuse diffused value
  83894. * @param specular specular value
  83895. * @param oneMinusSpecularStrength one minus the specular strength
  83896. * @returns metallic value
  83897. */
  83898. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  83899. /**
  83900. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  83901. * @param glTFMaterial glTF material
  83902. * @param babylonMaterial Babylon material
  83903. */
  83904. private static _SetAlphaMode;
  83905. /**
  83906. * Converts a Babylon Standard Material to a glTF Material
  83907. * @param babylonStandardMaterial BJS Standard Material
  83908. * @param mimeType mime type to use for the textures
  83909. * @param images array of glTF image interfaces
  83910. * @param textures array of glTF texture interfaces
  83911. * @param materials array of glTF material interfaces
  83912. * @param imageData map of image file name to data
  83913. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83914. */
  83915. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83916. private _finishMaterial;
  83917. /**
  83918. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83919. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  83920. * @param mimeType mime type to use for the textures
  83921. * @param images array of glTF image interfaces
  83922. * @param textures array of glTF texture interfaces
  83923. * @param materials array of glTF material interfaces
  83924. * @param imageData map of image file name to data
  83925. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83926. */
  83927. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83928. /**
  83929. * Converts an image typed array buffer to a base64 image
  83930. * @param buffer typed array buffer
  83931. * @param width width of the image
  83932. * @param height height of the image
  83933. * @param mimeType mimetype of the image
  83934. * @returns base64 image string
  83935. */
  83936. private _createBase64FromCanvasAsync;
  83937. /**
  83938. * Generates a white texture based on the specified width and height
  83939. * @param width width of the texture in pixels
  83940. * @param height height of the texture in pixels
  83941. * @param scene babylonjs scene
  83942. * @returns white texture
  83943. */
  83944. private _createWhiteTexture;
  83945. /**
  83946. * 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
  83947. * @param texture1 first texture to resize
  83948. * @param texture2 second texture to resize
  83949. * @param scene babylonjs scene
  83950. * @returns resized textures or null
  83951. */
  83952. private _resizeTexturesToSameDimensions;
  83953. /**
  83954. * Converts an array of pixels to a Float32Array
  83955. * Throws an error if the pixel format is not supported
  83956. * @param pixels - array buffer containing pixel values
  83957. * @returns Float32 of pixels
  83958. */
  83959. private _convertPixelArrayToFloat32;
  83960. /**
  83961. * Convert Specular Glossiness Textures to Metallic Roughness
  83962. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  83963. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  83964. * @param diffuseTexture texture used to store diffuse information
  83965. * @param specularGlossinessTexture texture used to store specular and glossiness information
  83966. * @param factors specular glossiness material factors
  83967. * @param mimeType the mime type to use for the texture
  83968. * @returns pbr metallic roughness interface or null
  83969. */
  83970. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  83971. /**
  83972. * Converts specular glossiness material properties to metallic roughness
  83973. * @param specularGlossiness interface with specular glossiness material properties
  83974. * @returns interface with metallic roughness material properties
  83975. */
  83976. private _convertSpecularGlossinessToMetallicRoughness;
  83977. /**
  83978. * Calculates the surface reflectance, independent of lighting conditions
  83979. * @param color Color source to calculate brightness from
  83980. * @returns number representing the perceived brightness, or zero if color is undefined
  83981. */
  83982. private _getPerceivedBrightness;
  83983. /**
  83984. * Returns the maximum color component value
  83985. * @param color
  83986. * @returns maximum color component value, or zero if color is null or undefined
  83987. */
  83988. private _getMaxComponent;
  83989. /**
  83990. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  83991. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83992. * @param mimeType mime type to use for the textures
  83993. * @param images array of glTF image interfaces
  83994. * @param textures array of glTF texture interfaces
  83995. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83996. * @param imageData map of image file name to data
  83997. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83998. * @returns glTF PBR Metallic Roughness factors
  83999. */
  84000. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84001. private _getGLTFTextureSampler;
  84002. private _getGLTFTextureWrapMode;
  84003. private _getGLTFTextureWrapModesSampler;
  84004. /**
  84005. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84006. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84007. * @param mimeType mime type to use for the textures
  84008. * @param images array of glTF image interfaces
  84009. * @param textures array of glTF texture interfaces
  84010. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84011. * @param imageData map of image file name to data
  84012. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84013. * @returns glTF PBR Metallic Roughness factors
  84014. */
  84015. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84016. /**
  84017. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84018. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84019. * @param mimeType mime type to use for the textures
  84020. * @param images array of glTF image interfaces
  84021. * @param textures array of glTF texture interfaces
  84022. * @param materials array of glTF material interfaces
  84023. * @param imageData map of image file name to data
  84024. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84025. */
  84026. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84027. private setMetallicRoughnessPbrMaterial;
  84028. private getPixelsFromTexture;
  84029. /**
  84030. * Extracts a texture from a Babylon texture into file data and glTF data
  84031. * @param babylonTexture Babylon texture to extract
  84032. * @param mimeType Mime Type of the babylonTexture
  84033. * @return glTF texture info, or null if the texture format is not supported
  84034. */
  84035. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84036. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84037. /**
  84038. * Builds a texture from base64 string
  84039. * @param base64Texture base64 texture string
  84040. * @param baseTextureName Name to use for the texture
  84041. * @param mimeType image mime type for the texture
  84042. * @param images array of images
  84043. * @param textures array of textures
  84044. * @param imageData map of image data
  84045. * @returns glTF texture info, or null if the texture format is not supported
  84046. */
  84047. private _getTextureInfoFromBase64;
  84048. }
  84049. }
  84050. declare module BABYLON {
  84051. /**
  84052. * Class for holding and downloading glTF file data
  84053. */
  84054. export class GLTFData {
  84055. /**
  84056. * Object which contains the file name as the key and its data as the value
  84057. */
  84058. glTFFiles: {
  84059. [fileName: string]: string | Blob;
  84060. };
  84061. /**
  84062. * Initializes the glTF file object
  84063. */
  84064. constructor();
  84065. /**
  84066. * Downloads the glTF data as files based on their names and data
  84067. */
  84068. downloadFiles(): void;
  84069. }
  84070. }
  84071. declare module BABYLON {
  84072. /**
  84073. * Holds a collection of exporter options and parameters
  84074. */
  84075. export interface IExportOptions {
  84076. /**
  84077. * Function which indicates whether a babylon node should be exported or not
  84078. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84079. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84080. */
  84081. shouldExportNode?(node: Node): boolean;
  84082. /**
  84083. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84084. * @param metadata source metadata to read from
  84085. * @returns the data to store to glTF node extras
  84086. */
  84087. metadataSelector?(metadata: any): any;
  84088. /**
  84089. * The sample rate to bake animation curves
  84090. */
  84091. animationSampleRate?: number;
  84092. /**
  84093. * Begin serialization without waiting for the scene to be ready
  84094. */
  84095. exportWithoutWaitingForScene?: boolean;
  84096. /**
  84097. * Indicates if coordinate system swapping root nodes should be included in export
  84098. */
  84099. includeCoordinateSystemConversionNodes?: boolean;
  84100. }
  84101. /**
  84102. * Class for generating glTF data from a Babylon scene.
  84103. */
  84104. export class GLTF2Export {
  84105. /**
  84106. * Exports the geometry of the scene to .gltf file format asynchronously
  84107. * @param scene Babylon scene with scene hierarchy information
  84108. * @param filePrefix File prefix to use when generating the glTF file
  84109. * @param options Exporter options
  84110. * @returns Returns an object with a .gltf file and associates texture names
  84111. * as keys and their data and paths as values
  84112. */
  84113. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84114. private static _PreExportAsync;
  84115. private static _PostExportAsync;
  84116. /**
  84117. * Exports the geometry of the scene to .glb file format asychronously
  84118. * @param scene Babylon scene with scene hierarchy information
  84119. * @param filePrefix File prefix to use when generating glb file
  84120. * @param options Exporter options
  84121. * @returns Returns an object with a .glb filename as key and data as value
  84122. */
  84123. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84124. }
  84125. }
  84126. declare module BABYLON.GLTF2.Exporter {
  84127. /**
  84128. * @hidden
  84129. */
  84130. export class _GLTFUtilities {
  84131. /**
  84132. * Creates a buffer view based on the supplied arguments
  84133. * @param bufferIndex index value of the specified buffer
  84134. * @param byteOffset byte offset value
  84135. * @param byteLength byte length of the bufferView
  84136. * @param byteStride byte distance between conequential elements
  84137. * @param name name of the buffer view
  84138. * @returns bufferView for glTF
  84139. */
  84140. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84141. /**
  84142. * Creates an accessor based on the supplied arguments
  84143. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84144. * @param name The name of the accessor
  84145. * @param type The type of the accessor
  84146. * @param componentType The datatype of components in the attribute
  84147. * @param count The number of attributes referenced by this accessor
  84148. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84149. * @param min Minimum value of each component in this attribute
  84150. * @param max Maximum value of each component in this attribute
  84151. * @returns accessor for glTF
  84152. */
  84153. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84154. /**
  84155. * Calculates the minimum and maximum values of an array of position floats
  84156. * @param positions Positions array of a mesh
  84157. * @param vertexStart Starting vertex offset to calculate min and max values
  84158. * @param vertexCount Number of vertices to check for min and max values
  84159. * @returns min number array and max number array
  84160. */
  84161. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84162. min: number[];
  84163. max: number[];
  84164. };
  84165. /**
  84166. * Converts a new right-handed Vector3
  84167. * @param vector vector3 array
  84168. * @returns right-handed Vector3
  84169. */
  84170. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84171. /**
  84172. * Converts a Vector3 to right-handed
  84173. * @param vector Vector3 to convert to right-handed
  84174. */
  84175. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84176. /**
  84177. * Converts a three element number array to right-handed
  84178. * @param vector number array to convert to right-handed
  84179. */
  84180. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84181. /**
  84182. * Converts a new right-handed Vector3
  84183. * @param vector vector3 array
  84184. * @returns right-handed Vector3
  84185. */
  84186. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84187. /**
  84188. * Converts a Vector3 to right-handed
  84189. * @param vector Vector3 to convert to right-handed
  84190. */
  84191. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84192. /**
  84193. * Converts a three element number array to right-handed
  84194. * @param vector number array to convert to right-handed
  84195. */
  84196. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84197. /**
  84198. * Converts a Vector4 to right-handed
  84199. * @param vector Vector4 to convert to right-handed
  84200. */
  84201. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84202. /**
  84203. * Converts a Vector4 to right-handed
  84204. * @param vector Vector4 to convert to right-handed
  84205. */
  84206. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84207. /**
  84208. * Converts a Quaternion to right-handed
  84209. * @param quaternion Source quaternion to convert to right-handed
  84210. */
  84211. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84212. /**
  84213. * Converts a Quaternion to right-handed
  84214. * @param quaternion Source quaternion to convert to right-handed
  84215. */
  84216. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84217. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84218. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84219. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84220. }
  84221. }
  84222. declare module BABYLON.GLTF2.Exporter {
  84223. /**
  84224. * Converts Babylon Scene into glTF 2.0.
  84225. * @hidden
  84226. */
  84227. export class _Exporter {
  84228. /**
  84229. * Stores the glTF to export
  84230. */
  84231. _glTF: IGLTF;
  84232. /**
  84233. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84234. */
  84235. _bufferViews: IBufferView[];
  84236. /**
  84237. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84238. */
  84239. _accessors: IAccessor[];
  84240. /**
  84241. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84242. */
  84243. _nodes: INode[];
  84244. /**
  84245. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84246. */
  84247. private _scenes;
  84248. /**
  84249. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84250. */
  84251. private _meshes;
  84252. /**
  84253. * Stores all the generated material information, which represents the appearance of each primitive
  84254. */
  84255. _materials: IMaterial[];
  84256. _materialMap: {
  84257. [materialID: number]: number;
  84258. };
  84259. /**
  84260. * Stores all the generated texture information, which is referenced by glTF materials
  84261. */
  84262. _textures: ITexture[];
  84263. /**
  84264. * Stores all the generated image information, which is referenced by glTF textures
  84265. */
  84266. _images: IImage[];
  84267. /**
  84268. * Stores all the texture samplers
  84269. */
  84270. _samplers: ISampler[];
  84271. /**
  84272. * Stores all the generated glTF skins
  84273. */
  84274. _skins: ISkin[];
  84275. /**
  84276. * Stores all the generated animation samplers, which is referenced by glTF animations
  84277. */
  84278. /**
  84279. * Stores the animations for glTF models
  84280. */
  84281. private _animations;
  84282. /**
  84283. * Stores the total amount of bytes stored in the glTF buffer
  84284. */
  84285. private _totalByteLength;
  84286. /**
  84287. * Stores a reference to the Babylon scene containing the source geometry and material information
  84288. */
  84289. _babylonScene: Scene;
  84290. /**
  84291. * Stores a map of the image data, where the key is the file name and the value
  84292. * is the image data
  84293. */
  84294. _imageData: {
  84295. [fileName: string]: {
  84296. data: Uint8Array;
  84297. mimeType: ImageMimeType;
  84298. };
  84299. };
  84300. protected _orderedImageData: Array<{
  84301. data: Uint8Array;
  84302. mimeType: ImageMimeType;
  84303. }>;
  84304. /**
  84305. * Stores a map of the unique id of a node to its index in the node array
  84306. */
  84307. _nodeMap: {
  84308. [key: number]: number;
  84309. };
  84310. /**
  84311. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84312. */
  84313. _convertToRightHandedSystem: boolean;
  84314. /**
  84315. * Specifies if a Babylon node should be converted to right-handed on export
  84316. */
  84317. _convertToRightHandedSystemMap: {
  84318. [nodeId: number]: boolean;
  84319. };
  84320. _includeCoordinateSystemConversionNodes: boolean;
  84321. /**
  84322. * Baked animation sample rate
  84323. */
  84324. private _animationSampleRate;
  84325. private _options;
  84326. private _localEngine;
  84327. _glTFMaterialExporter: _GLTFMaterialExporter;
  84328. private _extensions;
  84329. private static _ExtensionNames;
  84330. private static _ExtensionFactories;
  84331. private _applyExtension;
  84332. private _applyExtensions;
  84333. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84334. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84335. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84336. [key: number]: number;
  84337. }): Promise<Nullable<INode>>;
  84338. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84339. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84340. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84341. private _forEachExtensions;
  84342. private _extensionsOnExporting;
  84343. /**
  84344. * Load glTF serializer extensions
  84345. */
  84346. private _loadExtensions;
  84347. /**
  84348. * Creates a glTF Exporter instance, which can accept optional exporter options
  84349. * @param babylonScene Babylon scene object
  84350. * @param options Options to modify the behavior of the exporter
  84351. */
  84352. constructor(babylonScene: Scene, options?: IExportOptions);
  84353. dispose(): void;
  84354. /**
  84355. * Registers a glTF exporter extension
  84356. * @param name Name of the extension to export
  84357. * @param factory The factory function that creates the exporter extension
  84358. */
  84359. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84360. /**
  84361. * Un-registers an exporter extension
  84362. * @param name The name fo the exporter extension
  84363. * @returns A boolean indicating whether the extension has been un-registered
  84364. */
  84365. static UnregisterExtension(name: string): boolean;
  84366. /**
  84367. * Lazy load a local engine
  84368. */
  84369. _getLocalEngine(): Engine;
  84370. private reorderIndicesBasedOnPrimitiveMode;
  84371. /**
  84372. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84373. * clock-wise during export to glTF
  84374. * @param submesh BabylonJS submesh
  84375. * @param primitiveMode Primitive mode of the mesh
  84376. * @param sideOrientation the winding order of the submesh
  84377. * @param vertexBufferKind The type of vertex attribute
  84378. * @param meshAttributeArray The vertex attribute data
  84379. * @param byteOffset The offset to the binary data
  84380. * @param binaryWriter The binary data for the glTF file
  84381. * @param convertToRightHandedSystem Converts the values to right-handed
  84382. */
  84383. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84384. /**
  84385. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84386. * clock-wise during export to glTF
  84387. * @param submesh BabylonJS submesh
  84388. * @param primitiveMode Primitive mode of the mesh
  84389. * @param sideOrientation the winding order of the submesh
  84390. * @param vertexBufferKind The type of vertex attribute
  84391. * @param meshAttributeArray The vertex attribute data
  84392. * @param byteOffset The offset to the binary data
  84393. * @param binaryWriter The binary data for the glTF file
  84394. * @param convertToRightHandedSystem Converts the values to right-handed
  84395. */
  84396. private reorderTriangleFillMode;
  84397. /**
  84398. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84399. * clock-wise during export to glTF
  84400. * @param submesh BabylonJS submesh
  84401. * @param primitiveMode Primitive mode of the mesh
  84402. * @param sideOrientation the winding order of the submesh
  84403. * @param vertexBufferKind The type of vertex attribute
  84404. * @param meshAttributeArray The vertex attribute data
  84405. * @param byteOffset The offset to the binary data
  84406. * @param binaryWriter The binary data for the glTF file
  84407. * @param convertToRightHandedSystem Converts the values to right-handed
  84408. */
  84409. private reorderTriangleStripDrawMode;
  84410. /**
  84411. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84412. * clock-wise during export to glTF
  84413. * @param submesh BabylonJS submesh
  84414. * @param primitiveMode Primitive mode of the mesh
  84415. * @param sideOrientation the winding order of the submesh
  84416. * @param vertexBufferKind The type of vertex attribute
  84417. * @param meshAttributeArray The vertex attribute data
  84418. * @param byteOffset The offset to the binary data
  84419. * @param binaryWriter The binary data for the glTF file
  84420. * @param convertToRightHandedSystem Converts the values to right-handed
  84421. */
  84422. private reorderTriangleFanMode;
  84423. /**
  84424. * Writes the vertex attribute data to binary
  84425. * @param vertices The vertices to write to the binary writer
  84426. * @param byteOffset The offset into the binary writer to overwrite binary data
  84427. * @param vertexAttributeKind The vertex attribute type
  84428. * @param meshAttributeArray The vertex attribute data
  84429. * @param binaryWriter The writer containing the binary data
  84430. * @param convertToRightHandedSystem Converts the values to right-handed
  84431. */
  84432. private writeVertexAttributeData;
  84433. /**
  84434. * Writes mesh attribute data to a data buffer
  84435. * Returns the bytelength of the data
  84436. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84437. * @param meshAttributeArray Array containing the attribute data
  84438. * @param byteStride Specifies the space between data
  84439. * @param binaryWriter The buffer to write the binary data to
  84440. * @param convertToRightHandedSystem Converts the values to right-handed
  84441. */
  84442. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84443. /**
  84444. * Writes mesh attribute data to a data buffer
  84445. * Returns the bytelength of the data
  84446. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84447. * @param meshAttributeArray Array containing the attribute data
  84448. * @param byteStride Specifies the space between data
  84449. * @param binaryWriter The buffer to write the binary data to
  84450. * @param convertToRightHandedSystem Converts the values to right-handed
  84451. */
  84452. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84453. /**
  84454. * Generates glTF json data
  84455. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84456. * @param glTFPrefix Text to use when prefixing a glTF file
  84457. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84458. * @returns json data as string
  84459. */
  84460. private generateJSON;
  84461. /**
  84462. * Generates data for .gltf and .bin files based on the glTF prefix string
  84463. * @param glTFPrefix Text to use when prefixing a glTF file
  84464. * @param dispose Dispose the exporter
  84465. * @returns GLTFData with glTF file data
  84466. */
  84467. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84468. /**
  84469. * Creates a binary buffer for glTF
  84470. * @returns array buffer for binary data
  84471. */
  84472. private _generateBinaryAsync;
  84473. /**
  84474. * Pads the number to a multiple of 4
  84475. * @param num number to pad
  84476. * @returns padded number
  84477. */
  84478. private _getPadding;
  84479. /**
  84480. * @hidden
  84481. */
  84482. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84483. /**
  84484. * Sets the TRS for each node
  84485. * @param node glTF Node for storing the transformation data
  84486. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  84487. * @param convertToRightHandedSystem Converts the values to right-handed
  84488. */
  84489. private setNodeTransformation;
  84490. private getVertexBufferFromMesh;
  84491. /**
  84492. * Creates a bufferview based on the vertices type for the Babylon mesh
  84493. * @param kind Indicates the type of vertices data
  84494. * @param componentType Indicates the numerical type used to store the data
  84495. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  84496. * @param binaryWriter The buffer to write the bufferview data to
  84497. * @param convertToRightHandedSystem Converts the values to right-handed
  84498. */
  84499. private createBufferViewKind;
  84500. /**
  84501. * Creates a bufferview based on the vertices type for the Babylon mesh
  84502. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  84503. * @param babylonMorphTarget the morph target to be exported
  84504. * @param binaryWriter The buffer to write the bufferview data to
  84505. * @param convertToRightHandedSystem Converts the values to right-handed
  84506. */
  84507. private setMorphTargetAttributes;
  84508. /**
  84509. * The primitive mode of the Babylon mesh
  84510. * @param babylonMesh The BabylonJS mesh
  84511. */
  84512. private getMeshPrimitiveMode;
  84513. /**
  84514. * Sets the primitive mode of the glTF mesh primitive
  84515. * @param meshPrimitive glTF mesh primitive
  84516. * @param primitiveMode The primitive mode
  84517. */
  84518. private setPrimitiveMode;
  84519. /**
  84520. * Sets the vertex attribute accessor based of the glTF mesh primitive
  84521. * @param meshPrimitive glTF mesh primitive
  84522. * @param attributeKind vertex attribute
  84523. * @returns boolean specifying if uv coordinates are present
  84524. */
  84525. private setAttributeKind;
  84526. /**
  84527. * Sets data for the primitive attributes of each submesh
  84528. * @param mesh glTF Mesh object to store the primitive attribute information
  84529. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  84530. * @param binaryWriter Buffer to write the attribute data to
  84531. * @param convertToRightHandedSystem Converts the values to right-handed
  84532. */
  84533. private setPrimitiveAttributesAsync;
  84534. /**
  84535. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  84536. * @param node The node to check
  84537. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  84538. */
  84539. private isBabylonCoordinateSystemConvertingNode;
  84540. /**
  84541. * Creates a glTF scene based on the array of meshes
  84542. * Returns the the total byte offset
  84543. * @param babylonScene Babylon scene to get the mesh data from
  84544. * @param binaryWriter Buffer to write binary data to
  84545. */
  84546. private createSceneAsync;
  84547. /**
  84548. * Creates a mapping of Node unique id to node index and handles animations
  84549. * @param babylonScene Babylon Scene
  84550. * @param nodes Babylon transform nodes
  84551. * @param binaryWriter Buffer to write binary data to
  84552. * @returns Node mapping of unique id to index
  84553. */
  84554. private createNodeMapAndAnimationsAsync;
  84555. /**
  84556. * Creates a glTF node from a Babylon mesh
  84557. * @param babylonMesh Source Babylon mesh
  84558. * @param binaryWriter Buffer for storing geometry data
  84559. * @param convertToRightHandedSystem Converts the values to right-handed
  84560. * @param nodeMap Node mapping of unique id to glTF node index
  84561. * @returns glTF node
  84562. */
  84563. private createNodeAsync;
  84564. /**
  84565. * Creates a glTF skin from a Babylon skeleton
  84566. * @param babylonScene Babylon Scene
  84567. * @param nodes Babylon transform nodes
  84568. * @param binaryWriter Buffer to write binary data to
  84569. * @returns Node mapping of unique id to index
  84570. */
  84571. private createSkinsAsync;
  84572. }
  84573. /**
  84574. * @hidden
  84575. *
  84576. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  84577. */
  84578. export class _BinaryWriter {
  84579. /**
  84580. * Array buffer which stores all binary data
  84581. */
  84582. private _arrayBuffer;
  84583. /**
  84584. * View of the array buffer
  84585. */
  84586. private _dataView;
  84587. /**
  84588. * byte offset of data in array buffer
  84589. */
  84590. private _byteOffset;
  84591. /**
  84592. * Initialize binary writer with an initial byte length
  84593. * @param byteLength Initial byte length of the array buffer
  84594. */
  84595. constructor(byteLength: number);
  84596. /**
  84597. * Resize the array buffer to the specified byte length
  84598. * @param byteLength
  84599. */
  84600. private resizeBuffer;
  84601. /**
  84602. * Get an array buffer with the length of the byte offset
  84603. * @returns ArrayBuffer resized to the byte offset
  84604. */
  84605. getArrayBuffer(): ArrayBuffer;
  84606. /**
  84607. * Get the byte offset of the array buffer
  84608. * @returns byte offset
  84609. */
  84610. getByteOffset(): number;
  84611. /**
  84612. * Stores an UInt8 in the array buffer
  84613. * @param entry
  84614. * @param byteOffset If defined, specifies where to set the value as an offset.
  84615. */
  84616. setUInt8(entry: number, byteOffset?: number): void;
  84617. /**
  84618. * Stores an UInt16 in the array buffer
  84619. * @param entry
  84620. * @param byteOffset If defined, specifies where to set the value as an offset.
  84621. */
  84622. setUInt16(entry: number, byteOffset?: number): void;
  84623. /**
  84624. * Gets an UInt32 in the array buffer
  84625. * @param entry
  84626. * @param byteOffset If defined, specifies where to set the value as an offset.
  84627. */
  84628. getUInt32(byteOffset: number): number;
  84629. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84630. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84631. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84632. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84633. /**
  84634. * Stores a Float32 in the array buffer
  84635. * @param entry
  84636. */
  84637. setFloat32(entry: number, byteOffset?: number): void;
  84638. /**
  84639. * Stores an UInt32 in the array buffer
  84640. * @param entry
  84641. * @param byteOffset If defined, specifies where to set the value as an offset.
  84642. */
  84643. setUInt32(entry: number, byteOffset?: number): void;
  84644. }
  84645. }
  84646. declare module BABYLON.GLTF2.Exporter {
  84647. /**
  84648. * @hidden
  84649. * Interface to store animation data.
  84650. */
  84651. export interface _IAnimationData {
  84652. /**
  84653. * Keyframe data.
  84654. */
  84655. inputs: number[];
  84656. /**
  84657. * Value data.
  84658. */
  84659. outputs: number[][];
  84660. /**
  84661. * Animation interpolation data.
  84662. */
  84663. samplerInterpolation: AnimationSamplerInterpolation;
  84664. /**
  84665. * Minimum keyframe value.
  84666. */
  84667. inputsMin: number;
  84668. /**
  84669. * Maximum keyframe value.
  84670. */
  84671. inputsMax: number;
  84672. }
  84673. /**
  84674. * @hidden
  84675. */
  84676. export interface _IAnimationInfo {
  84677. /**
  84678. * The target channel for the animation
  84679. */
  84680. animationChannelTargetPath: AnimationChannelTargetPath;
  84681. /**
  84682. * The glTF accessor type for the data.
  84683. */
  84684. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  84685. /**
  84686. * Specifies if quaternions should be used.
  84687. */
  84688. useQuaternion: boolean;
  84689. }
  84690. /**
  84691. * @hidden
  84692. * Utility class for generating glTF animation data from BabylonJS.
  84693. */
  84694. export class _GLTFAnimation {
  84695. /**
  84696. * @ignore
  84697. *
  84698. * Creates glTF channel animation from BabylonJS animation.
  84699. * @param babylonTransformNode - BabylonJS mesh.
  84700. * @param animation - animation.
  84701. * @param animationChannelTargetPath - The target animation channel.
  84702. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  84703. * @param useQuaternion - Specifies if quaternions are used.
  84704. * @returns nullable IAnimationData
  84705. */
  84706. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  84707. private static _DeduceAnimationInfo;
  84708. /**
  84709. * @ignore
  84710. * Create node animations from the transform node animations
  84711. * @param babylonNode
  84712. * @param runtimeGLTFAnimation
  84713. * @param idleGLTFAnimations
  84714. * @param nodeMap
  84715. * @param nodes
  84716. * @param binaryWriter
  84717. * @param bufferViews
  84718. * @param accessors
  84719. * @param convertToRightHandedSystem
  84720. * @param animationSampleRate
  84721. */
  84722. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84723. [key: number]: number;
  84724. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84725. /**
  84726. * @ignore
  84727. * Create individual morph animations from the mesh's morph target animation tracks
  84728. * @param babylonNode
  84729. * @param runtimeGLTFAnimation
  84730. * @param idleGLTFAnimations
  84731. * @param nodeMap
  84732. * @param nodes
  84733. * @param binaryWriter
  84734. * @param bufferViews
  84735. * @param accessors
  84736. * @param convertToRightHandedSystem
  84737. * @param animationSampleRate
  84738. */
  84739. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84740. [key: number]: number;
  84741. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84742. /**
  84743. * @ignore
  84744. * Create node and morph animations from the animation groups
  84745. * @param babylonScene
  84746. * @param glTFAnimations
  84747. * @param nodeMap
  84748. * @param nodes
  84749. * @param binaryWriter
  84750. * @param bufferViews
  84751. * @param accessors
  84752. * @param convertToRightHandedSystemMap
  84753. * @param animationSampleRate
  84754. */
  84755. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  84756. [key: number]: number;
  84757. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  84758. [nodeId: number]: boolean;
  84759. }, animationSampleRate: number): void;
  84760. private static AddAnimation;
  84761. /**
  84762. * Create a baked animation
  84763. * @param babylonTransformNode BabylonJS mesh
  84764. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  84765. * @param animationChannelTargetPath animation target channel
  84766. * @param minFrame minimum animation frame
  84767. * @param maxFrame maximum animation frame
  84768. * @param fps frames per second of the animation
  84769. * @param inputs input key frames of the animation
  84770. * @param outputs output key frame data of the animation
  84771. * @param convertToRightHandedSystem converts the values to right-handed
  84772. * @param useQuaternion specifies if quaternions should be used
  84773. */
  84774. private static _CreateBakedAnimation;
  84775. private static _ConvertFactorToVector3OrQuaternion;
  84776. private static _SetInterpolatedValue;
  84777. /**
  84778. * Creates linear animation from the animation key frames
  84779. * @param babylonTransformNode BabylonJS mesh
  84780. * @param animation BabylonJS animation
  84781. * @param animationChannelTargetPath The target animation channel
  84782. * @param frameDelta The difference between the last and first frame of the animation
  84783. * @param inputs Array to store the key frame times
  84784. * @param outputs Array to store the key frame data
  84785. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84786. * @param useQuaternion Specifies if quaternions are used in the animation
  84787. */
  84788. private static _CreateLinearOrStepAnimation;
  84789. /**
  84790. * Creates cubic spline animation from the animation key frames
  84791. * @param babylonTransformNode BabylonJS mesh
  84792. * @param animation BabylonJS animation
  84793. * @param animationChannelTargetPath The target animation channel
  84794. * @param frameDelta The difference between the last and first frame of the animation
  84795. * @param inputs Array to store the key frame times
  84796. * @param outputs Array to store the key frame data
  84797. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84798. * @param useQuaternion Specifies if quaternions are used in the animation
  84799. */
  84800. private static _CreateCubicSplineAnimation;
  84801. private static _GetBasePositionRotationOrScale;
  84802. /**
  84803. * Adds a key frame value
  84804. * @param keyFrame
  84805. * @param animation
  84806. * @param outputs
  84807. * @param animationChannelTargetPath
  84808. * @param basePositionRotationOrScale
  84809. * @param convertToRightHandedSystem
  84810. * @param useQuaternion
  84811. */
  84812. private static _AddKeyframeValue;
  84813. /**
  84814. * Determine the interpolation based on the key frames
  84815. * @param keyFrames
  84816. * @param animationChannelTargetPath
  84817. * @param useQuaternion
  84818. */
  84819. private static _DeduceInterpolation;
  84820. /**
  84821. * Adds an input tangent or output tangent to the output data
  84822. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  84823. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  84824. * @param outputs The animation data by keyframe
  84825. * @param animationChannelTargetPath The target animation channel
  84826. * @param interpolation The interpolation type
  84827. * @param keyFrame The key frame with the animation data
  84828. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  84829. * @param useQuaternion Specifies if quaternions are used
  84830. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  84831. */
  84832. private static AddSplineTangent;
  84833. /**
  84834. * Get the minimum and maximum key frames' frame values
  84835. * @param keyFrames animation key frames
  84836. * @returns the minimum and maximum key frame value
  84837. */
  84838. private static calculateMinMaxKeyFrames;
  84839. }
  84840. }
  84841. declare module BABYLON.GLTF2.Exporter {
  84842. /** @hidden */
  84843. export var textureTransformPixelShader: {
  84844. name: string;
  84845. shader: string;
  84846. };
  84847. }
  84848. declare module BABYLON.GLTF2.Exporter.Extensions {
  84849. /**
  84850. * @hidden
  84851. */
  84852. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  84853. private _recordedTextures;
  84854. /** Name of this extension */
  84855. readonly name: string;
  84856. /** Defines whether this extension is enabled */
  84857. enabled: boolean;
  84858. /** Defines whether this extension is required */
  84859. required: boolean;
  84860. /** Reference to the glTF exporter */
  84861. private _wasUsed;
  84862. constructor(exporter: _Exporter);
  84863. dispose(): void;
  84864. /** @hidden */
  84865. get wasUsed(): boolean;
  84866. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84867. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  84868. /**
  84869. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  84870. * @param babylonTexture
  84871. * @param offset
  84872. * @param rotation
  84873. * @param scale
  84874. * @param scene
  84875. */
  84876. private _textureTransformTextureAsync;
  84877. }
  84878. }
  84879. declare module BABYLON.GLTF2.Exporter.Extensions {
  84880. /**
  84881. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  84882. */
  84883. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  84884. /** The name of this extension. */
  84885. readonly name: string;
  84886. /** Defines whether this extension is enabled. */
  84887. enabled: boolean;
  84888. /** Defines whether this extension is required */
  84889. required: boolean;
  84890. /** Reference to the glTF exporter */
  84891. private _exporter;
  84892. private _lights;
  84893. /** @hidden */
  84894. constructor(exporter: _Exporter);
  84895. /** @hidden */
  84896. dispose(): void;
  84897. /** @hidden */
  84898. get wasUsed(): boolean;
  84899. /** @hidden */
  84900. onExporting(): void;
  84901. /**
  84902. * Define this method to modify the default behavior when exporting a node
  84903. * @param context The context when exporting the node
  84904. * @param node glTF node
  84905. * @param babylonNode BabylonJS node
  84906. * @param nodeMap Node mapping of unique id to glTF node index
  84907. * @returns nullable INode promise
  84908. */
  84909. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84910. [key: number]: number;
  84911. }): Promise<Nullable<INode>>;
  84912. }
  84913. }
  84914. declare module BABYLON.GLTF2.Exporter.Extensions {
  84915. /**
  84916. * @hidden
  84917. */
  84918. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  84919. /** Name of this extension */
  84920. readonly name: string;
  84921. /** Defines whether this extension is enabled */
  84922. enabled: boolean;
  84923. /** Defines whether this extension is required */
  84924. required: boolean;
  84925. /** Reference to the glTF exporter */
  84926. private _textureInfos;
  84927. private _exportedTextures;
  84928. private _wasUsed;
  84929. constructor(exporter: _Exporter);
  84930. dispose(): void;
  84931. /** @hidden */
  84932. get wasUsed(): boolean;
  84933. private _getTextureIndex;
  84934. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84935. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84936. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84937. }
  84938. }
  84939. declare module BABYLON.GLTF2.Exporter.Extensions {
  84940. /**
  84941. * @hidden
  84942. */
  84943. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  84944. /** Name of this extension */
  84945. readonly name: string;
  84946. /** Defines whether this extension is enabled */
  84947. enabled: boolean;
  84948. /** Defines whether this extension is required */
  84949. required: boolean;
  84950. private _wasUsed;
  84951. constructor(exporter: _Exporter);
  84952. /** @hidden */
  84953. get wasUsed(): boolean;
  84954. dispose(): void;
  84955. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84956. }
  84957. }
  84958. declare module BABYLON {
  84959. /**
  84960. * Class for generating STL data from a Babylon scene.
  84961. */
  84962. export class STLExport {
  84963. /**
  84964. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  84965. * @param meshes list defines the mesh to serialize
  84966. * @param download triggers the automatic download of the file.
  84967. * @param fileName changes the downloads fileName.
  84968. * @param binary changes the STL to a binary type.
  84969. * @param isLittleEndian toggle for binary type exporter.
  84970. * @returns the STL as UTF8 string
  84971. */
  84972. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  84973. }
  84974. }
  84975. declare module "babylonjs-gltf2interface" {
  84976. export = BABYLON.GLTF2;
  84977. }
  84978. /**
  84979. * Module for glTF 2.0 Interface
  84980. */
  84981. declare module BABYLON.GLTF2 {
  84982. /**
  84983. * The datatype of the components in the attribute
  84984. */
  84985. const enum AccessorComponentType {
  84986. /**
  84987. * Byte
  84988. */
  84989. BYTE = 5120,
  84990. /**
  84991. * Unsigned Byte
  84992. */
  84993. UNSIGNED_BYTE = 5121,
  84994. /**
  84995. * Short
  84996. */
  84997. SHORT = 5122,
  84998. /**
  84999. * Unsigned Short
  85000. */
  85001. UNSIGNED_SHORT = 5123,
  85002. /**
  85003. * Unsigned Int
  85004. */
  85005. UNSIGNED_INT = 5125,
  85006. /**
  85007. * Float
  85008. */
  85009. FLOAT = 5126,
  85010. }
  85011. /**
  85012. * Specifies if the attirbute is a scalar, vector, or matrix
  85013. */
  85014. const enum AccessorType {
  85015. /**
  85016. * Scalar
  85017. */
  85018. SCALAR = "SCALAR",
  85019. /**
  85020. * Vector2
  85021. */
  85022. VEC2 = "VEC2",
  85023. /**
  85024. * Vector3
  85025. */
  85026. VEC3 = "VEC3",
  85027. /**
  85028. * Vector4
  85029. */
  85030. VEC4 = "VEC4",
  85031. /**
  85032. * Matrix2x2
  85033. */
  85034. MAT2 = "MAT2",
  85035. /**
  85036. * Matrix3x3
  85037. */
  85038. MAT3 = "MAT3",
  85039. /**
  85040. * Matrix4x4
  85041. */
  85042. MAT4 = "MAT4",
  85043. }
  85044. /**
  85045. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85046. */
  85047. const enum AnimationChannelTargetPath {
  85048. /**
  85049. * Translation
  85050. */
  85051. TRANSLATION = "translation",
  85052. /**
  85053. * Rotation
  85054. */
  85055. ROTATION = "rotation",
  85056. /**
  85057. * Scale
  85058. */
  85059. SCALE = "scale",
  85060. /**
  85061. * Weights
  85062. */
  85063. WEIGHTS = "weights",
  85064. }
  85065. /**
  85066. * Interpolation algorithm
  85067. */
  85068. const enum AnimationSamplerInterpolation {
  85069. /**
  85070. * The animated values are linearly interpolated between keyframes
  85071. */
  85072. LINEAR = "LINEAR",
  85073. /**
  85074. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85075. */
  85076. STEP = "STEP",
  85077. /**
  85078. * The animation's interpolation is computed using a cubic spline with specified tangents
  85079. */
  85080. CUBICSPLINE = "CUBICSPLINE",
  85081. }
  85082. /**
  85083. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85084. */
  85085. const enum CameraType {
  85086. /**
  85087. * A perspective camera containing properties to create a perspective projection matrix
  85088. */
  85089. PERSPECTIVE = "perspective",
  85090. /**
  85091. * An orthographic camera containing properties to create an orthographic projection matrix
  85092. */
  85093. ORTHOGRAPHIC = "orthographic",
  85094. }
  85095. /**
  85096. * The mime-type of the image
  85097. */
  85098. const enum ImageMimeType {
  85099. /**
  85100. * JPEG Mime-type
  85101. */
  85102. JPEG = "image/jpeg",
  85103. /**
  85104. * PNG Mime-type
  85105. */
  85106. PNG = "image/png",
  85107. }
  85108. /**
  85109. * The alpha rendering mode of the material
  85110. */
  85111. const enum MaterialAlphaMode {
  85112. /**
  85113. * The alpha value is ignored and the rendered output is fully opaque
  85114. */
  85115. OPAQUE = "OPAQUE",
  85116. /**
  85117. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85118. */
  85119. MASK = "MASK",
  85120. /**
  85121. * 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)
  85122. */
  85123. BLEND = "BLEND",
  85124. }
  85125. /**
  85126. * The type of the primitives to render
  85127. */
  85128. const enum MeshPrimitiveMode {
  85129. /**
  85130. * Points
  85131. */
  85132. POINTS = 0,
  85133. /**
  85134. * Lines
  85135. */
  85136. LINES = 1,
  85137. /**
  85138. * Line Loop
  85139. */
  85140. LINE_LOOP = 2,
  85141. /**
  85142. * Line Strip
  85143. */
  85144. LINE_STRIP = 3,
  85145. /**
  85146. * Triangles
  85147. */
  85148. TRIANGLES = 4,
  85149. /**
  85150. * Triangle Strip
  85151. */
  85152. TRIANGLE_STRIP = 5,
  85153. /**
  85154. * Triangle Fan
  85155. */
  85156. TRIANGLE_FAN = 6,
  85157. }
  85158. /**
  85159. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85160. */
  85161. const enum TextureMagFilter {
  85162. /**
  85163. * Nearest
  85164. */
  85165. NEAREST = 9728,
  85166. /**
  85167. * Linear
  85168. */
  85169. LINEAR = 9729,
  85170. }
  85171. /**
  85172. * Minification filter. All valid values correspond to WebGL enums
  85173. */
  85174. const enum TextureMinFilter {
  85175. /**
  85176. * Nearest
  85177. */
  85178. NEAREST = 9728,
  85179. /**
  85180. * Linear
  85181. */
  85182. LINEAR = 9729,
  85183. /**
  85184. * Nearest Mip-Map Nearest
  85185. */
  85186. NEAREST_MIPMAP_NEAREST = 9984,
  85187. /**
  85188. * Linear Mipmap Nearest
  85189. */
  85190. LINEAR_MIPMAP_NEAREST = 9985,
  85191. /**
  85192. * Nearest Mipmap Linear
  85193. */
  85194. NEAREST_MIPMAP_LINEAR = 9986,
  85195. /**
  85196. * Linear Mipmap Linear
  85197. */
  85198. LINEAR_MIPMAP_LINEAR = 9987,
  85199. }
  85200. /**
  85201. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85202. */
  85203. const enum TextureWrapMode {
  85204. /**
  85205. * Clamp to Edge
  85206. */
  85207. CLAMP_TO_EDGE = 33071,
  85208. /**
  85209. * Mirrored Repeat
  85210. */
  85211. MIRRORED_REPEAT = 33648,
  85212. /**
  85213. * Repeat
  85214. */
  85215. REPEAT = 10497,
  85216. }
  85217. /**
  85218. * glTF Property
  85219. */
  85220. interface IProperty {
  85221. /**
  85222. * Dictionary object with extension-specific objects
  85223. */
  85224. extensions?: {
  85225. [key: string]: any;
  85226. };
  85227. /**
  85228. * Application-Specific data
  85229. */
  85230. extras?: any;
  85231. }
  85232. /**
  85233. * glTF Child of Root Property
  85234. */
  85235. interface IChildRootProperty extends IProperty {
  85236. /**
  85237. * The user-defined name of this object
  85238. */
  85239. name?: string;
  85240. }
  85241. /**
  85242. * Indices of those attributes that deviate from their initialization value
  85243. */
  85244. interface IAccessorSparseIndices extends IProperty {
  85245. /**
  85246. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85247. */
  85248. bufferView: number;
  85249. /**
  85250. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85251. */
  85252. byteOffset?: number;
  85253. /**
  85254. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85255. */
  85256. componentType: AccessorComponentType;
  85257. }
  85258. /**
  85259. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85260. */
  85261. interface IAccessorSparseValues extends IProperty {
  85262. /**
  85263. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85264. */
  85265. bufferView: number;
  85266. /**
  85267. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85268. */
  85269. byteOffset?: number;
  85270. }
  85271. /**
  85272. * Sparse storage of attributes that deviate from their initialization value
  85273. */
  85274. interface IAccessorSparse extends IProperty {
  85275. /**
  85276. * The number of attributes encoded in this sparse accessor
  85277. */
  85278. count: number;
  85279. /**
  85280. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85281. */
  85282. indices: IAccessorSparseIndices;
  85283. /**
  85284. * 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
  85285. */
  85286. values: IAccessorSparseValues;
  85287. }
  85288. /**
  85289. * 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
  85290. */
  85291. interface IAccessor extends IChildRootProperty {
  85292. /**
  85293. * The index of the bufferview
  85294. */
  85295. bufferView?: number;
  85296. /**
  85297. * The offset relative to the start of the bufferView in bytes
  85298. */
  85299. byteOffset?: number;
  85300. /**
  85301. * The datatype of components in the attribute
  85302. */
  85303. componentType: AccessorComponentType;
  85304. /**
  85305. * Specifies whether integer data values should be normalized
  85306. */
  85307. normalized?: boolean;
  85308. /**
  85309. * The number of attributes referenced by this accessor
  85310. */
  85311. count: number;
  85312. /**
  85313. * Specifies if the attribute is a scalar, vector, or matrix
  85314. */
  85315. type: AccessorType;
  85316. /**
  85317. * Maximum value of each component in this attribute
  85318. */
  85319. max?: number[];
  85320. /**
  85321. * Minimum value of each component in this attribute
  85322. */
  85323. min?: number[];
  85324. /**
  85325. * Sparse storage of attributes that deviate from their initialization value
  85326. */
  85327. sparse?: IAccessorSparse;
  85328. }
  85329. /**
  85330. * Targets an animation's sampler at a node's property
  85331. */
  85332. interface IAnimationChannel extends IProperty {
  85333. /**
  85334. * The index of a sampler in this animation used to compute the value for the target
  85335. */
  85336. sampler: number;
  85337. /**
  85338. * The index of the node and TRS property to target
  85339. */
  85340. target: IAnimationChannelTarget;
  85341. }
  85342. /**
  85343. * The index of the node and TRS property that an animation channel targets
  85344. */
  85345. interface IAnimationChannelTarget extends IProperty {
  85346. /**
  85347. * The index of the node to target
  85348. */
  85349. node: number;
  85350. /**
  85351. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85352. */
  85353. path: AnimationChannelTargetPath;
  85354. }
  85355. /**
  85356. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85357. */
  85358. interface IAnimationSampler extends IProperty {
  85359. /**
  85360. * The index of an accessor containing keyframe input values, e.g., time
  85361. */
  85362. input: number;
  85363. /**
  85364. * Interpolation algorithm
  85365. */
  85366. interpolation?: AnimationSamplerInterpolation;
  85367. /**
  85368. * The index of an accessor, containing keyframe output values
  85369. */
  85370. output: number;
  85371. }
  85372. /**
  85373. * A keyframe animation
  85374. */
  85375. interface IAnimation extends IChildRootProperty {
  85376. /**
  85377. * An array of channels, each of which targets an animation's sampler at a node's property
  85378. */
  85379. channels: IAnimationChannel[];
  85380. /**
  85381. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85382. */
  85383. samplers: IAnimationSampler[];
  85384. }
  85385. /**
  85386. * Metadata about the glTF asset
  85387. */
  85388. interface IAsset extends IChildRootProperty {
  85389. /**
  85390. * A copyright message suitable for display to credit the content creator
  85391. */
  85392. copyright?: string;
  85393. /**
  85394. * Tool that generated this glTF model. Useful for debugging
  85395. */
  85396. generator?: string;
  85397. /**
  85398. * The glTF version that this asset targets
  85399. */
  85400. version: string;
  85401. /**
  85402. * The minimum glTF version that this asset targets
  85403. */
  85404. minVersion?: string;
  85405. }
  85406. /**
  85407. * A buffer points to binary geometry, animation, or skins
  85408. */
  85409. interface IBuffer extends IChildRootProperty {
  85410. /**
  85411. * 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
  85412. */
  85413. uri?: string;
  85414. /**
  85415. * The length of the buffer in bytes
  85416. */
  85417. byteLength: number;
  85418. }
  85419. /**
  85420. * A view into a buffer generally representing a subset of the buffer
  85421. */
  85422. interface IBufferView extends IChildRootProperty {
  85423. /**
  85424. * The index of the buffer
  85425. */
  85426. buffer: number;
  85427. /**
  85428. * The offset into the buffer in bytes
  85429. */
  85430. byteOffset?: number;
  85431. /**
  85432. * The lenth of the bufferView in bytes
  85433. */
  85434. byteLength: number;
  85435. /**
  85436. * The stride, in bytes
  85437. */
  85438. byteStride?: number;
  85439. }
  85440. /**
  85441. * An orthographic camera containing properties to create an orthographic projection matrix
  85442. */
  85443. interface ICameraOrthographic extends IProperty {
  85444. /**
  85445. * The floating-point horizontal magnification of the view. Must not be zero
  85446. */
  85447. xmag: number;
  85448. /**
  85449. * The floating-point vertical magnification of the view. Must not be zero
  85450. */
  85451. ymag: number;
  85452. /**
  85453. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85454. */
  85455. zfar: number;
  85456. /**
  85457. * The floating-point distance to the near clipping plane
  85458. */
  85459. znear: number;
  85460. }
  85461. /**
  85462. * A perspective camera containing properties to create a perspective projection matrix
  85463. */
  85464. interface ICameraPerspective extends IProperty {
  85465. /**
  85466. * The floating-point aspect ratio of the field of view
  85467. */
  85468. aspectRatio?: number;
  85469. /**
  85470. * The floating-point vertical field of view in radians
  85471. */
  85472. yfov: number;
  85473. /**
  85474. * The floating-point distance to the far clipping plane
  85475. */
  85476. zfar?: number;
  85477. /**
  85478. * The floating-point distance to the near clipping plane
  85479. */
  85480. znear: number;
  85481. }
  85482. /**
  85483. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85484. */
  85485. interface ICamera extends IChildRootProperty {
  85486. /**
  85487. * An orthographic camera containing properties to create an orthographic projection matrix
  85488. */
  85489. orthographic?: ICameraOrthographic;
  85490. /**
  85491. * A perspective camera containing properties to create a perspective projection matrix
  85492. */
  85493. perspective?: ICameraPerspective;
  85494. /**
  85495. * Specifies if the camera uses a perspective or orthographic projection
  85496. */
  85497. type: CameraType;
  85498. }
  85499. /**
  85500. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  85501. */
  85502. interface IImage extends IChildRootProperty {
  85503. /**
  85504. * 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
  85505. */
  85506. uri?: string;
  85507. /**
  85508. * The image's MIME type
  85509. */
  85510. mimeType?: ImageMimeType;
  85511. /**
  85512. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  85513. */
  85514. bufferView?: number;
  85515. }
  85516. /**
  85517. * Material Normal Texture Info
  85518. */
  85519. interface IMaterialNormalTextureInfo extends ITextureInfo {
  85520. /**
  85521. * The scalar multiplier applied to each normal vector of the normal texture
  85522. */
  85523. scale?: number;
  85524. }
  85525. /**
  85526. * Material Occlusion Texture Info
  85527. */
  85528. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  85529. /**
  85530. * A scalar multiplier controlling the amount of occlusion applied
  85531. */
  85532. strength?: number;
  85533. }
  85534. /**
  85535. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  85536. */
  85537. interface IMaterialPbrMetallicRoughness {
  85538. /**
  85539. * The material's base color factor
  85540. */
  85541. baseColorFactor?: number[];
  85542. /**
  85543. * The base color texture
  85544. */
  85545. baseColorTexture?: ITextureInfo;
  85546. /**
  85547. * The metalness of the material
  85548. */
  85549. metallicFactor?: number;
  85550. /**
  85551. * The roughness of the material
  85552. */
  85553. roughnessFactor?: number;
  85554. /**
  85555. * The metallic-roughness texture
  85556. */
  85557. metallicRoughnessTexture?: ITextureInfo;
  85558. }
  85559. /**
  85560. * The material appearance of a primitive
  85561. */
  85562. interface IMaterial extends IChildRootProperty {
  85563. /**
  85564. * 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
  85565. */
  85566. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  85567. /**
  85568. * The normal map texture
  85569. */
  85570. normalTexture?: IMaterialNormalTextureInfo;
  85571. /**
  85572. * The occlusion map texture
  85573. */
  85574. occlusionTexture?: IMaterialOcclusionTextureInfo;
  85575. /**
  85576. * The emissive map texture
  85577. */
  85578. emissiveTexture?: ITextureInfo;
  85579. /**
  85580. * 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
  85581. */
  85582. emissiveFactor?: number[];
  85583. /**
  85584. * The alpha rendering mode of the material
  85585. */
  85586. alphaMode?: MaterialAlphaMode;
  85587. /**
  85588. * The alpha cutoff value of the material
  85589. */
  85590. alphaCutoff?: number;
  85591. /**
  85592. * Specifies whether the material is double sided
  85593. */
  85594. doubleSided?: boolean;
  85595. }
  85596. /**
  85597. * Geometry to be rendered with the given material
  85598. */
  85599. interface IMeshPrimitive extends IProperty {
  85600. /**
  85601. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  85602. */
  85603. attributes: {
  85604. [name: string]: number;
  85605. };
  85606. /**
  85607. * The index of the accessor that contains the indices
  85608. */
  85609. indices?: number;
  85610. /**
  85611. * The index of the material to apply to this primitive when rendering
  85612. */
  85613. material?: number;
  85614. /**
  85615. * The type of primitives to render. All valid values correspond to WebGL enums
  85616. */
  85617. mode?: MeshPrimitiveMode;
  85618. /**
  85619. * 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
  85620. */
  85621. targets?: {
  85622. [name: string]: number;
  85623. }[];
  85624. }
  85625. /**
  85626. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  85627. */
  85628. interface IMesh extends IChildRootProperty {
  85629. /**
  85630. * An array of primitives, each defining geometry to be rendered with a material
  85631. */
  85632. primitives: IMeshPrimitive[];
  85633. /**
  85634. * Array of weights to be applied to the Morph Targets
  85635. */
  85636. weights?: number[];
  85637. }
  85638. /**
  85639. * A node in the node hierarchy
  85640. */
  85641. interface INode extends IChildRootProperty {
  85642. /**
  85643. * The index of the camera referenced by this node
  85644. */
  85645. camera?: number;
  85646. /**
  85647. * The indices of this node's children
  85648. */
  85649. children?: number[];
  85650. /**
  85651. * The index of the skin referenced by this node
  85652. */
  85653. skin?: number;
  85654. /**
  85655. * A floating-point 4x4 transformation matrix stored in column-major order
  85656. */
  85657. matrix?: number[];
  85658. /**
  85659. * The index of the mesh in this node
  85660. */
  85661. mesh?: number;
  85662. /**
  85663. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  85664. */
  85665. rotation?: number[];
  85666. /**
  85667. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  85668. */
  85669. scale?: number[];
  85670. /**
  85671. * The node's translation along the x, y, and z axes
  85672. */
  85673. translation?: number[];
  85674. /**
  85675. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  85676. */
  85677. weights?: number[];
  85678. }
  85679. /**
  85680. * Texture sampler properties for filtering and wrapping modes
  85681. */
  85682. interface ISampler extends IChildRootProperty {
  85683. /**
  85684. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85685. */
  85686. magFilter?: TextureMagFilter;
  85687. /**
  85688. * Minification filter. All valid values correspond to WebGL enums
  85689. */
  85690. minFilter?: TextureMinFilter;
  85691. /**
  85692. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85693. */
  85694. wrapS?: TextureWrapMode;
  85695. /**
  85696. * T (V) wrapping mode. All valid values correspond to WebGL enums
  85697. */
  85698. wrapT?: TextureWrapMode;
  85699. }
  85700. /**
  85701. * The root nodes of a scene
  85702. */
  85703. interface IScene extends IChildRootProperty {
  85704. /**
  85705. * The indices of each root node
  85706. */
  85707. nodes: number[];
  85708. }
  85709. /**
  85710. * Joints and matrices defining a skin
  85711. */
  85712. interface ISkin extends IChildRootProperty {
  85713. /**
  85714. * 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
  85715. */
  85716. inverseBindMatrices?: number;
  85717. /**
  85718. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  85719. */
  85720. skeleton?: number;
  85721. /**
  85722. * 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)
  85723. */
  85724. joints: number[];
  85725. }
  85726. /**
  85727. * A texture and its sampler
  85728. */
  85729. interface ITexture extends IChildRootProperty {
  85730. /**
  85731. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  85732. */
  85733. sampler?: number;
  85734. /**
  85735. * The index of the image used by this texture
  85736. */
  85737. source: number;
  85738. }
  85739. /**
  85740. * Reference to a texture
  85741. */
  85742. interface ITextureInfo extends IProperty {
  85743. /**
  85744. * The index of the texture
  85745. */
  85746. index: number;
  85747. /**
  85748. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  85749. */
  85750. texCoord?: number;
  85751. }
  85752. /**
  85753. * The root object for a glTF asset
  85754. */
  85755. interface IGLTF extends IProperty {
  85756. /**
  85757. * An array of accessors. An accessor is a typed view into a bufferView
  85758. */
  85759. accessors?: IAccessor[];
  85760. /**
  85761. * An array of keyframe animations
  85762. */
  85763. animations?: IAnimation[];
  85764. /**
  85765. * Metadata about the glTF asset
  85766. */
  85767. asset: IAsset;
  85768. /**
  85769. * An array of buffers. A buffer points to binary geometry, animation, or skins
  85770. */
  85771. buffers?: IBuffer[];
  85772. /**
  85773. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  85774. */
  85775. bufferViews?: IBufferView[];
  85776. /**
  85777. * An array of cameras
  85778. */
  85779. cameras?: ICamera[];
  85780. /**
  85781. * Names of glTF extensions used somewhere in this asset
  85782. */
  85783. extensionsUsed?: string[];
  85784. /**
  85785. * Names of glTF extensions required to properly load this asset
  85786. */
  85787. extensionsRequired?: string[];
  85788. /**
  85789. * An array of images. An image defines data used to create a texture
  85790. */
  85791. images?: IImage[];
  85792. /**
  85793. * An array of materials. A material defines the appearance of a primitive
  85794. */
  85795. materials?: IMaterial[];
  85796. /**
  85797. * An array of meshes. A mesh is a set of primitives to be rendered
  85798. */
  85799. meshes?: IMesh[];
  85800. /**
  85801. * An array of nodes
  85802. */
  85803. nodes?: INode[];
  85804. /**
  85805. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  85806. */
  85807. samplers?: ISampler[];
  85808. /**
  85809. * The index of the default scene
  85810. */
  85811. scene?: number;
  85812. /**
  85813. * An array of scenes
  85814. */
  85815. scenes?: IScene[];
  85816. /**
  85817. * An array of skins. A skin is defined by joints and matrices
  85818. */
  85819. skins?: ISkin[];
  85820. /**
  85821. * An array of textures
  85822. */
  85823. textures?: ITexture[];
  85824. }
  85825. /**
  85826. * The glTF validation results
  85827. * @ignore
  85828. */
  85829. interface IGLTFValidationResults {
  85830. info: {
  85831. generator: string;
  85832. hasAnimations: boolean;
  85833. hasDefaultScene: boolean;
  85834. hasMaterials: boolean;
  85835. hasMorphTargets: boolean;
  85836. hasSkins: boolean;
  85837. hasTextures: boolean;
  85838. maxAttributesUsed: number;
  85839. primitivesCount: number
  85840. };
  85841. issues: {
  85842. messages: Array<string>;
  85843. numErrors: number;
  85844. numHints: number;
  85845. numInfos: number;
  85846. numWarnings: number;
  85847. truncated: boolean
  85848. };
  85849. mimeType: string;
  85850. uri: string;
  85851. validatedAt: string;
  85852. validatorVersion: string;
  85853. }
  85854. /**
  85855. * The glTF validation options
  85856. */
  85857. interface IGLTFValidationOptions {
  85858. /** Uri to use */
  85859. uri?: string;
  85860. /** Function used to load external resources */
  85861. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  85862. /** Boolean indicating that we need to validate accessor data */
  85863. validateAccessorData?: boolean;
  85864. /** max number of issues allowed */
  85865. maxIssues?: number;
  85866. /** Ignored issues */
  85867. ignoredIssues?: Array<string>;
  85868. /** Value to override severy settings */
  85869. severityOverrides?: Object;
  85870. }
  85871. /**
  85872. * The glTF validator object
  85873. * @ignore
  85874. */
  85875. interface IGLTFValidator {
  85876. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85877. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85878. }
  85879. /**
  85880. * Interfaces from the EXT_lights_image_based extension
  85881. */
  85882. /** @hidden */
  85883. interface IEXTLightsImageBased_LightReferenceImageBased {
  85884. light: number;
  85885. }
  85886. /** @hidden */
  85887. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  85888. intensity: number;
  85889. rotation: number[];
  85890. specularImageSize: number;
  85891. specularImages: number[][];
  85892. irradianceCoefficients: number[][];
  85893. }
  85894. /** @hidden */
  85895. interface IEXTLightsImageBased {
  85896. lights: IEXTLightsImageBased_LightImageBased[];
  85897. }
  85898. /**
  85899. * Interfaces from the EXT_mesh_gpu_instancing extension
  85900. * !!! Experimental Extension Subject to Changes !!!
  85901. */
  85902. /** @hidden */
  85903. interface IEXTMeshGpuInstancing {
  85904. mesh?: number;
  85905. attributes: { [name: string]: number };
  85906. }
  85907. /**
  85908. * Interfaces from the KHR_draco_mesh_compression extension
  85909. */
  85910. /** @hidden */
  85911. interface IKHRDracoMeshCompression {
  85912. bufferView: number;
  85913. attributes: { [name: string]: number };
  85914. }
  85915. /**
  85916. * Interfaces from the KHR_lights_punctual extension
  85917. */
  85918. /** @hidden */
  85919. const enum IKHRLightsPunctual_LightType {
  85920. DIRECTIONAL = "directional",
  85921. POINT = "point",
  85922. SPOT = "spot"
  85923. }
  85924. /** @hidden */
  85925. interface IKHRLightsPunctual_LightReference {
  85926. light: number;
  85927. }
  85928. /** @hidden */
  85929. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  85930. type: IKHRLightsPunctual_LightType;
  85931. color?: number[];
  85932. intensity?: number;
  85933. range?: number;
  85934. spot?: {
  85935. innerConeAngle?: number;
  85936. outerConeAngle?: number;
  85937. };
  85938. }
  85939. /** @hidden */
  85940. interface IKHRLightsPunctual {
  85941. lights: IKHRLightsPunctual_Light[];
  85942. }
  85943. /**
  85944. * Interfaces from the KHR_materials_clearcoat extension
  85945. * !!! Experimental Extension Subject to Changes !!!
  85946. */
  85947. /** @hidden */
  85948. interface IKHRMaterialsClearcoat {
  85949. clearcoatFactor: number;
  85950. clearcoatTexture: ITextureInfo;
  85951. clearcoatRoughnessFactor: number;
  85952. clearcoatRoughnessTexture: ITextureInfo;
  85953. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  85954. }
  85955. /**
  85956. * Interfaces from the KHR_materials_ior extension
  85957. * !!! Experimental Extension Subject to Changes !!!
  85958. */
  85959. /** @hidden */
  85960. interface IKHRMaterialsIor {
  85961. ior: number;
  85962. }
  85963. /**
  85964. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  85965. */
  85966. /** @hidden */
  85967. interface IKHRMaterialsPbrSpecularGlossiness {
  85968. diffuseFactor: number[];
  85969. diffuseTexture: ITextureInfo;
  85970. specularFactor: number[];
  85971. glossinessFactor: number;
  85972. specularGlossinessTexture: ITextureInfo;
  85973. }
  85974. /**
  85975. * Interfaces from the KHR_materials_sheen extension
  85976. * !!! Experimental Extension Subject to Changes !!!
  85977. */
  85978. /** @hidden */
  85979. interface IKHRMaterialsSheen {
  85980. sheenColorFactor?: number[];
  85981. sheenColorTexture?: ITextureInfo;
  85982. sheenRoughnessFactor?: number;
  85983. sheenRoughnessTexture?: ITextureInfo;
  85984. }
  85985. /**
  85986. * Interfaces from the KHR_materials_specular extension
  85987. * !!! Experimental Extension Subject to Changes !!!
  85988. */
  85989. /** @hidden */
  85990. interface IKHRMaterialsSpecular {
  85991. specularFactor: number;
  85992. specularColorFactor: number[];
  85993. specularTexture: ITextureInfo;
  85994. }
  85995. /**
  85996. * Interfaces from the KHR_materials_transmission extension
  85997. * !!! Experimental Extension Subject to Changes !!!
  85998. */
  85999. /** @hidden */
  86000. interface IKHRMaterialsTransmission {
  86001. transmissionFactor?: number;
  86002. transmissionTexture?: ITextureInfo;
  86003. }
  86004. /**
  86005. * Interfaces from the KHR_materials_variants extension
  86006. * !!! Experimental Extension Subject to Changes !!!
  86007. */
  86008. /** @hidden */
  86009. interface IKHRMaterialVariants_Mapping extends IProperty {
  86010. mappings: Array<{
  86011. variants: number[];
  86012. material: number;
  86013. }>;
  86014. }
  86015. /** @hidden */
  86016. interface IKHRMaterialVariants_Variant extends IProperty {
  86017. name: string;
  86018. }
  86019. /** @hidden */
  86020. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86021. variants: Array<IKHRMaterialVariants_Variant>;
  86022. }
  86023. /**
  86024. * Interfaces from the KHR_texture_basisu extension
  86025. * !!! Experimental Extension Subject to Changes !!!
  86026. */
  86027. /** @hidden */
  86028. interface IKHRTextureBasisU {
  86029. source: number;
  86030. }
  86031. /**
  86032. * Interfaces from the EXT_texture_webp extension
  86033. */
  86034. /** @hidden */
  86035. interface IEXTTextureWebP {
  86036. source: number;
  86037. }
  86038. /**
  86039. * Interfaces from the KHR_texture_transform extension
  86040. */
  86041. /** @hidden */
  86042. interface IKHRTextureTransform {
  86043. offset?: number[];
  86044. rotation?: number;
  86045. scale?: number[];
  86046. texCoord?: number;
  86047. }
  86048. /**
  86049. * Interfaces from the KHR_xmp extension
  86050. * !!! Experimental Extension Subject to Changes !!!
  86051. */
  86052. /** @hidden */
  86053. interface IKHRXmp_Data {
  86054. [key: string]: unknown;
  86055. }
  86056. /** @hidden */
  86057. interface IKHRXmp_Gltf {
  86058. packets: IKHRXmp_Data[];
  86059. }
  86060. /** @hidden */
  86061. interface IKHRXmp_Node {
  86062. packet: number;
  86063. }
  86064. /**
  86065. * Interfaces from the MSFT_audio_emitter extension
  86066. */
  86067. /** @hidden */
  86068. interface IMSFTAudioEmitter_ClipReference {
  86069. clip: number;
  86070. weight?: number;
  86071. }
  86072. /** @hidden */
  86073. interface IMSFTAudioEmitter_EmittersReference {
  86074. emitters: number[];
  86075. }
  86076. /** @hidden */
  86077. const enum IMSFTAudioEmitter_DistanceModel {
  86078. linear = "linear",
  86079. inverse = "inverse",
  86080. exponential = "exponential",
  86081. }
  86082. /** @hidden */
  86083. interface IMSFTAudioEmitter_Emitter {
  86084. name?: string;
  86085. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86086. refDistance?: number;
  86087. maxDistance?: number;
  86088. rolloffFactor?: number;
  86089. innerAngle?: number;
  86090. outerAngle?: number;
  86091. loop?: boolean;
  86092. volume?: number;
  86093. clips: IMSFTAudioEmitter_ClipReference[];
  86094. }
  86095. /** @hidden */
  86096. const enum IMSFTAudioEmitter_AudioMimeType {
  86097. WAV = "audio/wav",
  86098. }
  86099. /** @hidden */
  86100. interface IMSFTAudioEmitter_Clip extends IProperty {
  86101. uri?: string;
  86102. bufferView?: number;
  86103. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86104. }
  86105. /** @hidden */
  86106. const enum IMSFTAudioEmitter_AnimationEventAction {
  86107. play = "play",
  86108. pause = "pause",
  86109. stop = "stop",
  86110. }
  86111. /** @hidden */
  86112. interface IMSFTAudioEmitter_AnimationEvent {
  86113. action: IMSFTAudioEmitter_AnimationEventAction;
  86114. emitter: number;
  86115. time: number;
  86116. startOffset?: number;
  86117. }
  86118. /**
  86119. * Interfaces from the MSFT_lod extension
  86120. */
  86121. /** @hidden */
  86122. interface IMSFTLOD {
  86123. ids: number[];
  86124. }
  86125. }
  86126. declare module BABYLON {
  86127. /** @hidden */
  86128. export var cellPixelShader: {
  86129. name: string;
  86130. shader: string;
  86131. };
  86132. }
  86133. declare module BABYLON {
  86134. /** @hidden */
  86135. export var cellVertexShader: {
  86136. name: string;
  86137. shader: string;
  86138. };
  86139. }
  86140. declare module BABYLON {
  86141. export class CellMaterial extends BABYLON.PushMaterial {
  86142. private _diffuseTexture;
  86143. diffuseTexture: BABYLON.BaseTexture;
  86144. diffuseColor: BABYLON.Color3;
  86145. _computeHighLevel: boolean;
  86146. computeHighLevel: boolean;
  86147. private _disableLighting;
  86148. disableLighting: boolean;
  86149. private _maxSimultaneousLights;
  86150. maxSimultaneousLights: number;
  86151. constructor(name: string, scene: BABYLON.Scene);
  86152. needAlphaBlending(): boolean;
  86153. needAlphaTesting(): boolean;
  86154. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86155. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86156. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86157. getAnimatables(): BABYLON.IAnimatable[];
  86158. getActiveTextures(): BABYLON.BaseTexture[];
  86159. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86160. dispose(forceDisposeEffect?: boolean): void;
  86161. getClassName(): string;
  86162. clone(name: string): CellMaterial;
  86163. serialize(): any;
  86164. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86165. }
  86166. }
  86167. declare module BABYLON {
  86168. export class CustomShaderStructure {
  86169. FragmentStore: string;
  86170. VertexStore: string;
  86171. constructor();
  86172. }
  86173. export class ShaderSpecialParts {
  86174. constructor();
  86175. Fragment_Begin: string;
  86176. Fragment_Definitions: string;
  86177. Fragment_MainBegin: string;
  86178. Fragment_Custom_Diffuse: string;
  86179. Fragment_Before_Lights: string;
  86180. Fragment_Before_Fog: string;
  86181. Fragment_Custom_Alpha: string;
  86182. Fragment_Before_FragColor: string;
  86183. Vertex_Begin: string;
  86184. Vertex_Definitions: string;
  86185. Vertex_MainBegin: string;
  86186. Vertex_Before_PositionUpdated: string;
  86187. Vertex_Before_NormalUpdated: string;
  86188. Vertex_After_WorldPosComputed: string;
  86189. Vertex_MainEnd: string;
  86190. }
  86191. export class CustomMaterial extends BABYLON.StandardMaterial {
  86192. static ShaderIndexer: number;
  86193. CustomParts: ShaderSpecialParts;
  86194. _isCreatedShader: boolean;
  86195. _createdShaderName: string;
  86196. _customUniform: string[];
  86197. _newUniforms: string[];
  86198. _newUniformInstances: {
  86199. [name: string]: any;
  86200. };
  86201. _newSamplerInstances: {
  86202. [name: string]: BABYLON.Texture;
  86203. };
  86204. _customAttributes: string[];
  86205. FragmentShader: string;
  86206. VertexShader: string;
  86207. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86208. ReviewUniform(name: string, arr: string[]): string[];
  86209. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86210. constructor(name: string, scene: BABYLON.Scene);
  86211. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86212. AddAttribute(name: string): CustomMaterial;
  86213. Fragment_Begin(shaderPart: string): CustomMaterial;
  86214. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86215. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86216. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86217. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86218. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86219. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86220. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86221. Vertex_Begin(shaderPart: string): CustomMaterial;
  86222. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86223. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86224. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86225. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86226. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86227. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86228. }
  86229. }
  86230. declare module BABYLON {
  86231. export class ShaderAlebdoParts {
  86232. constructor();
  86233. Fragment_Begin: string;
  86234. Fragment_Definitions: string;
  86235. Fragment_MainBegin: string;
  86236. Fragment_Custom_Albedo: string;
  86237. Fragment_Before_Lights: string;
  86238. Fragment_Custom_MetallicRoughness: string;
  86239. Fragment_Custom_MicroSurface: string;
  86240. Fragment_Before_Fog: string;
  86241. Fragment_Custom_Alpha: string;
  86242. Fragment_Before_FragColor: string;
  86243. Vertex_Begin: string;
  86244. Vertex_Definitions: string;
  86245. Vertex_MainBegin: string;
  86246. Vertex_Before_PositionUpdated: string;
  86247. Vertex_Before_NormalUpdated: string;
  86248. Vertex_After_WorldPosComputed: string;
  86249. Vertex_MainEnd: string;
  86250. }
  86251. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86252. static ShaderIndexer: number;
  86253. CustomParts: ShaderAlebdoParts;
  86254. _isCreatedShader: boolean;
  86255. _createdShaderName: string;
  86256. _customUniform: string[];
  86257. _newUniforms: string[];
  86258. _newUniformInstances: {
  86259. [name: string]: any;
  86260. };
  86261. _newSamplerInstances: {
  86262. [name: string]: BABYLON.Texture;
  86263. };
  86264. _customAttributes: string[];
  86265. FragmentShader: string;
  86266. VertexShader: string;
  86267. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86268. ReviewUniform(name: string, arr: string[]): string[];
  86269. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86270. constructor(name: string, scene: BABYLON.Scene);
  86271. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86272. AddAttribute(name: string): PBRCustomMaterial;
  86273. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86274. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86275. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86276. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86277. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86278. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86279. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86280. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86281. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86282. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86283. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86284. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86285. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86286. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86287. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86288. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86289. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86290. }
  86291. }
  86292. declare module BABYLON {
  86293. /** @hidden */
  86294. export var firePixelShader: {
  86295. name: string;
  86296. shader: string;
  86297. };
  86298. }
  86299. declare module BABYLON {
  86300. /** @hidden */
  86301. export var fireVertexShader: {
  86302. name: string;
  86303. shader: string;
  86304. };
  86305. }
  86306. declare module BABYLON {
  86307. export class FireMaterial extends BABYLON.PushMaterial {
  86308. private _diffuseTexture;
  86309. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86310. private _distortionTexture;
  86311. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86312. private _opacityTexture;
  86313. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86314. diffuseColor: BABYLON.Color3;
  86315. speed: number;
  86316. private _scaledDiffuse;
  86317. private _lastTime;
  86318. constructor(name: string, scene: BABYLON.Scene);
  86319. needAlphaBlending(): boolean;
  86320. needAlphaTesting(): boolean;
  86321. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86322. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86323. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86324. getAnimatables(): BABYLON.IAnimatable[];
  86325. getActiveTextures(): BABYLON.BaseTexture[];
  86326. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86327. getClassName(): string;
  86328. dispose(forceDisposeEffect?: boolean): void;
  86329. clone(name: string): FireMaterial;
  86330. serialize(): any;
  86331. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86332. }
  86333. }
  86334. declare module BABYLON {
  86335. /** @hidden */
  86336. export var furPixelShader: {
  86337. name: string;
  86338. shader: string;
  86339. };
  86340. }
  86341. declare module BABYLON {
  86342. /** @hidden */
  86343. export var furVertexShader: {
  86344. name: string;
  86345. shader: string;
  86346. };
  86347. }
  86348. declare module BABYLON {
  86349. export class FurMaterial extends BABYLON.PushMaterial {
  86350. private _diffuseTexture;
  86351. diffuseTexture: BABYLON.BaseTexture;
  86352. private _heightTexture;
  86353. heightTexture: BABYLON.BaseTexture;
  86354. diffuseColor: BABYLON.Color3;
  86355. furLength: number;
  86356. furAngle: number;
  86357. furColor: BABYLON.Color3;
  86358. furOffset: number;
  86359. furSpacing: number;
  86360. furGravity: BABYLON.Vector3;
  86361. furSpeed: number;
  86362. furDensity: number;
  86363. furOcclusion: number;
  86364. furTexture: BABYLON.DynamicTexture;
  86365. private _disableLighting;
  86366. disableLighting: boolean;
  86367. private _maxSimultaneousLights;
  86368. maxSimultaneousLights: number;
  86369. highLevelFur: boolean;
  86370. _meshes: BABYLON.AbstractMesh[];
  86371. private _furTime;
  86372. constructor(name: string, scene: BABYLON.Scene);
  86373. get furTime(): number;
  86374. set furTime(furTime: number);
  86375. needAlphaBlending(): boolean;
  86376. needAlphaTesting(): boolean;
  86377. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86378. updateFur(): void;
  86379. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86380. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86381. getAnimatables(): BABYLON.IAnimatable[];
  86382. getActiveTextures(): BABYLON.BaseTexture[];
  86383. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86384. dispose(forceDisposeEffect?: boolean): void;
  86385. clone(name: string): FurMaterial;
  86386. serialize(): any;
  86387. getClassName(): string;
  86388. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86389. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86390. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86391. }
  86392. }
  86393. declare module BABYLON {
  86394. /** @hidden */
  86395. export var gradientPixelShader: {
  86396. name: string;
  86397. shader: string;
  86398. };
  86399. }
  86400. declare module BABYLON {
  86401. /** @hidden */
  86402. export var gradientVertexShader: {
  86403. name: string;
  86404. shader: string;
  86405. };
  86406. }
  86407. declare module BABYLON {
  86408. export class GradientMaterial extends BABYLON.PushMaterial {
  86409. private _maxSimultaneousLights;
  86410. maxSimultaneousLights: number;
  86411. topColor: BABYLON.Color3;
  86412. topColorAlpha: number;
  86413. bottomColor: BABYLON.Color3;
  86414. bottomColorAlpha: number;
  86415. offset: number;
  86416. scale: number;
  86417. smoothness: number;
  86418. private _disableLighting;
  86419. disableLighting: boolean;
  86420. constructor(name: string, scene: BABYLON.Scene);
  86421. needAlphaBlending(): boolean;
  86422. needAlphaTesting(): boolean;
  86423. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86424. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86425. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86426. getAnimatables(): BABYLON.IAnimatable[];
  86427. dispose(forceDisposeEffect?: boolean): void;
  86428. clone(name: string): GradientMaterial;
  86429. serialize(): any;
  86430. getClassName(): string;
  86431. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86432. }
  86433. }
  86434. declare module BABYLON {
  86435. /** @hidden */
  86436. export var gridPixelShader: {
  86437. name: string;
  86438. shader: string;
  86439. };
  86440. }
  86441. declare module BABYLON {
  86442. /** @hidden */
  86443. export var gridVertexShader: {
  86444. name: string;
  86445. shader: string;
  86446. };
  86447. }
  86448. declare module BABYLON {
  86449. /**
  86450. * The grid materials allows you to wrap any shape with a grid.
  86451. * Colors are customizable.
  86452. */
  86453. export class GridMaterial extends BABYLON.PushMaterial {
  86454. /**
  86455. * Main color of the grid (e.g. between lines)
  86456. */
  86457. mainColor: BABYLON.Color3;
  86458. /**
  86459. * Color of the grid lines.
  86460. */
  86461. lineColor: BABYLON.Color3;
  86462. /**
  86463. * The scale of the grid compared to unit.
  86464. */
  86465. gridRatio: number;
  86466. /**
  86467. * Allows setting an offset for the grid lines.
  86468. */
  86469. gridOffset: BABYLON.Vector3;
  86470. /**
  86471. * The frequency of thicker lines.
  86472. */
  86473. majorUnitFrequency: number;
  86474. /**
  86475. * The visibility of minor units in the grid.
  86476. */
  86477. minorUnitVisibility: number;
  86478. /**
  86479. * The grid opacity outside of the lines.
  86480. */
  86481. opacity: number;
  86482. /**
  86483. * Determine RBG output is premultiplied by alpha value.
  86484. */
  86485. preMultiplyAlpha: boolean;
  86486. private _opacityTexture;
  86487. opacityTexture: BABYLON.BaseTexture;
  86488. private _gridControl;
  86489. /**
  86490. * constructor
  86491. * @param name The name given to the material in order to identify it afterwards.
  86492. * @param scene The scene the material is used in.
  86493. */
  86494. constructor(name: string, scene: BABYLON.Scene);
  86495. /**
  86496. * Returns wehter or not the grid requires alpha blending.
  86497. */
  86498. needAlphaBlending(): boolean;
  86499. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86500. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86501. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86502. /**
  86503. * Dispose the material and its associated resources.
  86504. * @param forceDisposeEffect will also dispose the used effect when true
  86505. */
  86506. dispose(forceDisposeEffect?: boolean): void;
  86507. clone(name: string): GridMaterial;
  86508. serialize(): any;
  86509. getClassName(): string;
  86510. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  86511. }
  86512. }
  86513. declare module BABYLON {
  86514. /** @hidden */
  86515. export var lavaPixelShader: {
  86516. name: string;
  86517. shader: string;
  86518. };
  86519. }
  86520. declare module BABYLON {
  86521. /** @hidden */
  86522. export var lavaVertexShader: {
  86523. name: string;
  86524. shader: string;
  86525. };
  86526. }
  86527. declare module BABYLON {
  86528. export class LavaMaterial extends BABYLON.PushMaterial {
  86529. private _diffuseTexture;
  86530. diffuseTexture: BABYLON.BaseTexture;
  86531. noiseTexture: BABYLON.BaseTexture;
  86532. fogColor: BABYLON.Color3;
  86533. speed: number;
  86534. movingSpeed: number;
  86535. lowFrequencySpeed: number;
  86536. fogDensity: number;
  86537. private _lastTime;
  86538. diffuseColor: BABYLON.Color3;
  86539. private _disableLighting;
  86540. disableLighting: boolean;
  86541. private _unlit;
  86542. unlit: boolean;
  86543. private _maxSimultaneousLights;
  86544. maxSimultaneousLights: number;
  86545. private _scaledDiffuse;
  86546. constructor(name: string, scene: BABYLON.Scene);
  86547. needAlphaBlending(): boolean;
  86548. needAlphaTesting(): boolean;
  86549. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86550. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86551. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86552. getAnimatables(): BABYLON.IAnimatable[];
  86553. getActiveTextures(): BABYLON.BaseTexture[];
  86554. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86555. dispose(forceDisposeEffect?: boolean): void;
  86556. clone(name: string): LavaMaterial;
  86557. serialize(): any;
  86558. getClassName(): string;
  86559. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  86560. }
  86561. }
  86562. declare module BABYLON {
  86563. /** @hidden */
  86564. export var mixPixelShader: {
  86565. name: string;
  86566. shader: string;
  86567. };
  86568. }
  86569. declare module BABYLON {
  86570. /** @hidden */
  86571. export var mixVertexShader: {
  86572. name: string;
  86573. shader: string;
  86574. };
  86575. }
  86576. declare module BABYLON {
  86577. export class MixMaterial extends BABYLON.PushMaterial {
  86578. /**
  86579. * Mix textures
  86580. */
  86581. private _mixTexture1;
  86582. mixTexture1: BABYLON.BaseTexture;
  86583. private _mixTexture2;
  86584. mixTexture2: BABYLON.BaseTexture;
  86585. /**
  86586. * Diffuse textures
  86587. */
  86588. private _diffuseTexture1;
  86589. diffuseTexture1: BABYLON.Texture;
  86590. private _diffuseTexture2;
  86591. diffuseTexture2: BABYLON.Texture;
  86592. private _diffuseTexture3;
  86593. diffuseTexture3: BABYLON.Texture;
  86594. private _diffuseTexture4;
  86595. diffuseTexture4: BABYLON.Texture;
  86596. private _diffuseTexture5;
  86597. diffuseTexture5: BABYLON.Texture;
  86598. private _diffuseTexture6;
  86599. diffuseTexture6: BABYLON.Texture;
  86600. private _diffuseTexture7;
  86601. diffuseTexture7: BABYLON.Texture;
  86602. private _diffuseTexture8;
  86603. diffuseTexture8: BABYLON.Texture;
  86604. /**
  86605. * Uniforms
  86606. */
  86607. diffuseColor: BABYLON.Color3;
  86608. specularColor: BABYLON.Color3;
  86609. specularPower: number;
  86610. private _disableLighting;
  86611. disableLighting: boolean;
  86612. private _maxSimultaneousLights;
  86613. maxSimultaneousLights: number;
  86614. constructor(name: string, scene: BABYLON.Scene);
  86615. needAlphaBlending(): boolean;
  86616. needAlphaTesting(): boolean;
  86617. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86618. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86619. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86620. getAnimatables(): BABYLON.IAnimatable[];
  86621. getActiveTextures(): BABYLON.BaseTexture[];
  86622. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86623. dispose(forceDisposeEffect?: boolean): void;
  86624. clone(name: string): MixMaterial;
  86625. serialize(): any;
  86626. getClassName(): string;
  86627. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  86628. }
  86629. }
  86630. declare module BABYLON {
  86631. /** @hidden */
  86632. export var normalPixelShader: {
  86633. name: string;
  86634. shader: string;
  86635. };
  86636. }
  86637. declare module BABYLON {
  86638. /** @hidden */
  86639. export var normalVertexShader: {
  86640. name: string;
  86641. shader: string;
  86642. };
  86643. }
  86644. declare module BABYLON {
  86645. export class NormalMaterial extends BABYLON.PushMaterial {
  86646. private _diffuseTexture;
  86647. diffuseTexture: BABYLON.BaseTexture;
  86648. diffuseColor: BABYLON.Color3;
  86649. private _disableLighting;
  86650. disableLighting: boolean;
  86651. private _maxSimultaneousLights;
  86652. maxSimultaneousLights: number;
  86653. constructor(name: string, scene: BABYLON.Scene);
  86654. needAlphaBlending(): boolean;
  86655. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86656. needAlphaTesting(): boolean;
  86657. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86658. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86659. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86660. getAnimatables(): BABYLON.IAnimatable[];
  86661. getActiveTextures(): BABYLON.BaseTexture[];
  86662. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86663. dispose(forceDisposeEffect?: boolean): void;
  86664. clone(name: string): NormalMaterial;
  86665. serialize(): any;
  86666. getClassName(): string;
  86667. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  86668. }
  86669. }
  86670. declare module BABYLON {
  86671. /** @hidden */
  86672. export var shadowOnlyPixelShader: {
  86673. name: string;
  86674. shader: string;
  86675. };
  86676. }
  86677. declare module BABYLON {
  86678. /** @hidden */
  86679. export var shadowOnlyVertexShader: {
  86680. name: string;
  86681. shader: string;
  86682. };
  86683. }
  86684. declare module BABYLON {
  86685. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  86686. private _activeLight;
  86687. private _needAlphaBlending;
  86688. constructor(name: string, scene: BABYLON.Scene);
  86689. shadowColor: BABYLON.Color3;
  86690. needAlphaBlending(): boolean;
  86691. needAlphaTesting(): boolean;
  86692. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86693. get activeLight(): BABYLON.IShadowLight;
  86694. set activeLight(light: BABYLON.IShadowLight);
  86695. private _getFirstShadowLightForMesh;
  86696. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86697. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86698. clone(name: string): ShadowOnlyMaterial;
  86699. serialize(): any;
  86700. getClassName(): string;
  86701. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  86702. }
  86703. }
  86704. declare module BABYLON {
  86705. /** @hidden */
  86706. export var simplePixelShader: {
  86707. name: string;
  86708. shader: string;
  86709. };
  86710. }
  86711. declare module BABYLON {
  86712. /** @hidden */
  86713. export var simpleVertexShader: {
  86714. name: string;
  86715. shader: string;
  86716. };
  86717. }
  86718. declare module BABYLON {
  86719. export class SimpleMaterial extends BABYLON.PushMaterial {
  86720. private _diffuseTexture;
  86721. diffuseTexture: BABYLON.BaseTexture;
  86722. diffuseColor: BABYLON.Color3;
  86723. private _disableLighting;
  86724. disableLighting: boolean;
  86725. private _maxSimultaneousLights;
  86726. maxSimultaneousLights: number;
  86727. constructor(name: string, scene: BABYLON.Scene);
  86728. needAlphaBlending(): boolean;
  86729. needAlphaTesting(): boolean;
  86730. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86731. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86732. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86733. getAnimatables(): BABYLON.IAnimatable[];
  86734. getActiveTextures(): BABYLON.BaseTexture[];
  86735. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86736. dispose(forceDisposeEffect?: boolean): void;
  86737. clone(name: string): SimpleMaterial;
  86738. serialize(): any;
  86739. getClassName(): string;
  86740. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  86741. }
  86742. }
  86743. declare module BABYLON {
  86744. /** @hidden */
  86745. export var skyPixelShader: {
  86746. name: string;
  86747. shader: string;
  86748. };
  86749. }
  86750. declare module BABYLON {
  86751. /** @hidden */
  86752. export var skyVertexShader: {
  86753. name: string;
  86754. shader: string;
  86755. };
  86756. }
  86757. declare module BABYLON {
  86758. /**
  86759. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  86760. * @see https://doc.babylonjs.com/extensions/sky
  86761. */
  86762. export class SkyMaterial extends BABYLON.PushMaterial {
  86763. /**
  86764. * Defines the overall luminance of sky in interval ]0, 1[.
  86765. */
  86766. luminance: number;
  86767. /**
  86768. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  86769. */
  86770. turbidity: number;
  86771. /**
  86772. * Defines the sky appearance (light intensity).
  86773. */
  86774. rayleigh: number;
  86775. /**
  86776. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  86777. */
  86778. mieCoefficient: number;
  86779. /**
  86780. * Defines the amount of haze particles following the Mie scattering theory.
  86781. */
  86782. mieDirectionalG: number;
  86783. /**
  86784. * Defines the distance of the sun according to the active scene camera.
  86785. */
  86786. distance: number;
  86787. /**
  86788. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  86789. * "inclined".
  86790. */
  86791. inclination: number;
  86792. /**
  86793. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  86794. * an object direction and a reference direction.
  86795. */
  86796. azimuth: number;
  86797. /**
  86798. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  86799. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  86800. */
  86801. sunPosition: BABYLON.Vector3;
  86802. /**
  86803. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  86804. * .sunPosition property.
  86805. */
  86806. useSunPosition: boolean;
  86807. /**
  86808. * Defines an offset vector used to get a horizon offset.
  86809. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  86810. */
  86811. cameraOffset: BABYLON.Vector3;
  86812. private _cameraPosition;
  86813. /**
  86814. * Instantiates a new sky material.
  86815. * This material allows to create dynamic and texture free
  86816. * effects for skyboxes by taking care of the atmosphere state.
  86817. * @see https://doc.babylonjs.com/extensions/sky
  86818. * @param name Define the name of the material in the scene
  86819. * @param scene Define the scene the material belong to
  86820. */
  86821. constructor(name: string, scene: BABYLON.Scene);
  86822. /**
  86823. * Specifies if the material will require alpha blending
  86824. * @returns a boolean specifying if alpha blending is needed
  86825. */
  86826. needAlphaBlending(): boolean;
  86827. /**
  86828. * Specifies if this material should be rendered in alpha test mode
  86829. * @returns false as the sky material doesn't need alpha testing.
  86830. */
  86831. needAlphaTesting(): boolean;
  86832. /**
  86833. * Get the texture used for alpha test purpose.
  86834. * @returns null as the sky material has no texture.
  86835. */
  86836. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86837. /**
  86838. * Get if the submesh is ready to be used and all its information available.
  86839. * Child classes can use it to update shaders
  86840. * @param mesh defines the mesh to check
  86841. * @param subMesh defines which submesh to check
  86842. * @param useInstances specifies that instances should be used
  86843. * @returns a boolean indicating that the submesh is ready or not
  86844. */
  86845. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86846. /**
  86847. * Binds the submesh to this material by preparing the effect and shader to draw
  86848. * @param world defines the world transformation matrix
  86849. * @param mesh defines the mesh containing the submesh
  86850. * @param subMesh defines the submesh to bind the material to
  86851. */
  86852. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86853. /**
  86854. * Get the list of animatables in the material.
  86855. * @returns the list of animatables object used in the material
  86856. */
  86857. getAnimatables(): BABYLON.IAnimatable[];
  86858. /**
  86859. * Disposes the material
  86860. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86861. */
  86862. dispose(forceDisposeEffect?: boolean): void;
  86863. /**
  86864. * Makes a duplicate of the material, and gives it a new name
  86865. * @param name defines the new name for the duplicated material
  86866. * @returns the cloned material
  86867. */
  86868. clone(name: string): SkyMaterial;
  86869. /**
  86870. * Serializes this material in a JSON representation
  86871. * @returns the serialized material object
  86872. */
  86873. serialize(): any;
  86874. /**
  86875. * Gets the current class name of the material e.g. "SkyMaterial"
  86876. * Mainly use in serialization.
  86877. * @returns the class name
  86878. */
  86879. getClassName(): string;
  86880. /**
  86881. * Creates a sky material from parsed material data
  86882. * @param source defines the JSON representation of the material
  86883. * @param scene defines the hosting scene
  86884. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86885. * @returns a new sky material
  86886. */
  86887. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  86888. }
  86889. }
  86890. declare module BABYLON {
  86891. /** @hidden */
  86892. export var terrainPixelShader: {
  86893. name: string;
  86894. shader: string;
  86895. };
  86896. }
  86897. declare module BABYLON {
  86898. /** @hidden */
  86899. export var terrainVertexShader: {
  86900. name: string;
  86901. shader: string;
  86902. };
  86903. }
  86904. declare module BABYLON {
  86905. export class TerrainMaterial extends BABYLON.PushMaterial {
  86906. private _mixTexture;
  86907. mixTexture: BABYLON.BaseTexture;
  86908. private _diffuseTexture1;
  86909. diffuseTexture1: BABYLON.Texture;
  86910. private _diffuseTexture2;
  86911. diffuseTexture2: BABYLON.Texture;
  86912. private _diffuseTexture3;
  86913. diffuseTexture3: BABYLON.Texture;
  86914. private _bumpTexture1;
  86915. bumpTexture1: BABYLON.Texture;
  86916. private _bumpTexture2;
  86917. bumpTexture2: BABYLON.Texture;
  86918. private _bumpTexture3;
  86919. bumpTexture3: BABYLON.Texture;
  86920. diffuseColor: BABYLON.Color3;
  86921. specularColor: BABYLON.Color3;
  86922. specularPower: number;
  86923. private _disableLighting;
  86924. disableLighting: boolean;
  86925. private _maxSimultaneousLights;
  86926. maxSimultaneousLights: number;
  86927. constructor(name: string, scene: BABYLON.Scene);
  86928. needAlphaBlending(): boolean;
  86929. needAlphaTesting(): boolean;
  86930. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86931. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86932. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86933. getAnimatables(): BABYLON.IAnimatable[];
  86934. getActiveTextures(): BABYLON.BaseTexture[];
  86935. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86936. dispose(forceDisposeEffect?: boolean): void;
  86937. clone(name: string): TerrainMaterial;
  86938. serialize(): any;
  86939. getClassName(): string;
  86940. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  86941. }
  86942. }
  86943. declare module BABYLON {
  86944. /** @hidden */
  86945. export var triplanarPixelShader: {
  86946. name: string;
  86947. shader: string;
  86948. };
  86949. }
  86950. declare module BABYLON {
  86951. /** @hidden */
  86952. export var triplanarVertexShader: {
  86953. name: string;
  86954. shader: string;
  86955. };
  86956. }
  86957. declare module BABYLON {
  86958. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  86959. mixTexture: BABYLON.BaseTexture;
  86960. private _diffuseTextureX;
  86961. diffuseTextureX: BABYLON.BaseTexture;
  86962. private _diffuseTextureY;
  86963. diffuseTextureY: BABYLON.BaseTexture;
  86964. private _diffuseTextureZ;
  86965. diffuseTextureZ: BABYLON.BaseTexture;
  86966. private _normalTextureX;
  86967. normalTextureX: BABYLON.BaseTexture;
  86968. private _normalTextureY;
  86969. normalTextureY: BABYLON.BaseTexture;
  86970. private _normalTextureZ;
  86971. normalTextureZ: BABYLON.BaseTexture;
  86972. tileSize: number;
  86973. diffuseColor: BABYLON.Color3;
  86974. specularColor: BABYLON.Color3;
  86975. specularPower: number;
  86976. private _disableLighting;
  86977. disableLighting: boolean;
  86978. private _maxSimultaneousLights;
  86979. maxSimultaneousLights: number;
  86980. constructor(name: string, scene: BABYLON.Scene);
  86981. needAlphaBlending(): boolean;
  86982. needAlphaTesting(): boolean;
  86983. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86984. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86985. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86986. getAnimatables(): BABYLON.IAnimatable[];
  86987. getActiveTextures(): BABYLON.BaseTexture[];
  86988. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86989. dispose(forceDisposeEffect?: boolean): void;
  86990. clone(name: string): TriPlanarMaterial;
  86991. serialize(): any;
  86992. getClassName(): string;
  86993. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  86994. }
  86995. }
  86996. declare module BABYLON {
  86997. /** @hidden */
  86998. export var waterPixelShader: {
  86999. name: string;
  87000. shader: string;
  87001. };
  87002. }
  87003. declare module BABYLON {
  87004. /** @hidden */
  87005. export var waterVertexShader: {
  87006. name: string;
  87007. shader: string;
  87008. };
  87009. }
  87010. declare module BABYLON {
  87011. export class WaterMaterial extends BABYLON.PushMaterial {
  87012. renderTargetSize: BABYLON.Vector2;
  87013. private _bumpTexture;
  87014. bumpTexture: BABYLON.BaseTexture;
  87015. diffuseColor: BABYLON.Color3;
  87016. specularColor: BABYLON.Color3;
  87017. specularPower: number;
  87018. private _disableLighting;
  87019. disableLighting: boolean;
  87020. private _maxSimultaneousLights;
  87021. maxSimultaneousLights: number;
  87022. /**
  87023. * Defines the wind force.
  87024. */
  87025. windForce: number;
  87026. /**
  87027. * Defines the direction of the wind in the plane (X, Z).
  87028. */
  87029. windDirection: BABYLON.Vector2;
  87030. /**
  87031. * Defines the height of the waves.
  87032. */
  87033. waveHeight: number;
  87034. /**
  87035. * Defines the bump height related to the bump map.
  87036. */
  87037. bumpHeight: number;
  87038. /**
  87039. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87040. */
  87041. private _bumpSuperimpose;
  87042. bumpSuperimpose: boolean;
  87043. /**
  87044. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87045. */
  87046. private _fresnelSeparate;
  87047. fresnelSeparate: boolean;
  87048. /**
  87049. * Defines wether or not bump Wwves modify the reflection.
  87050. */
  87051. private _bumpAffectsReflection;
  87052. bumpAffectsReflection: boolean;
  87053. /**
  87054. * Defines the water color blended with the refraction (near).
  87055. */
  87056. waterColor: BABYLON.Color3;
  87057. /**
  87058. * Defines the blend factor related to the water color.
  87059. */
  87060. colorBlendFactor: number;
  87061. /**
  87062. * Defines the water color blended with the reflection (far).
  87063. */
  87064. waterColor2: BABYLON.Color3;
  87065. /**
  87066. * Defines the blend factor related to the water color (reflection, far).
  87067. */
  87068. colorBlendFactor2: number;
  87069. /**
  87070. * Defines the maximum length of a wave.
  87071. */
  87072. waveLength: number;
  87073. /**
  87074. * Defines the waves speed.
  87075. */
  87076. waveSpeed: number;
  87077. /**
  87078. * 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.
  87079. */
  87080. waveCount: number;
  87081. /**
  87082. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87083. * will avoid calculating useless pixels in the pixel shader of the water material.
  87084. */
  87085. disableClipPlane: boolean;
  87086. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87087. private _mesh;
  87088. private _refractionRTT;
  87089. private _reflectionRTT;
  87090. private _reflectionTransform;
  87091. private _lastTime;
  87092. private _lastDeltaTime;
  87093. private _useLogarithmicDepth;
  87094. private _waitingRenderList;
  87095. private _imageProcessingConfiguration;
  87096. private _imageProcessingObserver;
  87097. /**
  87098. * Gets a boolean indicating that current material needs to register RTT
  87099. */
  87100. get hasRenderTargetTextures(): boolean;
  87101. /**
  87102. * Constructor
  87103. */
  87104. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87105. get useLogarithmicDepth(): boolean;
  87106. set useLogarithmicDepth(value: boolean);
  87107. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87108. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87109. addToRenderList(node: any): void;
  87110. enableRenderTargets(enable: boolean): void;
  87111. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87112. get renderTargetsEnabled(): boolean;
  87113. needAlphaBlending(): boolean;
  87114. needAlphaTesting(): boolean;
  87115. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87116. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87117. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87118. private _createRenderTargets;
  87119. getAnimatables(): BABYLON.IAnimatable[];
  87120. getActiveTextures(): BABYLON.BaseTexture[];
  87121. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87122. dispose(forceDisposeEffect?: boolean): void;
  87123. clone(name: string): WaterMaterial;
  87124. serialize(): any;
  87125. getClassName(): string;
  87126. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87127. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87128. }
  87129. }
  87130. declare module BABYLON {
  87131. /** @hidden */
  87132. export var asciiartPixelShader: {
  87133. name: string;
  87134. shader: string;
  87135. };
  87136. }
  87137. declare module BABYLON {
  87138. /**
  87139. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87140. *
  87141. * It basically takes care rendering the font front the given font size to a texture.
  87142. * This is used later on in the postprocess.
  87143. */
  87144. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87145. private _font;
  87146. private _text;
  87147. private _charSize;
  87148. /**
  87149. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87150. */
  87151. get charSize(): number;
  87152. /**
  87153. * Create a new instance of the Ascii Art FontTexture class
  87154. * @param name the name of the texture
  87155. * @param font the font to use, use the W3C CSS notation
  87156. * @param text the caracter set to use in the rendering.
  87157. * @param scene the scene that owns the texture
  87158. */
  87159. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87160. /**
  87161. * Gets the max char width of a font.
  87162. * @param font the font to use, use the W3C CSS notation
  87163. * @return the max char width
  87164. */
  87165. private getFontWidth;
  87166. /**
  87167. * Gets the max char height of a font.
  87168. * @param font the font to use, use the W3C CSS notation
  87169. * @return the max char height
  87170. */
  87171. private getFontHeight;
  87172. /**
  87173. * Clones the current AsciiArtTexture.
  87174. * @return the clone of the texture.
  87175. */
  87176. clone(): AsciiArtFontTexture;
  87177. /**
  87178. * Parses a json object representing the texture and returns an instance of it.
  87179. * @param source the source JSON representation
  87180. * @param scene the scene to create the texture for
  87181. * @return the parsed texture
  87182. */
  87183. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87184. }
  87185. /**
  87186. * Option available in the Ascii Art Post Process.
  87187. */
  87188. export interface IAsciiArtPostProcessOptions {
  87189. /**
  87190. * The font to use following the w3c font definition.
  87191. */
  87192. font?: string;
  87193. /**
  87194. * The character set to use in the postprocess.
  87195. */
  87196. characterSet?: string;
  87197. /**
  87198. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87199. * This number is defined between 0 and 1;
  87200. */
  87201. mixToTile?: number;
  87202. /**
  87203. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87204. * This number is defined between 0 and 1;
  87205. */
  87206. mixToNormal?: number;
  87207. }
  87208. /**
  87209. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87210. *
  87211. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87212. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87213. */
  87214. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87215. /**
  87216. * The font texture used to render the char in the post process.
  87217. */
  87218. private _asciiArtFontTexture;
  87219. /**
  87220. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87221. * This number is defined between 0 and 1;
  87222. */
  87223. mixToTile: number;
  87224. /**
  87225. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87226. * This number is defined between 0 and 1;
  87227. */
  87228. mixToNormal: number;
  87229. /**
  87230. * Instantiates a new Ascii Art Post Process.
  87231. * @param name the name to give to the postprocess
  87232. * @camera the camera to apply the post process to.
  87233. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87234. */
  87235. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87236. }
  87237. }
  87238. declare module BABYLON {
  87239. /** @hidden */
  87240. export var digitalrainPixelShader: {
  87241. name: string;
  87242. shader: string;
  87243. };
  87244. }
  87245. declare module BABYLON {
  87246. /**
  87247. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87248. *
  87249. * It basically takes care rendering the font front the given font size to a texture.
  87250. * This is used later on in the postprocess.
  87251. */
  87252. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87253. private _font;
  87254. private _text;
  87255. private _charSize;
  87256. /**
  87257. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87258. */
  87259. get charSize(): number;
  87260. /**
  87261. * Create a new instance of the Digital Rain FontTexture class
  87262. * @param name the name of the texture
  87263. * @param font the font to use, use the W3C CSS notation
  87264. * @param text the caracter set to use in the rendering.
  87265. * @param scene the scene that owns the texture
  87266. */
  87267. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87268. /**
  87269. * Gets the max char width of a font.
  87270. * @param font the font to use, use the W3C CSS notation
  87271. * @return the max char width
  87272. */
  87273. private getFontWidth;
  87274. /**
  87275. * Gets the max char height of a font.
  87276. * @param font the font to use, use the W3C CSS notation
  87277. * @return the max char height
  87278. */
  87279. private getFontHeight;
  87280. /**
  87281. * Clones the current DigitalRainFontTexture.
  87282. * @return the clone of the texture.
  87283. */
  87284. clone(): DigitalRainFontTexture;
  87285. /**
  87286. * Parses a json object representing the texture and returns an instance of it.
  87287. * @param source the source JSON representation
  87288. * @param scene the scene to create the texture for
  87289. * @return the parsed texture
  87290. */
  87291. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87292. }
  87293. /**
  87294. * Option available in the Digital Rain Post Process.
  87295. */
  87296. export interface IDigitalRainPostProcessOptions {
  87297. /**
  87298. * The font to use following the w3c font definition.
  87299. */
  87300. font?: string;
  87301. /**
  87302. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87303. * This number is defined between 0 and 1;
  87304. */
  87305. mixToTile?: number;
  87306. /**
  87307. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87308. * This number is defined between 0 and 1;
  87309. */
  87310. mixToNormal?: number;
  87311. }
  87312. /**
  87313. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87314. *
  87315. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87316. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87317. */
  87318. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87319. /**
  87320. * The font texture used to render the char in the post process.
  87321. */
  87322. private _digitalRainFontTexture;
  87323. /**
  87324. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87325. * This number is defined between 0 and 1;
  87326. */
  87327. mixToTile: number;
  87328. /**
  87329. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87330. * This number is defined between 0 and 1;
  87331. */
  87332. mixToNormal: number;
  87333. /**
  87334. * Instantiates a new Digital Rain Post Process.
  87335. * @param name the name to give to the postprocess
  87336. * @camera the camera to apply the post process to.
  87337. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87338. */
  87339. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87340. }
  87341. }
  87342. declare module BABYLON {
  87343. /** @hidden */
  87344. export var brickProceduralTexturePixelShader: {
  87345. name: string;
  87346. shader: string;
  87347. };
  87348. }
  87349. declare module BABYLON {
  87350. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87351. private _numberOfBricksHeight;
  87352. private _numberOfBricksWidth;
  87353. private _jointColor;
  87354. private _brickColor;
  87355. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87356. updateShaderUniforms(): void;
  87357. get numberOfBricksHeight(): number;
  87358. set numberOfBricksHeight(value: number);
  87359. get numberOfBricksWidth(): number;
  87360. set numberOfBricksWidth(value: number);
  87361. get jointColor(): BABYLON.Color3;
  87362. set jointColor(value: BABYLON.Color3);
  87363. get brickColor(): BABYLON.Color3;
  87364. set brickColor(value: BABYLON.Color3);
  87365. /**
  87366. * Serializes this brick procedural texture
  87367. * @returns a serialized brick procedural texture object
  87368. */
  87369. serialize(): any;
  87370. /**
  87371. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87372. * @param parsedTexture defines parsed texture data
  87373. * @param scene defines the current scene
  87374. * @param rootUrl defines the root URL containing brick procedural texture information
  87375. * @returns a parsed Brick Procedural BABYLON.Texture
  87376. */
  87377. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87378. }
  87379. }
  87380. declare module BABYLON {
  87381. /** @hidden */
  87382. export var cloudProceduralTexturePixelShader: {
  87383. name: string;
  87384. shader: string;
  87385. };
  87386. }
  87387. declare module BABYLON {
  87388. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87389. private _skyColor;
  87390. private _cloudColor;
  87391. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87392. updateShaderUniforms(): void;
  87393. get skyColor(): BABYLON.Color4;
  87394. set skyColor(value: BABYLON.Color4);
  87395. get cloudColor(): BABYLON.Color4;
  87396. set cloudColor(value: BABYLON.Color4);
  87397. /**
  87398. * Serializes this cloud procedural texture
  87399. * @returns a serialized cloud procedural texture object
  87400. */
  87401. serialize(): any;
  87402. /**
  87403. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87404. * @param parsedTexture defines parsed texture data
  87405. * @param scene defines the current scene
  87406. * @param rootUrl defines the root URL containing cloud procedural texture information
  87407. * @returns a parsed Cloud Procedural BABYLON.Texture
  87408. */
  87409. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87410. }
  87411. }
  87412. declare module BABYLON {
  87413. /** @hidden */
  87414. export var fireProceduralTexturePixelShader: {
  87415. name: string;
  87416. shader: string;
  87417. };
  87418. }
  87419. declare module BABYLON {
  87420. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87421. private _time;
  87422. private _speed;
  87423. private _autoGenerateTime;
  87424. private _fireColors;
  87425. private _alphaThreshold;
  87426. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87427. updateShaderUniforms(): void;
  87428. render(useCameraPostProcess?: boolean): void;
  87429. static get PurpleFireColors(): BABYLON.Color3[];
  87430. static get GreenFireColors(): BABYLON.Color3[];
  87431. static get RedFireColors(): BABYLON.Color3[];
  87432. static get BlueFireColors(): BABYLON.Color3[];
  87433. get autoGenerateTime(): boolean;
  87434. set autoGenerateTime(value: boolean);
  87435. get fireColors(): BABYLON.Color3[];
  87436. set fireColors(value: BABYLON.Color3[]);
  87437. get time(): number;
  87438. set time(value: number);
  87439. get speed(): BABYLON.Vector2;
  87440. set speed(value: BABYLON.Vector2);
  87441. get alphaThreshold(): number;
  87442. set alphaThreshold(value: number);
  87443. /**
  87444. * Serializes this fire procedural texture
  87445. * @returns a serialized fire procedural texture object
  87446. */
  87447. serialize(): any;
  87448. /**
  87449. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87450. * @param parsedTexture defines parsed texture data
  87451. * @param scene defines the current scene
  87452. * @param rootUrl defines the root URL containing fire procedural texture information
  87453. * @returns a parsed Fire Procedural BABYLON.Texture
  87454. */
  87455. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87456. }
  87457. }
  87458. declare module BABYLON {
  87459. /** @hidden */
  87460. export var grassProceduralTexturePixelShader: {
  87461. name: string;
  87462. shader: string;
  87463. };
  87464. }
  87465. declare module BABYLON {
  87466. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  87467. private _grassColors;
  87468. private _groundColor;
  87469. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87470. updateShaderUniforms(): void;
  87471. get grassColors(): BABYLON.Color3[];
  87472. set grassColors(value: BABYLON.Color3[]);
  87473. get groundColor(): BABYLON.Color3;
  87474. set groundColor(value: BABYLON.Color3);
  87475. /**
  87476. * Serializes this grass procedural texture
  87477. * @returns a serialized grass procedural texture object
  87478. */
  87479. serialize(): any;
  87480. /**
  87481. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  87482. * @param parsedTexture defines parsed texture data
  87483. * @param scene defines the current scene
  87484. * @param rootUrl defines the root URL containing grass procedural texture information
  87485. * @returns a parsed Grass Procedural BABYLON.Texture
  87486. */
  87487. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  87488. }
  87489. }
  87490. declare module BABYLON {
  87491. /** @hidden */
  87492. export var marbleProceduralTexturePixelShader: {
  87493. name: string;
  87494. shader: string;
  87495. };
  87496. }
  87497. declare module BABYLON {
  87498. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  87499. private _numberOfTilesHeight;
  87500. private _numberOfTilesWidth;
  87501. private _amplitude;
  87502. private _jointColor;
  87503. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87504. updateShaderUniforms(): void;
  87505. get numberOfTilesHeight(): number;
  87506. set numberOfTilesHeight(value: number);
  87507. get amplitude(): number;
  87508. set amplitude(value: number);
  87509. get numberOfTilesWidth(): number;
  87510. set numberOfTilesWidth(value: number);
  87511. get jointColor(): BABYLON.Color3;
  87512. set jointColor(value: BABYLON.Color3);
  87513. /**
  87514. * Serializes this marble procedural texture
  87515. * @returns a serialized marble procedural texture object
  87516. */
  87517. serialize(): any;
  87518. /**
  87519. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  87520. * @param parsedTexture defines parsed texture data
  87521. * @param scene defines the current scene
  87522. * @param rootUrl defines the root URL containing marble procedural texture information
  87523. * @returns a parsed Marble Procedural BABYLON.Texture
  87524. */
  87525. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  87526. }
  87527. }
  87528. declare module BABYLON {
  87529. /** @hidden */
  87530. export var normalMapProceduralTexturePixelShader: {
  87531. name: string;
  87532. shader: string;
  87533. };
  87534. }
  87535. declare module BABYLON {
  87536. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  87537. private _baseTexture;
  87538. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87539. updateShaderUniforms(): void;
  87540. render(useCameraPostProcess?: boolean): void;
  87541. resize(size: any, generateMipMaps: any): void;
  87542. get baseTexture(): BABYLON.Texture;
  87543. set baseTexture(texture: BABYLON.Texture);
  87544. /**
  87545. * Serializes this normal map procedural texture
  87546. * @returns a serialized normal map procedural texture object
  87547. */
  87548. serialize(): any;
  87549. /**
  87550. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  87551. * @param parsedTexture defines parsed texture data
  87552. * @param scene defines the current scene
  87553. * @param rootUrl defines the root URL containing normal map procedural texture information
  87554. * @returns a parsed Normal Map Procedural BABYLON.Texture
  87555. */
  87556. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  87557. }
  87558. }
  87559. declare module BABYLON {
  87560. /** @hidden */
  87561. export var perlinNoiseProceduralTexturePixelShader: {
  87562. name: string;
  87563. shader: string;
  87564. };
  87565. }
  87566. declare module BABYLON {
  87567. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  87568. time: number;
  87569. timeScale: number;
  87570. translationSpeed: number;
  87571. private _currentTranslation;
  87572. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87573. updateShaderUniforms(): void;
  87574. render(useCameraPostProcess?: boolean): void;
  87575. resize(size: any, generateMipMaps: any): void;
  87576. /**
  87577. * Serializes this perlin noise procedural texture
  87578. * @returns a serialized perlin noise procedural texture object
  87579. */
  87580. serialize(): any;
  87581. /**
  87582. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  87583. * @param parsedTexture defines parsed texture data
  87584. * @param scene defines the current scene
  87585. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  87586. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  87587. */
  87588. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  87589. }
  87590. }
  87591. declare module BABYLON {
  87592. /** @hidden */
  87593. export var roadProceduralTexturePixelShader: {
  87594. name: string;
  87595. shader: string;
  87596. };
  87597. }
  87598. declare module BABYLON {
  87599. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  87600. private _roadColor;
  87601. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87602. updateShaderUniforms(): void;
  87603. get roadColor(): BABYLON.Color3;
  87604. set roadColor(value: BABYLON.Color3);
  87605. /**
  87606. * Serializes this road procedural texture
  87607. * @returns a serialized road procedural texture object
  87608. */
  87609. serialize(): any;
  87610. /**
  87611. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  87612. * @param parsedTexture defines parsed texture data
  87613. * @param scene defines the current scene
  87614. * @param rootUrl defines the root URL containing road procedural texture information
  87615. * @returns a parsed Road Procedural BABYLON.Texture
  87616. */
  87617. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  87618. }
  87619. }
  87620. declare module BABYLON {
  87621. /** @hidden */
  87622. export var starfieldProceduralTexturePixelShader: {
  87623. name: string;
  87624. shader: string;
  87625. };
  87626. }
  87627. declare module BABYLON {
  87628. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  87629. private _time;
  87630. private _alpha;
  87631. private _beta;
  87632. private _zoom;
  87633. private _formuparam;
  87634. private _stepsize;
  87635. private _tile;
  87636. private _brightness;
  87637. private _darkmatter;
  87638. private _distfading;
  87639. private _saturation;
  87640. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87641. updateShaderUniforms(): void;
  87642. get time(): number;
  87643. set time(value: number);
  87644. get alpha(): number;
  87645. set alpha(value: number);
  87646. get beta(): number;
  87647. set beta(value: number);
  87648. get formuparam(): number;
  87649. set formuparam(value: number);
  87650. get stepsize(): number;
  87651. set stepsize(value: number);
  87652. get zoom(): number;
  87653. set zoom(value: number);
  87654. get tile(): number;
  87655. set tile(value: number);
  87656. get brightness(): number;
  87657. set brightness(value: number);
  87658. get darkmatter(): number;
  87659. set darkmatter(value: number);
  87660. get distfading(): number;
  87661. set distfading(value: number);
  87662. get saturation(): number;
  87663. set saturation(value: number);
  87664. /**
  87665. * Serializes this starfield procedural texture
  87666. * @returns a serialized starfield procedural texture object
  87667. */
  87668. serialize(): any;
  87669. /**
  87670. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  87671. * @param parsedTexture defines parsed texture data
  87672. * @param scene defines the current scene
  87673. * @param rootUrl defines the root URL containing startfield procedural texture information
  87674. * @returns a parsed Starfield Procedural BABYLON.Texture
  87675. */
  87676. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  87677. }
  87678. }
  87679. declare module BABYLON {
  87680. /** @hidden */
  87681. export var woodProceduralTexturePixelShader: {
  87682. name: string;
  87683. shader: string;
  87684. };
  87685. }
  87686. declare module BABYLON {
  87687. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  87688. private _ampScale;
  87689. private _woodColor;
  87690. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87691. updateShaderUniforms(): void;
  87692. get ampScale(): number;
  87693. set ampScale(value: number);
  87694. get woodColor(): BABYLON.Color3;
  87695. set woodColor(value: BABYLON.Color3);
  87696. /**
  87697. * Serializes this wood procedural texture
  87698. * @returns a serialized wood procedural texture object
  87699. */
  87700. serialize(): any;
  87701. /**
  87702. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  87703. * @param parsedTexture defines parsed texture data
  87704. * @param scene defines the current scene
  87705. * @param rootUrl defines the root URL containing wood procedural texture information
  87706. * @returns a parsed Wood Procedural BABYLON.Texture
  87707. */
  87708. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  87709. }
  87710. }