documentation.d.ts 3.7 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490874918749287493874948749587496874978749887499875008750187502875038750487505875068750787508875098751087511875128751387514875158751687517875188751987520875218752287523875248752587526875278752887529875308753187532875338753487535875368753787538875398754087541875428754387544875458754687547875488754987550875518755287553875548755587556875578755887559875608756187562875638756487565875668756787568875698757087571875728757387574875758757687577875788757987580875818758287583875848758587586875878758887589875908759187592875938759487595875968759787598875998760087601876028760387604876058760687607876088760987610876118761287613876148761587616876178761887619876208762187622876238762487625876268762787628876298763087631876328763387634876358763687637876388763987640876418764287643876448764587646876478764887649876508765187652876538765487655876568765787658876598766087661876628766387664876658766687667876688766987670876718767287673876748767587676876778767887679876808768187682876838768487685876868768787688876898769087691876928769387694876958769687697876988769987700877018770287703877048770587706877078770887709877108771187712877138771487715877168771787718877198772087721877228772387724877258772687727877288772987730877318773287733877348773587736877378773887739877408774187742877438774487745877468774787748877498775087751877528775387754877558775687757877588775987760877618776287763877648776587766877678776887769877708777187772877738777487775877768777787778877798778087781877828778387784877858778687787877888778987790877918779287793877948779587796877978779887799878008780187802878038780487805878068780787808878098781087811878128781387814878158781687817878188781987820878218782287823878248782587826878278782887829878308783187832878338783487835878368783787838878398784087841878428784387844878458784687847878488784987850878518785287853878548785587856878578785887859878608786187862878638786487865878668786787868878698787087871878728787387874878758787687877878788787987880878818788287883878848788587886878878788887889878908789187892878938789487895878968789787898878998790087901879028790387904879058790687907879088790987910879118791287913879148791587916879178791887919879208792187922879238792487925879268792787928879298793087931879328793387934879358793687937879388793987940879418794287943879448794587946879478794887949879508795187952879538795487955879568795787958879598796087961879628796387964879658796687967879688796987970879718797287973879748797587976879778797887979879808798187982879838798487985879868798787988879898799087991879928799387994879958799687997879988799988000880018800288003880048800588006880078800888009880108801188012880138801488015880168801788018880198802088021880228802388024880258802688027880288802988030880318803288033880348803588036880378803888039880408804188042880438804488045880468804788048880498805088051880528805388054880558805688057880588805988060880618806288063880648806588066880678806888069880708807188072880738807488075880768807788078880798808088081880828808388084880858808688087880888808988090880918809288093880948809588096880978809888099881008810188102881038810488105881068810788108881098811088111881128811388114881158811688117881188811988120881218812288123881248812588126881278812888129881308813188132881338813488135881368813788138881398814088141881428814388144881458814688147881488814988150881518815288153881548815588156881578815888159881608816188162881638816488165881668816788168881698817088171881728817388174881758817688177881788817988180881818818288183881848818588186881878818888189881908819188192881938819488195881968819788198881998820088201882028820388204882058820688207882088820988210882118821288213882148821588216882178821888219882208822188222882238822488225882268822788228882298823088231882328823388234882358823688237882388823988240882418824288243882448824588246882478824888249882508825188252882538825488255882568825788258882598826088261882628826388264882658826688267882688826988270882718827288273882748827588276882778827888279882808828188282882838828488285882868828788288882898829088291882928829388294882958829688297882988829988300883018830288303883048830588306883078830888309883108831188312883138831488315883168831788318883198832088321883228832388324883258832688327883288832988330883318833288333883348833588336883378833888339883408834188342883438834488345883468834788348883498835088351883528835388354883558835688357883588835988360883618836288363883648836588366883678836888369883708837188372883738837488375883768837788378883798838088381883828838388384883858838688387883888838988390883918839288393883948839588396883978839888399884008840188402884038840488405884068840788408884098841088411884128841388414884158841688417884188841988420884218842288423884248842588426884278842888429884308843188432884338843488435884368843788438884398844088441884428844388444884458844688447884488844988450884518845288453884548845588456884578845888459884608846188462884638846488465884668846788468884698847088471884728847388474884758847688477884788847988480884818848288483884848848588486884878848888489884908849188492884938849488495884968849788498884998850088501885028850388504885058850688507885088850988510885118851288513885148851588516885178851888519885208852188522885238852488525885268852788528885298853088531885328853388534885358853688537885388853988540885418854288543885448854588546885478854888549885508855188552885538855488555885568855788558885598856088561885628856388564885658856688567885688856988570885718857288573885748857588576885778857888579885808858188582885838858488585885868858788588885898859088591885928859388594885958859688597885988859988600886018860288603886048860588606886078860888609886108861188612886138861488615886168861788618886198862088621886228862388624886258862688627886288862988630886318863288633886348863588636886378863888639886408864188642886438864488645886468864788648886498865088651886528865388654886558865688657886588865988660886618866288663886648866588666886678866888669886708867188672886738867488675886768867788678886798868088681886828868388684886858868688687886888868988690
  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 readonly _xhr;
  484. /**
  485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  486. * i.e. when loading files, where the server/service expects an Authorization header
  487. */
  488. static CustomRequestHeaders: {
  489. [key: string]: string;
  490. };
  491. /**
  492. * Add callback functions in this array to update all the requests before they get sent to the network
  493. */
  494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  495. private _injectCustomRequestHeaders;
  496. /**
  497. * Gets or sets a function to be called when loading progress changes
  498. */
  499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  501. /**
  502. * Returns client's state
  503. */
  504. get readyState(): number;
  505. /**
  506. * Returns client's status
  507. */
  508. get status(): number;
  509. /**
  510. * Returns client's status as a text
  511. */
  512. get statusText(): string;
  513. /**
  514. * Returns client's response
  515. */
  516. get response(): any;
  517. /**
  518. * Returns client's response url
  519. */
  520. get responseURL(): string;
  521. /**
  522. * Returns client's response as text
  523. */
  524. get responseText(): string;
  525. /**
  526. * Gets or sets the expected response type
  527. */
  528. get responseType(): XMLHttpRequestResponseType;
  529. set responseType(value: XMLHttpRequestResponseType);
  530. /** @hidden */
  531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  532. /** @hidden */
  533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  534. /**
  535. * Cancels any network activity
  536. */
  537. abort(): void;
  538. /**
  539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  540. * @param body defines an optional request body
  541. */
  542. send(body?: Document | BodyInit | null): void;
  543. /**
  544. * Sets the request method, request URL
  545. * @param method defines the method to use (GET, POST, etc..)
  546. * @param url defines the url to connect with
  547. */
  548. open(method: string, url: string): void;
  549. /**
  550. * Sets the value of a request header.
  551. * @param name The name of the header whose value is to be set
  552. * @param value The value to set as the body of the header
  553. */
  554. setRequestHeader(name: string, value: string): void;
  555. /**
  556. * Get the string containing the text of a particular header's value.
  557. * @param name The name of the header
  558. * @returns The string containing the text of the given header name
  559. */
  560. getResponseHeader(name: string): Nullable<string>;
  561. }
  562. }
  563. declare module BABYLON {
  564. /**
  565. * File request interface
  566. */
  567. export interface IFileRequest {
  568. /**
  569. * Raised when the request is complete (success or error).
  570. */
  571. onCompleteObservable: Observable<IFileRequest>;
  572. /**
  573. * Aborts the request for a file.
  574. */
  575. abort: () => void;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * Define options used to create a render target texture
  581. */
  582. export class RenderTargetCreationOptions {
  583. /**
  584. * Specifies is mipmaps must be generated
  585. */
  586. generateMipMaps?: boolean;
  587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  588. generateDepthBuffer?: boolean;
  589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  590. generateStencilBuffer?: boolean;
  591. /** Defines texture type (int by default) */
  592. type?: number;
  593. /** Defines sampling mode (trilinear by default) */
  594. samplingMode?: number;
  595. /** Defines format (RGBA by default) */
  596. format?: number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /** Defines the cross module used constants to avoid circular dependncies */
  601. export class Constants {
  602. /** Defines that alpha blending is disabled */
  603. static readonly ALPHA_DISABLE: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  605. static readonly ALPHA_ADD: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  607. static readonly ALPHA_COMBINE: number;
  608. /** Defines that alpha blending is DEST - SRC * DEST */
  609. static readonly ALPHA_SUBTRACT: number;
  610. /** Defines that alpha blending is SRC * DEST */
  611. static readonly ALPHA_MULTIPLY: number;
  612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  613. static readonly ALPHA_MAXIMIZED: number;
  614. /** Defines that alpha blending is SRC + DEST */
  615. static readonly ALPHA_ONEONE: number;
  616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  617. static readonly ALPHA_PREMULTIPLIED: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  624. static readonly ALPHA_INTERPOLATE: number;
  625. /**
  626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  628. */
  629. static readonly ALPHA_SCREENMODE: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST
  632. * Alpha will be set to SRC ALPHA + DST ALPHA
  633. */
  634. static readonly ALPHA_ONEONE_ONEONE: number;
  635. /**
  636. * Defines that alpha blending is SRC * DST ALPHA + DST
  637. * Alpha will be set to 0
  638. */
  639. static readonly ALPHA_ALPHATOCOLOR: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. */
  643. static readonly ALPHA_REVERSEONEMINUS: number;
  644. /**
  645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  647. */
  648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  649. /**
  650. * Defines that alpha blending is SRC + DST
  651. * Alpha will be set to SRC ALPHA
  652. */
  653. static readonly ALPHA_ONEONE_ONEZERO: number;
  654. /**
  655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  656. * Alpha will be set to DST ALPHA
  657. */
  658. static readonly ALPHA_EXCLUSION: number;
  659. /** Defines that alpha blending equation a SUM */
  660. static readonly ALPHA_EQUATION_ADD: number;
  661. /** Defines that alpha blending equation a SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  665. /** Defines that alpha blending equation a MAX operation */
  666. static readonly ALPHA_EQUATION_MAX: number;
  667. /** Defines that alpha blending equation a MIN operation */
  668. static readonly ALPHA_EQUATION_MIN: number;
  669. /**
  670. * Defines that alpha blending equation a DARKEN operation:
  671. * It takes the min of the src and sums the alpha channels.
  672. */
  673. static readonly ALPHA_EQUATION_DARKEN: number;
  674. /** Defines that the ressource is not delayed*/
  675. static readonly DELAYLOADSTATE_NONE: number;
  676. /** Defines that the ressource was successfully delay loaded */
  677. static readonly DELAYLOADSTATE_LOADED: number;
  678. /** Defines that the ressource is currently delay loading */
  679. static readonly DELAYLOADSTATE_LOADING: number;
  680. /** Defines that the ressource is delayed and has not started loading */
  681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  683. static readonly NEVER: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  685. static readonly ALWAYS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  687. static readonly LESS: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  689. static readonly EQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  691. static readonly LEQUAL: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  693. static readonly GREATER: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  695. static readonly GEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  697. static readonly NOTEQUAL: number;
  698. /** Passed to stencilOperation to specify that stencil value must be kept */
  699. static readonly KEEP: number;
  700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  701. static readonly REPLACE: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  703. static readonly INCR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  705. static readonly DECR: number;
  706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  707. static readonly INVERT: number;
  708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  709. static readonly INCR_WRAP: number;
  710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  711. static readonly DECR_WRAP: number;
  712. /** Texture is not repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  714. /** Texture is repeating outside of 0..1 UVs */
  715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  716. /** Texture is repeating and mirrored */
  717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  718. /** ALPHA */
  719. static readonly TEXTUREFORMAT_ALPHA: number;
  720. /** LUMINANCE */
  721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  722. /** LUMINANCE_ALPHA */
  723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  724. /** RGB */
  725. static readonly TEXTUREFORMAT_RGB: number;
  726. /** RGBA */
  727. static readonly TEXTUREFORMAT_RGBA: number;
  728. /** RED */
  729. static readonly TEXTUREFORMAT_RED: number;
  730. /** RED (2nd reference) */
  731. static readonly TEXTUREFORMAT_R: number;
  732. /** RG */
  733. static readonly TEXTUREFORMAT_RG: number;
  734. /** RED_INTEGER */
  735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  736. /** RED_INTEGER (2nd reference) */
  737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  738. /** RG_INTEGER */
  739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  740. /** RGB_INTEGER */
  741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  742. /** RGBA_INTEGER */
  743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  744. /** UNSIGNED_BYTE */
  745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  746. /** UNSIGNED_BYTE (2nd reference) */
  747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  748. /** FLOAT */
  749. static readonly TEXTURETYPE_FLOAT: number;
  750. /** HALF_FLOAT */
  751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  752. /** BYTE */
  753. static readonly TEXTURETYPE_BYTE: number;
  754. /** SHORT */
  755. static readonly TEXTURETYPE_SHORT: number;
  756. /** UNSIGNED_SHORT */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  758. /** INT */
  759. static readonly TEXTURETYPE_INT: number;
  760. /** UNSIGNED_INT */
  761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  762. /** UNSIGNED_SHORT_4_4_4_4 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  764. /** UNSIGNED_SHORT_5_5_5_1 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  766. /** UNSIGNED_SHORT_5_6_5 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  768. /** UNSIGNED_INT_2_10_10_10_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  770. /** UNSIGNED_INT_24_8 */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  772. /** UNSIGNED_INT_10F_11F_11F_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  774. /** UNSIGNED_INT_5_9_9_9_REV */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  778. /** nearest is mag = nearest and min = nearest and no mip */
  779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  780. /** mag = nearest and min = nearest and mip = none */
  781. static readonly TEXTURE_NEAREST_NEAREST: number;
  782. /** Bilinear is mag = linear and min = linear and no mip */
  783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  784. /** mag = linear and min = linear and mip = none */
  785. static readonly TEXTURE_LINEAR_LINEAR: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  788. /** Trilinear is mag = linear and min = linear and mip = linear */
  789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = nearest and mip = nearest */
  791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = nearest */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  794. /** mag = nearest and min = linear and mip = linear */
  795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  796. /** mag = nearest and min = linear and mip = none */
  797. static readonly TEXTURE_NEAREST_LINEAR: number;
  798. /** nearest is mag = nearest and min = nearest and mip = linear */
  799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = nearest and mip = nearest */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  802. /** mag = linear and min = nearest and mip = linear */
  803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = none */
  807. static readonly TEXTURE_LINEAR_NEAREST: number;
  808. /** Explicit coordinates mode */
  809. static readonly TEXTURE_EXPLICIT_MODE: number;
  810. /** Spherical coordinates mode */
  811. static readonly TEXTURE_SPHERICAL_MODE: number;
  812. /** Planar coordinates mode */
  813. static readonly TEXTURE_PLANAR_MODE: number;
  814. /** Cubic coordinates mode */
  815. static readonly TEXTURE_CUBIC_MODE: number;
  816. /** Projection coordinates mode */
  817. static readonly TEXTURE_PROJECTION_MODE: number;
  818. /** Skybox coordinates mode */
  819. static readonly TEXTURE_SKYBOX_MODE: number;
  820. /** Inverse Cubic coordinates mode */
  821. static readonly TEXTURE_INVCUBIC_MODE: number;
  822. /** Equirectangular coordinates mode */
  823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  826. /** Equirectangular Fixed Mirrored coordinates mode */
  827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  828. /** Offline (baking) quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  830. /** High quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  832. /** Medium quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  834. /** Low quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  837. static readonly SCALEMODE_FLOOR: number;
  838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  839. static readonly SCALEMODE_NEAREST: number;
  840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  841. static readonly SCALEMODE_CEILING: number;
  842. /**
  843. * The dirty texture flag value
  844. */
  845. static readonly MATERIAL_TextureDirtyFlag: number;
  846. /**
  847. * The dirty light flag value
  848. */
  849. static readonly MATERIAL_LightDirtyFlag: number;
  850. /**
  851. * The dirty fresnel flag value
  852. */
  853. static readonly MATERIAL_FresnelDirtyFlag: number;
  854. /**
  855. * The dirty attribute flag value
  856. */
  857. static readonly MATERIAL_AttributesDirtyFlag: number;
  858. /**
  859. * The dirty misc flag value
  860. */
  861. static readonly MATERIAL_MiscDirtyFlag: number;
  862. /**
  863. * The dirty prepass flag value
  864. */
  865. static readonly MATERIAL_PrePassDirtyFlag: number;
  866. /**
  867. * The all dirty flag value
  868. */
  869. static readonly MATERIAL_AllDirtyFlag: number;
  870. /**
  871. * Returns the triangle fill mode
  872. */
  873. static readonly MATERIAL_TriangleFillMode: number;
  874. /**
  875. * Returns the wireframe mode
  876. */
  877. static readonly MATERIAL_WireFrameFillMode: number;
  878. /**
  879. * Returns the point fill mode
  880. */
  881. static readonly MATERIAL_PointFillMode: number;
  882. /**
  883. * Returns the point list draw mode
  884. */
  885. static readonly MATERIAL_PointListDrawMode: number;
  886. /**
  887. * Returns the line list draw mode
  888. */
  889. static readonly MATERIAL_LineListDrawMode: number;
  890. /**
  891. * Returns the line loop draw mode
  892. */
  893. static readonly MATERIAL_LineLoopDrawMode: number;
  894. /**
  895. * Returns the line strip draw mode
  896. */
  897. static readonly MATERIAL_LineStripDrawMode: number;
  898. /**
  899. * Returns the triangle strip draw mode
  900. */
  901. static readonly MATERIAL_TriangleStripDrawMode: number;
  902. /**
  903. * Returns the triangle fan draw mode
  904. */
  905. static readonly MATERIAL_TriangleFanDrawMode: number;
  906. /**
  907. * Stores the clock-wise side orientation
  908. */
  909. static readonly MATERIAL_ClockWiseSideOrientation: number;
  910. /**
  911. * Stores the counter clock-wise side orientation
  912. */
  913. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  914. /**
  915. * Nothing
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_NothingTrigger: number;
  919. /**
  920. * On pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickTrigger: number;
  924. /**
  925. * On left pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnLeftPickTrigger: number;
  929. /**
  930. * On right pick
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnRightPickTrigger: number;
  934. /**
  935. * On center pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnCenterPickTrigger: number;
  939. /**
  940. * On pick down
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickDownTrigger: number;
  944. /**
  945. * On double pick
  946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnDoublePickTrigger: number;
  949. /**
  950. * On pick up
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickUpTrigger: number;
  954. /**
  955. * On pick out.
  956. * This trigger will only be raised if you also declared a OnPickDown
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPickOutTrigger: number;
  960. /**
  961. * On long press
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnLongPressTrigger: number;
  965. /**
  966. * On pointer over
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnPointerOverTrigger: number;
  970. /**
  971. * On pointer out
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnPointerOutTrigger: number;
  975. /**
  976. * On every frame
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnEveryFrameTrigger: number;
  980. /**
  981. * On intersection enter
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnIntersectionEnterTrigger: number;
  985. /**
  986. * On intersection exit
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnIntersectionExitTrigger: number;
  990. /**
  991. * On key down
  992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  993. */
  994. static readonly ACTION_OnKeyDownTrigger: number;
  995. /**
  996. * On key up
  997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  998. */
  999. static readonly ACTION_OnKeyUpTrigger: number;
  1000. /**
  1001. * Billboard mode will only apply to Y axis
  1002. */
  1003. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1004. /**
  1005. * Billboard mode will apply to all axes
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1008. /**
  1009. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1012. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1013. * Test order :
  1014. * Is the bounding sphere outside the frustum ?
  1015. * If not, are the bounding box vertices outside the frustum ?
  1016. * It not, then the cullable object is in the frustum.
  1017. */
  1018. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1019. /** Culling strategy : Bounding Sphere Only.
  1020. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1021. * It's also less accurate than the standard because some not visible objects can still be selected.
  1022. * Test : is the bounding sphere outside the frustum ?
  1023. * If not, then the cullable object is in the frustum.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1026. /** Culling strategy : Optimistic Inclusion.
  1027. * This in an inclusion test first, then the standard exclusion test.
  1028. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1030. * Anyway, it's as accurate as the standard strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the default culling strategy.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1036. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1037. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1038. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1039. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1040. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1041. * Test :
  1042. * Is the cullable object bounding sphere center in the frustum ?
  1043. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1044. */
  1045. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1046. /**
  1047. * No logging while loading
  1048. */
  1049. static readonly SCENELOADER_NO_LOGGING: number;
  1050. /**
  1051. * Minimal logging while loading
  1052. */
  1053. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1054. /**
  1055. * Summary logging while loading
  1056. */
  1057. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1058. /**
  1059. * Detailled logging while loading
  1060. */
  1061. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1062. /**
  1063. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1065. */
  1066. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the position texture index in the textures array in the prepass
  1069. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1070. */
  1071. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1074. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1075. */
  1076. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1087. /**
  1088. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1089. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1090. */
  1091. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1092. /**
  1093. * Constant used to retrieve albedo index in the textures array in the prepass
  1094. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1095. */
  1096. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. * @param options options to be passed to the loader
  1123. */
  1124. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1125. /**
  1126. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1127. * @param data contains the texture data
  1128. * @param texture defines the BabylonJS internal texture
  1129. * @param callback defines the method to call once ready to upload
  1130. * @param options options to be passed to the loader
  1131. */
  1132. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1133. }
  1134. }
  1135. declare module BABYLON {
  1136. /**
  1137. * Class used to store and describe the pipeline context associated with an effect
  1138. */
  1139. export interface IPipelineContext {
  1140. /**
  1141. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1142. */
  1143. isAsync: boolean;
  1144. /**
  1145. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1146. */
  1147. isReady: boolean;
  1148. /** @hidden */
  1149. _getVertexShaderCode(): string | null;
  1150. /** @hidden */
  1151. _getFragmentShaderCode(): string | null;
  1152. /** @hidden */
  1153. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1154. }
  1155. }
  1156. declare module BABYLON {
  1157. /**
  1158. * Class used to store gfx data (like WebGLBuffer)
  1159. */
  1160. export class DataBuffer {
  1161. /**
  1162. * Gets or sets the number of objects referencing this buffer
  1163. */
  1164. references: number;
  1165. /** Gets or sets the size of the underlying buffer */
  1166. capacity: number;
  1167. /**
  1168. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1169. */
  1170. is32Bits: boolean;
  1171. /**
  1172. * Gets the underlying buffer
  1173. */
  1174. get underlyingResource(): any;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export interface IShaderProcessor {
  1180. attributeProcessor?: (attribute: string) => string;
  1181. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1182. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1183. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1184. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1185. lineProcessor?: (line: string, isFragment: boolean) => string;
  1186. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1187. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export interface ProcessingOptions {
  1193. defines: string[];
  1194. indexParameters: any;
  1195. isFragment: boolean;
  1196. shouldUseHighPrecisionShader: boolean;
  1197. supportsUniformBuffers: boolean;
  1198. shadersRepository: string;
  1199. includesShadersStore: {
  1200. [key: string]: string;
  1201. };
  1202. processor?: IShaderProcessor;
  1203. version: string;
  1204. platformName: string;
  1205. lookForClosingBracketForUniformBuffer?: boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module BABYLON {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1236. process(preprocessors: {
  1237. [key: string]: string;
  1238. }, options: ProcessingOptions): string;
  1239. }
  1240. }
  1241. declare module BABYLON {
  1242. /** @hidden */
  1243. export class ShaderDefineExpression {
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. private static _OperatorPriority;
  1248. private static _Stack;
  1249. static postfixToInfix(postfix: string[]): string;
  1250. static infixToPostfix(infix: string): string[];
  1251. }
  1252. }
  1253. declare module BABYLON {
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. not: boolean;
  1267. constructor(define: string, not?: boolean);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module BABYLON {
  1274. /** @hidden */
  1275. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1276. leftOperand: ShaderDefineExpression;
  1277. rightOperand: ShaderDefineExpression;
  1278. isTrue(preprocessors: {
  1279. [key: string]: string;
  1280. }): boolean;
  1281. }
  1282. }
  1283. declare module BABYLON {
  1284. /** @hidden */
  1285. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1286. leftOperand: ShaderDefineExpression;
  1287. rightOperand: ShaderDefineExpression;
  1288. isTrue(preprocessors: {
  1289. [key: string]: string;
  1290. }): boolean;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /** @hidden */
  1295. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1296. define: string;
  1297. operand: string;
  1298. testValue: string;
  1299. constructor(define: string, operand: string, testValue: string);
  1300. isTrue(preprocessors: {
  1301. [key: string]: string;
  1302. }): boolean;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * Class used to enable access to offline support
  1308. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1309. */
  1310. export interface IOfflineProvider {
  1311. /**
  1312. * Gets a boolean indicating if scene must be saved in the database
  1313. */
  1314. enableSceneOffline: boolean;
  1315. /**
  1316. * Gets a boolean indicating if textures must be saved in the database
  1317. */
  1318. enableTexturesOffline: boolean;
  1319. /**
  1320. * Open the offline support and make it available
  1321. * @param successCallback defines the callback to call on success
  1322. * @param errorCallback defines the callback to call on error
  1323. */
  1324. open(successCallback: () => void, errorCallback: () => void): void;
  1325. /**
  1326. * Loads an image from the offline support
  1327. * @param url defines the url to load from
  1328. * @param image defines the target DOM image
  1329. */
  1330. loadImage(url: string, image: HTMLImageElement): void;
  1331. /**
  1332. * Loads a file from offline support
  1333. * @param url defines the URL to load from
  1334. * @param sceneLoaded defines a callback to call on success
  1335. * @param progressCallBack defines a callback to call when progress changed
  1336. * @param errorCallback defines a callback to call on error
  1337. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1338. */
  1339. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1340. }
  1341. }
  1342. declare module BABYLON {
  1343. /**
  1344. * Class used to help managing file picking and drag'n'drop
  1345. * File Storage
  1346. */
  1347. export class FilesInputStore {
  1348. /**
  1349. * List of files ready to be loaded
  1350. */
  1351. static FilesToLoad: {
  1352. [key: string]: File;
  1353. };
  1354. }
  1355. }
  1356. declare module BABYLON {
  1357. /**
  1358. * Class used to define a retry strategy when error happens while loading assets
  1359. */
  1360. export class RetryStrategy {
  1361. /**
  1362. * Function used to defines an exponential back off strategy
  1363. * @param maxRetries defines the maximum number of retries (3 by default)
  1364. * @param baseInterval defines the interval between retries
  1365. * @returns the strategy function to use
  1366. */
  1367. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1368. }
  1369. }
  1370. declare module BABYLON {
  1371. /**
  1372. * @ignore
  1373. * Application error to support additional information when loading a file
  1374. */
  1375. export abstract class BaseError extends Error {
  1376. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1377. }
  1378. }
  1379. declare module BABYLON {
  1380. /** @ignore */
  1381. export class LoadFileError extends BaseError {
  1382. request?: WebRequest;
  1383. file?: File;
  1384. /**
  1385. * Creates a new LoadFileError
  1386. * @param message defines the message of the error
  1387. * @param request defines the optional web request
  1388. * @param file defines the optional file
  1389. */
  1390. constructor(message: string, object?: WebRequest | File);
  1391. }
  1392. /** @ignore */
  1393. export class RequestFileError extends BaseError {
  1394. request: WebRequest;
  1395. /**
  1396. * Creates a new LoadFileError
  1397. * @param message defines the message of the error
  1398. * @param request defines the optional web request
  1399. */
  1400. constructor(message: string, request: WebRequest);
  1401. }
  1402. /** @ignore */
  1403. export class ReadFileError extends BaseError {
  1404. file: File;
  1405. /**
  1406. * Creates a new ReadFileError
  1407. * @param message defines the message of the error
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, file: File);
  1411. }
  1412. /**
  1413. * @hidden
  1414. */
  1415. export class FileTools {
  1416. /**
  1417. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1418. */
  1419. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1420. /**
  1421. * Gets or sets the base URL to use to load assets
  1422. */
  1423. static BaseUrl: string;
  1424. /**
  1425. * Default behaviour for cors in the application.
  1426. * It can be a string if the expected behavior is identical in the entire app.
  1427. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1428. */
  1429. static CorsBehavior: string | ((url: string | string[]) => string);
  1430. /**
  1431. * Gets or sets a function used to pre-process url before using them to load assets
  1432. */
  1433. static PreprocessUrl: (url: string) => string;
  1434. /**
  1435. * Removes unwanted characters from an url
  1436. * @param url defines the url to clean
  1437. * @returns the cleaned url
  1438. */
  1439. private static _CleanUrl;
  1440. /**
  1441. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1442. * @param url define the url we are trying
  1443. * @param element define the dom element where to configure the cors policy
  1444. */
  1445. static SetCorsBehavior(url: string | string[], element: {
  1446. crossOrigin: string | null;
  1447. }): void;
  1448. /**
  1449. * Loads an image as an HTMLImageElement.
  1450. * @param input url string, ArrayBuffer, or Blob to load
  1451. * @param onLoad callback called when the image successfully loads
  1452. * @param onError callback called when the image fails to load
  1453. * @param offlineProvider offline provider for caching
  1454. * @param mimeType optional mime type
  1455. * @returns the HTMLImageElement of the loaded image
  1456. */
  1457. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1458. /**
  1459. * Reads a file from a File object
  1460. * @param file defines the file to load
  1461. * @param onSuccess defines the callback to call when data is loaded
  1462. * @param onProgress defines the callback to call during loading process
  1463. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1464. * @param onError defines the callback to call when an error occurs
  1465. * @returns a file request object
  1466. */
  1467. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1468. /**
  1469. * Loads a file from a url
  1470. * @param url url to load
  1471. * @param onSuccess callback called when the file successfully loads
  1472. * @param onProgress callback called while file is loading (if the server supports this mode)
  1473. * @param offlineProvider defines the offline provider for caching
  1474. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1475. * @param onError callback called when the file fails to load
  1476. * @returns a file request object
  1477. */
  1478. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1479. /**
  1480. * Loads a file
  1481. * @param url url to load
  1482. * @param onSuccess callback called when the file successfully loads
  1483. * @param onProgress callback called while file is loading (if the server supports this mode)
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @param onOpened callback called when the web request is opened
  1487. * @returns a file request object
  1488. */
  1489. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1490. /**
  1491. * Checks if the loaded document was accessed via `file:`-Protocol.
  1492. * @returns boolean
  1493. */
  1494. static IsFileURL(): boolean;
  1495. }
  1496. }
  1497. declare module BABYLON {
  1498. /** @hidden */
  1499. export class ShaderProcessor {
  1500. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1501. private static _ProcessPrecision;
  1502. private static _ExtractOperation;
  1503. private static _BuildSubExpression;
  1504. private static _BuildExpression;
  1505. private static _MoveCursorWithinIf;
  1506. private static _MoveCursor;
  1507. private static _EvaluatePreProcessors;
  1508. private static _PreparePreProcessors;
  1509. private static _ProcessShaderConversion;
  1510. private static _ProcessIncludes;
  1511. /**
  1512. * Loads a file from a url
  1513. * @param url url to load
  1514. * @param onSuccess callback called when the file successfully loads
  1515. * @param onProgress callback called while file is loading (if the server supports this mode)
  1516. * @param offlineProvider defines the offline provider for caching
  1517. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1518. * @param onError callback called when the file fails to load
  1519. * @returns a file request object
  1520. * @hidden
  1521. */
  1522. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1523. }
  1524. }
  1525. declare module BABYLON {
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IColor4Like {
  1530. r: float;
  1531. g: float;
  1532. b: float;
  1533. a: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IColor3Like {
  1539. r: float;
  1540. g: float;
  1541. b: float;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IVector4Like {
  1547. x: float;
  1548. y: float;
  1549. z: float;
  1550. w: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IVector3Like {
  1556. x: float;
  1557. y: float;
  1558. z: float;
  1559. }
  1560. /**
  1561. * @hidden
  1562. */
  1563. export interface IVector2Like {
  1564. x: float;
  1565. y: float;
  1566. }
  1567. /**
  1568. * @hidden
  1569. */
  1570. export interface IMatrixLike {
  1571. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1572. updateFlag: int;
  1573. }
  1574. /**
  1575. * @hidden
  1576. */
  1577. export interface IViewportLike {
  1578. x: float;
  1579. y: float;
  1580. width: float;
  1581. height: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IPlaneLike {
  1587. normal: IVector3Like;
  1588. d: float;
  1589. normalize(): void;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /**
  1594. * Interface used to define common properties for effect fallbacks
  1595. */
  1596. export interface IEffectFallbacks {
  1597. /**
  1598. * Removes the defines that should be removed when falling back.
  1599. * @param currentDefines defines the current define statements for the shader.
  1600. * @param effect defines the current effect we try to compile
  1601. * @returns The resulting defines with defines of the current rank removed.
  1602. */
  1603. reduce(currentDefines: string, effect: Effect): string;
  1604. /**
  1605. * Removes the fallback from the bound mesh.
  1606. */
  1607. unBindMesh(): void;
  1608. /**
  1609. * Checks to see if more fallbacks are still availible.
  1610. */
  1611. hasMoreFallbacks: boolean;
  1612. }
  1613. }
  1614. declare module BABYLON {
  1615. /**
  1616. * Interface for the size containing width and height
  1617. */
  1618. export interface ISize {
  1619. /**
  1620. * Width
  1621. */
  1622. width: number;
  1623. /**
  1624. * Heighht
  1625. */
  1626. height: number;
  1627. }
  1628. /**
  1629. * Size containing widht and height
  1630. */
  1631. export class Size implements ISize {
  1632. /**
  1633. * Width
  1634. */
  1635. width: number;
  1636. /**
  1637. * Height
  1638. */
  1639. height: number;
  1640. /**
  1641. * Creates a Size object from the given width and height (floats).
  1642. * @param width width of the new size
  1643. * @param height height of the new size
  1644. */
  1645. constructor(width: number, height: number);
  1646. /**
  1647. * Returns a string with the Size width and height
  1648. * @returns a string with the Size width and height
  1649. */
  1650. toString(): string;
  1651. /**
  1652. * "Size"
  1653. * @returns the string "Size"
  1654. */
  1655. getClassName(): string;
  1656. /**
  1657. * Returns the Size hash code.
  1658. * @returns a hash code for a unique width and height
  1659. */
  1660. getHashCode(): number;
  1661. /**
  1662. * Updates the current size from the given one.
  1663. * @param src the given size
  1664. */
  1665. copyFrom(src: Size): void;
  1666. /**
  1667. * Updates in place the current Size from the given floats.
  1668. * @param width width of the new size
  1669. * @param height height of the new size
  1670. * @returns the updated Size.
  1671. */
  1672. copyFromFloats(width: number, height: number): Size;
  1673. /**
  1674. * Updates in place the current Size from the given floats.
  1675. * @param width width to set
  1676. * @param height height to set
  1677. * @returns the updated Size.
  1678. */
  1679. set(width: number, height: number): Size;
  1680. /**
  1681. * Multiplies the width and height by numbers
  1682. * @param w factor to multiple the width by
  1683. * @param h factor to multiple the height by
  1684. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1685. */
  1686. multiplyByFloats(w: number, h: number): Size;
  1687. /**
  1688. * Clones the size
  1689. * @returns a new Size copied from the given one.
  1690. */
  1691. clone(): Size;
  1692. /**
  1693. * True if the current Size and the given one width and height are strictly equal.
  1694. * @param other the other size to compare against
  1695. * @returns True if the current Size and the given one width and height are strictly equal.
  1696. */
  1697. equals(other: Size): boolean;
  1698. /**
  1699. * The surface of the Size : width * height (float).
  1700. */
  1701. get surface(): number;
  1702. /**
  1703. * Create a new size of zero
  1704. * @returns a new Size set to (0.0, 0.0)
  1705. */
  1706. static Zero(): Size;
  1707. /**
  1708. * Sums the width and height of two sizes
  1709. * @param otherSize size to add to this size
  1710. * @returns a new Size set as the addition result of the current Size and the given one.
  1711. */
  1712. add(otherSize: Size): Size;
  1713. /**
  1714. * Subtracts the width and height of two
  1715. * @param otherSize size to subtract to this size
  1716. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1717. */
  1718. subtract(otherSize: Size): Size;
  1719. /**
  1720. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1721. * @param start starting size to lerp between
  1722. * @param end end size to lerp between
  1723. * @param amount amount to lerp between the start and end values
  1724. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1725. */
  1726. static Lerp(start: Size, end: Size, amount: number): Size;
  1727. }
  1728. }
  1729. declare module BABYLON {
  1730. /**
  1731. * Base class of all the textures in babylon.
  1732. * It groups all the common properties required to work with Thin Engine.
  1733. */
  1734. export class ThinTexture {
  1735. protected _wrapU: number;
  1736. /**
  1737. * | Value | Type | Description |
  1738. * | ----- | ------------------ | ----------- |
  1739. * | 0 | CLAMP_ADDRESSMODE | |
  1740. * | 1 | WRAP_ADDRESSMODE | |
  1741. * | 2 | MIRROR_ADDRESSMODE | |
  1742. */
  1743. get wrapU(): number;
  1744. set wrapU(value: number);
  1745. protected _wrapV: number;
  1746. /**
  1747. * | Value | Type | Description |
  1748. * | ----- | ------------------ | ----------- |
  1749. * | 0 | CLAMP_ADDRESSMODE | |
  1750. * | 1 | WRAP_ADDRESSMODE | |
  1751. * | 2 | MIRROR_ADDRESSMODE | |
  1752. */
  1753. get wrapV(): number;
  1754. set wrapV(value: number);
  1755. /**
  1756. * | Value | Type | Description |
  1757. * | ----- | ------------------ | ----------- |
  1758. * | 0 | CLAMP_ADDRESSMODE | |
  1759. * | 1 | WRAP_ADDRESSMODE | |
  1760. * | 2 | MIRROR_ADDRESSMODE | |
  1761. */
  1762. wrapR: number;
  1763. /**
  1764. * With compliant hardware and browser (supporting anisotropic filtering)
  1765. * this defines the level of anisotropic filtering in the texture.
  1766. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  1767. */
  1768. anisotropicFilteringLevel: number;
  1769. /**
  1770. * Define the current state of the loading sequence when in delayed load mode.
  1771. */
  1772. delayLoadState: number;
  1773. /**
  1774. * How a texture is mapped.
  1775. * Unused in thin texture mode.
  1776. */
  1777. get coordinatesMode(): number;
  1778. /**
  1779. * Define if the texture is a cube texture or if false a 2d texture.
  1780. */
  1781. get isCube(): boolean;
  1782. set isCube(value: boolean);
  1783. /**
  1784. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  1785. */
  1786. get is3D(): boolean;
  1787. set is3D(value: boolean);
  1788. /**
  1789. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  1790. */
  1791. get is2DArray(): boolean;
  1792. set is2DArray(value: boolean);
  1793. /**
  1794. * Get the class name of the texture.
  1795. * @returns "ThinTexture"
  1796. */
  1797. getClassName(): string;
  1798. /** @hidden */
  1799. _texture: Nullable<InternalTexture>;
  1800. protected _engine: Nullable<ThinEngine>;
  1801. private _cachedSize;
  1802. private _cachedBaseSize;
  1803. /**
  1804. * Instantiates a new ThinTexture.
  1805. * Base class of all the textures in babylon.
  1806. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  1807. * @param internalTexture Define the internalTexture to wrap
  1808. */
  1809. constructor(internalTexture: Nullable<InternalTexture>);
  1810. /**
  1811. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  1812. * @returns true if fully ready
  1813. */
  1814. isReady(): boolean;
  1815. /**
  1816. * Triggers the load sequence in delayed load mode.
  1817. */
  1818. delayLoad(): void;
  1819. /**
  1820. * Get the underlying lower level texture from Babylon.
  1821. * @returns the insternal texture
  1822. */
  1823. getInternalTexture(): Nullable<InternalTexture>;
  1824. /**
  1825. * Get the size of the texture.
  1826. * @returns the texture size.
  1827. */
  1828. getSize(): ISize;
  1829. /**
  1830. * Get the base size of the texture.
  1831. * It can be different from the size if the texture has been resized for POT for instance
  1832. * @returns the base size
  1833. */
  1834. getBaseSize(): ISize;
  1835. /**
  1836. * Update the sampling mode of the texture.
  1837. * Default is Trilinear mode.
  1838. *
  1839. * | Value | Type | Description |
  1840. * | ----- | ------------------ | ----------- |
  1841. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  1842. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  1843. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  1844. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  1845. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  1846. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  1847. * | 7 | NEAREST_LINEAR | |
  1848. * | 8 | NEAREST_NEAREST | |
  1849. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  1850. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  1851. * | 11 | LINEAR_LINEAR | |
  1852. * | 12 | LINEAR_NEAREST | |
  1853. *
  1854. * > _mag_: magnification filter (close to the viewer)
  1855. * > _min_: minification filter (far from the viewer)
  1856. * > _mip_: filter used between mip map levels
  1857. *@param samplingMode Define the new sampling mode of the texture
  1858. */
  1859. updateSamplingMode(samplingMode: number): void;
  1860. /**
  1861. * Release and destroy the underlying lower level texture aka internalTexture.
  1862. */
  1863. releaseInternalTexture(): void;
  1864. /**
  1865. * Dispose the texture and release its associated resources.
  1866. */
  1867. dispose(): void;
  1868. }
  1869. }
  1870. declare module BABYLON {
  1871. /**
  1872. * Defines an array and its length.
  1873. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  1874. */
  1875. export interface ISmartArrayLike<T> {
  1876. /**
  1877. * The data of the array.
  1878. */
  1879. data: Array<T>;
  1880. /**
  1881. * The active length of the array.
  1882. */
  1883. length: number;
  1884. }
  1885. /**
  1886. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1887. */
  1888. export class SmartArray<T> implements ISmartArrayLike<T> {
  1889. /**
  1890. * The full set of data from the array.
  1891. */
  1892. data: Array<T>;
  1893. /**
  1894. * The active length of the array.
  1895. */
  1896. length: number;
  1897. protected _id: number;
  1898. /**
  1899. * Instantiates a Smart Array.
  1900. * @param capacity defines the default capacity of the array.
  1901. */
  1902. constructor(capacity: number);
  1903. /**
  1904. * Pushes a value at the end of the active data.
  1905. * @param value defines the object to push in the array.
  1906. */
  1907. push(value: T): void;
  1908. /**
  1909. * Iterates over the active data and apply the lambda to them.
  1910. * @param func defines the action to apply on each value.
  1911. */
  1912. forEach(func: (content: T) => void): void;
  1913. /**
  1914. * Sorts the full sets of data.
  1915. * @param compareFn defines the comparison function to apply.
  1916. */
  1917. sort(compareFn: (a: T, b: T) => number): void;
  1918. /**
  1919. * Resets the active data to an empty array.
  1920. */
  1921. reset(): void;
  1922. /**
  1923. * Releases all the data from the array as well as the array.
  1924. */
  1925. dispose(): void;
  1926. /**
  1927. * Concats the active data with a given array.
  1928. * @param array defines the data to concatenate with.
  1929. */
  1930. concat(array: any): void;
  1931. /**
  1932. * Returns the position of a value in the active data.
  1933. * @param value defines the value to find the index for
  1934. * @returns the index if found in the active data otherwise -1
  1935. */
  1936. indexOf(value: T): number;
  1937. /**
  1938. * Returns whether an element is part of the active data.
  1939. * @param value defines the value to look for
  1940. * @returns true if found in the active data otherwise false
  1941. */
  1942. contains(value: T): boolean;
  1943. private static _GlobalId;
  1944. }
  1945. /**
  1946. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1947. * The data in this array can only be present once
  1948. */
  1949. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  1950. private _duplicateId;
  1951. /**
  1952. * Pushes a value at the end of the active data.
  1953. * THIS DOES NOT PREVENT DUPPLICATE DATA
  1954. * @param value defines the object to push in the array.
  1955. */
  1956. push(value: T): void;
  1957. /**
  1958. * Pushes a value at the end of the active data.
  1959. * If the data is already present, it won t be added again
  1960. * @param value defines the object to push in the array.
  1961. * @returns true if added false if it was already present
  1962. */
  1963. pushNoDuplicate(value: T): boolean;
  1964. /**
  1965. * Resets the active data to an empty array.
  1966. */
  1967. reset(): void;
  1968. /**
  1969. * Concats the active data with a given array.
  1970. * This ensures no dupplicate will be present in the result.
  1971. * @param array defines the data to concatenate with.
  1972. */
  1973. concatWithNoDuplicate(array: any): void;
  1974. }
  1975. }
  1976. declare module BABYLON {
  1977. /**
  1978. * Class used to evalaute queries containing `and` and `or` operators
  1979. */
  1980. export class AndOrNotEvaluator {
  1981. /**
  1982. * Evaluate a query
  1983. * @param query defines the query to evaluate
  1984. * @param evaluateCallback defines the callback used to filter result
  1985. * @returns true if the query matches
  1986. */
  1987. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1988. private static _HandleParenthesisContent;
  1989. private static _SimplifyNegation;
  1990. }
  1991. }
  1992. declare module BABYLON {
  1993. /**
  1994. * Class used to store custom tags
  1995. */
  1996. export class Tags {
  1997. /**
  1998. * Adds support for tags on the given object
  1999. * @param obj defines the object to use
  2000. */
  2001. static EnableFor(obj: any): void;
  2002. /**
  2003. * Removes tags support
  2004. * @param obj defines the object to use
  2005. */
  2006. static DisableFor(obj: any): void;
  2007. /**
  2008. * Gets a boolean indicating if the given object has tags
  2009. * @param obj defines the object to use
  2010. * @returns a boolean
  2011. */
  2012. static HasTags(obj: any): boolean;
  2013. /**
  2014. * Gets the tags available on a given object
  2015. * @param obj defines the object to use
  2016. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2017. * @returns the tags
  2018. */
  2019. static GetTags(obj: any, asString?: boolean): any;
  2020. /**
  2021. * Adds tags to an object
  2022. * @param obj defines the object to use
  2023. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2024. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2025. */
  2026. static AddTagsTo(obj: any, tagsString: string): void;
  2027. /**
  2028. * @hidden
  2029. */
  2030. static _AddTagTo(obj: any, tag: string): void;
  2031. /**
  2032. * Removes specific tags from a specific object
  2033. * @param obj defines the object to use
  2034. * @param tagsString defines the tags to remove
  2035. */
  2036. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2037. /**
  2038. * @hidden
  2039. */
  2040. static _RemoveTagFrom(obj: any, tag: string): void;
  2041. /**
  2042. * Defines if tags hosted on an object match a given query
  2043. * @param obj defines the object to use
  2044. * @param tagsQuery defines the tag query
  2045. * @returns a boolean
  2046. */
  2047. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2048. }
  2049. }
  2050. declare module BABYLON {
  2051. /**
  2052. * Scalar computation library
  2053. */
  2054. export class Scalar {
  2055. /**
  2056. * Two pi constants convenient for computation.
  2057. */
  2058. static TwoPi: number;
  2059. /**
  2060. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2061. * @param a number
  2062. * @param b number
  2063. * @param epsilon (default = 1.401298E-45)
  2064. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2065. */
  2066. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2067. /**
  2068. * Returns a string : the upper case translation of the number i to hexadecimal.
  2069. * @param i number
  2070. * @returns the upper case translation of the number i to hexadecimal.
  2071. */
  2072. static ToHex(i: number): string;
  2073. /**
  2074. * Returns -1 if value is negative and +1 is value is positive.
  2075. * @param value the value
  2076. * @returns the value itself if it's equal to zero.
  2077. */
  2078. static Sign(value: number): number;
  2079. /**
  2080. * Returns the value itself if it's between min and max.
  2081. * Returns min if the value is lower than min.
  2082. * Returns max if the value is greater than max.
  2083. * @param value the value to clmap
  2084. * @param min the min value to clamp to (default: 0)
  2085. * @param max the max value to clamp to (default: 1)
  2086. * @returns the clamped value
  2087. */
  2088. static Clamp(value: number, min?: number, max?: number): number;
  2089. /**
  2090. * the log2 of value.
  2091. * @param value the value to compute log2 of
  2092. * @returns the log2 of value.
  2093. */
  2094. static Log2(value: number): number;
  2095. /**
  2096. * Loops the value, so that it is never larger than length and never smaller than 0.
  2097. *
  2098. * This is similar to the modulo operator but it works with floating point numbers.
  2099. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2100. * With t = 5 and length = 2.5, the result would be 0.0.
  2101. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2102. * @param value the value
  2103. * @param length the length
  2104. * @returns the looped value
  2105. */
  2106. static Repeat(value: number, length: number): number;
  2107. /**
  2108. * Normalize the value between 0.0 and 1.0 using min and max values
  2109. * @param value value to normalize
  2110. * @param min max to normalize between
  2111. * @param max min to normalize between
  2112. * @returns the normalized value
  2113. */
  2114. static Normalize(value: number, min: number, max: number): number;
  2115. /**
  2116. * Denormalize the value from 0.0 and 1.0 using min and max values
  2117. * @param normalized value to denormalize
  2118. * @param min max to denormalize between
  2119. * @param max min to denormalize between
  2120. * @returns the denormalized value
  2121. */
  2122. static Denormalize(normalized: number, min: number, max: number): number;
  2123. /**
  2124. * Calculates the shortest difference between two given angles given in degrees.
  2125. * @param current current angle in degrees
  2126. * @param target target angle in degrees
  2127. * @returns the delta
  2128. */
  2129. static DeltaAngle(current: number, target: number): number;
  2130. /**
  2131. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2132. * @param tx value
  2133. * @param length length
  2134. * @returns The returned value will move back and forth between 0 and length
  2135. */
  2136. static PingPong(tx: number, length: number): number;
  2137. /**
  2138. * Interpolates between min and max with smoothing at the limits.
  2139. *
  2140. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2141. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2142. * @param from from
  2143. * @param to to
  2144. * @param tx value
  2145. * @returns the smooth stepped value
  2146. */
  2147. static SmoothStep(from: number, to: number, tx: number): number;
  2148. /**
  2149. * Moves a value current towards target.
  2150. *
  2151. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2152. * Negative values of maxDelta pushes the value away from target.
  2153. * @param current current value
  2154. * @param target target value
  2155. * @param maxDelta max distance to move
  2156. * @returns resulting value
  2157. */
  2158. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2159. /**
  2160. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2161. *
  2162. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2163. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2164. * @param current current value
  2165. * @param target target value
  2166. * @param maxDelta max distance to move
  2167. * @returns resulting angle
  2168. */
  2169. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2170. /**
  2171. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2172. * @param start start value
  2173. * @param end target value
  2174. * @param amount amount to lerp between
  2175. * @returns the lerped value
  2176. */
  2177. static Lerp(start: number, end: number, amount: number): number;
  2178. /**
  2179. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2180. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2181. * @param start start value
  2182. * @param end target value
  2183. * @param amount amount to lerp between
  2184. * @returns the lerped value
  2185. */
  2186. static LerpAngle(start: number, end: number, amount: number): number;
  2187. /**
  2188. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2189. * @param a start value
  2190. * @param b target value
  2191. * @param value value between a and b
  2192. * @returns the inverseLerp value
  2193. */
  2194. static InverseLerp(a: number, b: number, value: number): number;
  2195. /**
  2196. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2197. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2198. * @param value1 spline value
  2199. * @param tangent1 spline value
  2200. * @param value2 spline value
  2201. * @param tangent2 spline value
  2202. * @param amount input value
  2203. * @returns hermite result
  2204. */
  2205. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2206. /**
  2207. * Returns a random float number between and min and max values
  2208. * @param min min value of random
  2209. * @param max max value of random
  2210. * @returns random value
  2211. */
  2212. static RandomRange(min: number, max: number): number;
  2213. /**
  2214. * This function returns percentage of a number in a given range.
  2215. *
  2216. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2217. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2218. * @param number to convert to percentage
  2219. * @param min min range
  2220. * @param max max range
  2221. * @returns the percentage
  2222. */
  2223. static RangeToPercent(number: number, min: number, max: number): number;
  2224. /**
  2225. * This function returns number that corresponds to the percentage in a given range.
  2226. *
  2227. * PercentToRange(0.34,0,100) will return 34.
  2228. * @param percent to convert to number
  2229. * @param min min range
  2230. * @param max max range
  2231. * @returns the number
  2232. */
  2233. static PercentToRange(percent: number, min: number, max: number): number;
  2234. /**
  2235. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2236. * @param angle The angle to normalize in radian.
  2237. * @return The converted angle.
  2238. */
  2239. static NormalizeRadians(angle: number): number;
  2240. }
  2241. }
  2242. declare module BABYLON {
  2243. /**
  2244. * Constant used to convert a value to gamma space
  2245. * @ignorenaming
  2246. */
  2247. export const ToGammaSpace: number;
  2248. /**
  2249. * Constant used to convert a value to linear space
  2250. * @ignorenaming
  2251. */
  2252. export const ToLinearSpace = 2.2;
  2253. /**
  2254. * Constant used to define the minimal number value in Babylon.js
  2255. * @ignorenaming
  2256. */
  2257. let Epsilon: number;
  2258. }
  2259. declare module BABYLON {
  2260. /**
  2261. * Class used to represent a viewport on screen
  2262. */
  2263. export class Viewport {
  2264. /** viewport left coordinate */
  2265. x: number;
  2266. /** viewport top coordinate */
  2267. y: number;
  2268. /**viewport width */
  2269. width: number;
  2270. /** viewport height */
  2271. height: number;
  2272. /**
  2273. * Creates a Viewport object located at (x, y) and sized (width, height)
  2274. * @param x defines viewport left coordinate
  2275. * @param y defines viewport top coordinate
  2276. * @param width defines the viewport width
  2277. * @param height defines the viewport height
  2278. */
  2279. constructor(
  2280. /** viewport left coordinate */
  2281. x: number,
  2282. /** viewport top coordinate */
  2283. y: number,
  2284. /**viewport width */
  2285. width: number,
  2286. /** viewport height */
  2287. height: number);
  2288. /**
  2289. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2290. * @param renderWidth defines the rendering width
  2291. * @param renderHeight defines the rendering height
  2292. * @returns a new Viewport
  2293. */
  2294. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2295. /**
  2296. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2297. * @param renderWidth defines the rendering width
  2298. * @param renderHeight defines the rendering height
  2299. * @param ref defines the target viewport
  2300. * @returns the current viewport
  2301. */
  2302. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2303. /**
  2304. * Returns a new Viewport copied from the current one
  2305. * @returns a new Viewport
  2306. */
  2307. clone(): Viewport;
  2308. }
  2309. }
  2310. declare module BABYLON {
  2311. /**
  2312. * Class containing a set of static utilities functions for arrays.
  2313. */
  2314. export class ArrayTools {
  2315. /**
  2316. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2317. * @param size the number of element to construct and put in the array
  2318. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2319. * @returns a new array filled with new objects
  2320. */
  2321. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2322. }
  2323. }
  2324. declare module BABYLON {
  2325. /**
  2326. * Represents a plane by the equation ax + by + cz + d = 0
  2327. */
  2328. export class Plane {
  2329. private static _TmpMatrix;
  2330. /**
  2331. * Normal of the plane (a,b,c)
  2332. */
  2333. normal: Vector3;
  2334. /**
  2335. * d component of the plane
  2336. */
  2337. d: number;
  2338. /**
  2339. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2340. * @param a a component of the plane
  2341. * @param b b component of the plane
  2342. * @param c c component of the plane
  2343. * @param d d component of the plane
  2344. */
  2345. constructor(a: number, b: number, c: number, d: number);
  2346. /**
  2347. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2348. */
  2349. asArray(): number[];
  2350. /**
  2351. * @returns a new plane copied from the current Plane.
  2352. */
  2353. clone(): Plane;
  2354. /**
  2355. * @returns the string "Plane".
  2356. */
  2357. getClassName(): string;
  2358. /**
  2359. * @returns the Plane hash code.
  2360. */
  2361. getHashCode(): number;
  2362. /**
  2363. * Normalize the current Plane in place.
  2364. * @returns the updated Plane.
  2365. */
  2366. normalize(): Plane;
  2367. /**
  2368. * Applies a transformation the plane and returns the result
  2369. * @param transformation the transformation matrix to be applied to the plane
  2370. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2371. */
  2372. transform(transformation: DeepImmutable<Matrix>): Plane;
  2373. /**
  2374. * Compute the dot product between the point and the plane normal
  2375. * @param point point to calculate the dot product with
  2376. * @returns the dot product (float) of the point coordinates and the plane normal.
  2377. */
  2378. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2379. /**
  2380. * Updates the current Plane from the plane defined by the three given points.
  2381. * @param point1 one of the points used to contruct the plane
  2382. * @param point2 one of the points used to contruct the plane
  2383. * @param point3 one of the points used to contruct the plane
  2384. * @returns the updated Plane.
  2385. */
  2386. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2387. /**
  2388. * Checks if the plane is facing a given direction
  2389. * @param direction the direction to check if the plane is facing
  2390. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2391. * @returns True is the vector "direction" is the same side than the plane normal.
  2392. */
  2393. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2394. /**
  2395. * Calculates the distance to a point
  2396. * @param point point to calculate distance to
  2397. * @returns the signed distance (float) from the given point to the Plane.
  2398. */
  2399. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2400. /**
  2401. * Creates a plane from an array
  2402. * @param array the array to create a plane from
  2403. * @returns a new Plane from the given array.
  2404. */
  2405. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2406. /**
  2407. * Creates a plane from three points
  2408. * @param point1 point used to create the plane
  2409. * @param point2 point used to create the plane
  2410. * @param point3 point used to create the plane
  2411. * @returns a new Plane defined by the three given points.
  2412. */
  2413. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2414. /**
  2415. * Creates a plane from an origin point and a normal
  2416. * @param origin origin of the plane to be constructed
  2417. * @param normal normal of the plane to be constructed
  2418. * @returns a new Plane the normal vector to this plane at the given origin point.
  2419. * Note : the vector "normal" is updated because normalized.
  2420. */
  2421. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2422. /**
  2423. * Calculates the distance from a plane and a point
  2424. * @param origin origin of the plane to be constructed
  2425. * @param normal normal of the plane to be constructed
  2426. * @param point point to calculate distance to
  2427. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2428. */
  2429. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2430. }
  2431. }
  2432. declare module BABYLON {
  2433. /** @hidden */
  2434. export class PerformanceConfigurator {
  2435. /** @hidden */
  2436. static MatrixUse64Bits: boolean;
  2437. /** @hidden */
  2438. static MatrixTrackPrecisionChange: boolean;
  2439. /** @hidden */
  2440. static MatrixCurrentType: any;
  2441. /** @hidden */
  2442. static MatrixTrackedMatrices: Array<any> | null;
  2443. /** @hidden */
  2444. static SetMatrixPrecision(use64bits: boolean): void;
  2445. }
  2446. }
  2447. declare module BABYLON {
  2448. /**
  2449. * Class representing a vector containing 2 coordinates
  2450. */
  2451. export class Vector2 {
  2452. /** defines the first coordinate */
  2453. x: number;
  2454. /** defines the second coordinate */
  2455. y: number;
  2456. /**
  2457. * Creates a new Vector2 from the given x and y coordinates
  2458. * @param x defines the first coordinate
  2459. * @param y defines the second coordinate
  2460. */
  2461. constructor(
  2462. /** defines the first coordinate */
  2463. x?: number,
  2464. /** defines the second coordinate */
  2465. y?: number);
  2466. /**
  2467. * Gets a string with the Vector2 coordinates
  2468. * @returns a string with the Vector2 coordinates
  2469. */
  2470. toString(): string;
  2471. /**
  2472. * Gets class name
  2473. * @returns the string "Vector2"
  2474. */
  2475. getClassName(): string;
  2476. /**
  2477. * Gets current vector hash code
  2478. * @returns the Vector2 hash code as a number
  2479. */
  2480. getHashCode(): number;
  2481. /**
  2482. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2483. * @param array defines the source array
  2484. * @param index defines the offset in source array
  2485. * @returns the current Vector2
  2486. */
  2487. toArray(array: FloatArray, index?: number): Vector2;
  2488. /**
  2489. * Update the current vector from an array
  2490. * @param array defines the destination array
  2491. * @param index defines the offset in the destination array
  2492. * @returns the current Vector3
  2493. */
  2494. fromArray(array: FloatArray, index?: number): Vector2;
  2495. /**
  2496. * Copy the current vector to an array
  2497. * @returns a new array with 2 elements: the Vector2 coordinates.
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2502. * @param source defines the source Vector2
  2503. * @returns the current updated Vector2
  2504. */
  2505. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2506. /**
  2507. * Sets the Vector2 coordinates with the given floats
  2508. * @param x defines the first coordinate
  2509. * @param y defines the second coordinate
  2510. * @returns the current updated Vector2
  2511. */
  2512. copyFromFloats(x: number, y: number): Vector2;
  2513. /**
  2514. * Sets the Vector2 coordinates with the given floats
  2515. * @param x defines the first coordinate
  2516. * @param y defines the second coordinate
  2517. * @returns the current updated Vector2
  2518. */
  2519. set(x: number, y: number): Vector2;
  2520. /**
  2521. * Add another vector with the current one
  2522. * @param otherVector defines the other vector
  2523. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2524. */
  2525. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2526. /**
  2527. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2528. * @param otherVector defines the other vector
  2529. * @param result defines the target vector
  2530. * @returns the unmodified current Vector2
  2531. */
  2532. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2533. /**
  2534. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2535. * @param otherVector defines the other vector
  2536. * @returns the current updated Vector2
  2537. */
  2538. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2539. /**
  2540. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2541. * @param otherVector defines the other vector
  2542. * @returns a new Vector2
  2543. */
  2544. addVector3(otherVector: Vector3): Vector2;
  2545. /**
  2546. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2547. * @param otherVector defines the other vector
  2548. * @returns a new Vector2
  2549. */
  2550. subtract(otherVector: Vector2): Vector2;
  2551. /**
  2552. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2553. * @param otherVector defines the other vector
  2554. * @param result defines the target vector
  2555. * @returns the unmodified current Vector2
  2556. */
  2557. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2558. /**
  2559. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2560. * @param otherVector defines the other vector
  2561. * @returns the current updated Vector2
  2562. */
  2563. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2564. /**
  2565. * Multiplies in place the current Vector2 coordinates by the given ones
  2566. * @param otherVector defines the other vector
  2567. * @returns the current updated Vector2
  2568. */
  2569. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2570. /**
  2571. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2572. * @param otherVector defines the other vector
  2573. * @returns a new Vector2
  2574. */
  2575. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2576. /**
  2577. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2578. * @param otherVector defines the other vector
  2579. * @param result defines the target vector
  2580. * @returns the unmodified current Vector2
  2581. */
  2582. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2583. /**
  2584. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2585. * @param x defines the first coordinate
  2586. * @param y defines the second coordinate
  2587. * @returns a new Vector2
  2588. */
  2589. multiplyByFloats(x: number, y: number): Vector2;
  2590. /**
  2591. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2592. * @param otherVector defines the other vector
  2593. * @returns a new Vector2
  2594. */
  2595. divide(otherVector: Vector2): Vector2;
  2596. /**
  2597. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2598. * @param otherVector defines the other vector
  2599. * @param result defines the target vector
  2600. * @returns the unmodified current Vector2
  2601. */
  2602. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2603. /**
  2604. * Divides the current Vector2 coordinates by the given ones
  2605. * @param otherVector defines the other vector
  2606. * @returns the current updated Vector2
  2607. */
  2608. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2609. /**
  2610. * Gets a new Vector2 with current Vector2 negated coordinates
  2611. * @returns a new Vector2
  2612. */
  2613. negate(): Vector2;
  2614. /**
  2615. * Negate this vector in place
  2616. * @returns this
  2617. */
  2618. negateInPlace(): Vector2;
  2619. /**
  2620. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2621. * @param result defines the Vector3 object where to store the result
  2622. * @returns the current Vector2
  2623. */
  2624. negateToRef(result: Vector2): Vector2;
  2625. /**
  2626. * Multiply the Vector2 coordinates by scale
  2627. * @param scale defines the scaling factor
  2628. * @returns the current updated Vector2
  2629. */
  2630. scaleInPlace(scale: number): Vector2;
  2631. /**
  2632. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2633. * @param scale defines the scaling factor
  2634. * @returns a new Vector2
  2635. */
  2636. scale(scale: number): Vector2;
  2637. /**
  2638. * Scale the current Vector2 values by a factor to a given Vector2
  2639. * @param scale defines the scale factor
  2640. * @param result defines the Vector2 object where to store the result
  2641. * @returns the unmodified current Vector2
  2642. */
  2643. scaleToRef(scale: number, result: Vector2): Vector2;
  2644. /**
  2645. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2646. * @param scale defines the scale factor
  2647. * @param result defines the Vector2 object where to store the result
  2648. * @returns the unmodified current Vector2
  2649. */
  2650. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2651. /**
  2652. * Gets a boolean if two vectors are equals
  2653. * @param otherVector defines the other vector
  2654. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2655. */
  2656. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2657. /**
  2658. * Gets a boolean if two vectors are equals (using an epsilon value)
  2659. * @param otherVector defines the other vector
  2660. * @param epsilon defines the minimal distance to consider equality
  2661. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2662. */
  2663. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2664. /**
  2665. * Gets a new Vector2 from current Vector2 floored values
  2666. * @returns a new Vector2
  2667. */
  2668. floor(): Vector2;
  2669. /**
  2670. * Gets a new Vector2 from current Vector2 floored values
  2671. * @returns a new Vector2
  2672. */
  2673. fract(): Vector2;
  2674. /**
  2675. * Gets the length of the vector
  2676. * @returns the vector length (float)
  2677. */
  2678. length(): number;
  2679. /**
  2680. * Gets the vector squared length
  2681. * @returns the vector squared length (float)
  2682. */
  2683. lengthSquared(): number;
  2684. /**
  2685. * Normalize the vector
  2686. * @returns the current updated Vector2
  2687. */
  2688. normalize(): Vector2;
  2689. /**
  2690. * Gets a new Vector2 copied from the Vector2
  2691. * @returns a new Vector2
  2692. */
  2693. clone(): Vector2;
  2694. /**
  2695. * Gets a new Vector2(0, 0)
  2696. * @returns a new Vector2
  2697. */
  2698. static Zero(): Vector2;
  2699. /**
  2700. * Gets a new Vector2(1, 1)
  2701. * @returns a new Vector2
  2702. */
  2703. static One(): Vector2;
  2704. /**
  2705. * Gets a new Vector2 set from the given index element of the given array
  2706. * @param array defines the data source
  2707. * @param offset defines the offset in the data source
  2708. * @returns a new Vector2
  2709. */
  2710. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2711. /**
  2712. * Sets "result" from the given index element of the given array
  2713. * @param array defines the data source
  2714. * @param offset defines the offset in the data source
  2715. * @param result defines the target vector
  2716. */
  2717. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2718. /**
  2719. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2720. * @param value1 defines 1st point of control
  2721. * @param value2 defines 2nd point of control
  2722. * @param value3 defines 3rd point of control
  2723. * @param value4 defines 4th point of control
  2724. * @param amount defines the interpolation factor
  2725. * @returns a new Vector2
  2726. */
  2727. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2728. /**
  2729. * 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".
  2730. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2731. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2732. * @param value defines the value to clamp
  2733. * @param min defines the lower limit
  2734. * @param max defines the upper limit
  2735. * @returns a new Vector2
  2736. */
  2737. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2738. /**
  2739. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2740. * @param value1 defines the 1st control point
  2741. * @param tangent1 defines the outgoing tangent
  2742. * @param value2 defines the 2nd control point
  2743. * @param tangent2 defines the incoming tangent
  2744. * @param amount defines the interpolation factor
  2745. * @returns a new Vector2
  2746. */
  2747. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2748. /**
  2749. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2750. * @param start defines the start vector
  2751. * @param end defines the end vector
  2752. * @param amount defines the interpolation factor
  2753. * @returns a new Vector2
  2754. */
  2755. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2756. /**
  2757. * Gets the dot product of the vector "left" and the vector "right"
  2758. * @param left defines first vector
  2759. * @param right defines second vector
  2760. * @returns the dot product (float)
  2761. */
  2762. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2763. /**
  2764. * Returns a new Vector2 equal to the normalized given vector
  2765. * @param vector defines the vector to normalize
  2766. * @returns a new Vector2
  2767. */
  2768. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2769. /**
  2770. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2771. * @param left defines 1st vector
  2772. * @param right defines 2nd vector
  2773. * @returns a new Vector2
  2774. */
  2775. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2776. /**
  2777. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2778. * @param left defines 1st vector
  2779. * @param right defines 2nd vector
  2780. * @returns a new Vector2
  2781. */
  2782. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2783. /**
  2784. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2785. * @param vector defines the vector to transform
  2786. * @param transformation defines the matrix to apply
  2787. * @returns a new Vector2
  2788. */
  2789. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2790. /**
  2791. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2792. * @param vector defines the vector to transform
  2793. * @param transformation defines the matrix to apply
  2794. * @param result defines the target vector
  2795. */
  2796. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2797. /**
  2798. * Determines if a given vector is included in a triangle
  2799. * @param p defines the vector to test
  2800. * @param p0 defines 1st triangle point
  2801. * @param p1 defines 2nd triangle point
  2802. * @param p2 defines 3rd triangle point
  2803. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2804. */
  2805. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2806. /**
  2807. * Gets the distance between the vectors "value1" and "value2"
  2808. * @param value1 defines first vector
  2809. * @param value2 defines second vector
  2810. * @returns the distance between vectors
  2811. */
  2812. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2813. /**
  2814. * Returns the squared distance between the vectors "value1" and "value2"
  2815. * @param value1 defines first vector
  2816. * @param value2 defines second vector
  2817. * @returns the squared distance between vectors
  2818. */
  2819. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2820. /**
  2821. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2822. * @param value1 defines first vector
  2823. * @param value2 defines second vector
  2824. * @returns a new Vector2
  2825. */
  2826. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2827. /**
  2828. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2829. * @param p defines the middle point
  2830. * @param segA defines one point of the segment
  2831. * @param segB defines the other point of the segment
  2832. * @returns the shortest distance
  2833. */
  2834. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2835. }
  2836. /**
  2837. * Class used to store (x,y,z) vector representation
  2838. * A Vector3 is the main object used in 3D geometry
  2839. * It can represent etiher the coordinates of a point the space, either a direction
  2840. * Reminder: js uses a left handed forward facing system
  2841. */
  2842. export class Vector3 {
  2843. private static _UpReadOnly;
  2844. private static _ZeroReadOnly;
  2845. /** @hidden */
  2846. _x: number;
  2847. /** @hidden */
  2848. _y: number;
  2849. /** @hidden */
  2850. _z: number;
  2851. /** @hidden */
  2852. _isDirty: boolean;
  2853. /** Gets or sets the x coordinate */
  2854. get x(): number;
  2855. set x(value: number);
  2856. /** Gets or sets the y coordinate */
  2857. get y(): number;
  2858. set y(value: number);
  2859. /** Gets or sets the z coordinate */
  2860. get z(): number;
  2861. set z(value: number);
  2862. /**
  2863. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2864. * @param x defines the first coordinates (on X axis)
  2865. * @param y defines the second coordinates (on Y axis)
  2866. * @param z defines the third coordinates (on Z axis)
  2867. */
  2868. constructor(x?: number, y?: number, z?: number);
  2869. /**
  2870. * Creates a string representation of the Vector3
  2871. * @returns a string with the Vector3 coordinates.
  2872. */
  2873. toString(): string;
  2874. /**
  2875. * Gets the class name
  2876. * @returns the string "Vector3"
  2877. */
  2878. getClassName(): string;
  2879. /**
  2880. * Creates the Vector3 hash code
  2881. * @returns a number which tends to be unique between Vector3 instances
  2882. */
  2883. getHashCode(): number;
  2884. /**
  2885. * Creates an array containing three elements : the coordinates of the Vector3
  2886. * @returns a new array of numbers
  2887. */
  2888. asArray(): number[];
  2889. /**
  2890. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2891. * @param array defines the destination array
  2892. * @param index defines the offset in the destination array
  2893. * @returns the current Vector3
  2894. */
  2895. toArray(array: FloatArray, index?: number): Vector3;
  2896. /**
  2897. * Update the current vector from an array
  2898. * @param array defines the destination array
  2899. * @param index defines the offset in the destination array
  2900. * @returns the current Vector3
  2901. */
  2902. fromArray(array: FloatArray, index?: number): Vector3;
  2903. /**
  2904. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2905. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2906. */
  2907. toQuaternion(): Quaternion;
  2908. /**
  2909. * Adds the given vector to the current Vector3
  2910. * @param otherVector defines the second operand
  2911. * @returns the current updated Vector3
  2912. */
  2913. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2914. /**
  2915. * Adds the given coordinates to the current Vector3
  2916. * @param x defines the x coordinate of the operand
  2917. * @param y defines the y coordinate of the operand
  2918. * @param z defines the z coordinate of the operand
  2919. * @returns the current updated Vector3
  2920. */
  2921. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2922. /**
  2923. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2924. * @param otherVector defines the second operand
  2925. * @returns the resulting Vector3
  2926. */
  2927. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2928. /**
  2929. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2930. * @param otherVector defines the second operand
  2931. * @param result defines the Vector3 object where to store the result
  2932. * @returns the current Vector3
  2933. */
  2934. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2935. /**
  2936. * Subtract the given vector from the current Vector3
  2937. * @param otherVector defines the second operand
  2938. * @returns the current updated Vector3
  2939. */
  2940. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2941. /**
  2942. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2943. * @param otherVector defines the second operand
  2944. * @returns the resulting Vector3
  2945. */
  2946. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2947. /**
  2948. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2949. * @param otherVector defines the second operand
  2950. * @param result defines the Vector3 object where to store the result
  2951. * @returns the current Vector3
  2952. */
  2953. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2954. /**
  2955. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2956. * @param x defines the x coordinate of the operand
  2957. * @param y defines the y coordinate of the operand
  2958. * @param z defines the z coordinate of the operand
  2959. * @returns the resulting Vector3
  2960. */
  2961. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2962. /**
  2963. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2964. * @param x defines the x coordinate of the operand
  2965. * @param y defines the y coordinate of the operand
  2966. * @param z defines the z coordinate of the operand
  2967. * @param result defines the Vector3 object where to store the result
  2968. * @returns the current Vector3
  2969. */
  2970. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2971. /**
  2972. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2973. * @returns a new Vector3
  2974. */
  2975. negate(): Vector3;
  2976. /**
  2977. * Negate this vector in place
  2978. * @returns this
  2979. */
  2980. negateInPlace(): Vector3;
  2981. /**
  2982. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2983. * @param result defines the Vector3 object where to store the result
  2984. * @returns the current Vector3
  2985. */
  2986. negateToRef(result: Vector3): Vector3;
  2987. /**
  2988. * Multiplies the Vector3 coordinates by the float "scale"
  2989. * @param scale defines the multiplier factor
  2990. * @returns the current updated Vector3
  2991. */
  2992. scaleInPlace(scale: number): Vector3;
  2993. /**
  2994. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2995. * @param scale defines the multiplier factor
  2996. * @returns a new Vector3
  2997. */
  2998. scale(scale: number): Vector3;
  2999. /**
  3000. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3001. * @param scale defines the multiplier factor
  3002. * @param result defines the Vector3 object where to store the result
  3003. * @returns the current Vector3
  3004. */
  3005. scaleToRef(scale: number, result: Vector3): Vector3;
  3006. /**
  3007. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3008. * @param scale defines the scale factor
  3009. * @param result defines the Vector3 object where to store the result
  3010. * @returns the unmodified current Vector3
  3011. */
  3012. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3013. /**
  3014. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3015. * @param origin defines the origin of the projection ray
  3016. * @param plane defines the plane to project to
  3017. * @returns the projected vector3
  3018. */
  3019. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3020. /**
  3021. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3022. * @param origin defines the origin of the projection ray
  3023. * @param plane defines the plane to project to
  3024. * @param result defines the Vector3 where to store the result
  3025. */
  3026. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3027. /**
  3028. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3029. * @param otherVector defines the second operand
  3030. * @returns true if both vectors are equals
  3031. */
  3032. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3033. /**
  3034. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3035. * @param otherVector defines the second operand
  3036. * @param epsilon defines the minimal distance to define values as equals
  3037. * @returns true if both vectors are distant less than epsilon
  3038. */
  3039. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3040. /**
  3041. * Returns true if the current Vector3 coordinates equals the given floats
  3042. * @param x defines the x coordinate of the operand
  3043. * @param y defines the y coordinate of the operand
  3044. * @param z defines the z coordinate of the operand
  3045. * @returns true if both vectors are equals
  3046. */
  3047. equalsToFloats(x: number, y: number, z: number): boolean;
  3048. /**
  3049. * Multiplies the current Vector3 coordinates by the given ones
  3050. * @param otherVector defines the second operand
  3051. * @returns the current updated Vector3
  3052. */
  3053. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3054. /**
  3055. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3056. * @param otherVector defines the second operand
  3057. * @returns the new Vector3
  3058. */
  3059. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3060. /**
  3061. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3062. * @param otherVector defines the second operand
  3063. * @param result defines the Vector3 object where to store the result
  3064. * @returns the current Vector3
  3065. */
  3066. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3067. /**
  3068. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3069. * @param x defines the x coordinate of the operand
  3070. * @param y defines the y coordinate of the operand
  3071. * @param z defines the z coordinate of the operand
  3072. * @returns the new Vector3
  3073. */
  3074. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3075. /**
  3076. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3077. * @param otherVector defines the second operand
  3078. * @returns the new Vector3
  3079. */
  3080. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3081. /**
  3082. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3083. * @param otherVector defines the second operand
  3084. * @param result defines the Vector3 object where to store the result
  3085. * @returns the current Vector3
  3086. */
  3087. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3088. /**
  3089. * Divides the current Vector3 coordinates by the given ones.
  3090. * @param otherVector defines the second operand
  3091. * @returns the current updated Vector3
  3092. */
  3093. divideInPlace(otherVector: Vector3): Vector3;
  3094. /**
  3095. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3096. * @param other defines the second operand
  3097. * @returns the current updated Vector3
  3098. */
  3099. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3100. /**
  3101. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3102. * @param other defines the second operand
  3103. * @returns the current updated Vector3
  3104. */
  3105. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3106. /**
  3107. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3108. * @param x defines the x coordinate of the operand
  3109. * @param y defines the y coordinate of the operand
  3110. * @param z defines the z coordinate of the operand
  3111. * @returns the current updated Vector3
  3112. */
  3113. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3114. /**
  3115. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3116. * @param x defines the x coordinate of the operand
  3117. * @param y defines the y coordinate of the operand
  3118. * @param z defines the z coordinate of the operand
  3119. * @returns the current updated Vector3
  3120. */
  3121. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3122. /**
  3123. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3124. * Check if is non uniform within a certain amount of decimal places to account for this
  3125. * @param epsilon the amount the values can differ
  3126. * @returns if the the vector is non uniform to a certain number of decimal places
  3127. */
  3128. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3129. /**
  3130. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3131. */
  3132. get isNonUniform(): boolean;
  3133. /**
  3134. * Gets a new Vector3 from current Vector3 floored values
  3135. * @returns a new Vector3
  3136. */
  3137. floor(): Vector3;
  3138. /**
  3139. * Gets a new Vector3 from current Vector3 floored values
  3140. * @returns a new Vector3
  3141. */
  3142. fract(): Vector3;
  3143. /**
  3144. * Gets the length of the Vector3
  3145. * @returns the length of the Vector3
  3146. */
  3147. length(): number;
  3148. /**
  3149. * Gets the squared length of the Vector3
  3150. * @returns squared length of the Vector3
  3151. */
  3152. lengthSquared(): number;
  3153. /**
  3154. * Normalize the current Vector3.
  3155. * Please note that this is an in place operation.
  3156. * @returns the current updated Vector3
  3157. */
  3158. normalize(): Vector3;
  3159. /**
  3160. * Reorders the x y z properties of the vector in place
  3161. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3162. * @returns the current updated vector
  3163. */
  3164. reorderInPlace(order: string): this;
  3165. /**
  3166. * Rotates the vector around 0,0,0 by a quaternion
  3167. * @param quaternion the rotation quaternion
  3168. * @param result vector to store the result
  3169. * @returns the resulting vector
  3170. */
  3171. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3172. /**
  3173. * Rotates a vector around a given point
  3174. * @param quaternion the rotation quaternion
  3175. * @param point the point to rotate around
  3176. * @param result vector to store the result
  3177. * @returns the resulting vector
  3178. */
  3179. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3180. /**
  3181. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3182. * The cross product is then orthogonal to both current and "other"
  3183. * @param other defines the right operand
  3184. * @returns the cross product
  3185. */
  3186. cross(other: Vector3): Vector3;
  3187. /**
  3188. * Normalize the current Vector3 with the given input length.
  3189. * Please note that this is an in place operation.
  3190. * @param len the length of the vector
  3191. * @returns the current updated Vector3
  3192. */
  3193. normalizeFromLength(len: number): Vector3;
  3194. /**
  3195. * Normalize the current Vector3 to a new vector
  3196. * @returns the new Vector3
  3197. */
  3198. normalizeToNew(): Vector3;
  3199. /**
  3200. * Normalize the current Vector3 to the reference
  3201. * @param reference define the Vector3 to update
  3202. * @returns the updated Vector3
  3203. */
  3204. normalizeToRef(reference: Vector3): Vector3;
  3205. /**
  3206. * Creates a new Vector3 copied from the current Vector3
  3207. * @returns the new Vector3
  3208. */
  3209. clone(): Vector3;
  3210. /**
  3211. * Copies the given vector coordinates to the current Vector3 ones
  3212. * @param source defines the source Vector3
  3213. * @returns the current updated Vector3
  3214. */
  3215. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3216. /**
  3217. * Copies the given floats to the current Vector3 coordinates
  3218. * @param x defines the x coordinate of the operand
  3219. * @param y defines the y coordinate of the operand
  3220. * @param z defines the z coordinate of the operand
  3221. * @returns the current updated Vector3
  3222. */
  3223. copyFromFloats(x: number, y: number, z: number): Vector3;
  3224. /**
  3225. * Copies the given floats to the current Vector3 coordinates
  3226. * @param x defines the x coordinate of the operand
  3227. * @param y defines the y coordinate of the operand
  3228. * @param z defines the z coordinate of the operand
  3229. * @returns the current updated Vector3
  3230. */
  3231. set(x: number, y: number, z: number): Vector3;
  3232. /**
  3233. * Copies the given float to the current Vector3 coordinates
  3234. * @param v defines the x, y and z coordinates of the operand
  3235. * @returns the current updated Vector3
  3236. */
  3237. setAll(v: number): Vector3;
  3238. /**
  3239. * Get the clip factor between two vectors
  3240. * @param vector0 defines the first operand
  3241. * @param vector1 defines the second operand
  3242. * @param axis defines the axis to use
  3243. * @param size defines the size along the axis
  3244. * @returns the clip factor
  3245. */
  3246. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3247. /**
  3248. * Get angle between two vectors
  3249. * @param vector0 angle between vector0 and vector1
  3250. * @param vector1 angle between vector0 and vector1
  3251. * @param normal direction of the normal
  3252. * @return the angle between vector0 and vector1
  3253. */
  3254. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3255. /**
  3256. * Returns a new Vector3 set from the index "offset" of the given array
  3257. * @param array defines the source array
  3258. * @param offset defines the offset in the source array
  3259. * @returns the new Vector3
  3260. */
  3261. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3262. /**
  3263. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3264. * @param array defines the source array
  3265. * @param offset defines the offset in the source array
  3266. * @returns the new Vector3
  3267. * @deprecated Please use FromArray instead.
  3268. */
  3269. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3270. /**
  3271. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3272. * @param array defines the source array
  3273. * @param offset defines the offset in the source array
  3274. * @param result defines the Vector3 where to store the result
  3275. */
  3276. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3277. /**
  3278. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3279. * @param array defines the source array
  3280. * @param offset defines the offset in the source array
  3281. * @param result defines the Vector3 where to store the result
  3282. * @deprecated Please use FromArrayToRef instead.
  3283. */
  3284. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3285. /**
  3286. * Sets the given vector "result" with the given floats.
  3287. * @param x defines the x coordinate of the source
  3288. * @param y defines the y coordinate of the source
  3289. * @param z defines the z coordinate of the source
  3290. * @param result defines the Vector3 where to store the result
  3291. */
  3292. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3293. /**
  3294. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3295. * @returns a new empty Vector3
  3296. */
  3297. static Zero(): Vector3;
  3298. /**
  3299. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3300. * @returns a new unit Vector3
  3301. */
  3302. static One(): Vector3;
  3303. /**
  3304. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3305. * @returns a new up Vector3
  3306. */
  3307. static Up(): Vector3;
  3308. /**
  3309. * Gets a up Vector3 that must not be updated
  3310. */
  3311. static get UpReadOnly(): DeepImmutable<Vector3>;
  3312. /**
  3313. * Gets a zero Vector3 that must not be updated
  3314. */
  3315. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3316. /**
  3317. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3318. * @returns a new down Vector3
  3319. */
  3320. static Down(): Vector3;
  3321. /**
  3322. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3323. * @param rightHandedSystem is the scene right-handed (negative z)
  3324. * @returns a new forward Vector3
  3325. */
  3326. static Forward(rightHandedSystem?: boolean): Vector3;
  3327. /**
  3328. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3329. * @param rightHandedSystem is the scene right-handed (negative-z)
  3330. * @returns a new forward Vector3
  3331. */
  3332. static Backward(rightHandedSystem?: boolean): Vector3;
  3333. /**
  3334. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3335. * @returns a new right Vector3
  3336. */
  3337. static Right(): Vector3;
  3338. /**
  3339. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3340. * @returns a new left Vector3
  3341. */
  3342. static Left(): Vector3;
  3343. /**
  3344. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3345. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3346. * @param vector defines the Vector3 to transform
  3347. * @param transformation defines the transformation matrix
  3348. * @returns the transformed Vector3
  3349. */
  3350. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3351. /**
  3352. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3353. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3354. * @param vector defines the Vector3 to transform
  3355. * @param transformation defines the transformation matrix
  3356. * @param result defines the Vector3 where to store the result
  3357. */
  3358. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3359. /**
  3360. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3361. * This method computes tranformed coordinates only, not transformed direction vectors
  3362. * @param x define the x coordinate of the source vector
  3363. * @param y define the y coordinate of the source vector
  3364. * @param z define the z coordinate of the source vector
  3365. * @param transformation defines the transformation matrix
  3366. * @param result defines the Vector3 where to store the result
  3367. */
  3368. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3369. /**
  3370. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3371. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3372. * @param vector defines the Vector3 to transform
  3373. * @param transformation defines the transformation matrix
  3374. * @returns the new Vector3
  3375. */
  3376. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3377. /**
  3378. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3379. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3380. * @param vector defines the Vector3 to transform
  3381. * @param transformation defines the transformation matrix
  3382. * @param result defines the Vector3 where to store the result
  3383. */
  3384. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3385. /**
  3386. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3387. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3388. * @param x define the x coordinate of the source vector
  3389. * @param y define the y coordinate of the source vector
  3390. * @param z define the z coordinate of the source vector
  3391. * @param transformation defines the transformation matrix
  3392. * @param result defines the Vector3 where to store the result
  3393. */
  3394. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3395. /**
  3396. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3397. * @param value1 defines the first control point
  3398. * @param value2 defines the second control point
  3399. * @param value3 defines the third control point
  3400. * @param value4 defines the fourth control point
  3401. * @param amount defines the amount on the spline to use
  3402. * @returns the new Vector3
  3403. */
  3404. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3405. /**
  3406. * 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"
  3407. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3408. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3409. * @param value defines the current value
  3410. * @param min defines the lower range value
  3411. * @param max defines the upper range value
  3412. * @returns the new Vector3
  3413. */
  3414. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3415. /**
  3416. * 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"
  3417. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3418. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3419. * @param value defines the current value
  3420. * @param min defines the lower range value
  3421. * @param max defines the upper range value
  3422. * @param result defines the Vector3 where to store the result
  3423. */
  3424. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3425. /**
  3426. * Checks if a given vector is inside a specific range
  3427. * @param v defines the vector to test
  3428. * @param min defines the minimum range
  3429. * @param max defines the maximum range
  3430. */
  3431. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3432. /**
  3433. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3434. * @param value1 defines the first control point
  3435. * @param tangent1 defines the first tangent vector
  3436. * @param value2 defines the second control point
  3437. * @param tangent2 defines the second tangent vector
  3438. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3439. * @returns the new Vector3
  3440. */
  3441. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3442. /**
  3443. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3444. * @param start defines the start value
  3445. * @param end defines the end value
  3446. * @param amount max defines amount between both (between 0 and 1)
  3447. * @returns the new Vector3
  3448. */
  3449. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3450. /**
  3451. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3452. * @param start defines the start value
  3453. * @param end defines the end value
  3454. * @param amount max defines amount between both (between 0 and 1)
  3455. * @param result defines the Vector3 where to store the result
  3456. */
  3457. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3458. /**
  3459. * Returns the dot product (float) between the vectors "left" and "right"
  3460. * @param left defines the left operand
  3461. * @param right defines the right operand
  3462. * @returns the dot product
  3463. */
  3464. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3465. /**
  3466. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3467. * The cross product is then orthogonal to both "left" and "right"
  3468. * @param left defines the left operand
  3469. * @param right defines the right operand
  3470. * @returns the cross product
  3471. */
  3472. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3473. /**
  3474. * Sets the given vector "result" with the cross product of "left" and "right"
  3475. * The cross product is then orthogonal to both "left" and "right"
  3476. * @param left defines the left operand
  3477. * @param right defines the right operand
  3478. * @param result defines the Vector3 where to store the result
  3479. */
  3480. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3481. /**
  3482. * Returns a new Vector3 as the normalization of the given vector
  3483. * @param vector defines the Vector3 to normalize
  3484. * @returns the new Vector3
  3485. */
  3486. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3487. /**
  3488. * Sets the given vector "result" with the normalization of the given first vector
  3489. * @param vector defines the Vector3 to normalize
  3490. * @param result defines the Vector3 where to store the result
  3491. */
  3492. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3493. /**
  3494. * Project a Vector3 onto screen space
  3495. * @param vector defines the Vector3 to project
  3496. * @param world defines the world matrix to use
  3497. * @param transform defines the transform (view x projection) matrix to use
  3498. * @param viewport defines the screen viewport to use
  3499. * @returns the new Vector3
  3500. */
  3501. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3502. /**
  3503. * Project a Vector3 onto screen space to reference
  3504. * @param vector defines the Vector3 to project
  3505. * @param world defines the world matrix to use
  3506. * @param transform defines the transform (view x projection) matrix to use
  3507. * @param viewport defines the screen viewport to use
  3508. * @param result the vector in which the screen space will be stored
  3509. * @returns the new Vector3
  3510. */
  3511. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3512. /** @hidden */
  3513. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3514. /**
  3515. * Unproject from screen space to object space
  3516. * @param source defines the screen space Vector3 to use
  3517. * @param viewportWidth defines the current width of the viewport
  3518. * @param viewportHeight defines the current height of the viewport
  3519. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3520. * @param transform defines the transform (view x projection) matrix to use
  3521. * @returns the new Vector3
  3522. */
  3523. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3524. /**
  3525. * Unproject from screen space to object space
  3526. * @param source defines the screen space Vector3 to use
  3527. * @param viewportWidth defines the current width of the viewport
  3528. * @param viewportHeight defines the current height of the viewport
  3529. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3530. * @param view defines the view matrix to use
  3531. * @param projection defines the projection matrix to use
  3532. * @returns the new Vector3
  3533. */
  3534. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3535. /**
  3536. * Unproject from screen space to object space
  3537. * @param source defines the screen space Vector3 to use
  3538. * @param viewportWidth defines the current width of the viewport
  3539. * @param viewportHeight defines the current height of the viewport
  3540. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3541. * @param view defines the view matrix to use
  3542. * @param projection defines the projection matrix to use
  3543. * @param result defines the Vector3 where to store the result
  3544. */
  3545. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3546. /**
  3547. * Unproject from screen space to object space
  3548. * @param sourceX defines the screen space x coordinate to use
  3549. * @param sourceY defines the screen space y coordinate to use
  3550. * @param sourceZ defines the screen space z coordinate to use
  3551. * @param viewportWidth defines the current width of the viewport
  3552. * @param viewportHeight defines the current height of the viewport
  3553. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3554. * @param view defines the view matrix to use
  3555. * @param projection defines the projection matrix to use
  3556. * @param result defines the Vector3 where to store the result
  3557. */
  3558. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3559. /**
  3560. * Gets the minimal coordinate values between two Vector3
  3561. * @param left defines the first operand
  3562. * @param right defines the second operand
  3563. * @returns the new Vector3
  3564. */
  3565. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3566. /**
  3567. * Gets the maximal coordinate values between two Vector3
  3568. * @param left defines the first operand
  3569. * @param right defines the second operand
  3570. * @returns the new Vector3
  3571. */
  3572. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3573. /**
  3574. * Returns the distance between the vectors "value1" and "value2"
  3575. * @param value1 defines the first operand
  3576. * @param value2 defines the second operand
  3577. * @returns the distance
  3578. */
  3579. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3580. /**
  3581. * Returns the squared distance between the vectors "value1" and "value2"
  3582. * @param value1 defines the first operand
  3583. * @param value2 defines the second operand
  3584. * @returns the squared distance
  3585. */
  3586. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3587. /**
  3588. * Returns a new Vector3 located at the center between "value1" and "value2"
  3589. * @param value1 defines the first operand
  3590. * @param value2 defines the second operand
  3591. * @returns the new Vector3
  3592. */
  3593. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3594. /**
  3595. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3596. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3597. * to something in order to rotate it from its local system to the given target system
  3598. * Note: axis1, axis2 and axis3 are normalized during this operation
  3599. * @param axis1 defines the first axis
  3600. * @param axis2 defines the second axis
  3601. * @param axis3 defines the third axis
  3602. * @returns a new Vector3
  3603. */
  3604. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3605. /**
  3606. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3607. * @param axis1 defines the first axis
  3608. * @param axis2 defines the second axis
  3609. * @param axis3 defines the third axis
  3610. * @param ref defines the Vector3 where to store the result
  3611. */
  3612. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3613. }
  3614. /**
  3615. * Vector4 class created for EulerAngle class conversion to Quaternion
  3616. */
  3617. export class Vector4 {
  3618. /** x value of the vector */
  3619. x: number;
  3620. /** y value of the vector */
  3621. y: number;
  3622. /** z value of the vector */
  3623. z: number;
  3624. /** w value of the vector */
  3625. w: number;
  3626. /**
  3627. * Creates a Vector4 object from the given floats.
  3628. * @param x x value of the vector
  3629. * @param y y value of the vector
  3630. * @param z z value of the vector
  3631. * @param w w value of the vector
  3632. */
  3633. constructor(
  3634. /** x value of the vector */
  3635. x: number,
  3636. /** y value of the vector */
  3637. y: number,
  3638. /** z value of the vector */
  3639. z: number,
  3640. /** w value of the vector */
  3641. w: number);
  3642. /**
  3643. * Returns the string with the Vector4 coordinates.
  3644. * @returns a string containing all the vector values
  3645. */
  3646. toString(): string;
  3647. /**
  3648. * Returns the string "Vector4".
  3649. * @returns "Vector4"
  3650. */
  3651. getClassName(): string;
  3652. /**
  3653. * Returns the Vector4 hash code.
  3654. * @returns a unique hash code
  3655. */
  3656. getHashCode(): number;
  3657. /**
  3658. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3659. * @returns the resulting array
  3660. */
  3661. asArray(): number[];
  3662. /**
  3663. * Populates the given array from the given index with the Vector4 coordinates.
  3664. * @param array array to populate
  3665. * @param index index of the array to start at (default: 0)
  3666. * @returns the Vector4.
  3667. */
  3668. toArray(array: FloatArray, index?: number): Vector4;
  3669. /**
  3670. * Update the current vector from an array
  3671. * @param array defines the destination array
  3672. * @param index defines the offset in the destination array
  3673. * @returns the current Vector3
  3674. */
  3675. fromArray(array: FloatArray, index?: number): Vector4;
  3676. /**
  3677. * Adds the given vector to the current Vector4.
  3678. * @param otherVector the vector to add
  3679. * @returns the updated Vector4.
  3680. */
  3681. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3682. /**
  3683. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3684. * @param otherVector the vector to add
  3685. * @returns the resulting vector
  3686. */
  3687. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3688. /**
  3689. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3690. * @param otherVector the vector to add
  3691. * @param result the vector to store the result
  3692. * @returns the current Vector4.
  3693. */
  3694. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3695. /**
  3696. * Subtract in place the given vector from the current Vector4.
  3697. * @param otherVector the vector to subtract
  3698. * @returns the updated Vector4.
  3699. */
  3700. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3701. /**
  3702. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3703. * @param otherVector the vector to add
  3704. * @returns the new vector with the result
  3705. */
  3706. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3707. /**
  3708. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3709. * @param otherVector the vector to subtract
  3710. * @param result the vector to store the result
  3711. * @returns the current Vector4.
  3712. */
  3713. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3714. /**
  3715. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3716. */
  3717. /**
  3718. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3719. * @param x value to subtract
  3720. * @param y value to subtract
  3721. * @param z value to subtract
  3722. * @param w value to subtract
  3723. * @returns new vector containing the result
  3724. */
  3725. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3726. /**
  3727. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3728. * @param x value to subtract
  3729. * @param y value to subtract
  3730. * @param z value to subtract
  3731. * @param w value to subtract
  3732. * @param result the vector to store the result in
  3733. * @returns the current Vector4.
  3734. */
  3735. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3736. /**
  3737. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3738. * @returns a new vector with the negated values
  3739. */
  3740. negate(): Vector4;
  3741. /**
  3742. * Negate this vector in place
  3743. * @returns this
  3744. */
  3745. negateInPlace(): Vector4;
  3746. /**
  3747. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3748. * @param result defines the Vector3 object where to store the result
  3749. * @returns the current Vector4
  3750. */
  3751. negateToRef(result: Vector4): Vector4;
  3752. /**
  3753. * Multiplies the current Vector4 coordinates by scale (float).
  3754. * @param scale the number to scale with
  3755. * @returns the updated Vector4.
  3756. */
  3757. scaleInPlace(scale: number): Vector4;
  3758. /**
  3759. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3760. * @param scale the number to scale with
  3761. * @returns a new vector with the result
  3762. */
  3763. scale(scale: number): Vector4;
  3764. /**
  3765. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3766. * @param scale the number to scale with
  3767. * @param result a vector to store the result in
  3768. * @returns the current Vector4.
  3769. */
  3770. scaleToRef(scale: number, result: Vector4): Vector4;
  3771. /**
  3772. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3773. * @param scale defines the scale factor
  3774. * @param result defines the Vector4 object where to store the result
  3775. * @returns the unmodified current Vector4
  3776. */
  3777. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3778. /**
  3779. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3780. * @param otherVector the vector to compare against
  3781. * @returns true if they are equal
  3782. */
  3783. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3784. /**
  3785. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3786. * @param otherVector vector to compare against
  3787. * @param epsilon (Default: very small number)
  3788. * @returns true if they are equal
  3789. */
  3790. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3791. /**
  3792. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3793. * @param x x value to compare against
  3794. * @param y y value to compare against
  3795. * @param z z value to compare against
  3796. * @param w w value to compare against
  3797. * @returns true if equal
  3798. */
  3799. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3800. /**
  3801. * Multiplies in place the current Vector4 by the given one.
  3802. * @param otherVector vector to multiple with
  3803. * @returns the updated Vector4.
  3804. */
  3805. multiplyInPlace(otherVector: Vector4): Vector4;
  3806. /**
  3807. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3808. * @param otherVector vector to multiple with
  3809. * @returns resulting new vector
  3810. */
  3811. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3812. /**
  3813. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3814. * @param otherVector vector to multiple with
  3815. * @param result vector to store the result
  3816. * @returns the current Vector4.
  3817. */
  3818. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3819. /**
  3820. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3821. * @param x x value multiply with
  3822. * @param y y value multiply with
  3823. * @param z z value multiply with
  3824. * @param w w value multiply with
  3825. * @returns resulting new vector
  3826. */
  3827. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3828. /**
  3829. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3830. * @param otherVector vector to devide with
  3831. * @returns resulting new vector
  3832. */
  3833. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3834. /**
  3835. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3836. * @param otherVector vector to devide with
  3837. * @param result vector to store the result
  3838. * @returns the current Vector4.
  3839. */
  3840. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3841. /**
  3842. * Divides the current Vector3 coordinates by the given ones.
  3843. * @param otherVector vector to devide with
  3844. * @returns the updated Vector3.
  3845. */
  3846. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3847. /**
  3848. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3849. * @param other defines the second operand
  3850. * @returns the current updated Vector4
  3851. */
  3852. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3853. /**
  3854. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3855. * @param other defines the second operand
  3856. * @returns the current updated Vector4
  3857. */
  3858. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3859. /**
  3860. * Gets a new Vector4 from current Vector4 floored values
  3861. * @returns a new Vector4
  3862. */
  3863. floor(): Vector4;
  3864. /**
  3865. * Gets a new Vector4 from current Vector3 floored values
  3866. * @returns a new Vector4
  3867. */
  3868. fract(): Vector4;
  3869. /**
  3870. * Returns the Vector4 length (float).
  3871. * @returns the length
  3872. */
  3873. length(): number;
  3874. /**
  3875. * Returns the Vector4 squared length (float).
  3876. * @returns the length squared
  3877. */
  3878. lengthSquared(): number;
  3879. /**
  3880. * Normalizes in place the Vector4.
  3881. * @returns the updated Vector4.
  3882. */
  3883. normalize(): Vector4;
  3884. /**
  3885. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3886. * @returns this converted to a new vector3
  3887. */
  3888. toVector3(): Vector3;
  3889. /**
  3890. * Returns a new Vector4 copied from the current one.
  3891. * @returns the new cloned vector
  3892. */
  3893. clone(): Vector4;
  3894. /**
  3895. * Updates the current Vector4 with the given one coordinates.
  3896. * @param source the source vector to copy from
  3897. * @returns the updated Vector4.
  3898. */
  3899. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3900. /**
  3901. * Updates the current Vector4 coordinates with the given floats.
  3902. * @param x float to copy from
  3903. * @param y float to copy from
  3904. * @param z float to copy from
  3905. * @param w float to copy from
  3906. * @returns the updated Vector4.
  3907. */
  3908. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3909. /**
  3910. * Updates the current Vector4 coordinates with the given floats.
  3911. * @param x float to set from
  3912. * @param y float to set from
  3913. * @param z float to set from
  3914. * @param w float to set from
  3915. * @returns the updated Vector4.
  3916. */
  3917. set(x: number, y: number, z: number, w: number): Vector4;
  3918. /**
  3919. * Copies the given float to the current Vector3 coordinates
  3920. * @param v defines the x, y, z and w coordinates of the operand
  3921. * @returns the current updated Vector3
  3922. */
  3923. setAll(v: number): Vector4;
  3924. /**
  3925. * Returns a new Vector4 set from the starting index of the given array.
  3926. * @param array the array to pull values from
  3927. * @param offset the offset into the array to start at
  3928. * @returns the new vector
  3929. */
  3930. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3931. /**
  3932. * Updates the given vector "result" from the starting index of the given array.
  3933. * @param array the array to pull values from
  3934. * @param offset the offset into the array to start at
  3935. * @param result the vector to store the result in
  3936. */
  3937. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3938. /**
  3939. * Updates the given vector "result" from the starting index of the given Float32Array.
  3940. * @param array the array to pull values from
  3941. * @param offset the offset into the array to start at
  3942. * @param result the vector to store the result in
  3943. */
  3944. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3945. /**
  3946. * Updates the given vector "result" coordinates from the given floats.
  3947. * @param x float to set from
  3948. * @param y float to set from
  3949. * @param z float to set from
  3950. * @param w float to set from
  3951. * @param result the vector to the floats in
  3952. */
  3953. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3954. /**
  3955. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3956. * @returns the new vector
  3957. */
  3958. static Zero(): Vector4;
  3959. /**
  3960. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3961. * @returns the new vector
  3962. */
  3963. static One(): Vector4;
  3964. /**
  3965. * Returns a new normalized Vector4 from the given one.
  3966. * @param vector the vector to normalize
  3967. * @returns the vector
  3968. */
  3969. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3970. /**
  3971. * Updates the given vector "result" from the normalization of the given one.
  3972. * @param vector the vector to normalize
  3973. * @param result the vector to store the result in
  3974. */
  3975. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3976. /**
  3977. * Returns a vector with the minimum values from the left and right vectors
  3978. * @param left left vector to minimize
  3979. * @param right right vector to minimize
  3980. * @returns a new vector with the minimum of the left and right vector values
  3981. */
  3982. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3983. /**
  3984. * Returns a vector with the maximum values from the left and right vectors
  3985. * @param left left vector to maximize
  3986. * @param right right vector to maximize
  3987. * @returns a new vector with the maximum of the left and right vector values
  3988. */
  3989. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3990. /**
  3991. * Returns the distance (float) between the vectors "value1" and "value2".
  3992. * @param value1 value to calulate the distance between
  3993. * @param value2 value to calulate the distance between
  3994. * @return the distance between the two vectors
  3995. */
  3996. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3997. /**
  3998. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3999. * @param value1 value to calulate the distance between
  4000. * @param value2 value to calulate the distance between
  4001. * @return the distance between the two vectors squared
  4002. */
  4003. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4004. /**
  4005. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4006. * @param value1 value to calulate the center between
  4007. * @param value2 value to calulate the center between
  4008. * @return the center between the two vectors
  4009. */
  4010. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4011. /**
  4012. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4013. * This methods computes transformed normalized direction vectors only.
  4014. * @param vector the vector to transform
  4015. * @param transformation the transformation matrix to apply
  4016. * @returns the new vector
  4017. */
  4018. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4019. /**
  4020. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4021. * This methods computes transformed normalized direction vectors only.
  4022. * @param vector the vector to transform
  4023. * @param transformation the transformation matrix to apply
  4024. * @param result the vector to store the result in
  4025. */
  4026. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4027. /**
  4028. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4029. * This methods computes transformed normalized direction vectors only.
  4030. * @param x value to transform
  4031. * @param y value to transform
  4032. * @param z value to transform
  4033. * @param w value to transform
  4034. * @param transformation the transformation matrix to apply
  4035. * @param result the vector to store the results in
  4036. */
  4037. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4038. /**
  4039. * Creates a new Vector4 from a Vector3
  4040. * @param source defines the source data
  4041. * @param w defines the 4th component (default is 0)
  4042. * @returns a new Vector4
  4043. */
  4044. static FromVector3(source: Vector3, w?: number): Vector4;
  4045. }
  4046. /**
  4047. * Class used to store quaternion data
  4048. * @see https://en.wikipedia.org/wiki/Quaternion
  4049. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4050. */
  4051. export class Quaternion {
  4052. /** @hidden */
  4053. _x: number;
  4054. /** @hidden */
  4055. _y: number;
  4056. /** @hidden */
  4057. _z: number;
  4058. /** @hidden */
  4059. _w: number;
  4060. /** @hidden */
  4061. _isDirty: boolean;
  4062. /** Gets or sets the x coordinate */
  4063. get x(): number;
  4064. set x(value: number);
  4065. /** Gets or sets the y coordinate */
  4066. get y(): number;
  4067. set y(value: number);
  4068. /** Gets or sets the z coordinate */
  4069. get z(): number;
  4070. set z(value: number);
  4071. /** Gets or sets the w coordinate */
  4072. get w(): number;
  4073. set w(value: number);
  4074. /**
  4075. * Creates a new Quaternion from the given floats
  4076. * @param x defines the first component (0 by default)
  4077. * @param y defines the second component (0 by default)
  4078. * @param z defines the third component (0 by default)
  4079. * @param w defines the fourth component (1.0 by default)
  4080. */
  4081. constructor(x?: number, y?: number, z?: number, w?: number);
  4082. /**
  4083. * Gets a string representation for the current quaternion
  4084. * @returns a string with the Quaternion coordinates
  4085. */
  4086. toString(): string;
  4087. /**
  4088. * Gets the class name of the quaternion
  4089. * @returns the string "Quaternion"
  4090. */
  4091. getClassName(): string;
  4092. /**
  4093. * Gets a hash code for this quaternion
  4094. * @returns the quaternion hash code
  4095. */
  4096. getHashCode(): number;
  4097. /**
  4098. * Copy the quaternion to an array
  4099. * @returns a new array populated with 4 elements from the quaternion coordinates
  4100. */
  4101. asArray(): number[];
  4102. /**
  4103. * Check if two quaternions are equals
  4104. * @param otherQuaternion defines the second operand
  4105. * @return true if the current quaternion and the given one coordinates are strictly equals
  4106. */
  4107. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4108. /**
  4109. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4110. * @param otherQuaternion defines the other quaternion
  4111. * @param epsilon defines the minimal distance to consider equality
  4112. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4113. */
  4114. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4115. /**
  4116. * Clone the current quaternion
  4117. * @returns a new quaternion copied from the current one
  4118. */
  4119. clone(): Quaternion;
  4120. /**
  4121. * Copy a quaternion to the current one
  4122. * @param other defines the other quaternion
  4123. * @returns the updated current quaternion
  4124. */
  4125. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4126. /**
  4127. * Updates the current quaternion with the given float coordinates
  4128. * @param x defines the x coordinate
  4129. * @param y defines the y coordinate
  4130. * @param z defines the z coordinate
  4131. * @param w defines the w coordinate
  4132. * @returns the updated current quaternion
  4133. */
  4134. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4135. /**
  4136. * Updates the current quaternion from the given float coordinates
  4137. * @param x defines the x coordinate
  4138. * @param y defines the y coordinate
  4139. * @param z defines the z coordinate
  4140. * @param w defines the w coordinate
  4141. * @returns the updated current quaternion
  4142. */
  4143. set(x: number, y: number, z: number, w: number): Quaternion;
  4144. /**
  4145. * Adds two quaternions
  4146. * @param other defines the second operand
  4147. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4148. */
  4149. add(other: DeepImmutable<Quaternion>): Quaternion;
  4150. /**
  4151. * Add a quaternion to the current one
  4152. * @param other defines the quaternion to add
  4153. * @returns the current quaternion
  4154. */
  4155. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4156. /**
  4157. * Subtract two quaternions
  4158. * @param other defines the second operand
  4159. * @returns a new quaternion as the subtraction result of the given one from the current one
  4160. */
  4161. subtract(other: Quaternion): Quaternion;
  4162. /**
  4163. * Multiplies the current quaternion by a scale factor
  4164. * @param value defines the scale factor
  4165. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4166. */
  4167. scale(value: number): Quaternion;
  4168. /**
  4169. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4170. * @param scale defines the scale factor
  4171. * @param result defines the Quaternion object where to store the result
  4172. * @returns the unmodified current quaternion
  4173. */
  4174. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4175. /**
  4176. * Multiplies in place the current quaternion by a scale factor
  4177. * @param value defines the scale factor
  4178. * @returns the current modified quaternion
  4179. */
  4180. scaleInPlace(value: number): Quaternion;
  4181. /**
  4182. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4183. * @param scale defines the scale factor
  4184. * @param result defines the Quaternion object where to store the result
  4185. * @returns the unmodified current quaternion
  4186. */
  4187. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4188. /**
  4189. * Multiplies two quaternions
  4190. * @param q1 defines the second operand
  4191. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4192. */
  4193. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4194. /**
  4195. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4196. * @param q1 defines the second operand
  4197. * @param result defines the target quaternion
  4198. * @returns the current quaternion
  4199. */
  4200. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4201. /**
  4202. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4203. * @param q1 defines the second operand
  4204. * @returns the currentupdated quaternion
  4205. */
  4206. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4207. /**
  4208. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4209. * @param ref defines the target quaternion
  4210. * @returns the current quaternion
  4211. */
  4212. conjugateToRef(ref: Quaternion): Quaternion;
  4213. /**
  4214. * Conjugates in place (1-q) the current quaternion
  4215. * @returns the current updated quaternion
  4216. */
  4217. conjugateInPlace(): Quaternion;
  4218. /**
  4219. * Conjugates in place (1-q) the current quaternion
  4220. * @returns a new quaternion
  4221. */
  4222. conjugate(): Quaternion;
  4223. /**
  4224. * Gets length of current quaternion
  4225. * @returns the quaternion length (float)
  4226. */
  4227. length(): number;
  4228. /**
  4229. * Normalize in place the current quaternion
  4230. * @returns the current updated quaternion
  4231. */
  4232. normalize(): Quaternion;
  4233. /**
  4234. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4235. * @param order is a reserved parameter and is ignored for now
  4236. * @returns a new Vector3 containing the Euler angles
  4237. */
  4238. toEulerAngles(order?: string): Vector3;
  4239. /**
  4240. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4241. * @param result defines the vector which will be filled with the Euler angles
  4242. * @returns the current unchanged quaternion
  4243. */
  4244. toEulerAnglesToRef(result: Vector3): Quaternion;
  4245. /**
  4246. * Updates the given rotation matrix with the current quaternion values
  4247. * @param result defines the target matrix
  4248. * @returns the current unchanged quaternion
  4249. */
  4250. toRotationMatrix(result: Matrix): Quaternion;
  4251. /**
  4252. * Updates the current quaternion from the given rotation matrix values
  4253. * @param matrix defines the source matrix
  4254. * @returns the current updated quaternion
  4255. */
  4256. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4257. /**
  4258. * Creates a new quaternion from a rotation matrix
  4259. * @param matrix defines the source matrix
  4260. * @returns a new quaternion created from the given rotation matrix values
  4261. */
  4262. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4263. /**
  4264. * Updates the given quaternion with the given rotation matrix values
  4265. * @param matrix defines the source matrix
  4266. * @param result defines the target quaternion
  4267. */
  4268. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4269. /**
  4270. * Returns the dot product (float) between the quaternions "left" and "right"
  4271. * @param left defines the left operand
  4272. * @param right defines the right operand
  4273. * @returns the dot product
  4274. */
  4275. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4276. /**
  4277. * Checks if the two quaternions are close to each other
  4278. * @param quat0 defines the first quaternion to check
  4279. * @param quat1 defines the second quaternion to check
  4280. * @returns true if the two quaternions are close to each other
  4281. */
  4282. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4283. /**
  4284. * Creates an empty quaternion
  4285. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4286. */
  4287. static Zero(): Quaternion;
  4288. /**
  4289. * Inverse a given quaternion
  4290. * @param q defines the source quaternion
  4291. * @returns a new quaternion as the inverted current quaternion
  4292. */
  4293. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4294. /**
  4295. * Inverse a given quaternion
  4296. * @param q defines the source quaternion
  4297. * @param result the quaternion the result will be stored in
  4298. * @returns the result quaternion
  4299. */
  4300. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4301. /**
  4302. * Creates an identity quaternion
  4303. * @returns the identity quaternion
  4304. */
  4305. static Identity(): Quaternion;
  4306. /**
  4307. * Gets a boolean indicating if the given quaternion is identity
  4308. * @param quaternion defines the quaternion to check
  4309. * @returns true if the quaternion is identity
  4310. */
  4311. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4312. /**
  4313. * Creates a quaternion from a rotation around an axis
  4314. * @param axis defines the axis to use
  4315. * @param angle defines the angle to use
  4316. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4317. */
  4318. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4319. /**
  4320. * Creates a rotation around an axis and stores it into the given quaternion
  4321. * @param axis defines the axis to use
  4322. * @param angle defines the angle to use
  4323. * @param result defines the target quaternion
  4324. * @returns the target quaternion
  4325. */
  4326. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4327. /**
  4328. * Creates a new quaternion from data stored into an array
  4329. * @param array defines the data source
  4330. * @param offset defines the offset in the source array where the data starts
  4331. * @returns a new quaternion
  4332. */
  4333. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4334. /**
  4335. * Updates the given quaternion "result" from the starting index of the given array.
  4336. * @param array the array to pull values from
  4337. * @param offset the offset into the array to start at
  4338. * @param result the quaternion to store the result in
  4339. */
  4340. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4341. /**
  4342. * Create a quaternion from Euler rotation angles
  4343. * @param x Pitch
  4344. * @param y Yaw
  4345. * @param z Roll
  4346. * @returns the new Quaternion
  4347. */
  4348. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4349. /**
  4350. * Updates a quaternion from Euler rotation angles
  4351. * @param x Pitch
  4352. * @param y Yaw
  4353. * @param z Roll
  4354. * @param result the quaternion to store the result
  4355. * @returns the updated quaternion
  4356. */
  4357. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4358. /**
  4359. * Create a quaternion from Euler rotation vector
  4360. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4361. * @returns the new Quaternion
  4362. */
  4363. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4364. /**
  4365. * Updates a quaternion from Euler rotation vector
  4366. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4367. * @param result the quaternion to store the result
  4368. * @returns the updated quaternion
  4369. */
  4370. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4371. /**
  4372. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4373. * @param yaw defines the rotation around Y axis
  4374. * @param pitch defines the rotation around X axis
  4375. * @param roll defines the rotation around Z axis
  4376. * @returns the new quaternion
  4377. */
  4378. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4379. /**
  4380. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4381. * @param yaw defines the rotation around Y axis
  4382. * @param pitch defines the rotation around X axis
  4383. * @param roll defines the rotation around Z axis
  4384. * @param result defines the target quaternion
  4385. */
  4386. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4387. /**
  4388. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4389. * @param alpha defines the rotation around first axis
  4390. * @param beta defines the rotation around second axis
  4391. * @param gamma defines the rotation around third axis
  4392. * @returns the new quaternion
  4393. */
  4394. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4395. /**
  4396. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4397. * @param alpha defines the rotation around first axis
  4398. * @param beta defines the rotation around second axis
  4399. * @param gamma defines the rotation around third axis
  4400. * @param result defines the target quaternion
  4401. */
  4402. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4403. /**
  4404. * 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)
  4405. * @param axis1 defines the first axis
  4406. * @param axis2 defines the second axis
  4407. * @param axis3 defines the third axis
  4408. * @returns the new quaternion
  4409. */
  4410. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4411. /**
  4412. * 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
  4413. * @param axis1 defines the first axis
  4414. * @param axis2 defines the second axis
  4415. * @param axis3 defines the third axis
  4416. * @param ref defines the target quaternion
  4417. */
  4418. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4419. /**
  4420. * Interpolates between two quaternions
  4421. * @param left defines first quaternion
  4422. * @param right defines second quaternion
  4423. * @param amount defines the gradient to use
  4424. * @returns the new interpolated quaternion
  4425. */
  4426. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4427. /**
  4428. * Interpolates between two quaternions and stores it into a target quaternion
  4429. * @param left defines first quaternion
  4430. * @param right defines second quaternion
  4431. * @param amount defines the gradient to use
  4432. * @param result defines the target quaternion
  4433. */
  4434. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4435. /**
  4436. * Interpolate between two quaternions using Hermite interpolation
  4437. * @param value1 defines first quaternion
  4438. * @param tangent1 defines the incoming tangent
  4439. * @param value2 defines second quaternion
  4440. * @param tangent2 defines the outgoing tangent
  4441. * @param amount defines the target quaternion
  4442. * @returns the new interpolated quaternion
  4443. */
  4444. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4445. }
  4446. /**
  4447. * Class used to store matrix data (4x4)
  4448. */
  4449. export class Matrix {
  4450. /**
  4451. * Gets the precision of matrix computations
  4452. */
  4453. static get Use64Bits(): boolean;
  4454. private static _updateFlagSeed;
  4455. private static _identityReadOnly;
  4456. private _isIdentity;
  4457. private _isIdentityDirty;
  4458. private _isIdentity3x2;
  4459. private _isIdentity3x2Dirty;
  4460. /**
  4461. * Gets the update flag of the matrix which is an unique number for the matrix.
  4462. * It will be incremented every time the matrix data change.
  4463. * You can use it to speed the comparison between two versions of the same matrix.
  4464. */
  4465. updateFlag: number;
  4466. private readonly _m;
  4467. /**
  4468. * Gets the internal data of the matrix
  4469. */
  4470. get m(): DeepImmutable<Float32Array | Array<number>>;
  4471. /** @hidden */
  4472. _markAsUpdated(): void;
  4473. /** @hidden */
  4474. private _updateIdentityStatus;
  4475. /**
  4476. * Creates an empty matrix (filled with zeros)
  4477. */
  4478. constructor();
  4479. /**
  4480. * Check if the current matrix is identity
  4481. * @returns true is the matrix is the identity matrix
  4482. */
  4483. isIdentity(): boolean;
  4484. /**
  4485. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4486. * @returns true is the matrix is the identity matrix
  4487. */
  4488. isIdentityAs3x2(): boolean;
  4489. /**
  4490. * Gets the determinant of the matrix
  4491. * @returns the matrix determinant
  4492. */
  4493. determinant(): number;
  4494. /**
  4495. * Returns the matrix as a Float32Array or Array<number>
  4496. * @returns the matrix underlying array
  4497. */
  4498. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4499. /**
  4500. * Returns the matrix as a Float32Array or Array<number>
  4501. * @returns the matrix underlying array.
  4502. */
  4503. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4504. /**
  4505. * Inverts the current matrix in place
  4506. * @returns the current inverted matrix
  4507. */
  4508. invert(): Matrix;
  4509. /**
  4510. * Sets all the matrix elements to zero
  4511. * @returns the current matrix
  4512. */
  4513. reset(): Matrix;
  4514. /**
  4515. * Adds the current matrix with a second one
  4516. * @param other defines the matrix to add
  4517. * @returns a new matrix as the addition of the current matrix and the given one
  4518. */
  4519. add(other: DeepImmutable<Matrix>): Matrix;
  4520. /**
  4521. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4522. * @param other defines the matrix to add
  4523. * @param result defines the target matrix
  4524. * @returns the current matrix
  4525. */
  4526. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4527. /**
  4528. * Adds in place the given matrix to the current matrix
  4529. * @param other defines the second operand
  4530. * @returns the current updated matrix
  4531. */
  4532. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4533. /**
  4534. * Sets the given matrix to the current inverted Matrix
  4535. * @param other defines the target matrix
  4536. * @returns the unmodified current matrix
  4537. */
  4538. invertToRef(other: Matrix): Matrix;
  4539. /**
  4540. * add a value at the specified position in the current Matrix
  4541. * @param index the index of the value within the matrix. between 0 and 15.
  4542. * @param value the value to be added
  4543. * @returns the current updated matrix
  4544. */
  4545. addAtIndex(index: number, value: number): Matrix;
  4546. /**
  4547. * mutiply the specified position in the current Matrix by a value
  4548. * @param index the index of the value within the matrix. between 0 and 15.
  4549. * @param value the value to be added
  4550. * @returns the current updated matrix
  4551. */
  4552. multiplyAtIndex(index: number, value: number): Matrix;
  4553. /**
  4554. * Inserts the translation vector (using 3 floats) in the current matrix
  4555. * @param x defines the 1st component of the translation
  4556. * @param y defines the 2nd component of the translation
  4557. * @param z defines the 3rd component of the translation
  4558. * @returns the current updated matrix
  4559. */
  4560. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4561. /**
  4562. * Adds the translation vector (using 3 floats) in the current matrix
  4563. * @param x defines the 1st component of the translation
  4564. * @param y defines the 2nd component of the translation
  4565. * @param z defines the 3rd component of the translation
  4566. * @returns the current updated matrix
  4567. */
  4568. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4569. /**
  4570. * Inserts the translation vector in the current matrix
  4571. * @param vector3 defines the translation to insert
  4572. * @returns the current updated matrix
  4573. */
  4574. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4575. /**
  4576. * Gets the translation value of the current matrix
  4577. * @returns a new Vector3 as the extracted translation from the matrix
  4578. */
  4579. getTranslation(): Vector3;
  4580. /**
  4581. * Fill a Vector3 with the extracted translation from the matrix
  4582. * @param result defines the Vector3 where to store the translation
  4583. * @returns the current matrix
  4584. */
  4585. getTranslationToRef(result: Vector3): Matrix;
  4586. /**
  4587. * Remove rotation and scaling part from the matrix
  4588. * @returns the updated matrix
  4589. */
  4590. removeRotationAndScaling(): Matrix;
  4591. /**
  4592. * Multiply two matrices
  4593. * @param other defines the second operand
  4594. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4595. */
  4596. multiply(other: DeepImmutable<Matrix>): Matrix;
  4597. /**
  4598. * Copy the current matrix from the given one
  4599. * @param other defines the source matrix
  4600. * @returns the current updated matrix
  4601. */
  4602. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4603. /**
  4604. * Populates the given array from the starting index with the current matrix values
  4605. * @param array defines the target array
  4606. * @param offset defines the offset in the target array where to start storing values
  4607. * @returns the current matrix
  4608. */
  4609. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4610. /**
  4611. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4612. * @param other defines the second operand
  4613. * @param result defines the matrix where to store the multiplication
  4614. * @returns the current matrix
  4615. */
  4616. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4617. /**
  4618. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4619. * @param other defines the second operand
  4620. * @param result defines the array where to store the multiplication
  4621. * @param offset defines the offset in the target array where to start storing values
  4622. * @returns the current matrix
  4623. */
  4624. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4625. /**
  4626. * Check equality between this matrix and a second one
  4627. * @param value defines the second matrix to compare
  4628. * @returns true is the current matrix and the given one values are strictly equal
  4629. */
  4630. equals(value: DeepImmutable<Matrix>): boolean;
  4631. /**
  4632. * Clone the current matrix
  4633. * @returns a new matrix from the current matrix
  4634. */
  4635. clone(): Matrix;
  4636. /**
  4637. * Returns the name of the current matrix class
  4638. * @returns the string "Matrix"
  4639. */
  4640. getClassName(): string;
  4641. /**
  4642. * Gets the hash code of the current matrix
  4643. * @returns the hash code
  4644. */
  4645. getHashCode(): number;
  4646. /**
  4647. * Decomposes the current Matrix into a translation, rotation and scaling components
  4648. * @param scale defines the scale vector3 given as a reference to update
  4649. * @param rotation defines the rotation quaternion given as a reference to update
  4650. * @param translation defines the translation vector3 given as a reference to update
  4651. * @returns true if operation was successful
  4652. */
  4653. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4654. /**
  4655. * Gets specific row of the matrix
  4656. * @param index defines the number of the row to get
  4657. * @returns the index-th row of the current matrix as a new Vector4
  4658. */
  4659. getRow(index: number): Nullable<Vector4>;
  4660. /**
  4661. * Sets the index-th row of the current matrix to the vector4 values
  4662. * @param index defines the number of the row to set
  4663. * @param row defines the target vector4
  4664. * @returns the updated current matrix
  4665. */
  4666. setRow(index: number, row: Vector4): Matrix;
  4667. /**
  4668. * Compute the transpose of the matrix
  4669. * @returns the new transposed matrix
  4670. */
  4671. transpose(): Matrix;
  4672. /**
  4673. * Compute the transpose of the matrix and store it in a given matrix
  4674. * @param result defines the target matrix
  4675. * @returns the current matrix
  4676. */
  4677. transposeToRef(result: Matrix): Matrix;
  4678. /**
  4679. * Sets the index-th row of the current matrix with the given 4 x float values
  4680. * @param index defines the row index
  4681. * @param x defines the x component to set
  4682. * @param y defines the y component to set
  4683. * @param z defines the z component to set
  4684. * @param w defines the w component to set
  4685. * @returns the updated current matrix
  4686. */
  4687. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4688. /**
  4689. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4690. * @param scale defines the scale factor
  4691. * @returns a new matrix
  4692. */
  4693. scale(scale: number): Matrix;
  4694. /**
  4695. * Scale the current matrix values by a factor to a given result matrix
  4696. * @param scale defines the scale factor
  4697. * @param result defines the matrix to store the result
  4698. * @returns the current matrix
  4699. */
  4700. scaleToRef(scale: number, result: Matrix): Matrix;
  4701. /**
  4702. * Scale the current matrix values by a factor and add the result to a given matrix
  4703. * @param scale defines the scale factor
  4704. * @param result defines the Matrix to store the result
  4705. * @returns the current matrix
  4706. */
  4707. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4708. /**
  4709. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4710. * @param ref matrix to store the result
  4711. */
  4712. toNormalMatrix(ref: Matrix): void;
  4713. /**
  4714. * Gets only rotation part of the current matrix
  4715. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4716. */
  4717. getRotationMatrix(): Matrix;
  4718. /**
  4719. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4720. * @param result defines the target matrix to store data to
  4721. * @returns the current matrix
  4722. */
  4723. getRotationMatrixToRef(result: Matrix): Matrix;
  4724. /**
  4725. * Toggles model matrix from being right handed to left handed in place and vice versa
  4726. */
  4727. toggleModelMatrixHandInPlace(): void;
  4728. /**
  4729. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4730. */
  4731. toggleProjectionMatrixHandInPlace(): void;
  4732. /**
  4733. * Creates a matrix from an array
  4734. * @param array defines the source array
  4735. * @param offset defines an offset in the source array
  4736. * @returns a new Matrix set from the starting index of the given array
  4737. */
  4738. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4739. /**
  4740. * Copy the content of an array into a given matrix
  4741. * @param array defines the source array
  4742. * @param offset defines an offset in the source array
  4743. * @param result defines the target matrix
  4744. */
  4745. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4746. /**
  4747. * Stores an array into a matrix after having multiplied each component by a given factor
  4748. * @param array defines the source array
  4749. * @param offset defines the offset in the source array
  4750. * @param scale defines the scaling factor
  4751. * @param result defines the target matrix
  4752. */
  4753. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4754. /**
  4755. * Gets an identity matrix that must not be updated
  4756. */
  4757. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4758. /**
  4759. * Stores a list of values (16) inside a given matrix
  4760. * @param initialM11 defines 1st value of 1st row
  4761. * @param initialM12 defines 2nd value of 1st row
  4762. * @param initialM13 defines 3rd value of 1st row
  4763. * @param initialM14 defines 4th value of 1st row
  4764. * @param initialM21 defines 1st value of 2nd row
  4765. * @param initialM22 defines 2nd value of 2nd row
  4766. * @param initialM23 defines 3rd value of 2nd row
  4767. * @param initialM24 defines 4th value of 2nd row
  4768. * @param initialM31 defines 1st value of 3rd row
  4769. * @param initialM32 defines 2nd value of 3rd row
  4770. * @param initialM33 defines 3rd value of 3rd row
  4771. * @param initialM34 defines 4th value of 3rd row
  4772. * @param initialM41 defines 1st value of 4th row
  4773. * @param initialM42 defines 2nd value of 4th row
  4774. * @param initialM43 defines 3rd value of 4th row
  4775. * @param initialM44 defines 4th value of 4th row
  4776. * @param result defines the target matrix
  4777. */
  4778. 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;
  4779. /**
  4780. * Creates new matrix from a list of values (16)
  4781. * @param initialM11 defines 1st value of 1st row
  4782. * @param initialM12 defines 2nd value of 1st row
  4783. * @param initialM13 defines 3rd value of 1st row
  4784. * @param initialM14 defines 4th value of 1st row
  4785. * @param initialM21 defines 1st value of 2nd row
  4786. * @param initialM22 defines 2nd value of 2nd row
  4787. * @param initialM23 defines 3rd value of 2nd row
  4788. * @param initialM24 defines 4th value of 2nd row
  4789. * @param initialM31 defines 1st value of 3rd row
  4790. * @param initialM32 defines 2nd value of 3rd row
  4791. * @param initialM33 defines 3rd value of 3rd row
  4792. * @param initialM34 defines 4th value of 3rd row
  4793. * @param initialM41 defines 1st value of 4th row
  4794. * @param initialM42 defines 2nd value of 4th row
  4795. * @param initialM43 defines 3rd value of 4th row
  4796. * @param initialM44 defines 4th value of 4th row
  4797. * @returns the new matrix
  4798. */
  4799. 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;
  4800. /**
  4801. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4802. * @param scale defines the scale vector3
  4803. * @param rotation defines the rotation quaternion
  4804. * @param translation defines the translation vector3
  4805. * @returns a new matrix
  4806. */
  4807. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4808. /**
  4809. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4810. * @param scale defines the scale vector3
  4811. * @param rotation defines the rotation quaternion
  4812. * @param translation defines the translation vector3
  4813. * @param result defines the target matrix
  4814. */
  4815. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4816. /**
  4817. * Creates a new identity matrix
  4818. * @returns a new identity matrix
  4819. */
  4820. static Identity(): Matrix;
  4821. /**
  4822. * Creates a new identity matrix and stores the result in a given matrix
  4823. * @param result defines the target matrix
  4824. */
  4825. static IdentityToRef(result: Matrix): void;
  4826. /**
  4827. * Creates a new zero matrix
  4828. * @returns a new zero matrix
  4829. */
  4830. static Zero(): Matrix;
  4831. /**
  4832. * Creates a new rotation matrix for "angle" radians around the X axis
  4833. * @param angle defines the angle (in radians) to use
  4834. * @return the new matrix
  4835. */
  4836. static RotationX(angle: number): Matrix;
  4837. /**
  4838. * Creates a new matrix as the invert of a given matrix
  4839. * @param source defines the source matrix
  4840. * @returns the new matrix
  4841. */
  4842. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4843. /**
  4844. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4845. * @param angle defines the angle (in radians) to use
  4846. * @param result defines the target matrix
  4847. */
  4848. static RotationXToRef(angle: number, result: Matrix): void;
  4849. /**
  4850. * Creates a new rotation matrix for "angle" radians around the Y axis
  4851. * @param angle defines the angle (in radians) to use
  4852. * @return the new matrix
  4853. */
  4854. static RotationY(angle: number): Matrix;
  4855. /**
  4856. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4857. * @param angle defines the angle (in radians) to use
  4858. * @param result defines the target matrix
  4859. */
  4860. static RotationYToRef(angle: number, result: Matrix): void;
  4861. /**
  4862. * Creates a new rotation matrix for "angle" radians around the Z axis
  4863. * @param angle defines the angle (in radians) to use
  4864. * @return the new matrix
  4865. */
  4866. static RotationZ(angle: number): Matrix;
  4867. /**
  4868. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4869. * @param angle defines the angle (in radians) to use
  4870. * @param result defines the target matrix
  4871. */
  4872. static RotationZToRef(angle: number, result: Matrix): void;
  4873. /**
  4874. * Creates a new rotation matrix for "angle" radians around the given axis
  4875. * @param axis defines the axis to use
  4876. * @param angle defines the angle (in radians) to use
  4877. * @return the new matrix
  4878. */
  4879. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4880. /**
  4881. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4882. * @param axis defines the axis to use
  4883. * @param angle defines the angle (in radians) to use
  4884. * @param result defines the target matrix
  4885. */
  4886. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4887. /**
  4888. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4889. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4890. * @param from defines the vector to align
  4891. * @param to defines the vector to align to
  4892. * @param result defines the target matrix
  4893. */
  4894. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4895. /**
  4896. * Creates a rotation matrix
  4897. * @param yaw defines the yaw angle in radians (Y axis)
  4898. * @param pitch defines the pitch angle in radians (X axis)
  4899. * @param roll defines the roll angle in radians (Z axis)
  4900. * @returns the new rotation matrix
  4901. */
  4902. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4903. /**
  4904. * Creates a rotation matrix and stores it in a given matrix
  4905. * @param yaw defines the yaw angle in radians (Y axis)
  4906. * @param pitch defines the pitch angle in radians (X axis)
  4907. * @param roll defines the roll angle in radians (Z axis)
  4908. * @param result defines the target matrix
  4909. */
  4910. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4911. /**
  4912. * Creates a scaling matrix
  4913. * @param x defines the scale factor on X axis
  4914. * @param y defines the scale factor on Y axis
  4915. * @param z defines the scale factor on Z axis
  4916. * @returns the new matrix
  4917. */
  4918. static Scaling(x: number, y: number, z: number): Matrix;
  4919. /**
  4920. * Creates a scaling matrix and stores it in a given matrix
  4921. * @param x defines the scale factor on X axis
  4922. * @param y defines the scale factor on Y axis
  4923. * @param z defines the scale factor on Z axis
  4924. * @param result defines the target matrix
  4925. */
  4926. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4927. /**
  4928. * Creates a translation matrix
  4929. * @param x defines the translation on X axis
  4930. * @param y defines the translation on Y axis
  4931. * @param z defines the translationon Z axis
  4932. * @returns the new matrix
  4933. */
  4934. static Translation(x: number, y: number, z: number): Matrix;
  4935. /**
  4936. * Creates a translation matrix and stores it in a given matrix
  4937. * @param x defines the translation on X axis
  4938. * @param y defines the translation on Y axis
  4939. * @param z defines the translationon Z axis
  4940. * @param result defines the target matrix
  4941. */
  4942. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4943. /**
  4944. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4945. * @param startValue defines the start value
  4946. * @param endValue defines the end value
  4947. * @param gradient defines the gradient factor
  4948. * @returns the new matrix
  4949. */
  4950. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4951. /**
  4952. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4953. * @param startValue defines the start value
  4954. * @param endValue defines the end value
  4955. * @param gradient defines the gradient factor
  4956. * @param result defines the Matrix object where to store data
  4957. */
  4958. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4959. /**
  4960. * Builds a new matrix whose values are computed by:
  4961. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4962. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4963. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4964. * @param startValue defines the first matrix
  4965. * @param endValue defines the second matrix
  4966. * @param gradient defines the gradient between the two matrices
  4967. * @returns the new matrix
  4968. */
  4969. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4970. /**
  4971. * Update a matrix to values which are computed by:
  4972. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4973. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4974. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4975. * @param startValue defines the first matrix
  4976. * @param endValue defines the second matrix
  4977. * @param gradient defines the gradient between the two matrices
  4978. * @param result defines the target matrix
  4979. */
  4980. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4981. /**
  4982. * 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"
  4983. * This function works in left handed mode
  4984. * @param eye defines the final position of the entity
  4985. * @param target defines where the entity should look at
  4986. * @param up defines the up vector for the entity
  4987. * @returns the new matrix
  4988. */
  4989. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4990. /**
  4991. * 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".
  4992. * This function works in left handed mode
  4993. * @param eye defines the final position of the entity
  4994. * @param target defines where the entity should look at
  4995. * @param up defines the up vector for the entity
  4996. * @param result defines the target matrix
  4997. */
  4998. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4999. /**
  5000. * 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"
  5001. * This function works in right handed mode
  5002. * @param eye defines the final position of the entity
  5003. * @param target defines where the entity should look at
  5004. * @param up defines the up vector for the entity
  5005. * @returns the new matrix
  5006. */
  5007. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5008. /**
  5009. * 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".
  5010. * This function works in right handed mode
  5011. * @param eye defines the final position of the entity
  5012. * @param target defines where the entity should look at
  5013. * @param up defines the up vector for the entity
  5014. * @param result defines the target matrix
  5015. */
  5016. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5017. /**
  5018. * Create a left-handed orthographic projection matrix
  5019. * @param width defines the viewport width
  5020. * @param height defines the viewport height
  5021. * @param znear defines the near clip plane
  5022. * @param zfar defines the far clip plane
  5023. * @returns a new matrix as a left-handed orthographic projection matrix
  5024. */
  5025. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5026. /**
  5027. * Store a left-handed orthographic projection to a given matrix
  5028. * @param width defines the viewport width
  5029. * @param height defines the viewport height
  5030. * @param znear defines the near clip plane
  5031. * @param zfar defines the far clip plane
  5032. * @param result defines the target matrix
  5033. */
  5034. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5035. /**
  5036. * Create a left-handed orthographic projection matrix
  5037. * @param left defines the viewport left coordinate
  5038. * @param right defines the viewport right coordinate
  5039. * @param bottom defines the viewport bottom coordinate
  5040. * @param top defines the viewport top coordinate
  5041. * @param znear defines the near clip plane
  5042. * @param zfar defines the far clip plane
  5043. * @returns a new matrix as a left-handed orthographic projection matrix
  5044. */
  5045. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5046. /**
  5047. * Stores a left-handed orthographic projection into a given matrix
  5048. * @param left defines the viewport left coordinate
  5049. * @param right defines the viewport right coordinate
  5050. * @param bottom defines the viewport bottom coordinate
  5051. * @param top defines the viewport top coordinate
  5052. * @param znear defines the near clip plane
  5053. * @param zfar defines the far clip plane
  5054. * @param result defines the target matrix
  5055. */
  5056. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5057. /**
  5058. * Creates a right-handed orthographic projection matrix
  5059. * @param left defines the viewport left coordinate
  5060. * @param right defines the viewport right coordinate
  5061. * @param bottom defines the viewport bottom coordinate
  5062. * @param top defines the viewport top coordinate
  5063. * @param znear defines the near clip plane
  5064. * @param zfar defines the far clip plane
  5065. * @returns a new matrix as a right-handed orthographic projection matrix
  5066. */
  5067. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5068. /**
  5069. * Stores a right-handed orthographic projection into a given matrix
  5070. * @param left defines the viewport left coordinate
  5071. * @param right defines the viewport right coordinate
  5072. * @param bottom defines the viewport bottom coordinate
  5073. * @param top defines the viewport top coordinate
  5074. * @param znear defines the near clip plane
  5075. * @param zfar defines the far clip plane
  5076. * @param result defines the target matrix
  5077. */
  5078. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5079. /**
  5080. * Creates a left-handed perspective projection matrix
  5081. * @param width defines the viewport width
  5082. * @param height defines the viewport height
  5083. * @param znear defines the near clip plane
  5084. * @param zfar defines the far clip plane
  5085. * @returns a new matrix as a left-handed perspective projection matrix
  5086. */
  5087. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5088. /**
  5089. * Creates a left-handed perspective projection matrix
  5090. * @param fov defines the horizontal field of view
  5091. * @param aspect defines the aspect ratio
  5092. * @param znear defines the near clip plane
  5093. * @param zfar defines the far clip plane
  5094. * @returns a new matrix as a left-handed perspective projection matrix
  5095. */
  5096. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5097. /**
  5098. * Stores a left-handed perspective projection into a given matrix
  5099. * @param fov defines the horizontal field of view
  5100. * @param aspect defines the aspect ratio
  5101. * @param znear defines the near clip plane
  5102. * @param zfar defines the far clip plane
  5103. * @param result defines the target matrix
  5104. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5105. */
  5106. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5107. /**
  5108. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5109. * @param fov defines the horizontal field of view
  5110. * @param aspect defines the aspect ratio
  5111. * @param znear defines the near clip plane
  5112. * @param zfar not used as infinity is used as far clip
  5113. * @param result defines the target matrix
  5114. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5115. */
  5116. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5117. /**
  5118. * Creates a right-handed perspective projection matrix
  5119. * @param fov defines the horizontal field of view
  5120. * @param aspect defines the aspect ratio
  5121. * @param znear defines the near clip plane
  5122. * @param zfar defines the far clip plane
  5123. * @returns a new matrix as a right-handed perspective projection matrix
  5124. */
  5125. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5126. /**
  5127. * Stores a right-handed perspective projection into a given matrix
  5128. * @param fov defines the horizontal field of view
  5129. * @param aspect defines the aspect ratio
  5130. * @param znear defines the near clip plane
  5131. * @param zfar defines the far clip plane
  5132. * @param result defines the target matrix
  5133. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5134. */
  5135. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5136. /**
  5137. * Stores a right-handed perspective projection into a given matrix
  5138. * @param fov defines the horizontal field of view
  5139. * @param aspect defines the aspect ratio
  5140. * @param znear defines the near clip plane
  5141. * @param zfar not used as infinity is used as far clip
  5142. * @param result defines the target matrix
  5143. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5144. */
  5145. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5146. /**
  5147. * Stores a perspective projection for WebVR info a given matrix
  5148. * @param fov defines the field of view
  5149. * @param znear defines the near clip plane
  5150. * @param zfar defines the far clip plane
  5151. * @param result defines the target matrix
  5152. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5153. */
  5154. static PerspectiveFovWebVRToRef(fov: {
  5155. upDegrees: number;
  5156. downDegrees: number;
  5157. leftDegrees: number;
  5158. rightDegrees: number;
  5159. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5160. /**
  5161. * Computes a complete transformation matrix
  5162. * @param viewport defines the viewport to use
  5163. * @param world defines the world matrix
  5164. * @param view defines the view matrix
  5165. * @param projection defines the projection matrix
  5166. * @param zmin defines the near clip plane
  5167. * @param zmax defines the far clip plane
  5168. * @returns the transformation matrix
  5169. */
  5170. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5171. /**
  5172. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5173. * @param matrix defines the matrix to use
  5174. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5175. */
  5176. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5177. /**
  5178. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5179. * @param matrix defines the matrix to use
  5180. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5181. */
  5182. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5183. /**
  5184. * Compute the transpose of a given matrix
  5185. * @param matrix defines the matrix to transpose
  5186. * @returns the new matrix
  5187. */
  5188. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5189. /**
  5190. * Compute the transpose of a matrix and store it in a target matrix
  5191. * @param matrix defines the matrix to transpose
  5192. * @param result defines the target matrix
  5193. */
  5194. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5195. /**
  5196. * Computes a reflection matrix from a plane
  5197. * @param plane defines the reflection plane
  5198. * @returns a new matrix
  5199. */
  5200. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5201. /**
  5202. * Computes a reflection matrix from a plane
  5203. * @param plane defines the reflection plane
  5204. * @param result defines the target matrix
  5205. */
  5206. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5207. /**
  5208. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5209. * @param xaxis defines the value of the 1st axis
  5210. * @param yaxis defines the value of the 2nd axis
  5211. * @param zaxis defines the value of the 3rd axis
  5212. * @param result defines the target matrix
  5213. */
  5214. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5215. /**
  5216. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5217. * @param quat defines the quaternion to use
  5218. * @param result defines the target matrix
  5219. */
  5220. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5221. }
  5222. /**
  5223. * @hidden
  5224. */
  5225. export class TmpVectors {
  5226. static Vector2: Vector2[];
  5227. static Vector3: Vector3[];
  5228. static Vector4: Vector4[];
  5229. static Quaternion: Quaternion[];
  5230. static Matrix: Matrix[];
  5231. }
  5232. }
  5233. declare module BABYLON {
  5234. /**
  5235. * Defines potential orientation for back face culling
  5236. */
  5237. export enum Orientation {
  5238. /**
  5239. * Clockwise
  5240. */
  5241. CW = 0,
  5242. /** Counter clockwise */
  5243. CCW = 1
  5244. }
  5245. /** Class used to represent a Bezier curve */
  5246. export class BezierCurve {
  5247. /**
  5248. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5249. * @param t defines the time
  5250. * @param x1 defines the left coordinate on X axis
  5251. * @param y1 defines the left coordinate on Y axis
  5252. * @param x2 defines the right coordinate on X axis
  5253. * @param y2 defines the right coordinate on Y axis
  5254. * @returns the interpolated value
  5255. */
  5256. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5257. }
  5258. /**
  5259. * Defines angle representation
  5260. */
  5261. export class Angle {
  5262. private _radians;
  5263. /**
  5264. * Creates an Angle object of "radians" radians (float).
  5265. * @param radians the angle in radians
  5266. */
  5267. constructor(radians: number);
  5268. /**
  5269. * Get value in degrees
  5270. * @returns the Angle value in degrees (float)
  5271. */
  5272. degrees(): number;
  5273. /**
  5274. * Get value in radians
  5275. * @returns the Angle value in radians (float)
  5276. */
  5277. radians(): number;
  5278. /**
  5279. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5280. * @param a defines first point as the origin
  5281. * @param b defines point
  5282. * @returns a new Angle
  5283. */
  5284. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5285. /**
  5286. * Gets a new Angle object from the given float in radians
  5287. * @param radians defines the angle value in radians
  5288. * @returns a new Angle
  5289. */
  5290. static FromRadians(radians: number): Angle;
  5291. /**
  5292. * Gets a new Angle object from the given float in degrees
  5293. * @param degrees defines the angle value in degrees
  5294. * @returns a new Angle
  5295. */
  5296. static FromDegrees(degrees: number): Angle;
  5297. }
  5298. /**
  5299. * This represents an arc in a 2d space.
  5300. */
  5301. export class Arc2 {
  5302. /** Defines the start point of the arc */
  5303. startPoint: Vector2;
  5304. /** Defines the mid point of the arc */
  5305. midPoint: Vector2;
  5306. /** Defines the end point of the arc */
  5307. endPoint: Vector2;
  5308. /**
  5309. * Defines the center point of the arc.
  5310. */
  5311. centerPoint: Vector2;
  5312. /**
  5313. * Defines the radius of the arc.
  5314. */
  5315. radius: number;
  5316. /**
  5317. * Defines the angle of the arc (from mid point to end point).
  5318. */
  5319. angle: Angle;
  5320. /**
  5321. * Defines the start angle of the arc (from start point to middle point).
  5322. */
  5323. startAngle: Angle;
  5324. /**
  5325. * Defines the orientation of the arc (clock wise/counter clock wise).
  5326. */
  5327. orientation: Orientation;
  5328. /**
  5329. * Creates an Arc object from the three given points : start, middle and end.
  5330. * @param startPoint Defines the start point of the arc
  5331. * @param midPoint Defines the midlle point of the arc
  5332. * @param endPoint Defines the end point of the arc
  5333. */
  5334. constructor(
  5335. /** Defines the start point of the arc */
  5336. startPoint: Vector2,
  5337. /** Defines the mid point of the arc */
  5338. midPoint: Vector2,
  5339. /** Defines the end point of the arc */
  5340. endPoint: Vector2);
  5341. }
  5342. /**
  5343. * Represents a 2D path made up of multiple 2D points
  5344. */
  5345. export class Path2 {
  5346. private _points;
  5347. private _length;
  5348. /**
  5349. * If the path start and end point are the same
  5350. */
  5351. closed: boolean;
  5352. /**
  5353. * Creates a Path2 object from the starting 2D coordinates x and y.
  5354. * @param x the starting points x value
  5355. * @param y the starting points y value
  5356. */
  5357. constructor(x: number, y: number);
  5358. /**
  5359. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5360. * @param x the added points x value
  5361. * @param y the added points y value
  5362. * @returns the updated Path2.
  5363. */
  5364. addLineTo(x: number, y: number): Path2;
  5365. /**
  5366. * 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.
  5367. * @param midX middle point x value
  5368. * @param midY middle point y value
  5369. * @param endX end point x value
  5370. * @param endY end point y value
  5371. * @param numberOfSegments (default: 36)
  5372. * @returns the updated Path2.
  5373. */
  5374. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5375. /**
  5376. * Closes the Path2.
  5377. * @returns the Path2.
  5378. */
  5379. close(): Path2;
  5380. /**
  5381. * Gets the sum of the distance between each sequential point in the path
  5382. * @returns the Path2 total length (float).
  5383. */
  5384. length(): number;
  5385. /**
  5386. * Gets the points which construct the path
  5387. * @returns the Path2 internal array of points.
  5388. */
  5389. getPoints(): Vector2[];
  5390. /**
  5391. * Retreives the point at the distance aways from the starting point
  5392. * @param normalizedLengthPosition the length along the path to retreive the point from
  5393. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5394. */
  5395. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5396. /**
  5397. * Creates a new path starting from an x and y position
  5398. * @param x starting x value
  5399. * @param y starting y value
  5400. * @returns a new Path2 starting at the coordinates (x, y).
  5401. */
  5402. static StartingAt(x: number, y: number): Path2;
  5403. }
  5404. /**
  5405. * Represents a 3D path made up of multiple 3D points
  5406. */
  5407. export class Path3D {
  5408. /**
  5409. * an array of Vector3, the curve axis of the Path3D
  5410. */
  5411. path: Vector3[];
  5412. private _curve;
  5413. private _distances;
  5414. private _tangents;
  5415. private _normals;
  5416. private _binormals;
  5417. private _raw;
  5418. private _alignTangentsWithPath;
  5419. private readonly _pointAtData;
  5420. /**
  5421. * new Path3D(path, normal, raw)
  5422. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5423. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5424. * @param path an array of Vector3, the curve axis of the Path3D
  5425. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5426. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5427. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5428. */
  5429. constructor(
  5430. /**
  5431. * an array of Vector3, the curve axis of the Path3D
  5432. */
  5433. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5434. /**
  5435. * Returns the Path3D array of successive Vector3 designing its curve.
  5436. * @returns the Path3D array of successive Vector3 designing its curve.
  5437. */
  5438. getCurve(): Vector3[];
  5439. /**
  5440. * Returns the Path3D array of successive Vector3 designing its curve.
  5441. * @returns the Path3D array of successive Vector3 designing its curve.
  5442. */
  5443. getPoints(): Vector3[];
  5444. /**
  5445. * @returns the computed length (float) of the path.
  5446. */
  5447. length(): number;
  5448. /**
  5449. * Returns an array populated with tangent vectors on each Path3D curve point.
  5450. * @returns an array populated with tangent vectors on each Path3D curve point.
  5451. */
  5452. getTangents(): Vector3[];
  5453. /**
  5454. * Returns an array populated with normal vectors on each Path3D curve point.
  5455. * @returns an array populated with normal vectors on each Path3D curve point.
  5456. */
  5457. getNormals(): Vector3[];
  5458. /**
  5459. * Returns an array populated with binormal vectors on each Path3D curve point.
  5460. * @returns an array populated with binormal vectors on each Path3D curve point.
  5461. */
  5462. getBinormals(): Vector3[];
  5463. /**
  5464. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5465. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5466. */
  5467. getDistances(): number[];
  5468. /**
  5469. * Returns an interpolated point along this path
  5470. * @param position the position of the point along this path, from 0.0 to 1.0
  5471. * @returns a new Vector3 as the point
  5472. */
  5473. getPointAt(position: number): Vector3;
  5474. /**
  5475. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5476. * @param position the position of the point along this path, from 0.0 to 1.0
  5477. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5478. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5479. */
  5480. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5481. /**
  5482. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5483. * @param position the position of the point along this path, from 0.0 to 1.0
  5484. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5485. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5486. */
  5487. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5488. /**
  5489. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5490. * @param position the position of the point along this path, from 0.0 to 1.0
  5491. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5492. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5493. */
  5494. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5495. /**
  5496. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5497. * @param position the position of the point along this path, from 0.0 to 1.0
  5498. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5499. */
  5500. getDistanceAt(position: number): number;
  5501. /**
  5502. * Returns the array index of the previous point of an interpolated point along this path
  5503. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5504. * @returns the array index
  5505. */
  5506. getPreviousPointIndexAt(position: number): number;
  5507. /**
  5508. * 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)
  5509. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5510. * @returns the sub position
  5511. */
  5512. getSubPositionAt(position: number): number;
  5513. /**
  5514. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5515. * @param target the vector of which to get the closest position to
  5516. * @returns the position of the closest virtual point on this path to the target vector
  5517. */
  5518. getClosestPositionTo(target: Vector3): number;
  5519. /**
  5520. * Returns a sub path (slice) of this path
  5521. * @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
  5522. * @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
  5523. * @returns a sub path (slice) of this path
  5524. */
  5525. slice(start?: number, end?: number): Path3D;
  5526. /**
  5527. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5528. * @param path path which all values are copied into the curves points
  5529. * @param firstNormal which should be projected onto the curve
  5530. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5531. * @returns the same object updated.
  5532. */
  5533. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5534. private _compute;
  5535. private _getFirstNonNullVector;
  5536. private _getLastNonNullVector;
  5537. private _normalVector;
  5538. /**
  5539. * Updates the point at data for an interpolated point along this curve
  5540. * @param position the position of the point along this curve, from 0.0 to 1.0
  5541. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5542. * @returns the (updated) point at data
  5543. */
  5544. private _updatePointAtData;
  5545. /**
  5546. * Updates the point at data from the specified parameters
  5547. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5548. * @param point the interpolated point
  5549. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5550. */
  5551. private _setPointAtData;
  5552. /**
  5553. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5554. */
  5555. private _updateInterpolationMatrix;
  5556. }
  5557. /**
  5558. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5559. * A Curve3 is designed from a series of successive Vector3.
  5560. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5561. */
  5562. export class Curve3 {
  5563. private _points;
  5564. private _length;
  5565. /**
  5566. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5567. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5568. * @param v1 (Vector3) the control point
  5569. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5570. * @param nbPoints (integer) the wanted number of points in the curve
  5571. * @returns the created Curve3
  5572. */
  5573. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5574. /**
  5575. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5576. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5577. * @param v1 (Vector3) the first control point
  5578. * @param v2 (Vector3) the second control point
  5579. * @param v3 (Vector3) the end point of the Cubic Bezier
  5580. * @param nbPoints (integer) the wanted number of points in the curve
  5581. * @returns the created Curve3
  5582. */
  5583. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5584. /**
  5585. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5586. * @param p1 (Vector3) the origin point of the Hermite Spline
  5587. * @param t1 (Vector3) the tangent vector at the origin point
  5588. * @param p2 (Vector3) the end point of the Hermite Spline
  5589. * @param t2 (Vector3) the tangent vector at the end point
  5590. * @param nbPoints (integer) the wanted number of points in the curve
  5591. * @returns the created Curve3
  5592. */
  5593. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5594. /**
  5595. * Returns a Curve3 object along a CatmullRom Spline curve :
  5596. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5597. * @param nbPoints (integer) the wanted number of points between each curve control points
  5598. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5599. * @returns the created Curve3
  5600. */
  5601. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5602. /**
  5603. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5604. * A Curve3 is designed from a series of successive Vector3.
  5605. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5606. * @param points points which make up the curve
  5607. */
  5608. constructor(points: Vector3[]);
  5609. /**
  5610. * @returns the Curve3 stored array of successive Vector3
  5611. */
  5612. getPoints(): Vector3[];
  5613. /**
  5614. * @returns the computed length (float) of the curve.
  5615. */
  5616. length(): number;
  5617. /**
  5618. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5619. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5620. * curveA and curveB keep unchanged.
  5621. * @param curve the curve to continue from this curve
  5622. * @returns the newly constructed curve
  5623. */
  5624. continue(curve: DeepImmutable<Curve3>): Curve3;
  5625. private _computeLength;
  5626. }
  5627. }
  5628. declare module BABYLON {
  5629. /**
  5630. * This represents the main contract an easing function should follow.
  5631. * Easing functions are used throughout the animation system.
  5632. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5633. */
  5634. export interface IEasingFunction {
  5635. /**
  5636. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5637. * of the easing function.
  5638. * The link below provides some of the most common examples of easing functions.
  5639. * @see https://easings.net/
  5640. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5641. * @returns the corresponding value on the curve defined by the easing function
  5642. */
  5643. ease(gradient: number): number;
  5644. }
  5645. /**
  5646. * Base class used for every default easing function.
  5647. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5648. */
  5649. export class EasingFunction implements IEasingFunction {
  5650. /**
  5651. * Interpolation follows the mathematical formula associated with the easing function.
  5652. */
  5653. static readonly EASINGMODE_EASEIN: number;
  5654. /**
  5655. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5656. */
  5657. static readonly EASINGMODE_EASEOUT: number;
  5658. /**
  5659. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5660. */
  5661. static readonly EASINGMODE_EASEINOUT: number;
  5662. private _easingMode;
  5663. /**
  5664. * Sets the easing mode of the current function.
  5665. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5666. */
  5667. setEasingMode(easingMode: number): void;
  5668. /**
  5669. * Gets the current easing mode.
  5670. * @returns the easing mode
  5671. */
  5672. getEasingMode(): number;
  5673. /**
  5674. * @hidden
  5675. */
  5676. easeInCore(gradient: number): number;
  5677. /**
  5678. * Given an input gradient between 0 and 1, this returns the corresponding value
  5679. * of the easing function.
  5680. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5681. * @returns the corresponding value on the curve defined by the easing function
  5682. */
  5683. ease(gradient: number): number;
  5684. }
  5685. /**
  5686. * Easing function with a circle shape (see link below).
  5687. * @see https://easings.net/#easeInCirc
  5688. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5689. */
  5690. export class CircleEase extends EasingFunction implements IEasingFunction {
  5691. /** @hidden */
  5692. easeInCore(gradient: number): number;
  5693. }
  5694. /**
  5695. * Easing function with a ease back shape (see link below).
  5696. * @see https://easings.net/#easeInBack
  5697. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5698. */
  5699. export class BackEase extends EasingFunction implements IEasingFunction {
  5700. /** Defines the amplitude of the function */
  5701. amplitude: number;
  5702. /**
  5703. * Instantiates a back ease easing
  5704. * @see https://easings.net/#easeInBack
  5705. * @param amplitude Defines the amplitude of the function
  5706. */
  5707. constructor(
  5708. /** Defines the amplitude of the function */
  5709. amplitude?: number);
  5710. /** @hidden */
  5711. easeInCore(gradient: number): number;
  5712. }
  5713. /**
  5714. * Easing function with a bouncing shape (see link below).
  5715. * @see https://easings.net/#easeInBounce
  5716. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5717. */
  5718. export class BounceEase extends EasingFunction implements IEasingFunction {
  5719. /** Defines the number of bounces */
  5720. bounces: number;
  5721. /** Defines the amplitude of the bounce */
  5722. bounciness: number;
  5723. /**
  5724. * Instantiates a bounce easing
  5725. * @see https://easings.net/#easeInBounce
  5726. * @param bounces Defines the number of bounces
  5727. * @param bounciness Defines the amplitude of the bounce
  5728. */
  5729. constructor(
  5730. /** Defines the number of bounces */
  5731. bounces?: number,
  5732. /** Defines the amplitude of the bounce */
  5733. bounciness?: number);
  5734. /** @hidden */
  5735. easeInCore(gradient: number): number;
  5736. }
  5737. /**
  5738. * Easing function with a power of 3 shape (see link below).
  5739. * @see https://easings.net/#easeInCubic
  5740. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5741. */
  5742. export class CubicEase extends EasingFunction implements IEasingFunction {
  5743. /** @hidden */
  5744. easeInCore(gradient: number): number;
  5745. }
  5746. /**
  5747. * Easing function with an elastic shape (see link below).
  5748. * @see https://easings.net/#easeInElastic
  5749. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5750. */
  5751. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5752. /** Defines the number of oscillations*/
  5753. oscillations: number;
  5754. /** Defines the amplitude of the oscillations*/
  5755. springiness: number;
  5756. /**
  5757. * Instantiates an elastic easing function
  5758. * @see https://easings.net/#easeInElastic
  5759. * @param oscillations Defines the number of oscillations
  5760. * @param springiness Defines the amplitude of the oscillations
  5761. */
  5762. constructor(
  5763. /** Defines the number of oscillations*/
  5764. oscillations?: number,
  5765. /** Defines the amplitude of the oscillations*/
  5766. springiness?: number);
  5767. /** @hidden */
  5768. easeInCore(gradient: number): number;
  5769. }
  5770. /**
  5771. * Easing function with an exponential shape (see link below).
  5772. * @see https://easings.net/#easeInExpo
  5773. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5774. */
  5775. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5776. /** Defines the exponent of the function */
  5777. exponent: number;
  5778. /**
  5779. * Instantiates an exponential easing function
  5780. * @see https://easings.net/#easeInExpo
  5781. * @param exponent Defines the exponent of the function
  5782. */
  5783. constructor(
  5784. /** Defines the exponent of the function */
  5785. exponent?: number);
  5786. /** @hidden */
  5787. easeInCore(gradient: number): number;
  5788. }
  5789. /**
  5790. * Easing function with a power shape (see link below).
  5791. * @see https://easings.net/#easeInQuad
  5792. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5793. */
  5794. export class PowerEase extends EasingFunction implements IEasingFunction {
  5795. /** Defines the power of the function */
  5796. power: number;
  5797. /**
  5798. * Instantiates an power base easing function
  5799. * @see https://easings.net/#easeInQuad
  5800. * @param power Defines the power of the function
  5801. */
  5802. constructor(
  5803. /** Defines the power of the function */
  5804. power?: number);
  5805. /** @hidden */
  5806. easeInCore(gradient: number): number;
  5807. }
  5808. /**
  5809. * Easing function with a power of 2 shape (see link below).
  5810. * @see https://easings.net/#easeInQuad
  5811. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5812. */
  5813. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5814. /** @hidden */
  5815. easeInCore(gradient: number): number;
  5816. }
  5817. /**
  5818. * Easing function with a power of 4 shape (see link below).
  5819. * @see https://easings.net/#easeInQuart
  5820. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5821. */
  5822. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5823. /** @hidden */
  5824. easeInCore(gradient: number): number;
  5825. }
  5826. /**
  5827. * Easing function with a power of 5 shape (see link below).
  5828. * @see https://easings.net/#easeInQuint
  5829. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5830. */
  5831. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5832. /** @hidden */
  5833. easeInCore(gradient: number): number;
  5834. }
  5835. /**
  5836. * Easing function with a sin shape (see link below).
  5837. * @see https://easings.net/#easeInSine
  5838. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5839. */
  5840. export class SineEase extends EasingFunction implements IEasingFunction {
  5841. /** @hidden */
  5842. easeInCore(gradient: number): number;
  5843. }
  5844. /**
  5845. * Easing function with a bezier shape (see link below).
  5846. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5847. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5848. */
  5849. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5850. /** Defines the x component of the start tangent in the bezier curve */
  5851. x1: number;
  5852. /** Defines the y component of the start tangent in the bezier curve */
  5853. y1: number;
  5854. /** Defines the x component of the end tangent in the bezier curve */
  5855. x2: number;
  5856. /** Defines the y component of the end tangent in the bezier curve */
  5857. y2: number;
  5858. /**
  5859. * Instantiates a bezier function
  5860. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5861. * @param x1 Defines the x component of the start tangent in the bezier curve
  5862. * @param y1 Defines the y component of the start tangent in the bezier curve
  5863. * @param x2 Defines the x component of the end tangent in the bezier curve
  5864. * @param y2 Defines the y component of the end tangent in the bezier curve
  5865. */
  5866. constructor(
  5867. /** Defines the x component of the start tangent in the bezier curve */
  5868. x1?: number,
  5869. /** Defines the y component of the start tangent in the bezier curve */
  5870. y1?: number,
  5871. /** Defines the x component of the end tangent in the bezier curve */
  5872. x2?: number,
  5873. /** Defines the y component of the end tangent in the bezier curve */
  5874. y2?: number);
  5875. /** @hidden */
  5876. easeInCore(gradient: number): number;
  5877. }
  5878. }
  5879. declare module BABYLON {
  5880. /**
  5881. * Class used to hold a RBG color
  5882. */
  5883. export class Color3 {
  5884. /**
  5885. * Defines the red component (between 0 and 1, default is 0)
  5886. */
  5887. r: number;
  5888. /**
  5889. * Defines the green component (between 0 and 1, default is 0)
  5890. */
  5891. g: number;
  5892. /**
  5893. * Defines the blue component (between 0 and 1, default is 0)
  5894. */
  5895. b: number;
  5896. /**
  5897. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5898. * @param r defines the red component (between 0 and 1, default is 0)
  5899. * @param g defines the green component (between 0 and 1, default is 0)
  5900. * @param b defines the blue component (between 0 and 1, default is 0)
  5901. */
  5902. constructor(
  5903. /**
  5904. * Defines the red component (between 0 and 1, default is 0)
  5905. */
  5906. r?: number,
  5907. /**
  5908. * Defines the green component (between 0 and 1, default is 0)
  5909. */
  5910. g?: number,
  5911. /**
  5912. * Defines the blue component (between 0 and 1, default is 0)
  5913. */
  5914. b?: number);
  5915. /**
  5916. * Creates a string with the Color3 current values
  5917. * @returns the string representation of the Color3 object
  5918. */
  5919. toString(): string;
  5920. /**
  5921. * Returns the string "Color3"
  5922. * @returns "Color3"
  5923. */
  5924. getClassName(): string;
  5925. /**
  5926. * Compute the Color3 hash code
  5927. * @returns an unique number that can be used to hash Color3 objects
  5928. */
  5929. getHashCode(): number;
  5930. /**
  5931. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5932. * @param array defines the array where to store the r,g,b components
  5933. * @param index defines an optional index in the target array to define where to start storing values
  5934. * @returns the current Color3 object
  5935. */
  5936. toArray(array: FloatArray, index?: number): Color3;
  5937. /**
  5938. * Update the current color with values stored in an array from the starting index of the given array
  5939. * @param array defines the source array
  5940. * @param offset defines an offset in the source array
  5941. * @returns the current Color3 object
  5942. */
  5943. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5944. /**
  5945. * Returns a new Color4 object from the current Color3 and the given alpha
  5946. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5947. * @returns a new Color4 object
  5948. */
  5949. toColor4(alpha?: number): Color4;
  5950. /**
  5951. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5952. * @returns the new array
  5953. */
  5954. asArray(): number[];
  5955. /**
  5956. * Returns the luminance value
  5957. * @returns a float value
  5958. */
  5959. toLuminance(): number;
  5960. /**
  5961. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5962. * @param otherColor defines the second operand
  5963. * @returns the new Color3 object
  5964. */
  5965. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5966. /**
  5967. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5968. * @param otherColor defines the second operand
  5969. * @param result defines the Color3 object where to store the result
  5970. * @returns the current Color3
  5971. */
  5972. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5973. /**
  5974. * Determines equality between Color3 objects
  5975. * @param otherColor defines the second operand
  5976. * @returns true if the rgb values are equal to the given ones
  5977. */
  5978. equals(otherColor: DeepImmutable<Color3>): boolean;
  5979. /**
  5980. * Determines equality between the current Color3 object and a set of r,b,g values
  5981. * @param r defines the red component to check
  5982. * @param g defines the green component to check
  5983. * @param b defines the blue component to check
  5984. * @returns true if the rgb values are equal to the given ones
  5985. */
  5986. equalsFloats(r: number, g: number, b: number): boolean;
  5987. /**
  5988. * Multiplies in place each rgb value by scale
  5989. * @param scale defines the scaling factor
  5990. * @returns the updated Color3
  5991. */
  5992. scale(scale: number): Color3;
  5993. /**
  5994. * Multiplies the rgb values by scale and stores the result into "result"
  5995. * @param scale defines the scaling factor
  5996. * @param result defines the Color3 object where to store the result
  5997. * @returns the unmodified current Color3
  5998. */
  5999. scaleToRef(scale: number, result: Color3): Color3;
  6000. /**
  6001. * Scale the current Color3 values by a factor and add the result to a given Color3
  6002. * @param scale defines the scale factor
  6003. * @param result defines color to store the result into
  6004. * @returns the unmodified current Color3
  6005. */
  6006. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6007. /**
  6008. * Clamps the rgb values by the min and max values and stores the result into "result"
  6009. * @param min defines minimum clamping value (default is 0)
  6010. * @param max defines maximum clamping value (default is 1)
  6011. * @param result defines color to store the result into
  6012. * @returns the original Color3
  6013. */
  6014. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6015. /**
  6016. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6017. * @param otherColor defines the second operand
  6018. * @returns the new Color3
  6019. */
  6020. add(otherColor: DeepImmutable<Color3>): Color3;
  6021. /**
  6022. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6023. * @param otherColor defines the second operand
  6024. * @param result defines Color3 object to store the result into
  6025. * @returns the unmodified current Color3
  6026. */
  6027. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6028. /**
  6029. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6030. * @param otherColor defines the second operand
  6031. * @returns the new Color3
  6032. */
  6033. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6034. /**
  6035. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6036. * @param otherColor defines the second operand
  6037. * @param result defines Color3 object to store the result into
  6038. * @returns the unmodified current Color3
  6039. */
  6040. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6041. /**
  6042. * Copy the current object
  6043. * @returns a new Color3 copied the current one
  6044. */
  6045. clone(): Color3;
  6046. /**
  6047. * Copies the rgb values from the source in the current Color3
  6048. * @param source defines the source Color3 object
  6049. * @returns the updated Color3 object
  6050. */
  6051. copyFrom(source: DeepImmutable<Color3>): Color3;
  6052. /**
  6053. * Updates the Color3 rgb values from the given floats
  6054. * @param r defines the red component to read from
  6055. * @param g defines the green component to read from
  6056. * @param b defines the blue component to read from
  6057. * @returns the current Color3 object
  6058. */
  6059. copyFromFloats(r: number, g: number, b: number): Color3;
  6060. /**
  6061. * Updates the Color3 rgb values from the given floats
  6062. * @param r defines the red component to read from
  6063. * @param g defines the green component to read from
  6064. * @param b defines the blue component to read from
  6065. * @returns the current Color3 object
  6066. */
  6067. set(r: number, g: number, b: number): Color3;
  6068. /**
  6069. * Compute the Color3 hexadecimal code as a string
  6070. * @returns a string containing the hexadecimal representation of the Color3 object
  6071. */
  6072. toHexString(): string;
  6073. /**
  6074. * Computes a new Color3 converted from the current one to linear space
  6075. * @returns a new Color3 object
  6076. */
  6077. toLinearSpace(): Color3;
  6078. /**
  6079. * Converts current color in rgb space to HSV values
  6080. * @returns a new color3 representing the HSV values
  6081. */
  6082. toHSV(): Color3;
  6083. /**
  6084. * Converts current color in rgb space to HSV values
  6085. * @param result defines the Color3 where to store the HSV values
  6086. */
  6087. toHSVToRef(result: Color3): void;
  6088. /**
  6089. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6090. * @param convertedColor defines the Color3 object where to store the linear space version
  6091. * @returns the unmodified Color3
  6092. */
  6093. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6094. /**
  6095. * Computes a new Color3 converted from the current one to gamma space
  6096. * @returns a new Color3 object
  6097. */
  6098. toGammaSpace(): Color3;
  6099. /**
  6100. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6101. * @param convertedColor defines the Color3 object where to store the gamma space version
  6102. * @returns the unmodified Color3
  6103. */
  6104. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6105. private static _BlackReadOnly;
  6106. /**
  6107. * Convert Hue, saturation and value to a Color3 (RGB)
  6108. * @param hue defines the hue
  6109. * @param saturation defines the saturation
  6110. * @param value defines the value
  6111. * @param result defines the Color3 where to store the RGB values
  6112. */
  6113. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6114. /**
  6115. * Creates a new Color3 from the string containing valid hexadecimal values
  6116. * @param hex defines a string containing valid hexadecimal values
  6117. * @returns a new Color3 object
  6118. */
  6119. static FromHexString(hex: string): Color3;
  6120. /**
  6121. * Creates a new Color3 from the starting index of the given array
  6122. * @param array defines the source array
  6123. * @param offset defines an offset in the source array
  6124. * @returns a new Color3 object
  6125. */
  6126. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6127. /**
  6128. * Creates a new Color3 from the starting index element of the given array
  6129. * @param array defines the source array to read from
  6130. * @param offset defines the offset in the source array
  6131. * @param result defines the target Color3 object
  6132. */
  6133. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6134. /**
  6135. * Creates a new Color3 from integer values (< 256)
  6136. * @param r defines the red component to read from (value between 0 and 255)
  6137. * @param g defines the green component to read from (value between 0 and 255)
  6138. * @param b defines the blue component to read from (value between 0 and 255)
  6139. * @returns a new Color3 object
  6140. */
  6141. static FromInts(r: number, g: number, b: number): Color3;
  6142. /**
  6143. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6144. * @param start defines the start Color3 value
  6145. * @param end defines the end Color3 value
  6146. * @param amount defines the gradient value between start and end
  6147. * @returns a new Color3 object
  6148. */
  6149. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6150. /**
  6151. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6152. * @param left defines the start value
  6153. * @param right defines the end value
  6154. * @param amount defines the gradient factor
  6155. * @param result defines the Color3 object where to store the result
  6156. */
  6157. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6158. /**
  6159. * Returns a Color3 value containing a red color
  6160. * @returns a new Color3 object
  6161. */
  6162. static Red(): Color3;
  6163. /**
  6164. * Returns a Color3 value containing a green color
  6165. * @returns a new Color3 object
  6166. */
  6167. static Green(): Color3;
  6168. /**
  6169. * Returns a Color3 value containing a blue color
  6170. * @returns a new Color3 object
  6171. */
  6172. static Blue(): Color3;
  6173. /**
  6174. * Returns a Color3 value containing a black color
  6175. * @returns a new Color3 object
  6176. */
  6177. static Black(): Color3;
  6178. /**
  6179. * Gets a Color3 value containing a black color that must not be updated
  6180. */
  6181. static get BlackReadOnly(): DeepImmutable<Color3>;
  6182. /**
  6183. * Returns a Color3 value containing a white color
  6184. * @returns a new Color3 object
  6185. */
  6186. static White(): Color3;
  6187. /**
  6188. * Returns a Color3 value containing a purple color
  6189. * @returns a new Color3 object
  6190. */
  6191. static Purple(): Color3;
  6192. /**
  6193. * Returns a Color3 value containing a magenta color
  6194. * @returns a new Color3 object
  6195. */
  6196. static Magenta(): Color3;
  6197. /**
  6198. * Returns a Color3 value containing a yellow color
  6199. * @returns a new Color3 object
  6200. */
  6201. static Yellow(): Color3;
  6202. /**
  6203. * Returns a Color3 value containing a gray color
  6204. * @returns a new Color3 object
  6205. */
  6206. static Gray(): Color3;
  6207. /**
  6208. * Returns a Color3 value containing a teal color
  6209. * @returns a new Color3 object
  6210. */
  6211. static Teal(): Color3;
  6212. /**
  6213. * Returns a Color3 value containing a random color
  6214. * @returns a new Color3 object
  6215. */
  6216. static Random(): Color3;
  6217. }
  6218. /**
  6219. * Class used to hold a RBGA color
  6220. */
  6221. export class Color4 {
  6222. /**
  6223. * Defines the red component (between 0 and 1, default is 0)
  6224. */
  6225. r: number;
  6226. /**
  6227. * Defines the green component (between 0 and 1, default is 0)
  6228. */
  6229. g: number;
  6230. /**
  6231. * Defines the blue component (between 0 and 1, default is 0)
  6232. */
  6233. b: number;
  6234. /**
  6235. * Defines the alpha component (between 0 and 1, default is 1)
  6236. */
  6237. a: number;
  6238. /**
  6239. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6240. * @param r defines the red component (between 0 and 1, default is 0)
  6241. * @param g defines the green component (between 0 and 1, default is 0)
  6242. * @param b defines the blue component (between 0 and 1, default is 0)
  6243. * @param a defines the alpha component (between 0 and 1, default is 1)
  6244. */
  6245. constructor(
  6246. /**
  6247. * Defines the red component (between 0 and 1, default is 0)
  6248. */
  6249. r?: number,
  6250. /**
  6251. * Defines the green component (between 0 and 1, default is 0)
  6252. */
  6253. g?: number,
  6254. /**
  6255. * Defines the blue component (between 0 and 1, default is 0)
  6256. */
  6257. b?: number,
  6258. /**
  6259. * Defines the alpha component (between 0 and 1, default is 1)
  6260. */
  6261. a?: number);
  6262. /**
  6263. * Adds in place the given Color4 values to the current Color4 object
  6264. * @param right defines the second operand
  6265. * @returns the current updated Color4 object
  6266. */
  6267. addInPlace(right: DeepImmutable<Color4>): Color4;
  6268. /**
  6269. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6270. * @returns the new array
  6271. */
  6272. asArray(): number[];
  6273. /**
  6274. * Stores from the starting index in the given array the Color4 successive values
  6275. * @param array defines the array where to store the r,g,b components
  6276. * @param index defines an optional index in the target array to define where to start storing values
  6277. * @returns the current Color4 object
  6278. */
  6279. toArray(array: number[], index?: number): Color4;
  6280. /**
  6281. * Update the current color with values stored in an array from the starting index of the given array
  6282. * @param array defines the source array
  6283. * @param offset defines an offset in the source array
  6284. * @returns the current Color4 object
  6285. */
  6286. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6287. /**
  6288. * Determines equality between Color4 objects
  6289. * @param otherColor defines the second operand
  6290. * @returns true if the rgba values are equal to the given ones
  6291. */
  6292. equals(otherColor: DeepImmutable<Color4>): boolean;
  6293. /**
  6294. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6295. * @param right defines the second operand
  6296. * @returns a new Color4 object
  6297. */
  6298. add(right: DeepImmutable<Color4>): Color4;
  6299. /**
  6300. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6301. * @param right defines the second operand
  6302. * @returns a new Color4 object
  6303. */
  6304. subtract(right: DeepImmutable<Color4>): Color4;
  6305. /**
  6306. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6307. * @param right defines the second operand
  6308. * @param result defines the Color4 object where to store the result
  6309. * @returns the current Color4 object
  6310. */
  6311. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6312. /**
  6313. * Creates a new Color4 with the current Color4 values multiplied by scale
  6314. * @param scale defines the scaling factor to apply
  6315. * @returns a new Color4 object
  6316. */
  6317. scale(scale: number): Color4;
  6318. /**
  6319. * Multiplies the current Color4 values by scale and stores the result in "result"
  6320. * @param scale defines the scaling factor to apply
  6321. * @param result defines the Color4 object where to store the result
  6322. * @returns the current unmodified Color4
  6323. */
  6324. scaleToRef(scale: number, result: Color4): Color4;
  6325. /**
  6326. * Scale the current Color4 values by a factor and add the result to a given Color4
  6327. * @param scale defines the scale factor
  6328. * @param result defines the Color4 object where to store the result
  6329. * @returns the unmodified current Color4
  6330. */
  6331. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6332. /**
  6333. * Clamps the rgb values by the min and max values and stores the result into "result"
  6334. * @param min defines minimum clamping value (default is 0)
  6335. * @param max defines maximum clamping value (default is 1)
  6336. * @param result defines color to store the result into.
  6337. * @returns the cuurent Color4
  6338. */
  6339. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6340. /**
  6341. * Multipy an Color4 value by another and return a new Color4 object
  6342. * @param color defines the Color4 value to multiply by
  6343. * @returns a new Color4 object
  6344. */
  6345. multiply(color: Color4): Color4;
  6346. /**
  6347. * Multipy a Color4 value by another and push the result in a reference value
  6348. * @param color defines the Color4 value to multiply by
  6349. * @param result defines the Color4 to fill the result in
  6350. * @returns the result Color4
  6351. */
  6352. multiplyToRef(color: Color4, result: Color4): Color4;
  6353. /**
  6354. * Creates a string with the Color4 current values
  6355. * @returns the string representation of the Color4 object
  6356. */
  6357. toString(): string;
  6358. /**
  6359. * Returns the string "Color4"
  6360. * @returns "Color4"
  6361. */
  6362. getClassName(): string;
  6363. /**
  6364. * Compute the Color4 hash code
  6365. * @returns an unique number that can be used to hash Color4 objects
  6366. */
  6367. getHashCode(): number;
  6368. /**
  6369. * Creates a new Color4 copied from the current one
  6370. * @returns a new Color4 object
  6371. */
  6372. clone(): Color4;
  6373. /**
  6374. * Copies the given Color4 values into the current one
  6375. * @param source defines the source Color4 object
  6376. * @returns the current updated Color4 object
  6377. */
  6378. copyFrom(source: Color4): Color4;
  6379. /**
  6380. * Copies the given float values into the current one
  6381. * @param r defines the red component to read from
  6382. * @param g defines the green component to read from
  6383. * @param b defines the blue component to read from
  6384. * @param a defines the alpha component to read from
  6385. * @returns the current updated Color4 object
  6386. */
  6387. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6388. /**
  6389. * Copies the given float values into the current one
  6390. * @param r defines the red component to read from
  6391. * @param g defines the green component to read from
  6392. * @param b defines the blue component to read from
  6393. * @param a defines the alpha component to read from
  6394. * @returns the current updated Color4 object
  6395. */
  6396. set(r: number, g: number, b: number, a: number): Color4;
  6397. /**
  6398. * Compute the Color4 hexadecimal code as a string
  6399. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6400. * @returns a string containing the hexadecimal representation of the Color4 object
  6401. */
  6402. toHexString(returnAsColor3?: boolean): string;
  6403. /**
  6404. * Computes a new Color4 converted from the current one to linear space
  6405. * @returns a new Color4 object
  6406. */
  6407. toLinearSpace(): Color4;
  6408. /**
  6409. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6410. * @param convertedColor defines the Color4 object where to store the linear space version
  6411. * @returns the unmodified Color4
  6412. */
  6413. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6414. /**
  6415. * Computes a new Color4 converted from the current one to gamma space
  6416. * @returns a new Color4 object
  6417. */
  6418. toGammaSpace(): Color4;
  6419. /**
  6420. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6421. * @param convertedColor defines the Color4 object where to store the gamma space version
  6422. * @returns the unmodified Color4
  6423. */
  6424. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6425. /**
  6426. * Creates a new Color4 from the string containing valid hexadecimal values
  6427. * @param hex defines a string containing valid hexadecimal values
  6428. * @returns a new Color4 object
  6429. */
  6430. static FromHexString(hex: string): Color4;
  6431. /**
  6432. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6433. * @param left defines the start value
  6434. * @param right defines the end value
  6435. * @param amount defines the gradient factor
  6436. * @returns a new Color4 object
  6437. */
  6438. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6439. /**
  6440. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6441. * @param left defines the start value
  6442. * @param right defines the end value
  6443. * @param amount defines the gradient factor
  6444. * @param result defines the Color4 object where to store data
  6445. */
  6446. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6447. /**
  6448. * Creates a new Color4 from a Color3 and an alpha value
  6449. * @param color3 defines the source Color3 to read from
  6450. * @param alpha defines the alpha component (1.0 by default)
  6451. * @returns a new Color4 object
  6452. */
  6453. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6454. /**
  6455. * Creates a new Color4 from the starting index element of the given array
  6456. * @param array defines the source array to read from
  6457. * @param offset defines the offset in the source array
  6458. * @returns a new Color4 object
  6459. */
  6460. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6461. /**
  6462. * Creates a new Color4 from the starting index element of the given array
  6463. * @param array defines the source array to read from
  6464. * @param offset defines the offset in the source array
  6465. * @param result defines the target Color4 object
  6466. */
  6467. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6468. /**
  6469. * Creates a new Color3 from integer values (< 256)
  6470. * @param r defines the red component to read from (value between 0 and 255)
  6471. * @param g defines the green component to read from (value between 0 and 255)
  6472. * @param b defines the blue component to read from (value between 0 and 255)
  6473. * @param a defines the alpha component to read from (value between 0 and 255)
  6474. * @returns a new Color3 object
  6475. */
  6476. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6477. /**
  6478. * Check the content of a given array and convert it to an array containing RGBA data
  6479. * If the original array was already containing count * 4 values then it is returned directly
  6480. * @param colors defines the array to check
  6481. * @param count defines the number of RGBA data to expect
  6482. * @returns an array containing count * 4 values (RGBA)
  6483. */
  6484. static CheckColors4(colors: number[], count: number): number[];
  6485. }
  6486. /**
  6487. * @hidden
  6488. */
  6489. export class TmpColors {
  6490. static Color3: Color3[];
  6491. static Color4: Color4[];
  6492. }
  6493. }
  6494. declare module BABYLON {
  6495. /**
  6496. * Defines an interface which represents an animation key frame
  6497. */
  6498. export interface IAnimationKey {
  6499. /**
  6500. * Frame of the key frame
  6501. */
  6502. frame: number;
  6503. /**
  6504. * Value at the specifies key frame
  6505. */
  6506. value: any;
  6507. /**
  6508. * The input tangent for the cubic hermite spline
  6509. */
  6510. inTangent?: any;
  6511. /**
  6512. * The output tangent for the cubic hermite spline
  6513. */
  6514. outTangent?: any;
  6515. /**
  6516. * The animation interpolation type
  6517. */
  6518. interpolation?: AnimationKeyInterpolation;
  6519. }
  6520. /**
  6521. * Enum for the animation key frame interpolation type
  6522. */
  6523. export enum AnimationKeyInterpolation {
  6524. /**
  6525. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6526. */
  6527. STEP = 1
  6528. }
  6529. }
  6530. declare module BABYLON {
  6531. /**
  6532. * Represents the range of an animation
  6533. */
  6534. export class AnimationRange {
  6535. /**The name of the animation range**/
  6536. name: string;
  6537. /**The starting frame of the animation */
  6538. from: number;
  6539. /**The ending frame of the animation*/
  6540. to: number;
  6541. /**
  6542. * Initializes the range of an animation
  6543. * @param name The name of the animation range
  6544. * @param from The starting frame of the animation
  6545. * @param to The ending frame of the animation
  6546. */
  6547. constructor(
  6548. /**The name of the animation range**/
  6549. name: string,
  6550. /**The starting frame of the animation */
  6551. from: number,
  6552. /**The ending frame of the animation*/
  6553. to: number);
  6554. /**
  6555. * Makes a copy of the animation range
  6556. * @returns A copy of the animation range
  6557. */
  6558. clone(): AnimationRange;
  6559. }
  6560. }
  6561. declare module BABYLON {
  6562. /**
  6563. * Composed of a frame, and an action function
  6564. */
  6565. export class AnimationEvent {
  6566. /** The frame for which the event is triggered **/
  6567. frame: number;
  6568. /** The event to perform when triggered **/
  6569. action: (currentFrame: number) => void;
  6570. /** Specifies if the event should be triggered only once**/
  6571. onlyOnce?: boolean | undefined;
  6572. /**
  6573. * Specifies if the animation event is done
  6574. */
  6575. isDone: boolean;
  6576. /**
  6577. * Initializes the animation event
  6578. * @param frame The frame for which the event is triggered
  6579. * @param action The event to perform when triggered
  6580. * @param onlyOnce Specifies if the event should be triggered only once
  6581. */
  6582. constructor(
  6583. /** The frame for which the event is triggered **/
  6584. frame: number,
  6585. /** The event to perform when triggered **/
  6586. action: (currentFrame: number) => void,
  6587. /** Specifies if the event should be triggered only once**/
  6588. onlyOnce?: boolean | undefined);
  6589. /** @hidden */
  6590. _clone(): AnimationEvent;
  6591. }
  6592. }
  6593. declare module BABYLON {
  6594. /**
  6595. * Interface used to define a behavior
  6596. */
  6597. export interface Behavior<T> {
  6598. /** gets or sets behavior's name */
  6599. name: string;
  6600. /**
  6601. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6602. */
  6603. init(): void;
  6604. /**
  6605. * Called when the behavior is attached to a target
  6606. * @param target defines the target where the behavior is attached to
  6607. */
  6608. attach(target: T): void;
  6609. /**
  6610. * Called when the behavior is detached from its target
  6611. */
  6612. detach(): void;
  6613. }
  6614. /**
  6615. * Interface implemented by classes supporting behaviors
  6616. */
  6617. export interface IBehaviorAware<T> {
  6618. /**
  6619. * Attach a behavior
  6620. * @param behavior defines the behavior to attach
  6621. * @returns the current host
  6622. */
  6623. addBehavior(behavior: Behavior<T>): T;
  6624. /**
  6625. * Remove a behavior from the current object
  6626. * @param behavior defines the behavior to detach
  6627. * @returns the current host
  6628. */
  6629. removeBehavior(behavior: Behavior<T>): T;
  6630. /**
  6631. * Gets a behavior using its name to search
  6632. * @param name defines the name to search
  6633. * @returns the behavior or null if not found
  6634. */
  6635. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6636. }
  6637. }
  6638. declare module BABYLON {
  6639. /**
  6640. * Class used to store data that will be store in GPU memory
  6641. */
  6642. export class Buffer {
  6643. private _engine;
  6644. private _buffer;
  6645. /** @hidden */
  6646. _data: Nullable<DataArray>;
  6647. private _updatable;
  6648. private _instanced;
  6649. private _divisor;
  6650. /**
  6651. * Gets the byte stride.
  6652. */
  6653. readonly byteStride: number;
  6654. /**
  6655. * Constructor
  6656. * @param engine the engine
  6657. * @param data the data to use for this buffer
  6658. * @param updatable whether the data is updatable
  6659. * @param stride the stride (optional)
  6660. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6661. * @param instanced whether the buffer is instanced (optional)
  6662. * @param useBytes set to true if the stride in in bytes (optional)
  6663. * @param divisor sets an optional divisor for instances (1 by default)
  6664. */
  6665. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6666. /**
  6667. * Create a new VertexBuffer based on the current buffer
  6668. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6669. * @param offset defines offset in the buffer (0 by default)
  6670. * @param size defines the size in floats of attributes (position is 3 for instance)
  6671. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6672. * @param instanced defines if the vertex buffer contains indexed data
  6673. * @param useBytes defines if the offset and stride are in bytes *
  6674. * @param divisor sets an optional divisor for instances (1 by default)
  6675. * @returns the new vertex buffer
  6676. */
  6677. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6678. /**
  6679. * Gets a boolean indicating if the Buffer is updatable?
  6680. * @returns true if the buffer is updatable
  6681. */
  6682. isUpdatable(): boolean;
  6683. /**
  6684. * Gets current buffer's data
  6685. * @returns a DataArray or null
  6686. */
  6687. getData(): Nullable<DataArray>;
  6688. /**
  6689. * Gets underlying native buffer
  6690. * @returns underlying native buffer
  6691. */
  6692. getBuffer(): Nullable<DataBuffer>;
  6693. /**
  6694. * Gets the stride in float32 units (i.e. byte stride / 4).
  6695. * May not be an integer if the byte stride is not divisible by 4.
  6696. * @returns the stride in float32 units
  6697. * @deprecated Please use byteStride instead.
  6698. */
  6699. getStrideSize(): number;
  6700. /**
  6701. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6702. * @param data defines the data to store
  6703. */
  6704. create(data?: Nullable<DataArray>): void;
  6705. /** @hidden */
  6706. _rebuild(): void;
  6707. /**
  6708. * Update current buffer data
  6709. * @param data defines the data to store
  6710. */
  6711. update(data: DataArray): void;
  6712. /**
  6713. * Updates the data directly.
  6714. * @param data the new data
  6715. * @param offset the new offset
  6716. * @param vertexCount the vertex count (optional)
  6717. * @param useBytes set to true if the offset is in bytes
  6718. */
  6719. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6720. /**
  6721. * Release all resources
  6722. */
  6723. dispose(): void;
  6724. }
  6725. /**
  6726. * Specialized buffer used to store vertex data
  6727. */
  6728. export class VertexBuffer {
  6729. /** @hidden */
  6730. _buffer: Buffer;
  6731. private _kind;
  6732. private _size;
  6733. private _ownsBuffer;
  6734. private _instanced;
  6735. private _instanceDivisor;
  6736. /**
  6737. * The byte type.
  6738. */
  6739. static readonly BYTE: number;
  6740. /**
  6741. * The unsigned byte type.
  6742. */
  6743. static readonly UNSIGNED_BYTE: number;
  6744. /**
  6745. * The short type.
  6746. */
  6747. static readonly SHORT: number;
  6748. /**
  6749. * The unsigned short type.
  6750. */
  6751. static readonly UNSIGNED_SHORT: number;
  6752. /**
  6753. * The integer type.
  6754. */
  6755. static readonly INT: number;
  6756. /**
  6757. * The unsigned integer type.
  6758. */
  6759. static readonly UNSIGNED_INT: number;
  6760. /**
  6761. * The float type.
  6762. */
  6763. static readonly FLOAT: number;
  6764. /**
  6765. * Gets or sets the instance divisor when in instanced mode
  6766. */
  6767. get instanceDivisor(): number;
  6768. set instanceDivisor(value: number);
  6769. /**
  6770. * Gets the byte stride.
  6771. */
  6772. readonly byteStride: number;
  6773. /**
  6774. * Gets the byte offset.
  6775. */
  6776. readonly byteOffset: number;
  6777. /**
  6778. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6779. */
  6780. readonly normalized: boolean;
  6781. /**
  6782. * Gets the data type of each component in the array.
  6783. */
  6784. readonly type: number;
  6785. /**
  6786. * Constructor
  6787. * @param engine the engine
  6788. * @param data the data to use for this vertex buffer
  6789. * @param kind the vertex buffer kind
  6790. * @param updatable whether the data is updatable
  6791. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6792. * @param stride the stride (optional)
  6793. * @param instanced whether the buffer is instanced (optional)
  6794. * @param offset the offset of the data (optional)
  6795. * @param size the number of components (optional)
  6796. * @param type the type of the component (optional)
  6797. * @param normalized whether the data contains normalized data (optional)
  6798. * @param useBytes set to true if stride and offset are in bytes (optional)
  6799. * @param divisor defines the instance divisor to use (1 by default)
  6800. */
  6801. 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);
  6802. /** @hidden */
  6803. _rebuild(): void;
  6804. /**
  6805. * Returns the kind of the VertexBuffer (string)
  6806. * @returns a string
  6807. */
  6808. getKind(): string;
  6809. /**
  6810. * Gets a boolean indicating if the VertexBuffer is updatable?
  6811. * @returns true if the buffer is updatable
  6812. */
  6813. isUpdatable(): boolean;
  6814. /**
  6815. * Gets current buffer's data
  6816. * @returns a DataArray or null
  6817. */
  6818. getData(): Nullable<DataArray>;
  6819. /**
  6820. * Gets underlying native buffer
  6821. * @returns underlying native buffer
  6822. */
  6823. getBuffer(): Nullable<DataBuffer>;
  6824. /**
  6825. * Gets the stride in float32 units (i.e. byte stride / 4).
  6826. * May not be an integer if the byte stride is not divisible by 4.
  6827. * @returns the stride in float32 units
  6828. * @deprecated Please use byteStride instead.
  6829. */
  6830. getStrideSize(): number;
  6831. /**
  6832. * Returns the offset as a multiple of the type byte length.
  6833. * @returns the offset in bytes
  6834. * @deprecated Please use byteOffset instead.
  6835. */
  6836. getOffset(): number;
  6837. /**
  6838. * Returns the number of components per vertex attribute (integer)
  6839. * @returns the size in float
  6840. */
  6841. getSize(): number;
  6842. /**
  6843. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6844. * @returns true if this buffer is instanced
  6845. */
  6846. getIsInstanced(): boolean;
  6847. /**
  6848. * Returns the instancing divisor, zero for non-instanced (integer).
  6849. * @returns a number
  6850. */
  6851. getInstanceDivisor(): number;
  6852. /**
  6853. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6854. * @param data defines the data to store
  6855. */
  6856. create(data?: DataArray): void;
  6857. /**
  6858. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6859. * This function will create a new buffer if the current one is not updatable
  6860. * @param data defines the data to store
  6861. */
  6862. update(data: DataArray): void;
  6863. /**
  6864. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6865. * Returns the directly updated WebGLBuffer.
  6866. * @param data the new data
  6867. * @param offset the new offset
  6868. * @param useBytes set to true if the offset is in bytes
  6869. */
  6870. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6871. /**
  6872. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6873. */
  6874. dispose(): void;
  6875. /**
  6876. * Enumerates each value of this vertex buffer as numbers.
  6877. * @param count the number of values to enumerate
  6878. * @param callback the callback function called for each value
  6879. */
  6880. forEach(count: number, callback: (value: number, index: number) => void): void;
  6881. /**
  6882. * Positions
  6883. */
  6884. static readonly PositionKind: string;
  6885. /**
  6886. * Normals
  6887. */
  6888. static readonly NormalKind: string;
  6889. /**
  6890. * Tangents
  6891. */
  6892. static readonly TangentKind: string;
  6893. /**
  6894. * Texture coordinates
  6895. */
  6896. static readonly UVKind: string;
  6897. /**
  6898. * Texture coordinates 2
  6899. */
  6900. static readonly UV2Kind: string;
  6901. /**
  6902. * Texture coordinates 3
  6903. */
  6904. static readonly UV3Kind: string;
  6905. /**
  6906. * Texture coordinates 4
  6907. */
  6908. static readonly UV4Kind: string;
  6909. /**
  6910. * Texture coordinates 5
  6911. */
  6912. static readonly UV5Kind: string;
  6913. /**
  6914. * Texture coordinates 6
  6915. */
  6916. static readonly UV6Kind: string;
  6917. /**
  6918. * Colors
  6919. */
  6920. static readonly ColorKind: string;
  6921. /**
  6922. * Matrix indices (for bones)
  6923. */
  6924. static readonly MatricesIndicesKind: string;
  6925. /**
  6926. * Matrix weights (for bones)
  6927. */
  6928. static readonly MatricesWeightsKind: string;
  6929. /**
  6930. * Additional matrix indices (for bones)
  6931. */
  6932. static readonly MatricesIndicesExtraKind: string;
  6933. /**
  6934. * Additional matrix weights (for bones)
  6935. */
  6936. static readonly MatricesWeightsExtraKind: string;
  6937. /**
  6938. * Deduces the stride given a kind.
  6939. * @param kind The kind string to deduce
  6940. * @returns The deduced stride
  6941. */
  6942. static DeduceStride(kind: string): number;
  6943. /**
  6944. * Gets the byte length of the given type.
  6945. * @param type the type
  6946. * @returns the number of bytes
  6947. */
  6948. static GetTypeByteLength(type: number): number;
  6949. /**
  6950. * Enumerates each value of the given parameters as numbers.
  6951. * @param data the data to enumerate
  6952. * @param byteOffset the byte offset of the data
  6953. * @param byteStride the byte stride of the data
  6954. * @param componentCount the number of components per element
  6955. * @param componentType the type of the component
  6956. * @param count the number of values to enumerate
  6957. * @param normalized whether the data is normalized
  6958. * @param callback the callback function called for each value
  6959. */
  6960. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6961. private static _GetFloatValue;
  6962. }
  6963. }
  6964. declare module BABYLON {
  6965. /**
  6966. * @hidden
  6967. */
  6968. export class IntersectionInfo {
  6969. bu: Nullable<number>;
  6970. bv: Nullable<number>;
  6971. distance: number;
  6972. faceId: number;
  6973. subMeshId: number;
  6974. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6975. }
  6976. }
  6977. declare module BABYLON {
  6978. /**
  6979. * Class used to store bounding sphere information
  6980. */
  6981. export class BoundingSphere {
  6982. /**
  6983. * Gets the center of the bounding sphere in local space
  6984. */
  6985. readonly center: Vector3;
  6986. /**
  6987. * Radius of the bounding sphere in local space
  6988. */
  6989. radius: number;
  6990. /**
  6991. * Gets the center of the bounding sphere in world space
  6992. */
  6993. readonly centerWorld: Vector3;
  6994. /**
  6995. * Radius of the bounding sphere in world space
  6996. */
  6997. radiusWorld: number;
  6998. /**
  6999. * Gets the minimum vector in local space
  7000. */
  7001. readonly minimum: Vector3;
  7002. /**
  7003. * Gets the maximum vector in local space
  7004. */
  7005. readonly maximum: Vector3;
  7006. private _worldMatrix;
  7007. private static readonly TmpVector3;
  7008. /**
  7009. * Creates a new bounding sphere
  7010. * @param min defines the minimum vector (in local space)
  7011. * @param max defines the maximum vector (in local space)
  7012. * @param worldMatrix defines the new world matrix
  7013. */
  7014. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7015. /**
  7016. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7017. * @param min defines the new minimum vector (in local space)
  7018. * @param max defines the new maximum vector (in local space)
  7019. * @param worldMatrix defines the new world matrix
  7020. */
  7021. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7022. /**
  7023. * Scale the current bounding sphere by applying a scale factor
  7024. * @param factor defines the scale factor to apply
  7025. * @returns the current bounding box
  7026. */
  7027. scale(factor: number): BoundingSphere;
  7028. /**
  7029. * Gets the world matrix of the bounding box
  7030. * @returns a matrix
  7031. */
  7032. getWorldMatrix(): DeepImmutable<Matrix>;
  7033. /** @hidden */
  7034. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7035. /**
  7036. * Tests if the bounding sphere is intersecting the frustum planes
  7037. * @param frustumPlanes defines the frustum planes to test
  7038. * @returns true if there is an intersection
  7039. */
  7040. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7041. /**
  7042. * Tests if the bounding sphere center is in between the frustum planes.
  7043. * Used for optimistic fast inclusion.
  7044. * @param frustumPlanes defines the frustum planes to test
  7045. * @returns true if the sphere center is in between the frustum planes
  7046. */
  7047. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7048. /**
  7049. * Tests if a point is inside the bounding sphere
  7050. * @param point defines the point to test
  7051. * @returns true if the point is inside the bounding sphere
  7052. */
  7053. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7054. /**
  7055. * Checks if two sphere intersct
  7056. * @param sphere0 sphere 0
  7057. * @param sphere1 sphere 1
  7058. * @returns true if the speres intersect
  7059. */
  7060. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7061. }
  7062. }
  7063. declare module BABYLON {
  7064. /**
  7065. * Class used to store bounding box information
  7066. */
  7067. export class BoundingBox implements ICullable {
  7068. /**
  7069. * Gets the 8 vectors representing the bounding box in local space
  7070. */
  7071. readonly vectors: Vector3[];
  7072. /**
  7073. * Gets the center of the bounding box in local space
  7074. */
  7075. readonly center: Vector3;
  7076. /**
  7077. * Gets the center of the bounding box in world space
  7078. */
  7079. readonly centerWorld: Vector3;
  7080. /**
  7081. * Gets the extend size in local space
  7082. */
  7083. readonly extendSize: Vector3;
  7084. /**
  7085. * Gets the extend size in world space
  7086. */
  7087. readonly extendSizeWorld: Vector3;
  7088. /**
  7089. * Gets the OBB (object bounding box) directions
  7090. */
  7091. readonly directions: Vector3[];
  7092. /**
  7093. * Gets the 8 vectors representing the bounding box in world space
  7094. */
  7095. readonly vectorsWorld: Vector3[];
  7096. /**
  7097. * Gets the minimum vector in world space
  7098. */
  7099. readonly minimumWorld: Vector3;
  7100. /**
  7101. * Gets the maximum vector in world space
  7102. */
  7103. readonly maximumWorld: Vector3;
  7104. /**
  7105. * Gets the minimum vector in local space
  7106. */
  7107. readonly minimum: Vector3;
  7108. /**
  7109. * Gets the maximum vector in local space
  7110. */
  7111. readonly maximum: Vector3;
  7112. private _worldMatrix;
  7113. private static readonly TmpVector3;
  7114. /**
  7115. * @hidden
  7116. */
  7117. _tag: number;
  7118. /**
  7119. * Creates a new bounding box
  7120. * @param min defines the minimum vector (in local space)
  7121. * @param max defines the maximum vector (in local space)
  7122. * @param worldMatrix defines the new world matrix
  7123. */
  7124. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7125. /**
  7126. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7127. * @param min defines the new minimum vector (in local space)
  7128. * @param max defines the new maximum vector (in local space)
  7129. * @param worldMatrix defines the new world matrix
  7130. */
  7131. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7132. /**
  7133. * Scale the current bounding box by applying a scale factor
  7134. * @param factor defines the scale factor to apply
  7135. * @returns the current bounding box
  7136. */
  7137. scale(factor: number): BoundingBox;
  7138. /**
  7139. * Gets the world matrix of the bounding box
  7140. * @returns a matrix
  7141. */
  7142. getWorldMatrix(): DeepImmutable<Matrix>;
  7143. /** @hidden */
  7144. _update(world: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * Tests if the bounding box is intersecting the frustum planes
  7147. * @param frustumPlanes defines the frustum planes to test
  7148. * @returns true if there is an intersection
  7149. */
  7150. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7151. /**
  7152. * Tests if the bounding box is entirely inside the frustum planes
  7153. * @param frustumPlanes defines the frustum planes to test
  7154. * @returns true if there is an inclusion
  7155. */
  7156. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7157. /**
  7158. * Tests if a point is inside the bounding box
  7159. * @param point defines the point to test
  7160. * @returns true if the point is inside the bounding box
  7161. */
  7162. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7163. /**
  7164. * Tests if the bounding box intersects with a bounding sphere
  7165. * @param sphere defines the sphere to test
  7166. * @returns true if there is an intersection
  7167. */
  7168. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7169. /**
  7170. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7171. * @param min defines the min vector to use
  7172. * @param max defines the max vector to use
  7173. * @returns true if there is an intersection
  7174. */
  7175. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7176. /**
  7177. * Tests if two bounding boxes are intersections
  7178. * @param box0 defines the first box to test
  7179. * @param box1 defines the second box to test
  7180. * @returns true if there is an intersection
  7181. */
  7182. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7183. /**
  7184. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7185. * @param minPoint defines the minimum vector of the bounding box
  7186. * @param maxPoint defines the maximum vector of the bounding box
  7187. * @param sphereCenter defines the sphere center
  7188. * @param sphereRadius defines the sphere radius
  7189. * @returns true if there is an intersection
  7190. */
  7191. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7192. /**
  7193. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7194. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7195. * @param frustumPlanes defines the frustum planes to test
  7196. * @return true if there is an inclusion
  7197. */
  7198. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7199. /**
  7200. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7201. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7202. * @param frustumPlanes defines the frustum planes to test
  7203. * @return true if there is an intersection
  7204. */
  7205. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7206. }
  7207. }
  7208. declare module BABYLON {
  7209. /** @hidden */
  7210. export class Collider {
  7211. /** Define if a collision was found */
  7212. collisionFound: boolean;
  7213. /**
  7214. * Define last intersection point in local space
  7215. */
  7216. intersectionPoint: Vector3;
  7217. /**
  7218. * Define last collided mesh
  7219. */
  7220. collidedMesh: Nullable<AbstractMesh>;
  7221. private _collisionPoint;
  7222. private _planeIntersectionPoint;
  7223. private _tempVector;
  7224. private _tempVector2;
  7225. private _tempVector3;
  7226. private _tempVector4;
  7227. private _edge;
  7228. private _baseToVertex;
  7229. private _destinationPoint;
  7230. private _slidePlaneNormal;
  7231. private _displacementVector;
  7232. /** @hidden */
  7233. _radius: Vector3;
  7234. /** @hidden */
  7235. _retry: number;
  7236. private _velocity;
  7237. private _basePoint;
  7238. private _epsilon;
  7239. /** @hidden */
  7240. _velocityWorldLength: number;
  7241. /** @hidden */
  7242. _basePointWorld: Vector3;
  7243. private _velocityWorld;
  7244. private _normalizedVelocity;
  7245. /** @hidden */
  7246. _initialVelocity: Vector3;
  7247. /** @hidden */
  7248. _initialPosition: Vector3;
  7249. private _nearestDistance;
  7250. private _collisionMask;
  7251. get collisionMask(): number;
  7252. set collisionMask(mask: number);
  7253. /**
  7254. * Gets the plane normal used to compute the sliding response (in local space)
  7255. */
  7256. get slidePlaneNormal(): Vector3;
  7257. /** @hidden */
  7258. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7259. /** @hidden */
  7260. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7261. /** @hidden */
  7262. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7263. /** @hidden */
  7264. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7265. /** @hidden */
  7266. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7267. /** @hidden */
  7268. _getResponse(pos: Vector3, vel: Vector3): void;
  7269. }
  7270. }
  7271. declare module BABYLON {
  7272. /**
  7273. * Interface for cullable objects
  7274. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7275. */
  7276. export interface ICullable {
  7277. /**
  7278. * Checks if the object or part of the object is in the frustum
  7279. * @param frustumPlanes Camera near/planes
  7280. * @returns true if the object is in frustum otherwise false
  7281. */
  7282. isInFrustum(frustumPlanes: Plane[]): boolean;
  7283. /**
  7284. * Checks if a cullable object (mesh...) is in the camera frustum
  7285. * Unlike isInFrustum this cheks the full bounding box
  7286. * @param frustumPlanes Camera near/planes
  7287. * @returns true if the object is in frustum otherwise false
  7288. */
  7289. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7290. }
  7291. /**
  7292. * Info for a bounding data of a mesh
  7293. */
  7294. export class BoundingInfo implements ICullable {
  7295. /**
  7296. * Bounding box for the mesh
  7297. */
  7298. readonly boundingBox: BoundingBox;
  7299. /**
  7300. * Bounding sphere for the mesh
  7301. */
  7302. readonly boundingSphere: BoundingSphere;
  7303. private _isLocked;
  7304. private static readonly TmpVector3;
  7305. /**
  7306. * Constructs bounding info
  7307. * @param minimum min vector of the bounding box/sphere
  7308. * @param maximum max vector of the bounding box/sphere
  7309. * @param worldMatrix defines the new world matrix
  7310. */
  7311. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7312. /**
  7313. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7314. * @param min defines the new minimum vector (in local space)
  7315. * @param max defines the new maximum vector (in local space)
  7316. * @param worldMatrix defines the new world matrix
  7317. */
  7318. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7319. /**
  7320. * min vector of the bounding box/sphere
  7321. */
  7322. get minimum(): Vector3;
  7323. /**
  7324. * max vector of the bounding box/sphere
  7325. */
  7326. get maximum(): Vector3;
  7327. /**
  7328. * If the info is locked and won't be updated to avoid perf overhead
  7329. */
  7330. get isLocked(): boolean;
  7331. set isLocked(value: boolean);
  7332. /**
  7333. * Updates the bounding sphere and box
  7334. * @param world world matrix to be used to update
  7335. */
  7336. update(world: DeepImmutable<Matrix>): void;
  7337. /**
  7338. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7339. * @param center New center of the bounding info
  7340. * @param extend New extend of the bounding info
  7341. * @returns the current bounding info
  7342. */
  7343. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7344. /**
  7345. * Scale the current bounding info by applying a scale factor
  7346. * @param factor defines the scale factor to apply
  7347. * @returns the current bounding info
  7348. */
  7349. scale(factor: number): BoundingInfo;
  7350. /**
  7351. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7352. * @param frustumPlanes defines the frustum to test
  7353. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7354. * @returns true if the bounding info is in the frustum planes
  7355. */
  7356. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7357. /**
  7358. * Gets the world distance between the min and max points of the bounding box
  7359. */
  7360. get diagonalLength(): number;
  7361. /**
  7362. * Checks if a cullable object (mesh...) is in the camera frustum
  7363. * Unlike isInFrustum this cheks the full bounding box
  7364. * @param frustumPlanes Camera near/planes
  7365. * @returns true if the object is in frustum otherwise false
  7366. */
  7367. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7368. /** @hidden */
  7369. _checkCollision(collider: Collider): boolean;
  7370. /**
  7371. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7372. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7373. * @param point the point to check intersection with
  7374. * @returns if the point intersects
  7375. */
  7376. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7377. /**
  7378. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7379. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7380. * @param boundingInfo the bounding info to check intersection with
  7381. * @param precise if the intersection should be done using OBB
  7382. * @returns if the bounding info intersects
  7383. */
  7384. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7385. }
  7386. }
  7387. declare module BABYLON {
  7388. /**
  7389. * Extracts minimum and maximum values from a list of indexed positions
  7390. * @param positions defines the positions to use
  7391. * @param indices defines the indices to the positions
  7392. * @param indexStart defines the start index
  7393. * @param indexCount defines the end index
  7394. * @param bias defines bias value to add to the result
  7395. * @return minimum and maximum values
  7396. */
  7397. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7398. minimum: Vector3;
  7399. maximum: Vector3;
  7400. };
  7401. /**
  7402. * Extracts minimum and maximum values from a list of positions
  7403. * @param positions defines the positions to use
  7404. * @param start defines the start index in the positions array
  7405. * @param count defines the number of positions to handle
  7406. * @param bias defines bias value to add to the result
  7407. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7408. * @return minimum and maximum values
  7409. */
  7410. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7411. minimum: Vector3;
  7412. maximum: Vector3;
  7413. };
  7414. }
  7415. declare module BABYLON {
  7416. /**
  7417. * Class used to manipulate GUIDs
  7418. */
  7419. export class GUID {
  7420. /**
  7421. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7422. * Be aware Math.random() could cause collisions, but:
  7423. * "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"
  7424. * @returns a pseudo random id
  7425. */
  7426. static RandomId(): string;
  7427. }
  7428. }
  7429. declare module BABYLON {
  7430. /**
  7431. * Base class of all the textures in babylon.
  7432. * It groups all the common properties the materials, post process, lights... might need
  7433. * in order to make a correct use of the texture.
  7434. */
  7435. export class BaseTexture extends ThinTexture implements IAnimatable {
  7436. /**
  7437. * Default anisotropic filtering level for the application.
  7438. * It is set to 4 as a good tradeoff between perf and quality.
  7439. */
  7440. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7441. /**
  7442. * Gets or sets the unique id of the texture
  7443. */
  7444. uniqueId: number;
  7445. /**
  7446. * Define the name of the texture.
  7447. */
  7448. name: string;
  7449. /**
  7450. * Gets or sets an object used to store user defined information.
  7451. */
  7452. metadata: any;
  7453. /**
  7454. * For internal use only. Please do not use.
  7455. */
  7456. reservedDataStore: any;
  7457. private _hasAlpha;
  7458. /**
  7459. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7460. */
  7461. set hasAlpha(value: boolean);
  7462. get hasAlpha(): boolean;
  7463. /**
  7464. * Defines if the alpha value should be determined via the rgb values.
  7465. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7466. */
  7467. getAlphaFromRGB: boolean;
  7468. /**
  7469. * Intensity or strength of the texture.
  7470. * It is commonly used by materials to fine tune the intensity of the texture
  7471. */
  7472. level: number;
  7473. /**
  7474. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7475. * This is part of the texture as textures usually maps to one uv set.
  7476. */
  7477. coordinatesIndex: number;
  7478. protected _coordinatesMode: number;
  7479. /**
  7480. * How a texture is mapped.
  7481. *
  7482. * | Value | Type | Description |
  7483. * | ----- | ----------------------------------- | ----------- |
  7484. * | 0 | EXPLICIT_MODE | |
  7485. * | 1 | SPHERICAL_MODE | |
  7486. * | 2 | PLANAR_MODE | |
  7487. * | 3 | CUBIC_MODE | |
  7488. * | 4 | PROJECTION_MODE | |
  7489. * | 5 | SKYBOX_MODE | |
  7490. * | 6 | INVCUBIC_MODE | |
  7491. * | 7 | EQUIRECTANGULAR_MODE | |
  7492. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7493. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7494. */
  7495. set coordinatesMode(value: number);
  7496. get coordinatesMode(): number;
  7497. /**
  7498. * | Value | Type | Description |
  7499. * | ----- | ------------------ | ----------- |
  7500. * | 0 | CLAMP_ADDRESSMODE | |
  7501. * | 1 | WRAP_ADDRESSMODE | |
  7502. * | 2 | MIRROR_ADDRESSMODE | |
  7503. */
  7504. get wrapU(): number;
  7505. set wrapU(value: number);
  7506. /**
  7507. * | Value | Type | Description |
  7508. * | ----- | ------------------ | ----------- |
  7509. * | 0 | CLAMP_ADDRESSMODE | |
  7510. * | 1 | WRAP_ADDRESSMODE | |
  7511. * | 2 | MIRROR_ADDRESSMODE | |
  7512. */
  7513. get wrapV(): number;
  7514. set wrapV(value: number);
  7515. /**
  7516. * | Value | Type | Description |
  7517. * | ----- | ------------------ | ----------- |
  7518. * | 0 | CLAMP_ADDRESSMODE | |
  7519. * | 1 | WRAP_ADDRESSMODE | |
  7520. * | 2 | MIRROR_ADDRESSMODE | |
  7521. */
  7522. wrapR: number;
  7523. /**
  7524. * With compliant hardware and browser (supporting anisotropic filtering)
  7525. * this defines the level of anisotropic filtering in the texture.
  7526. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7527. */
  7528. anisotropicFilteringLevel: number;
  7529. private _isCube;
  7530. /**
  7531. * Define if the texture is a cube texture or if false a 2d texture.
  7532. */
  7533. get isCube(): boolean;
  7534. set isCube(value: boolean);
  7535. /**
  7536. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7537. */
  7538. get is3D(): boolean;
  7539. set is3D(value: boolean);
  7540. /**
  7541. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7542. */
  7543. get is2DArray(): boolean;
  7544. set is2DArray(value: boolean);
  7545. private _gammaSpace;
  7546. /**
  7547. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7548. * HDR texture are usually stored in linear space.
  7549. * This only impacts the PBR and Background materials
  7550. */
  7551. get gammaSpace(): boolean;
  7552. set gammaSpace(gamma: boolean);
  7553. /**
  7554. * Gets or sets whether or not the texture contains RGBD data.
  7555. */
  7556. get isRGBD(): boolean;
  7557. set isRGBD(value: boolean);
  7558. /**
  7559. * Is Z inverted in the texture (useful in a cube texture).
  7560. */
  7561. invertZ: boolean;
  7562. /**
  7563. * Are mip maps generated for this texture or not.
  7564. */
  7565. get noMipmap(): boolean;
  7566. /**
  7567. * @hidden
  7568. */
  7569. lodLevelInAlpha: boolean;
  7570. /**
  7571. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7572. */
  7573. get lodGenerationOffset(): number;
  7574. set lodGenerationOffset(value: number);
  7575. /**
  7576. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7577. */
  7578. get lodGenerationScale(): number;
  7579. set lodGenerationScale(value: number);
  7580. /**
  7581. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7582. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7583. * average roughness values.
  7584. */
  7585. get linearSpecularLOD(): boolean;
  7586. set linearSpecularLOD(value: boolean);
  7587. /**
  7588. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7589. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7590. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7591. */
  7592. get irradianceTexture(): Nullable<BaseTexture>;
  7593. set irradianceTexture(value: Nullable<BaseTexture>);
  7594. /**
  7595. * Define if the texture is a render target.
  7596. */
  7597. isRenderTarget: boolean;
  7598. /**
  7599. * Define the unique id of the texture in the scene.
  7600. */
  7601. get uid(): string;
  7602. /** @hidden */
  7603. _prefiltered: boolean;
  7604. /**
  7605. * Return a string representation of the texture.
  7606. * @returns the texture as a string
  7607. */
  7608. toString(): string;
  7609. /**
  7610. * Get the class name of the texture.
  7611. * @returns "BaseTexture"
  7612. */
  7613. getClassName(): string;
  7614. /**
  7615. * Define the list of animation attached to the texture.
  7616. */
  7617. animations: Animation[];
  7618. /**
  7619. * An event triggered when the texture is disposed.
  7620. */
  7621. onDisposeObservable: Observable<BaseTexture>;
  7622. private _onDisposeObserver;
  7623. /**
  7624. * Callback triggered when the texture has been disposed.
  7625. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7626. */
  7627. set onDispose(callback: () => void);
  7628. protected _scene: Nullable<Scene>;
  7629. /** @hidden */
  7630. _texture: Nullable<InternalTexture>;
  7631. private _uid;
  7632. /**
  7633. * Define if the texture is preventinga material to render or not.
  7634. * If not and the texture is not ready, the engine will use a default black texture instead.
  7635. */
  7636. get isBlocking(): boolean;
  7637. /**
  7638. * Instantiates a new BaseTexture.
  7639. * Base class of all the textures in babylon.
  7640. * It groups all the common properties the materials, post process, lights... might need
  7641. * in order to make a correct use of the texture.
  7642. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7643. */
  7644. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7645. /**
  7646. * Get the scene the texture belongs to.
  7647. * @returns the scene or null if undefined
  7648. */
  7649. getScene(): Nullable<Scene>;
  7650. /** @hidden */
  7651. protected _getEngine(): Nullable<ThinEngine>;
  7652. /**
  7653. * Checks if the texture has the same transform matrix than another texture
  7654. * @param texture texture to check against
  7655. * @returns true if the transforms are the same, else false
  7656. */
  7657. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7658. /**
  7659. * Get the texture transform matrix used to offset tile the texture for istance.
  7660. * @returns the transformation matrix
  7661. */
  7662. getTextureMatrix(): Matrix;
  7663. /**
  7664. * Get the texture reflection matrix used to rotate/transform the reflection.
  7665. * @returns the reflection matrix
  7666. */
  7667. getReflectionTextureMatrix(): Matrix;
  7668. /**
  7669. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7670. * @returns true if ready or not blocking
  7671. */
  7672. isReadyOrNotBlocking(): boolean;
  7673. /**
  7674. * Scales the texture if is `canRescale()`
  7675. * @param ratio the resize factor we want to use to rescale
  7676. */
  7677. scale(ratio: number): void;
  7678. /**
  7679. * Get if the texture can rescale.
  7680. */
  7681. get canRescale(): boolean;
  7682. /** @hidden */
  7683. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7684. /** @hidden */
  7685. _rebuild(): void;
  7686. /**
  7687. * Clones the texture.
  7688. * @returns the cloned texture
  7689. */
  7690. clone(): Nullable<BaseTexture>;
  7691. /**
  7692. * Get the texture underlying type (INT, FLOAT...)
  7693. */
  7694. get textureType(): number;
  7695. /**
  7696. * Get the texture underlying format (RGB, RGBA...)
  7697. */
  7698. get textureFormat(): number;
  7699. /**
  7700. * Indicates that textures need to be re-calculated for all materials
  7701. */
  7702. protected _markAllSubMeshesAsTexturesDirty(): void;
  7703. /**
  7704. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7705. * This will returns an RGBA array buffer containing either in values (0-255) or
  7706. * float values (0-1) depending of the underlying buffer type.
  7707. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7708. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7709. * @param buffer defines a user defined buffer to fill with data (can be null)
  7710. * @returns The Array buffer containing the pixels data.
  7711. */
  7712. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  7713. /** @hidden */
  7714. get _lodTextureHigh(): Nullable<BaseTexture>;
  7715. /** @hidden */
  7716. get _lodTextureMid(): Nullable<BaseTexture>;
  7717. /** @hidden */
  7718. get _lodTextureLow(): Nullable<BaseTexture>;
  7719. /**
  7720. * Dispose the texture and release its associated resources.
  7721. */
  7722. dispose(): void;
  7723. /**
  7724. * Serialize the texture into a JSON representation that can be parsed later on.
  7725. * @returns the JSON representation of the texture
  7726. */
  7727. serialize(): any;
  7728. /**
  7729. * Helper function to be called back once a list of texture contains only ready textures.
  7730. * @param textures Define the list of textures to wait for
  7731. * @param callback Define the callback triggered once the entire list will be ready
  7732. */
  7733. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  7734. private static _isScene;
  7735. }
  7736. }
  7737. declare module BABYLON {
  7738. /** @hidden */
  7739. export class WebGLDataBuffer extends DataBuffer {
  7740. private _buffer;
  7741. constructor(resource: WebGLBuffer);
  7742. get underlyingResource(): any;
  7743. }
  7744. }
  7745. declare module BABYLON {
  7746. /** @hidden */
  7747. export class WebGLPipelineContext implements IPipelineContext {
  7748. engine: ThinEngine;
  7749. program: Nullable<WebGLProgram>;
  7750. context?: WebGLRenderingContext;
  7751. vertexShader?: WebGLShader;
  7752. fragmentShader?: WebGLShader;
  7753. isParallelCompiled: boolean;
  7754. onCompiled?: () => void;
  7755. transformFeedback?: WebGLTransformFeedback | null;
  7756. vertexCompilationError: Nullable<string>;
  7757. fragmentCompilationError: Nullable<string>;
  7758. programLinkError: Nullable<string>;
  7759. programValidationError: Nullable<string>;
  7760. get isAsync(): boolean;
  7761. get isReady(): boolean;
  7762. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7763. _getVertexShaderCode(): string | null;
  7764. _getFragmentShaderCode(): string | null;
  7765. }
  7766. }
  7767. declare module BABYLON {
  7768. interface ThinEngine {
  7769. /**
  7770. * Create an uniform buffer
  7771. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7772. * @param elements defines the content of the uniform buffer
  7773. * @returns the webGL uniform buffer
  7774. */
  7775. createUniformBuffer(elements: FloatArray): DataBuffer;
  7776. /**
  7777. * Create a dynamic uniform buffer
  7778. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7779. * @param elements defines the content of the uniform buffer
  7780. * @returns the webGL uniform buffer
  7781. */
  7782. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7783. /**
  7784. * Update an existing uniform buffer
  7785. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7786. * @param uniformBuffer defines the target uniform buffer
  7787. * @param elements defines the content to update
  7788. * @param offset defines the offset in the uniform buffer where update should start
  7789. * @param count defines the size of the data to update
  7790. */
  7791. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7792. /**
  7793. * Bind an uniform buffer to the current webGL context
  7794. * @param buffer defines the buffer to bind
  7795. */
  7796. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7797. /**
  7798. * Bind a buffer to the current webGL context at a given location
  7799. * @param buffer defines the buffer to bind
  7800. * @param location defines the index where to bind the buffer
  7801. */
  7802. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7803. /**
  7804. * Bind a specific block at a given index in a specific shader program
  7805. * @param pipelineContext defines the pipeline context to use
  7806. * @param blockName defines the block name
  7807. * @param index defines the index where to bind the block
  7808. */
  7809. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7810. }
  7811. }
  7812. declare module BABYLON {
  7813. /**
  7814. * Uniform buffer objects.
  7815. *
  7816. * Handles blocks of uniform on the GPU.
  7817. *
  7818. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7819. *
  7820. * For more information, please refer to :
  7821. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7822. */
  7823. export class UniformBuffer {
  7824. private _engine;
  7825. private _buffer;
  7826. private _data;
  7827. private _bufferData;
  7828. private _dynamic?;
  7829. private _uniformLocations;
  7830. private _uniformSizes;
  7831. private _uniformLocationPointer;
  7832. private _needSync;
  7833. private _noUBO;
  7834. private _currentEffect;
  7835. /** @hidden */
  7836. _alreadyBound: boolean;
  7837. private static _MAX_UNIFORM_SIZE;
  7838. private static _tempBuffer;
  7839. /**
  7840. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7841. * This is dynamic to allow compat with webgl 1 and 2.
  7842. * You will need to pass the name of the uniform as well as the value.
  7843. */
  7844. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7845. /**
  7846. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7847. * This is dynamic to allow compat with webgl 1 and 2.
  7848. * You will need to pass the name of the uniform as well as the value.
  7849. */
  7850. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7851. /**
  7852. * Lambda to Update a single float in a uniform buffer.
  7853. * This is dynamic to allow compat with webgl 1 and 2.
  7854. * You will need to pass the name of the uniform as well as the value.
  7855. */
  7856. updateFloat: (name: string, x: number) => void;
  7857. /**
  7858. * Lambda to Update a vec2 of float in a uniform buffer.
  7859. * This is dynamic to allow compat with webgl 1 and 2.
  7860. * You will need to pass the name of the uniform as well as the value.
  7861. */
  7862. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7863. /**
  7864. * Lambda to Update a vec3 of float in a uniform buffer.
  7865. * This is dynamic to allow compat with webgl 1 and 2.
  7866. * You will need to pass the name of the uniform as well as the value.
  7867. */
  7868. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7869. /**
  7870. * Lambda to Update a vec4 of float in a uniform buffer.
  7871. * This is dynamic to allow compat with webgl 1 and 2.
  7872. * You will need to pass the name of the uniform as well as the value.
  7873. */
  7874. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7875. /**
  7876. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7877. * This is dynamic to allow compat with webgl 1 and 2.
  7878. * You will need to pass the name of the uniform as well as the value.
  7879. */
  7880. updateMatrix: (name: string, mat: Matrix) => void;
  7881. /**
  7882. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7883. * This is dynamic to allow compat with webgl 1 and 2.
  7884. * You will need to pass the name of the uniform as well as the value.
  7885. */
  7886. updateVector3: (name: string, vector: Vector3) => void;
  7887. /**
  7888. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7889. * This is dynamic to allow compat with webgl 1 and 2.
  7890. * You will need to pass the name of the uniform as well as the value.
  7891. */
  7892. updateVector4: (name: string, vector: Vector4) => void;
  7893. /**
  7894. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7895. * This is dynamic to allow compat with webgl 1 and 2.
  7896. * You will need to pass the name of the uniform as well as the value.
  7897. */
  7898. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7899. /**
  7900. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7901. * This is dynamic to allow compat with webgl 1 and 2.
  7902. * You will need to pass the name of the uniform as well as the value.
  7903. */
  7904. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7905. /**
  7906. * Instantiates a new Uniform buffer objects.
  7907. *
  7908. * Handles blocks of uniform on the GPU.
  7909. *
  7910. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7911. *
  7912. * For more information, please refer to :
  7913. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7914. * @param engine Define the engine the buffer is associated with
  7915. * @param data Define the data contained in the buffer
  7916. * @param dynamic Define if the buffer is updatable
  7917. */
  7918. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7919. /**
  7920. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7921. * or just falling back on setUniformXXX calls.
  7922. */
  7923. get useUbo(): boolean;
  7924. /**
  7925. * Indicates if the WebGL underlying uniform buffer is in sync
  7926. * with the javascript cache data.
  7927. */
  7928. get isSync(): boolean;
  7929. /**
  7930. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7931. * Also, a dynamic UniformBuffer will disable cache verification and always
  7932. * update the underlying WebGL uniform buffer to the GPU.
  7933. * @returns if Dynamic, otherwise false
  7934. */
  7935. isDynamic(): boolean;
  7936. /**
  7937. * The data cache on JS side.
  7938. * @returns the underlying data as a float array
  7939. */
  7940. getData(): Float32Array;
  7941. /**
  7942. * The underlying WebGL Uniform buffer.
  7943. * @returns the webgl buffer
  7944. */
  7945. getBuffer(): Nullable<DataBuffer>;
  7946. /**
  7947. * std140 layout specifies how to align data within an UBO structure.
  7948. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7949. * for specs.
  7950. */
  7951. private _fillAlignment;
  7952. /**
  7953. * Adds an uniform in the buffer.
  7954. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7955. * for the layout to be correct !
  7956. * @param name Name of the uniform, as used in the uniform block in the shader.
  7957. * @param size Data size, or data directly.
  7958. */
  7959. addUniform(name: string, size: number | number[]): void;
  7960. /**
  7961. * Adds a Matrix 4x4 to the uniform buffer.
  7962. * @param name Name of the uniform, as used in the uniform block in the shader.
  7963. * @param mat A 4x4 matrix.
  7964. */
  7965. addMatrix(name: string, mat: Matrix): void;
  7966. /**
  7967. * Adds a vec2 to the uniform buffer.
  7968. * @param name Name of the uniform, as used in the uniform block in the shader.
  7969. * @param x Define the x component value of the vec2
  7970. * @param y Define the y component value of the vec2
  7971. */
  7972. addFloat2(name: string, x: number, y: number): void;
  7973. /**
  7974. * Adds a vec3 to the uniform buffer.
  7975. * @param name Name of the uniform, as used in the uniform block in the shader.
  7976. * @param x Define the x component value of the vec3
  7977. * @param y Define the y component value of the vec3
  7978. * @param z Define the z component value of the vec3
  7979. */
  7980. addFloat3(name: string, x: number, y: number, z: number): void;
  7981. /**
  7982. * Adds a vec3 to the uniform buffer.
  7983. * @param name Name of the uniform, as used in the uniform block in the shader.
  7984. * @param color Define the vec3 from a Color
  7985. */
  7986. addColor3(name: string, color: Color3): void;
  7987. /**
  7988. * Adds a vec4 to the uniform buffer.
  7989. * @param name Name of the uniform, as used in the uniform block in the shader.
  7990. * @param color Define the rgb components from a Color
  7991. * @param alpha Define the a component of the vec4
  7992. */
  7993. addColor4(name: string, color: Color3, alpha: number): void;
  7994. /**
  7995. * Adds a vec3 to the uniform buffer.
  7996. * @param name Name of the uniform, as used in the uniform block in the shader.
  7997. * @param vector Define the vec3 components from a Vector
  7998. */
  7999. addVector3(name: string, vector: Vector3): void;
  8000. /**
  8001. * Adds a Matrix 3x3 to the uniform buffer.
  8002. * @param name Name of the uniform, as used in the uniform block in the shader.
  8003. */
  8004. addMatrix3x3(name: string): void;
  8005. /**
  8006. * Adds a Matrix 2x2 to the uniform buffer.
  8007. * @param name Name of the uniform, as used in the uniform block in the shader.
  8008. */
  8009. addMatrix2x2(name: string): void;
  8010. /**
  8011. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8012. */
  8013. create(): void;
  8014. /** @hidden */
  8015. _rebuild(): void;
  8016. /**
  8017. * Updates the WebGL Uniform Buffer on the GPU.
  8018. * If the `dynamic` flag is set to true, no cache comparison is done.
  8019. * Otherwise, the buffer will be updated only if the cache differs.
  8020. */
  8021. update(): void;
  8022. /**
  8023. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8024. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8025. * @param data Define the flattened data
  8026. * @param size Define the size of the data.
  8027. */
  8028. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8029. private _valueCache;
  8030. private _cacheMatrix;
  8031. private _updateMatrix3x3ForUniform;
  8032. private _updateMatrix3x3ForEffect;
  8033. private _updateMatrix2x2ForEffect;
  8034. private _updateMatrix2x2ForUniform;
  8035. private _updateFloatForEffect;
  8036. private _updateFloatForUniform;
  8037. private _updateFloat2ForEffect;
  8038. private _updateFloat2ForUniform;
  8039. private _updateFloat3ForEffect;
  8040. private _updateFloat3ForUniform;
  8041. private _updateFloat4ForEffect;
  8042. private _updateFloat4ForUniform;
  8043. private _updateMatrixForEffect;
  8044. private _updateMatrixForUniform;
  8045. private _updateVector3ForEffect;
  8046. private _updateVector3ForUniform;
  8047. private _updateVector4ForEffect;
  8048. private _updateVector4ForUniform;
  8049. private _updateColor3ForEffect;
  8050. private _updateColor3ForUniform;
  8051. private _updateColor4ForEffect;
  8052. private _updateColor4ForUniform;
  8053. /**
  8054. * Sets a sampler uniform on the effect.
  8055. * @param name Define the name of the sampler.
  8056. * @param texture Define the texture to set in the sampler
  8057. */
  8058. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8059. /**
  8060. * Directly updates the value of the uniform in the cache AND on the GPU.
  8061. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8062. * @param data Define the flattened data
  8063. */
  8064. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8065. /**
  8066. * Binds this uniform buffer to an effect.
  8067. * @param effect Define the effect to bind the buffer to
  8068. * @param name Name of the uniform block in the shader.
  8069. */
  8070. bindToEffect(effect: Effect, name: string): void;
  8071. /**
  8072. * Disposes the uniform buffer.
  8073. */
  8074. dispose(): void;
  8075. }
  8076. }
  8077. declare module BABYLON {
  8078. /**
  8079. * Manages the defines for the Material
  8080. */
  8081. export class MaterialDefines {
  8082. /** @hidden */
  8083. protected _keys: string[];
  8084. private _isDirty;
  8085. /** @hidden */
  8086. _renderId: number;
  8087. /** @hidden */
  8088. _areLightsDirty: boolean;
  8089. /** @hidden */
  8090. _areLightsDisposed: boolean;
  8091. /** @hidden */
  8092. _areAttributesDirty: boolean;
  8093. /** @hidden */
  8094. _areTexturesDirty: boolean;
  8095. /** @hidden */
  8096. _areFresnelDirty: boolean;
  8097. /** @hidden */
  8098. _areMiscDirty: boolean;
  8099. /** @hidden */
  8100. _arePrePassDirty: boolean;
  8101. /** @hidden */
  8102. _areImageProcessingDirty: boolean;
  8103. /** @hidden */
  8104. _normals: boolean;
  8105. /** @hidden */
  8106. _uvs: boolean;
  8107. /** @hidden */
  8108. _needNormals: boolean;
  8109. /** @hidden */
  8110. _needUVs: boolean;
  8111. [id: string]: any;
  8112. /**
  8113. * Specifies if the material needs to be re-calculated
  8114. */
  8115. get isDirty(): boolean;
  8116. /**
  8117. * Marks the material to indicate that it has been re-calculated
  8118. */
  8119. markAsProcessed(): void;
  8120. /**
  8121. * Marks the material to indicate that it needs to be re-calculated
  8122. */
  8123. markAsUnprocessed(): void;
  8124. /**
  8125. * Marks the material to indicate all of its defines need to be re-calculated
  8126. */
  8127. markAllAsDirty(): void;
  8128. /**
  8129. * Marks the material to indicate that image processing needs to be re-calculated
  8130. */
  8131. markAsImageProcessingDirty(): void;
  8132. /**
  8133. * Marks the material to indicate the lights need to be re-calculated
  8134. * @param disposed Defines whether the light is dirty due to dispose or not
  8135. */
  8136. markAsLightDirty(disposed?: boolean): void;
  8137. /**
  8138. * Marks the attribute state as changed
  8139. */
  8140. markAsAttributesDirty(): void;
  8141. /**
  8142. * Marks the texture state as changed
  8143. */
  8144. markAsTexturesDirty(): void;
  8145. /**
  8146. * Marks the fresnel state as changed
  8147. */
  8148. markAsFresnelDirty(): void;
  8149. /**
  8150. * Marks the misc state as changed
  8151. */
  8152. markAsMiscDirty(): void;
  8153. /**
  8154. * Marks the prepass state as changed
  8155. */
  8156. markAsPrePassDirty(): void;
  8157. /**
  8158. * Rebuilds the material defines
  8159. */
  8160. rebuild(): void;
  8161. /**
  8162. * Specifies if two material defines are equal
  8163. * @param other - A material define instance to compare to
  8164. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8165. */
  8166. isEqual(other: MaterialDefines): boolean;
  8167. /**
  8168. * Clones this instance's defines to another instance
  8169. * @param other - material defines to clone values to
  8170. */
  8171. cloneTo(other: MaterialDefines): void;
  8172. /**
  8173. * Resets the material define values
  8174. */
  8175. reset(): void;
  8176. /**
  8177. * Converts the material define values to a string
  8178. * @returns - String of material define information
  8179. */
  8180. toString(): string;
  8181. }
  8182. }
  8183. declare module BABYLON {
  8184. /**
  8185. * Enum that determines the text-wrapping mode to use.
  8186. */
  8187. export enum InspectableType {
  8188. /**
  8189. * Checkbox for booleans
  8190. */
  8191. Checkbox = 0,
  8192. /**
  8193. * Sliders for numbers
  8194. */
  8195. Slider = 1,
  8196. /**
  8197. * Vector3
  8198. */
  8199. Vector3 = 2,
  8200. /**
  8201. * Quaternions
  8202. */
  8203. Quaternion = 3,
  8204. /**
  8205. * Color3
  8206. */
  8207. Color3 = 4,
  8208. /**
  8209. * String
  8210. */
  8211. String = 5
  8212. }
  8213. /**
  8214. * Interface used to define custom inspectable properties.
  8215. * This interface is used by the inspector to display custom property grids
  8216. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8217. */
  8218. export interface IInspectable {
  8219. /**
  8220. * Gets the label to display
  8221. */
  8222. label: string;
  8223. /**
  8224. * Gets the name of the property to edit
  8225. */
  8226. propertyName: string;
  8227. /**
  8228. * Gets the type of the editor to use
  8229. */
  8230. type: InspectableType;
  8231. /**
  8232. * Gets the minimum value of the property when using in "slider" mode
  8233. */
  8234. min?: number;
  8235. /**
  8236. * Gets the maximum value of the property when using in "slider" mode
  8237. */
  8238. max?: number;
  8239. /**
  8240. * Gets the setp to use when using in "slider" mode
  8241. */
  8242. step?: number;
  8243. }
  8244. }
  8245. declare module BABYLON {
  8246. /**
  8247. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8248. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8249. * 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.
  8250. */
  8251. export abstract class Light extends Node {
  8252. /**
  8253. * Falloff Default: light is falling off following the material specification:
  8254. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8255. */
  8256. static readonly FALLOFF_DEFAULT: number;
  8257. /**
  8258. * Falloff Physical: light is falling off following the inverse squared distance law.
  8259. */
  8260. static readonly FALLOFF_PHYSICAL: number;
  8261. /**
  8262. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8263. * to enhance interoperability with other engines.
  8264. */
  8265. static readonly FALLOFF_GLTF: number;
  8266. /**
  8267. * Falloff Standard: light is falling off like in the standard material
  8268. * to enhance interoperability with other materials.
  8269. */
  8270. static readonly FALLOFF_STANDARD: number;
  8271. /**
  8272. * If every light affecting the material is in this lightmapMode,
  8273. * material.lightmapTexture adds or multiplies
  8274. * (depends on material.useLightmapAsShadowmap)
  8275. * after every other light calculations.
  8276. */
  8277. static readonly LIGHTMAP_DEFAULT: number;
  8278. /**
  8279. * material.lightmapTexture as only diffuse lighting from this light
  8280. * adds only specular lighting from this light
  8281. * adds dynamic shadows
  8282. */
  8283. static readonly LIGHTMAP_SPECULAR: number;
  8284. /**
  8285. * material.lightmapTexture as only lighting
  8286. * no light calculation from this light
  8287. * only adds dynamic shadows from this light
  8288. */
  8289. static readonly LIGHTMAP_SHADOWSONLY: number;
  8290. /**
  8291. * Each light type uses the default quantity according to its type:
  8292. * point/spot lights use luminous intensity
  8293. * directional lights use illuminance
  8294. */
  8295. static readonly INTENSITYMODE_AUTOMATIC: number;
  8296. /**
  8297. * lumen (lm)
  8298. */
  8299. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8300. /**
  8301. * candela (lm/sr)
  8302. */
  8303. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8304. /**
  8305. * lux (lm/m^2)
  8306. */
  8307. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8308. /**
  8309. * nit (cd/m^2)
  8310. */
  8311. static readonly INTENSITYMODE_LUMINANCE: number;
  8312. /**
  8313. * Light type const id of the point light.
  8314. */
  8315. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8316. /**
  8317. * Light type const id of the directional light.
  8318. */
  8319. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8320. /**
  8321. * Light type const id of the spot light.
  8322. */
  8323. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8324. /**
  8325. * Light type const id of the hemispheric light.
  8326. */
  8327. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8328. /**
  8329. * Diffuse gives the basic color to an object.
  8330. */
  8331. diffuse: Color3;
  8332. /**
  8333. * Specular produces a highlight color on an object.
  8334. * Note: This is note affecting PBR materials.
  8335. */
  8336. specular: Color3;
  8337. /**
  8338. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8339. * falling off base on range or angle.
  8340. * This can be set to any values in Light.FALLOFF_x.
  8341. *
  8342. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8343. * other types of materials.
  8344. */
  8345. falloffType: number;
  8346. /**
  8347. * Strength of the light.
  8348. * Note: By default it is define in the framework own unit.
  8349. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8350. */
  8351. intensity: number;
  8352. private _range;
  8353. protected _inverseSquaredRange: number;
  8354. /**
  8355. * Defines how far from the source the light is impacting in scene units.
  8356. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8357. */
  8358. get range(): number;
  8359. /**
  8360. * Defines how far from the source the light is impacting in scene units.
  8361. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8362. */
  8363. set range(value: number);
  8364. /**
  8365. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8366. * of light.
  8367. */
  8368. private _photometricScale;
  8369. private _intensityMode;
  8370. /**
  8371. * Gets the photometric scale used to interpret the intensity.
  8372. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8373. */
  8374. get intensityMode(): number;
  8375. /**
  8376. * Sets the photometric scale used to interpret the intensity.
  8377. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8378. */
  8379. set intensityMode(value: number);
  8380. private _radius;
  8381. /**
  8382. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8383. */
  8384. get radius(): number;
  8385. /**
  8386. * sets the light radius used by PBR Materials to simulate soft area lights.
  8387. */
  8388. set radius(value: number);
  8389. private _renderPriority;
  8390. /**
  8391. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8392. * exceeding the number allowed of the materials.
  8393. */
  8394. renderPriority: number;
  8395. private _shadowEnabled;
  8396. /**
  8397. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8398. * the current shadow generator.
  8399. */
  8400. get shadowEnabled(): boolean;
  8401. /**
  8402. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8403. * the current shadow generator.
  8404. */
  8405. set shadowEnabled(value: boolean);
  8406. private _includedOnlyMeshes;
  8407. /**
  8408. * Gets the only meshes impacted by this light.
  8409. */
  8410. get includedOnlyMeshes(): AbstractMesh[];
  8411. /**
  8412. * Sets the only meshes impacted by this light.
  8413. */
  8414. set includedOnlyMeshes(value: AbstractMesh[]);
  8415. private _excludedMeshes;
  8416. /**
  8417. * Gets the meshes not impacted by this light.
  8418. */
  8419. get excludedMeshes(): AbstractMesh[];
  8420. /**
  8421. * Sets the meshes not impacted by this light.
  8422. */
  8423. set excludedMeshes(value: AbstractMesh[]);
  8424. private _excludeWithLayerMask;
  8425. /**
  8426. * Gets the layer id use to find what meshes are not impacted by the light.
  8427. * Inactive if 0
  8428. */
  8429. get excludeWithLayerMask(): number;
  8430. /**
  8431. * Sets the layer id use to find what meshes are not impacted by the light.
  8432. * Inactive if 0
  8433. */
  8434. set excludeWithLayerMask(value: number);
  8435. private _includeOnlyWithLayerMask;
  8436. /**
  8437. * Gets the layer id use to find what meshes are impacted by the light.
  8438. * Inactive if 0
  8439. */
  8440. get includeOnlyWithLayerMask(): number;
  8441. /**
  8442. * Sets the layer id use to find what meshes are impacted by the light.
  8443. * Inactive if 0
  8444. */
  8445. set includeOnlyWithLayerMask(value: number);
  8446. private _lightmapMode;
  8447. /**
  8448. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8449. */
  8450. get lightmapMode(): number;
  8451. /**
  8452. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8453. */
  8454. set lightmapMode(value: number);
  8455. /**
  8456. * Shadow generator associted to the light.
  8457. * @hidden Internal use only.
  8458. */
  8459. _shadowGenerator: Nullable<IShadowGenerator>;
  8460. /**
  8461. * @hidden Internal use only.
  8462. */
  8463. _excludedMeshesIds: string[];
  8464. /**
  8465. * @hidden Internal use only.
  8466. */
  8467. _includedOnlyMeshesIds: string[];
  8468. /**
  8469. * The current light unifom buffer.
  8470. * @hidden Internal use only.
  8471. */
  8472. _uniformBuffer: UniformBuffer;
  8473. /** @hidden */
  8474. _renderId: number;
  8475. /**
  8476. * Creates a Light object in the scene.
  8477. * Documentation : https://doc.babylonjs.com/babylon101/lights
  8478. * @param name The firendly name of the light
  8479. * @param scene The scene the light belongs too
  8480. */
  8481. constructor(name: string, scene: Scene);
  8482. protected abstract _buildUniformLayout(): void;
  8483. /**
  8484. * Sets the passed Effect "effect" with the Light information.
  8485. * @param effect The effect to update
  8486. * @param lightIndex The index of the light in the effect to update
  8487. * @returns The light
  8488. */
  8489. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  8490. /**
  8491. * Sets the passed Effect "effect" with the Light textures.
  8492. * @param effect The effect to update
  8493. * @param lightIndex The index of the light in the effect to update
  8494. * @returns The light
  8495. */
  8496. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  8497. /**
  8498. * Binds the lights information from the scene to the effect for the given mesh.
  8499. * @param lightIndex Light index
  8500. * @param scene The scene where the light belongs to
  8501. * @param effect The effect we are binding the data to
  8502. * @param useSpecular Defines if specular is supported
  8503. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8504. */
  8505. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  8506. /**
  8507. * Sets the passed Effect "effect" with the Light information.
  8508. * @param effect The effect to update
  8509. * @param lightDataUniformName The uniform used to store light data (position or direction)
  8510. * @returns The light
  8511. */
  8512. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  8513. /**
  8514. * Returns the string "Light".
  8515. * @returns the class name
  8516. */
  8517. getClassName(): string;
  8518. /** @hidden */
  8519. readonly _isLight: boolean;
  8520. /**
  8521. * Converts the light information to a readable string for debug purpose.
  8522. * @param fullDetails Supports for multiple levels of logging within scene loading
  8523. * @returns the human readable light info
  8524. */
  8525. toString(fullDetails?: boolean): string;
  8526. /** @hidden */
  8527. protected _syncParentEnabledState(): void;
  8528. /**
  8529. * Set the enabled state of this node.
  8530. * @param value - the new enabled state
  8531. */
  8532. setEnabled(value: boolean): void;
  8533. /**
  8534. * Returns the Light associated shadow generator if any.
  8535. * @return the associated shadow generator.
  8536. */
  8537. getShadowGenerator(): Nullable<IShadowGenerator>;
  8538. /**
  8539. * Returns a Vector3, the absolute light position in the World.
  8540. * @returns the world space position of the light
  8541. */
  8542. getAbsolutePosition(): Vector3;
  8543. /**
  8544. * Specifies if the light will affect the passed mesh.
  8545. * @param mesh The mesh to test against the light
  8546. * @return true the mesh is affected otherwise, false.
  8547. */
  8548. canAffectMesh(mesh: AbstractMesh): boolean;
  8549. /**
  8550. * Sort function to order lights for rendering.
  8551. * @param a First Light object to compare to second.
  8552. * @param b Second Light object to compare first.
  8553. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  8554. */
  8555. static CompareLightsPriority(a: Light, b: Light): number;
  8556. /**
  8557. * Releases resources associated with this node.
  8558. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8559. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8560. */
  8561. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8562. /**
  8563. * Returns the light type ID (integer).
  8564. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8565. */
  8566. getTypeID(): number;
  8567. /**
  8568. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  8569. * @returns the scaled intensity in intensity mode unit
  8570. */
  8571. getScaledIntensity(): number;
  8572. /**
  8573. * Returns a new Light object, named "name", from the current one.
  8574. * @param name The name of the cloned light
  8575. * @param newParent The parent of this light, if it has one
  8576. * @returns the new created light
  8577. */
  8578. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  8579. /**
  8580. * Serializes the current light into a Serialization object.
  8581. * @returns the serialized object.
  8582. */
  8583. serialize(): any;
  8584. /**
  8585. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  8586. * This new light is named "name" and added to the passed scene.
  8587. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  8588. * @param name The friendly name of the light
  8589. * @param scene The scene the new light will belong to
  8590. * @returns the constructor function
  8591. */
  8592. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  8593. /**
  8594. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  8595. * @param parsedLight The JSON representation of the light
  8596. * @param scene The scene to create the parsed light in
  8597. * @returns the created light after parsing
  8598. */
  8599. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  8600. private _hookArrayForExcluded;
  8601. private _hookArrayForIncludedOnly;
  8602. private _resyncMeshes;
  8603. /**
  8604. * Forces the meshes to update their light related information in their rendering used effects
  8605. * @hidden Internal Use Only
  8606. */
  8607. _markMeshesAsLightDirty(): void;
  8608. /**
  8609. * Recomputes the cached photometric scale if needed.
  8610. */
  8611. private _computePhotometricScale;
  8612. /**
  8613. * Returns the Photometric Scale according to the light type and intensity mode.
  8614. */
  8615. private _getPhotometricScale;
  8616. /**
  8617. * Reorder the light in the scene according to their defined priority.
  8618. * @hidden Internal Use Only
  8619. */
  8620. _reorderLightsInScene(): void;
  8621. /**
  8622. * Prepares the list of defines specific to the light type.
  8623. * @param defines the list of defines
  8624. * @param lightIndex defines the index of the light for the effect
  8625. */
  8626. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  8627. }
  8628. }
  8629. declare module BABYLON {
  8630. /** Defines supported spaces */
  8631. export enum Space {
  8632. /** Local (object) space */
  8633. LOCAL = 0,
  8634. /** World space */
  8635. WORLD = 1,
  8636. /** Bone space */
  8637. BONE = 2
  8638. }
  8639. /** Defines the 3 main axes */
  8640. export class Axis {
  8641. /** X axis */
  8642. static X: Vector3;
  8643. /** Y axis */
  8644. static Y: Vector3;
  8645. /** Z axis */
  8646. static Z: Vector3;
  8647. }
  8648. /**
  8649. * Defines cartesian components.
  8650. */
  8651. export enum Coordinate {
  8652. /** X axis */
  8653. X = 0,
  8654. /** Y axis */
  8655. Y = 1,
  8656. /** Z axis */
  8657. Z = 2
  8658. }
  8659. }
  8660. declare module BABYLON {
  8661. /**
  8662. * Interface describing all the common properties and methods a shadow light needs to implement.
  8663. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8664. * as well as binding the different shadow properties to the effects.
  8665. */
  8666. export interface IShadowLight extends Light {
  8667. /**
  8668. * The light id in the scene (used in scene.findLighById for instance)
  8669. */
  8670. id: string;
  8671. /**
  8672. * The position the shdow will be casted from.
  8673. */
  8674. position: Vector3;
  8675. /**
  8676. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8677. */
  8678. direction: Vector3;
  8679. /**
  8680. * The transformed position. Position of the light in world space taking parenting in account.
  8681. */
  8682. transformedPosition: Vector3;
  8683. /**
  8684. * The transformed direction. Direction of the light in world space taking parenting in account.
  8685. */
  8686. transformedDirection: Vector3;
  8687. /**
  8688. * The friendly name of the light in the scene.
  8689. */
  8690. name: string;
  8691. /**
  8692. * Defines the shadow projection clipping minimum z value.
  8693. */
  8694. shadowMinZ: number;
  8695. /**
  8696. * Defines the shadow projection clipping maximum z value.
  8697. */
  8698. shadowMaxZ: number;
  8699. /**
  8700. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8701. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8702. */
  8703. computeTransformedInformation(): boolean;
  8704. /**
  8705. * Gets the scene the light belongs to.
  8706. * @returns The scene
  8707. */
  8708. getScene(): Scene;
  8709. /**
  8710. * Callback defining a custom Projection Matrix Builder.
  8711. * This can be used to override the default projection matrix computation.
  8712. */
  8713. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8714. /**
  8715. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8716. * @param matrix The materix to updated with the projection information
  8717. * @param viewMatrix The transform matrix of the light
  8718. * @param renderList The list of mesh to render in the map
  8719. * @returns The current light
  8720. */
  8721. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8722. /**
  8723. * Gets the current depth scale used in ESM.
  8724. * @returns The scale
  8725. */
  8726. getDepthScale(): number;
  8727. /**
  8728. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8729. * @returns true if a cube texture needs to be use
  8730. */
  8731. needCube(): boolean;
  8732. /**
  8733. * Detects if the projection matrix requires to be recomputed this frame.
  8734. * @returns true if it requires to be recomputed otherwise, false.
  8735. */
  8736. needProjectionMatrixCompute(): boolean;
  8737. /**
  8738. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8739. */
  8740. forceProjectionMatrixCompute(): void;
  8741. /**
  8742. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8743. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8744. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8745. */
  8746. getShadowDirection(faceIndex?: number): Vector3;
  8747. /**
  8748. * Gets the minZ used for shadow according to both the scene and the light.
  8749. * @param activeCamera The camera we are returning the min for
  8750. * @returns the depth min z
  8751. */
  8752. getDepthMinZ(activeCamera: Camera): number;
  8753. /**
  8754. * Gets the maxZ used for shadow according to both the scene and the light.
  8755. * @param activeCamera The camera we are returning the max for
  8756. * @returns the depth max z
  8757. */
  8758. getDepthMaxZ(activeCamera: Camera): number;
  8759. }
  8760. /**
  8761. * Base implementation IShadowLight
  8762. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8763. */
  8764. export abstract class ShadowLight extends Light implements IShadowLight {
  8765. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8766. protected _position: Vector3;
  8767. protected _setPosition(value: Vector3): void;
  8768. /**
  8769. * Sets the position the shadow will be casted from. Also use as the light position for both
  8770. * point and spot lights.
  8771. */
  8772. get position(): Vector3;
  8773. /**
  8774. * Sets the position the shadow will be casted from. Also use as the light position for both
  8775. * point and spot lights.
  8776. */
  8777. set position(value: Vector3);
  8778. protected _direction: Vector3;
  8779. protected _setDirection(value: Vector3): void;
  8780. /**
  8781. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8782. * Also use as the light direction on spot and directional lights.
  8783. */
  8784. get direction(): Vector3;
  8785. /**
  8786. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8787. * Also use as the light direction on spot and directional lights.
  8788. */
  8789. set direction(value: Vector3);
  8790. protected _shadowMinZ: number;
  8791. /**
  8792. * Gets the shadow projection clipping minimum z value.
  8793. */
  8794. get shadowMinZ(): number;
  8795. /**
  8796. * Sets the shadow projection clipping minimum z value.
  8797. */
  8798. set shadowMinZ(value: number);
  8799. protected _shadowMaxZ: number;
  8800. /**
  8801. * Sets the shadow projection clipping maximum z value.
  8802. */
  8803. get shadowMaxZ(): number;
  8804. /**
  8805. * Gets the shadow projection clipping maximum z value.
  8806. */
  8807. set shadowMaxZ(value: number);
  8808. /**
  8809. * Callback defining a custom Projection Matrix Builder.
  8810. * This can be used to override the default projection matrix computation.
  8811. */
  8812. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8813. /**
  8814. * The transformed position. Position of the light in world space taking parenting in account.
  8815. */
  8816. transformedPosition: Vector3;
  8817. /**
  8818. * The transformed direction. Direction of the light in world space taking parenting in account.
  8819. */
  8820. transformedDirection: Vector3;
  8821. private _needProjectionMatrixCompute;
  8822. /**
  8823. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8824. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8825. */
  8826. computeTransformedInformation(): boolean;
  8827. /**
  8828. * Return the depth scale used for the shadow map.
  8829. * @returns the depth scale.
  8830. */
  8831. getDepthScale(): number;
  8832. /**
  8833. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8834. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8835. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8836. */
  8837. getShadowDirection(faceIndex?: number): Vector3;
  8838. /**
  8839. * Returns the ShadowLight absolute position in the World.
  8840. * @returns the position vector in world space
  8841. */
  8842. getAbsolutePosition(): Vector3;
  8843. /**
  8844. * Sets the ShadowLight direction toward the passed target.
  8845. * @param target The point to target in local space
  8846. * @returns the updated ShadowLight direction
  8847. */
  8848. setDirectionToTarget(target: Vector3): Vector3;
  8849. /**
  8850. * Returns the light rotation in euler definition.
  8851. * @returns the x y z rotation in local space.
  8852. */
  8853. getRotation(): Vector3;
  8854. /**
  8855. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8856. * @returns true if a cube texture needs to be use
  8857. */
  8858. needCube(): boolean;
  8859. /**
  8860. * Detects if the projection matrix requires to be recomputed this frame.
  8861. * @returns true if it requires to be recomputed otherwise, false.
  8862. */
  8863. needProjectionMatrixCompute(): boolean;
  8864. /**
  8865. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8866. */
  8867. forceProjectionMatrixCompute(): void;
  8868. /** @hidden */
  8869. _initCache(): void;
  8870. /** @hidden */
  8871. _isSynchronized(): boolean;
  8872. /**
  8873. * Computes the world matrix of the node
  8874. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8875. * @returns the world matrix
  8876. */
  8877. computeWorldMatrix(force?: boolean): Matrix;
  8878. /**
  8879. * Gets the minZ used for shadow according to both the scene and the light.
  8880. * @param activeCamera The camera we are returning the min for
  8881. * @returns the depth min z
  8882. */
  8883. getDepthMinZ(activeCamera: Camera): number;
  8884. /**
  8885. * Gets the maxZ used for shadow according to both the scene and the light.
  8886. * @param activeCamera The camera we are returning the max for
  8887. * @returns the depth max z
  8888. */
  8889. getDepthMaxZ(activeCamera: Camera): number;
  8890. /**
  8891. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8892. * @param matrix The materix to updated with the projection information
  8893. * @param viewMatrix The transform matrix of the light
  8894. * @param renderList The list of mesh to render in the map
  8895. * @returns The current light
  8896. */
  8897. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8898. }
  8899. }
  8900. declare module BABYLON {
  8901. /**
  8902. * Configuration needed for prepass-capable materials
  8903. */
  8904. export class PrePassConfiguration {
  8905. /**
  8906. * Previous world matrices of meshes carrying this material
  8907. * Used for computing velocity
  8908. */
  8909. previousWorldMatrices: {
  8910. [index: number]: Matrix;
  8911. };
  8912. /**
  8913. * Previous view project matrix
  8914. * Used for computing velocity
  8915. */
  8916. previousViewProjection: Matrix;
  8917. /**
  8918. * Previous bones of meshes carrying this material
  8919. * Used for computing velocity
  8920. */
  8921. previousBones: {
  8922. [index: number]: Float32Array;
  8923. };
  8924. /**
  8925. * Add the required uniforms to the current list.
  8926. * @param uniforms defines the current uniform list.
  8927. */
  8928. static AddUniforms(uniforms: string[]): void;
  8929. /**
  8930. * Add the required samplers to the current list.
  8931. * @param samplers defines the current sampler list.
  8932. */
  8933. static AddSamplers(samplers: string[]): void;
  8934. /**
  8935. * Binds the material data.
  8936. * @param effect defines the effect to update
  8937. * @param scene defines the scene the material belongs to.
  8938. * @param mesh The mesh
  8939. * @param world World matrix of this mesh
  8940. * @param isFrozen Is the material frozen
  8941. */
  8942. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  8943. }
  8944. }
  8945. declare module BABYLON {
  8946. /**
  8947. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8948. * This is the base of the follow, arc rotate cameras and Free camera
  8949. * @see https://doc.babylonjs.com/features/cameras
  8950. */
  8951. export class TargetCamera extends Camera {
  8952. private static _RigCamTransformMatrix;
  8953. private static _TargetTransformMatrix;
  8954. private static _TargetFocalPoint;
  8955. private _tmpUpVector;
  8956. private _tmpTargetVector;
  8957. /**
  8958. * Define the current direction the camera is moving to
  8959. */
  8960. cameraDirection: Vector3;
  8961. /**
  8962. * Define the current rotation the camera is rotating to
  8963. */
  8964. cameraRotation: Vector2;
  8965. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  8966. ignoreParentScaling: boolean;
  8967. /**
  8968. * When set, the up vector of the camera will be updated by the rotation of the camera
  8969. */
  8970. updateUpVectorFromRotation: boolean;
  8971. private _tmpQuaternion;
  8972. /**
  8973. * Define the current rotation of the camera
  8974. */
  8975. rotation: Vector3;
  8976. /**
  8977. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8978. */
  8979. rotationQuaternion: Quaternion;
  8980. /**
  8981. * Define the current speed of the camera
  8982. */
  8983. speed: number;
  8984. /**
  8985. * Add constraint to the camera to prevent it to move freely in all directions and
  8986. * around all axis.
  8987. */
  8988. noRotationConstraint: boolean;
  8989. /**
  8990. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8991. * panning
  8992. */
  8993. invertRotation: boolean;
  8994. /**
  8995. * Speed multiplier for inverse camera panning
  8996. */
  8997. inverseRotationSpeed: number;
  8998. /**
  8999. * Define the current target of the camera as an object or a position.
  9000. */
  9001. lockedTarget: any;
  9002. /** @hidden */
  9003. _currentTarget: Vector3;
  9004. /** @hidden */
  9005. _initialFocalDistance: number;
  9006. /** @hidden */
  9007. _viewMatrix: Matrix;
  9008. /** @hidden */
  9009. _camMatrix: Matrix;
  9010. /** @hidden */
  9011. _cameraTransformMatrix: Matrix;
  9012. /** @hidden */
  9013. _cameraRotationMatrix: Matrix;
  9014. /** @hidden */
  9015. _referencePoint: Vector3;
  9016. /** @hidden */
  9017. _transformedReferencePoint: Vector3;
  9018. /** @hidden */
  9019. _reset: () => void;
  9020. private _defaultUp;
  9021. /**
  9022. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9023. * This is the base of the follow, arc rotate cameras and Free camera
  9024. * @see https://doc.babylonjs.com/features/cameras
  9025. * @param name Defines the name of the camera in the scene
  9026. * @param position Defines the start position of the camera in the scene
  9027. * @param scene Defines the scene the camera belongs to
  9028. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9029. */
  9030. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9031. /**
  9032. * Gets the position in front of the camera at a given distance.
  9033. * @param distance The distance from the camera we want the position to be
  9034. * @returns the position
  9035. */
  9036. getFrontPosition(distance: number): Vector3;
  9037. /** @hidden */
  9038. _getLockedTargetPosition(): Nullable<Vector3>;
  9039. private _storedPosition;
  9040. private _storedRotation;
  9041. private _storedRotationQuaternion;
  9042. /**
  9043. * Store current camera state of the camera (fov, position, rotation, etc..)
  9044. * @returns the camera
  9045. */
  9046. storeState(): Camera;
  9047. /**
  9048. * Restored camera state. You must call storeState() first
  9049. * @returns whether it was successful or not
  9050. * @hidden
  9051. */
  9052. _restoreStateValues(): boolean;
  9053. /** @hidden */
  9054. _initCache(): void;
  9055. /** @hidden */
  9056. _updateCache(ignoreParentClass?: boolean): void;
  9057. /** @hidden */
  9058. _isSynchronizedViewMatrix(): boolean;
  9059. /** @hidden */
  9060. _computeLocalCameraSpeed(): number;
  9061. /**
  9062. * Defines the target the camera should look at.
  9063. * @param target Defines the new target as a Vector or a mesh
  9064. */
  9065. setTarget(target: Vector3): void;
  9066. /**
  9067. * Defines the target point of the camera.
  9068. * The camera looks towards it form the radius distance.
  9069. */
  9070. get target(): Vector3;
  9071. set target(value: Vector3);
  9072. /**
  9073. * Return the current target position of the camera. This value is expressed in local space.
  9074. * @returns the target position
  9075. */
  9076. getTarget(): Vector3;
  9077. /** @hidden */
  9078. _decideIfNeedsToMove(): boolean;
  9079. /** @hidden */
  9080. _updatePosition(): void;
  9081. /** @hidden */
  9082. _checkInputs(): void;
  9083. protected _updateCameraRotationMatrix(): void;
  9084. /**
  9085. * 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)
  9086. * @returns the current camera
  9087. */
  9088. private _rotateUpVectorWithCameraRotationMatrix;
  9089. private _cachedRotationZ;
  9090. private _cachedQuaternionRotationZ;
  9091. /** @hidden */
  9092. _getViewMatrix(): Matrix;
  9093. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9094. /**
  9095. * @hidden
  9096. */
  9097. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9098. /**
  9099. * @hidden
  9100. */
  9101. _updateRigCameras(): void;
  9102. private _getRigCamPositionAndTarget;
  9103. /**
  9104. * Gets the current object class name.
  9105. * @return the class name
  9106. */
  9107. getClassName(): string;
  9108. }
  9109. }
  9110. declare module BABYLON {
  9111. /**
  9112. * @ignore
  9113. * This is a list of all the different input types that are available in the application.
  9114. * Fo instance: ArcRotateCameraGamepadInput...
  9115. */
  9116. export var CameraInputTypes: {};
  9117. /**
  9118. * This is the contract to implement in order to create a new input class.
  9119. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9120. */
  9121. export interface ICameraInput<TCamera extends Camera> {
  9122. /**
  9123. * Defines the camera the input is attached to.
  9124. */
  9125. camera: Nullable<TCamera>;
  9126. /**
  9127. * Gets the class name of the current intput.
  9128. * @returns the class name
  9129. */
  9130. getClassName(): string;
  9131. /**
  9132. * Get the friendly name associated with the input class.
  9133. * @returns the input friendly name
  9134. */
  9135. getSimpleName(): string;
  9136. /**
  9137. * Attach the input controls to a specific dom element to get the input from.
  9138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9139. */
  9140. attachControl(noPreventDefault?: boolean): void;
  9141. /**
  9142. * Detach the current controls from the specified dom element.
  9143. */
  9144. detachControl(): void;
  9145. /**
  9146. * Update the current camera state depending on the inputs that have been used this frame.
  9147. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9148. */
  9149. checkInputs?: () => void;
  9150. }
  9151. /**
  9152. * Represents a map of input types to input instance or input index to input instance.
  9153. */
  9154. export interface CameraInputsMap<TCamera extends Camera> {
  9155. /**
  9156. * Accessor to the input by input type.
  9157. */
  9158. [name: string]: ICameraInput<TCamera>;
  9159. /**
  9160. * Accessor to the input by input index.
  9161. */
  9162. [idx: number]: ICameraInput<TCamera>;
  9163. }
  9164. /**
  9165. * This represents the input manager used within a camera.
  9166. * It helps dealing with all the different kind of input attached to a camera.
  9167. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9168. */
  9169. export class CameraInputsManager<TCamera extends Camera> {
  9170. /**
  9171. * Defines the list of inputs attahed to the camera.
  9172. */
  9173. attached: CameraInputsMap<TCamera>;
  9174. /**
  9175. * Defines the dom element the camera is collecting inputs from.
  9176. * This is null if the controls have not been attached.
  9177. */
  9178. attachedToElement: boolean;
  9179. /**
  9180. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9181. */
  9182. noPreventDefault: boolean;
  9183. /**
  9184. * Defined the camera the input manager belongs to.
  9185. */
  9186. camera: TCamera;
  9187. /**
  9188. * Update the current camera state depending on the inputs that have been used this frame.
  9189. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9190. */
  9191. checkInputs: () => void;
  9192. /**
  9193. * Instantiate a new Camera Input Manager.
  9194. * @param camera Defines the camera the input manager blongs to
  9195. */
  9196. constructor(camera: TCamera);
  9197. /**
  9198. * Add an input method to a camera
  9199. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9200. * @param input camera input method
  9201. */
  9202. add(input: ICameraInput<TCamera>): void;
  9203. /**
  9204. * Remove a specific input method from a camera
  9205. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9206. * @param inputToRemove camera input method
  9207. */
  9208. remove(inputToRemove: ICameraInput<TCamera>): void;
  9209. /**
  9210. * Remove a specific input type from a camera
  9211. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9212. * @param inputType the type of the input to remove
  9213. */
  9214. removeByType(inputType: string): void;
  9215. private _addCheckInputs;
  9216. /**
  9217. * Attach the input controls to the currently attached dom element to listen the events from.
  9218. * @param input Defines the input to attach
  9219. */
  9220. attachInput(input: ICameraInput<TCamera>): void;
  9221. /**
  9222. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9223. * @param element Defines the dom element to collect the events from
  9224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9225. */
  9226. attachElement(noPreventDefault?: boolean): void;
  9227. /**
  9228. * Detach the current manager inputs controls from a specific dom element.
  9229. * @param element Defines the dom element to collect the events from
  9230. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9231. */
  9232. detachElement(disconnect?: boolean): void;
  9233. /**
  9234. * Rebuild the dynamic inputCheck function from the current list of
  9235. * defined inputs in the manager.
  9236. */
  9237. rebuildInputCheck(): void;
  9238. /**
  9239. * Remove all attached input methods from a camera
  9240. */
  9241. clear(): void;
  9242. /**
  9243. * Serialize the current input manager attached to a camera.
  9244. * This ensures than once parsed,
  9245. * the input associated to the camera will be identical to the current ones
  9246. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9247. */
  9248. serialize(serializedCamera: any): void;
  9249. /**
  9250. * Parses an input manager serialized JSON to restore the previous list of inputs
  9251. * and states associated to a camera.
  9252. * @param parsedCamera Defines the JSON to parse
  9253. */
  9254. parse(parsedCamera: any): void;
  9255. }
  9256. }
  9257. declare module BABYLON {
  9258. /**
  9259. * Gather the list of keyboard event types as constants.
  9260. */
  9261. export class KeyboardEventTypes {
  9262. /**
  9263. * The keydown event is fired when a key becomes active (pressed).
  9264. */
  9265. static readonly KEYDOWN: number;
  9266. /**
  9267. * The keyup event is fired when a key has been released.
  9268. */
  9269. static readonly KEYUP: number;
  9270. }
  9271. /**
  9272. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9273. */
  9274. export class KeyboardInfo {
  9275. /**
  9276. * Defines the type of event (KeyboardEventTypes)
  9277. */
  9278. type: number;
  9279. /**
  9280. * Defines the related dom event
  9281. */
  9282. event: KeyboardEvent;
  9283. /**
  9284. * Instantiates a new keyboard info.
  9285. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9286. * @param type Defines the type of event (KeyboardEventTypes)
  9287. * @param event Defines the related dom event
  9288. */
  9289. constructor(
  9290. /**
  9291. * Defines the type of event (KeyboardEventTypes)
  9292. */
  9293. type: number,
  9294. /**
  9295. * Defines the related dom event
  9296. */
  9297. event: KeyboardEvent);
  9298. }
  9299. /**
  9300. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9301. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9302. */
  9303. export class KeyboardInfoPre extends KeyboardInfo {
  9304. /**
  9305. * Defines the type of event (KeyboardEventTypes)
  9306. */
  9307. type: number;
  9308. /**
  9309. * Defines the related dom event
  9310. */
  9311. event: KeyboardEvent;
  9312. /**
  9313. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9314. */
  9315. skipOnPointerObservable: boolean;
  9316. /**
  9317. * Instantiates a new keyboard pre info.
  9318. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9319. * @param type Defines the type of event (KeyboardEventTypes)
  9320. * @param event Defines the related dom event
  9321. */
  9322. constructor(
  9323. /**
  9324. * Defines the type of event (KeyboardEventTypes)
  9325. */
  9326. type: number,
  9327. /**
  9328. * Defines the related dom event
  9329. */
  9330. event: KeyboardEvent);
  9331. }
  9332. }
  9333. declare module BABYLON {
  9334. /**
  9335. * Manage the keyboard inputs to control the movement of a free camera.
  9336. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9337. */
  9338. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9339. /**
  9340. * Defines the camera the input is attached to.
  9341. */
  9342. camera: FreeCamera;
  9343. /**
  9344. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9345. */
  9346. keysUp: number[];
  9347. /**
  9348. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9349. */
  9350. keysUpward: number[];
  9351. /**
  9352. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9353. */
  9354. keysDown: number[];
  9355. /**
  9356. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9357. */
  9358. keysDownward: number[];
  9359. /**
  9360. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9361. */
  9362. keysLeft: number[];
  9363. /**
  9364. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9365. */
  9366. keysRight: number[];
  9367. private _keys;
  9368. private _onCanvasBlurObserver;
  9369. private _onKeyboardObserver;
  9370. private _engine;
  9371. private _scene;
  9372. /**
  9373. * Attach the input controls to a specific dom element to get the input from.
  9374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9375. */
  9376. attachControl(noPreventDefault?: boolean): void;
  9377. /**
  9378. * Detach the current controls from the specified dom element.
  9379. */
  9380. detachControl(): void;
  9381. /**
  9382. * Update the current camera state depending on the inputs that have been used this frame.
  9383. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9384. */
  9385. checkInputs(): void;
  9386. /**
  9387. * Gets the class name of the current intput.
  9388. * @returns the class name
  9389. */
  9390. getClassName(): string;
  9391. /** @hidden */
  9392. _onLostFocus(): void;
  9393. /**
  9394. * Get the friendly name associated with the input class.
  9395. * @returns the input friendly name
  9396. */
  9397. getSimpleName(): string;
  9398. }
  9399. }
  9400. declare module BABYLON {
  9401. /**
  9402. * Interface used to define Action
  9403. */
  9404. export interface IAction {
  9405. /**
  9406. * Trigger for the action
  9407. */
  9408. trigger: number;
  9409. /** Options of the trigger */
  9410. triggerOptions: any;
  9411. /**
  9412. * Gets the trigger parameters
  9413. * @returns the trigger parameters
  9414. */
  9415. getTriggerParameter(): any;
  9416. /**
  9417. * Internal only - executes current action event
  9418. * @hidden
  9419. */
  9420. _executeCurrent(evt?: ActionEvent): void;
  9421. /**
  9422. * Serialize placeholder for child classes
  9423. * @param parent of child
  9424. * @returns the serialized object
  9425. */
  9426. serialize(parent: any): any;
  9427. /**
  9428. * Internal only
  9429. * @hidden
  9430. */
  9431. _prepare(): void;
  9432. /**
  9433. * Internal only - manager for action
  9434. * @hidden
  9435. */
  9436. _actionManager: Nullable<AbstractActionManager>;
  9437. /**
  9438. * Adds action to chain of actions, may be a DoNothingAction
  9439. * @param action defines the next action to execute
  9440. * @returns The action passed in
  9441. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9442. */
  9443. then(action: IAction): IAction;
  9444. }
  9445. /**
  9446. * The action to be carried out following a trigger
  9447. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9448. */
  9449. export class Action implements IAction {
  9450. /** the trigger, with or without parameters, for the action */
  9451. triggerOptions: any;
  9452. /**
  9453. * Trigger for the action
  9454. */
  9455. trigger: number;
  9456. /**
  9457. * Internal only - manager for action
  9458. * @hidden
  9459. */
  9460. _actionManager: ActionManager;
  9461. private _nextActiveAction;
  9462. private _child;
  9463. private _condition?;
  9464. private _triggerParameter;
  9465. /**
  9466. * An event triggered prior to action being executed.
  9467. */
  9468. onBeforeExecuteObservable: Observable<Action>;
  9469. /**
  9470. * Creates a new Action
  9471. * @param triggerOptions the trigger, with or without parameters, for the action
  9472. * @param condition an optional determinant of action
  9473. */
  9474. constructor(
  9475. /** the trigger, with or without parameters, for the action */
  9476. triggerOptions: any, condition?: Condition);
  9477. /**
  9478. * Internal only
  9479. * @hidden
  9480. */
  9481. _prepare(): void;
  9482. /**
  9483. * Gets the trigger parameters
  9484. * @returns the trigger parameters
  9485. */
  9486. getTriggerParameter(): any;
  9487. /**
  9488. * Internal only - executes current action event
  9489. * @hidden
  9490. */
  9491. _executeCurrent(evt?: ActionEvent): void;
  9492. /**
  9493. * Execute placeholder for child classes
  9494. * @param evt optional action event
  9495. */
  9496. execute(evt?: ActionEvent): void;
  9497. /**
  9498. * Skips to next active action
  9499. */
  9500. skipToNextActiveAction(): void;
  9501. /**
  9502. * Adds action to chain of actions, may be a DoNothingAction
  9503. * @param action defines the next action to execute
  9504. * @returns The action passed in
  9505. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9506. */
  9507. then(action: Action): Action;
  9508. /**
  9509. * Internal only
  9510. * @hidden
  9511. */
  9512. _getProperty(propertyPath: string): string;
  9513. /**
  9514. * Internal only
  9515. * @hidden
  9516. */
  9517. _getEffectiveTarget(target: any, propertyPath: string): any;
  9518. /**
  9519. * Serialize placeholder for child classes
  9520. * @param parent of child
  9521. * @returns the serialized object
  9522. */
  9523. serialize(parent: any): any;
  9524. /**
  9525. * Internal only called by serialize
  9526. * @hidden
  9527. */
  9528. protected _serialize(serializedAction: any, parent?: any): any;
  9529. /**
  9530. * Internal only
  9531. * @hidden
  9532. */
  9533. static _SerializeValueAsString: (value: any) => string;
  9534. /**
  9535. * Internal only
  9536. * @hidden
  9537. */
  9538. static _GetTargetProperty: (target: Scene | Node) => {
  9539. name: string;
  9540. targetType: string;
  9541. value: string;
  9542. };
  9543. }
  9544. }
  9545. declare module BABYLON {
  9546. /**
  9547. * A Condition applied to an Action
  9548. */
  9549. export class Condition {
  9550. /**
  9551. * Internal only - manager for action
  9552. * @hidden
  9553. */
  9554. _actionManager: ActionManager;
  9555. /**
  9556. * Internal only
  9557. * @hidden
  9558. */
  9559. _evaluationId: number;
  9560. /**
  9561. * Internal only
  9562. * @hidden
  9563. */
  9564. _currentResult: boolean;
  9565. /**
  9566. * Creates a new Condition
  9567. * @param actionManager the manager of the action the condition is applied to
  9568. */
  9569. constructor(actionManager: ActionManager);
  9570. /**
  9571. * Check if the current condition is valid
  9572. * @returns a boolean
  9573. */
  9574. isValid(): boolean;
  9575. /**
  9576. * Internal only
  9577. * @hidden
  9578. */
  9579. _getProperty(propertyPath: string): string;
  9580. /**
  9581. * Internal only
  9582. * @hidden
  9583. */
  9584. _getEffectiveTarget(target: any, propertyPath: string): any;
  9585. /**
  9586. * Serialize placeholder for child classes
  9587. * @returns the serialized object
  9588. */
  9589. serialize(): any;
  9590. /**
  9591. * Internal only
  9592. * @hidden
  9593. */
  9594. protected _serialize(serializedCondition: any): any;
  9595. }
  9596. /**
  9597. * Defines specific conditional operators as extensions of Condition
  9598. */
  9599. export class ValueCondition extends Condition {
  9600. /** path to specify the property of the target the conditional operator uses */
  9601. propertyPath: string;
  9602. /** the value compared by the conditional operator against the current value of the property */
  9603. value: any;
  9604. /** the conditional operator, default ValueCondition.IsEqual */
  9605. operator: number;
  9606. /**
  9607. * Internal only
  9608. * @hidden
  9609. */
  9610. private static _IsEqual;
  9611. /**
  9612. * Internal only
  9613. * @hidden
  9614. */
  9615. private static _IsDifferent;
  9616. /**
  9617. * Internal only
  9618. * @hidden
  9619. */
  9620. private static _IsGreater;
  9621. /**
  9622. * Internal only
  9623. * @hidden
  9624. */
  9625. private static _IsLesser;
  9626. /**
  9627. * returns the number for IsEqual
  9628. */
  9629. static get IsEqual(): number;
  9630. /**
  9631. * Returns the number for IsDifferent
  9632. */
  9633. static get IsDifferent(): number;
  9634. /**
  9635. * Returns the number for IsGreater
  9636. */
  9637. static get IsGreater(): number;
  9638. /**
  9639. * Returns the number for IsLesser
  9640. */
  9641. static get IsLesser(): number;
  9642. /**
  9643. * Internal only The action manager for the condition
  9644. * @hidden
  9645. */
  9646. _actionManager: ActionManager;
  9647. /**
  9648. * Internal only
  9649. * @hidden
  9650. */
  9651. private _target;
  9652. /**
  9653. * Internal only
  9654. * @hidden
  9655. */
  9656. private _effectiveTarget;
  9657. /**
  9658. * Internal only
  9659. * @hidden
  9660. */
  9661. private _property;
  9662. /**
  9663. * Creates a new ValueCondition
  9664. * @param actionManager manager for the action the condition applies to
  9665. * @param target for the action
  9666. * @param propertyPath path to specify the property of the target the conditional operator uses
  9667. * @param value the value compared by the conditional operator against the current value of the property
  9668. * @param operator the conditional operator, default ValueCondition.IsEqual
  9669. */
  9670. constructor(actionManager: ActionManager, target: any,
  9671. /** path to specify the property of the target the conditional operator uses */
  9672. propertyPath: string,
  9673. /** the value compared by the conditional operator against the current value of the property */
  9674. value: any,
  9675. /** the conditional operator, default ValueCondition.IsEqual */
  9676. operator?: number);
  9677. /**
  9678. * Compares the given value with the property value for the specified conditional operator
  9679. * @returns the result of the comparison
  9680. */
  9681. isValid(): boolean;
  9682. /**
  9683. * Serialize the ValueCondition into a JSON compatible object
  9684. * @returns serialization object
  9685. */
  9686. serialize(): any;
  9687. /**
  9688. * Gets the name of the conditional operator for the ValueCondition
  9689. * @param operator the conditional operator
  9690. * @returns the name
  9691. */
  9692. static GetOperatorName(operator: number): string;
  9693. }
  9694. /**
  9695. * Defines a predicate condition as an extension of Condition
  9696. */
  9697. export class PredicateCondition extends Condition {
  9698. /** defines the predicate function used to validate the condition */
  9699. predicate: () => boolean;
  9700. /**
  9701. * Internal only - manager for action
  9702. * @hidden
  9703. */
  9704. _actionManager: ActionManager;
  9705. /**
  9706. * Creates a new PredicateCondition
  9707. * @param actionManager manager for the action the condition applies to
  9708. * @param predicate defines the predicate function used to validate the condition
  9709. */
  9710. constructor(actionManager: ActionManager,
  9711. /** defines the predicate function used to validate the condition */
  9712. predicate: () => boolean);
  9713. /**
  9714. * @returns the validity of the predicate condition
  9715. */
  9716. isValid(): boolean;
  9717. }
  9718. /**
  9719. * Defines a state condition as an extension of Condition
  9720. */
  9721. export class StateCondition extends Condition {
  9722. /** Value to compare with target state */
  9723. value: string;
  9724. /**
  9725. * Internal only - manager for action
  9726. * @hidden
  9727. */
  9728. _actionManager: ActionManager;
  9729. /**
  9730. * Internal only
  9731. * @hidden
  9732. */
  9733. private _target;
  9734. /**
  9735. * Creates a new StateCondition
  9736. * @param actionManager manager for the action the condition applies to
  9737. * @param target of the condition
  9738. * @param value to compare with target state
  9739. */
  9740. constructor(actionManager: ActionManager, target: any,
  9741. /** Value to compare with target state */
  9742. value: string);
  9743. /**
  9744. * Gets a boolean indicating if the current condition is met
  9745. * @returns the validity of the state
  9746. */
  9747. isValid(): boolean;
  9748. /**
  9749. * Serialize the StateCondition into a JSON compatible object
  9750. * @returns serialization object
  9751. */
  9752. serialize(): any;
  9753. }
  9754. }
  9755. declare module BABYLON {
  9756. /**
  9757. * This defines an action responsible to toggle a boolean once triggered.
  9758. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9759. */
  9760. export class SwitchBooleanAction extends Action {
  9761. /**
  9762. * The path to the boolean property in the target object
  9763. */
  9764. propertyPath: string;
  9765. private _target;
  9766. private _effectiveTarget;
  9767. private _property;
  9768. /**
  9769. * Instantiate the action
  9770. * @param triggerOptions defines the trigger options
  9771. * @param target defines the object containing the boolean
  9772. * @param propertyPath defines the path to the boolean property in the target object
  9773. * @param condition defines the trigger related conditions
  9774. */
  9775. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9776. /** @hidden */
  9777. _prepare(): void;
  9778. /**
  9779. * Execute the action toggle the boolean value.
  9780. */
  9781. execute(): void;
  9782. /**
  9783. * Serializes the actions and its related information.
  9784. * @param parent defines the object to serialize in
  9785. * @returns the serialized object
  9786. */
  9787. serialize(parent: any): any;
  9788. }
  9789. /**
  9790. * This defines an action responsible to set a the state field of the target
  9791. * to a desired value once triggered.
  9792. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9793. */
  9794. export class SetStateAction extends Action {
  9795. /**
  9796. * The value to store in the state field.
  9797. */
  9798. value: string;
  9799. private _target;
  9800. /**
  9801. * Instantiate the action
  9802. * @param triggerOptions defines the trigger options
  9803. * @param target defines the object containing the state property
  9804. * @param value defines the value to store in the state field
  9805. * @param condition defines the trigger related conditions
  9806. */
  9807. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9808. /**
  9809. * Execute the action and store the value on the target state property.
  9810. */
  9811. execute(): void;
  9812. /**
  9813. * Serializes the actions and its related information.
  9814. * @param parent defines the object to serialize in
  9815. * @returns the serialized object
  9816. */
  9817. serialize(parent: any): any;
  9818. }
  9819. /**
  9820. * This defines an action responsible to set a property of the target
  9821. * to a desired value once triggered.
  9822. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9823. */
  9824. export class SetValueAction extends Action {
  9825. /**
  9826. * The path of the property to set in the target.
  9827. */
  9828. propertyPath: string;
  9829. /**
  9830. * The value to set in the property
  9831. */
  9832. value: any;
  9833. private _target;
  9834. private _effectiveTarget;
  9835. private _property;
  9836. /**
  9837. * Instantiate the action
  9838. * @param triggerOptions defines the trigger options
  9839. * @param target defines the object containing the property
  9840. * @param propertyPath defines the path of the property to set in the target
  9841. * @param value defines the value to set in the property
  9842. * @param condition defines the trigger related conditions
  9843. */
  9844. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9845. /** @hidden */
  9846. _prepare(): void;
  9847. /**
  9848. * Execute the action and set the targetted property to the desired value.
  9849. */
  9850. execute(): void;
  9851. /**
  9852. * Serializes the actions and its related information.
  9853. * @param parent defines the object to serialize in
  9854. * @returns the serialized object
  9855. */
  9856. serialize(parent: any): any;
  9857. }
  9858. /**
  9859. * This defines an action responsible to increment the target value
  9860. * to a desired value once triggered.
  9861. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9862. */
  9863. export class IncrementValueAction extends Action {
  9864. /**
  9865. * The path of the property to increment in the target.
  9866. */
  9867. propertyPath: string;
  9868. /**
  9869. * The value we should increment the property by.
  9870. */
  9871. value: any;
  9872. private _target;
  9873. private _effectiveTarget;
  9874. private _property;
  9875. /**
  9876. * Instantiate the action
  9877. * @param triggerOptions defines the trigger options
  9878. * @param target defines the object containing the property
  9879. * @param propertyPath defines the path of the property to increment in the target
  9880. * @param value defines the value value we should increment the property by
  9881. * @param condition defines the trigger related conditions
  9882. */
  9883. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9884. /** @hidden */
  9885. _prepare(): void;
  9886. /**
  9887. * Execute the action and increment the target of the value amount.
  9888. */
  9889. execute(): void;
  9890. /**
  9891. * Serializes the actions and its related information.
  9892. * @param parent defines the object to serialize in
  9893. * @returns the serialized object
  9894. */
  9895. serialize(parent: any): any;
  9896. }
  9897. /**
  9898. * This defines an action responsible to start an animation once triggered.
  9899. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9900. */
  9901. export class PlayAnimationAction extends Action {
  9902. /**
  9903. * Where the animation should start (animation frame)
  9904. */
  9905. from: number;
  9906. /**
  9907. * Where the animation should stop (animation frame)
  9908. */
  9909. to: number;
  9910. /**
  9911. * Define if the animation should loop or stop after the first play.
  9912. */
  9913. loop?: boolean;
  9914. private _target;
  9915. /**
  9916. * Instantiate the action
  9917. * @param triggerOptions defines the trigger options
  9918. * @param target defines the target animation or animation name
  9919. * @param from defines from where the animation should start (animation frame)
  9920. * @param end defines where the animation should stop (animation frame)
  9921. * @param loop defines if the animation should loop or stop after the first play
  9922. * @param condition defines the trigger related conditions
  9923. */
  9924. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9925. /** @hidden */
  9926. _prepare(): void;
  9927. /**
  9928. * Execute the action and play the animation.
  9929. */
  9930. execute(): void;
  9931. /**
  9932. * Serializes the actions and its related information.
  9933. * @param parent defines the object to serialize in
  9934. * @returns the serialized object
  9935. */
  9936. serialize(parent: any): any;
  9937. }
  9938. /**
  9939. * This defines an action responsible to stop an animation once triggered.
  9940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9941. */
  9942. export class StopAnimationAction extends Action {
  9943. private _target;
  9944. /**
  9945. * Instantiate the action
  9946. * @param triggerOptions defines the trigger options
  9947. * @param target defines the target animation or animation name
  9948. * @param condition defines the trigger related conditions
  9949. */
  9950. constructor(triggerOptions: any, target: any, condition?: Condition);
  9951. /** @hidden */
  9952. _prepare(): void;
  9953. /**
  9954. * Execute the action and stop the animation.
  9955. */
  9956. execute(): void;
  9957. /**
  9958. * Serializes the actions and its related information.
  9959. * @param parent defines the object to serialize in
  9960. * @returns the serialized object
  9961. */
  9962. serialize(parent: any): any;
  9963. }
  9964. /**
  9965. * This defines an action responsible that does nothing once triggered.
  9966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class DoNothingAction extends Action {
  9969. /**
  9970. * Instantiate the action
  9971. * @param triggerOptions defines the trigger options
  9972. * @param condition defines the trigger related conditions
  9973. */
  9974. constructor(triggerOptions?: any, condition?: Condition);
  9975. /**
  9976. * Execute the action and do nothing.
  9977. */
  9978. execute(): void;
  9979. /**
  9980. * Serializes the actions and its related information.
  9981. * @param parent defines the object to serialize in
  9982. * @returns the serialized object
  9983. */
  9984. serialize(parent: any): any;
  9985. }
  9986. /**
  9987. * This defines an action responsible to trigger several actions once triggered.
  9988. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9989. */
  9990. export class CombineAction extends Action {
  9991. /**
  9992. * The list of aggregated animations to run.
  9993. */
  9994. children: Action[];
  9995. /**
  9996. * Instantiate the action
  9997. * @param triggerOptions defines the trigger options
  9998. * @param children defines the list of aggregated animations to run
  9999. * @param condition defines the trigger related conditions
  10000. */
  10001. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10002. /** @hidden */
  10003. _prepare(): void;
  10004. /**
  10005. * Execute the action and executes all the aggregated actions.
  10006. */
  10007. execute(evt: ActionEvent): 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 to run code (external event) once triggered.
  10017. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10018. */
  10019. export class ExecuteCodeAction extends Action {
  10020. /**
  10021. * The callback function to run.
  10022. */
  10023. func: (evt: ActionEvent) => void;
  10024. /**
  10025. * Instantiate the action
  10026. * @param triggerOptions defines the trigger options
  10027. * @param func defines the callback function to run
  10028. * @param condition defines the trigger related conditions
  10029. */
  10030. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10031. /**
  10032. * Execute the action and run the attached code.
  10033. */
  10034. execute(evt: ActionEvent): void;
  10035. }
  10036. /**
  10037. * This defines an action responsible to set the parent property of the target once triggered.
  10038. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10039. */
  10040. export class SetParentAction extends Action {
  10041. private _parent;
  10042. private _target;
  10043. /**
  10044. * Instantiate the action
  10045. * @param triggerOptions defines the trigger options
  10046. * @param target defines the target containing the parent property
  10047. * @param parent defines from where the animation should start (animation frame)
  10048. * @param condition defines the trigger related conditions
  10049. */
  10050. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10051. /** @hidden */
  10052. _prepare(): void;
  10053. /**
  10054. * Execute the action and set the parent property.
  10055. */
  10056. execute(): void;
  10057. /**
  10058. * Serializes the actions and its related information.
  10059. * @param parent defines the object to serialize in
  10060. * @returns the serialized object
  10061. */
  10062. serialize(parent: any): any;
  10063. }
  10064. }
  10065. declare module BABYLON {
  10066. /**
  10067. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10068. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10069. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10070. */
  10071. export class ActionManager extends AbstractActionManager {
  10072. /**
  10073. * Nothing
  10074. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10075. */
  10076. static readonly NothingTrigger: number;
  10077. /**
  10078. * On pick
  10079. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10080. */
  10081. static readonly OnPickTrigger: number;
  10082. /**
  10083. * On left pick
  10084. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10085. */
  10086. static readonly OnLeftPickTrigger: number;
  10087. /**
  10088. * On right pick
  10089. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10090. */
  10091. static readonly OnRightPickTrigger: number;
  10092. /**
  10093. * On center pick
  10094. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10095. */
  10096. static readonly OnCenterPickTrigger: number;
  10097. /**
  10098. * On pick down
  10099. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10100. */
  10101. static readonly OnPickDownTrigger: number;
  10102. /**
  10103. * On double pick
  10104. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10105. */
  10106. static readonly OnDoublePickTrigger: number;
  10107. /**
  10108. * On pick up
  10109. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10110. */
  10111. static readonly OnPickUpTrigger: number;
  10112. /**
  10113. * On pick out.
  10114. * This trigger will only be raised if you also declared a OnPickDown
  10115. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10116. */
  10117. static readonly OnPickOutTrigger: number;
  10118. /**
  10119. * On long press
  10120. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10121. */
  10122. static readonly OnLongPressTrigger: number;
  10123. /**
  10124. * On pointer over
  10125. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10126. */
  10127. static readonly OnPointerOverTrigger: number;
  10128. /**
  10129. * On pointer out
  10130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10131. */
  10132. static readonly OnPointerOutTrigger: number;
  10133. /**
  10134. * On every frame
  10135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10136. */
  10137. static readonly OnEveryFrameTrigger: number;
  10138. /**
  10139. * On intersection enter
  10140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10141. */
  10142. static readonly OnIntersectionEnterTrigger: number;
  10143. /**
  10144. * On intersection exit
  10145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10146. */
  10147. static readonly OnIntersectionExitTrigger: number;
  10148. /**
  10149. * On key down
  10150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10151. */
  10152. static readonly OnKeyDownTrigger: number;
  10153. /**
  10154. * On key up
  10155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10156. */
  10157. static readonly OnKeyUpTrigger: number;
  10158. private _scene;
  10159. /**
  10160. * Creates a new action manager
  10161. * @param scene defines the hosting scene
  10162. */
  10163. constructor(scene: Scene);
  10164. /**
  10165. * Releases all associated resources
  10166. */
  10167. dispose(): void;
  10168. /**
  10169. * Gets hosting scene
  10170. * @returns the hosting scene
  10171. */
  10172. getScene(): Scene;
  10173. /**
  10174. * Does this action manager handles actions of any of the given triggers
  10175. * @param triggers defines the triggers to be tested
  10176. * @return a boolean indicating whether one (or more) of the triggers is handled
  10177. */
  10178. hasSpecificTriggers(triggers: number[]): boolean;
  10179. /**
  10180. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10181. * speed.
  10182. * @param triggerA defines the trigger to be tested
  10183. * @param triggerB defines the trigger to be tested
  10184. * @return a boolean indicating whether one (or more) of the triggers is handled
  10185. */
  10186. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10187. /**
  10188. * Does this action manager handles actions of a given trigger
  10189. * @param trigger defines the trigger to be tested
  10190. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10191. * @return whether the trigger is handled
  10192. */
  10193. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10194. /**
  10195. * Does this action manager has pointer triggers
  10196. */
  10197. get hasPointerTriggers(): boolean;
  10198. /**
  10199. * Does this action manager has pick triggers
  10200. */
  10201. get hasPickTriggers(): boolean;
  10202. /**
  10203. * Registers an action to this action manager
  10204. * @param action defines the action to be registered
  10205. * @return the action amended (prepared) after registration
  10206. */
  10207. registerAction(action: IAction): Nullable<IAction>;
  10208. /**
  10209. * Unregisters an action to this action manager
  10210. * @param action defines the action to be unregistered
  10211. * @return a boolean indicating whether the action has been unregistered
  10212. */
  10213. unregisterAction(action: IAction): Boolean;
  10214. /**
  10215. * Process a specific trigger
  10216. * @param trigger defines the trigger to process
  10217. * @param evt defines the event details to be processed
  10218. */
  10219. processTrigger(trigger: number, evt?: IActionEvent): void;
  10220. /** @hidden */
  10221. _getEffectiveTarget(target: any, propertyPath: string): any;
  10222. /** @hidden */
  10223. _getProperty(propertyPath: string): string;
  10224. /**
  10225. * Serialize this manager to a JSON object
  10226. * @param name defines the property name to store this manager
  10227. * @returns a JSON representation of this manager
  10228. */
  10229. serialize(name: string): any;
  10230. /**
  10231. * Creates a new ActionManager from a JSON data
  10232. * @param parsedActions defines the JSON data to read from
  10233. * @param object defines the hosting mesh
  10234. * @param scene defines the hosting scene
  10235. */
  10236. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10237. /**
  10238. * Get a trigger name by index
  10239. * @param trigger defines the trigger index
  10240. * @returns a trigger name
  10241. */
  10242. static GetTriggerName(trigger: number): string;
  10243. }
  10244. }
  10245. declare module BABYLON {
  10246. /**
  10247. * Class representing a ray with position and direction
  10248. */
  10249. export class Ray {
  10250. /** origin point */
  10251. origin: Vector3;
  10252. /** direction */
  10253. direction: Vector3;
  10254. /** length of the ray */
  10255. length: number;
  10256. private static readonly _TmpVector3;
  10257. private _tmpRay;
  10258. /**
  10259. * Creates a new ray
  10260. * @param origin origin point
  10261. * @param direction direction
  10262. * @param length length of the ray
  10263. */
  10264. constructor(
  10265. /** origin point */
  10266. origin: Vector3,
  10267. /** direction */
  10268. direction: Vector3,
  10269. /** length of the ray */
  10270. length?: number);
  10271. /**
  10272. * Checks if the ray intersects a box
  10273. * This does not account for the ray lenght by design to improve perfs.
  10274. * @param minimum bound of the box
  10275. * @param maximum bound of the box
  10276. * @param intersectionTreshold extra extend to be added to the box in all direction
  10277. * @returns if the box was hit
  10278. */
  10279. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10280. /**
  10281. * Checks if the ray intersects a box
  10282. * This does not account for the ray lenght by design to improve perfs.
  10283. * @param box the bounding box to check
  10284. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10285. * @returns if the box was hit
  10286. */
  10287. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10288. /**
  10289. * If the ray hits a sphere
  10290. * @param sphere the bounding sphere to check
  10291. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10292. * @returns true if it hits the sphere
  10293. */
  10294. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10295. /**
  10296. * If the ray hits a triange
  10297. * @param vertex0 triangle vertex
  10298. * @param vertex1 triangle vertex
  10299. * @param vertex2 triangle vertex
  10300. * @returns intersection information if hit
  10301. */
  10302. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10303. /**
  10304. * Checks if ray intersects a plane
  10305. * @param plane the plane to check
  10306. * @returns the distance away it was hit
  10307. */
  10308. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10309. /**
  10310. * Calculate the intercept of a ray on a given axis
  10311. * @param axis to check 'x' | 'y' | 'z'
  10312. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10313. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10314. */
  10315. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10316. /**
  10317. * Checks if ray intersects a mesh
  10318. * @param mesh the mesh to check
  10319. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10320. * @returns picking info of the intersecton
  10321. */
  10322. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10323. /**
  10324. * Checks if ray intersects a mesh
  10325. * @param meshes the meshes to check
  10326. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10327. * @param results array to store result in
  10328. * @returns Array of picking infos
  10329. */
  10330. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10331. private _comparePickingInfo;
  10332. private static smallnum;
  10333. private static rayl;
  10334. /**
  10335. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10336. * @param sega the first point of the segment to test the intersection against
  10337. * @param segb the second point of the segment to test the intersection against
  10338. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10339. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10340. */
  10341. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10342. /**
  10343. * Update the ray from viewport position
  10344. * @param x position
  10345. * @param y y position
  10346. * @param viewportWidth viewport width
  10347. * @param viewportHeight viewport height
  10348. * @param world world matrix
  10349. * @param view view matrix
  10350. * @param projection projection matrix
  10351. * @returns this ray updated
  10352. */
  10353. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10354. /**
  10355. * Creates a ray with origin and direction of 0,0,0
  10356. * @returns the new ray
  10357. */
  10358. static Zero(): Ray;
  10359. /**
  10360. * Creates a new ray from screen space and viewport
  10361. * @param x position
  10362. * @param y y position
  10363. * @param viewportWidth viewport width
  10364. * @param viewportHeight viewport height
  10365. * @param world world matrix
  10366. * @param view view matrix
  10367. * @param projection projection matrix
  10368. * @returns new ray
  10369. */
  10370. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10371. /**
  10372. * 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
  10373. * transformed to the given world matrix.
  10374. * @param origin The origin point
  10375. * @param end The end point
  10376. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10377. * @returns the new ray
  10378. */
  10379. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10380. /**
  10381. * Transforms a ray by a matrix
  10382. * @param ray ray to transform
  10383. * @param matrix matrix to apply
  10384. * @returns the resulting new ray
  10385. */
  10386. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10387. /**
  10388. * Transforms a ray by a matrix
  10389. * @param ray ray to transform
  10390. * @param matrix matrix to apply
  10391. * @param result ray to store result in
  10392. */
  10393. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10394. /**
  10395. * Unproject a ray from screen space to object space
  10396. * @param sourceX defines the screen space x coordinate to use
  10397. * @param sourceY defines the screen space y coordinate to use
  10398. * @param viewportWidth defines the current width of the viewport
  10399. * @param viewportHeight defines the current height of the viewport
  10400. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10401. * @param view defines the view matrix to use
  10402. * @param projection defines the projection matrix to use
  10403. */
  10404. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10405. }
  10406. /**
  10407. * Type used to define predicate used to select faces when a mesh intersection is detected
  10408. */
  10409. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10410. interface Scene {
  10411. /** @hidden */
  10412. _tempPickingRay: Nullable<Ray>;
  10413. /** @hidden */
  10414. _cachedRayForTransform: Ray;
  10415. /** @hidden */
  10416. _pickWithRayInverseMatrix: Matrix;
  10417. /** @hidden */
  10418. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10419. /** @hidden */
  10420. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10421. /** @hidden */
  10422. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10423. }
  10424. }
  10425. declare module BABYLON {
  10426. /**
  10427. * Groups all the scene component constants in one place to ease maintenance.
  10428. * @hidden
  10429. */
  10430. export class SceneComponentConstants {
  10431. static readonly NAME_EFFECTLAYER: string;
  10432. static readonly NAME_LAYER: string;
  10433. static readonly NAME_LENSFLARESYSTEM: string;
  10434. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10435. static readonly NAME_PARTICLESYSTEM: string;
  10436. static readonly NAME_GAMEPAD: string;
  10437. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10438. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10439. static readonly NAME_PREPASSRENDERER: string;
  10440. static readonly NAME_DEPTHRENDERER: string;
  10441. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10442. static readonly NAME_SPRITE: string;
  10443. static readonly NAME_SUBSURFACE: string;
  10444. static readonly NAME_OUTLINERENDERER: string;
  10445. static readonly NAME_PROCEDURALTEXTURE: string;
  10446. static readonly NAME_SHADOWGENERATOR: string;
  10447. static readonly NAME_OCTREE: string;
  10448. static readonly NAME_PHYSICSENGINE: string;
  10449. static readonly NAME_AUDIO: string;
  10450. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10451. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10452. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10453. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10454. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10455. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10456. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10457. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10458. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10459. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10460. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10461. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10462. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10463. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10464. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10465. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10466. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10467. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10468. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10469. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10470. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10471. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10472. static readonly STEP_AFTERRENDER_AUDIO: number;
  10473. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10474. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10475. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10476. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10477. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10478. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10479. static readonly STEP_POINTERMOVE_SPRITE: number;
  10480. static readonly STEP_POINTERDOWN_SPRITE: number;
  10481. static readonly STEP_POINTERUP_SPRITE: number;
  10482. }
  10483. /**
  10484. * This represents a scene component.
  10485. *
  10486. * This is used to decouple the dependency the scene is having on the different workloads like
  10487. * layers, post processes...
  10488. */
  10489. export interface ISceneComponent {
  10490. /**
  10491. * The name of the component. Each component must have a unique name.
  10492. */
  10493. name: string;
  10494. /**
  10495. * The scene the component belongs to.
  10496. */
  10497. scene: Scene;
  10498. /**
  10499. * Register the component to one instance of a scene.
  10500. */
  10501. register(): void;
  10502. /**
  10503. * Rebuilds the elements related to this component in case of
  10504. * context lost for instance.
  10505. */
  10506. rebuild(): void;
  10507. /**
  10508. * Disposes the component and the associated ressources.
  10509. */
  10510. dispose(): void;
  10511. }
  10512. /**
  10513. * This represents a SERIALIZABLE scene component.
  10514. *
  10515. * This extends Scene Component to add Serialization methods on top.
  10516. */
  10517. export interface ISceneSerializableComponent extends ISceneComponent {
  10518. /**
  10519. * Adds all the elements from the container to the scene
  10520. * @param container the container holding the elements
  10521. */
  10522. addFromContainer(container: AbstractScene): void;
  10523. /**
  10524. * Removes all the elements in the container from the scene
  10525. * @param container contains the elements to remove
  10526. * @param dispose if the removed element should be disposed (default: false)
  10527. */
  10528. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10529. /**
  10530. * Serializes the component data to the specified json object
  10531. * @param serializationObject The object to serialize to
  10532. */
  10533. serialize(serializationObject: any): void;
  10534. }
  10535. /**
  10536. * Strong typing of a Mesh related stage step action
  10537. */
  10538. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10539. /**
  10540. * Strong typing of a Evaluate Sub Mesh related stage step action
  10541. */
  10542. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10543. /**
  10544. * Strong typing of a pre active Mesh related stage step action
  10545. */
  10546. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10547. /**
  10548. * Strong typing of a Camera related stage step action
  10549. */
  10550. export type CameraStageAction = (camera: Camera) => void;
  10551. /**
  10552. * Strong typing of a Camera Frame buffer related stage step action
  10553. */
  10554. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10555. /**
  10556. * Strong typing of a Render Target related stage step action
  10557. */
  10558. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10559. /**
  10560. * Strong typing of a RenderingGroup related stage step action
  10561. */
  10562. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10563. /**
  10564. * Strong typing of a Mesh Render related stage step action
  10565. */
  10566. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10567. /**
  10568. * Strong typing of a simple stage step action
  10569. */
  10570. export type SimpleStageAction = () => void;
  10571. /**
  10572. * Strong typing of a render target action.
  10573. */
  10574. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10575. /**
  10576. * Strong typing of a pointer move action.
  10577. */
  10578. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10579. /**
  10580. * Strong typing of a pointer up/down action.
  10581. */
  10582. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10583. /**
  10584. * Representation of a stage in the scene (Basically a list of ordered steps)
  10585. * @hidden
  10586. */
  10587. export class Stage<T extends Function> extends Array<{
  10588. index: number;
  10589. component: ISceneComponent;
  10590. action: T;
  10591. }> {
  10592. /**
  10593. * Hide ctor from the rest of the world.
  10594. * @param items The items to add.
  10595. */
  10596. private constructor();
  10597. /**
  10598. * Creates a new Stage.
  10599. * @returns A new instance of a Stage
  10600. */
  10601. static Create<T extends Function>(): Stage<T>;
  10602. /**
  10603. * Registers a step in an ordered way in the targeted stage.
  10604. * @param index Defines the position to register the step in
  10605. * @param component Defines the component attached to the step
  10606. * @param action Defines the action to launch during the step
  10607. */
  10608. registerStep(index: number, component: ISceneComponent, action: T): void;
  10609. /**
  10610. * Clears all the steps from the stage.
  10611. */
  10612. clear(): void;
  10613. }
  10614. }
  10615. declare module BABYLON {
  10616. interface Scene {
  10617. /** @hidden */
  10618. _pointerOverSprite: Nullable<Sprite>;
  10619. /** @hidden */
  10620. _pickedDownSprite: Nullable<Sprite>;
  10621. /** @hidden */
  10622. _tempSpritePickingRay: Nullable<Ray>;
  10623. /**
  10624. * All of the sprite managers added to this scene
  10625. * @see https://doc.babylonjs.com/babylon101/sprites
  10626. */
  10627. spriteManagers: Array<ISpriteManager>;
  10628. /**
  10629. * An event triggered when sprites rendering is about to start
  10630. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10631. */
  10632. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10633. /**
  10634. * An event triggered when sprites rendering is done
  10635. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10636. */
  10637. onAfterSpritesRenderingObservable: Observable<Scene>;
  10638. /** @hidden */
  10639. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10640. /** Launch a ray to try to pick a sprite in the scene
  10641. * @param x position on screen
  10642. * @param y position on screen
  10643. * @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
  10644. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10645. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10646. * @returns a PickingInfo
  10647. */
  10648. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10649. /** Use the given ray to pick a sprite in the scene
  10650. * @param ray The ray (in world space) to use to pick meshes
  10651. * @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
  10652. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10653. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10654. * @returns a PickingInfo
  10655. */
  10656. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10657. /** @hidden */
  10658. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10659. /** Launch a ray to try to pick sprites in the scene
  10660. * @param x position on screen
  10661. * @param y position on screen
  10662. * @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
  10663. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10664. * @returns a PickingInfo array
  10665. */
  10666. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10667. /** Use the given ray to pick sprites in the scene
  10668. * @param ray The ray (in world space) to use to pick meshes
  10669. * @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
  10670. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10671. * @returns a PickingInfo array
  10672. */
  10673. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10674. /**
  10675. * Force the sprite under the pointer
  10676. * @param sprite defines the sprite to use
  10677. */
  10678. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10679. /**
  10680. * Gets the sprite under the pointer
  10681. * @returns a Sprite or null if no sprite is under the pointer
  10682. */
  10683. getPointerOverSprite(): Nullable<Sprite>;
  10684. }
  10685. /**
  10686. * Defines the sprite scene component responsible to manage sprites
  10687. * in a given scene.
  10688. */
  10689. export class SpriteSceneComponent implements ISceneComponent {
  10690. /**
  10691. * The component name helpfull to identify the component in the list of scene components.
  10692. */
  10693. readonly name: string;
  10694. /**
  10695. * The scene the component belongs to.
  10696. */
  10697. scene: Scene;
  10698. /** @hidden */
  10699. private _spritePredicate;
  10700. /**
  10701. * Creates a new instance of the component for the given scene
  10702. * @param scene Defines the scene to register the component in
  10703. */
  10704. constructor(scene: Scene);
  10705. /**
  10706. * Registers the component in a given scene
  10707. */
  10708. register(): void;
  10709. /**
  10710. * Rebuilds the elements related to this component in case of
  10711. * context lost for instance.
  10712. */
  10713. rebuild(): void;
  10714. /**
  10715. * Disposes the component and the associated ressources.
  10716. */
  10717. dispose(): void;
  10718. private _pickSpriteButKeepRay;
  10719. private _pointerMove;
  10720. private _pointerDown;
  10721. private _pointerUp;
  10722. }
  10723. }
  10724. declare module BABYLON {
  10725. /**
  10726. * Class used to provide helper for timing
  10727. */
  10728. export class TimingTools {
  10729. /**
  10730. * Polyfill for setImmediate
  10731. * @param action defines the action to execute after the current execution block
  10732. */
  10733. static SetImmediate(action: () => void): void;
  10734. }
  10735. }
  10736. declare module BABYLON {
  10737. /**
  10738. * Class used to enable instatition of objects by class name
  10739. */
  10740. export class InstantiationTools {
  10741. /**
  10742. * Use this object to register external classes like custom textures or material
  10743. * to allow the laoders to instantiate them
  10744. */
  10745. static RegisteredExternalClasses: {
  10746. [key: string]: Object;
  10747. };
  10748. /**
  10749. * Tries to instantiate a new object from a given class name
  10750. * @param className defines the class name to instantiate
  10751. * @returns the new object or null if the system was not able to do the instantiation
  10752. */
  10753. static Instantiate(className: string): any;
  10754. }
  10755. }
  10756. declare module BABYLON {
  10757. /**
  10758. * Class used to host copy specific utilities
  10759. */
  10760. export class CopyTools {
  10761. /**
  10762. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  10763. * @param texture defines the texture to read pixels from
  10764. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  10765. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  10766. * @returns The base64 encoded string or null
  10767. */
  10768. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  10769. }
  10770. }
  10771. declare module BABYLON {
  10772. /**
  10773. * Define options used to create a depth texture
  10774. */
  10775. export class DepthTextureCreationOptions {
  10776. /** Specifies whether or not a stencil should be allocated in the texture */
  10777. generateStencil?: boolean;
  10778. /** Specifies whether or not bilinear filtering is enable on the texture */
  10779. bilinearFiltering?: boolean;
  10780. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10781. comparisonFunction?: number;
  10782. /** Specifies if the created texture is a cube texture */
  10783. isCube?: boolean;
  10784. }
  10785. }
  10786. declare module BABYLON {
  10787. interface ThinEngine {
  10788. /**
  10789. * Creates a depth stencil cube texture.
  10790. * This is only available in WebGL 2.
  10791. * @param size The size of face edge in the cube texture.
  10792. * @param options The options defining the cube texture.
  10793. * @returns The cube texture
  10794. */
  10795. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  10796. /**
  10797. * Creates a cube texture
  10798. * @param rootUrl defines the url where the files to load is located
  10799. * @param scene defines the current scene
  10800. * @param files defines the list of files to load (1 per face)
  10801. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10802. * @param onLoad defines an optional callback raised when the texture is loaded
  10803. * @param onError defines an optional callback raised if there is an issue to load the texture
  10804. * @param format defines the format of the data
  10805. * @param forcedExtension defines the extension to use to pick the right loader
  10806. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10807. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10808. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10809. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10810. * @param loaderOptions options to be passed to the loader
  10811. * @returns the cube texture as an InternalTexture
  10812. */
  10813. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  10814. /**
  10815. * Creates a cube texture
  10816. * @param rootUrl defines the url where the files to load is located
  10817. * @param scene defines the current scene
  10818. * @param files defines the list of files to load (1 per face)
  10819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10820. * @param onLoad defines an optional callback raised when the texture is loaded
  10821. * @param onError defines an optional callback raised if there is an issue to load the texture
  10822. * @param format defines the format of the data
  10823. * @param forcedExtension defines the extension to use to pick the right loader
  10824. * @returns the cube texture as an InternalTexture
  10825. */
  10826. 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;
  10827. /**
  10828. * Creates a cube texture
  10829. * @param rootUrl defines the url where the files to load is located
  10830. * @param scene defines the current scene
  10831. * @param files defines the list of files to load (1 per face)
  10832. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10833. * @param onLoad defines an optional callback raised when the texture is loaded
  10834. * @param onError defines an optional callback raised if there is an issue to load the texture
  10835. * @param format defines the format of the data
  10836. * @param forcedExtension defines the extension to use to pick the right loader
  10837. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10838. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10839. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10840. * @returns the cube texture as an InternalTexture
  10841. */
  10842. 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;
  10843. /** @hidden */
  10844. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  10845. /** @hidden */
  10846. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  10847. /** @hidden */
  10848. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10849. /** @hidden */
  10850. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10851. /**
  10852. * @hidden
  10853. */
  10854. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  10855. }
  10856. }
  10857. declare module BABYLON {
  10858. /**
  10859. * Class for creating a cube texture
  10860. */
  10861. export class CubeTexture extends BaseTexture {
  10862. private _delayedOnLoad;
  10863. /**
  10864. * Observable triggered once the texture has been loaded.
  10865. */
  10866. onLoadObservable: Observable<CubeTexture>;
  10867. /**
  10868. * The url of the texture
  10869. */
  10870. url: string;
  10871. /**
  10872. * Gets or sets the center of the bounding box associated with the cube texture.
  10873. * It must define where the camera used to render the texture was set
  10874. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10875. */
  10876. boundingBoxPosition: Vector3;
  10877. private _boundingBoxSize;
  10878. /**
  10879. * Gets or sets the size of the bounding box associated with the cube texture
  10880. * When defined, the cubemap will switch to local mode
  10881. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  10882. * @example https://www.babylonjs-playground.com/#RNASML
  10883. */
  10884. set boundingBoxSize(value: Vector3);
  10885. /**
  10886. * Returns the bounding box size
  10887. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10888. */
  10889. get boundingBoxSize(): Vector3;
  10890. protected _rotationY: number;
  10891. /**
  10892. * Sets texture matrix rotation angle around Y axis in radians.
  10893. */
  10894. set rotationY(value: number);
  10895. /**
  10896. * Gets texture matrix rotation angle around Y axis radians.
  10897. */
  10898. get rotationY(): number;
  10899. /**
  10900. * Are mip maps generated for this texture or not.
  10901. */
  10902. get noMipmap(): boolean;
  10903. private _noMipmap;
  10904. private _files;
  10905. protected _forcedExtension: Nullable<string>;
  10906. private _extensions;
  10907. private _textureMatrix;
  10908. private _format;
  10909. private _createPolynomials;
  10910. private _loaderOptions;
  10911. /**
  10912. * Creates a cube texture from an array of image urls
  10913. * @param files defines an array of image urls
  10914. * @param scene defines the hosting scene
  10915. * @param noMipmap specifies if mip maps are not used
  10916. * @returns a cube texture
  10917. */
  10918. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  10919. /**
  10920. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  10921. * @param url defines the url of the prefiltered texture
  10922. * @param scene defines the scene the texture is attached to
  10923. * @param forcedExtension defines the extension of the file if different from the url
  10924. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10925. * @return the prefiltered texture
  10926. */
  10927. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  10928. /**
  10929. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  10930. * as prefiltered data.
  10931. * @param rootUrl defines the url of the texture or the root name of the six images
  10932. * @param null defines the scene or engine the texture is attached to
  10933. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  10934. * @param noMipmap defines if mipmaps should be created or not
  10935. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  10936. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  10937. * @param onError defines a callback triggered in case of error during load
  10938. * @param format defines the internal format to use for the texture once loaded
  10939. * @param prefiltered defines whether or not the texture is created from prefiltered data
  10940. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  10941. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10942. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10943. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10944. * @param loaderOptions options to be passed to the loader
  10945. * @return the cube texture
  10946. */
  10947. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  10948. /**
  10949. * Get the current class name of the texture useful for serialization or dynamic coding.
  10950. * @returns "CubeTexture"
  10951. */
  10952. getClassName(): string;
  10953. /**
  10954. * Update the url (and optional buffer) of this texture if url was null during construction.
  10955. * @param url the url of the texture
  10956. * @param forcedExtension defines the extension to use
  10957. * @param onLoad callback called when the texture is loaded (defaults to null)
  10958. * @param prefiltered Defines whether the updated texture is prefiltered or not
  10959. */
  10960. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  10961. /**
  10962. * Delays loading of the cube texture
  10963. * @param forcedExtension defines the extension to use
  10964. */
  10965. delayLoad(forcedExtension?: string): void;
  10966. /**
  10967. * Returns the reflection texture matrix
  10968. * @returns the reflection texture matrix
  10969. */
  10970. getReflectionTextureMatrix(): Matrix;
  10971. /**
  10972. * Sets the reflection texture matrix
  10973. * @param value Reflection texture matrix
  10974. */
  10975. setReflectionTextureMatrix(value: Matrix): void;
  10976. /**
  10977. * Parses text to create a cube texture
  10978. * @param parsedTexture define the serialized text to read from
  10979. * @param scene defines the hosting scene
  10980. * @param rootUrl defines the root url of the cube texture
  10981. * @returns a cube texture
  10982. */
  10983. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  10984. /**
  10985. * Makes a clone, or deep copy, of the cube texture
  10986. * @returns a new cube texture
  10987. */
  10988. clone(): CubeTexture;
  10989. }
  10990. }
  10991. declare module BABYLON {
  10992. /**
  10993. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  10994. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  10995. * 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;
  10996. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  10997. */
  10998. export class ColorCurves {
  10999. private _dirty;
  11000. private _tempColor;
  11001. private _globalCurve;
  11002. private _highlightsCurve;
  11003. private _midtonesCurve;
  11004. private _shadowsCurve;
  11005. private _positiveCurve;
  11006. private _negativeCurve;
  11007. private _globalHue;
  11008. private _globalDensity;
  11009. private _globalSaturation;
  11010. private _globalExposure;
  11011. /**
  11012. * Gets the global Hue value.
  11013. * 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).
  11014. */
  11015. get globalHue(): number;
  11016. /**
  11017. * Sets the global Hue value.
  11018. * 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).
  11019. */
  11020. set globalHue(value: number);
  11021. /**
  11022. * Gets the global Density value.
  11023. * 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.
  11024. * Values less than zero provide a filter of opposite hue.
  11025. */
  11026. get globalDensity(): number;
  11027. /**
  11028. * Sets the global Density value.
  11029. * 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.
  11030. * Values less than zero provide a filter of opposite hue.
  11031. */
  11032. set globalDensity(value: number);
  11033. /**
  11034. * Gets the global Saturation value.
  11035. * 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.
  11036. */
  11037. get globalSaturation(): number;
  11038. /**
  11039. * Sets the global Saturation value.
  11040. * 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.
  11041. */
  11042. set globalSaturation(value: number);
  11043. /**
  11044. * Gets the global Exposure value.
  11045. * 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.
  11046. */
  11047. get globalExposure(): number;
  11048. /**
  11049. * Sets the global Exposure value.
  11050. * 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.
  11051. */
  11052. set globalExposure(value: number);
  11053. private _highlightsHue;
  11054. private _highlightsDensity;
  11055. private _highlightsSaturation;
  11056. private _highlightsExposure;
  11057. /**
  11058. * Gets the highlights Hue value.
  11059. * 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).
  11060. */
  11061. get highlightsHue(): number;
  11062. /**
  11063. * Sets the highlights Hue value.
  11064. * 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).
  11065. */
  11066. set highlightsHue(value: number);
  11067. /**
  11068. * Gets the highlights Density value.
  11069. * 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.
  11070. * Values less than zero provide a filter of opposite hue.
  11071. */
  11072. get highlightsDensity(): number;
  11073. /**
  11074. * Sets the highlights Density value.
  11075. * 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.
  11076. * Values less than zero provide a filter of opposite hue.
  11077. */
  11078. set highlightsDensity(value: number);
  11079. /**
  11080. * Gets the highlights Saturation value.
  11081. * 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.
  11082. */
  11083. get highlightsSaturation(): number;
  11084. /**
  11085. * Sets the highlights Saturation value.
  11086. * 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.
  11087. */
  11088. set highlightsSaturation(value: number);
  11089. /**
  11090. * Gets the highlights Exposure value.
  11091. * 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.
  11092. */
  11093. get highlightsExposure(): number;
  11094. /**
  11095. * Sets the highlights Exposure value.
  11096. * 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.
  11097. */
  11098. set highlightsExposure(value: number);
  11099. private _midtonesHue;
  11100. private _midtonesDensity;
  11101. private _midtonesSaturation;
  11102. private _midtonesExposure;
  11103. /**
  11104. * Gets the midtones Hue value.
  11105. * 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).
  11106. */
  11107. get midtonesHue(): number;
  11108. /**
  11109. * Sets the midtones Hue value.
  11110. * 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).
  11111. */
  11112. set midtonesHue(value: number);
  11113. /**
  11114. * Gets the midtones Density value.
  11115. * 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.
  11116. * Values less than zero provide a filter of opposite hue.
  11117. */
  11118. get midtonesDensity(): number;
  11119. /**
  11120. * Sets the midtones Density value.
  11121. * 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.
  11122. * Values less than zero provide a filter of opposite hue.
  11123. */
  11124. set midtonesDensity(value: number);
  11125. /**
  11126. * Gets the midtones Saturation value.
  11127. * 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.
  11128. */
  11129. get midtonesSaturation(): number;
  11130. /**
  11131. * Sets the midtones Saturation value.
  11132. * 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.
  11133. */
  11134. set midtonesSaturation(value: number);
  11135. /**
  11136. * Gets the midtones Exposure value.
  11137. * 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.
  11138. */
  11139. get midtonesExposure(): number;
  11140. /**
  11141. * Sets the midtones Exposure value.
  11142. * 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.
  11143. */
  11144. set midtonesExposure(value: number);
  11145. private _shadowsHue;
  11146. private _shadowsDensity;
  11147. private _shadowsSaturation;
  11148. private _shadowsExposure;
  11149. /**
  11150. * Gets the shadows Hue value.
  11151. * 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).
  11152. */
  11153. get shadowsHue(): number;
  11154. /**
  11155. * Sets the shadows Hue value.
  11156. * 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).
  11157. */
  11158. set shadowsHue(value: number);
  11159. /**
  11160. * Gets the shadows Density value.
  11161. * 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.
  11162. * Values less than zero provide a filter of opposite hue.
  11163. */
  11164. get shadowsDensity(): number;
  11165. /**
  11166. * Sets the shadows Density value.
  11167. * 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.
  11168. * Values less than zero provide a filter of opposite hue.
  11169. */
  11170. set shadowsDensity(value: number);
  11171. /**
  11172. * Gets the shadows Saturation value.
  11173. * 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.
  11174. */
  11175. get shadowsSaturation(): number;
  11176. /**
  11177. * Sets the shadows Saturation value.
  11178. * 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.
  11179. */
  11180. set shadowsSaturation(value: number);
  11181. /**
  11182. * Gets the shadows Exposure value.
  11183. * 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.
  11184. */
  11185. get shadowsExposure(): number;
  11186. /**
  11187. * Sets the shadows Exposure value.
  11188. * 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.
  11189. */
  11190. set shadowsExposure(value: number);
  11191. /**
  11192. * Returns the class name
  11193. * @returns The class name
  11194. */
  11195. getClassName(): string;
  11196. /**
  11197. * Binds the color curves to the shader.
  11198. * @param colorCurves The color curve to bind
  11199. * @param effect The effect to bind to
  11200. * @param positiveUniform The positive uniform shader parameter
  11201. * @param neutralUniform The neutral uniform shader parameter
  11202. * @param negativeUniform The negative uniform shader parameter
  11203. */
  11204. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11205. /**
  11206. * Prepare the list of uniforms associated with the ColorCurves effects.
  11207. * @param uniformsList The list of uniforms used in the effect
  11208. */
  11209. static PrepareUniforms(uniformsList: string[]): void;
  11210. /**
  11211. * Returns color grading data based on a hue, density, saturation and exposure value.
  11212. * @param filterHue The hue of the color filter.
  11213. * @param filterDensity The density of the color filter.
  11214. * @param saturation The saturation.
  11215. * @param exposure The exposure.
  11216. * @param result The result data container.
  11217. */
  11218. private getColorGradingDataToRef;
  11219. /**
  11220. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11221. * @param value The input slider value in range [-100,100].
  11222. * @returns Adjusted value.
  11223. */
  11224. private static applyColorGradingSliderNonlinear;
  11225. /**
  11226. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11227. * @param hue The hue (H) input.
  11228. * @param saturation The saturation (S) input.
  11229. * @param brightness The brightness (B) input.
  11230. * @result An RGBA color represented as Vector4.
  11231. */
  11232. private static fromHSBToRef;
  11233. /**
  11234. * Returns a value clamped between min and max
  11235. * @param value The value to clamp
  11236. * @param min The minimum of value
  11237. * @param max The maximum of value
  11238. * @returns The clamped value.
  11239. */
  11240. private static clamp;
  11241. /**
  11242. * Clones the current color curve instance.
  11243. * @return The cloned curves
  11244. */
  11245. clone(): ColorCurves;
  11246. /**
  11247. * Serializes the current color curve instance to a json representation.
  11248. * @return a JSON representation
  11249. */
  11250. serialize(): any;
  11251. /**
  11252. * Parses the color curve from a json representation.
  11253. * @param source the JSON source to parse
  11254. * @return The parsed curves
  11255. */
  11256. static Parse(source: any): ColorCurves;
  11257. }
  11258. }
  11259. declare module BABYLON {
  11260. /**
  11261. * Interface to follow in your material defines to integrate easily the
  11262. * Image proccessing functions.
  11263. * @hidden
  11264. */
  11265. export interface IImageProcessingConfigurationDefines {
  11266. IMAGEPROCESSING: boolean;
  11267. VIGNETTE: boolean;
  11268. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11269. VIGNETTEBLENDMODEOPAQUE: boolean;
  11270. TONEMAPPING: boolean;
  11271. TONEMAPPING_ACES: boolean;
  11272. CONTRAST: boolean;
  11273. EXPOSURE: boolean;
  11274. COLORCURVES: boolean;
  11275. COLORGRADING: boolean;
  11276. COLORGRADING3D: boolean;
  11277. SAMPLER3DGREENDEPTH: boolean;
  11278. SAMPLER3DBGRMAP: boolean;
  11279. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11280. }
  11281. /**
  11282. * @hidden
  11283. */
  11284. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11285. IMAGEPROCESSING: boolean;
  11286. VIGNETTE: boolean;
  11287. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11288. VIGNETTEBLENDMODEOPAQUE: boolean;
  11289. TONEMAPPING: boolean;
  11290. TONEMAPPING_ACES: boolean;
  11291. CONTRAST: boolean;
  11292. COLORCURVES: boolean;
  11293. COLORGRADING: boolean;
  11294. COLORGRADING3D: boolean;
  11295. SAMPLER3DGREENDEPTH: boolean;
  11296. SAMPLER3DBGRMAP: boolean;
  11297. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11298. EXPOSURE: boolean;
  11299. constructor();
  11300. }
  11301. /**
  11302. * This groups together the common properties used for image processing either in direct forward pass
  11303. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11304. * or not.
  11305. */
  11306. export class ImageProcessingConfiguration {
  11307. /**
  11308. * Default tone mapping applied in BabylonJS.
  11309. */
  11310. static readonly TONEMAPPING_STANDARD: number;
  11311. /**
  11312. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11313. * to other engines rendering to increase portability.
  11314. */
  11315. static readonly TONEMAPPING_ACES: number;
  11316. /**
  11317. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11318. */
  11319. colorCurves: Nullable<ColorCurves>;
  11320. private _colorCurvesEnabled;
  11321. /**
  11322. * Gets wether the color curves effect is enabled.
  11323. */
  11324. get colorCurvesEnabled(): boolean;
  11325. /**
  11326. * Sets wether the color curves effect is enabled.
  11327. */
  11328. set colorCurvesEnabled(value: boolean);
  11329. private _colorGradingTexture;
  11330. /**
  11331. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11332. */
  11333. get colorGradingTexture(): Nullable<BaseTexture>;
  11334. /**
  11335. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11336. */
  11337. set colorGradingTexture(value: Nullable<BaseTexture>);
  11338. private _colorGradingEnabled;
  11339. /**
  11340. * Gets wether the color grading effect is enabled.
  11341. */
  11342. get colorGradingEnabled(): boolean;
  11343. /**
  11344. * Sets wether the color grading effect is enabled.
  11345. */
  11346. set colorGradingEnabled(value: boolean);
  11347. private _colorGradingWithGreenDepth;
  11348. /**
  11349. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11350. */
  11351. get colorGradingWithGreenDepth(): boolean;
  11352. /**
  11353. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11354. */
  11355. set colorGradingWithGreenDepth(value: boolean);
  11356. private _colorGradingBGR;
  11357. /**
  11358. * Gets wether the color grading texture contains BGR values.
  11359. */
  11360. get colorGradingBGR(): boolean;
  11361. /**
  11362. * Sets wether the color grading texture contains BGR values.
  11363. */
  11364. set colorGradingBGR(value: boolean);
  11365. /** @hidden */
  11366. _exposure: number;
  11367. /**
  11368. * Gets the Exposure used in the effect.
  11369. */
  11370. get exposure(): number;
  11371. /**
  11372. * Sets the Exposure used in the effect.
  11373. */
  11374. set exposure(value: number);
  11375. private _toneMappingEnabled;
  11376. /**
  11377. * Gets wether the tone mapping effect is enabled.
  11378. */
  11379. get toneMappingEnabled(): boolean;
  11380. /**
  11381. * Sets wether the tone mapping effect is enabled.
  11382. */
  11383. set toneMappingEnabled(value: boolean);
  11384. private _toneMappingType;
  11385. /**
  11386. * Gets the type of tone mapping effect.
  11387. */
  11388. get toneMappingType(): number;
  11389. /**
  11390. * Sets the type of tone mapping effect used in BabylonJS.
  11391. */
  11392. set toneMappingType(value: number);
  11393. protected _contrast: number;
  11394. /**
  11395. * Gets the contrast used in the effect.
  11396. */
  11397. get contrast(): number;
  11398. /**
  11399. * Sets the contrast used in the effect.
  11400. */
  11401. set contrast(value: number);
  11402. /**
  11403. * Vignette stretch size.
  11404. */
  11405. vignetteStretch: number;
  11406. /**
  11407. * Vignette centre X Offset.
  11408. */
  11409. vignetteCentreX: number;
  11410. /**
  11411. * Vignette centre Y Offset.
  11412. */
  11413. vignetteCentreY: number;
  11414. /**
  11415. * Vignette weight or intensity of the vignette effect.
  11416. */
  11417. vignetteWeight: number;
  11418. /**
  11419. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11420. * if vignetteEnabled is set to true.
  11421. */
  11422. vignetteColor: Color4;
  11423. /**
  11424. * Camera field of view used by the Vignette effect.
  11425. */
  11426. vignetteCameraFov: number;
  11427. private _vignetteBlendMode;
  11428. /**
  11429. * Gets the vignette blend mode allowing different kind of effect.
  11430. */
  11431. get vignetteBlendMode(): number;
  11432. /**
  11433. * Sets the vignette blend mode allowing different kind of effect.
  11434. */
  11435. set vignetteBlendMode(value: number);
  11436. private _vignetteEnabled;
  11437. /**
  11438. * Gets wether the vignette effect is enabled.
  11439. */
  11440. get vignetteEnabled(): boolean;
  11441. /**
  11442. * Sets wether the vignette effect is enabled.
  11443. */
  11444. set vignetteEnabled(value: boolean);
  11445. private _applyByPostProcess;
  11446. /**
  11447. * Gets wether the image processing is applied through a post process or not.
  11448. */
  11449. get applyByPostProcess(): boolean;
  11450. /**
  11451. * Sets wether the image processing is applied through a post process or not.
  11452. */
  11453. set applyByPostProcess(value: boolean);
  11454. private _isEnabled;
  11455. /**
  11456. * Gets wether the image processing is enabled or not.
  11457. */
  11458. get isEnabled(): boolean;
  11459. /**
  11460. * Sets wether the image processing is enabled or not.
  11461. */
  11462. set isEnabled(value: boolean);
  11463. /**
  11464. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11465. */
  11466. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11467. /**
  11468. * Method called each time the image processing information changes requires to recompile the effect.
  11469. */
  11470. protected _updateParameters(): void;
  11471. /**
  11472. * Gets the current class name.
  11473. * @return "ImageProcessingConfiguration"
  11474. */
  11475. getClassName(): string;
  11476. /**
  11477. * Prepare the list of uniforms associated with the Image Processing effects.
  11478. * @param uniforms The list of uniforms used in the effect
  11479. * @param defines the list of defines currently in use
  11480. */
  11481. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11482. /**
  11483. * Prepare the list of samplers associated with the Image Processing effects.
  11484. * @param samplersList The list of uniforms used in the effect
  11485. * @param defines the list of defines currently in use
  11486. */
  11487. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11488. /**
  11489. * Prepare the list of defines associated to the shader.
  11490. * @param defines the list of defines to complete
  11491. * @param forPostProcess Define if we are currently in post process mode or not
  11492. */
  11493. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11494. /**
  11495. * Returns true if all the image processing information are ready.
  11496. * @returns True if ready, otherwise, false
  11497. */
  11498. isReady(): boolean;
  11499. /**
  11500. * Binds the image processing to the shader.
  11501. * @param effect The effect to bind to
  11502. * @param overrideAspectRatio Override the aspect ratio of the effect
  11503. */
  11504. bind(effect: Effect, overrideAspectRatio?: number): void;
  11505. /**
  11506. * Clones the current image processing instance.
  11507. * @return The cloned image processing
  11508. */
  11509. clone(): ImageProcessingConfiguration;
  11510. /**
  11511. * Serializes the current image processing instance to a json representation.
  11512. * @return a JSON representation
  11513. */
  11514. serialize(): any;
  11515. /**
  11516. * Parses the image processing from a json representation.
  11517. * @param source the JSON source to parse
  11518. * @return The parsed image processing
  11519. */
  11520. static Parse(source: any): ImageProcessingConfiguration;
  11521. private static _VIGNETTEMODE_MULTIPLY;
  11522. private static _VIGNETTEMODE_OPAQUE;
  11523. /**
  11524. * Used to apply the vignette as a mix with the pixel color.
  11525. */
  11526. static get VIGNETTEMODE_MULTIPLY(): number;
  11527. /**
  11528. * Used to apply the vignette as a replacement of the pixel color.
  11529. */
  11530. static get VIGNETTEMODE_OPAQUE(): number;
  11531. }
  11532. }
  11533. declare module BABYLON {
  11534. /** @hidden */
  11535. export var postprocessVertexShader: {
  11536. name: string;
  11537. shader: string;
  11538. };
  11539. }
  11540. declare module BABYLON {
  11541. /**
  11542. * Type used to define a render target texture size (either with a number or with a rect width and height)
  11543. */
  11544. export type RenderTargetTextureSize = number | {
  11545. width: number;
  11546. height: number;
  11547. layers?: number;
  11548. };
  11549. interface ThinEngine {
  11550. /**
  11551. * Creates a new render target texture
  11552. * @param size defines the size of the texture
  11553. * @param options defines the options used to create the texture
  11554. * @returns a new render target texture stored in an InternalTexture
  11555. */
  11556. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11557. /**
  11558. * Creates a depth stencil texture.
  11559. * This is only available in WebGL 2 or with the depth texture extension available.
  11560. * @param size The size of face edge in the texture.
  11561. * @param options The options defining the texture.
  11562. * @returns The texture
  11563. */
  11564. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11565. /** @hidden */
  11566. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11567. }
  11568. }
  11569. declare module BABYLON {
  11570. /**
  11571. * Defines the kind of connection point for node based material
  11572. */
  11573. export enum NodeMaterialBlockConnectionPointTypes {
  11574. /** Float */
  11575. Float = 1,
  11576. /** Int */
  11577. Int = 2,
  11578. /** Vector2 */
  11579. Vector2 = 4,
  11580. /** Vector3 */
  11581. Vector3 = 8,
  11582. /** Vector4 */
  11583. Vector4 = 16,
  11584. /** Color3 */
  11585. Color3 = 32,
  11586. /** Color4 */
  11587. Color4 = 64,
  11588. /** Matrix */
  11589. Matrix = 128,
  11590. /** Custom object */
  11591. Object = 256,
  11592. /** Detect type based on connection */
  11593. AutoDetect = 1024,
  11594. /** Output type that will be defined by input type */
  11595. BasedOnInput = 2048
  11596. }
  11597. }
  11598. declare module BABYLON {
  11599. /**
  11600. * Enum used to define the target of a block
  11601. */
  11602. export enum NodeMaterialBlockTargets {
  11603. /** Vertex shader */
  11604. Vertex = 1,
  11605. /** Fragment shader */
  11606. Fragment = 2,
  11607. /** Neutral */
  11608. Neutral = 4,
  11609. /** Vertex and Fragment */
  11610. VertexAndFragment = 3
  11611. }
  11612. }
  11613. declare module BABYLON {
  11614. /**
  11615. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  11616. */
  11617. export enum NodeMaterialBlockConnectionPointMode {
  11618. /** Value is an uniform */
  11619. Uniform = 0,
  11620. /** Value is a mesh attribute */
  11621. Attribute = 1,
  11622. /** Value is a varying between vertex and fragment shaders */
  11623. Varying = 2,
  11624. /** Mode is undefined */
  11625. Undefined = 3
  11626. }
  11627. }
  11628. declare module BABYLON {
  11629. /**
  11630. * Enum used to define system values e.g. values automatically provided by the system
  11631. */
  11632. export enum NodeMaterialSystemValues {
  11633. /** World */
  11634. World = 1,
  11635. /** View */
  11636. View = 2,
  11637. /** Projection */
  11638. Projection = 3,
  11639. /** ViewProjection */
  11640. ViewProjection = 4,
  11641. /** WorldView */
  11642. WorldView = 5,
  11643. /** WorldViewProjection */
  11644. WorldViewProjection = 6,
  11645. /** CameraPosition */
  11646. CameraPosition = 7,
  11647. /** Fog Color */
  11648. FogColor = 8,
  11649. /** Delta time */
  11650. DeltaTime = 9
  11651. }
  11652. }
  11653. declare module BABYLON {
  11654. /**
  11655. * Represents a camera frustum
  11656. */
  11657. export class Frustum {
  11658. /**
  11659. * Gets the planes representing the frustum
  11660. * @param transform matrix to be applied to the returned planes
  11661. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  11662. */
  11663. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  11664. /**
  11665. * Gets the near frustum plane transformed by the transform matrix
  11666. * @param transform transformation matrix to be applied to the resulting frustum plane
  11667. * @param frustumPlane the resuling frustum plane
  11668. */
  11669. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11670. /**
  11671. * Gets the far frustum plane transformed by the transform matrix
  11672. * @param transform transformation matrix to be applied to the resulting frustum plane
  11673. * @param frustumPlane the resuling frustum plane
  11674. */
  11675. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11676. /**
  11677. * Gets the left frustum plane transformed by the transform matrix
  11678. * @param transform transformation matrix to be applied to the resulting frustum plane
  11679. * @param frustumPlane the resuling frustum plane
  11680. */
  11681. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11682. /**
  11683. * Gets the right frustum plane transformed by the transform matrix
  11684. * @param transform transformation matrix to be applied to the resulting frustum plane
  11685. * @param frustumPlane the resuling frustum plane
  11686. */
  11687. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11688. /**
  11689. * Gets the top frustum plane transformed by the transform matrix
  11690. * @param transform transformation matrix to be applied to the resulting frustum plane
  11691. * @param frustumPlane the resuling frustum plane
  11692. */
  11693. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11694. /**
  11695. * Gets the bottom frustum plane transformed by the transform matrix
  11696. * @param transform transformation matrix to be applied to the resulting frustum plane
  11697. * @param frustumPlane the resuling frustum plane
  11698. */
  11699. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11700. /**
  11701. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  11702. * @param transform transformation matrix to be applied to the resulting frustum planes
  11703. * @param frustumPlanes the resuling frustum planes
  11704. */
  11705. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  11706. }
  11707. }
  11708. declare module BABYLON {
  11709. /**
  11710. * Contains position and normal vectors for a vertex
  11711. */
  11712. export class PositionNormalVertex {
  11713. /** the position of the vertex (defaut: 0,0,0) */
  11714. position: Vector3;
  11715. /** the normal of the vertex (defaut: 0,1,0) */
  11716. normal: Vector3;
  11717. /**
  11718. * Creates a PositionNormalVertex
  11719. * @param position the position of the vertex (defaut: 0,0,0)
  11720. * @param normal the normal of the vertex (defaut: 0,1,0)
  11721. */
  11722. constructor(
  11723. /** the position of the vertex (defaut: 0,0,0) */
  11724. position?: Vector3,
  11725. /** the normal of the vertex (defaut: 0,1,0) */
  11726. normal?: Vector3);
  11727. /**
  11728. * Clones the PositionNormalVertex
  11729. * @returns the cloned PositionNormalVertex
  11730. */
  11731. clone(): PositionNormalVertex;
  11732. }
  11733. /**
  11734. * Contains position, normal and uv vectors for a vertex
  11735. */
  11736. export class PositionNormalTextureVertex {
  11737. /** the position of the vertex (defaut: 0,0,0) */
  11738. position: Vector3;
  11739. /** the normal of the vertex (defaut: 0,1,0) */
  11740. normal: Vector3;
  11741. /** the uv of the vertex (default: 0,0) */
  11742. uv: Vector2;
  11743. /**
  11744. * Creates a PositionNormalTextureVertex
  11745. * @param position the position of the vertex (defaut: 0,0,0)
  11746. * @param normal the normal of the vertex (defaut: 0,1,0)
  11747. * @param uv the uv of the vertex (default: 0,0)
  11748. */
  11749. constructor(
  11750. /** the position of the vertex (defaut: 0,0,0) */
  11751. position?: Vector3,
  11752. /** the normal of the vertex (defaut: 0,1,0) */
  11753. normal?: Vector3,
  11754. /** the uv of the vertex (default: 0,0) */
  11755. uv?: Vector2);
  11756. /**
  11757. * Clones the PositionNormalTextureVertex
  11758. * @returns the cloned PositionNormalTextureVertex
  11759. */
  11760. clone(): PositionNormalTextureVertex;
  11761. }
  11762. }
  11763. declare module BABYLON {
  11764. /**
  11765. * Enum defining the type of animations supported by InputBlock
  11766. */
  11767. export enum AnimatedInputBlockTypes {
  11768. /** No animation */
  11769. None = 0,
  11770. /** Time based animation. Will only work for floats */
  11771. Time = 1
  11772. }
  11773. }
  11774. declare module BABYLON {
  11775. /**
  11776. * Block used to expose an input value
  11777. */
  11778. export class InputBlock extends NodeMaterialBlock {
  11779. private _mode;
  11780. private _associatedVariableName;
  11781. private _storedValue;
  11782. private _valueCallback;
  11783. private _type;
  11784. private _animationType;
  11785. /** Gets or set a value used to limit the range of float values */
  11786. min: number;
  11787. /** Gets or set a value used to limit the range of float values */
  11788. max: number;
  11789. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  11790. isBoolean: boolean;
  11791. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  11792. matrixMode: number;
  11793. /** @hidden */
  11794. _systemValue: Nullable<NodeMaterialSystemValues>;
  11795. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  11796. isConstant: boolean;
  11797. /** Gets or sets the group to use to display this block in the Inspector */
  11798. groupInInspector: string;
  11799. /** Gets an observable raised when the value is changed */
  11800. onValueChangedObservable: Observable<InputBlock>;
  11801. /**
  11802. * Gets or sets the connection point type (default is float)
  11803. */
  11804. get type(): NodeMaterialBlockConnectionPointTypes;
  11805. /**
  11806. * Creates a new InputBlock
  11807. * @param name defines the block name
  11808. * @param target defines the target of that block (Vertex by default)
  11809. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  11810. */
  11811. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  11812. /**
  11813. * Validates if a name is a reserve word.
  11814. * @param newName the new name to be given to the node.
  11815. * @returns false if the name is a reserve word, else true.
  11816. */
  11817. validateBlockName(newName: string): boolean;
  11818. /**
  11819. * Gets the output component
  11820. */
  11821. get output(): NodeMaterialConnectionPoint;
  11822. /**
  11823. * Set the source of this connection point to a vertex attribute
  11824. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  11825. * @returns the current connection point
  11826. */
  11827. setAsAttribute(attributeName?: string): InputBlock;
  11828. /**
  11829. * Set the source of this connection point to a system value
  11830. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  11831. * @returns the current connection point
  11832. */
  11833. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  11834. /**
  11835. * Gets or sets the value of that point.
  11836. * Please note that this value will be ignored if valueCallback is defined
  11837. */
  11838. get value(): any;
  11839. set value(value: any);
  11840. /**
  11841. * Gets or sets a callback used to get the value of that point.
  11842. * Please note that setting this value will force the connection point to ignore the value property
  11843. */
  11844. get valueCallback(): () => any;
  11845. set valueCallback(value: () => any);
  11846. /**
  11847. * Gets or sets the associated variable name in the shader
  11848. */
  11849. get associatedVariableName(): string;
  11850. set associatedVariableName(value: string);
  11851. /** Gets or sets the type of animation applied to the input */
  11852. get animationType(): AnimatedInputBlockTypes;
  11853. set animationType(value: AnimatedInputBlockTypes);
  11854. /**
  11855. * Gets a boolean indicating that this connection point not defined yet
  11856. */
  11857. get isUndefined(): boolean;
  11858. /**
  11859. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  11860. * In this case the connection point name must be the name of the uniform to use.
  11861. * Can only be set on inputs
  11862. */
  11863. get isUniform(): boolean;
  11864. set isUniform(value: boolean);
  11865. /**
  11866. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  11867. * In this case the connection point name must be the name of the attribute to use
  11868. * Can only be set on inputs
  11869. */
  11870. get isAttribute(): boolean;
  11871. set isAttribute(value: boolean);
  11872. /**
  11873. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  11874. * Can only be set on exit points
  11875. */
  11876. get isVarying(): boolean;
  11877. set isVarying(value: boolean);
  11878. /**
  11879. * Gets a boolean indicating that the current connection point is a system value
  11880. */
  11881. get isSystemValue(): boolean;
  11882. /**
  11883. * Gets or sets the current well known value or null if not defined as a system value
  11884. */
  11885. get systemValue(): Nullable<NodeMaterialSystemValues>;
  11886. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  11887. /**
  11888. * Gets the current class name
  11889. * @returns the class name
  11890. */
  11891. getClassName(): string;
  11892. /**
  11893. * Animate the input if animationType !== None
  11894. * @param scene defines the rendering scene
  11895. */
  11896. animate(scene: Scene): void;
  11897. private _emitDefine;
  11898. initialize(state: NodeMaterialBuildState): void;
  11899. /**
  11900. * Set the input block to its default value (based on its type)
  11901. */
  11902. setDefaultValue(): void;
  11903. private _emitConstant;
  11904. /** @hidden */
  11905. get _noContextSwitch(): boolean;
  11906. private _emit;
  11907. /** @hidden */
  11908. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  11909. /** @hidden */
  11910. _transmit(effect: Effect, scene: Scene): void;
  11911. protected _buildBlock(state: NodeMaterialBuildState): void;
  11912. protected _dumpPropertiesCode(): string;
  11913. dispose(): void;
  11914. serialize(): any;
  11915. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  11916. }
  11917. }
  11918. declare module BABYLON {
  11919. /**
  11920. * Enum used to define the compatibility state between two connection points
  11921. */
  11922. export enum NodeMaterialConnectionPointCompatibilityStates {
  11923. /** Points are compatibles */
  11924. Compatible = 0,
  11925. /** Points are incompatible because of their types */
  11926. TypeIncompatible = 1,
  11927. /** Points are incompatible because of their targets (vertex vs fragment) */
  11928. TargetIncompatible = 2
  11929. }
  11930. /**
  11931. * Defines the direction of a connection point
  11932. */
  11933. export enum NodeMaterialConnectionPointDirection {
  11934. /** Input */
  11935. Input = 0,
  11936. /** Output */
  11937. Output = 1
  11938. }
  11939. /**
  11940. * Defines a connection point for a block
  11941. */
  11942. export class NodeMaterialConnectionPoint {
  11943. /**
  11944. * Checks if two types are equivalent
  11945. * @param type1 type 1 to check
  11946. * @param type2 type 2 to check
  11947. * @returns true if both types are equivalent, else false
  11948. */
  11949. static AreEquivalentTypes(type1: number, type2: number): boolean;
  11950. /** @hidden */
  11951. _ownerBlock: NodeMaterialBlock;
  11952. /** @hidden */
  11953. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  11954. private _endpoints;
  11955. private _associatedVariableName;
  11956. private _direction;
  11957. /** @hidden */
  11958. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  11959. /** @hidden */
  11960. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  11961. /** @hidden */
  11962. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  11963. private _type;
  11964. /** @hidden */
  11965. _enforceAssociatedVariableName: boolean;
  11966. /** Gets the direction of the point */
  11967. get direction(): NodeMaterialConnectionPointDirection;
  11968. /** Indicates that this connection point needs dual validation before being connected to another point */
  11969. needDualDirectionValidation: boolean;
  11970. /**
  11971. * Gets or sets the additional types supported by this connection point
  11972. */
  11973. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  11974. /**
  11975. * Gets or sets the additional types excluded by this connection point
  11976. */
  11977. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  11978. /**
  11979. * Observable triggered when this point is connected
  11980. */
  11981. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  11982. /**
  11983. * Gets or sets the associated variable name in the shader
  11984. */
  11985. get associatedVariableName(): string;
  11986. set associatedVariableName(value: string);
  11987. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  11988. get innerType(): NodeMaterialBlockConnectionPointTypes;
  11989. /**
  11990. * Gets or sets the connection point type (default is float)
  11991. */
  11992. get type(): NodeMaterialBlockConnectionPointTypes;
  11993. set type(value: NodeMaterialBlockConnectionPointTypes);
  11994. /**
  11995. * Gets or sets the connection point name
  11996. */
  11997. name: string;
  11998. /**
  11999. * Gets or sets the connection point name
  12000. */
  12001. displayName: string;
  12002. /**
  12003. * Gets or sets a boolean indicating that this connection point can be omitted
  12004. */
  12005. isOptional: boolean;
  12006. /**
  12007. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12008. */
  12009. isExposedOnFrame: boolean;
  12010. /**
  12011. * Gets or sets number indicating the position that the port is exposed to on a frame
  12012. */
  12013. exposedPortPosition: number;
  12014. /**
  12015. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12016. */
  12017. define: string;
  12018. /** @hidden */
  12019. _prioritizeVertex: boolean;
  12020. private _target;
  12021. /** Gets or sets the target of that connection point */
  12022. get target(): NodeMaterialBlockTargets;
  12023. set target(value: NodeMaterialBlockTargets);
  12024. /**
  12025. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12026. */
  12027. get isConnected(): boolean;
  12028. /**
  12029. * Gets a boolean indicating that the current point is connected to an input block
  12030. */
  12031. get isConnectedToInputBlock(): boolean;
  12032. /**
  12033. * Gets a the connected input block (if any)
  12034. */
  12035. get connectInputBlock(): Nullable<InputBlock>;
  12036. /** Get the other side of the connection (if any) */
  12037. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12038. /** Get the block that owns this connection point */
  12039. get ownerBlock(): NodeMaterialBlock;
  12040. /** Get the block connected on the other side of this connection (if any) */
  12041. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12042. /** Get the block connected on the endpoints of this connection (if any) */
  12043. get connectedBlocks(): Array<NodeMaterialBlock>;
  12044. /** Gets the list of connected endpoints */
  12045. get endpoints(): NodeMaterialConnectionPoint[];
  12046. /** Gets a boolean indicating if that output point is connected to at least one input */
  12047. get hasEndpoints(): boolean;
  12048. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12049. get isConnectedInVertexShader(): boolean;
  12050. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12051. get isConnectedInFragmentShader(): boolean;
  12052. /**
  12053. * Creates a block suitable to be used as an input for this input point.
  12054. * If null is returned, a block based on the point type will be created.
  12055. * @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
  12056. */
  12057. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12058. /**
  12059. * Creates a new connection point
  12060. * @param name defines the connection point name
  12061. * @param ownerBlock defines the block hosting this connection point
  12062. * @param direction defines the direction of the connection point
  12063. */
  12064. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12065. /**
  12066. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12067. * @returns the class name
  12068. */
  12069. getClassName(): string;
  12070. /**
  12071. * Gets a boolean indicating if the current point can be connected to another point
  12072. * @param connectionPoint defines the other connection point
  12073. * @returns a boolean
  12074. */
  12075. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12076. /**
  12077. * Gets a number indicating if the current point can be connected to another point
  12078. * @param connectionPoint defines the other connection point
  12079. * @returns a number defining the compatibility state
  12080. */
  12081. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12082. /**
  12083. * Connect this point to another connection point
  12084. * @param connectionPoint defines the other connection point
  12085. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12086. * @returns the current connection point
  12087. */
  12088. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12089. /**
  12090. * Disconnect this point from one of his endpoint
  12091. * @param endpoint defines the other connection point
  12092. * @returns the current connection point
  12093. */
  12094. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12095. /**
  12096. * Serializes this point in a JSON representation
  12097. * @param isInput defines if the connection point is an input (default is true)
  12098. * @returns the serialized point object
  12099. */
  12100. serialize(isInput?: boolean): any;
  12101. /**
  12102. * Release resources
  12103. */
  12104. dispose(): void;
  12105. }
  12106. }
  12107. declare module BABYLON {
  12108. /**
  12109. * Enum used to define the material modes
  12110. */
  12111. export enum NodeMaterialModes {
  12112. /** Regular material */
  12113. Material = 0,
  12114. /** For post process */
  12115. PostProcess = 1,
  12116. /** For particle system */
  12117. Particle = 2,
  12118. /** For procedural texture */
  12119. ProceduralTexture = 3
  12120. }
  12121. }
  12122. declare module BABYLON {
  12123. /** @hidden */
  12124. export var helperFunctions: {
  12125. name: string;
  12126. shader: string;
  12127. };
  12128. }
  12129. declare module BABYLON {
  12130. /**
  12131. * Block used to read a texture from a sampler
  12132. */
  12133. export class TextureBlock extends NodeMaterialBlock {
  12134. private _defineName;
  12135. private _linearDefineName;
  12136. private _gammaDefineName;
  12137. private _tempTextureRead;
  12138. private _samplerName;
  12139. private _transformedUVName;
  12140. private _textureTransformName;
  12141. private _textureInfoName;
  12142. private _mainUVName;
  12143. private _mainUVDefineName;
  12144. private _fragmentOnly;
  12145. /**
  12146. * Gets or sets the texture associated with the node
  12147. */
  12148. texture: Nullable<Texture>;
  12149. /**
  12150. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12151. */
  12152. convertToGammaSpace: boolean;
  12153. /**
  12154. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12155. */
  12156. convertToLinearSpace: boolean;
  12157. /**
  12158. * Create a new TextureBlock
  12159. * @param name defines the block name
  12160. */
  12161. constructor(name: string, fragmentOnly?: boolean);
  12162. /**
  12163. * Gets the current class name
  12164. * @returns the class name
  12165. */
  12166. getClassName(): string;
  12167. /**
  12168. * Gets the uv input component
  12169. */
  12170. get uv(): NodeMaterialConnectionPoint;
  12171. /**
  12172. * Gets the rgba output component
  12173. */
  12174. get rgba(): NodeMaterialConnectionPoint;
  12175. /**
  12176. * Gets the rgb output component
  12177. */
  12178. get rgb(): NodeMaterialConnectionPoint;
  12179. /**
  12180. * Gets the r output component
  12181. */
  12182. get r(): NodeMaterialConnectionPoint;
  12183. /**
  12184. * Gets the g output component
  12185. */
  12186. get g(): NodeMaterialConnectionPoint;
  12187. /**
  12188. * Gets the b output component
  12189. */
  12190. get b(): NodeMaterialConnectionPoint;
  12191. /**
  12192. * Gets the a output component
  12193. */
  12194. get a(): NodeMaterialConnectionPoint;
  12195. get target(): NodeMaterialBlockTargets;
  12196. autoConfigure(material: NodeMaterial): void;
  12197. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12198. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12199. isReady(): boolean;
  12200. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12201. private get _isMixed();
  12202. private _injectVertexCode;
  12203. private _writeTextureRead;
  12204. private _writeOutput;
  12205. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12206. protected _dumpPropertiesCode(): string;
  12207. serialize(): any;
  12208. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12209. }
  12210. }
  12211. declare module BABYLON {
  12212. /** @hidden */
  12213. export var reflectionFunction: {
  12214. name: string;
  12215. shader: string;
  12216. };
  12217. }
  12218. declare module BABYLON {
  12219. /**
  12220. * Base block used to read a reflection texture from a sampler
  12221. */
  12222. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12223. /** @hidden */
  12224. _define3DName: string;
  12225. /** @hidden */
  12226. _defineCubicName: string;
  12227. /** @hidden */
  12228. _defineExplicitName: string;
  12229. /** @hidden */
  12230. _defineProjectionName: string;
  12231. /** @hidden */
  12232. _defineLocalCubicName: string;
  12233. /** @hidden */
  12234. _defineSphericalName: string;
  12235. /** @hidden */
  12236. _definePlanarName: string;
  12237. /** @hidden */
  12238. _defineEquirectangularName: string;
  12239. /** @hidden */
  12240. _defineMirroredEquirectangularFixedName: string;
  12241. /** @hidden */
  12242. _defineEquirectangularFixedName: string;
  12243. /** @hidden */
  12244. _defineSkyboxName: string;
  12245. /** @hidden */
  12246. _defineOppositeZ: string;
  12247. /** @hidden */
  12248. _cubeSamplerName: string;
  12249. /** @hidden */
  12250. _2DSamplerName: string;
  12251. protected _positionUVWName: string;
  12252. protected _directionWName: string;
  12253. protected _reflectionVectorName: string;
  12254. /** @hidden */
  12255. _reflectionCoordsName: string;
  12256. /** @hidden */
  12257. _reflectionMatrixName: string;
  12258. protected _reflectionColorName: string;
  12259. /**
  12260. * Gets or sets the texture associated with the node
  12261. */
  12262. texture: Nullable<BaseTexture>;
  12263. /**
  12264. * Create a new ReflectionTextureBaseBlock
  12265. * @param name defines the block name
  12266. */
  12267. constructor(name: string);
  12268. /**
  12269. * Gets the current class name
  12270. * @returns the class name
  12271. */
  12272. getClassName(): string;
  12273. /**
  12274. * Gets the world position input component
  12275. */
  12276. abstract get position(): NodeMaterialConnectionPoint;
  12277. /**
  12278. * Gets the world position input component
  12279. */
  12280. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12281. /**
  12282. * Gets the world normal input component
  12283. */
  12284. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12285. /**
  12286. * Gets the world input component
  12287. */
  12288. abstract get world(): NodeMaterialConnectionPoint;
  12289. /**
  12290. * Gets the camera (or eye) position component
  12291. */
  12292. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12293. /**
  12294. * Gets the view input component
  12295. */
  12296. abstract get view(): NodeMaterialConnectionPoint;
  12297. protected _getTexture(): Nullable<BaseTexture>;
  12298. autoConfigure(material: NodeMaterial): void;
  12299. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12300. isReady(): boolean;
  12301. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12302. /**
  12303. * Gets the code to inject in the vertex shader
  12304. * @param state current state of the node material building
  12305. * @returns the shader code
  12306. */
  12307. handleVertexSide(state: NodeMaterialBuildState): string;
  12308. /**
  12309. * Handles the inits for the fragment code path
  12310. * @param state node material build state
  12311. */
  12312. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12313. /**
  12314. * Generates the reflection coords code for the fragment code path
  12315. * @param worldNormalVarName name of the world normal variable
  12316. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12317. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12318. * @returns the shader code
  12319. */
  12320. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12321. /**
  12322. * Generates the reflection color code for the fragment code path
  12323. * @param lodVarName name of the lod variable
  12324. * @param swizzleLookupTexture swizzle to use for the final color variable
  12325. * @returns the shader code
  12326. */
  12327. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12328. /**
  12329. * Generates the code corresponding to the connected output points
  12330. * @param state node material build state
  12331. * @param varName name of the variable to output
  12332. * @returns the shader code
  12333. */
  12334. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12335. protected _buildBlock(state: NodeMaterialBuildState): this;
  12336. protected _dumpPropertiesCode(): string;
  12337. serialize(): any;
  12338. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12339. }
  12340. }
  12341. declare module BABYLON {
  12342. /**
  12343. * Defines a connection point to be used for points with a custom object type
  12344. */
  12345. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12346. private _blockType;
  12347. private _blockName;
  12348. private _nameForCheking?;
  12349. /**
  12350. * Creates a new connection point
  12351. * @param name defines the connection point name
  12352. * @param ownerBlock defines the block hosting this connection point
  12353. * @param direction defines the direction of the connection point
  12354. */
  12355. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12356. /**
  12357. * Gets a number indicating if the current point can be connected to another point
  12358. * @param connectionPoint defines the other connection point
  12359. * @returns a number defining the compatibility state
  12360. */
  12361. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12362. /**
  12363. * Creates a block suitable to be used as an input for this input point.
  12364. * If null is returned, a block based on the point type will be created.
  12365. * @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
  12366. */
  12367. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12368. }
  12369. }
  12370. declare module BABYLON {
  12371. /**
  12372. * Enum defining the type of properties that can be edited in the property pages in the NME
  12373. */
  12374. export enum PropertyTypeForEdition {
  12375. /** property is a boolean */
  12376. Boolean = 0,
  12377. /** property is a float */
  12378. Float = 1,
  12379. /** property is a Vector2 */
  12380. Vector2 = 2,
  12381. /** property is a list of values */
  12382. List = 3
  12383. }
  12384. /**
  12385. * Interface that defines an option in a variable of type list
  12386. */
  12387. export interface IEditablePropertyListOption {
  12388. /** label of the option */
  12389. "label": string;
  12390. /** value of the option */
  12391. "value": number;
  12392. }
  12393. /**
  12394. * Interface that defines the options available for an editable property
  12395. */
  12396. export interface IEditablePropertyOption {
  12397. /** min value */
  12398. "min"?: number;
  12399. /** max value */
  12400. "max"?: number;
  12401. /** notifiers: indicates which actions to take when the property is changed */
  12402. "notifiers"?: {
  12403. /** the material should be rebuilt */
  12404. "rebuild"?: boolean;
  12405. /** the preview should be updated */
  12406. "update"?: boolean;
  12407. };
  12408. /** list of the options for a variable of type list */
  12409. "options"?: IEditablePropertyListOption[];
  12410. }
  12411. /**
  12412. * Interface that describes an editable property
  12413. */
  12414. export interface IPropertyDescriptionForEdition {
  12415. /** name of the property */
  12416. "propertyName": string;
  12417. /** display name of the property */
  12418. "displayName": string;
  12419. /** type of the property */
  12420. "type": PropertyTypeForEdition;
  12421. /** group of the property - all properties with the same group value will be displayed in a specific section */
  12422. "groupName": string;
  12423. /** options for the property */
  12424. "options": IEditablePropertyOption;
  12425. }
  12426. /**
  12427. * Decorator that flags a property in a node material block as being editable
  12428. */
  12429. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  12430. }
  12431. declare module BABYLON {
  12432. /**
  12433. * Block used to implement the refraction part of the sub surface module of the PBR material
  12434. */
  12435. export class RefractionBlock extends NodeMaterialBlock {
  12436. /** @hidden */
  12437. _define3DName: string;
  12438. /** @hidden */
  12439. _refractionMatrixName: string;
  12440. /** @hidden */
  12441. _defineLODRefractionAlpha: string;
  12442. /** @hidden */
  12443. _defineLinearSpecularRefraction: string;
  12444. /** @hidden */
  12445. _defineOppositeZ: string;
  12446. /** @hidden */
  12447. _cubeSamplerName: string;
  12448. /** @hidden */
  12449. _2DSamplerName: string;
  12450. /** @hidden */
  12451. _vRefractionMicrosurfaceInfosName: string;
  12452. /** @hidden */
  12453. _vRefractionInfosName: string;
  12454. private _scene;
  12455. /**
  12456. * The properties below are set by the main PBR block prior to calling methods of this class.
  12457. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  12458. * It's less burden on the user side in the editor part.
  12459. */
  12460. /** @hidden */
  12461. viewConnectionPoint: NodeMaterialConnectionPoint;
  12462. /** @hidden */
  12463. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  12464. /**
  12465. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  12466. * Materials half opaque for instance using refraction could benefit from this control.
  12467. */
  12468. linkRefractionWithTransparency: boolean;
  12469. /**
  12470. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  12471. */
  12472. invertRefractionY: boolean;
  12473. /**
  12474. * Gets or sets the texture associated with the node
  12475. */
  12476. texture: Nullable<BaseTexture>;
  12477. /**
  12478. * Create a new RefractionBlock
  12479. * @param name defines the block name
  12480. */
  12481. constructor(name: string);
  12482. /**
  12483. * Gets the current class name
  12484. * @returns the class name
  12485. */
  12486. getClassName(): string;
  12487. /**
  12488. * Gets the intensity input component
  12489. */
  12490. get intensity(): NodeMaterialConnectionPoint;
  12491. /**
  12492. * Gets the tint at distance input component
  12493. */
  12494. get tintAtDistance(): NodeMaterialConnectionPoint;
  12495. /**
  12496. * Gets the view input component
  12497. */
  12498. get view(): NodeMaterialConnectionPoint;
  12499. /**
  12500. * Gets the refraction object output component
  12501. */
  12502. get refraction(): NodeMaterialConnectionPoint;
  12503. /**
  12504. * Returns true if the block has a texture
  12505. */
  12506. get hasTexture(): boolean;
  12507. protected _getTexture(): Nullable<BaseTexture>;
  12508. autoConfigure(material: NodeMaterial): void;
  12509. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12510. isReady(): boolean;
  12511. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  12512. /**
  12513. * Gets the main code of the block (fragment side)
  12514. * @param state current state of the node material building
  12515. * @returns the shader code
  12516. */
  12517. getCode(state: NodeMaterialBuildState): string;
  12518. protected _buildBlock(state: NodeMaterialBuildState): this;
  12519. protected _dumpPropertiesCode(): string;
  12520. serialize(): any;
  12521. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12522. }
  12523. }
  12524. declare module BABYLON {
  12525. /**
  12526. * Base block used as input for post process
  12527. */
  12528. export class CurrentScreenBlock extends NodeMaterialBlock {
  12529. private _samplerName;
  12530. private _linearDefineName;
  12531. private _gammaDefineName;
  12532. private _mainUVName;
  12533. private _tempTextureRead;
  12534. /**
  12535. * Gets or sets the texture associated with the node
  12536. */
  12537. texture: Nullable<BaseTexture>;
  12538. /**
  12539. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12540. */
  12541. convertToGammaSpace: boolean;
  12542. /**
  12543. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12544. */
  12545. convertToLinearSpace: boolean;
  12546. /**
  12547. * Create a new CurrentScreenBlock
  12548. * @param name defines the block name
  12549. */
  12550. constructor(name: string);
  12551. /**
  12552. * Gets the current class name
  12553. * @returns the class name
  12554. */
  12555. getClassName(): string;
  12556. /**
  12557. * Gets the uv input component
  12558. */
  12559. get uv(): NodeMaterialConnectionPoint;
  12560. /**
  12561. * Gets the rgba output component
  12562. */
  12563. get rgba(): NodeMaterialConnectionPoint;
  12564. /**
  12565. * Gets the rgb output component
  12566. */
  12567. get rgb(): NodeMaterialConnectionPoint;
  12568. /**
  12569. * Gets the r output component
  12570. */
  12571. get r(): NodeMaterialConnectionPoint;
  12572. /**
  12573. * Gets the g output component
  12574. */
  12575. get g(): NodeMaterialConnectionPoint;
  12576. /**
  12577. * Gets the b output component
  12578. */
  12579. get b(): NodeMaterialConnectionPoint;
  12580. /**
  12581. * Gets the a output component
  12582. */
  12583. get a(): NodeMaterialConnectionPoint;
  12584. /**
  12585. * Initialize the block and prepare the context for build
  12586. * @param state defines the state that will be used for the build
  12587. */
  12588. initialize(state: NodeMaterialBuildState): void;
  12589. get target(): NodeMaterialBlockTargets;
  12590. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12591. isReady(): boolean;
  12592. private _injectVertexCode;
  12593. private _writeTextureRead;
  12594. private _writeOutput;
  12595. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12596. serialize(): any;
  12597. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12598. }
  12599. }
  12600. declare module BABYLON {
  12601. /**
  12602. * Base block used for the particle texture
  12603. */
  12604. export class ParticleTextureBlock extends NodeMaterialBlock {
  12605. private _samplerName;
  12606. private _linearDefineName;
  12607. private _gammaDefineName;
  12608. private _tempTextureRead;
  12609. /**
  12610. * Gets or sets the texture associated with the node
  12611. */
  12612. texture: Nullable<BaseTexture>;
  12613. /**
  12614. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12615. */
  12616. convertToGammaSpace: boolean;
  12617. /**
  12618. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12619. */
  12620. convertToLinearSpace: boolean;
  12621. /**
  12622. * Create a new ParticleTextureBlock
  12623. * @param name defines the block name
  12624. */
  12625. constructor(name: string);
  12626. /**
  12627. * Gets the current class name
  12628. * @returns the class name
  12629. */
  12630. getClassName(): string;
  12631. /**
  12632. * Gets the uv input component
  12633. */
  12634. get uv(): NodeMaterialConnectionPoint;
  12635. /**
  12636. * Gets the rgba output component
  12637. */
  12638. get rgba(): NodeMaterialConnectionPoint;
  12639. /**
  12640. * Gets the rgb output component
  12641. */
  12642. get rgb(): NodeMaterialConnectionPoint;
  12643. /**
  12644. * Gets the r output component
  12645. */
  12646. get r(): NodeMaterialConnectionPoint;
  12647. /**
  12648. * Gets the g output component
  12649. */
  12650. get g(): NodeMaterialConnectionPoint;
  12651. /**
  12652. * Gets the b output component
  12653. */
  12654. get b(): NodeMaterialConnectionPoint;
  12655. /**
  12656. * Gets the a output component
  12657. */
  12658. get a(): NodeMaterialConnectionPoint;
  12659. /**
  12660. * Initialize the block and prepare the context for build
  12661. * @param state defines the state that will be used for the build
  12662. */
  12663. initialize(state: NodeMaterialBuildState): void;
  12664. autoConfigure(material: NodeMaterial): void;
  12665. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12666. isReady(): boolean;
  12667. private _writeOutput;
  12668. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12669. serialize(): any;
  12670. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12671. }
  12672. }
  12673. declare module BABYLON {
  12674. /**
  12675. * Class used to store shared data between 2 NodeMaterialBuildState
  12676. */
  12677. export class NodeMaterialBuildStateSharedData {
  12678. /**
  12679. * Gets the list of emitted varyings
  12680. */
  12681. temps: string[];
  12682. /**
  12683. * Gets the list of emitted varyings
  12684. */
  12685. varyings: string[];
  12686. /**
  12687. * Gets the varying declaration string
  12688. */
  12689. varyingDeclaration: string;
  12690. /**
  12691. * Input blocks
  12692. */
  12693. inputBlocks: InputBlock[];
  12694. /**
  12695. * Input blocks
  12696. */
  12697. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  12698. /**
  12699. * Bindable blocks (Blocks that need to set data to the effect)
  12700. */
  12701. bindableBlocks: NodeMaterialBlock[];
  12702. /**
  12703. * List of blocks that can provide a compilation fallback
  12704. */
  12705. blocksWithFallbacks: NodeMaterialBlock[];
  12706. /**
  12707. * List of blocks that can provide a define update
  12708. */
  12709. blocksWithDefines: NodeMaterialBlock[];
  12710. /**
  12711. * List of blocks that can provide a repeatable content
  12712. */
  12713. repeatableContentBlocks: NodeMaterialBlock[];
  12714. /**
  12715. * List of blocks that can provide a dynamic list of uniforms
  12716. */
  12717. dynamicUniformBlocks: NodeMaterialBlock[];
  12718. /**
  12719. * List of blocks that can block the isReady function for the material
  12720. */
  12721. blockingBlocks: NodeMaterialBlock[];
  12722. /**
  12723. * Gets the list of animated inputs
  12724. */
  12725. animatedInputs: InputBlock[];
  12726. /**
  12727. * Build Id used to avoid multiple recompilations
  12728. */
  12729. buildId: number;
  12730. /** List of emitted variables */
  12731. variableNames: {
  12732. [key: string]: number;
  12733. };
  12734. /** List of emitted defines */
  12735. defineNames: {
  12736. [key: string]: number;
  12737. };
  12738. /** Should emit comments? */
  12739. emitComments: boolean;
  12740. /** Emit build activity */
  12741. verbose: boolean;
  12742. /** Gets or sets the hosting scene */
  12743. scene: Scene;
  12744. /**
  12745. * Gets the compilation hints emitted at compilation time
  12746. */
  12747. hints: {
  12748. needWorldViewMatrix: boolean;
  12749. needWorldViewProjectionMatrix: boolean;
  12750. needAlphaBlending: boolean;
  12751. needAlphaTesting: boolean;
  12752. };
  12753. /**
  12754. * List of compilation checks
  12755. */
  12756. checks: {
  12757. emitVertex: boolean;
  12758. emitFragment: boolean;
  12759. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  12760. };
  12761. /**
  12762. * Is vertex program allowed to be empty?
  12763. */
  12764. allowEmptyVertexProgram: boolean;
  12765. /** Creates a new shared data */
  12766. constructor();
  12767. /**
  12768. * Emits console errors and exceptions if there is a failing check
  12769. */
  12770. emitErrors(): void;
  12771. }
  12772. }
  12773. declare module BABYLON {
  12774. /**
  12775. * Class used to store node based material build state
  12776. */
  12777. export class NodeMaterialBuildState {
  12778. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  12779. supportUniformBuffers: boolean;
  12780. /**
  12781. * Gets the list of emitted attributes
  12782. */
  12783. attributes: string[];
  12784. /**
  12785. * Gets the list of emitted uniforms
  12786. */
  12787. uniforms: string[];
  12788. /**
  12789. * Gets the list of emitted constants
  12790. */
  12791. constants: string[];
  12792. /**
  12793. * Gets the list of emitted samplers
  12794. */
  12795. samplers: string[];
  12796. /**
  12797. * Gets the list of emitted functions
  12798. */
  12799. functions: {
  12800. [key: string]: string;
  12801. };
  12802. /**
  12803. * Gets the list of emitted extensions
  12804. */
  12805. extensions: {
  12806. [key: string]: string;
  12807. };
  12808. /**
  12809. * Gets the target of the compilation state
  12810. */
  12811. target: NodeMaterialBlockTargets;
  12812. /**
  12813. * Gets the list of emitted counters
  12814. */
  12815. counters: {
  12816. [key: string]: number;
  12817. };
  12818. /**
  12819. * Shared data between multiple NodeMaterialBuildState instances
  12820. */
  12821. sharedData: NodeMaterialBuildStateSharedData;
  12822. /** @hidden */
  12823. _vertexState: NodeMaterialBuildState;
  12824. /** @hidden */
  12825. _attributeDeclaration: string;
  12826. /** @hidden */
  12827. _uniformDeclaration: string;
  12828. /** @hidden */
  12829. _constantDeclaration: string;
  12830. /** @hidden */
  12831. _samplerDeclaration: string;
  12832. /** @hidden */
  12833. _varyingTransfer: string;
  12834. /** @hidden */
  12835. _injectAtEnd: string;
  12836. private _repeatableContentAnchorIndex;
  12837. /** @hidden */
  12838. _builtCompilationString: string;
  12839. /**
  12840. * Gets the emitted compilation strings
  12841. */
  12842. compilationString: string;
  12843. /**
  12844. * Finalize the compilation strings
  12845. * @param state defines the current compilation state
  12846. */
  12847. finalize(state: NodeMaterialBuildState): void;
  12848. /** @hidden */
  12849. get _repeatableContentAnchor(): string;
  12850. /** @hidden */
  12851. _getFreeVariableName(prefix: string): string;
  12852. /** @hidden */
  12853. _getFreeDefineName(prefix: string): string;
  12854. /** @hidden */
  12855. _excludeVariableName(name: string): void;
  12856. /** @hidden */
  12857. _emit2DSampler(name: string): void;
  12858. /** @hidden */
  12859. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  12860. /** @hidden */
  12861. _emitExtension(name: string, extension: string, define?: string): void;
  12862. /** @hidden */
  12863. _emitFunction(name: string, code: string, comments: string): void;
  12864. /** @hidden */
  12865. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  12866. replaceStrings?: {
  12867. search: RegExp;
  12868. replace: string;
  12869. }[];
  12870. repeatKey?: string;
  12871. }): string;
  12872. /** @hidden */
  12873. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  12874. repeatKey?: string;
  12875. removeAttributes?: boolean;
  12876. removeUniforms?: boolean;
  12877. removeVaryings?: boolean;
  12878. removeIfDef?: boolean;
  12879. replaceStrings?: {
  12880. search: RegExp;
  12881. replace: string;
  12882. }[];
  12883. }, storeKey?: string): void;
  12884. /** @hidden */
  12885. _registerTempVariable(name: string): boolean;
  12886. /** @hidden */
  12887. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  12888. /** @hidden */
  12889. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  12890. /** @hidden */
  12891. _emitFloat(value: number): string;
  12892. }
  12893. }
  12894. declare module BABYLON {
  12895. /**
  12896. * Helper class used to generate session unique ID
  12897. */
  12898. export class UniqueIdGenerator {
  12899. private static _UniqueIdCounter;
  12900. /**
  12901. * Gets an unique (relatively to the current scene) Id
  12902. */
  12903. static get UniqueId(): number;
  12904. }
  12905. }
  12906. declare module BABYLON {
  12907. /**
  12908. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12909. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12910. */
  12911. export class EffectFallbacks implements IEffectFallbacks {
  12912. private _defines;
  12913. private _currentRank;
  12914. private _maxRank;
  12915. private _mesh;
  12916. /**
  12917. * Removes the fallback from the bound mesh.
  12918. */
  12919. unBindMesh(): void;
  12920. /**
  12921. * Adds a fallback on the specified property.
  12922. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12923. * @param define The name of the define in the shader
  12924. */
  12925. addFallback(rank: number, define: string): void;
  12926. /**
  12927. * Sets the mesh to use CPU skinning when needing to fallback.
  12928. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12929. * @param mesh The mesh to use the fallbacks.
  12930. */
  12931. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12932. /**
  12933. * Checks to see if more fallbacks are still availible.
  12934. */
  12935. get hasMoreFallbacks(): boolean;
  12936. /**
  12937. * Removes the defines that should be removed when falling back.
  12938. * @param currentDefines defines the current define statements for the shader.
  12939. * @param effect defines the current effect we try to compile
  12940. * @returns The resulting defines with defines of the current rank removed.
  12941. */
  12942. reduce(currentDefines: string, effect: Effect): string;
  12943. }
  12944. }
  12945. declare module BABYLON {
  12946. /**
  12947. * Defines a block that can be used inside a node based material
  12948. */
  12949. export class NodeMaterialBlock {
  12950. private _buildId;
  12951. private _buildTarget;
  12952. private _target;
  12953. private _isFinalMerger;
  12954. private _isInput;
  12955. private _name;
  12956. protected _isUnique: boolean;
  12957. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  12958. inputsAreExclusive: boolean;
  12959. /** @hidden */
  12960. _codeVariableName: string;
  12961. /** @hidden */
  12962. _inputs: NodeMaterialConnectionPoint[];
  12963. /** @hidden */
  12964. _outputs: NodeMaterialConnectionPoint[];
  12965. /** @hidden */
  12966. _preparationId: number;
  12967. /**
  12968. * Gets the name of the block
  12969. */
  12970. get name(): string;
  12971. /**
  12972. * Sets the name of the block. Will check if the name is valid.
  12973. */
  12974. set name(newName: string);
  12975. /**
  12976. * Gets or sets the unique id of the node
  12977. */
  12978. uniqueId: number;
  12979. /**
  12980. * Gets or sets the comments associated with this block
  12981. */
  12982. comments: string;
  12983. /**
  12984. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  12985. */
  12986. get isUnique(): boolean;
  12987. /**
  12988. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  12989. */
  12990. get isFinalMerger(): boolean;
  12991. /**
  12992. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  12993. */
  12994. get isInput(): boolean;
  12995. /**
  12996. * Gets or sets the build Id
  12997. */
  12998. get buildId(): number;
  12999. set buildId(value: number);
  13000. /**
  13001. * Gets or sets the target of the block
  13002. */
  13003. get target(): NodeMaterialBlockTargets;
  13004. set target(value: NodeMaterialBlockTargets);
  13005. /**
  13006. * Gets the list of input points
  13007. */
  13008. get inputs(): NodeMaterialConnectionPoint[];
  13009. /** Gets the list of output points */
  13010. get outputs(): NodeMaterialConnectionPoint[];
  13011. /**
  13012. * Find an input by its name
  13013. * @param name defines the name of the input to look for
  13014. * @returns the input or null if not found
  13015. */
  13016. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13017. /**
  13018. * Find an output by its name
  13019. * @param name defines the name of the outputto look for
  13020. * @returns the output or null if not found
  13021. */
  13022. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13023. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13024. visibleInInspector: boolean;
  13025. /**
  13026. * Creates a new NodeMaterialBlock
  13027. * @param name defines the block name
  13028. * @param target defines the target of that block (Vertex by default)
  13029. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13030. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13031. */
  13032. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13033. /**
  13034. * Initialize the block and prepare the context for build
  13035. * @param state defines the state that will be used for the build
  13036. */
  13037. initialize(state: NodeMaterialBuildState): void;
  13038. /**
  13039. * Bind data to effect. Will only be called for blocks with isBindable === true
  13040. * @param effect defines the effect to bind data to
  13041. * @param nodeMaterial defines the hosting NodeMaterial
  13042. * @param mesh defines the mesh that will be rendered
  13043. * @param subMesh defines the submesh that will be rendered
  13044. */
  13045. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13046. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13047. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13048. protected _writeFloat(value: number): string;
  13049. /**
  13050. * Gets the current class name e.g. "NodeMaterialBlock"
  13051. * @returns the class name
  13052. */
  13053. getClassName(): string;
  13054. /**
  13055. * Register a new input. Must be called inside a block constructor
  13056. * @param name defines the connection point name
  13057. * @param type defines the connection point type
  13058. * @param isOptional defines a boolean indicating that this input can be omitted
  13059. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13060. * @param point an already created connection point. If not provided, create a new one
  13061. * @returns the current block
  13062. */
  13063. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13064. /**
  13065. * Register a new output. Must be called inside a block constructor
  13066. * @param name defines the connection point name
  13067. * @param type defines the connection point type
  13068. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13069. * @param point an already created connection point. If not provided, create a new one
  13070. * @returns the current block
  13071. */
  13072. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13073. /**
  13074. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13075. * @param forOutput defines an optional connection point to check compatibility with
  13076. * @returns the first available input or null
  13077. */
  13078. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13079. /**
  13080. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13081. * @param forBlock defines an optional block to check compatibility with
  13082. * @returns the first available input or null
  13083. */
  13084. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13085. /**
  13086. * Gets the sibling of the given output
  13087. * @param current defines the current output
  13088. * @returns the next output in the list or null
  13089. */
  13090. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13091. /**
  13092. * Connect current block with another block
  13093. * @param other defines the block to connect with
  13094. * @param options define the various options to help pick the right connections
  13095. * @returns the current block
  13096. */
  13097. connectTo(other: NodeMaterialBlock, options?: {
  13098. input?: string;
  13099. output?: string;
  13100. outputSwizzle?: string;
  13101. }): this | undefined;
  13102. protected _buildBlock(state: NodeMaterialBuildState): void;
  13103. /**
  13104. * Add uniforms, samplers and uniform buffers at compilation time
  13105. * @param state defines the state to update
  13106. * @param nodeMaterial defines the node material requesting the update
  13107. * @param defines defines the material defines to update
  13108. * @param uniformBuffers defines the list of uniform buffer names
  13109. */
  13110. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13111. /**
  13112. * Add potential fallbacks if shader compilation fails
  13113. * @param mesh defines the mesh to be rendered
  13114. * @param fallbacks defines the current prioritized list of fallbacks
  13115. */
  13116. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13117. /**
  13118. * Initialize defines for shader compilation
  13119. * @param mesh defines the mesh to be rendered
  13120. * @param nodeMaterial defines the node material requesting the update
  13121. * @param defines defines the material defines to update
  13122. * @param useInstances specifies that instances should be used
  13123. */
  13124. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13125. /**
  13126. * Update defines for shader compilation
  13127. * @param mesh defines the mesh to be rendered
  13128. * @param nodeMaterial defines the node material requesting the update
  13129. * @param defines defines the material defines to update
  13130. * @param useInstances specifies that instances should be used
  13131. * @param subMesh defines which submesh to render
  13132. */
  13133. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13134. /**
  13135. * Lets the block try to connect some inputs automatically
  13136. * @param material defines the hosting NodeMaterial
  13137. */
  13138. autoConfigure(material: NodeMaterial): void;
  13139. /**
  13140. * Function called when a block is declared as repeatable content generator
  13141. * @param vertexShaderState defines the current compilation state for the vertex shader
  13142. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13143. * @param mesh defines the mesh to be rendered
  13144. * @param defines defines the material defines to update
  13145. */
  13146. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13147. /**
  13148. * Checks if the block is ready
  13149. * @param mesh defines the mesh to be rendered
  13150. * @param nodeMaterial defines the node material requesting the update
  13151. * @param defines defines the material defines to update
  13152. * @param useInstances specifies that instances should be used
  13153. * @returns true if the block is ready
  13154. */
  13155. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13156. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13157. private _processBuild;
  13158. /**
  13159. * Validates the new name for the block node.
  13160. * @param newName the new name to be given to the node.
  13161. * @returns false if the name is a reserve word, else true.
  13162. */
  13163. validateBlockName(newName: string): boolean;
  13164. /**
  13165. * Compile the current node and generate the shader code
  13166. * @param state defines the current compilation state (uniforms, samplers, current string)
  13167. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13168. * @returns true if already built
  13169. */
  13170. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13171. protected _inputRename(name: string): string;
  13172. protected _outputRename(name: string): string;
  13173. protected _dumpPropertiesCode(): string;
  13174. /** @hidden */
  13175. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13176. /** @hidden */
  13177. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13178. /**
  13179. * Clone the current block to a new identical block
  13180. * @param scene defines the hosting scene
  13181. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13182. * @returns a copy of the current block
  13183. */
  13184. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13185. /**
  13186. * Serializes this block in a JSON representation
  13187. * @returns the serialized block object
  13188. */
  13189. serialize(): any;
  13190. /** @hidden */
  13191. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13192. private _deserializePortDisplayNamesAndExposedOnFrame;
  13193. /**
  13194. * Release resources
  13195. */
  13196. dispose(): void;
  13197. }
  13198. }
  13199. declare module BABYLON {
  13200. /**
  13201. * Base class of materials working in push mode in babylon JS
  13202. * @hidden
  13203. */
  13204. export class PushMaterial extends Material {
  13205. protected _activeEffect: Effect;
  13206. protected _normalMatrix: Matrix;
  13207. constructor(name: string, scene: Scene);
  13208. getEffect(): Effect;
  13209. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13210. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13211. /**
  13212. * Binds the given world matrix to the active effect
  13213. *
  13214. * @param world the matrix to bind
  13215. */
  13216. bindOnlyWorldMatrix(world: Matrix): void;
  13217. /**
  13218. * Binds the given normal matrix to the active effect
  13219. *
  13220. * @param normalMatrix the matrix to bind
  13221. */
  13222. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13223. bind(world: Matrix, mesh?: Mesh): void;
  13224. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13225. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13226. }
  13227. }
  13228. declare module BABYLON {
  13229. /**
  13230. * Root class for all node material optimizers
  13231. */
  13232. export class NodeMaterialOptimizer {
  13233. /**
  13234. * Function used to optimize a NodeMaterial graph
  13235. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13236. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13237. */
  13238. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13239. }
  13240. }
  13241. declare module BABYLON {
  13242. /**
  13243. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13244. */
  13245. export class TransformBlock extends NodeMaterialBlock {
  13246. /**
  13247. * Defines the value to use to complement W value to transform it to a Vector4
  13248. */
  13249. complementW: number;
  13250. /**
  13251. * Defines the value to use to complement z value to transform it to a Vector4
  13252. */
  13253. complementZ: number;
  13254. /**
  13255. * Creates a new TransformBlock
  13256. * @param name defines the block name
  13257. */
  13258. constructor(name: string);
  13259. /**
  13260. * Gets the current class name
  13261. * @returns the class name
  13262. */
  13263. getClassName(): string;
  13264. /**
  13265. * Gets the vector input
  13266. */
  13267. get vector(): NodeMaterialConnectionPoint;
  13268. /**
  13269. * Gets the output component
  13270. */
  13271. get output(): NodeMaterialConnectionPoint;
  13272. /**
  13273. * Gets the xyz output component
  13274. */
  13275. get xyz(): NodeMaterialConnectionPoint;
  13276. /**
  13277. * Gets the matrix transform input
  13278. */
  13279. get transform(): NodeMaterialConnectionPoint;
  13280. protected _buildBlock(state: NodeMaterialBuildState): this;
  13281. /**
  13282. * Update defines for shader compilation
  13283. * @param mesh defines the mesh to be rendered
  13284. * @param nodeMaterial defines the node material requesting the update
  13285. * @param defines defines the material defines to update
  13286. * @param useInstances specifies that instances should be used
  13287. * @param subMesh defines which submesh to render
  13288. */
  13289. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13290. serialize(): any;
  13291. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13292. protected _dumpPropertiesCode(): string;
  13293. }
  13294. }
  13295. declare module BABYLON {
  13296. /**
  13297. * Block used to output the vertex position
  13298. */
  13299. export class VertexOutputBlock extends NodeMaterialBlock {
  13300. /**
  13301. * Creates a new VertexOutputBlock
  13302. * @param name defines the block name
  13303. */
  13304. constructor(name: string);
  13305. /**
  13306. * Gets the current class name
  13307. * @returns the class name
  13308. */
  13309. getClassName(): string;
  13310. /**
  13311. * Gets the vector input component
  13312. */
  13313. get vector(): NodeMaterialConnectionPoint;
  13314. protected _buildBlock(state: NodeMaterialBuildState): this;
  13315. }
  13316. }
  13317. declare module BABYLON {
  13318. /**
  13319. * Block used to output the final color
  13320. */
  13321. export class FragmentOutputBlock extends NodeMaterialBlock {
  13322. /**
  13323. * Create a new FragmentOutputBlock
  13324. * @param name defines the block name
  13325. */
  13326. constructor(name: string);
  13327. /**
  13328. * Gets the current class name
  13329. * @returns the class name
  13330. */
  13331. getClassName(): string;
  13332. /**
  13333. * Gets the rgba input component
  13334. */
  13335. get rgba(): NodeMaterialConnectionPoint;
  13336. /**
  13337. * Gets the rgb input component
  13338. */
  13339. get rgb(): NodeMaterialConnectionPoint;
  13340. /**
  13341. * Gets the a input component
  13342. */
  13343. get a(): NodeMaterialConnectionPoint;
  13344. protected _buildBlock(state: NodeMaterialBuildState): this;
  13345. }
  13346. }
  13347. declare module BABYLON {
  13348. /**
  13349. * Block used for the particle ramp gradient section
  13350. */
  13351. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13352. /**
  13353. * Create a new ParticleRampGradientBlock
  13354. * @param name defines the block name
  13355. */
  13356. constructor(name: string);
  13357. /**
  13358. * Gets the current class name
  13359. * @returns the class name
  13360. */
  13361. getClassName(): string;
  13362. /**
  13363. * Gets the color input component
  13364. */
  13365. get color(): NodeMaterialConnectionPoint;
  13366. /**
  13367. * Gets the rampColor output component
  13368. */
  13369. get rampColor(): NodeMaterialConnectionPoint;
  13370. /**
  13371. * Initialize the block and prepare the context for build
  13372. * @param state defines the state that will be used for the build
  13373. */
  13374. initialize(state: NodeMaterialBuildState): void;
  13375. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13376. }
  13377. }
  13378. declare module BABYLON {
  13379. /**
  13380. * Block used for the particle blend multiply section
  13381. */
  13382. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13383. /**
  13384. * Create a new ParticleBlendMultiplyBlock
  13385. * @param name defines the block name
  13386. */
  13387. constructor(name: string);
  13388. /**
  13389. * Gets the current class name
  13390. * @returns the class name
  13391. */
  13392. getClassName(): string;
  13393. /**
  13394. * Gets the color input component
  13395. */
  13396. get color(): NodeMaterialConnectionPoint;
  13397. /**
  13398. * Gets the alphaTexture input component
  13399. */
  13400. get alphaTexture(): NodeMaterialConnectionPoint;
  13401. /**
  13402. * Gets the alphaColor input component
  13403. */
  13404. get alphaColor(): NodeMaterialConnectionPoint;
  13405. /**
  13406. * Gets the blendColor output component
  13407. */
  13408. get blendColor(): NodeMaterialConnectionPoint;
  13409. /**
  13410. * Initialize the block and prepare the context for build
  13411. * @param state defines the state that will be used for the build
  13412. */
  13413. initialize(state: NodeMaterialBuildState): void;
  13414. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13415. }
  13416. }
  13417. declare module BABYLON {
  13418. /**
  13419. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  13420. */
  13421. export class VectorMergerBlock extends NodeMaterialBlock {
  13422. /**
  13423. * Create a new VectorMergerBlock
  13424. * @param name defines the block name
  13425. */
  13426. constructor(name: string);
  13427. /**
  13428. * Gets the current class name
  13429. * @returns the class name
  13430. */
  13431. getClassName(): string;
  13432. /**
  13433. * Gets the xyz component (input)
  13434. */
  13435. get xyzIn(): NodeMaterialConnectionPoint;
  13436. /**
  13437. * Gets the xy component (input)
  13438. */
  13439. get xyIn(): NodeMaterialConnectionPoint;
  13440. /**
  13441. * Gets the x component (input)
  13442. */
  13443. get x(): NodeMaterialConnectionPoint;
  13444. /**
  13445. * Gets the y component (input)
  13446. */
  13447. get y(): NodeMaterialConnectionPoint;
  13448. /**
  13449. * Gets the z component (input)
  13450. */
  13451. get z(): NodeMaterialConnectionPoint;
  13452. /**
  13453. * Gets the w component (input)
  13454. */
  13455. get w(): NodeMaterialConnectionPoint;
  13456. /**
  13457. * Gets the xyzw component (output)
  13458. */
  13459. get xyzw(): NodeMaterialConnectionPoint;
  13460. /**
  13461. * Gets the xyz component (output)
  13462. */
  13463. get xyzOut(): NodeMaterialConnectionPoint;
  13464. /**
  13465. * Gets the xy component (output)
  13466. */
  13467. get xyOut(): NodeMaterialConnectionPoint;
  13468. /**
  13469. * Gets the xy component (output)
  13470. * @deprecated Please use xyOut instead.
  13471. */
  13472. get xy(): NodeMaterialConnectionPoint;
  13473. /**
  13474. * Gets the xyz component (output)
  13475. * @deprecated Please use xyzOut instead.
  13476. */
  13477. get xyz(): NodeMaterialConnectionPoint;
  13478. protected _buildBlock(state: NodeMaterialBuildState): this;
  13479. }
  13480. }
  13481. declare module BABYLON {
  13482. /**
  13483. * Block used to remap a float from a range to a new one
  13484. */
  13485. export class RemapBlock extends NodeMaterialBlock {
  13486. /**
  13487. * Gets or sets the source range
  13488. */
  13489. sourceRange: Vector2;
  13490. /**
  13491. * Gets or sets the target range
  13492. */
  13493. targetRange: Vector2;
  13494. /**
  13495. * Creates a new RemapBlock
  13496. * @param name defines the block name
  13497. */
  13498. constructor(name: string);
  13499. /**
  13500. * Gets the current class name
  13501. * @returns the class name
  13502. */
  13503. getClassName(): string;
  13504. /**
  13505. * Gets the input component
  13506. */
  13507. get input(): NodeMaterialConnectionPoint;
  13508. /**
  13509. * Gets the source min input component
  13510. */
  13511. get sourceMin(): NodeMaterialConnectionPoint;
  13512. /**
  13513. * Gets the source max input component
  13514. */
  13515. get sourceMax(): NodeMaterialConnectionPoint;
  13516. /**
  13517. * Gets the target min input component
  13518. */
  13519. get targetMin(): NodeMaterialConnectionPoint;
  13520. /**
  13521. * Gets the target max input component
  13522. */
  13523. get targetMax(): NodeMaterialConnectionPoint;
  13524. /**
  13525. * Gets the output component
  13526. */
  13527. get output(): NodeMaterialConnectionPoint;
  13528. protected _buildBlock(state: NodeMaterialBuildState): this;
  13529. protected _dumpPropertiesCode(): string;
  13530. serialize(): any;
  13531. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13532. }
  13533. }
  13534. declare module BABYLON {
  13535. /**
  13536. * Block used to multiply 2 values
  13537. */
  13538. export class MultiplyBlock extends NodeMaterialBlock {
  13539. /**
  13540. * Creates a new MultiplyBlock
  13541. * @param name defines the block name
  13542. */
  13543. constructor(name: string);
  13544. /**
  13545. * Gets the current class name
  13546. * @returns the class name
  13547. */
  13548. getClassName(): string;
  13549. /**
  13550. * Gets the left operand input component
  13551. */
  13552. get left(): NodeMaterialConnectionPoint;
  13553. /**
  13554. * Gets the right operand input component
  13555. */
  13556. get right(): NodeMaterialConnectionPoint;
  13557. /**
  13558. * Gets the output component
  13559. */
  13560. get output(): NodeMaterialConnectionPoint;
  13561. protected _buildBlock(state: NodeMaterialBuildState): this;
  13562. }
  13563. }
  13564. declare module BABYLON {
  13565. /** Interface used by value gradients (color, factor, ...) */
  13566. export interface IValueGradient {
  13567. /**
  13568. * Gets or sets the gradient value (between 0 and 1)
  13569. */
  13570. gradient: number;
  13571. }
  13572. /** Class used to store color4 gradient */
  13573. export class ColorGradient implements IValueGradient {
  13574. /**
  13575. * Gets or sets the gradient value (between 0 and 1)
  13576. */
  13577. gradient: number;
  13578. /**
  13579. * Gets or sets first associated color
  13580. */
  13581. color1: Color4;
  13582. /**
  13583. * Gets or sets second associated color
  13584. */
  13585. color2?: Color4 | undefined;
  13586. /**
  13587. * Creates a new color4 gradient
  13588. * @param gradient gets or sets the gradient value (between 0 and 1)
  13589. * @param color1 gets or sets first associated color
  13590. * @param color2 gets or sets first second color
  13591. */
  13592. constructor(
  13593. /**
  13594. * Gets or sets the gradient value (between 0 and 1)
  13595. */
  13596. gradient: number,
  13597. /**
  13598. * Gets or sets first associated color
  13599. */
  13600. color1: Color4,
  13601. /**
  13602. * Gets or sets second associated color
  13603. */
  13604. color2?: Color4 | undefined);
  13605. /**
  13606. * Will get a color picked randomly between color1 and color2.
  13607. * If color2 is undefined then color1 will be used
  13608. * @param result defines the target Color4 to store the result in
  13609. */
  13610. getColorToRef(result: Color4): void;
  13611. }
  13612. /** Class used to store color 3 gradient */
  13613. export class Color3Gradient implements IValueGradient {
  13614. /**
  13615. * Gets or sets the gradient value (between 0 and 1)
  13616. */
  13617. gradient: number;
  13618. /**
  13619. * Gets or sets the associated color
  13620. */
  13621. color: Color3;
  13622. /**
  13623. * Creates a new color3 gradient
  13624. * @param gradient gets or sets the gradient value (between 0 and 1)
  13625. * @param color gets or sets associated color
  13626. */
  13627. constructor(
  13628. /**
  13629. * Gets or sets the gradient value (between 0 and 1)
  13630. */
  13631. gradient: number,
  13632. /**
  13633. * Gets or sets the associated color
  13634. */
  13635. color: Color3);
  13636. }
  13637. /** Class used to store factor gradient */
  13638. export class FactorGradient implements IValueGradient {
  13639. /**
  13640. * Gets or sets the gradient value (between 0 and 1)
  13641. */
  13642. gradient: number;
  13643. /**
  13644. * Gets or sets first associated factor
  13645. */
  13646. factor1: number;
  13647. /**
  13648. * Gets or sets second associated factor
  13649. */
  13650. factor2?: number | undefined;
  13651. /**
  13652. * Creates a new factor gradient
  13653. * @param gradient gets or sets the gradient value (between 0 and 1)
  13654. * @param factor1 gets or sets first associated factor
  13655. * @param factor2 gets or sets second associated factor
  13656. */
  13657. constructor(
  13658. /**
  13659. * Gets or sets the gradient value (between 0 and 1)
  13660. */
  13661. gradient: number,
  13662. /**
  13663. * Gets or sets first associated factor
  13664. */
  13665. factor1: number,
  13666. /**
  13667. * Gets or sets second associated factor
  13668. */
  13669. factor2?: number | undefined);
  13670. /**
  13671. * Will get a number picked randomly between factor1 and factor2.
  13672. * If factor2 is undefined then factor1 will be used
  13673. * @returns the picked number
  13674. */
  13675. getFactor(): number;
  13676. }
  13677. /**
  13678. * Helper used to simplify some generic gradient tasks
  13679. */
  13680. export class GradientHelper {
  13681. /**
  13682. * Gets the current gradient from an array of IValueGradient
  13683. * @param ratio defines the current ratio to get
  13684. * @param gradients defines the array of IValueGradient
  13685. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  13686. */
  13687. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  13688. }
  13689. }
  13690. declare module BABYLON {
  13691. interface ThinEngine {
  13692. /**
  13693. * Creates a raw texture
  13694. * @param data defines the data to store in the texture
  13695. * @param width defines the width of the texture
  13696. * @param height defines the height of the texture
  13697. * @param format defines the format of the data
  13698. * @param generateMipMaps defines if the engine should generate the mip levels
  13699. * @param invertY defines if data must be stored with Y axis inverted
  13700. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  13701. * @param compression defines the compression used (null by default)
  13702. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13703. * @returns the raw texture inside an InternalTexture
  13704. */
  13705. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  13706. /**
  13707. * Update a raw texture
  13708. * @param texture defines the texture to update
  13709. * @param data defines the data to store in the texture
  13710. * @param format defines the format of the data
  13711. * @param invertY defines if data must be stored with Y axis inverted
  13712. */
  13713. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13714. /**
  13715. * Update a raw texture
  13716. * @param texture defines the texture to update
  13717. * @param data defines the data to store in the texture
  13718. * @param format defines the format of the data
  13719. * @param invertY defines if data must be stored with Y axis inverted
  13720. * @param compression defines the compression used (null by default)
  13721. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13722. */
  13723. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  13724. /**
  13725. * Creates a new raw cube texture
  13726. * @param data defines the array of data to use to create each face
  13727. * @param size defines the size of the textures
  13728. * @param format defines the format of the data
  13729. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13730. * @param generateMipMaps defines if the engine should generate the mip levels
  13731. * @param invertY defines if data must be stored with Y axis inverted
  13732. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13733. * @param compression defines the compression used (null by default)
  13734. * @returns the cube texture as an InternalTexture
  13735. */
  13736. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  13737. /**
  13738. * Update a raw cube texture
  13739. * @param texture defines the texture to udpdate
  13740. * @param data defines the data to store
  13741. * @param format defines the data format
  13742. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13743. * @param invertY defines if data must be stored with Y axis inverted
  13744. */
  13745. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  13746. /**
  13747. * Update a raw cube texture
  13748. * @param texture defines the texture to udpdate
  13749. * @param data defines the data to store
  13750. * @param format defines the data format
  13751. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13752. * @param invertY defines if data must be stored with Y axis inverted
  13753. * @param compression defines the compression used (null by default)
  13754. */
  13755. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  13756. /**
  13757. * Update a raw cube texture
  13758. * @param texture defines the texture to udpdate
  13759. * @param data defines the data to store
  13760. * @param format defines the data format
  13761. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13762. * @param invertY defines if data must be stored with Y axis inverted
  13763. * @param compression defines the compression used (null by default)
  13764. * @param level defines which level of the texture to update
  13765. */
  13766. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  13767. /**
  13768. * Creates a new raw cube texture from a specified url
  13769. * @param url defines the url where the data is located
  13770. * @param scene defines the current scene
  13771. * @param size defines the size of the textures
  13772. * @param format defines the format of the data
  13773. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13774. * @param noMipmap defines if the engine should avoid generating the mip levels
  13775. * @param callback defines a callback used to extract texture data from loaded data
  13776. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13777. * @param onLoad defines a callback called when texture is loaded
  13778. * @param onError defines a callback called if there is an error
  13779. * @returns the cube texture as an InternalTexture
  13780. */
  13781. 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;
  13782. /**
  13783. * Creates a new raw cube texture from a specified url
  13784. * @param url defines the url where the data is located
  13785. * @param scene defines the current scene
  13786. * @param size defines the size of the textures
  13787. * @param format defines the format of the data
  13788. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13789. * @param noMipmap defines if the engine should avoid generating the mip levels
  13790. * @param callback defines a callback used to extract texture data from loaded data
  13791. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13792. * @param onLoad defines a callback called when texture is loaded
  13793. * @param onError defines a callback called if there is an error
  13794. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13795. * @param invertY defines if data must be stored with Y axis inverted
  13796. * @returns the cube texture as an InternalTexture
  13797. */
  13798. 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;
  13799. /**
  13800. * Creates a new raw 3D texture
  13801. * @param data defines the data used to create the texture
  13802. * @param width defines the width of the texture
  13803. * @param height defines the height of the texture
  13804. * @param depth defines the depth of the texture
  13805. * @param format defines the format of the texture
  13806. * @param generateMipMaps defines if the engine must generate mip levels
  13807. * @param invertY defines if data must be stored with Y axis inverted
  13808. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13809. * @param compression defines the compressed used (can be null)
  13810. * @param textureType defines the compressed used (can be null)
  13811. * @returns a new raw 3D texture (stored in an InternalTexture)
  13812. */
  13813. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13814. /**
  13815. * Update a raw 3D texture
  13816. * @param texture defines the texture to update
  13817. * @param data defines the data to store
  13818. * @param format defines the data format
  13819. * @param invertY defines if data must be stored with Y axis inverted
  13820. */
  13821. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13822. /**
  13823. * Update a raw 3D texture
  13824. * @param texture defines the texture to update
  13825. * @param data defines the data to store
  13826. * @param format defines the data format
  13827. * @param invertY defines if data must be stored with Y axis inverted
  13828. * @param compression defines the used compression (can be null)
  13829. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13830. */
  13831. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13832. /**
  13833. * Creates a new raw 2D array texture
  13834. * @param data defines the data used to create the texture
  13835. * @param width defines the width of the texture
  13836. * @param height defines the height of the texture
  13837. * @param depth defines the number of layers of the texture
  13838. * @param format defines the format of the texture
  13839. * @param generateMipMaps defines if the engine must generate mip levels
  13840. * @param invertY defines if data must be stored with Y axis inverted
  13841. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13842. * @param compression defines the compressed used (can be null)
  13843. * @param textureType defines the compressed used (can be null)
  13844. * @returns a new raw 2D array texture (stored in an InternalTexture)
  13845. */
  13846. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13847. /**
  13848. * Update a raw 2D array texture
  13849. * @param texture defines the texture to update
  13850. * @param data defines the data to store
  13851. * @param format defines the data format
  13852. * @param invertY defines if data must be stored with Y axis inverted
  13853. */
  13854. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13855. /**
  13856. * Update a raw 2D array texture
  13857. * @param texture defines the texture to update
  13858. * @param data defines the data to store
  13859. * @param format defines the data format
  13860. * @param invertY defines if data must be stored with Y axis inverted
  13861. * @param compression defines the used compression (can be null)
  13862. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13863. */
  13864. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13865. }
  13866. }
  13867. declare module BABYLON {
  13868. /**
  13869. * Raw texture can help creating a texture directly from an array of data.
  13870. * This can be super useful if you either get the data from an uncompressed source or
  13871. * if you wish to create your texture pixel by pixel.
  13872. */
  13873. export class RawTexture extends Texture {
  13874. /**
  13875. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13876. */
  13877. format: number;
  13878. /**
  13879. * Instantiates a new RawTexture.
  13880. * Raw texture can help creating a texture directly from an array of data.
  13881. * This can be super useful if you either get the data from an uncompressed source or
  13882. * if you wish to create your texture pixel by pixel.
  13883. * @param data define the array of data to use to create the texture
  13884. * @param width define the width of the texture
  13885. * @param height define the height of the texture
  13886. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13887. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13888. * @param generateMipMaps define whether mip maps should be generated or not
  13889. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13890. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13891. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13892. */
  13893. constructor(data: ArrayBufferView, width: number, height: number,
  13894. /**
  13895. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13896. */
  13897. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13898. /**
  13899. * Updates the texture underlying data.
  13900. * @param data Define the new data of the texture
  13901. */
  13902. update(data: ArrayBufferView): void;
  13903. /**
  13904. * Creates a luminance texture from some data.
  13905. * @param data Define the texture data
  13906. * @param width Define the width of the texture
  13907. * @param height Define the height of the texture
  13908. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13909. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13910. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13911. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13912. * @returns the luminance texture
  13913. */
  13914. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13915. /**
  13916. * Creates a luminance alpha texture from some data.
  13917. * @param data Define the texture data
  13918. * @param width Define the width of the texture
  13919. * @param height Define the height of the texture
  13920. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13921. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13922. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13923. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13924. * @returns the luminance alpha texture
  13925. */
  13926. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13927. /**
  13928. * Creates an alpha texture from some data.
  13929. * @param data Define the texture data
  13930. * @param width Define the width of the texture
  13931. * @param height Define the height of the texture
  13932. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13933. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13934. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13935. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13936. * @returns the alpha texture
  13937. */
  13938. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13939. /**
  13940. * Creates a RGB texture from some data.
  13941. * @param data Define the texture data
  13942. * @param width Define the width of the texture
  13943. * @param height Define the height of the texture
  13944. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13945. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13946. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13947. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13948. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13949. * @returns the RGB alpha texture
  13950. */
  13951. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13952. /**
  13953. * Creates a RGBA texture from some data.
  13954. * @param data Define the texture data
  13955. * @param width Define the width of the texture
  13956. * @param height Define the height of the texture
  13957. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13958. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13959. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13960. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13961. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13962. * @returns the RGBA texture
  13963. */
  13964. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13965. /**
  13966. * Creates a R texture from some data.
  13967. * @param data Define the texture data
  13968. * @param width Define the width of the texture
  13969. * @param height Define the height of the texture
  13970. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13971. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13974. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13975. * @returns the R texture
  13976. */
  13977. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13978. }
  13979. }
  13980. declare module BABYLON {
  13981. interface ThinEngine {
  13982. /**
  13983. * Update a dynamic index buffer
  13984. * @param indexBuffer defines the target index buffer
  13985. * @param indices defines the data to update
  13986. * @param offset defines the offset in the target index buffer where update should start
  13987. */
  13988. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  13989. /**
  13990. * Updates a dynamic vertex buffer.
  13991. * @param vertexBuffer the vertex buffer to update
  13992. * @param data the data used to update the vertex buffer
  13993. * @param byteOffset the byte offset of the data
  13994. * @param byteLength the byte length of the data
  13995. */
  13996. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  13997. }
  13998. }
  13999. declare module BABYLON {
  14000. interface AbstractScene {
  14001. /**
  14002. * The list of procedural textures added to the scene
  14003. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14004. */
  14005. proceduralTextures: Array<ProceduralTexture>;
  14006. }
  14007. /**
  14008. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14009. * in a given scene.
  14010. */
  14011. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14012. /**
  14013. * The component name helpfull to identify the component in the list of scene components.
  14014. */
  14015. readonly name: string;
  14016. /**
  14017. * The scene the component belongs to.
  14018. */
  14019. scene: Scene;
  14020. /**
  14021. * Creates a new instance of the component for the given scene
  14022. * @param scene Defines the scene to register the component in
  14023. */
  14024. constructor(scene: Scene);
  14025. /**
  14026. * Registers the component in a given scene
  14027. */
  14028. register(): void;
  14029. /**
  14030. * Rebuilds the elements related to this component in case of
  14031. * context lost for instance.
  14032. */
  14033. rebuild(): void;
  14034. /**
  14035. * Disposes the component and the associated ressources.
  14036. */
  14037. dispose(): void;
  14038. private _beforeClear;
  14039. }
  14040. }
  14041. declare module BABYLON {
  14042. interface ThinEngine {
  14043. /**
  14044. * Creates a new render target cube texture
  14045. * @param size defines the size of the texture
  14046. * @param options defines the options used to create the texture
  14047. * @returns a new render target cube texture stored in an InternalTexture
  14048. */
  14049. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14050. }
  14051. }
  14052. declare module BABYLON {
  14053. /** @hidden */
  14054. export var proceduralVertexShader: {
  14055. name: string;
  14056. shader: string;
  14057. };
  14058. }
  14059. declare module BABYLON {
  14060. /**
  14061. * 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.
  14062. * This is the base class of any Procedural texture and contains most of the shareable code.
  14063. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14064. */
  14065. export class ProceduralTexture extends Texture {
  14066. /**
  14067. * Define if the texture is enabled or not (disabled texture will not render)
  14068. */
  14069. isEnabled: boolean;
  14070. /**
  14071. * Define if the texture must be cleared before rendering (default is true)
  14072. */
  14073. autoClear: boolean;
  14074. /**
  14075. * Callback called when the texture is generated
  14076. */
  14077. onGenerated: () => void;
  14078. /**
  14079. * Event raised when the texture is generated
  14080. */
  14081. onGeneratedObservable: Observable<ProceduralTexture>;
  14082. /**
  14083. * Event raised before the texture is generated
  14084. */
  14085. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14086. /**
  14087. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14088. */
  14089. nodeMaterialSource: Nullable<NodeMaterial>;
  14090. /** @hidden */
  14091. _generateMipMaps: boolean;
  14092. /** @hidden **/
  14093. _effect: Effect;
  14094. /** @hidden */
  14095. _textures: {
  14096. [key: string]: Texture;
  14097. };
  14098. /** @hidden */
  14099. protected _fallbackTexture: Nullable<Texture>;
  14100. private _size;
  14101. private _currentRefreshId;
  14102. private _frameId;
  14103. private _refreshRate;
  14104. private _vertexBuffers;
  14105. private _indexBuffer;
  14106. private _uniforms;
  14107. private _samplers;
  14108. private _fragment;
  14109. private _floats;
  14110. private _ints;
  14111. private _floatsArrays;
  14112. private _colors3;
  14113. private _colors4;
  14114. private _vectors2;
  14115. private _vectors3;
  14116. private _matrices;
  14117. private _fallbackTextureUsed;
  14118. private _fullEngine;
  14119. private _cachedDefines;
  14120. private _contentUpdateId;
  14121. private _contentData;
  14122. /**
  14123. * Instantiates a new procedural texture.
  14124. * 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.
  14125. * This is the base class of any Procedural texture and contains most of the shareable code.
  14126. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14127. * @param name Define the name of the texture
  14128. * @param size Define the size of the texture to create
  14129. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14130. * @param scene Define the scene the texture belongs to
  14131. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14132. * @param generateMipMaps Define if the texture should creates mip maps or not
  14133. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14134. * @param textureType The FBO internal texture type
  14135. */
  14136. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14137. /**
  14138. * The effect that is created when initializing the post process.
  14139. * @returns The created effect corresponding the the postprocess.
  14140. */
  14141. getEffect(): Effect;
  14142. /**
  14143. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14144. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14145. */
  14146. getContent(): Nullable<ArrayBufferView>;
  14147. private _createIndexBuffer;
  14148. /** @hidden */
  14149. _rebuild(): void;
  14150. /**
  14151. * Resets the texture in order to recreate its associated resources.
  14152. * This can be called in case of context loss
  14153. */
  14154. reset(): void;
  14155. protected _getDefines(): string;
  14156. /**
  14157. * Is the texture ready to be used ? (rendered at least once)
  14158. * @returns true if ready, otherwise, false.
  14159. */
  14160. isReady(): boolean;
  14161. /**
  14162. * Resets the refresh counter of the texture and start bak from scratch.
  14163. * Could be useful to regenerate the texture if it is setup to render only once.
  14164. */
  14165. resetRefreshCounter(): void;
  14166. /**
  14167. * Set the fragment shader to use in order to render the texture.
  14168. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14169. */
  14170. setFragment(fragment: any): void;
  14171. /**
  14172. * Define the refresh rate of the texture or the rendering frequency.
  14173. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14174. */
  14175. get refreshRate(): number;
  14176. set refreshRate(value: number);
  14177. /** @hidden */
  14178. _shouldRender(): boolean;
  14179. /**
  14180. * Get the size the texture is rendering at.
  14181. * @returns the size (on cube texture it is always squared)
  14182. */
  14183. getRenderSize(): RenderTargetTextureSize;
  14184. /**
  14185. * Resize the texture to new value.
  14186. * @param size Define the new size the texture should have
  14187. * @param generateMipMaps Define whether the new texture should create mip maps
  14188. */
  14189. resize(size: number, generateMipMaps: boolean): void;
  14190. private _checkUniform;
  14191. /**
  14192. * Set a texture in the shader program used to render.
  14193. * @param name Define the name of the uniform samplers as defined in the shader
  14194. * @param texture Define the texture to bind to this sampler
  14195. * @return the texture itself allowing "fluent" like uniform updates
  14196. */
  14197. setTexture(name: string, texture: Texture): ProceduralTexture;
  14198. /**
  14199. * Set a float in the shader.
  14200. * @param name Define the name of the uniform as defined in the shader
  14201. * @param value Define the value to give to the uniform
  14202. * @return the texture itself allowing "fluent" like uniform updates
  14203. */
  14204. setFloat(name: string, value: number): ProceduralTexture;
  14205. /**
  14206. * Set a int in the shader.
  14207. * @param name Define the name of the uniform as defined in the shader
  14208. * @param value Define the value to give to the uniform
  14209. * @return the texture itself allowing "fluent" like uniform updates
  14210. */
  14211. setInt(name: string, value: number): ProceduralTexture;
  14212. /**
  14213. * Set an array of floats in the shader.
  14214. * @param name Define the name of the uniform as defined in the shader
  14215. * @param value Define the value to give to the uniform
  14216. * @return the texture itself allowing "fluent" like uniform updates
  14217. */
  14218. setFloats(name: string, value: number[]): ProceduralTexture;
  14219. /**
  14220. * Set a vec3 in the shader from a Color3.
  14221. * @param name Define the name of the uniform as defined in the shader
  14222. * @param value Define the value to give to the uniform
  14223. * @return the texture itself allowing "fluent" like uniform updates
  14224. */
  14225. setColor3(name: string, value: Color3): ProceduralTexture;
  14226. /**
  14227. * Set a vec4 in the shader from a Color4.
  14228. * @param name Define the name of the uniform as defined in the shader
  14229. * @param value Define the value to give to the uniform
  14230. * @return the texture itself allowing "fluent" like uniform updates
  14231. */
  14232. setColor4(name: string, value: Color4): ProceduralTexture;
  14233. /**
  14234. * Set a vec2 in the shader from a Vector2.
  14235. * @param name Define the name of the uniform as defined in the shader
  14236. * @param value Define the value to give to the uniform
  14237. * @return the texture itself allowing "fluent" like uniform updates
  14238. */
  14239. setVector2(name: string, value: Vector2): ProceduralTexture;
  14240. /**
  14241. * Set a vec3 in the shader from a Vector3.
  14242. * @param name Define the name of the uniform as defined in the shader
  14243. * @param value Define the value to give to the uniform
  14244. * @return the texture itself allowing "fluent" like uniform updates
  14245. */
  14246. setVector3(name: string, value: Vector3): ProceduralTexture;
  14247. /**
  14248. * Set a mat4 in the shader from a MAtrix.
  14249. * @param name Define the name of the uniform as defined in the shader
  14250. * @param value Define the value to give to the uniform
  14251. * @return the texture itself allowing "fluent" like uniform updates
  14252. */
  14253. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14254. /**
  14255. * Render the texture to its associated render target.
  14256. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14257. */
  14258. render(useCameraPostProcess?: boolean): void;
  14259. /**
  14260. * Clone the texture.
  14261. * @returns the cloned texture
  14262. */
  14263. clone(): ProceduralTexture;
  14264. /**
  14265. * Dispose the texture and release its asoociated resources.
  14266. */
  14267. dispose(): void;
  14268. }
  14269. }
  14270. declare module BABYLON {
  14271. /**
  14272. * This represents the base class for particle system in Babylon.
  14273. * 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.
  14274. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14275. * @example https://doc.babylonjs.com/babylon101/particles
  14276. */
  14277. export class BaseParticleSystem {
  14278. /**
  14279. * Source color is added to the destination color without alpha affecting the result
  14280. */
  14281. static BLENDMODE_ONEONE: number;
  14282. /**
  14283. * Blend current color and particle color using particle’s alpha
  14284. */
  14285. static BLENDMODE_STANDARD: number;
  14286. /**
  14287. * Add current color and particle color multiplied by particle’s alpha
  14288. */
  14289. static BLENDMODE_ADD: number;
  14290. /**
  14291. * Multiply current color with particle color
  14292. */
  14293. static BLENDMODE_MULTIPLY: number;
  14294. /**
  14295. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14296. */
  14297. static BLENDMODE_MULTIPLYADD: number;
  14298. /**
  14299. * List of animations used by the particle system.
  14300. */
  14301. animations: Animation[];
  14302. /**
  14303. * Gets or sets the unique id of the particle system
  14304. */
  14305. uniqueId: number;
  14306. /**
  14307. * The id of the Particle system.
  14308. */
  14309. id: string;
  14310. /**
  14311. * The friendly name of the Particle system.
  14312. */
  14313. name: string;
  14314. /**
  14315. * Snippet ID if the particle system was created from the snippet server
  14316. */
  14317. snippetId: string;
  14318. /**
  14319. * The rendering group used by the Particle system to chose when to render.
  14320. */
  14321. renderingGroupId: number;
  14322. /**
  14323. * The emitter represents the Mesh or position we are attaching the particle system to.
  14324. */
  14325. emitter: Nullable<AbstractMesh | Vector3>;
  14326. /**
  14327. * The maximum number of particles to emit per frame
  14328. */
  14329. emitRate: number;
  14330. /**
  14331. * If you want to launch only a few particles at once, that can be done, as well.
  14332. */
  14333. manualEmitCount: number;
  14334. /**
  14335. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14336. */
  14337. updateSpeed: number;
  14338. /**
  14339. * The amount of time the particle system is running (depends of the overall update speed).
  14340. */
  14341. targetStopDuration: number;
  14342. /**
  14343. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14344. */
  14345. disposeOnStop: boolean;
  14346. /**
  14347. * Minimum power of emitting particles.
  14348. */
  14349. minEmitPower: number;
  14350. /**
  14351. * Maximum power of emitting particles.
  14352. */
  14353. maxEmitPower: number;
  14354. /**
  14355. * Minimum life time of emitting particles.
  14356. */
  14357. minLifeTime: number;
  14358. /**
  14359. * Maximum life time of emitting particles.
  14360. */
  14361. maxLifeTime: number;
  14362. /**
  14363. * Minimum Size of emitting particles.
  14364. */
  14365. minSize: number;
  14366. /**
  14367. * Maximum Size of emitting particles.
  14368. */
  14369. maxSize: number;
  14370. /**
  14371. * Minimum scale of emitting particles on X axis.
  14372. */
  14373. minScaleX: number;
  14374. /**
  14375. * Maximum scale of emitting particles on X axis.
  14376. */
  14377. maxScaleX: number;
  14378. /**
  14379. * Minimum scale of emitting particles on Y axis.
  14380. */
  14381. minScaleY: number;
  14382. /**
  14383. * Maximum scale of emitting particles on Y axis.
  14384. */
  14385. maxScaleY: number;
  14386. /**
  14387. * Gets or sets the minimal initial rotation in radians.
  14388. */
  14389. minInitialRotation: number;
  14390. /**
  14391. * Gets or sets the maximal initial rotation in radians.
  14392. */
  14393. maxInitialRotation: number;
  14394. /**
  14395. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14396. */
  14397. minAngularSpeed: number;
  14398. /**
  14399. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14400. */
  14401. maxAngularSpeed: number;
  14402. /**
  14403. * The texture used to render each particle. (this can be a spritesheet)
  14404. */
  14405. particleTexture: Nullable<BaseTexture>;
  14406. /**
  14407. * The layer mask we are rendering the particles through.
  14408. */
  14409. layerMask: number;
  14410. /**
  14411. * This can help using your own shader to render the particle system.
  14412. * The according effect will be created
  14413. */
  14414. customShader: any;
  14415. /**
  14416. * By default particle system starts as soon as they are created. This prevents the
  14417. * automatic start to happen and let you decide when to start emitting particles.
  14418. */
  14419. preventAutoStart: boolean;
  14420. private _noiseTexture;
  14421. /**
  14422. * Gets or sets a texture used to add random noise to particle positions
  14423. */
  14424. get noiseTexture(): Nullable<ProceduralTexture>;
  14425. set noiseTexture(value: Nullable<ProceduralTexture>);
  14426. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14427. noiseStrength: Vector3;
  14428. /**
  14429. * Callback triggered when the particle animation is ending.
  14430. */
  14431. onAnimationEnd: Nullable<() => void>;
  14432. /**
  14433. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14434. */
  14435. blendMode: number;
  14436. /**
  14437. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14438. * to override the particles.
  14439. */
  14440. forceDepthWrite: boolean;
  14441. /** 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 */
  14442. preWarmCycles: number;
  14443. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14444. preWarmStepOffset: number;
  14445. /**
  14446. * 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)
  14447. */
  14448. spriteCellChangeSpeed: number;
  14449. /**
  14450. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14451. */
  14452. startSpriteCellID: number;
  14453. /**
  14454. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14455. */
  14456. endSpriteCellID: number;
  14457. /**
  14458. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14459. */
  14460. spriteCellWidth: number;
  14461. /**
  14462. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14463. */
  14464. spriteCellHeight: number;
  14465. /**
  14466. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14467. */
  14468. spriteRandomStartCell: boolean;
  14469. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14470. translationPivot: Vector2;
  14471. /** @hidden */
  14472. protected _isAnimationSheetEnabled: boolean;
  14473. /**
  14474. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14475. */
  14476. beginAnimationOnStart: boolean;
  14477. /**
  14478. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14479. */
  14480. beginAnimationFrom: number;
  14481. /**
  14482. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14483. */
  14484. beginAnimationTo: number;
  14485. /**
  14486. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14487. */
  14488. beginAnimationLoop: boolean;
  14489. /**
  14490. * Gets or sets a world offset applied to all particles
  14491. */
  14492. worldOffset: Vector3;
  14493. /**
  14494. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14495. */
  14496. get isAnimationSheetEnabled(): boolean;
  14497. set isAnimationSheetEnabled(value: boolean);
  14498. /**
  14499. * Get hosting scene
  14500. * @returns the scene
  14501. */
  14502. getScene(): Nullable<Scene>;
  14503. /**
  14504. * You can use gravity if you want to give an orientation to your particles.
  14505. */
  14506. gravity: Vector3;
  14507. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14508. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14509. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14510. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14511. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14512. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14513. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14514. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14515. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14516. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14517. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14518. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14519. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14520. /**
  14521. * Defines the delay in milliseconds before starting the system (0 by default)
  14522. */
  14523. startDelay: number;
  14524. /**
  14525. * Gets the current list of drag gradients.
  14526. * You must use addDragGradient and removeDragGradient to udpate this list
  14527. * @returns the list of drag gradients
  14528. */
  14529. getDragGradients(): Nullable<Array<FactorGradient>>;
  14530. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14531. limitVelocityDamping: number;
  14532. /**
  14533. * Gets the current list of limit velocity gradients.
  14534. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14535. * @returns the list of limit velocity gradients
  14536. */
  14537. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14538. /**
  14539. * Gets the current list of color gradients.
  14540. * You must use addColorGradient and removeColorGradient to udpate this list
  14541. * @returns the list of color gradients
  14542. */
  14543. getColorGradients(): Nullable<Array<ColorGradient>>;
  14544. /**
  14545. * Gets the current list of size gradients.
  14546. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14547. * @returns the list of size gradients
  14548. */
  14549. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14550. /**
  14551. * Gets the current list of color remap gradients.
  14552. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14553. * @returns the list of color remap gradients
  14554. */
  14555. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14556. /**
  14557. * Gets the current list of alpha remap gradients.
  14558. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14559. * @returns the list of alpha remap gradients
  14560. */
  14561. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14562. /**
  14563. * Gets the current list of life time gradients.
  14564. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14565. * @returns the list of life time gradients
  14566. */
  14567. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14568. /**
  14569. * Gets the current list of angular speed gradients.
  14570. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14571. * @returns the list of angular speed gradients
  14572. */
  14573. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14574. /**
  14575. * Gets the current list of velocity gradients.
  14576. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14577. * @returns the list of velocity gradients
  14578. */
  14579. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14580. /**
  14581. * Gets the current list of start size gradients.
  14582. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14583. * @returns the list of start size gradients
  14584. */
  14585. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14586. /**
  14587. * Gets the current list of emit rate gradients.
  14588. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14589. * @returns the list of emit rate gradients
  14590. */
  14591. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14592. /**
  14593. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14594. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14595. */
  14596. get direction1(): Vector3;
  14597. set direction1(value: Vector3);
  14598. /**
  14599. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14600. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14601. */
  14602. get direction2(): Vector3;
  14603. set direction2(value: Vector3);
  14604. /**
  14605. * 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.
  14606. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14607. */
  14608. get minEmitBox(): Vector3;
  14609. set minEmitBox(value: Vector3);
  14610. /**
  14611. * 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.
  14612. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14613. */
  14614. get maxEmitBox(): Vector3;
  14615. set maxEmitBox(value: Vector3);
  14616. /**
  14617. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14618. */
  14619. color1: Color4;
  14620. /**
  14621. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14622. */
  14623. color2: Color4;
  14624. /**
  14625. * Color the particle will have at the end of its lifetime
  14626. */
  14627. colorDead: Color4;
  14628. /**
  14629. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14630. */
  14631. textureMask: Color4;
  14632. /**
  14633. * The particle emitter type defines the emitter used by the particle system.
  14634. * It can be for example box, sphere, or cone...
  14635. */
  14636. particleEmitterType: IParticleEmitterType;
  14637. /** @hidden */
  14638. _isSubEmitter: boolean;
  14639. /**
  14640. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14641. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14642. */
  14643. billboardMode: number;
  14644. protected _isBillboardBased: boolean;
  14645. /**
  14646. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14647. */
  14648. get isBillboardBased(): boolean;
  14649. set isBillboardBased(value: boolean);
  14650. /**
  14651. * The scene the particle system belongs to.
  14652. */
  14653. protected _scene: Nullable<Scene>;
  14654. /**
  14655. * The engine the particle system belongs to.
  14656. */
  14657. protected _engine: ThinEngine;
  14658. /**
  14659. * Local cache of defines for image processing.
  14660. */
  14661. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14662. /**
  14663. * Default configuration related to image processing available in the standard Material.
  14664. */
  14665. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  14666. /**
  14667. * Gets the image processing configuration used either in this material.
  14668. */
  14669. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  14670. /**
  14671. * Sets the Default image processing configuration used either in the this material.
  14672. *
  14673. * If sets to null, the scene one is in use.
  14674. */
  14675. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  14676. /**
  14677. * Attaches a new image processing configuration to the Standard Material.
  14678. * @param configuration
  14679. */
  14680. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14681. /** @hidden */
  14682. protected _reset(): void;
  14683. /** @hidden */
  14684. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14685. /**
  14686. * Instantiates a particle system.
  14687. * 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.
  14688. * @param name The name of the particle system
  14689. */
  14690. constructor(name: string);
  14691. /**
  14692. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14693. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14694. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14695. * @returns the emitter
  14696. */
  14697. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14698. /**
  14699. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14700. * @param radius The radius of the hemisphere to emit from
  14701. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14702. * @returns the emitter
  14703. */
  14704. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14705. /**
  14706. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14707. * @param radius The radius of the sphere to emit from
  14708. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14709. * @returns the emitter
  14710. */
  14711. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14712. /**
  14713. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14714. * @param radius The radius of the sphere to emit from
  14715. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14716. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14717. * @returns the emitter
  14718. */
  14719. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14720. /**
  14721. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14722. * @param radius The radius of the emission cylinder
  14723. * @param height The height of the emission cylinder
  14724. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14725. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14726. * @returns the emitter
  14727. */
  14728. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14729. /**
  14730. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14731. * @param radius The radius of the cylinder to emit from
  14732. * @param height The height of the emission cylinder
  14733. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14734. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14735. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14736. * @returns the emitter
  14737. */
  14738. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14739. /**
  14740. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14741. * @param radius The radius of the cone to emit from
  14742. * @param angle The base angle of the cone
  14743. * @returns the emitter
  14744. */
  14745. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14746. /**
  14747. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14748. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14749. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14750. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14751. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14752. * @returns the emitter
  14753. */
  14754. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14755. }
  14756. }
  14757. declare module BABYLON {
  14758. /**
  14759. * Type of sub emitter
  14760. */
  14761. export enum SubEmitterType {
  14762. /**
  14763. * Attached to the particle over it's lifetime
  14764. */
  14765. ATTACHED = 0,
  14766. /**
  14767. * Created when the particle dies
  14768. */
  14769. END = 1
  14770. }
  14771. /**
  14772. * Sub emitter class used to emit particles from an existing particle
  14773. */
  14774. export class SubEmitter {
  14775. /**
  14776. * the particle system to be used by the sub emitter
  14777. */
  14778. particleSystem: ParticleSystem;
  14779. /**
  14780. * Type of the submitter (Default: END)
  14781. */
  14782. type: SubEmitterType;
  14783. /**
  14784. * 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)
  14785. * Note: This only is supported when using an emitter of type Mesh
  14786. */
  14787. inheritDirection: boolean;
  14788. /**
  14789. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14790. */
  14791. inheritedVelocityAmount: number;
  14792. /**
  14793. * Creates a sub emitter
  14794. * @param particleSystem the particle system to be used by the sub emitter
  14795. */
  14796. constructor(
  14797. /**
  14798. * the particle system to be used by the sub emitter
  14799. */
  14800. particleSystem: ParticleSystem);
  14801. /**
  14802. * Clones the sub emitter
  14803. * @returns the cloned sub emitter
  14804. */
  14805. clone(): SubEmitter;
  14806. /**
  14807. * Serialize current object to a JSON object
  14808. * @returns the serialized object
  14809. */
  14810. serialize(): any;
  14811. /** @hidden */
  14812. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  14813. /**
  14814. * Creates a new SubEmitter from a serialized JSON version
  14815. * @param serializationObject defines the JSON object to read from
  14816. * @param sceneOrEngine defines the hosting scene or the hosting engine
  14817. * @param rootUrl defines the rootUrl for data loading
  14818. * @returns a new SubEmitter
  14819. */
  14820. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  14821. /** Release associated resources */
  14822. dispose(): void;
  14823. }
  14824. }
  14825. declare module BABYLON {
  14826. /** @hidden */
  14827. export var clipPlaneFragmentDeclaration: {
  14828. name: string;
  14829. shader: string;
  14830. };
  14831. }
  14832. declare module BABYLON {
  14833. /** @hidden */
  14834. export var imageProcessingDeclaration: {
  14835. name: string;
  14836. shader: string;
  14837. };
  14838. }
  14839. declare module BABYLON {
  14840. /** @hidden */
  14841. export var imageProcessingFunctions: {
  14842. name: string;
  14843. shader: string;
  14844. };
  14845. }
  14846. declare module BABYLON {
  14847. /** @hidden */
  14848. export var clipPlaneFragment: {
  14849. name: string;
  14850. shader: string;
  14851. };
  14852. }
  14853. declare module BABYLON {
  14854. /** @hidden */
  14855. export var particlesPixelShader: {
  14856. name: string;
  14857. shader: string;
  14858. };
  14859. }
  14860. declare module BABYLON {
  14861. /** @hidden */
  14862. export var clipPlaneVertexDeclaration: {
  14863. name: string;
  14864. shader: string;
  14865. };
  14866. }
  14867. declare module BABYLON {
  14868. /** @hidden */
  14869. export var clipPlaneVertex: {
  14870. name: string;
  14871. shader: string;
  14872. };
  14873. }
  14874. declare module BABYLON {
  14875. /** @hidden */
  14876. export var particlesVertexShader: {
  14877. name: string;
  14878. shader: string;
  14879. };
  14880. }
  14881. declare module BABYLON {
  14882. /**
  14883. * Interface used to define entities containing multiple clip planes
  14884. */
  14885. export interface IClipPlanesHolder {
  14886. /**
  14887. * Gets or sets the active clipplane 1
  14888. */
  14889. clipPlane: Nullable<Plane>;
  14890. /**
  14891. * Gets or sets the active clipplane 2
  14892. */
  14893. clipPlane2: Nullable<Plane>;
  14894. /**
  14895. * Gets or sets the active clipplane 3
  14896. */
  14897. clipPlane3: Nullable<Plane>;
  14898. /**
  14899. * Gets or sets the active clipplane 4
  14900. */
  14901. clipPlane4: Nullable<Plane>;
  14902. /**
  14903. * Gets or sets the active clipplane 5
  14904. */
  14905. clipPlane5: Nullable<Plane>;
  14906. /**
  14907. * Gets or sets the active clipplane 6
  14908. */
  14909. clipPlane6: Nullable<Plane>;
  14910. }
  14911. }
  14912. declare module BABYLON {
  14913. /**
  14914. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  14915. *
  14916. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  14917. *
  14918. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14919. */
  14920. export class ThinMaterialHelper {
  14921. /**
  14922. * Binds the clip plane information from the holder to the effect.
  14923. * @param effect The effect we are binding the data to
  14924. * @param holder The entity containing the clip plane information
  14925. */
  14926. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  14927. }
  14928. }
  14929. declare module BABYLON {
  14930. interface ThinEngine {
  14931. /**
  14932. * Sets alpha constants used by some alpha blending modes
  14933. * @param r defines the red component
  14934. * @param g defines the green component
  14935. * @param b defines the blue component
  14936. * @param a defines the alpha component
  14937. */
  14938. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  14939. /**
  14940. * Sets the current alpha mode
  14941. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  14942. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  14943. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14944. */
  14945. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  14946. /**
  14947. * Gets the current alpha mode
  14948. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14949. * @returns the current alpha mode
  14950. */
  14951. getAlphaMode(): number;
  14952. /**
  14953. * Sets the current alpha equation
  14954. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  14955. */
  14956. setAlphaEquation(equation: number): void;
  14957. /**
  14958. * Gets the current alpha equation.
  14959. * @returns the current alpha equation
  14960. */
  14961. getAlphaEquation(): number;
  14962. }
  14963. }
  14964. declare module BABYLON {
  14965. /**
  14966. * This represents a particle system in Babylon.
  14967. * 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.
  14968. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14969. * @example https://doc.babylonjs.com/babylon101/particles
  14970. */
  14971. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14972. /**
  14973. * Billboard mode will only apply to Y axis
  14974. */
  14975. static readonly BILLBOARDMODE_Y: number;
  14976. /**
  14977. * Billboard mode will apply to all axes
  14978. */
  14979. static readonly BILLBOARDMODE_ALL: number;
  14980. /**
  14981. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14982. */
  14983. static readonly BILLBOARDMODE_STRETCHED: number;
  14984. /**
  14985. * This function can be defined to provide custom update for active particles.
  14986. * This function will be called instead of regular update (age, position, color, etc.).
  14987. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14988. */
  14989. updateFunction: (particles: Particle[]) => void;
  14990. private _emitterWorldMatrix;
  14991. /**
  14992. * This function can be defined to specify initial direction for every new particle.
  14993. * It by default use the emitterType defined function
  14994. */
  14995. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  14996. /**
  14997. * This function can be defined to specify initial position for every new particle.
  14998. * It by default use the emitterType defined function
  14999. */
  15000. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15001. /**
  15002. * @hidden
  15003. */
  15004. _inheritedVelocityOffset: Vector3;
  15005. /**
  15006. * An event triggered when the system is disposed
  15007. */
  15008. onDisposeObservable: Observable<IParticleSystem>;
  15009. /**
  15010. * An event triggered when the system is stopped
  15011. */
  15012. onStoppedObservable: Observable<IParticleSystem>;
  15013. private _onDisposeObserver;
  15014. /**
  15015. * Sets a callback that will be triggered when the system is disposed
  15016. */
  15017. set onDispose(callback: () => void);
  15018. private _particles;
  15019. private _epsilon;
  15020. private _capacity;
  15021. private _stockParticles;
  15022. private _newPartsExcess;
  15023. private _vertexData;
  15024. private _vertexBuffer;
  15025. private _vertexBuffers;
  15026. private _spriteBuffer;
  15027. private _indexBuffer;
  15028. private _effect;
  15029. private _customEffect;
  15030. private _cachedDefines;
  15031. private _scaledColorStep;
  15032. private _colorDiff;
  15033. private _scaledDirection;
  15034. private _scaledGravity;
  15035. private _currentRenderId;
  15036. private _alive;
  15037. private _useInstancing;
  15038. private _vertexArrayObject;
  15039. private _started;
  15040. private _stopped;
  15041. private _actualFrame;
  15042. private _scaledUpdateSpeed;
  15043. private _vertexBufferSize;
  15044. /** @hidden */
  15045. _currentEmitRateGradient: Nullable<FactorGradient>;
  15046. /** @hidden */
  15047. _currentEmitRate1: number;
  15048. /** @hidden */
  15049. _currentEmitRate2: number;
  15050. /** @hidden */
  15051. _currentStartSizeGradient: Nullable<FactorGradient>;
  15052. /** @hidden */
  15053. _currentStartSize1: number;
  15054. /** @hidden */
  15055. _currentStartSize2: number;
  15056. private readonly _rawTextureWidth;
  15057. private _rampGradientsTexture;
  15058. private _useRampGradients;
  15059. /** Gets or sets a matrix to use to compute projection */
  15060. defaultProjectionMatrix: Matrix;
  15061. /** Gets or sets a matrix to use to compute view */
  15062. defaultViewMatrix: Matrix;
  15063. /** Gets or sets a boolean indicating that ramp gradients must be used
  15064. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15065. */
  15066. get useRampGradients(): boolean;
  15067. set useRampGradients(value: boolean);
  15068. /**
  15069. * 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.
  15070. * 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: [])
  15071. */
  15072. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15073. private _subEmitters;
  15074. /**
  15075. * @hidden
  15076. * If the particle systems emitter should be disposed when the particle system is disposed
  15077. */
  15078. _disposeEmitterOnDispose: boolean;
  15079. /**
  15080. * The current active Sub-systems, this property is used by the root particle system only.
  15081. */
  15082. activeSubSystems: Array<ParticleSystem>;
  15083. /**
  15084. * Specifies if the particles are updated in emitter local space or world space
  15085. */
  15086. isLocal: boolean;
  15087. private _rootParticleSystem;
  15088. /**
  15089. * Gets the current list of active particles
  15090. */
  15091. get particles(): Particle[];
  15092. /**
  15093. * Gets the number of particles active at the same time.
  15094. * @returns The number of active particles.
  15095. */
  15096. getActiveCount(): number;
  15097. /**
  15098. * Returns the string "ParticleSystem"
  15099. * @returns a string containing the class name
  15100. */
  15101. getClassName(): string;
  15102. /**
  15103. * Gets a boolean indicating that the system is stopping
  15104. * @returns true if the system is currently stopping
  15105. */
  15106. isStopping(): boolean;
  15107. /**
  15108. * Gets the custom effect used to render the particles
  15109. * @param blendMode Blend mode for which the effect should be retrieved
  15110. * @returns The effect
  15111. */
  15112. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15113. /**
  15114. * Sets the custom effect used to render the particles
  15115. * @param effect The effect to set
  15116. * @param blendMode Blend mode for which the effect should be set
  15117. */
  15118. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15119. /** @hidden */
  15120. private _onBeforeDrawParticlesObservable;
  15121. /**
  15122. * Observable that will be called just before the particles are drawn
  15123. */
  15124. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15125. /**
  15126. * Gets the name of the particle vertex shader
  15127. */
  15128. get vertexShaderName(): string;
  15129. /**
  15130. * Instantiates a particle system.
  15131. * 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.
  15132. * @param name The name of the particle system
  15133. * @param capacity The max number of particles alive at the same time
  15134. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15135. * @param customEffect a custom effect used to change the way particles are rendered by default
  15136. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15137. * @param epsilon Offset used to render the particles
  15138. */
  15139. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15140. private _addFactorGradient;
  15141. private _removeFactorGradient;
  15142. /**
  15143. * Adds a new life time gradient
  15144. * @param gradient defines the gradient to use (between 0 and 1)
  15145. * @param factor defines the life time factor to affect to the specified gradient
  15146. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15147. * @returns the current particle system
  15148. */
  15149. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15150. /**
  15151. * Remove a specific life time gradient
  15152. * @param gradient defines the gradient to remove
  15153. * @returns the current particle system
  15154. */
  15155. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15156. /**
  15157. * Adds a new size gradient
  15158. * @param gradient defines the gradient to use (between 0 and 1)
  15159. * @param factor defines the size factor to affect to the specified gradient
  15160. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15161. * @returns the current particle system
  15162. */
  15163. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15164. /**
  15165. * Remove a specific size gradient
  15166. * @param gradient defines the gradient to remove
  15167. * @returns the current particle system
  15168. */
  15169. removeSizeGradient(gradient: number): IParticleSystem;
  15170. /**
  15171. * Adds a new color remap gradient
  15172. * @param gradient defines the gradient to use (between 0 and 1)
  15173. * @param min defines the color remap minimal range
  15174. * @param max defines the color remap maximal range
  15175. * @returns the current particle system
  15176. */
  15177. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15178. /**
  15179. * Remove a specific color remap gradient
  15180. * @param gradient defines the gradient to remove
  15181. * @returns the current particle system
  15182. */
  15183. removeColorRemapGradient(gradient: number): IParticleSystem;
  15184. /**
  15185. * Adds a new alpha remap gradient
  15186. * @param gradient defines the gradient to use (between 0 and 1)
  15187. * @param min defines the alpha remap minimal range
  15188. * @param max defines the alpha remap maximal range
  15189. * @returns the current particle system
  15190. */
  15191. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15192. /**
  15193. * Remove a specific alpha remap gradient
  15194. * @param gradient defines the gradient to remove
  15195. * @returns the current particle system
  15196. */
  15197. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15198. /**
  15199. * Adds a new angular speed gradient
  15200. * @param gradient defines the gradient to use (between 0 and 1)
  15201. * @param factor defines the angular speed to affect to the specified gradient
  15202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15203. * @returns the current particle system
  15204. */
  15205. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15206. /**
  15207. * Remove a specific angular speed gradient
  15208. * @param gradient defines the gradient to remove
  15209. * @returns the current particle system
  15210. */
  15211. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15212. /**
  15213. * Adds a new velocity gradient
  15214. * @param gradient defines the gradient to use (between 0 and 1)
  15215. * @param factor defines the velocity to affect to the specified gradient
  15216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15217. * @returns the current particle system
  15218. */
  15219. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15220. /**
  15221. * Remove a specific velocity gradient
  15222. * @param gradient defines the gradient to remove
  15223. * @returns the current particle system
  15224. */
  15225. removeVelocityGradient(gradient: number): IParticleSystem;
  15226. /**
  15227. * Adds a new limit velocity gradient
  15228. * @param gradient defines the gradient to use (between 0 and 1)
  15229. * @param factor defines the limit velocity value to affect to the specified gradient
  15230. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15231. * @returns the current particle system
  15232. */
  15233. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15234. /**
  15235. * Remove a specific limit velocity gradient
  15236. * @param gradient defines the gradient to remove
  15237. * @returns the current particle system
  15238. */
  15239. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15240. /**
  15241. * Adds a new drag gradient
  15242. * @param gradient defines the gradient to use (between 0 and 1)
  15243. * @param factor defines the drag value to affect to the specified gradient
  15244. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15245. * @returns the current particle system
  15246. */
  15247. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15248. /**
  15249. * Remove a specific drag gradient
  15250. * @param gradient defines the gradient to remove
  15251. * @returns the current particle system
  15252. */
  15253. removeDragGradient(gradient: number): IParticleSystem;
  15254. /**
  15255. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15256. * @param gradient defines the gradient to use (between 0 and 1)
  15257. * @param factor defines the emit rate value to affect to the specified gradient
  15258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15259. * @returns the current particle system
  15260. */
  15261. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15262. /**
  15263. * Remove a specific emit rate gradient
  15264. * @param gradient defines the gradient to remove
  15265. * @returns the current particle system
  15266. */
  15267. removeEmitRateGradient(gradient: number): IParticleSystem;
  15268. /**
  15269. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15270. * @param gradient defines the gradient to use (between 0 and 1)
  15271. * @param factor defines the start size value to affect to the specified gradient
  15272. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15273. * @returns the current particle system
  15274. */
  15275. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15276. /**
  15277. * Remove a specific start size gradient
  15278. * @param gradient defines the gradient to remove
  15279. * @returns the current particle system
  15280. */
  15281. removeStartSizeGradient(gradient: number): IParticleSystem;
  15282. private _createRampGradientTexture;
  15283. /**
  15284. * Gets the current list of ramp gradients.
  15285. * You must use addRampGradient and removeRampGradient to udpate this list
  15286. * @returns the list of ramp gradients
  15287. */
  15288. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15289. /** Force the system to rebuild all gradients that need to be resync */
  15290. forceRefreshGradients(): void;
  15291. private _syncRampGradientTexture;
  15292. /**
  15293. * Adds a new ramp gradient used to remap particle colors
  15294. * @param gradient defines the gradient to use (between 0 and 1)
  15295. * @param color defines the color to affect to the specified gradient
  15296. * @returns the current particle system
  15297. */
  15298. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15299. /**
  15300. * Remove a specific ramp gradient
  15301. * @param gradient defines the gradient to remove
  15302. * @returns the current particle system
  15303. */
  15304. removeRampGradient(gradient: number): ParticleSystem;
  15305. /**
  15306. * Adds a new color gradient
  15307. * @param gradient defines the gradient to use (between 0 and 1)
  15308. * @param color1 defines the color to affect to the specified gradient
  15309. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15310. * @returns this particle system
  15311. */
  15312. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15313. /**
  15314. * Remove a specific color gradient
  15315. * @param gradient defines the gradient to remove
  15316. * @returns this particle system
  15317. */
  15318. removeColorGradient(gradient: number): IParticleSystem;
  15319. private _fetchR;
  15320. protected _reset(): void;
  15321. private _resetEffect;
  15322. private _createVertexBuffers;
  15323. private _createIndexBuffer;
  15324. /**
  15325. * Gets the maximum number of particles active at the same time.
  15326. * @returns The max number of active particles.
  15327. */
  15328. getCapacity(): number;
  15329. /**
  15330. * Gets whether there are still active particles in the system.
  15331. * @returns True if it is alive, otherwise false.
  15332. */
  15333. isAlive(): boolean;
  15334. /**
  15335. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15336. * @returns True if it has been started, otherwise false.
  15337. */
  15338. isStarted(): boolean;
  15339. private _prepareSubEmitterInternalArray;
  15340. /**
  15341. * Starts the particle system and begins to emit
  15342. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15343. */
  15344. start(delay?: number): void;
  15345. /**
  15346. * Stops the particle system.
  15347. * @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.
  15348. */
  15349. stop(stopSubEmitters?: boolean): void;
  15350. /**
  15351. * Remove all active particles
  15352. */
  15353. reset(): void;
  15354. /**
  15355. * @hidden (for internal use only)
  15356. */
  15357. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15358. /**
  15359. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15360. * Its lifetime will start back at 0.
  15361. */
  15362. recycleParticle: (particle: Particle) => void;
  15363. private _stopSubEmitters;
  15364. private _createParticle;
  15365. private _removeFromRoot;
  15366. private _emitFromParticle;
  15367. private _update;
  15368. /** @hidden */
  15369. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15370. /** @hidden */
  15371. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15372. /**
  15373. * Fill the defines array according to the current settings of the particle system
  15374. * @param defines Array to be updated
  15375. * @param blendMode blend mode to take into account when updating the array
  15376. */
  15377. fillDefines(defines: Array<string>, blendMode: number): void;
  15378. /**
  15379. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15380. * @param uniforms Uniforms array to fill
  15381. * @param attributes Attributes array to fill
  15382. * @param samplers Samplers array to fill
  15383. */
  15384. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15385. /** @hidden */
  15386. private _getEffect;
  15387. /**
  15388. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15389. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15390. */
  15391. animate(preWarmOnly?: boolean): void;
  15392. private _appendParticleVertices;
  15393. /**
  15394. * Rebuilds the particle system.
  15395. */
  15396. rebuild(): void;
  15397. /**
  15398. * Is this system ready to be used/rendered
  15399. * @return true if the system is ready
  15400. */
  15401. isReady(): boolean;
  15402. private _render;
  15403. /**
  15404. * Renders the particle system in its current state.
  15405. * @returns the current number of particles
  15406. */
  15407. render(): number;
  15408. /**
  15409. * Disposes the particle system and free the associated resources
  15410. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15411. */
  15412. dispose(disposeTexture?: boolean): void;
  15413. /**
  15414. * Clones the particle system.
  15415. * @param name The name of the cloned object
  15416. * @param newEmitter The new emitter to use
  15417. * @returns the cloned particle system
  15418. */
  15419. clone(name: string, newEmitter: any): ParticleSystem;
  15420. /**
  15421. * Serializes the particle system to a JSON object
  15422. * @param serializeTexture defines if the texture must be serialized as well
  15423. * @returns the JSON object
  15424. */
  15425. serialize(serializeTexture?: boolean): any;
  15426. /** @hidden */
  15427. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  15428. /** @hidden */
  15429. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  15430. /**
  15431. * Parses a JSON object to create a particle system.
  15432. * @param parsedParticleSystem The JSON object to parse
  15433. * @param sceneOrEngine The scene or the engine to create the particle system in
  15434. * @param rootUrl The root url to use to load external dependencies like texture
  15435. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15436. * @returns the Parsed particle system
  15437. */
  15438. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15439. }
  15440. }
  15441. declare module BABYLON {
  15442. /**
  15443. * A particle represents one of the element emitted by a particle system.
  15444. * This is mainly define by its coordinates, direction, velocity and age.
  15445. */
  15446. export class Particle {
  15447. /**
  15448. * The particle system the particle belongs to.
  15449. */
  15450. particleSystem: ParticleSystem;
  15451. private static _Count;
  15452. /**
  15453. * Unique ID of the particle
  15454. */
  15455. id: number;
  15456. /**
  15457. * The world position of the particle in the scene.
  15458. */
  15459. position: Vector3;
  15460. /**
  15461. * The world direction of the particle in the scene.
  15462. */
  15463. direction: Vector3;
  15464. /**
  15465. * The color of the particle.
  15466. */
  15467. color: Color4;
  15468. /**
  15469. * The color change of the particle per step.
  15470. */
  15471. colorStep: Color4;
  15472. /**
  15473. * Defines how long will the life of the particle be.
  15474. */
  15475. lifeTime: number;
  15476. /**
  15477. * The current age of the particle.
  15478. */
  15479. age: number;
  15480. /**
  15481. * The current size of the particle.
  15482. */
  15483. size: number;
  15484. /**
  15485. * The current scale of the particle.
  15486. */
  15487. scale: Vector2;
  15488. /**
  15489. * The current angle of the particle.
  15490. */
  15491. angle: number;
  15492. /**
  15493. * Defines how fast is the angle changing.
  15494. */
  15495. angularSpeed: number;
  15496. /**
  15497. * Defines the cell index used by the particle to be rendered from a sprite.
  15498. */
  15499. cellIndex: number;
  15500. /**
  15501. * The information required to support color remapping
  15502. */
  15503. remapData: Vector4;
  15504. /** @hidden */
  15505. _randomCellOffset?: number;
  15506. /** @hidden */
  15507. _initialDirection: Nullable<Vector3>;
  15508. /** @hidden */
  15509. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15510. /** @hidden */
  15511. _initialStartSpriteCellID: number;
  15512. /** @hidden */
  15513. _initialEndSpriteCellID: number;
  15514. /** @hidden */
  15515. _currentColorGradient: Nullable<ColorGradient>;
  15516. /** @hidden */
  15517. _currentColor1: Color4;
  15518. /** @hidden */
  15519. _currentColor2: Color4;
  15520. /** @hidden */
  15521. _currentSizeGradient: Nullable<FactorGradient>;
  15522. /** @hidden */
  15523. _currentSize1: number;
  15524. /** @hidden */
  15525. _currentSize2: number;
  15526. /** @hidden */
  15527. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15528. /** @hidden */
  15529. _currentAngularSpeed1: number;
  15530. /** @hidden */
  15531. _currentAngularSpeed2: number;
  15532. /** @hidden */
  15533. _currentVelocityGradient: Nullable<FactorGradient>;
  15534. /** @hidden */
  15535. _currentVelocity1: number;
  15536. /** @hidden */
  15537. _currentVelocity2: number;
  15538. /** @hidden */
  15539. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15540. /** @hidden */
  15541. _currentLimitVelocity1: number;
  15542. /** @hidden */
  15543. _currentLimitVelocity2: number;
  15544. /** @hidden */
  15545. _currentDragGradient: Nullable<FactorGradient>;
  15546. /** @hidden */
  15547. _currentDrag1: number;
  15548. /** @hidden */
  15549. _currentDrag2: number;
  15550. /** @hidden */
  15551. _randomNoiseCoordinates1: Vector3;
  15552. /** @hidden */
  15553. _randomNoiseCoordinates2: Vector3;
  15554. /** @hidden */
  15555. _localPosition?: Vector3;
  15556. /**
  15557. * Creates a new instance Particle
  15558. * @param particleSystem the particle system the particle belongs to
  15559. */
  15560. constructor(
  15561. /**
  15562. * The particle system the particle belongs to.
  15563. */
  15564. particleSystem: ParticleSystem);
  15565. private updateCellInfoFromSystem;
  15566. /**
  15567. * Defines how the sprite cell index is updated for the particle
  15568. */
  15569. updateCellIndex(): void;
  15570. /** @hidden */
  15571. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15572. /** @hidden */
  15573. _inheritParticleInfoToSubEmitters(): void;
  15574. /** @hidden */
  15575. _reset(): void;
  15576. /**
  15577. * Copy the properties of particle to another one.
  15578. * @param other the particle to copy the information to.
  15579. */
  15580. copyTo(other: Particle): void;
  15581. }
  15582. }
  15583. declare module BABYLON {
  15584. /**
  15585. * Particle emitter represents a volume emitting particles.
  15586. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15587. */
  15588. export interface IParticleEmitterType {
  15589. /**
  15590. * Called by the particle System when the direction is computed for the created particle.
  15591. * @param worldMatrix is the world matrix of the particle system
  15592. * @param directionToUpdate is the direction vector to update with the result
  15593. * @param particle is the particle we are computed the direction for
  15594. * @param isLocal defines if the direction should be set in local space
  15595. */
  15596. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15597. /**
  15598. * Called by the particle System when the position is computed for the created particle.
  15599. * @param worldMatrix is the world matrix of the particle system
  15600. * @param positionToUpdate is the position vector to update with the result
  15601. * @param particle is the particle we are computed the position for
  15602. * @param isLocal defines if the position should be set in local space
  15603. */
  15604. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15605. /**
  15606. * Clones the current emitter and returns a copy of it
  15607. * @returns the new emitter
  15608. */
  15609. clone(): IParticleEmitterType;
  15610. /**
  15611. * Called by the GPUParticleSystem to setup the update shader
  15612. * @param effect defines the update shader
  15613. */
  15614. applyToShader(effect: Effect): void;
  15615. /**
  15616. * Returns a string to use to update the GPU particles update shader
  15617. * @returns the effect defines string
  15618. */
  15619. getEffectDefines(): string;
  15620. /**
  15621. * Returns a string representing the class name
  15622. * @returns a string containing the class name
  15623. */
  15624. getClassName(): string;
  15625. /**
  15626. * Serializes the particle system to a JSON object.
  15627. * @returns the JSON object
  15628. */
  15629. serialize(): any;
  15630. /**
  15631. * Parse properties from a JSON object
  15632. * @param serializationObject defines the JSON object
  15633. * @param scene defines the hosting scene
  15634. */
  15635. parse(serializationObject: any, scene: Nullable<Scene>): void;
  15636. }
  15637. }
  15638. declare module BABYLON {
  15639. /**
  15640. * Particle emitter emitting particles from the inside of a box.
  15641. * It emits the particles randomly between 2 given directions.
  15642. */
  15643. export class BoxParticleEmitter implements IParticleEmitterType {
  15644. /**
  15645. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15646. */
  15647. direction1: Vector3;
  15648. /**
  15649. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15650. */
  15651. direction2: Vector3;
  15652. /**
  15653. * 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.
  15654. */
  15655. minEmitBox: Vector3;
  15656. /**
  15657. * 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.
  15658. */
  15659. maxEmitBox: Vector3;
  15660. /**
  15661. * Creates a new instance BoxParticleEmitter
  15662. */
  15663. constructor();
  15664. /**
  15665. * Called by the particle System when the direction is computed for the created particle.
  15666. * @param worldMatrix is the world matrix of the particle system
  15667. * @param directionToUpdate is the direction vector to update with the result
  15668. * @param particle is the particle we are computed the direction for
  15669. * @param isLocal defines if the direction should be set in local space
  15670. */
  15671. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15672. /**
  15673. * Called by the particle System when the position is computed for the created particle.
  15674. * @param worldMatrix is the world matrix of the particle system
  15675. * @param positionToUpdate is the position vector to update with the result
  15676. * @param particle is the particle we are computed the position for
  15677. * @param isLocal defines if the position should be set in local space
  15678. */
  15679. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15680. /**
  15681. * Clones the current emitter and returns a copy of it
  15682. * @returns the new emitter
  15683. */
  15684. clone(): BoxParticleEmitter;
  15685. /**
  15686. * Called by the GPUParticleSystem to setup the update shader
  15687. * @param effect defines the update shader
  15688. */
  15689. applyToShader(effect: Effect): void;
  15690. /**
  15691. * Returns a string to use to update the GPU particles update shader
  15692. * @returns a string containng the defines string
  15693. */
  15694. getEffectDefines(): string;
  15695. /**
  15696. * Returns the string "BoxParticleEmitter"
  15697. * @returns a string containing the class name
  15698. */
  15699. getClassName(): string;
  15700. /**
  15701. * Serializes the particle system to a JSON object.
  15702. * @returns the JSON object
  15703. */
  15704. serialize(): any;
  15705. /**
  15706. * Parse properties from a JSON object
  15707. * @param serializationObject defines the JSON object
  15708. */
  15709. parse(serializationObject: any): void;
  15710. }
  15711. }
  15712. declare module BABYLON {
  15713. /**
  15714. * Particle emitter emitting particles from the inside of a cone.
  15715. * It emits the particles alongside the cone volume from the base to the particle.
  15716. * The emission direction might be randomized.
  15717. */
  15718. export class ConeParticleEmitter implements IParticleEmitterType {
  15719. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15720. directionRandomizer: number;
  15721. private _radius;
  15722. private _angle;
  15723. private _height;
  15724. /**
  15725. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15726. */
  15727. radiusRange: number;
  15728. /**
  15729. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15730. */
  15731. heightRange: number;
  15732. /**
  15733. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15734. */
  15735. emitFromSpawnPointOnly: boolean;
  15736. /**
  15737. * Gets or sets the radius of the emission cone
  15738. */
  15739. get radius(): number;
  15740. set radius(value: number);
  15741. /**
  15742. * Gets or sets the angle of the emission cone
  15743. */
  15744. get angle(): number;
  15745. set angle(value: number);
  15746. private _buildHeight;
  15747. /**
  15748. * Creates a new instance ConeParticleEmitter
  15749. * @param radius the radius of the emission cone (1 by default)
  15750. * @param angle the cone base angle (PI by default)
  15751. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15752. */
  15753. constructor(radius?: number, angle?: number,
  15754. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15755. directionRandomizer?: number);
  15756. /**
  15757. * Called by the particle System when the direction is computed for the created particle.
  15758. * @param worldMatrix is the world matrix of the particle system
  15759. * @param directionToUpdate is the direction vector to update with the result
  15760. * @param particle is the particle we are computed the direction for
  15761. * @param isLocal defines if the direction should be set in local space
  15762. */
  15763. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15764. /**
  15765. * Called by the particle System when the position is computed for the created particle.
  15766. * @param worldMatrix is the world matrix of the particle system
  15767. * @param positionToUpdate is the position vector to update with the result
  15768. * @param particle is the particle we are computed the position for
  15769. * @param isLocal defines if the position should be set in local space
  15770. */
  15771. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15772. /**
  15773. * Clones the current emitter and returns a copy of it
  15774. * @returns the new emitter
  15775. */
  15776. clone(): ConeParticleEmitter;
  15777. /**
  15778. * Called by the GPUParticleSystem to setup the update shader
  15779. * @param effect defines the update shader
  15780. */
  15781. applyToShader(effect: Effect): void;
  15782. /**
  15783. * Returns a string to use to update the GPU particles update shader
  15784. * @returns a string containng the defines string
  15785. */
  15786. getEffectDefines(): string;
  15787. /**
  15788. * Returns the string "ConeParticleEmitter"
  15789. * @returns a string containing the class name
  15790. */
  15791. getClassName(): string;
  15792. /**
  15793. * Serializes the particle system to a JSON object.
  15794. * @returns the JSON object
  15795. */
  15796. serialize(): any;
  15797. /**
  15798. * Parse properties from a JSON object
  15799. * @param serializationObject defines the JSON object
  15800. */
  15801. parse(serializationObject: any): void;
  15802. }
  15803. }
  15804. declare module BABYLON {
  15805. /**
  15806. * Particle emitter emitting particles from the inside of a cylinder.
  15807. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15808. */
  15809. export class CylinderParticleEmitter implements IParticleEmitterType {
  15810. /**
  15811. * The radius of the emission cylinder.
  15812. */
  15813. radius: number;
  15814. /**
  15815. * The height of the emission cylinder.
  15816. */
  15817. height: number;
  15818. /**
  15819. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15820. */
  15821. radiusRange: number;
  15822. /**
  15823. * How much to randomize the particle direction [0-1].
  15824. */
  15825. directionRandomizer: number;
  15826. /**
  15827. * Creates a new instance CylinderParticleEmitter
  15828. * @param radius the radius of the emission cylinder (1 by default)
  15829. * @param height the height of the emission cylinder (1 by default)
  15830. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15831. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15832. */
  15833. constructor(
  15834. /**
  15835. * The radius of the emission cylinder.
  15836. */
  15837. radius?: number,
  15838. /**
  15839. * The height of the emission cylinder.
  15840. */
  15841. height?: number,
  15842. /**
  15843. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15844. */
  15845. radiusRange?: number,
  15846. /**
  15847. * How much to randomize the particle direction [0-1].
  15848. */
  15849. directionRandomizer?: number);
  15850. /**
  15851. * Called by the particle System when the direction is computed for the created particle.
  15852. * @param worldMatrix is the world matrix of the particle system
  15853. * @param directionToUpdate is the direction vector to update with the result
  15854. * @param particle is the particle we are computed the direction for
  15855. * @param isLocal defines if the direction should be set in local space
  15856. */
  15857. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15858. /**
  15859. * Called by the particle System when the position is computed for the created particle.
  15860. * @param worldMatrix is the world matrix of the particle system
  15861. * @param positionToUpdate is the position vector to update with the result
  15862. * @param particle is the particle we are computed the position for
  15863. * @param isLocal defines if the position should be set in local space
  15864. */
  15865. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15866. /**
  15867. * Clones the current emitter and returns a copy of it
  15868. * @returns the new emitter
  15869. */
  15870. clone(): CylinderParticleEmitter;
  15871. /**
  15872. * Called by the GPUParticleSystem to setup the update shader
  15873. * @param effect defines the update shader
  15874. */
  15875. applyToShader(effect: Effect): void;
  15876. /**
  15877. * Returns a string to use to update the GPU particles update shader
  15878. * @returns a string containng the defines string
  15879. */
  15880. getEffectDefines(): string;
  15881. /**
  15882. * Returns the string "CylinderParticleEmitter"
  15883. * @returns a string containing the class name
  15884. */
  15885. getClassName(): string;
  15886. /**
  15887. * Serializes the particle system to a JSON object.
  15888. * @returns the JSON object
  15889. */
  15890. serialize(): any;
  15891. /**
  15892. * Parse properties from a JSON object
  15893. * @param serializationObject defines the JSON object
  15894. */
  15895. parse(serializationObject: any): void;
  15896. }
  15897. /**
  15898. * Particle emitter emitting particles from the inside of a cylinder.
  15899. * It emits the particles randomly between two vectors.
  15900. */
  15901. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15902. /**
  15903. * The min limit of the emission direction.
  15904. */
  15905. direction1: Vector3;
  15906. /**
  15907. * The max limit of the emission direction.
  15908. */
  15909. direction2: Vector3;
  15910. /**
  15911. * Creates a new instance CylinderDirectedParticleEmitter
  15912. * @param radius the radius of the emission cylinder (1 by default)
  15913. * @param height the height of the emission cylinder (1 by default)
  15914. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15915. * @param direction1 the min limit of the emission direction (up vector by default)
  15916. * @param direction2 the max limit of the emission direction (up vector by default)
  15917. */
  15918. constructor(radius?: number, height?: number, radiusRange?: number,
  15919. /**
  15920. * The min limit of the emission direction.
  15921. */
  15922. direction1?: Vector3,
  15923. /**
  15924. * The max limit of the emission direction.
  15925. */
  15926. direction2?: Vector3);
  15927. /**
  15928. * Called by the particle System when the direction is computed for the created particle.
  15929. * @param worldMatrix is the world matrix of the particle system
  15930. * @param directionToUpdate is the direction vector to update with the result
  15931. * @param particle is the particle we are computed the direction for
  15932. */
  15933. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15934. /**
  15935. * Clones the current emitter and returns a copy of it
  15936. * @returns the new emitter
  15937. */
  15938. clone(): CylinderDirectedParticleEmitter;
  15939. /**
  15940. * Called by the GPUParticleSystem to setup the update shader
  15941. * @param effect defines the update shader
  15942. */
  15943. applyToShader(effect: Effect): void;
  15944. /**
  15945. * Returns a string to use to update the GPU particles update shader
  15946. * @returns a string containng the defines string
  15947. */
  15948. getEffectDefines(): string;
  15949. /**
  15950. * Returns the string "CylinderDirectedParticleEmitter"
  15951. * @returns a string containing the class name
  15952. */
  15953. getClassName(): string;
  15954. /**
  15955. * Serializes the particle system to a JSON object.
  15956. * @returns the JSON object
  15957. */
  15958. serialize(): any;
  15959. /**
  15960. * Parse properties from a JSON object
  15961. * @param serializationObject defines the JSON object
  15962. */
  15963. parse(serializationObject: any): void;
  15964. }
  15965. }
  15966. declare module BABYLON {
  15967. /**
  15968. * Particle emitter emitting particles from the inside of a hemisphere.
  15969. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15970. */
  15971. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15972. /**
  15973. * The radius of the emission hemisphere.
  15974. */
  15975. radius: number;
  15976. /**
  15977. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15978. */
  15979. radiusRange: number;
  15980. /**
  15981. * How much to randomize the particle direction [0-1].
  15982. */
  15983. directionRandomizer: number;
  15984. /**
  15985. * Creates a new instance HemisphericParticleEmitter
  15986. * @param radius the radius of the emission hemisphere (1 by default)
  15987. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15988. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15989. */
  15990. constructor(
  15991. /**
  15992. * The radius of the emission hemisphere.
  15993. */
  15994. radius?: number,
  15995. /**
  15996. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15997. */
  15998. radiusRange?: number,
  15999. /**
  16000. * How much to randomize the particle direction [0-1].
  16001. */
  16002. directionRandomizer?: number);
  16003. /**
  16004. * Called by the particle System when the direction is computed for the created particle.
  16005. * @param worldMatrix is the world matrix of the particle system
  16006. * @param directionToUpdate is the direction vector to update with the result
  16007. * @param particle is the particle we are computed the direction for
  16008. * @param isLocal defines if the direction should be set in local space
  16009. */
  16010. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16011. /**
  16012. * Called by the particle System when the position is computed for the created particle.
  16013. * @param worldMatrix is the world matrix of the particle system
  16014. * @param positionToUpdate is the position vector to update with the result
  16015. * @param particle is the particle we are computed the position for
  16016. * @param isLocal defines if the position should be set in local space
  16017. */
  16018. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16019. /**
  16020. * Clones the current emitter and returns a copy of it
  16021. * @returns the new emitter
  16022. */
  16023. clone(): HemisphericParticleEmitter;
  16024. /**
  16025. * Called by the GPUParticleSystem to setup the update shader
  16026. * @param effect defines the update shader
  16027. */
  16028. applyToShader(effect: Effect): void;
  16029. /**
  16030. * Returns a string to use to update the GPU particles update shader
  16031. * @returns a string containng the defines string
  16032. */
  16033. getEffectDefines(): string;
  16034. /**
  16035. * Returns the string "HemisphericParticleEmitter"
  16036. * @returns a string containing the class name
  16037. */
  16038. getClassName(): string;
  16039. /**
  16040. * Serializes the particle system to a JSON object.
  16041. * @returns the JSON object
  16042. */
  16043. serialize(): any;
  16044. /**
  16045. * Parse properties from a JSON object
  16046. * @param serializationObject defines the JSON object
  16047. */
  16048. parse(serializationObject: any): void;
  16049. }
  16050. }
  16051. declare module BABYLON {
  16052. /**
  16053. * Particle emitter emitting particles from a point.
  16054. * It emits the particles randomly between 2 given directions.
  16055. */
  16056. export class PointParticleEmitter implements IParticleEmitterType {
  16057. /**
  16058. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16059. */
  16060. direction1: Vector3;
  16061. /**
  16062. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16063. */
  16064. direction2: Vector3;
  16065. /**
  16066. * Creates a new instance PointParticleEmitter
  16067. */
  16068. constructor();
  16069. /**
  16070. * Called by the particle System when the direction is computed for the created particle.
  16071. * @param worldMatrix is the world matrix of the particle system
  16072. * @param directionToUpdate is the direction vector to update with the result
  16073. * @param particle is the particle we are computed the direction for
  16074. * @param isLocal defines if the direction should be set in local space
  16075. */
  16076. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16077. /**
  16078. * Called by the particle System when the position is computed for the created particle.
  16079. * @param worldMatrix is the world matrix of the particle system
  16080. * @param positionToUpdate is the position vector to update with the result
  16081. * @param particle is the particle we are computed the position for
  16082. * @param isLocal defines if the position should be set in local space
  16083. */
  16084. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16085. /**
  16086. * Clones the current emitter and returns a copy of it
  16087. * @returns the new emitter
  16088. */
  16089. clone(): PointParticleEmitter;
  16090. /**
  16091. * Called by the GPUParticleSystem to setup the update shader
  16092. * @param effect defines the update shader
  16093. */
  16094. applyToShader(effect: Effect): void;
  16095. /**
  16096. * Returns a string to use to update the GPU particles update shader
  16097. * @returns a string containng the defines string
  16098. */
  16099. getEffectDefines(): string;
  16100. /**
  16101. * Returns the string "PointParticleEmitter"
  16102. * @returns a string containing the class name
  16103. */
  16104. getClassName(): string;
  16105. /**
  16106. * Serializes the particle system to a JSON object.
  16107. * @returns the JSON object
  16108. */
  16109. serialize(): any;
  16110. /**
  16111. * Parse properties from a JSON object
  16112. * @param serializationObject defines the JSON object
  16113. */
  16114. parse(serializationObject: any): void;
  16115. }
  16116. }
  16117. declare module BABYLON {
  16118. /**
  16119. * Particle emitter emitting particles from the inside of a sphere.
  16120. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16121. */
  16122. export class SphereParticleEmitter implements IParticleEmitterType {
  16123. /**
  16124. * The radius of the emission sphere.
  16125. */
  16126. radius: number;
  16127. /**
  16128. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16129. */
  16130. radiusRange: number;
  16131. /**
  16132. * How much to randomize the particle direction [0-1].
  16133. */
  16134. directionRandomizer: number;
  16135. /**
  16136. * Creates a new instance SphereParticleEmitter
  16137. * @param radius the radius of the emission sphere (1 by default)
  16138. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16139. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16140. */
  16141. constructor(
  16142. /**
  16143. * The radius of the emission sphere.
  16144. */
  16145. radius?: number,
  16146. /**
  16147. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16148. */
  16149. radiusRange?: number,
  16150. /**
  16151. * How much to randomize the particle direction [0-1].
  16152. */
  16153. directionRandomizer?: number);
  16154. /**
  16155. * Called by the particle System when the direction is computed for the created particle.
  16156. * @param worldMatrix is the world matrix of the particle system
  16157. * @param directionToUpdate is the direction vector to update with the result
  16158. * @param particle is the particle we are computed the direction for
  16159. * @param isLocal defines if the direction should be set in local space
  16160. */
  16161. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16162. /**
  16163. * Called by the particle System when the position is computed for the created particle.
  16164. * @param worldMatrix is the world matrix of the particle system
  16165. * @param positionToUpdate is the position vector to update with the result
  16166. * @param particle is the particle we are computed the position for
  16167. * @param isLocal defines if the position should be set in local space
  16168. */
  16169. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16170. /**
  16171. * Clones the current emitter and returns a copy of it
  16172. * @returns the new emitter
  16173. */
  16174. clone(): SphereParticleEmitter;
  16175. /**
  16176. * Called by the GPUParticleSystem to setup the update shader
  16177. * @param effect defines the update shader
  16178. */
  16179. applyToShader(effect: Effect): void;
  16180. /**
  16181. * Returns a string to use to update the GPU particles update shader
  16182. * @returns a string containng the defines string
  16183. */
  16184. getEffectDefines(): string;
  16185. /**
  16186. * Returns the string "SphereParticleEmitter"
  16187. * @returns a string containing the class name
  16188. */
  16189. getClassName(): string;
  16190. /**
  16191. * Serializes the particle system to a JSON object.
  16192. * @returns the JSON object
  16193. */
  16194. serialize(): any;
  16195. /**
  16196. * Parse properties from a JSON object
  16197. * @param serializationObject defines the JSON object
  16198. */
  16199. parse(serializationObject: any): void;
  16200. }
  16201. /**
  16202. * Particle emitter emitting particles from the inside of a sphere.
  16203. * It emits the particles randomly between two vectors.
  16204. */
  16205. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16206. /**
  16207. * The min limit of the emission direction.
  16208. */
  16209. direction1: Vector3;
  16210. /**
  16211. * The max limit of the emission direction.
  16212. */
  16213. direction2: Vector3;
  16214. /**
  16215. * Creates a new instance SphereDirectedParticleEmitter
  16216. * @param radius the radius of the emission sphere (1 by default)
  16217. * @param direction1 the min limit of the emission direction (up vector by default)
  16218. * @param direction2 the max limit of the emission direction (up vector by default)
  16219. */
  16220. constructor(radius?: number,
  16221. /**
  16222. * The min limit of the emission direction.
  16223. */
  16224. direction1?: Vector3,
  16225. /**
  16226. * The max limit of the emission direction.
  16227. */
  16228. direction2?: Vector3);
  16229. /**
  16230. * Called by the particle System when the direction is computed for the created particle.
  16231. * @param worldMatrix is the world matrix of the particle system
  16232. * @param directionToUpdate is the direction vector to update with the result
  16233. * @param particle is the particle we are computed the direction for
  16234. */
  16235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16236. /**
  16237. * Clones the current emitter and returns a copy of it
  16238. * @returns the new emitter
  16239. */
  16240. clone(): SphereDirectedParticleEmitter;
  16241. /**
  16242. * Called by the GPUParticleSystem to setup the update shader
  16243. * @param effect defines the update shader
  16244. */
  16245. applyToShader(effect: Effect): void;
  16246. /**
  16247. * Returns a string to use to update the GPU particles update shader
  16248. * @returns a string containng the defines string
  16249. */
  16250. getEffectDefines(): string;
  16251. /**
  16252. * Returns the string "SphereDirectedParticleEmitter"
  16253. * @returns a string containing the class name
  16254. */
  16255. getClassName(): string;
  16256. /**
  16257. * Serializes the particle system to a JSON object.
  16258. * @returns the JSON object
  16259. */
  16260. serialize(): any;
  16261. /**
  16262. * Parse properties from a JSON object
  16263. * @param serializationObject defines the JSON object
  16264. */
  16265. parse(serializationObject: any): void;
  16266. }
  16267. }
  16268. declare module BABYLON {
  16269. /**
  16270. * Particle emitter emitting particles from a custom list of positions.
  16271. */
  16272. export class CustomParticleEmitter implements IParticleEmitterType {
  16273. /**
  16274. * Gets or sets the position generator that will create the inital position of each particle.
  16275. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16276. */
  16277. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16278. /**
  16279. * Gets or sets the destination generator that will create the final destination of each particle.
  16280. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16281. */
  16282. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16283. /**
  16284. * Creates a new instance CustomParticleEmitter
  16285. */
  16286. constructor();
  16287. /**
  16288. * Called by the particle System when the direction is computed for the created particle.
  16289. * @param worldMatrix is the world matrix of the particle system
  16290. * @param directionToUpdate is the direction vector to update with the result
  16291. * @param particle is the particle we are computed the direction for
  16292. * @param isLocal defines if the direction should be set in local space
  16293. */
  16294. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16295. /**
  16296. * Called by the particle System when the position is computed for the created particle.
  16297. * @param worldMatrix is the world matrix of the particle system
  16298. * @param positionToUpdate is the position vector to update with the result
  16299. * @param particle is the particle we are computed the position for
  16300. * @param isLocal defines if the position should be set in local space
  16301. */
  16302. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16303. /**
  16304. * Clones the current emitter and returns a copy of it
  16305. * @returns the new emitter
  16306. */
  16307. clone(): CustomParticleEmitter;
  16308. /**
  16309. * Called by the GPUParticleSystem to setup the update shader
  16310. * @param effect defines the update shader
  16311. */
  16312. applyToShader(effect: Effect): void;
  16313. /**
  16314. * Returns a string to use to update the GPU particles update shader
  16315. * @returns a string containng the defines string
  16316. */
  16317. getEffectDefines(): string;
  16318. /**
  16319. * Returns the string "PointParticleEmitter"
  16320. * @returns a string containing the class name
  16321. */
  16322. getClassName(): string;
  16323. /**
  16324. * Serializes the particle system to a JSON object.
  16325. * @returns the JSON object
  16326. */
  16327. serialize(): any;
  16328. /**
  16329. * Parse properties from a JSON object
  16330. * @param serializationObject defines the JSON object
  16331. */
  16332. parse(serializationObject: any): void;
  16333. }
  16334. }
  16335. declare module BABYLON {
  16336. /**
  16337. * Particle emitter emitting particles from the inside of a box.
  16338. * It emits the particles randomly between 2 given directions.
  16339. */
  16340. export class MeshParticleEmitter implements IParticleEmitterType {
  16341. private _indices;
  16342. private _positions;
  16343. private _normals;
  16344. private _storedNormal;
  16345. private _mesh;
  16346. /**
  16347. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16348. */
  16349. direction1: Vector3;
  16350. /**
  16351. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16352. */
  16353. direction2: Vector3;
  16354. /**
  16355. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16356. */
  16357. useMeshNormalsForDirection: boolean;
  16358. /** Defines the mesh to use as source */
  16359. get mesh(): Nullable<AbstractMesh>;
  16360. set mesh(value: Nullable<AbstractMesh>);
  16361. /**
  16362. * Creates a new instance MeshParticleEmitter
  16363. * @param mesh defines the mesh to use as source
  16364. */
  16365. constructor(mesh?: Nullable<AbstractMesh>);
  16366. /**
  16367. * Called by the particle System when the direction is computed for the created particle.
  16368. * @param worldMatrix is the world matrix of the particle system
  16369. * @param directionToUpdate is the direction vector to update with the result
  16370. * @param particle is the particle we are computed the direction for
  16371. * @param isLocal defines if the direction should be set in local space
  16372. */
  16373. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16374. /**
  16375. * Called by the particle System when the position is computed for the created particle.
  16376. * @param worldMatrix is the world matrix of the particle system
  16377. * @param positionToUpdate is the position vector to update with the result
  16378. * @param particle is the particle we are computed the position for
  16379. * @param isLocal defines if the position should be set in local space
  16380. */
  16381. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16382. /**
  16383. * Clones the current emitter and returns a copy of it
  16384. * @returns the new emitter
  16385. */
  16386. clone(): MeshParticleEmitter;
  16387. /**
  16388. * Called by the GPUParticleSystem to setup the update shader
  16389. * @param effect defines the update shader
  16390. */
  16391. applyToShader(effect: Effect): void;
  16392. /**
  16393. * Returns a string to use to update the GPU particles update shader
  16394. * @returns a string containng the defines string
  16395. */
  16396. getEffectDefines(): string;
  16397. /**
  16398. * Returns the string "BoxParticleEmitter"
  16399. * @returns a string containing the class name
  16400. */
  16401. getClassName(): string;
  16402. /**
  16403. * Serializes the particle system to a JSON object.
  16404. * @returns the JSON object
  16405. */
  16406. serialize(): any;
  16407. /**
  16408. * Parse properties from a JSON object
  16409. * @param serializationObject defines the JSON object
  16410. * @param scene defines the hosting scene
  16411. */
  16412. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16413. }
  16414. }
  16415. declare module BABYLON {
  16416. /**
  16417. * Interface representing a particle system in Babylon.js.
  16418. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16419. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16420. */
  16421. export interface IParticleSystem {
  16422. /**
  16423. * List of animations used by the particle system.
  16424. */
  16425. animations: Animation[];
  16426. /**
  16427. * The id of the Particle system.
  16428. */
  16429. id: string;
  16430. /**
  16431. * The name of the Particle system.
  16432. */
  16433. name: string;
  16434. /**
  16435. * The emitter represents the Mesh or position we are attaching the particle system to.
  16436. */
  16437. emitter: Nullable<AbstractMesh | Vector3>;
  16438. /**
  16439. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16440. */
  16441. isBillboardBased: boolean;
  16442. /**
  16443. * The rendering group used by the Particle system to chose when to render.
  16444. */
  16445. renderingGroupId: number;
  16446. /**
  16447. * The layer mask we are rendering the particles through.
  16448. */
  16449. layerMask: number;
  16450. /**
  16451. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16452. */
  16453. updateSpeed: number;
  16454. /**
  16455. * The amount of time the particle system is running (depends of the overall update speed).
  16456. */
  16457. targetStopDuration: number;
  16458. /**
  16459. * The texture used to render each particle. (this can be a spritesheet)
  16460. */
  16461. particleTexture: Nullable<BaseTexture>;
  16462. /**
  16463. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16464. */
  16465. blendMode: number;
  16466. /**
  16467. * Minimum life time of emitting particles.
  16468. */
  16469. minLifeTime: number;
  16470. /**
  16471. * Maximum life time of emitting particles.
  16472. */
  16473. maxLifeTime: number;
  16474. /**
  16475. * Minimum Size of emitting particles.
  16476. */
  16477. minSize: number;
  16478. /**
  16479. * Maximum Size of emitting particles.
  16480. */
  16481. maxSize: number;
  16482. /**
  16483. * Minimum scale of emitting particles on X axis.
  16484. */
  16485. minScaleX: number;
  16486. /**
  16487. * Maximum scale of emitting particles on X axis.
  16488. */
  16489. maxScaleX: number;
  16490. /**
  16491. * Minimum scale of emitting particles on Y axis.
  16492. */
  16493. minScaleY: number;
  16494. /**
  16495. * Maximum scale of emitting particles on Y axis.
  16496. */
  16497. maxScaleY: number;
  16498. /**
  16499. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16500. */
  16501. color1: Color4;
  16502. /**
  16503. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16504. */
  16505. color2: Color4;
  16506. /**
  16507. * Color the particle will have at the end of its lifetime.
  16508. */
  16509. colorDead: Color4;
  16510. /**
  16511. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16512. */
  16513. emitRate: number;
  16514. /**
  16515. * You can use gravity if you want to give an orientation to your particles.
  16516. */
  16517. gravity: Vector3;
  16518. /**
  16519. * Minimum power of emitting particles.
  16520. */
  16521. minEmitPower: number;
  16522. /**
  16523. * Maximum power of emitting particles.
  16524. */
  16525. maxEmitPower: number;
  16526. /**
  16527. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16528. */
  16529. minAngularSpeed: number;
  16530. /**
  16531. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16532. */
  16533. maxAngularSpeed: number;
  16534. /**
  16535. * Gets or sets the minimal initial rotation in radians.
  16536. */
  16537. minInitialRotation: number;
  16538. /**
  16539. * Gets or sets the maximal initial rotation in radians.
  16540. */
  16541. maxInitialRotation: number;
  16542. /**
  16543. * The particle emitter type defines the emitter used by the particle system.
  16544. * It can be for example box, sphere, or cone...
  16545. */
  16546. particleEmitterType: Nullable<IParticleEmitterType>;
  16547. /**
  16548. * Defines the delay in milliseconds before starting the system (0 by default)
  16549. */
  16550. startDelay: number;
  16551. /**
  16552. * 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
  16553. */
  16554. preWarmCycles: number;
  16555. /**
  16556. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16557. */
  16558. preWarmStepOffset: number;
  16559. /**
  16560. * 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)
  16561. */
  16562. spriteCellChangeSpeed: number;
  16563. /**
  16564. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16565. */
  16566. startSpriteCellID: number;
  16567. /**
  16568. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16569. */
  16570. endSpriteCellID: number;
  16571. /**
  16572. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16573. */
  16574. spriteCellWidth: number;
  16575. /**
  16576. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16577. */
  16578. spriteCellHeight: number;
  16579. /**
  16580. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16581. */
  16582. spriteRandomStartCell: boolean;
  16583. /**
  16584. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16585. */
  16586. isAnimationSheetEnabled: boolean;
  16587. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16588. translationPivot: Vector2;
  16589. /**
  16590. * Gets or sets a texture used to add random noise to particle positions
  16591. */
  16592. noiseTexture: Nullable<BaseTexture>;
  16593. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16594. noiseStrength: Vector3;
  16595. /**
  16596. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16597. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16598. */
  16599. billboardMode: number;
  16600. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16601. limitVelocityDamping: number;
  16602. /**
  16603. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16604. */
  16605. beginAnimationOnStart: boolean;
  16606. /**
  16607. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16608. */
  16609. beginAnimationFrom: number;
  16610. /**
  16611. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16612. */
  16613. beginAnimationTo: number;
  16614. /**
  16615. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16616. */
  16617. beginAnimationLoop: boolean;
  16618. /**
  16619. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16620. */
  16621. disposeOnStop: boolean;
  16622. /**
  16623. * Specifies if the particles are updated in emitter local space or world space
  16624. */
  16625. isLocal: boolean;
  16626. /** Snippet ID if the particle system was created from the snippet server */
  16627. snippetId: string;
  16628. /** Gets or sets a matrix to use to compute projection */
  16629. defaultProjectionMatrix: Matrix;
  16630. /**
  16631. * Gets the maximum number of particles active at the same time.
  16632. * @returns The max number of active particles.
  16633. */
  16634. getCapacity(): number;
  16635. /**
  16636. * Gets the number of particles active at the same time.
  16637. * @returns The number of active particles.
  16638. */
  16639. getActiveCount(): number;
  16640. /**
  16641. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16642. * @returns True if it has been started, otherwise false.
  16643. */
  16644. isStarted(): boolean;
  16645. /**
  16646. * Animates the particle system for this frame.
  16647. */
  16648. animate(): void;
  16649. /**
  16650. * Renders the particle system in its current state.
  16651. * @returns the current number of particles
  16652. */
  16653. render(): number;
  16654. /**
  16655. * Dispose the particle system and frees its associated resources.
  16656. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16657. */
  16658. dispose(disposeTexture?: boolean): void;
  16659. /**
  16660. * An event triggered when the system is disposed
  16661. */
  16662. onDisposeObservable: Observable<IParticleSystem>;
  16663. /**
  16664. * An event triggered when the system is stopped
  16665. */
  16666. onStoppedObservable: Observable<IParticleSystem>;
  16667. /**
  16668. * Clones the particle system.
  16669. * @param name The name of the cloned object
  16670. * @param newEmitter The new emitter to use
  16671. * @returns the cloned particle system
  16672. */
  16673. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16674. /**
  16675. * Serializes the particle system to a JSON object
  16676. * @param serializeTexture defines if the texture must be serialized as well
  16677. * @returns the JSON object
  16678. */
  16679. serialize(serializeTexture: boolean): any;
  16680. /**
  16681. * Rebuild the particle system
  16682. */
  16683. rebuild(): void;
  16684. /** Force the system to rebuild all gradients that need to be resync */
  16685. forceRefreshGradients(): void;
  16686. /**
  16687. * Starts the particle system and begins to emit
  16688. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16689. */
  16690. start(delay?: number): void;
  16691. /**
  16692. * Stops the particle system.
  16693. */
  16694. stop(): void;
  16695. /**
  16696. * Remove all active particles
  16697. */
  16698. reset(): void;
  16699. /**
  16700. * Gets a boolean indicating that the system is stopping
  16701. * @returns true if the system is currently stopping
  16702. */
  16703. isStopping(): boolean;
  16704. /**
  16705. * Is this system ready to be used/rendered
  16706. * @return true if the system is ready
  16707. */
  16708. isReady(): boolean;
  16709. /**
  16710. * Returns the string "ParticleSystem"
  16711. * @returns a string containing the class name
  16712. */
  16713. getClassName(): string;
  16714. /**
  16715. * Gets the custom effect used to render the particles
  16716. * @param blendMode Blend mode for which the effect should be retrieved
  16717. * @returns The effect
  16718. */
  16719. getCustomEffect(blendMode: number): Nullable<Effect>;
  16720. /**
  16721. * Sets the custom effect used to render the particles
  16722. * @param effect The effect to set
  16723. * @param blendMode Blend mode for which the effect should be set
  16724. */
  16725. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  16726. /**
  16727. * Fill the defines array according to the current settings of the particle system
  16728. * @param defines Array to be updated
  16729. * @param blendMode blend mode to take into account when updating the array
  16730. */
  16731. fillDefines(defines: Array<string>, blendMode: number): void;
  16732. /**
  16733. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16734. * @param uniforms Uniforms array to fill
  16735. * @param attributes Attributes array to fill
  16736. * @param samplers Samplers array to fill
  16737. */
  16738. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16739. /**
  16740. * Observable that will be called just before the particles are drawn
  16741. */
  16742. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  16743. /**
  16744. * Gets the name of the particle vertex shader
  16745. */
  16746. vertexShaderName: string;
  16747. /**
  16748. * Adds a new color gradient
  16749. * @param gradient defines the gradient to use (between 0 and 1)
  16750. * @param color1 defines the color to affect to the specified gradient
  16751. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16752. * @returns the current particle system
  16753. */
  16754. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16755. /**
  16756. * Remove a specific color gradient
  16757. * @param gradient defines the gradient to remove
  16758. * @returns the current particle system
  16759. */
  16760. removeColorGradient(gradient: number): IParticleSystem;
  16761. /**
  16762. * Adds a new size gradient
  16763. * @param gradient defines the gradient to use (between 0 and 1)
  16764. * @param factor defines the size factor to affect to the specified gradient
  16765. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16766. * @returns the current particle system
  16767. */
  16768. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16769. /**
  16770. * Remove a specific size gradient
  16771. * @param gradient defines the gradient to remove
  16772. * @returns the current particle system
  16773. */
  16774. removeSizeGradient(gradient: number): IParticleSystem;
  16775. /**
  16776. * Gets the current list of color gradients.
  16777. * You must use addColorGradient and removeColorGradient to udpate this list
  16778. * @returns the list of color gradients
  16779. */
  16780. getColorGradients(): Nullable<Array<ColorGradient>>;
  16781. /**
  16782. * Gets the current list of size gradients.
  16783. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16784. * @returns the list of size gradients
  16785. */
  16786. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16787. /**
  16788. * Gets the current list of angular speed gradients.
  16789. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16790. * @returns the list of angular speed gradients
  16791. */
  16792. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16793. /**
  16794. * Adds a new angular speed gradient
  16795. * @param gradient defines the gradient to use (between 0 and 1)
  16796. * @param factor defines the angular speed to affect to the specified gradient
  16797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16798. * @returns the current particle system
  16799. */
  16800. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16801. /**
  16802. * Remove a specific angular speed gradient
  16803. * @param gradient defines the gradient to remove
  16804. * @returns the current particle system
  16805. */
  16806. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16807. /**
  16808. * Gets the current list of velocity gradients.
  16809. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16810. * @returns the list of velocity gradients
  16811. */
  16812. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16813. /**
  16814. * Adds a new velocity gradient
  16815. * @param gradient defines the gradient to use (between 0 and 1)
  16816. * @param factor defines the velocity to affect to the specified gradient
  16817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16818. * @returns the current particle system
  16819. */
  16820. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16821. /**
  16822. * Remove a specific velocity gradient
  16823. * @param gradient defines the gradient to remove
  16824. * @returns the current particle system
  16825. */
  16826. removeVelocityGradient(gradient: number): IParticleSystem;
  16827. /**
  16828. * Gets the current list of limit velocity gradients.
  16829. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16830. * @returns the list of limit velocity gradients
  16831. */
  16832. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16833. /**
  16834. * Adds a new limit velocity gradient
  16835. * @param gradient defines the gradient to use (between 0 and 1)
  16836. * @param factor defines the limit velocity to affect to the specified gradient
  16837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16838. * @returns the current particle system
  16839. */
  16840. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16841. /**
  16842. * Remove a specific limit velocity gradient
  16843. * @param gradient defines the gradient to remove
  16844. * @returns the current particle system
  16845. */
  16846. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16847. /**
  16848. * Adds a new drag gradient
  16849. * @param gradient defines the gradient to use (between 0 and 1)
  16850. * @param factor defines the drag to affect to the specified gradient
  16851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16852. * @returns the current particle system
  16853. */
  16854. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16855. /**
  16856. * Remove a specific drag gradient
  16857. * @param gradient defines the gradient to remove
  16858. * @returns the current particle system
  16859. */
  16860. removeDragGradient(gradient: number): IParticleSystem;
  16861. /**
  16862. * Gets the current list of drag gradients.
  16863. * You must use addDragGradient and removeDragGradient to udpate this list
  16864. * @returns the list of drag gradients
  16865. */
  16866. getDragGradients(): Nullable<Array<FactorGradient>>;
  16867. /**
  16868. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16869. * @param gradient defines the gradient to use (between 0 and 1)
  16870. * @param factor defines the emit rate to affect to the specified gradient
  16871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16872. * @returns the current particle system
  16873. */
  16874. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16875. /**
  16876. * Remove a specific emit rate gradient
  16877. * @param gradient defines the gradient to remove
  16878. * @returns the current particle system
  16879. */
  16880. removeEmitRateGradient(gradient: number): IParticleSystem;
  16881. /**
  16882. * Gets the current list of emit rate gradients.
  16883. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16884. * @returns the list of emit rate gradients
  16885. */
  16886. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16887. /**
  16888. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16889. * @param gradient defines the gradient to use (between 0 and 1)
  16890. * @param factor defines the start size to affect to the specified gradient
  16891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16892. * @returns the current particle system
  16893. */
  16894. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16895. /**
  16896. * Remove a specific start size gradient
  16897. * @param gradient defines the gradient to remove
  16898. * @returns the current particle system
  16899. */
  16900. removeStartSizeGradient(gradient: number): IParticleSystem;
  16901. /**
  16902. * Gets the current list of start size gradients.
  16903. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16904. * @returns the list of start size gradients
  16905. */
  16906. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16907. /**
  16908. * Adds a new life time gradient
  16909. * @param gradient defines the gradient to use (between 0 and 1)
  16910. * @param factor defines the life time factor to affect to the specified gradient
  16911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16912. * @returns the current particle system
  16913. */
  16914. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16915. /**
  16916. * Remove a specific life time gradient
  16917. * @param gradient defines the gradient to remove
  16918. * @returns the current particle system
  16919. */
  16920. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16921. /**
  16922. * Gets the current list of life time gradients.
  16923. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16924. * @returns the list of life time gradients
  16925. */
  16926. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16927. /**
  16928. * Gets the current list of color gradients.
  16929. * You must use addColorGradient and removeColorGradient to udpate this list
  16930. * @returns the list of color gradients
  16931. */
  16932. getColorGradients(): Nullable<Array<ColorGradient>>;
  16933. /**
  16934. * Adds a new ramp gradient used to remap particle colors
  16935. * @param gradient defines the gradient to use (between 0 and 1)
  16936. * @param color defines the color to affect to the specified gradient
  16937. * @returns the current particle system
  16938. */
  16939. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16940. /**
  16941. * Gets the current list of ramp gradients.
  16942. * You must use addRampGradient and removeRampGradient to udpate this list
  16943. * @returns the list of ramp gradients
  16944. */
  16945. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16946. /** Gets or sets a boolean indicating that ramp gradients must be used
  16947. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16948. */
  16949. useRampGradients: boolean;
  16950. /**
  16951. * Adds a new color remap gradient
  16952. * @param gradient defines the gradient to use (between 0 and 1)
  16953. * @param min defines the color remap minimal range
  16954. * @param max defines the color remap maximal range
  16955. * @returns the current particle system
  16956. */
  16957. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16958. /**
  16959. * Gets the current list of color remap gradients.
  16960. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16961. * @returns the list of color remap gradients
  16962. */
  16963. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16964. /**
  16965. * Adds a new alpha remap gradient
  16966. * @param gradient defines the gradient to use (between 0 and 1)
  16967. * @param min defines the alpha remap minimal range
  16968. * @param max defines the alpha remap maximal range
  16969. * @returns the current particle system
  16970. */
  16971. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16972. /**
  16973. * Gets the current list of alpha remap gradients.
  16974. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16975. * @returns the list of alpha remap gradients
  16976. */
  16977. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16978. /**
  16979. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16980. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16981. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16982. * @returns the emitter
  16983. */
  16984. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16985. /**
  16986. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16987. * @param radius The radius of the hemisphere to emit from
  16988. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16989. * @returns the emitter
  16990. */
  16991. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16992. /**
  16993. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16994. * @param radius The radius of the sphere to emit from
  16995. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16996. * @returns the emitter
  16997. */
  16998. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16999. /**
  17000. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17001. * @param radius The radius of the sphere to emit from
  17002. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17003. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17004. * @returns the emitter
  17005. */
  17006. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17007. /**
  17008. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17009. * @param radius The radius of the emission cylinder
  17010. * @param height The height of the emission cylinder
  17011. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17012. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17013. * @returns the emitter
  17014. */
  17015. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17016. /**
  17017. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17018. * @param radius The radius of the cylinder to emit from
  17019. * @param height The height of the emission cylinder
  17020. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17021. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17022. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17023. * @returns the emitter
  17024. */
  17025. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17026. /**
  17027. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17028. * @param radius The radius of the cone to emit from
  17029. * @param angle The base angle of the cone
  17030. * @returns the emitter
  17031. */
  17032. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17033. /**
  17034. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17035. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17036. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17037. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17038. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17039. * @returns the emitter
  17040. */
  17041. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17042. /**
  17043. * Get hosting scene
  17044. * @returns the scene
  17045. */
  17046. getScene(): Nullable<Scene>;
  17047. }
  17048. }
  17049. declare module BABYLON {
  17050. /**
  17051. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17052. */
  17053. export class ColorSplitterBlock extends NodeMaterialBlock {
  17054. /**
  17055. * Create a new ColorSplitterBlock
  17056. * @param name defines the block name
  17057. */
  17058. constructor(name: string);
  17059. /**
  17060. * Gets the current class name
  17061. * @returns the class name
  17062. */
  17063. getClassName(): string;
  17064. /**
  17065. * Gets the rgba component (input)
  17066. */
  17067. get rgba(): NodeMaterialConnectionPoint;
  17068. /**
  17069. * Gets the rgb component (input)
  17070. */
  17071. get rgbIn(): NodeMaterialConnectionPoint;
  17072. /**
  17073. * Gets the rgb component (output)
  17074. */
  17075. get rgbOut(): NodeMaterialConnectionPoint;
  17076. /**
  17077. * Gets the r component (output)
  17078. */
  17079. get r(): NodeMaterialConnectionPoint;
  17080. /**
  17081. * Gets the g component (output)
  17082. */
  17083. get g(): NodeMaterialConnectionPoint;
  17084. /**
  17085. * Gets the b component (output)
  17086. */
  17087. get b(): NodeMaterialConnectionPoint;
  17088. /**
  17089. * Gets the a component (output)
  17090. */
  17091. get a(): NodeMaterialConnectionPoint;
  17092. protected _inputRename(name: string): string;
  17093. protected _outputRename(name: string): string;
  17094. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17095. }
  17096. }
  17097. declare module BABYLON {
  17098. /**
  17099. * Operations supported by the Trigonometry block
  17100. */
  17101. export enum TrigonometryBlockOperations {
  17102. /** Cos */
  17103. Cos = 0,
  17104. /** Sin */
  17105. Sin = 1,
  17106. /** Abs */
  17107. Abs = 2,
  17108. /** Exp */
  17109. Exp = 3,
  17110. /** Exp2 */
  17111. Exp2 = 4,
  17112. /** Round */
  17113. Round = 5,
  17114. /** Floor */
  17115. Floor = 6,
  17116. /** Ceiling */
  17117. Ceiling = 7,
  17118. /** Square root */
  17119. Sqrt = 8,
  17120. /** Log */
  17121. Log = 9,
  17122. /** Tangent */
  17123. Tan = 10,
  17124. /** Arc tangent */
  17125. ArcTan = 11,
  17126. /** Arc cosinus */
  17127. ArcCos = 12,
  17128. /** Arc sinus */
  17129. ArcSin = 13,
  17130. /** Fraction */
  17131. Fract = 14,
  17132. /** Sign */
  17133. Sign = 15,
  17134. /** To radians (from degrees) */
  17135. Radians = 16,
  17136. /** To degrees (from radians) */
  17137. Degrees = 17
  17138. }
  17139. /**
  17140. * Block used to apply trigonometry operation to floats
  17141. */
  17142. export class TrigonometryBlock extends NodeMaterialBlock {
  17143. /**
  17144. * Gets or sets the operation applied by the block
  17145. */
  17146. operation: TrigonometryBlockOperations;
  17147. /**
  17148. * Creates a new TrigonometryBlock
  17149. * @param name defines the block name
  17150. */
  17151. constructor(name: string);
  17152. /**
  17153. * Gets the current class name
  17154. * @returns the class name
  17155. */
  17156. getClassName(): string;
  17157. /**
  17158. * Gets the input component
  17159. */
  17160. get input(): NodeMaterialConnectionPoint;
  17161. /**
  17162. * Gets the output component
  17163. */
  17164. get output(): NodeMaterialConnectionPoint;
  17165. protected _buildBlock(state: NodeMaterialBuildState): this;
  17166. serialize(): any;
  17167. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17168. protected _dumpPropertiesCode(): string;
  17169. }
  17170. }
  17171. declare module BABYLON {
  17172. /**
  17173. * Interface used to configure the node material editor
  17174. */
  17175. export interface INodeMaterialEditorOptions {
  17176. /** Define the URl to load node editor script */
  17177. editorURL?: string;
  17178. }
  17179. /** @hidden */
  17180. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17181. NORMAL: boolean;
  17182. TANGENT: boolean;
  17183. UV1: boolean;
  17184. /** BONES */
  17185. NUM_BONE_INFLUENCERS: number;
  17186. BonesPerMesh: number;
  17187. BONETEXTURE: boolean;
  17188. /** MORPH TARGETS */
  17189. MORPHTARGETS: boolean;
  17190. MORPHTARGETS_NORMAL: boolean;
  17191. MORPHTARGETS_TANGENT: boolean;
  17192. MORPHTARGETS_UV: boolean;
  17193. NUM_MORPH_INFLUENCERS: number;
  17194. /** IMAGE PROCESSING */
  17195. IMAGEPROCESSING: boolean;
  17196. VIGNETTE: boolean;
  17197. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17198. VIGNETTEBLENDMODEOPAQUE: boolean;
  17199. TONEMAPPING: boolean;
  17200. TONEMAPPING_ACES: boolean;
  17201. CONTRAST: boolean;
  17202. EXPOSURE: boolean;
  17203. COLORCURVES: boolean;
  17204. COLORGRADING: boolean;
  17205. COLORGRADING3D: boolean;
  17206. SAMPLER3DGREENDEPTH: boolean;
  17207. SAMPLER3DBGRMAP: boolean;
  17208. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17209. /** MISC. */
  17210. BUMPDIRECTUV: number;
  17211. constructor();
  17212. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17213. }
  17214. /**
  17215. * Class used to configure NodeMaterial
  17216. */
  17217. export interface INodeMaterialOptions {
  17218. /**
  17219. * Defines if blocks should emit comments
  17220. */
  17221. emitComments: boolean;
  17222. }
  17223. /**
  17224. * Class used to create a node based material built by assembling shader blocks
  17225. */
  17226. export class NodeMaterial extends PushMaterial {
  17227. private static _BuildIdGenerator;
  17228. private _options;
  17229. private _vertexCompilationState;
  17230. private _fragmentCompilationState;
  17231. private _sharedData;
  17232. private _buildId;
  17233. private _buildWasSuccessful;
  17234. private _cachedWorldViewMatrix;
  17235. private _cachedWorldViewProjectionMatrix;
  17236. private _optimizers;
  17237. private _animationFrame;
  17238. /** Define the Url to load node editor script */
  17239. static EditorURL: string;
  17240. /** Define the Url to load snippets */
  17241. static SnippetUrl: string;
  17242. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17243. static IgnoreTexturesAtLoadTime: boolean;
  17244. private BJSNODEMATERIALEDITOR;
  17245. /** Get the inspector from bundle or global */
  17246. private _getGlobalNodeMaterialEditor;
  17247. /**
  17248. * Snippet ID if the material was created from the snippet server
  17249. */
  17250. snippetId: string;
  17251. /**
  17252. * Gets or sets data used by visual editor
  17253. * @see https://nme.babylonjs.com
  17254. */
  17255. editorData: any;
  17256. /**
  17257. * 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)
  17258. */
  17259. ignoreAlpha: boolean;
  17260. /**
  17261. * Defines the maximum number of lights that can be used in the material
  17262. */
  17263. maxSimultaneousLights: number;
  17264. /**
  17265. * Observable raised when the material is built
  17266. */
  17267. onBuildObservable: Observable<NodeMaterial>;
  17268. /**
  17269. * Gets or sets the root nodes of the material vertex shader
  17270. */
  17271. _vertexOutputNodes: NodeMaterialBlock[];
  17272. /**
  17273. * Gets or sets the root nodes of the material fragment (pixel) shader
  17274. */
  17275. _fragmentOutputNodes: NodeMaterialBlock[];
  17276. /** Gets or sets options to control the node material overall behavior */
  17277. get options(): INodeMaterialOptions;
  17278. set options(options: INodeMaterialOptions);
  17279. /**
  17280. * Default configuration related to image processing available in the standard Material.
  17281. */
  17282. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17283. /**
  17284. * Gets the image processing configuration used either in this material.
  17285. */
  17286. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17287. /**
  17288. * Sets the Default image processing configuration used either in the this material.
  17289. *
  17290. * If sets to null, the scene one is in use.
  17291. */
  17292. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17293. /**
  17294. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17295. */
  17296. attachedBlocks: NodeMaterialBlock[];
  17297. /**
  17298. * Specifies the mode of the node material
  17299. * @hidden
  17300. */
  17301. _mode: NodeMaterialModes;
  17302. /**
  17303. * Gets the mode property
  17304. */
  17305. get mode(): NodeMaterialModes;
  17306. /**
  17307. * A free comment about the material
  17308. */
  17309. comment: string;
  17310. /**
  17311. * Create a new node based material
  17312. * @param name defines the material name
  17313. * @param scene defines the hosting scene
  17314. * @param options defines creation option
  17315. */
  17316. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17317. /**
  17318. * Gets the current class name of the material e.g. "NodeMaterial"
  17319. * @returns the class name
  17320. */
  17321. getClassName(): string;
  17322. /**
  17323. * Keep track of the image processing observer to allow dispose and replace.
  17324. */
  17325. private _imageProcessingObserver;
  17326. /**
  17327. * Attaches a new image processing configuration to the Standard Material.
  17328. * @param configuration
  17329. */
  17330. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17331. /**
  17332. * Get a block by its name
  17333. * @param name defines the name of the block to retrieve
  17334. * @returns the required block or null if not found
  17335. */
  17336. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17337. /**
  17338. * Get a block by its name
  17339. * @param predicate defines the predicate used to find the good candidate
  17340. * @returns the required block or null if not found
  17341. */
  17342. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17343. /**
  17344. * Get an input block by its name
  17345. * @param predicate defines the predicate used to find the good candidate
  17346. * @returns the required input block or null if not found
  17347. */
  17348. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17349. /**
  17350. * Gets the list of input blocks attached to this material
  17351. * @returns an array of InputBlocks
  17352. */
  17353. getInputBlocks(): InputBlock[];
  17354. /**
  17355. * Adds a new optimizer to the list of optimizers
  17356. * @param optimizer defines the optimizers to add
  17357. * @returns the current material
  17358. */
  17359. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17360. /**
  17361. * Remove an optimizer from the list of optimizers
  17362. * @param optimizer defines the optimizers to remove
  17363. * @returns the current material
  17364. */
  17365. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17366. /**
  17367. * Add a new block to the list of output nodes
  17368. * @param node defines the node to add
  17369. * @returns the current material
  17370. */
  17371. addOutputNode(node: NodeMaterialBlock): this;
  17372. /**
  17373. * Remove a block from the list of root nodes
  17374. * @param node defines the node to remove
  17375. * @returns the current material
  17376. */
  17377. removeOutputNode(node: NodeMaterialBlock): this;
  17378. private _addVertexOutputNode;
  17379. private _removeVertexOutputNode;
  17380. private _addFragmentOutputNode;
  17381. private _removeFragmentOutputNode;
  17382. /**
  17383. * Specifies if the material will require alpha blending
  17384. * @returns a boolean specifying if alpha blending is needed
  17385. */
  17386. needAlphaBlending(): boolean;
  17387. /**
  17388. * Specifies if this material should be rendered in alpha test mode
  17389. * @returns a boolean specifying if an alpha test is needed.
  17390. */
  17391. needAlphaTesting(): boolean;
  17392. private _initializeBlock;
  17393. private _resetDualBlocks;
  17394. /**
  17395. * Remove a block from the current node material
  17396. * @param block defines the block to remove
  17397. */
  17398. removeBlock(block: NodeMaterialBlock): void;
  17399. /**
  17400. * Build the material and generates the inner effect
  17401. * @param verbose defines if the build should log activity
  17402. */
  17403. build(verbose?: boolean): void;
  17404. /**
  17405. * Runs an otpimization phase to try to improve the shader code
  17406. */
  17407. optimize(): void;
  17408. private _prepareDefinesForAttributes;
  17409. /**
  17410. * Create a post process from the material
  17411. * @param camera The camera to apply the render pass to.
  17412. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17414. * @param engine The engine which the post process will be applied. (default: current engine)
  17415. * @param reusable If the post process can be reused on the same frame. (default: false)
  17416. * @param textureType Type of textures used when performing the post process. (default: 0)
  17417. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  17418. * @returns the post process created
  17419. */
  17420. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  17421. /**
  17422. * Create the post process effect from the material
  17423. * @param postProcess The post process to create the effect for
  17424. */
  17425. createEffectForPostProcess(postProcess: PostProcess): void;
  17426. private _createEffectForPostProcess;
  17427. /**
  17428. * Create a new procedural texture based on this node material
  17429. * @param size defines the size of the texture
  17430. * @param scene defines the hosting scene
  17431. * @returns the new procedural texture attached to this node material
  17432. */
  17433. createProceduralTexture(size: number | {
  17434. width: number;
  17435. height: number;
  17436. layers?: number;
  17437. }, scene: Scene): Nullable<ProceduralTexture>;
  17438. private _createEffectForParticles;
  17439. private _checkInternals;
  17440. /**
  17441. * Create the effect to be used as the custom effect for a particle system
  17442. * @param particleSystem Particle system to create the effect for
  17443. * @param onCompiled defines a function to call when the effect creation is successful
  17444. * @param onError defines a function to call when the effect creation has failed
  17445. */
  17446. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  17447. private _processDefines;
  17448. /**
  17449. * Get if the submesh is ready to be used and all its information available.
  17450. * Child classes can use it to update shaders
  17451. * @param mesh defines the mesh to check
  17452. * @param subMesh defines which submesh to check
  17453. * @param useInstances specifies that instances should be used
  17454. * @returns a boolean indicating that the submesh is ready or not
  17455. */
  17456. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17457. /**
  17458. * Get a string representing the shaders built by the current node graph
  17459. */
  17460. get compiledShaders(): string;
  17461. /**
  17462. * Binds the world matrix to the material
  17463. * @param world defines the world transformation matrix
  17464. */
  17465. bindOnlyWorldMatrix(world: Matrix): void;
  17466. /**
  17467. * Binds the submesh to this material by preparing the effect and shader to draw
  17468. * @param world defines the world transformation matrix
  17469. * @param mesh defines the mesh containing the submesh
  17470. * @param subMesh defines the submesh to bind the material to
  17471. */
  17472. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17473. /**
  17474. * Gets the active textures from the material
  17475. * @returns an array of textures
  17476. */
  17477. getActiveTextures(): BaseTexture[];
  17478. /**
  17479. * Gets the list of texture blocks
  17480. * @returns an array of texture blocks
  17481. */
  17482. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  17483. /**
  17484. * Specifies if the material uses a texture
  17485. * @param texture defines the texture to check against the material
  17486. * @returns a boolean specifying if the material uses the texture
  17487. */
  17488. hasTexture(texture: BaseTexture): boolean;
  17489. /**
  17490. * Disposes the material
  17491. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17492. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17493. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17494. */
  17495. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17496. /** Creates the node editor window. */
  17497. private _createNodeEditor;
  17498. /**
  17499. * Launch the node material editor
  17500. * @param config Define the configuration of the editor
  17501. * @return a promise fulfilled when the node editor is visible
  17502. */
  17503. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  17504. /**
  17505. * Clear the current material
  17506. */
  17507. clear(): void;
  17508. /**
  17509. * Clear the current material and set it to a default state
  17510. */
  17511. setToDefault(): void;
  17512. /**
  17513. * Clear the current material and set it to a default state for post process
  17514. */
  17515. setToDefaultPostProcess(): void;
  17516. /**
  17517. * Clear the current material and set it to a default state for procedural texture
  17518. */
  17519. setToDefaultProceduralTexture(): void;
  17520. /**
  17521. * Clear the current material and set it to a default state for particle
  17522. */
  17523. setToDefaultParticle(): void;
  17524. /**
  17525. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  17526. * @param url defines the url to load from
  17527. * @returns a promise that will fullfil when the material is fully loaded
  17528. */
  17529. loadAsync(url: string): Promise<void>;
  17530. private _gatherBlocks;
  17531. /**
  17532. * Generate a string containing the code declaration required to create an equivalent of this material
  17533. * @returns a string
  17534. */
  17535. generateCode(): string;
  17536. /**
  17537. * Serializes this material in a JSON representation
  17538. * @returns the serialized material object
  17539. */
  17540. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  17541. private _restoreConnections;
  17542. /**
  17543. * Clear the current graph and load a new one from a serialization object
  17544. * @param source defines the JSON representation of the material
  17545. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17546. * @param merge defines whether or not the source must be merged or replace the current content
  17547. */
  17548. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  17549. /**
  17550. * Makes a duplicate of the current material.
  17551. * @param name - name to use for the new material.
  17552. */
  17553. clone(name: string): NodeMaterial;
  17554. /**
  17555. * Creates a node material from parsed material data
  17556. * @param source defines the JSON representation of the material
  17557. * @param scene defines the hosting scene
  17558. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17559. * @returns a new node material
  17560. */
  17561. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  17562. /**
  17563. * Creates a node material from a snippet saved in a remote file
  17564. * @param name defines the name of the material to create
  17565. * @param url defines the url to load from
  17566. * @param scene defines the hosting scene
  17567. * @returns a promise that will resolve to the new node material
  17568. */
  17569. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  17570. /**
  17571. * Creates a node material from a snippet saved by the node material editor
  17572. * @param snippetId defines the snippet to load
  17573. * @param scene defines the hosting scene
  17574. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17575. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  17576. * @returns a promise that will resolve to the new node material
  17577. */
  17578. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  17579. /**
  17580. * Creates a new node material set to default basic configuration
  17581. * @param name defines the name of the material
  17582. * @param scene defines the hosting scene
  17583. * @returns a new NodeMaterial
  17584. */
  17585. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  17586. }
  17587. }
  17588. declare module BABYLON {
  17589. interface ThinEngine {
  17590. /**
  17591. * Unbind a list of render target textures from the webGL context
  17592. * This is used only when drawBuffer extension or webGL2 are active
  17593. * @param textures defines the render target textures to unbind
  17594. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  17595. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  17596. */
  17597. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  17598. /**
  17599. * Create a multi render target texture
  17600. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  17601. * @param size defines the size of the texture
  17602. * @param options defines the creation options
  17603. * @returns the cube texture as an InternalTexture
  17604. */
  17605. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  17606. /**
  17607. * Update the sample count for a given multiple render target texture
  17608. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  17609. * @param textures defines the textures to update
  17610. * @param samples defines the sample count to set
  17611. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  17612. */
  17613. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  17614. /**
  17615. * Select a subsets of attachments to draw to.
  17616. * @param attachments gl attachments
  17617. */
  17618. bindAttachments(attachments: number[]): void;
  17619. /**
  17620. * Creates a layout object to draw/clear on specific textures in a MRT
  17621. * @param textureStatus textureStatus[i] indicates if the i-th is active
  17622. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  17623. */
  17624. buildTextureLayout(textureStatus: boolean[]): number[];
  17625. /**
  17626. * Restores the webgl state to only draw on the main color attachment
  17627. */
  17628. restoreSingleAttachment(): void;
  17629. }
  17630. }
  17631. declare module BABYLON {
  17632. /**
  17633. * Creation options of the multi render target texture.
  17634. */
  17635. export interface IMultiRenderTargetOptions {
  17636. /**
  17637. * Define if the texture needs to create mip maps after render.
  17638. */
  17639. generateMipMaps?: boolean;
  17640. /**
  17641. * Define the types of all the draw buffers we want to create
  17642. */
  17643. types?: number[];
  17644. /**
  17645. * Define the sampling modes of all the draw buffers we want to create
  17646. */
  17647. samplingModes?: number[];
  17648. /**
  17649. * Define if a depth buffer is required
  17650. */
  17651. generateDepthBuffer?: boolean;
  17652. /**
  17653. * Define if a stencil buffer is required
  17654. */
  17655. generateStencilBuffer?: boolean;
  17656. /**
  17657. * Define if a depth texture is required instead of a depth buffer
  17658. */
  17659. generateDepthTexture?: boolean;
  17660. /**
  17661. * Define the number of desired draw buffers
  17662. */
  17663. textureCount?: number;
  17664. /**
  17665. * Define if aspect ratio should be adapted to the texture or stay the scene one
  17666. */
  17667. doNotChangeAspectRatio?: boolean;
  17668. /**
  17669. * Define the default type of the buffers we are creating
  17670. */
  17671. defaultType?: number;
  17672. }
  17673. /**
  17674. * A multi render target, like a render target provides the ability to render to a texture.
  17675. * Unlike the render target, it can render to several draw buffers in one draw.
  17676. * This is specially interesting in deferred rendering or for any effects requiring more than
  17677. * just one color from a single pass.
  17678. */
  17679. export class MultiRenderTarget extends RenderTargetTexture {
  17680. private _internalTextures;
  17681. private _textures;
  17682. private _multiRenderTargetOptions;
  17683. private _count;
  17684. /**
  17685. * Get if draw buffers are currently supported by the used hardware and browser.
  17686. */
  17687. get isSupported(): boolean;
  17688. /**
  17689. * Get the list of textures generated by the multi render target.
  17690. */
  17691. get textures(): Texture[];
  17692. /**
  17693. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  17694. */
  17695. get count(): number;
  17696. /**
  17697. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  17698. */
  17699. get depthTexture(): Texture;
  17700. /**
  17701. * Set the wrapping mode on U of all the textures we are rendering to.
  17702. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17703. */
  17704. set wrapU(wrap: number);
  17705. /**
  17706. * Set the wrapping mode on V of all the textures we are rendering to.
  17707. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17708. */
  17709. set wrapV(wrap: number);
  17710. /**
  17711. * Instantiate a new multi render target texture.
  17712. * A multi render target, like a render target provides the ability to render to a texture.
  17713. * Unlike the render target, it can render to several draw buffers in one draw.
  17714. * This is specially interesting in deferred rendering or for any effects requiring more than
  17715. * just one color from a single pass.
  17716. * @param name Define the name of the texture
  17717. * @param size Define the size of the buffers to render to
  17718. * @param count Define the number of target we are rendering into
  17719. * @param scene Define the scene the texture belongs to
  17720. * @param options Define the options used to create the multi render target
  17721. */
  17722. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  17723. private _initTypes;
  17724. /** @hidden */
  17725. _rebuild(forceFullRebuild?: boolean): void;
  17726. private _createInternalTextures;
  17727. private _createTextures;
  17728. /**
  17729. * Replaces a texture within the MRT.
  17730. * @param texture The new texture to insert in the MRT
  17731. * @param index The index of the texture to replace
  17732. */
  17733. replaceTexture(texture: Texture, index: number): void;
  17734. /**
  17735. * Define the number of samples used if MSAA is enabled.
  17736. */
  17737. get samples(): number;
  17738. set samples(value: number);
  17739. /**
  17740. * Resize all the textures in the multi render target.
  17741. * Be careful as it will recreate all the data in the new texture.
  17742. * @param size Define the new size
  17743. */
  17744. resize(size: any): void;
  17745. /**
  17746. * Changes the number of render targets in this MRT
  17747. * Be careful as it will recreate all the data in the new texture.
  17748. * @param count new texture count
  17749. * @param options Specifies texture types and sampling modes for new textures
  17750. */
  17751. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  17752. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17753. /**
  17754. * Dispose the render targets and their associated resources
  17755. */
  17756. dispose(): void;
  17757. /**
  17758. * Release all the underlying texture used as draw buffers.
  17759. */
  17760. releaseInternalTextures(): void;
  17761. }
  17762. }
  17763. declare module BABYLON {
  17764. /** @hidden */
  17765. export var imageProcessingPixelShader: {
  17766. name: string;
  17767. shader: string;
  17768. };
  17769. }
  17770. declare module BABYLON {
  17771. /**
  17772. * ImageProcessingPostProcess
  17773. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  17774. */
  17775. export class ImageProcessingPostProcess extends PostProcess {
  17776. /**
  17777. * Default configuration related to image processing available in the PBR Material.
  17778. */
  17779. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17780. /**
  17781. * Gets the image processing configuration used either in this material.
  17782. */
  17783. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17784. /**
  17785. * Sets the Default image processing configuration used either in the this material.
  17786. *
  17787. * If sets to null, the scene one is in use.
  17788. */
  17789. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17790. /**
  17791. * Keep track of the image processing observer to allow dispose and replace.
  17792. */
  17793. private _imageProcessingObserver;
  17794. /**
  17795. * Attaches a new image processing configuration to the PBR Material.
  17796. * @param configuration
  17797. */
  17798. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  17799. /**
  17800. * If the post process is supported.
  17801. */
  17802. get isSupported(): boolean;
  17803. /**
  17804. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17805. */
  17806. get colorCurves(): Nullable<ColorCurves>;
  17807. /**
  17808. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17809. */
  17810. set colorCurves(value: Nullable<ColorCurves>);
  17811. /**
  17812. * Gets wether the color curves effect is enabled.
  17813. */
  17814. get colorCurvesEnabled(): boolean;
  17815. /**
  17816. * Sets wether the color curves effect is enabled.
  17817. */
  17818. set colorCurvesEnabled(value: boolean);
  17819. /**
  17820. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17821. */
  17822. get colorGradingTexture(): Nullable<BaseTexture>;
  17823. /**
  17824. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17825. */
  17826. set colorGradingTexture(value: Nullable<BaseTexture>);
  17827. /**
  17828. * Gets wether the color grading effect is enabled.
  17829. */
  17830. get colorGradingEnabled(): boolean;
  17831. /**
  17832. * Gets wether the color grading effect is enabled.
  17833. */
  17834. set colorGradingEnabled(value: boolean);
  17835. /**
  17836. * Gets exposure used in the effect.
  17837. */
  17838. get exposure(): number;
  17839. /**
  17840. * Sets exposure used in the effect.
  17841. */
  17842. set exposure(value: number);
  17843. /**
  17844. * Gets wether tonemapping is enabled or not.
  17845. */
  17846. get toneMappingEnabled(): boolean;
  17847. /**
  17848. * Sets wether tonemapping is enabled or not
  17849. */
  17850. set toneMappingEnabled(value: boolean);
  17851. /**
  17852. * Gets the type of tone mapping effect.
  17853. */
  17854. get toneMappingType(): number;
  17855. /**
  17856. * Sets the type of tone mapping effect.
  17857. */
  17858. set toneMappingType(value: number);
  17859. /**
  17860. * Gets contrast used in the effect.
  17861. */
  17862. get contrast(): number;
  17863. /**
  17864. * Sets contrast used in the effect.
  17865. */
  17866. set contrast(value: number);
  17867. /**
  17868. * Gets Vignette stretch size.
  17869. */
  17870. get vignetteStretch(): number;
  17871. /**
  17872. * Sets Vignette stretch size.
  17873. */
  17874. set vignetteStretch(value: number);
  17875. /**
  17876. * Gets Vignette centre X Offset.
  17877. */
  17878. get vignetteCentreX(): number;
  17879. /**
  17880. * Sets Vignette centre X Offset.
  17881. */
  17882. set vignetteCentreX(value: number);
  17883. /**
  17884. * Gets Vignette centre Y Offset.
  17885. */
  17886. get vignetteCentreY(): number;
  17887. /**
  17888. * Sets Vignette centre Y Offset.
  17889. */
  17890. set vignetteCentreY(value: number);
  17891. /**
  17892. * Gets Vignette weight or intensity of the vignette effect.
  17893. */
  17894. get vignetteWeight(): number;
  17895. /**
  17896. * Sets Vignette weight or intensity of the vignette effect.
  17897. */
  17898. set vignetteWeight(value: number);
  17899. /**
  17900. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17901. * if vignetteEnabled is set to true.
  17902. */
  17903. get vignetteColor(): Color4;
  17904. /**
  17905. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17906. * if vignetteEnabled is set to true.
  17907. */
  17908. set vignetteColor(value: Color4);
  17909. /**
  17910. * Gets Camera field of view used by the Vignette effect.
  17911. */
  17912. get vignetteCameraFov(): number;
  17913. /**
  17914. * Sets Camera field of view used by the Vignette effect.
  17915. */
  17916. set vignetteCameraFov(value: number);
  17917. /**
  17918. * Gets the vignette blend mode allowing different kind of effect.
  17919. */
  17920. get vignetteBlendMode(): number;
  17921. /**
  17922. * Sets the vignette blend mode allowing different kind of effect.
  17923. */
  17924. set vignetteBlendMode(value: number);
  17925. /**
  17926. * Gets wether the vignette effect is enabled.
  17927. */
  17928. get vignetteEnabled(): boolean;
  17929. /**
  17930. * Sets wether the vignette effect is enabled.
  17931. */
  17932. set vignetteEnabled(value: boolean);
  17933. private _fromLinearSpace;
  17934. /**
  17935. * Gets wether the input of the processing is in Gamma or Linear Space.
  17936. */
  17937. get fromLinearSpace(): boolean;
  17938. /**
  17939. * Sets wether the input of the processing is in Gamma or Linear Space.
  17940. */
  17941. set fromLinearSpace(value: boolean);
  17942. /**
  17943. * Defines cache preventing GC.
  17944. */
  17945. private _defines;
  17946. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  17947. /**
  17948. * "ImageProcessingPostProcess"
  17949. * @returns "ImageProcessingPostProcess"
  17950. */
  17951. getClassName(): string;
  17952. /**
  17953. * @hidden
  17954. */
  17955. _updateParameters(): void;
  17956. dispose(camera?: Camera): void;
  17957. }
  17958. }
  17959. declare module BABYLON {
  17960. /**
  17961. * Interface for defining prepass effects in the prepass post-process pipeline
  17962. */
  17963. export interface PrePassEffectConfiguration {
  17964. /**
  17965. * Name of the effect
  17966. */
  17967. name: string;
  17968. /**
  17969. * Post process to attach for this effect
  17970. */
  17971. postProcess?: PostProcess;
  17972. /**
  17973. * Textures required in the MRT
  17974. */
  17975. texturesRequired: number[];
  17976. /**
  17977. * Is the effect enabled
  17978. */
  17979. enabled: boolean;
  17980. /**
  17981. * Disposes the effect configuration
  17982. */
  17983. dispose?: () => void;
  17984. /**
  17985. * Creates the associated post process
  17986. */
  17987. createPostProcess?: () => PostProcess;
  17988. }
  17989. }
  17990. declare module BABYLON {
  17991. /**
  17992. * Options to be used when creating a FresnelParameters.
  17993. */
  17994. export type IFresnelParametersCreationOptions = {
  17995. /**
  17996. * Define the color used on edges (grazing angle)
  17997. */
  17998. leftColor?: Color3;
  17999. /**
  18000. * Define the color used on center
  18001. */
  18002. rightColor?: Color3;
  18003. /**
  18004. * Define bias applied to computed fresnel term
  18005. */
  18006. bias?: number;
  18007. /**
  18008. * Defined the power exponent applied to fresnel term
  18009. */
  18010. power?: number;
  18011. /**
  18012. * Define if the fresnel effect is enable or not.
  18013. */
  18014. isEnabled?: boolean;
  18015. };
  18016. /**
  18017. * Serialized format for FresnelParameters.
  18018. */
  18019. export type IFresnelParametersSerialized = {
  18020. /**
  18021. * Define the color used on edges (grazing angle) [as an array]
  18022. */
  18023. leftColor: number[];
  18024. /**
  18025. * Define the color used on center [as an array]
  18026. */
  18027. rightColor: number[];
  18028. /**
  18029. * Define bias applied to computed fresnel term
  18030. */
  18031. bias: number;
  18032. /**
  18033. * Defined the power exponent applied to fresnel term
  18034. */
  18035. power?: number;
  18036. /**
  18037. * Define if the fresnel effect is enable or not.
  18038. */
  18039. isEnabled: boolean;
  18040. };
  18041. /**
  18042. * This represents all the required information to add a fresnel effect on a material:
  18043. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18044. */
  18045. export class FresnelParameters {
  18046. private _isEnabled;
  18047. /**
  18048. * Define if the fresnel effect is enable or not.
  18049. */
  18050. get isEnabled(): boolean;
  18051. set isEnabled(value: boolean);
  18052. /**
  18053. * Define the color used on edges (grazing angle)
  18054. */
  18055. leftColor: Color3;
  18056. /**
  18057. * Define the color used on center
  18058. */
  18059. rightColor: Color3;
  18060. /**
  18061. * Define bias applied to computed fresnel term
  18062. */
  18063. bias: number;
  18064. /**
  18065. * Defined the power exponent applied to fresnel term
  18066. */
  18067. power: number;
  18068. /**
  18069. * Creates a new FresnelParameters object.
  18070. *
  18071. * @param options provide your own settings to optionally to override defaults
  18072. */
  18073. constructor(options?: IFresnelParametersCreationOptions);
  18074. /**
  18075. * Clones the current fresnel and its valuues
  18076. * @returns a clone fresnel configuration
  18077. */
  18078. clone(): FresnelParameters;
  18079. /**
  18080. * Determines equality between FresnelParameters objects
  18081. * @param otherFresnelParameters defines the second operand
  18082. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18083. */
  18084. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18085. /**
  18086. * Serializes the current fresnel parameters to a JSON representation.
  18087. * @return the JSON serialization
  18088. */
  18089. serialize(): IFresnelParametersSerialized;
  18090. /**
  18091. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18092. * @param parsedFresnelParameters Define the JSON representation
  18093. * @returns the parsed parameters
  18094. */
  18095. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18096. }
  18097. }
  18098. declare module BABYLON {
  18099. /**
  18100. * This groups all the flags used to control the materials channel.
  18101. */
  18102. export class MaterialFlags {
  18103. private static _DiffuseTextureEnabled;
  18104. /**
  18105. * Are diffuse textures enabled in the application.
  18106. */
  18107. static get DiffuseTextureEnabled(): boolean;
  18108. static set DiffuseTextureEnabled(value: boolean);
  18109. private static _DetailTextureEnabled;
  18110. /**
  18111. * Are detail textures enabled in the application.
  18112. */
  18113. static get DetailTextureEnabled(): boolean;
  18114. static set DetailTextureEnabled(value: boolean);
  18115. private static _AmbientTextureEnabled;
  18116. /**
  18117. * Are ambient textures enabled in the application.
  18118. */
  18119. static get AmbientTextureEnabled(): boolean;
  18120. static set AmbientTextureEnabled(value: boolean);
  18121. private static _OpacityTextureEnabled;
  18122. /**
  18123. * Are opacity textures enabled in the application.
  18124. */
  18125. static get OpacityTextureEnabled(): boolean;
  18126. static set OpacityTextureEnabled(value: boolean);
  18127. private static _ReflectionTextureEnabled;
  18128. /**
  18129. * Are reflection textures enabled in the application.
  18130. */
  18131. static get ReflectionTextureEnabled(): boolean;
  18132. static set ReflectionTextureEnabled(value: boolean);
  18133. private static _EmissiveTextureEnabled;
  18134. /**
  18135. * Are emissive textures enabled in the application.
  18136. */
  18137. static get EmissiveTextureEnabled(): boolean;
  18138. static set EmissiveTextureEnabled(value: boolean);
  18139. private static _SpecularTextureEnabled;
  18140. /**
  18141. * Are specular textures enabled in the application.
  18142. */
  18143. static get SpecularTextureEnabled(): boolean;
  18144. static set SpecularTextureEnabled(value: boolean);
  18145. private static _BumpTextureEnabled;
  18146. /**
  18147. * Are bump textures enabled in the application.
  18148. */
  18149. static get BumpTextureEnabled(): boolean;
  18150. static set BumpTextureEnabled(value: boolean);
  18151. private static _LightmapTextureEnabled;
  18152. /**
  18153. * Are lightmap textures enabled in the application.
  18154. */
  18155. static get LightmapTextureEnabled(): boolean;
  18156. static set LightmapTextureEnabled(value: boolean);
  18157. private static _RefractionTextureEnabled;
  18158. /**
  18159. * Are refraction textures enabled in the application.
  18160. */
  18161. static get RefractionTextureEnabled(): boolean;
  18162. static set RefractionTextureEnabled(value: boolean);
  18163. private static _ColorGradingTextureEnabled;
  18164. /**
  18165. * Are color grading textures enabled in the application.
  18166. */
  18167. static get ColorGradingTextureEnabled(): boolean;
  18168. static set ColorGradingTextureEnabled(value: boolean);
  18169. private static _FresnelEnabled;
  18170. /**
  18171. * Are fresnels enabled in the application.
  18172. */
  18173. static get FresnelEnabled(): boolean;
  18174. static set FresnelEnabled(value: boolean);
  18175. private static _ClearCoatTextureEnabled;
  18176. /**
  18177. * Are clear coat textures enabled in the application.
  18178. */
  18179. static get ClearCoatTextureEnabled(): boolean;
  18180. static set ClearCoatTextureEnabled(value: boolean);
  18181. private static _ClearCoatBumpTextureEnabled;
  18182. /**
  18183. * Are clear coat bump textures enabled in the application.
  18184. */
  18185. static get ClearCoatBumpTextureEnabled(): boolean;
  18186. static set ClearCoatBumpTextureEnabled(value: boolean);
  18187. private static _ClearCoatTintTextureEnabled;
  18188. /**
  18189. * Are clear coat tint textures enabled in the application.
  18190. */
  18191. static get ClearCoatTintTextureEnabled(): boolean;
  18192. static set ClearCoatTintTextureEnabled(value: boolean);
  18193. private static _SheenTextureEnabled;
  18194. /**
  18195. * Are sheen textures enabled in the application.
  18196. */
  18197. static get SheenTextureEnabled(): boolean;
  18198. static set SheenTextureEnabled(value: boolean);
  18199. private static _AnisotropicTextureEnabled;
  18200. /**
  18201. * Are anisotropic textures enabled in the application.
  18202. */
  18203. static get AnisotropicTextureEnabled(): boolean;
  18204. static set AnisotropicTextureEnabled(value: boolean);
  18205. private static _ThicknessTextureEnabled;
  18206. /**
  18207. * Are thickness textures enabled in the application.
  18208. */
  18209. static get ThicknessTextureEnabled(): boolean;
  18210. static set ThicknessTextureEnabled(value: boolean);
  18211. }
  18212. }
  18213. declare module BABYLON {
  18214. /** @hidden */
  18215. export var defaultFragmentDeclaration: {
  18216. name: string;
  18217. shader: string;
  18218. };
  18219. }
  18220. declare module BABYLON {
  18221. /** @hidden */
  18222. export var defaultUboDeclaration: {
  18223. name: string;
  18224. shader: string;
  18225. };
  18226. }
  18227. declare module BABYLON {
  18228. /** @hidden */
  18229. export var prePassDeclaration: {
  18230. name: string;
  18231. shader: string;
  18232. };
  18233. }
  18234. declare module BABYLON {
  18235. /** @hidden */
  18236. export var lightFragmentDeclaration: {
  18237. name: string;
  18238. shader: string;
  18239. };
  18240. }
  18241. declare module BABYLON {
  18242. /** @hidden */
  18243. export var lightUboDeclaration: {
  18244. name: string;
  18245. shader: string;
  18246. };
  18247. }
  18248. declare module BABYLON {
  18249. /** @hidden */
  18250. export var lightsFragmentFunctions: {
  18251. name: string;
  18252. shader: string;
  18253. };
  18254. }
  18255. declare module BABYLON {
  18256. /** @hidden */
  18257. export var shadowsFragmentFunctions: {
  18258. name: string;
  18259. shader: string;
  18260. };
  18261. }
  18262. declare module BABYLON {
  18263. /** @hidden */
  18264. export var fresnelFunction: {
  18265. name: string;
  18266. shader: string;
  18267. };
  18268. }
  18269. declare module BABYLON {
  18270. /** @hidden */
  18271. export var bumpFragmentMainFunctions: {
  18272. name: string;
  18273. shader: string;
  18274. };
  18275. }
  18276. declare module BABYLON {
  18277. /** @hidden */
  18278. export var bumpFragmentFunctions: {
  18279. name: string;
  18280. shader: string;
  18281. };
  18282. }
  18283. declare module BABYLON {
  18284. /** @hidden */
  18285. export var logDepthDeclaration: {
  18286. name: string;
  18287. shader: string;
  18288. };
  18289. }
  18290. declare module BABYLON {
  18291. /** @hidden */
  18292. export var fogFragmentDeclaration: {
  18293. name: string;
  18294. shader: string;
  18295. };
  18296. }
  18297. declare module BABYLON {
  18298. /** @hidden */
  18299. export var bumpFragment: {
  18300. name: string;
  18301. shader: string;
  18302. };
  18303. }
  18304. declare module BABYLON {
  18305. /** @hidden */
  18306. export var depthPrePass: {
  18307. name: string;
  18308. shader: string;
  18309. };
  18310. }
  18311. declare module BABYLON {
  18312. /** @hidden */
  18313. export var lightFragment: {
  18314. name: string;
  18315. shader: string;
  18316. };
  18317. }
  18318. declare module BABYLON {
  18319. /** @hidden */
  18320. export var logDepthFragment: {
  18321. name: string;
  18322. shader: string;
  18323. };
  18324. }
  18325. declare module BABYLON {
  18326. /** @hidden */
  18327. export var fogFragment: {
  18328. name: string;
  18329. shader: string;
  18330. };
  18331. }
  18332. declare module BABYLON {
  18333. /** @hidden */
  18334. export var defaultPixelShader: {
  18335. name: string;
  18336. shader: string;
  18337. };
  18338. }
  18339. declare module BABYLON {
  18340. /** @hidden */
  18341. export var defaultVertexDeclaration: {
  18342. name: string;
  18343. shader: string;
  18344. };
  18345. }
  18346. declare module BABYLON {
  18347. /** @hidden */
  18348. export var bonesDeclaration: {
  18349. name: string;
  18350. shader: string;
  18351. };
  18352. }
  18353. declare module BABYLON {
  18354. /** @hidden */
  18355. export var instancesDeclaration: {
  18356. name: string;
  18357. shader: string;
  18358. };
  18359. }
  18360. declare module BABYLON {
  18361. /** @hidden */
  18362. export var prePassVertexDeclaration: {
  18363. name: string;
  18364. shader: string;
  18365. };
  18366. }
  18367. declare module BABYLON {
  18368. /** @hidden */
  18369. export var bumpVertexDeclaration: {
  18370. name: string;
  18371. shader: string;
  18372. };
  18373. }
  18374. declare module BABYLON {
  18375. /** @hidden */
  18376. export var fogVertexDeclaration: {
  18377. name: string;
  18378. shader: string;
  18379. };
  18380. }
  18381. declare module BABYLON {
  18382. /** @hidden */
  18383. export var morphTargetsVertexGlobalDeclaration: {
  18384. name: string;
  18385. shader: string;
  18386. };
  18387. }
  18388. declare module BABYLON {
  18389. /** @hidden */
  18390. export var morphTargetsVertexDeclaration: {
  18391. name: string;
  18392. shader: string;
  18393. };
  18394. }
  18395. declare module BABYLON {
  18396. /** @hidden */
  18397. export var morphTargetsVertex: {
  18398. name: string;
  18399. shader: string;
  18400. };
  18401. }
  18402. declare module BABYLON {
  18403. /** @hidden */
  18404. export var instancesVertex: {
  18405. name: string;
  18406. shader: string;
  18407. };
  18408. }
  18409. declare module BABYLON {
  18410. /** @hidden */
  18411. export var bonesVertex: {
  18412. name: string;
  18413. shader: string;
  18414. };
  18415. }
  18416. declare module BABYLON {
  18417. /** @hidden */
  18418. export var prePassVertex: {
  18419. name: string;
  18420. shader: string;
  18421. };
  18422. }
  18423. declare module BABYLON {
  18424. /** @hidden */
  18425. export var bumpVertex: {
  18426. name: string;
  18427. shader: string;
  18428. };
  18429. }
  18430. declare module BABYLON {
  18431. /** @hidden */
  18432. export var fogVertex: {
  18433. name: string;
  18434. shader: string;
  18435. };
  18436. }
  18437. declare module BABYLON {
  18438. /** @hidden */
  18439. export var shadowsVertex: {
  18440. name: string;
  18441. shader: string;
  18442. };
  18443. }
  18444. declare module BABYLON {
  18445. /** @hidden */
  18446. export var pointCloudVertex: {
  18447. name: string;
  18448. shader: string;
  18449. };
  18450. }
  18451. declare module BABYLON {
  18452. /** @hidden */
  18453. export var logDepthVertex: {
  18454. name: string;
  18455. shader: string;
  18456. };
  18457. }
  18458. declare module BABYLON {
  18459. /** @hidden */
  18460. export var defaultVertexShader: {
  18461. name: string;
  18462. shader: string;
  18463. };
  18464. }
  18465. declare module BABYLON {
  18466. /**
  18467. * @hidden
  18468. */
  18469. export interface IMaterialDetailMapDefines {
  18470. DETAIL: boolean;
  18471. DETAILDIRECTUV: number;
  18472. DETAIL_NORMALBLENDMETHOD: number;
  18473. /** @hidden */
  18474. _areTexturesDirty: boolean;
  18475. }
  18476. /**
  18477. * Define the code related to the detail map parameters of a material
  18478. *
  18479. * Inspired from:
  18480. * 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
  18481. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  18482. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  18483. */
  18484. export class DetailMapConfiguration {
  18485. private _texture;
  18486. /**
  18487. * The detail texture of the material.
  18488. */
  18489. texture: Nullable<BaseTexture>;
  18490. /**
  18491. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  18492. * Bigger values mean stronger blending
  18493. */
  18494. diffuseBlendLevel: number;
  18495. /**
  18496. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  18497. * Bigger values mean stronger blending. Only used with PBR materials
  18498. */
  18499. roughnessBlendLevel: number;
  18500. /**
  18501. * Defines how strong the bump effect from the detail map is
  18502. * Bigger values mean stronger effect
  18503. */
  18504. bumpLevel: number;
  18505. private _normalBlendMethod;
  18506. /**
  18507. * The method used to blend the bump and detail normals together
  18508. */
  18509. normalBlendMethod: number;
  18510. private _isEnabled;
  18511. /**
  18512. * Enable or disable the detail map on this material
  18513. */
  18514. isEnabled: boolean;
  18515. /** @hidden */
  18516. private _internalMarkAllSubMeshesAsTexturesDirty;
  18517. /** @hidden */
  18518. _markAllSubMeshesAsTexturesDirty(): void;
  18519. /**
  18520. * Instantiate a new detail map
  18521. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  18522. */
  18523. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  18524. /**
  18525. * Gets whether the submesh is ready to be used or not.
  18526. * @param defines the list of "defines" to update.
  18527. * @param scene defines the scene the material belongs to.
  18528. * @returns - boolean indicating that the submesh is ready or not.
  18529. */
  18530. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  18531. /**
  18532. * Update the defines for detail map usage
  18533. * @param defines the list of "defines" to update.
  18534. * @param scene defines the scene the material belongs to.
  18535. */
  18536. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  18537. /**
  18538. * Binds the material data.
  18539. * @param uniformBuffer defines the Uniform buffer to fill in.
  18540. * @param scene defines the scene the material belongs to.
  18541. * @param isFrozen defines whether the material is frozen or not.
  18542. */
  18543. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  18544. /**
  18545. * Checks to see if a texture is used in the material.
  18546. * @param texture - Base texture to use.
  18547. * @returns - Boolean specifying if a texture is used in the material.
  18548. */
  18549. hasTexture(texture: BaseTexture): boolean;
  18550. /**
  18551. * Returns an array of the actively used textures.
  18552. * @param activeTextures Array of BaseTextures
  18553. */
  18554. getActiveTextures(activeTextures: BaseTexture[]): void;
  18555. /**
  18556. * Returns the animatable textures.
  18557. * @param animatables Array of animatable textures.
  18558. */
  18559. getAnimatables(animatables: IAnimatable[]): void;
  18560. /**
  18561. * Disposes the resources of the material.
  18562. * @param forceDisposeTextures - Forces the disposal of all textures.
  18563. */
  18564. dispose(forceDisposeTextures?: boolean): void;
  18565. /**
  18566. * Get the current class name useful for serialization or dynamic coding.
  18567. * @returns "DetailMap"
  18568. */
  18569. getClassName(): string;
  18570. /**
  18571. * Add the required uniforms to the current list.
  18572. * @param uniforms defines the current uniform list.
  18573. */
  18574. static AddUniforms(uniforms: string[]): void;
  18575. /**
  18576. * Add the required samplers to the current list.
  18577. * @param samplers defines the current sampler list.
  18578. */
  18579. static AddSamplers(samplers: string[]): void;
  18580. /**
  18581. * Add the required uniforms to the current buffer.
  18582. * @param uniformBuffer defines the current uniform buffer.
  18583. */
  18584. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  18585. /**
  18586. * Makes a duplicate of the current instance into another one.
  18587. * @param detailMap define the instance where to copy the info
  18588. */
  18589. copyTo(detailMap: DetailMapConfiguration): void;
  18590. /**
  18591. * Serializes this detail map instance
  18592. * @returns - An object with the serialized instance.
  18593. */
  18594. serialize(): any;
  18595. /**
  18596. * Parses a detail map setting from a serialized object.
  18597. * @param source - Serialized object.
  18598. * @param scene Defines the scene we are parsing for
  18599. * @param rootUrl Defines the rootUrl to load from
  18600. */
  18601. parse(source: any, scene: Scene, rootUrl: string): void;
  18602. }
  18603. }
  18604. declare module BABYLON {
  18605. /** @hidden */
  18606. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  18607. MAINUV1: boolean;
  18608. MAINUV2: boolean;
  18609. DIFFUSE: boolean;
  18610. DIFFUSEDIRECTUV: number;
  18611. DETAIL: boolean;
  18612. DETAILDIRECTUV: number;
  18613. DETAIL_NORMALBLENDMETHOD: number;
  18614. AMBIENT: boolean;
  18615. AMBIENTDIRECTUV: number;
  18616. OPACITY: boolean;
  18617. OPACITYDIRECTUV: number;
  18618. OPACITYRGB: boolean;
  18619. REFLECTION: boolean;
  18620. EMISSIVE: boolean;
  18621. EMISSIVEDIRECTUV: number;
  18622. SPECULAR: boolean;
  18623. SPECULARDIRECTUV: number;
  18624. BUMP: boolean;
  18625. BUMPDIRECTUV: number;
  18626. PARALLAX: boolean;
  18627. PARALLAXOCCLUSION: boolean;
  18628. SPECULAROVERALPHA: boolean;
  18629. CLIPPLANE: boolean;
  18630. CLIPPLANE2: boolean;
  18631. CLIPPLANE3: boolean;
  18632. CLIPPLANE4: boolean;
  18633. CLIPPLANE5: boolean;
  18634. CLIPPLANE6: boolean;
  18635. ALPHATEST: boolean;
  18636. DEPTHPREPASS: boolean;
  18637. ALPHAFROMDIFFUSE: boolean;
  18638. POINTSIZE: boolean;
  18639. FOG: boolean;
  18640. SPECULARTERM: boolean;
  18641. DIFFUSEFRESNEL: boolean;
  18642. OPACITYFRESNEL: boolean;
  18643. REFLECTIONFRESNEL: boolean;
  18644. REFRACTIONFRESNEL: boolean;
  18645. EMISSIVEFRESNEL: boolean;
  18646. FRESNEL: boolean;
  18647. NORMAL: boolean;
  18648. UV1: boolean;
  18649. UV2: boolean;
  18650. VERTEXCOLOR: boolean;
  18651. VERTEXALPHA: boolean;
  18652. NUM_BONE_INFLUENCERS: number;
  18653. BonesPerMesh: number;
  18654. BONETEXTURE: boolean;
  18655. BONES_VELOCITY_ENABLED: boolean;
  18656. INSTANCES: boolean;
  18657. THIN_INSTANCES: boolean;
  18658. GLOSSINESS: boolean;
  18659. ROUGHNESS: boolean;
  18660. EMISSIVEASILLUMINATION: boolean;
  18661. LINKEMISSIVEWITHDIFFUSE: boolean;
  18662. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18663. LIGHTMAP: boolean;
  18664. LIGHTMAPDIRECTUV: number;
  18665. OBJECTSPACE_NORMALMAP: boolean;
  18666. USELIGHTMAPASSHADOWMAP: boolean;
  18667. REFLECTIONMAP_3D: boolean;
  18668. REFLECTIONMAP_SPHERICAL: boolean;
  18669. REFLECTIONMAP_PLANAR: boolean;
  18670. REFLECTIONMAP_CUBIC: boolean;
  18671. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18672. REFLECTIONMAP_PROJECTION: boolean;
  18673. REFLECTIONMAP_SKYBOX: boolean;
  18674. REFLECTIONMAP_EXPLICIT: boolean;
  18675. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18676. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18677. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18678. INVERTCUBICMAP: boolean;
  18679. LOGARITHMICDEPTH: boolean;
  18680. REFRACTION: boolean;
  18681. REFRACTIONMAP_3D: boolean;
  18682. REFLECTIONOVERALPHA: boolean;
  18683. TWOSIDEDLIGHTING: boolean;
  18684. SHADOWFLOAT: boolean;
  18685. MORPHTARGETS: boolean;
  18686. MORPHTARGETS_NORMAL: boolean;
  18687. MORPHTARGETS_TANGENT: boolean;
  18688. MORPHTARGETS_UV: boolean;
  18689. NUM_MORPH_INFLUENCERS: number;
  18690. NONUNIFORMSCALING: boolean;
  18691. PREMULTIPLYALPHA: boolean;
  18692. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  18693. ALPHABLEND: boolean;
  18694. PREPASS: boolean;
  18695. PREPASS_IRRADIANCE: boolean;
  18696. PREPASS_IRRADIANCE_INDEX: number;
  18697. PREPASS_ALBEDO: boolean;
  18698. PREPASS_ALBEDO_INDEX: number;
  18699. PREPASS_DEPTHNORMAL: boolean;
  18700. PREPASS_DEPTHNORMAL_INDEX: number;
  18701. PREPASS_POSITION: boolean;
  18702. PREPASS_POSITION_INDEX: number;
  18703. PREPASS_VELOCITY: boolean;
  18704. PREPASS_VELOCITY_INDEX: number;
  18705. PREPASS_REFLECTIVITY: boolean;
  18706. PREPASS_REFLECTIVITY_INDEX: number;
  18707. SCENE_MRT_COUNT: number;
  18708. RGBDLIGHTMAP: boolean;
  18709. RGBDREFLECTION: boolean;
  18710. RGBDREFRACTION: boolean;
  18711. IMAGEPROCESSING: boolean;
  18712. VIGNETTE: boolean;
  18713. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18714. VIGNETTEBLENDMODEOPAQUE: boolean;
  18715. TONEMAPPING: boolean;
  18716. TONEMAPPING_ACES: boolean;
  18717. CONTRAST: boolean;
  18718. COLORCURVES: boolean;
  18719. COLORGRADING: boolean;
  18720. COLORGRADING3D: boolean;
  18721. SAMPLER3DGREENDEPTH: boolean;
  18722. SAMPLER3DBGRMAP: boolean;
  18723. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18724. MULTIVIEW: boolean;
  18725. /**
  18726. * If the reflection texture on this material is in linear color space
  18727. * @hidden
  18728. */
  18729. IS_REFLECTION_LINEAR: boolean;
  18730. /**
  18731. * If the refraction texture on this material is in linear color space
  18732. * @hidden
  18733. */
  18734. IS_REFRACTION_LINEAR: boolean;
  18735. EXPOSURE: boolean;
  18736. constructor();
  18737. setReflectionMode(modeToEnable: string): void;
  18738. }
  18739. /**
  18740. * This is the default material used in Babylon. It is the best trade off between quality
  18741. * and performances.
  18742. * @see https://doc.babylonjs.com/babylon101/materials
  18743. */
  18744. export class StandardMaterial extends PushMaterial {
  18745. private _diffuseTexture;
  18746. /**
  18747. * The basic texture of the material as viewed under a light.
  18748. */
  18749. diffuseTexture: Nullable<BaseTexture>;
  18750. private _ambientTexture;
  18751. /**
  18752. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  18753. */
  18754. ambientTexture: Nullable<BaseTexture>;
  18755. private _opacityTexture;
  18756. /**
  18757. * Define the transparency of the material from a texture.
  18758. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  18759. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  18760. */
  18761. opacityTexture: Nullable<BaseTexture>;
  18762. private _reflectionTexture;
  18763. /**
  18764. * Define the texture used to display the reflection.
  18765. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18766. */
  18767. reflectionTexture: Nullable<BaseTexture>;
  18768. private _emissiveTexture;
  18769. /**
  18770. * Define texture of the material as if self lit.
  18771. * This will be mixed in the final result even in the absence of light.
  18772. */
  18773. emissiveTexture: Nullable<BaseTexture>;
  18774. private _specularTexture;
  18775. /**
  18776. * Define how the color and intensity of the highlight given by the light in the material.
  18777. */
  18778. specularTexture: Nullable<BaseTexture>;
  18779. private _bumpTexture;
  18780. /**
  18781. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  18782. * 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.
  18783. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  18784. */
  18785. bumpTexture: Nullable<BaseTexture>;
  18786. private _lightmapTexture;
  18787. /**
  18788. * Complex lighting can be computationally expensive to compute at runtime.
  18789. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  18790. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  18791. */
  18792. lightmapTexture: Nullable<BaseTexture>;
  18793. private _refractionTexture;
  18794. /**
  18795. * Define the texture used to display the refraction.
  18796. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18797. */
  18798. refractionTexture: Nullable<BaseTexture>;
  18799. /**
  18800. * The color of the material lit by the environmental background lighting.
  18801. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  18802. */
  18803. ambientColor: Color3;
  18804. /**
  18805. * The basic color of the material as viewed under a light.
  18806. */
  18807. diffuseColor: Color3;
  18808. /**
  18809. * Define how the color and intensity of the highlight given by the light in the material.
  18810. */
  18811. specularColor: Color3;
  18812. /**
  18813. * Define the color of the material as if self lit.
  18814. * This will be mixed in the final result even in the absence of light.
  18815. */
  18816. emissiveColor: Color3;
  18817. /**
  18818. * Defines how sharp are the highlights in the material.
  18819. * The bigger the value the sharper giving a more glossy feeling to the result.
  18820. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  18821. */
  18822. specularPower: number;
  18823. private _useAlphaFromDiffuseTexture;
  18824. /**
  18825. * Does the transparency come from the diffuse texture alpha channel.
  18826. */
  18827. useAlphaFromDiffuseTexture: boolean;
  18828. private _useEmissiveAsIllumination;
  18829. /**
  18830. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  18831. */
  18832. useEmissiveAsIllumination: boolean;
  18833. private _linkEmissiveWithDiffuse;
  18834. /**
  18835. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  18836. * the emissive level when the final color is close to one.
  18837. */
  18838. linkEmissiveWithDiffuse: boolean;
  18839. private _useSpecularOverAlpha;
  18840. /**
  18841. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  18842. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  18843. */
  18844. useSpecularOverAlpha: boolean;
  18845. private _useReflectionOverAlpha;
  18846. /**
  18847. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  18848. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  18849. */
  18850. useReflectionOverAlpha: boolean;
  18851. private _disableLighting;
  18852. /**
  18853. * Does lights from the scene impacts this material.
  18854. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  18855. */
  18856. disableLighting: boolean;
  18857. private _useObjectSpaceNormalMap;
  18858. /**
  18859. * Allows using an object space normal map (instead of tangent space).
  18860. */
  18861. useObjectSpaceNormalMap: boolean;
  18862. private _useParallax;
  18863. /**
  18864. * Is parallax enabled or not.
  18865. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18866. */
  18867. useParallax: boolean;
  18868. private _useParallaxOcclusion;
  18869. /**
  18870. * Is parallax occlusion enabled or not.
  18871. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  18872. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18873. */
  18874. useParallaxOcclusion: boolean;
  18875. /**
  18876. * 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.
  18877. */
  18878. parallaxScaleBias: number;
  18879. private _roughness;
  18880. /**
  18881. * Helps to define how blurry the reflections should appears in the material.
  18882. */
  18883. roughness: number;
  18884. /**
  18885. * In case of refraction, define the value of the index of refraction.
  18886. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18887. */
  18888. indexOfRefraction: number;
  18889. /**
  18890. * Invert the refraction texture alongside the y axis.
  18891. * It can be useful with procedural textures or probe for instance.
  18892. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18893. */
  18894. invertRefractionY: boolean;
  18895. /**
  18896. * Defines the alpha limits in alpha test mode.
  18897. */
  18898. alphaCutOff: number;
  18899. private _useLightmapAsShadowmap;
  18900. /**
  18901. * In case of light mapping, define whether the map contains light or shadow informations.
  18902. */
  18903. useLightmapAsShadowmap: boolean;
  18904. private _diffuseFresnelParameters;
  18905. /**
  18906. * Define the diffuse fresnel parameters of the material.
  18907. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18908. */
  18909. diffuseFresnelParameters: FresnelParameters;
  18910. private _opacityFresnelParameters;
  18911. /**
  18912. * Define the opacity fresnel parameters of the material.
  18913. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18914. */
  18915. opacityFresnelParameters: FresnelParameters;
  18916. private _reflectionFresnelParameters;
  18917. /**
  18918. * Define the reflection fresnel parameters of the material.
  18919. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18920. */
  18921. reflectionFresnelParameters: FresnelParameters;
  18922. private _refractionFresnelParameters;
  18923. /**
  18924. * Define the refraction fresnel parameters of the material.
  18925. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18926. */
  18927. refractionFresnelParameters: FresnelParameters;
  18928. private _emissiveFresnelParameters;
  18929. /**
  18930. * Define the emissive fresnel parameters of the material.
  18931. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18932. */
  18933. emissiveFresnelParameters: FresnelParameters;
  18934. private _useReflectionFresnelFromSpecular;
  18935. /**
  18936. * If true automatically deducts the fresnels values from the material specularity.
  18937. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18938. */
  18939. useReflectionFresnelFromSpecular: boolean;
  18940. private _useGlossinessFromSpecularMapAlpha;
  18941. /**
  18942. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  18943. */
  18944. useGlossinessFromSpecularMapAlpha: boolean;
  18945. private _maxSimultaneousLights;
  18946. /**
  18947. * Defines the maximum number of lights that can be used in the material
  18948. */
  18949. maxSimultaneousLights: number;
  18950. private _invertNormalMapX;
  18951. /**
  18952. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  18953. */
  18954. invertNormalMapX: boolean;
  18955. private _invertNormalMapY;
  18956. /**
  18957. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  18958. */
  18959. invertNormalMapY: boolean;
  18960. private _twoSidedLighting;
  18961. /**
  18962. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  18963. */
  18964. twoSidedLighting: boolean;
  18965. /**
  18966. * Default configuration related to image processing available in the standard Material.
  18967. */
  18968. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18969. /**
  18970. * Gets the image processing configuration used either in this material.
  18971. */
  18972. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18973. /**
  18974. * Sets the Default image processing configuration used either in the this material.
  18975. *
  18976. * If sets to null, the scene one is in use.
  18977. */
  18978. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18979. /**
  18980. * Keep track of the image processing observer to allow dispose and replace.
  18981. */
  18982. private _imageProcessingObserver;
  18983. /**
  18984. * Attaches a new image processing configuration to the Standard Material.
  18985. * @param configuration
  18986. */
  18987. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18988. /**
  18989. * Defines additionnal PrePass parameters for the material.
  18990. */
  18991. readonly prePassConfiguration: PrePassConfiguration;
  18992. /**
  18993. * Gets wether the color curves effect is enabled.
  18994. */
  18995. get cameraColorCurvesEnabled(): boolean;
  18996. /**
  18997. * Sets wether the color curves effect is enabled.
  18998. */
  18999. set cameraColorCurvesEnabled(value: boolean);
  19000. /**
  19001. * Gets wether the color grading effect is enabled.
  19002. */
  19003. get cameraColorGradingEnabled(): boolean;
  19004. /**
  19005. * Gets wether the color grading effect is enabled.
  19006. */
  19007. set cameraColorGradingEnabled(value: boolean);
  19008. /**
  19009. * Gets wether tonemapping is enabled or not.
  19010. */
  19011. get cameraToneMappingEnabled(): boolean;
  19012. /**
  19013. * Sets wether tonemapping is enabled or not
  19014. */
  19015. set cameraToneMappingEnabled(value: boolean);
  19016. /**
  19017. * The camera exposure used on this material.
  19018. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19019. * This corresponds to a photographic exposure.
  19020. */
  19021. get cameraExposure(): number;
  19022. /**
  19023. * The camera exposure used on this material.
  19024. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19025. * This corresponds to a photographic exposure.
  19026. */
  19027. set cameraExposure(value: number);
  19028. /**
  19029. * Gets The camera contrast used on this material.
  19030. */
  19031. get cameraContrast(): number;
  19032. /**
  19033. * Sets The camera contrast used on this material.
  19034. */
  19035. set cameraContrast(value: number);
  19036. /**
  19037. * Gets the Color Grading 2D Lookup Texture.
  19038. */
  19039. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19040. /**
  19041. * Sets the Color Grading 2D Lookup Texture.
  19042. */
  19043. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19044. /**
  19045. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19046. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19047. * 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;
  19048. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19049. */
  19050. get cameraColorCurves(): Nullable<ColorCurves>;
  19051. /**
  19052. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19053. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19054. * 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;
  19055. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19056. */
  19057. set cameraColorCurves(value: Nullable<ColorCurves>);
  19058. /**
  19059. * Can this material render to several textures at once
  19060. */
  19061. get canRenderToMRT(): boolean;
  19062. /**
  19063. * Defines the detail map parameters for the material.
  19064. */
  19065. readonly detailMap: DetailMapConfiguration;
  19066. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19067. protected _worldViewProjectionMatrix: Matrix;
  19068. protected _globalAmbientColor: Color3;
  19069. protected _useLogarithmicDepth: boolean;
  19070. protected _rebuildInParallel: boolean;
  19071. /**
  19072. * Instantiates a new standard material.
  19073. * This is the default material used in Babylon. It is the best trade off between quality
  19074. * and performances.
  19075. * @see https://doc.babylonjs.com/babylon101/materials
  19076. * @param name Define the name of the material in the scene
  19077. * @param scene Define the scene the material belong to
  19078. */
  19079. constructor(name: string, scene: Scene);
  19080. /**
  19081. * Gets a boolean indicating that current material needs to register RTT
  19082. */
  19083. get hasRenderTargetTextures(): boolean;
  19084. /**
  19085. * Gets the current class name of the material e.g. "StandardMaterial"
  19086. * Mainly use in serialization.
  19087. * @returns the class name
  19088. */
  19089. getClassName(): string;
  19090. /**
  19091. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19092. * You can try switching to logarithmic depth.
  19093. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19094. */
  19095. get useLogarithmicDepth(): boolean;
  19096. set useLogarithmicDepth(value: boolean);
  19097. /**
  19098. * Specifies if the material will require alpha blending
  19099. * @returns a boolean specifying if alpha blending is needed
  19100. */
  19101. needAlphaBlending(): boolean;
  19102. /**
  19103. * Specifies if this material should be rendered in alpha test mode
  19104. * @returns a boolean specifying if an alpha test is needed.
  19105. */
  19106. needAlphaTesting(): boolean;
  19107. /**
  19108. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19109. */
  19110. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19111. /**
  19112. * Specifies whether or not there is a usable alpha channel for transparency.
  19113. */
  19114. protected _hasAlphaChannel(): boolean;
  19115. /**
  19116. * Get the texture used for alpha test purpose.
  19117. * @returns the diffuse texture in case of the standard material.
  19118. */
  19119. getAlphaTestTexture(): Nullable<BaseTexture>;
  19120. /**
  19121. * Get if the submesh is ready to be used and all its information available.
  19122. * Child classes can use it to update shaders
  19123. * @param mesh defines the mesh to check
  19124. * @param subMesh defines which submesh to check
  19125. * @param useInstances specifies that instances should be used
  19126. * @returns a boolean indicating that the submesh is ready or not
  19127. */
  19128. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19129. /**
  19130. * Builds the material UBO layouts.
  19131. * Used internally during the effect preparation.
  19132. */
  19133. buildUniformLayout(): void;
  19134. /**
  19135. * Unbinds the material from the mesh
  19136. */
  19137. unbind(): void;
  19138. /**
  19139. * Binds the submesh to this material by preparing the effect and shader to draw
  19140. * @param world defines the world transformation matrix
  19141. * @param mesh defines the mesh containing the submesh
  19142. * @param subMesh defines the submesh to bind the material to
  19143. */
  19144. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19145. /**
  19146. * Get the list of animatables in the material.
  19147. * @returns the list of animatables object used in the material
  19148. */
  19149. getAnimatables(): IAnimatable[];
  19150. /**
  19151. * Gets the active textures from the material
  19152. * @returns an array of textures
  19153. */
  19154. getActiveTextures(): BaseTexture[];
  19155. /**
  19156. * Specifies if the material uses a texture
  19157. * @param texture defines the texture to check against the material
  19158. * @returns a boolean specifying if the material uses the texture
  19159. */
  19160. hasTexture(texture: BaseTexture): boolean;
  19161. /**
  19162. * Disposes the material
  19163. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19164. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19165. */
  19166. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19167. /**
  19168. * Makes a duplicate of the material, and gives it a new name
  19169. * @param name defines the new name for the duplicated material
  19170. * @returns the cloned material
  19171. */
  19172. clone(name: string): StandardMaterial;
  19173. /**
  19174. * Serializes this material in a JSON representation
  19175. * @returns the serialized material object
  19176. */
  19177. serialize(): any;
  19178. /**
  19179. * Creates a standard material from parsed material data
  19180. * @param source defines the JSON representation of the material
  19181. * @param scene defines the hosting scene
  19182. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19183. * @returns a new standard material
  19184. */
  19185. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19186. /**
  19187. * Are diffuse textures enabled in the application.
  19188. */
  19189. static get DiffuseTextureEnabled(): boolean;
  19190. static set DiffuseTextureEnabled(value: boolean);
  19191. /**
  19192. * Are detail textures enabled in the application.
  19193. */
  19194. static get DetailTextureEnabled(): boolean;
  19195. static set DetailTextureEnabled(value: boolean);
  19196. /**
  19197. * Are ambient textures enabled in the application.
  19198. */
  19199. static get AmbientTextureEnabled(): boolean;
  19200. static set AmbientTextureEnabled(value: boolean);
  19201. /**
  19202. * Are opacity textures enabled in the application.
  19203. */
  19204. static get OpacityTextureEnabled(): boolean;
  19205. static set OpacityTextureEnabled(value: boolean);
  19206. /**
  19207. * Are reflection textures enabled in the application.
  19208. */
  19209. static get ReflectionTextureEnabled(): boolean;
  19210. static set ReflectionTextureEnabled(value: boolean);
  19211. /**
  19212. * Are emissive textures enabled in the application.
  19213. */
  19214. static get EmissiveTextureEnabled(): boolean;
  19215. static set EmissiveTextureEnabled(value: boolean);
  19216. /**
  19217. * Are specular textures enabled in the application.
  19218. */
  19219. static get SpecularTextureEnabled(): boolean;
  19220. static set SpecularTextureEnabled(value: boolean);
  19221. /**
  19222. * Are bump textures enabled in the application.
  19223. */
  19224. static get BumpTextureEnabled(): boolean;
  19225. static set BumpTextureEnabled(value: boolean);
  19226. /**
  19227. * Are lightmap textures enabled in the application.
  19228. */
  19229. static get LightmapTextureEnabled(): boolean;
  19230. static set LightmapTextureEnabled(value: boolean);
  19231. /**
  19232. * Are refraction textures enabled in the application.
  19233. */
  19234. static get RefractionTextureEnabled(): boolean;
  19235. static set RefractionTextureEnabled(value: boolean);
  19236. /**
  19237. * Are color grading textures enabled in the application.
  19238. */
  19239. static get ColorGradingTextureEnabled(): boolean;
  19240. static set ColorGradingTextureEnabled(value: boolean);
  19241. /**
  19242. * Are fresnels enabled in the application.
  19243. */
  19244. static get FresnelEnabled(): boolean;
  19245. static set FresnelEnabled(value: boolean);
  19246. }
  19247. }
  19248. declare module BABYLON {
  19249. /** @hidden */
  19250. export var rgbdDecodePixelShader: {
  19251. name: string;
  19252. shader: string;
  19253. };
  19254. }
  19255. declare module BABYLON {
  19256. /**
  19257. * Class used to host RGBD texture specific utilities
  19258. */
  19259. export class RGBDTextureTools {
  19260. /**
  19261. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19262. * @param texture the texture to expand.
  19263. */
  19264. static ExpandRGBDTexture(texture: Texture): void;
  19265. }
  19266. }
  19267. declare module BABYLON {
  19268. /**
  19269. * Class used to host texture specific utilities
  19270. */
  19271. export class BRDFTextureTools {
  19272. /**
  19273. * Prevents texture cache collision
  19274. */
  19275. private static _instanceNumber;
  19276. /**
  19277. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  19278. * @param scene defines the hosting scene
  19279. * @returns the environment BRDF texture
  19280. */
  19281. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  19282. private static _environmentBRDFBase64Texture;
  19283. }
  19284. }
  19285. declare module BABYLON {
  19286. /**
  19287. * @hidden
  19288. */
  19289. export interface IMaterialClearCoatDefines {
  19290. CLEARCOAT: boolean;
  19291. CLEARCOAT_DEFAULTIOR: boolean;
  19292. CLEARCOAT_TEXTURE: boolean;
  19293. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  19294. CLEARCOAT_TEXTUREDIRECTUV: number;
  19295. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  19296. CLEARCOAT_BUMP: boolean;
  19297. CLEARCOAT_BUMPDIRECTUV: number;
  19298. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19299. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19300. CLEARCOAT_REMAP_F0: boolean;
  19301. CLEARCOAT_TINT: boolean;
  19302. CLEARCOAT_TINT_TEXTURE: boolean;
  19303. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  19304. /** @hidden */
  19305. _areTexturesDirty: boolean;
  19306. }
  19307. /**
  19308. * Define the code related to the clear coat parameters of the pbr material.
  19309. */
  19310. export class PBRClearCoatConfiguration {
  19311. /**
  19312. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19313. * The default fits with a polyurethane material.
  19314. * @hidden
  19315. */
  19316. static readonly _DefaultIndexOfRefraction: number;
  19317. private _isEnabled;
  19318. /**
  19319. * Defines if the clear coat is enabled in the material.
  19320. */
  19321. isEnabled: boolean;
  19322. /**
  19323. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  19324. */
  19325. intensity: number;
  19326. /**
  19327. * Defines the clear coat layer roughness.
  19328. */
  19329. roughness: number;
  19330. private _indexOfRefraction;
  19331. /**
  19332. * Defines the index of refraction of the clear coat.
  19333. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19334. * The default fits with a polyurethane material.
  19335. * Changing the default value is more performance intensive.
  19336. */
  19337. indexOfRefraction: number;
  19338. private _texture;
  19339. /**
  19340. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  19341. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  19342. * if textureRoughness is not empty, else no texture roughness is used
  19343. */
  19344. texture: Nullable<BaseTexture>;
  19345. private _useRoughnessFromMainTexture;
  19346. /**
  19347. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  19348. * If false, the green channel from textureRoughness is used for roughness
  19349. */
  19350. useRoughnessFromMainTexture: boolean;
  19351. private _textureRoughness;
  19352. /**
  19353. * Stores the clear coat roughness in a texture (green channel)
  19354. * Not used if useRoughnessFromMainTexture is true
  19355. */
  19356. textureRoughness: Nullable<BaseTexture>;
  19357. private _remapF0OnInterfaceChange;
  19358. /**
  19359. * Defines if the F0 value should be remapped to account for the interface change in the material.
  19360. */
  19361. remapF0OnInterfaceChange: boolean;
  19362. private _bumpTexture;
  19363. /**
  19364. * Define the clear coat specific bump texture.
  19365. */
  19366. bumpTexture: Nullable<BaseTexture>;
  19367. private _isTintEnabled;
  19368. /**
  19369. * Defines if the clear coat tint is enabled in the material.
  19370. */
  19371. isTintEnabled: boolean;
  19372. /**
  19373. * Defines the clear coat tint of the material.
  19374. * This is only use if tint is enabled
  19375. */
  19376. tintColor: Color3;
  19377. /**
  19378. * Defines the distance at which the tint color should be found in the
  19379. * clear coat media.
  19380. * This is only use if tint is enabled
  19381. */
  19382. tintColorAtDistance: number;
  19383. /**
  19384. * Defines the clear coat layer thickness.
  19385. * This is only use if tint is enabled
  19386. */
  19387. tintThickness: number;
  19388. private _tintTexture;
  19389. /**
  19390. * Stores the clear tint values in a texture.
  19391. * rgb is tint
  19392. * a is a thickness factor
  19393. */
  19394. tintTexture: Nullable<BaseTexture>;
  19395. /** @hidden */
  19396. private _internalMarkAllSubMeshesAsTexturesDirty;
  19397. /** @hidden */
  19398. _markAllSubMeshesAsTexturesDirty(): void;
  19399. /**
  19400. * Instantiate a new istance of clear coat configuration.
  19401. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19402. */
  19403. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19404. /**
  19405. * Gets wehter the submesh is ready to be used or not.
  19406. * @param defines the list of "defines" to update.
  19407. * @param scene defines the scene the material belongs to.
  19408. * @param engine defines the engine the material belongs to.
  19409. * @param disableBumpMap defines wether the material disables bump or not.
  19410. * @returns - boolean indicating that the submesh is ready or not.
  19411. */
  19412. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  19413. /**
  19414. * Checks to see if a texture is used in the material.
  19415. * @param defines the list of "defines" to update.
  19416. * @param scene defines the scene to the material belongs to.
  19417. */
  19418. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  19419. /**
  19420. * Binds the material data.
  19421. * @param uniformBuffer defines the Uniform buffer to fill in.
  19422. * @param scene defines the scene the material belongs to.
  19423. * @param engine defines the engine the material belongs to.
  19424. * @param disableBumpMap defines wether the material disables bump or not.
  19425. * @param isFrozen defines wether the material is frozen or not.
  19426. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  19427. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  19428. * @param subMesh the submesh to bind data for
  19429. */
  19430. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  19431. /**
  19432. * Checks to see if a texture is used in the material.
  19433. * @param texture - Base texture to use.
  19434. * @returns - Boolean specifying if a texture is used in the material.
  19435. */
  19436. hasTexture(texture: BaseTexture): boolean;
  19437. /**
  19438. * Returns an array of the actively used textures.
  19439. * @param activeTextures Array of BaseTextures
  19440. */
  19441. getActiveTextures(activeTextures: BaseTexture[]): void;
  19442. /**
  19443. * Returns the animatable textures.
  19444. * @param animatables Array of animatable textures.
  19445. */
  19446. getAnimatables(animatables: IAnimatable[]): void;
  19447. /**
  19448. * Disposes the resources of the material.
  19449. * @param forceDisposeTextures - Forces the disposal of all textures.
  19450. */
  19451. dispose(forceDisposeTextures?: boolean): void;
  19452. /**
  19453. * Get the current class name of the texture useful for serialization or dynamic coding.
  19454. * @returns "PBRClearCoatConfiguration"
  19455. */
  19456. getClassName(): string;
  19457. /**
  19458. * Add fallbacks to the effect fallbacks list.
  19459. * @param defines defines the Base texture to use.
  19460. * @param fallbacks defines the current fallback list.
  19461. * @param currentRank defines the current fallback rank.
  19462. * @returns the new fallback rank.
  19463. */
  19464. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19465. /**
  19466. * Add the required uniforms to the current list.
  19467. * @param uniforms defines the current uniform list.
  19468. */
  19469. static AddUniforms(uniforms: string[]): void;
  19470. /**
  19471. * Add the required samplers to the current list.
  19472. * @param samplers defines the current sampler list.
  19473. */
  19474. static AddSamplers(samplers: string[]): void;
  19475. /**
  19476. * Add the required uniforms to the current buffer.
  19477. * @param uniformBuffer defines the current uniform buffer.
  19478. */
  19479. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19480. /**
  19481. * Makes a duplicate of the current configuration into another one.
  19482. * @param clearCoatConfiguration define the config where to copy the info
  19483. */
  19484. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  19485. /**
  19486. * Serializes this clear coat configuration.
  19487. * @returns - An object with the serialized config.
  19488. */
  19489. serialize(): any;
  19490. /**
  19491. * Parses a anisotropy Configuration from a serialized object.
  19492. * @param source - Serialized object.
  19493. * @param scene Defines the scene we are parsing for
  19494. * @param rootUrl Defines the rootUrl to load from
  19495. */
  19496. parse(source: any, scene: Scene, rootUrl: string): void;
  19497. }
  19498. }
  19499. declare module BABYLON {
  19500. /**
  19501. * @hidden
  19502. */
  19503. export interface IMaterialAnisotropicDefines {
  19504. ANISOTROPIC: boolean;
  19505. ANISOTROPIC_TEXTURE: boolean;
  19506. ANISOTROPIC_TEXTUREDIRECTUV: number;
  19507. MAINUV1: boolean;
  19508. _areTexturesDirty: boolean;
  19509. _needUVs: boolean;
  19510. }
  19511. /**
  19512. * Define the code related to the anisotropic parameters of the pbr material.
  19513. */
  19514. export class PBRAnisotropicConfiguration {
  19515. private _isEnabled;
  19516. /**
  19517. * Defines if the anisotropy is enabled in the material.
  19518. */
  19519. isEnabled: boolean;
  19520. /**
  19521. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  19522. */
  19523. intensity: number;
  19524. /**
  19525. * Defines if the effect is along the tangents, bitangents or in between.
  19526. * By default, the effect is "strectching" the highlights along the tangents.
  19527. */
  19528. direction: Vector2;
  19529. private _texture;
  19530. /**
  19531. * Stores the anisotropy values in a texture.
  19532. * rg is direction (like normal from -1 to 1)
  19533. * b is a intensity
  19534. */
  19535. texture: Nullable<BaseTexture>;
  19536. /** @hidden */
  19537. private _internalMarkAllSubMeshesAsTexturesDirty;
  19538. /** @hidden */
  19539. _markAllSubMeshesAsTexturesDirty(): void;
  19540. /**
  19541. * Instantiate a new istance of anisotropy configuration.
  19542. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19543. */
  19544. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19545. /**
  19546. * Specifies that the submesh is ready to be used.
  19547. * @param defines the list of "defines" to update.
  19548. * @param scene defines the scene the material belongs to.
  19549. * @returns - boolean indicating that the submesh is ready or not.
  19550. */
  19551. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  19552. /**
  19553. * Checks to see if a texture is used in the material.
  19554. * @param defines the list of "defines" to update.
  19555. * @param mesh the mesh we are preparing the defines for.
  19556. * @param scene defines the scene the material belongs to.
  19557. */
  19558. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  19559. /**
  19560. * Binds the material data.
  19561. * @param uniformBuffer defines the Uniform buffer to fill in.
  19562. * @param scene defines the scene the material belongs to.
  19563. * @param isFrozen defines wether the material is frozen or not.
  19564. */
  19565. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19566. /**
  19567. * Checks to see if a texture is used in the material.
  19568. * @param texture - Base texture to use.
  19569. * @returns - Boolean specifying if a texture is used in the material.
  19570. */
  19571. hasTexture(texture: BaseTexture): boolean;
  19572. /**
  19573. * Returns an array of the actively used textures.
  19574. * @param activeTextures Array of BaseTextures
  19575. */
  19576. getActiveTextures(activeTextures: BaseTexture[]): void;
  19577. /**
  19578. * Returns the animatable textures.
  19579. * @param animatables Array of animatable textures.
  19580. */
  19581. getAnimatables(animatables: IAnimatable[]): void;
  19582. /**
  19583. * Disposes the resources of the material.
  19584. * @param forceDisposeTextures - Forces the disposal of all textures.
  19585. */
  19586. dispose(forceDisposeTextures?: boolean): void;
  19587. /**
  19588. * Get the current class name of the texture useful for serialization or dynamic coding.
  19589. * @returns "PBRAnisotropicConfiguration"
  19590. */
  19591. getClassName(): string;
  19592. /**
  19593. * Add fallbacks to the effect fallbacks list.
  19594. * @param defines defines the Base texture to use.
  19595. * @param fallbacks defines the current fallback list.
  19596. * @param currentRank defines the current fallback rank.
  19597. * @returns the new fallback rank.
  19598. */
  19599. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19600. /**
  19601. * Add the required uniforms to the current list.
  19602. * @param uniforms defines the current uniform list.
  19603. */
  19604. static AddUniforms(uniforms: string[]): void;
  19605. /**
  19606. * Add the required uniforms to the current buffer.
  19607. * @param uniformBuffer defines the current uniform buffer.
  19608. */
  19609. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19610. /**
  19611. * Add the required samplers to the current list.
  19612. * @param samplers defines the current sampler list.
  19613. */
  19614. static AddSamplers(samplers: string[]): void;
  19615. /**
  19616. * Makes a duplicate of the current configuration into another one.
  19617. * @param anisotropicConfiguration define the config where to copy the info
  19618. */
  19619. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  19620. /**
  19621. * Serializes this anisotropy configuration.
  19622. * @returns - An object with the serialized config.
  19623. */
  19624. serialize(): any;
  19625. /**
  19626. * Parses a anisotropy Configuration from a serialized object.
  19627. * @param source - Serialized object.
  19628. * @param scene Defines the scene we are parsing for
  19629. * @param rootUrl Defines the rootUrl to load from
  19630. */
  19631. parse(source: any, scene: Scene, rootUrl: string): void;
  19632. }
  19633. }
  19634. declare module BABYLON {
  19635. /**
  19636. * @hidden
  19637. */
  19638. export interface IMaterialBRDFDefines {
  19639. BRDF_V_HEIGHT_CORRELATED: boolean;
  19640. MS_BRDF_ENERGY_CONSERVATION: boolean;
  19641. SPHERICAL_HARMONICS: boolean;
  19642. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  19643. /** @hidden */
  19644. _areMiscDirty: boolean;
  19645. }
  19646. /**
  19647. * Define the code related to the BRDF parameters of the pbr material.
  19648. */
  19649. export class PBRBRDFConfiguration {
  19650. /**
  19651. * Default value used for the energy conservation.
  19652. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19653. */
  19654. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  19655. /**
  19656. * Default value used for the Smith Visibility Height Correlated mode.
  19657. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19658. */
  19659. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  19660. /**
  19661. * Default value used for the IBL diffuse part.
  19662. * This can help switching back to the polynomials mode globally which is a tiny bit
  19663. * less GPU intensive at the drawback of a lower quality.
  19664. */
  19665. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  19666. /**
  19667. * Default value used for activating energy conservation for the specular workflow.
  19668. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19669. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19670. */
  19671. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  19672. private _useEnergyConservation;
  19673. /**
  19674. * Defines if the material uses energy conservation.
  19675. */
  19676. useEnergyConservation: boolean;
  19677. private _useSmithVisibilityHeightCorrelated;
  19678. /**
  19679. * LEGACY Mode set to false
  19680. * Defines if the material uses height smith correlated visibility term.
  19681. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  19682. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  19683. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  19684. * Not relying on height correlated will also disable energy conservation.
  19685. */
  19686. useSmithVisibilityHeightCorrelated: boolean;
  19687. private _useSphericalHarmonics;
  19688. /**
  19689. * LEGACY Mode set to false
  19690. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  19691. * diffuse part of the IBL.
  19692. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  19693. * to the ground truth.
  19694. */
  19695. useSphericalHarmonics: boolean;
  19696. private _useSpecularGlossinessInputEnergyConservation;
  19697. /**
  19698. * Defines if the material uses energy conservation, when the specular workflow is active.
  19699. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19700. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19701. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  19702. */
  19703. useSpecularGlossinessInputEnergyConservation: boolean;
  19704. /** @hidden */
  19705. private _internalMarkAllSubMeshesAsMiscDirty;
  19706. /** @hidden */
  19707. _markAllSubMeshesAsMiscDirty(): void;
  19708. /**
  19709. * Instantiate a new istance of clear coat configuration.
  19710. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  19711. */
  19712. constructor(markAllSubMeshesAsMiscDirty: () => void);
  19713. /**
  19714. * Checks to see if a texture is used in the material.
  19715. * @param defines the list of "defines" to update.
  19716. */
  19717. prepareDefines(defines: IMaterialBRDFDefines): void;
  19718. /**
  19719. * Get the current class name of the texture useful for serialization or dynamic coding.
  19720. * @returns "PBRClearCoatConfiguration"
  19721. */
  19722. getClassName(): string;
  19723. /**
  19724. * Makes a duplicate of the current configuration into another one.
  19725. * @param brdfConfiguration define the config where to copy the info
  19726. */
  19727. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  19728. /**
  19729. * Serializes this BRDF configuration.
  19730. * @returns - An object with the serialized config.
  19731. */
  19732. serialize(): any;
  19733. /**
  19734. * Parses a anisotropy Configuration from a serialized object.
  19735. * @param source - Serialized object.
  19736. * @param scene Defines the scene we are parsing for
  19737. * @param rootUrl Defines the rootUrl to load from
  19738. */
  19739. parse(source: any, scene: Scene, rootUrl: string): void;
  19740. }
  19741. }
  19742. declare module BABYLON {
  19743. /**
  19744. * @hidden
  19745. */
  19746. export interface IMaterialSheenDefines {
  19747. SHEEN: boolean;
  19748. SHEEN_TEXTURE: boolean;
  19749. SHEEN_TEXTURE_ROUGHNESS: boolean;
  19750. SHEEN_TEXTUREDIRECTUV: number;
  19751. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  19752. SHEEN_LINKWITHALBEDO: boolean;
  19753. SHEEN_ROUGHNESS: boolean;
  19754. SHEEN_ALBEDOSCALING: boolean;
  19755. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19756. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19757. /** @hidden */
  19758. _areTexturesDirty: boolean;
  19759. }
  19760. /**
  19761. * Define the code related to the Sheen parameters of the pbr material.
  19762. */
  19763. export class PBRSheenConfiguration {
  19764. private _isEnabled;
  19765. /**
  19766. * Defines if the material uses sheen.
  19767. */
  19768. isEnabled: boolean;
  19769. private _linkSheenWithAlbedo;
  19770. /**
  19771. * Defines if the sheen is linked to the sheen color.
  19772. */
  19773. linkSheenWithAlbedo: boolean;
  19774. /**
  19775. * Defines the sheen intensity.
  19776. */
  19777. intensity: number;
  19778. /**
  19779. * Defines the sheen color.
  19780. */
  19781. color: Color3;
  19782. private _texture;
  19783. /**
  19784. * Stores the sheen tint values in a texture.
  19785. * rgb is tint
  19786. * 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)
  19787. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  19788. */
  19789. texture: Nullable<BaseTexture>;
  19790. private _useRoughnessFromMainTexture;
  19791. /**
  19792. * Indicates that the alpha channel of the texture property will be used for roughness.
  19793. * Has no effect if the roughness (and texture!) property is not defined
  19794. */
  19795. useRoughnessFromMainTexture: boolean;
  19796. private _roughness;
  19797. /**
  19798. * Defines the sheen roughness.
  19799. * It is not taken into account if linkSheenWithAlbedo is true.
  19800. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  19801. */
  19802. roughness: Nullable<number>;
  19803. private _textureRoughness;
  19804. /**
  19805. * Stores the sheen roughness in a texture.
  19806. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  19807. */
  19808. textureRoughness: Nullable<BaseTexture>;
  19809. private _albedoScaling;
  19810. /**
  19811. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  19812. * It allows the strength of the sheen effect to not depend on the base color of the material,
  19813. * making it easier to setup and tweak the effect
  19814. */
  19815. albedoScaling: boolean;
  19816. /** @hidden */
  19817. private _internalMarkAllSubMeshesAsTexturesDirty;
  19818. /** @hidden */
  19819. _markAllSubMeshesAsTexturesDirty(): void;
  19820. /**
  19821. * Instantiate a new istance of clear coat configuration.
  19822. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19823. */
  19824. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19825. /**
  19826. * Specifies that the submesh is ready to be used.
  19827. * @param defines the list of "defines" to update.
  19828. * @param scene defines the scene the material belongs to.
  19829. * @returns - boolean indicating that the submesh is ready or not.
  19830. */
  19831. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  19832. /**
  19833. * Checks to see if a texture is used in the material.
  19834. * @param defines the list of "defines" to update.
  19835. * @param scene defines the scene the material belongs to.
  19836. */
  19837. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  19838. /**
  19839. * Binds the material data.
  19840. * @param uniformBuffer defines the Uniform buffer to fill in.
  19841. * @param scene defines the scene the material belongs to.
  19842. * @param isFrozen defines wether the material is frozen or not.
  19843. * @param subMesh the submesh to bind data for
  19844. */
  19845. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  19846. /**
  19847. * Checks to see if a texture is used in the material.
  19848. * @param texture - Base texture to use.
  19849. * @returns - Boolean specifying if a texture is used in the material.
  19850. */
  19851. hasTexture(texture: BaseTexture): boolean;
  19852. /**
  19853. * Returns an array of the actively used textures.
  19854. * @param activeTextures Array of BaseTextures
  19855. */
  19856. getActiveTextures(activeTextures: BaseTexture[]): void;
  19857. /**
  19858. * Returns the animatable textures.
  19859. * @param animatables Array of animatable textures.
  19860. */
  19861. getAnimatables(animatables: IAnimatable[]): void;
  19862. /**
  19863. * Disposes the resources of the material.
  19864. * @param forceDisposeTextures - Forces the disposal of all textures.
  19865. */
  19866. dispose(forceDisposeTextures?: boolean): void;
  19867. /**
  19868. * Get the current class name of the texture useful for serialization or dynamic coding.
  19869. * @returns "PBRSheenConfiguration"
  19870. */
  19871. getClassName(): string;
  19872. /**
  19873. * Add fallbacks to the effect fallbacks list.
  19874. * @param defines defines the Base texture to use.
  19875. * @param fallbacks defines the current fallback list.
  19876. * @param currentRank defines the current fallback rank.
  19877. * @returns the new fallback rank.
  19878. */
  19879. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19880. /**
  19881. * Add the required uniforms to the current list.
  19882. * @param uniforms defines the current uniform list.
  19883. */
  19884. static AddUniforms(uniforms: string[]): void;
  19885. /**
  19886. * Add the required uniforms to the current buffer.
  19887. * @param uniformBuffer defines the current uniform buffer.
  19888. */
  19889. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19890. /**
  19891. * Add the required samplers to the current list.
  19892. * @param samplers defines the current sampler list.
  19893. */
  19894. static AddSamplers(samplers: string[]): void;
  19895. /**
  19896. * Makes a duplicate of the current configuration into another one.
  19897. * @param sheenConfiguration define the config where to copy the info
  19898. */
  19899. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  19900. /**
  19901. * Serializes this BRDF configuration.
  19902. * @returns - An object with the serialized config.
  19903. */
  19904. serialize(): any;
  19905. /**
  19906. * Parses a anisotropy Configuration from a serialized object.
  19907. * @param source - Serialized object.
  19908. * @param scene Defines the scene we are parsing for
  19909. * @param rootUrl Defines the rootUrl to load from
  19910. */
  19911. parse(source: any, scene: Scene, rootUrl: string): void;
  19912. }
  19913. }
  19914. declare module BABYLON {
  19915. /**
  19916. * @hidden
  19917. */
  19918. export interface IMaterialSubSurfaceDefines {
  19919. SUBSURFACE: boolean;
  19920. SS_REFRACTION: boolean;
  19921. SS_TRANSLUCENCY: boolean;
  19922. SS_SCATTERING: boolean;
  19923. SS_THICKNESSANDMASK_TEXTURE: boolean;
  19924. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  19925. SS_REFRACTIONMAP_3D: boolean;
  19926. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  19927. SS_LODINREFRACTIONALPHA: boolean;
  19928. SS_GAMMAREFRACTION: boolean;
  19929. SS_RGBDREFRACTION: boolean;
  19930. SS_LINEARSPECULARREFRACTION: boolean;
  19931. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  19932. SS_ALBEDOFORREFRACTIONTINT: boolean;
  19933. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  19934. /** @hidden */
  19935. _areTexturesDirty: boolean;
  19936. }
  19937. /**
  19938. * Define the code related to the sub surface parameters of the pbr material.
  19939. */
  19940. export class PBRSubSurfaceConfiguration {
  19941. private _isRefractionEnabled;
  19942. /**
  19943. * Defines if the refraction is enabled in the material.
  19944. */
  19945. isRefractionEnabled: boolean;
  19946. private _isTranslucencyEnabled;
  19947. /**
  19948. * Defines if the translucency is enabled in the material.
  19949. */
  19950. isTranslucencyEnabled: boolean;
  19951. private _isScatteringEnabled;
  19952. /**
  19953. * Defines if the sub surface scattering is enabled in the material.
  19954. */
  19955. isScatteringEnabled: boolean;
  19956. private _scatteringDiffusionProfileIndex;
  19957. /**
  19958. * Diffusion profile for subsurface scattering.
  19959. * Useful for better scattering in the skins or foliages.
  19960. */
  19961. get scatteringDiffusionProfile(): Nullable<Color3>;
  19962. set scatteringDiffusionProfile(c: Nullable<Color3>);
  19963. /**
  19964. * Defines the refraction intensity of the material.
  19965. * The refraction when enabled replaces the Diffuse part of the material.
  19966. * The intensity helps transitionning between diffuse and refraction.
  19967. */
  19968. refractionIntensity: number;
  19969. /**
  19970. * Defines the translucency intensity of the material.
  19971. * When translucency has been enabled, this defines how much of the "translucency"
  19972. * is addded to the diffuse part of the material.
  19973. */
  19974. translucencyIntensity: number;
  19975. /**
  19976. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  19977. */
  19978. useAlbedoToTintRefraction: boolean;
  19979. private _thicknessTexture;
  19980. /**
  19981. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  19982. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  19983. * 0 would mean minimumThickness
  19984. * 1 would mean maximumThickness
  19985. * The other channels might be use as a mask to vary the different effects intensity.
  19986. */
  19987. thicknessTexture: Nullable<BaseTexture>;
  19988. private _refractionTexture;
  19989. /**
  19990. * Defines the texture to use for refraction.
  19991. */
  19992. refractionTexture: Nullable<BaseTexture>;
  19993. private _indexOfRefraction;
  19994. /**
  19995. * Index of refraction of the material base layer.
  19996. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  19997. *
  19998. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  19999. *
  20000. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20001. */
  20002. indexOfRefraction: number;
  20003. private _volumeIndexOfRefraction;
  20004. /**
  20005. * Index of refraction of the material's volume.
  20006. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20007. *
  20008. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20009. * the volume will use the same IOR as the surface.
  20010. */
  20011. get volumeIndexOfRefraction(): number;
  20012. set volumeIndexOfRefraction(value: number);
  20013. private _invertRefractionY;
  20014. /**
  20015. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20016. */
  20017. invertRefractionY: boolean;
  20018. private _linkRefractionWithTransparency;
  20019. /**
  20020. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20021. * Materials half opaque for instance using refraction could benefit from this control.
  20022. */
  20023. linkRefractionWithTransparency: boolean;
  20024. /**
  20025. * Defines the minimum thickness stored in the thickness map.
  20026. * If no thickness map is defined, this value will be used to simulate thickness.
  20027. */
  20028. minimumThickness: number;
  20029. /**
  20030. * Defines the maximum thickness stored in the thickness map.
  20031. */
  20032. maximumThickness: number;
  20033. /**
  20034. * Defines the volume tint of the material.
  20035. * This is used for both translucency and scattering.
  20036. */
  20037. tintColor: Color3;
  20038. /**
  20039. * Defines the distance at which the tint color should be found in the media.
  20040. * This is used for refraction only.
  20041. */
  20042. tintColorAtDistance: number;
  20043. /**
  20044. * Defines how far each channel transmit through the media.
  20045. * It is defined as a color to simplify it selection.
  20046. */
  20047. diffusionDistance: Color3;
  20048. private _useMaskFromThicknessTexture;
  20049. /**
  20050. * Stores the intensity of the different subsurface effects in the thickness texture.
  20051. * * the green channel is the translucency intensity.
  20052. * * the blue channel is the scattering intensity.
  20053. * * the alpha channel is the refraction intensity.
  20054. */
  20055. useMaskFromThicknessTexture: boolean;
  20056. private _scene;
  20057. /** @hidden */
  20058. private _internalMarkAllSubMeshesAsTexturesDirty;
  20059. private _internalMarkScenePrePassDirty;
  20060. /** @hidden */
  20061. _markAllSubMeshesAsTexturesDirty(): void;
  20062. /** @hidden */
  20063. _markScenePrePassDirty(): void;
  20064. /**
  20065. * Instantiate a new istance of sub surface configuration.
  20066. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20067. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20068. * @param scene The scene
  20069. */
  20070. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20071. /**
  20072. * Gets wehter the submesh is ready to be used or not.
  20073. * @param defines the list of "defines" to update.
  20074. * @param scene defines the scene the material belongs to.
  20075. * @returns - boolean indicating that the submesh is ready or not.
  20076. */
  20077. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20078. /**
  20079. * Checks to see if a texture is used in the material.
  20080. * @param defines the list of "defines" to update.
  20081. * @param scene defines the scene to the material belongs to.
  20082. */
  20083. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20084. /**
  20085. * Binds the material data.
  20086. * @param uniformBuffer defines the Uniform buffer to fill in.
  20087. * @param scene defines the scene the material belongs to.
  20088. * @param engine defines the engine the material belongs to.
  20089. * @param isFrozen defines whether the material is frozen or not.
  20090. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20091. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20092. */
  20093. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20094. /**
  20095. * Unbinds the material from the mesh.
  20096. * @param activeEffect defines the effect that should be unbound from.
  20097. * @returns true if unbound, otherwise false
  20098. */
  20099. unbind(activeEffect: Effect): boolean;
  20100. /**
  20101. * Returns the texture used for refraction or null if none is used.
  20102. * @param scene defines the scene the material belongs to.
  20103. * @returns - Refraction texture if present. If no refraction texture and refraction
  20104. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20105. */
  20106. private _getRefractionTexture;
  20107. /**
  20108. * Returns true if alpha blending should be disabled.
  20109. */
  20110. get disableAlphaBlending(): boolean;
  20111. /**
  20112. * Fills the list of render target textures.
  20113. * @param renderTargets the list of render targets to update
  20114. */
  20115. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20116. /**
  20117. * Checks to see if a texture is used in the material.
  20118. * @param texture - Base texture to use.
  20119. * @returns - Boolean specifying if a texture is used in the material.
  20120. */
  20121. hasTexture(texture: BaseTexture): boolean;
  20122. /**
  20123. * Gets a boolean indicating that current material needs to register RTT
  20124. * @returns true if this uses a render target otherwise false.
  20125. */
  20126. hasRenderTargetTextures(): boolean;
  20127. /**
  20128. * Returns an array of the actively used textures.
  20129. * @param activeTextures Array of BaseTextures
  20130. */
  20131. getActiveTextures(activeTextures: BaseTexture[]): void;
  20132. /**
  20133. * Returns the animatable textures.
  20134. * @param animatables Array of animatable textures.
  20135. */
  20136. getAnimatables(animatables: IAnimatable[]): void;
  20137. /**
  20138. * Disposes the resources of the material.
  20139. * @param forceDisposeTextures - Forces the disposal of all textures.
  20140. */
  20141. dispose(forceDisposeTextures?: boolean): void;
  20142. /**
  20143. * Get the current class name of the texture useful for serialization or dynamic coding.
  20144. * @returns "PBRSubSurfaceConfiguration"
  20145. */
  20146. getClassName(): string;
  20147. /**
  20148. * Add fallbacks to the effect fallbacks list.
  20149. * @param defines defines the Base texture to use.
  20150. * @param fallbacks defines the current fallback list.
  20151. * @param currentRank defines the current fallback rank.
  20152. * @returns the new fallback rank.
  20153. */
  20154. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20155. /**
  20156. * Add the required uniforms to the current list.
  20157. * @param uniforms defines the current uniform list.
  20158. */
  20159. static AddUniforms(uniforms: string[]): void;
  20160. /**
  20161. * Add the required samplers to the current list.
  20162. * @param samplers defines the current sampler list.
  20163. */
  20164. static AddSamplers(samplers: string[]): void;
  20165. /**
  20166. * Add the required uniforms to the current buffer.
  20167. * @param uniformBuffer defines the current uniform buffer.
  20168. */
  20169. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20170. /**
  20171. * Makes a duplicate of the current configuration into another one.
  20172. * @param configuration define the config where to copy the info
  20173. */
  20174. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20175. /**
  20176. * Serializes this Sub Surface configuration.
  20177. * @returns - An object with the serialized config.
  20178. */
  20179. serialize(): any;
  20180. /**
  20181. * Parses a anisotropy Configuration from a serialized object.
  20182. * @param source - Serialized object.
  20183. * @param scene Defines the scene we are parsing for
  20184. * @param rootUrl Defines the rootUrl to load from
  20185. */
  20186. parse(source: any, scene: Scene, rootUrl: string): void;
  20187. }
  20188. }
  20189. declare module BABYLON {
  20190. /**
  20191. * Class representing spherical harmonics coefficients to the 3rd degree
  20192. */
  20193. export class SphericalHarmonics {
  20194. /**
  20195. * Defines whether or not the harmonics have been prescaled for rendering.
  20196. */
  20197. preScaled: boolean;
  20198. /**
  20199. * The l0,0 coefficients of the spherical harmonics
  20200. */
  20201. l00: Vector3;
  20202. /**
  20203. * The l1,-1 coefficients of the spherical harmonics
  20204. */
  20205. l1_1: Vector3;
  20206. /**
  20207. * The l1,0 coefficients of the spherical harmonics
  20208. */
  20209. l10: Vector3;
  20210. /**
  20211. * The l1,1 coefficients of the spherical harmonics
  20212. */
  20213. l11: Vector3;
  20214. /**
  20215. * The l2,-2 coefficients of the spherical harmonics
  20216. */
  20217. l2_2: Vector3;
  20218. /**
  20219. * The l2,-1 coefficients of the spherical harmonics
  20220. */
  20221. l2_1: Vector3;
  20222. /**
  20223. * The l2,0 coefficients of the spherical harmonics
  20224. */
  20225. l20: Vector3;
  20226. /**
  20227. * The l2,1 coefficients of the spherical harmonics
  20228. */
  20229. l21: Vector3;
  20230. /**
  20231. * The l2,2 coefficients of the spherical harmonics
  20232. */
  20233. l22: Vector3;
  20234. /**
  20235. * Adds a light to the spherical harmonics
  20236. * @param direction the direction of the light
  20237. * @param color the color of the light
  20238. * @param deltaSolidAngle the delta solid angle of the light
  20239. */
  20240. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20241. /**
  20242. * Scales the spherical harmonics by the given amount
  20243. * @param scale the amount to scale
  20244. */
  20245. scaleInPlace(scale: number): void;
  20246. /**
  20247. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20248. *
  20249. * ```
  20250. * E_lm = A_l * L_lm
  20251. * ```
  20252. *
  20253. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20254. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20255. * the scaling factors are given in equation 9.
  20256. */
  20257. convertIncidentRadianceToIrradiance(): void;
  20258. /**
  20259. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20260. *
  20261. * ```
  20262. * L = (1/pi) * E * rho
  20263. * ```
  20264. *
  20265. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20266. */
  20267. convertIrradianceToLambertianRadiance(): void;
  20268. /**
  20269. * Integrates the reconstruction coefficients directly in to the SH preventing further
  20270. * required operations at run time.
  20271. *
  20272. * This is simply done by scaling back the SH with Ylm constants parameter.
  20273. * The trigonometric part being applied by the shader at run time.
  20274. */
  20275. preScaleForRendering(): void;
  20276. /**
  20277. * Constructs a spherical harmonics from an array.
  20278. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20279. * @returns the spherical harmonics
  20280. */
  20281. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20282. /**
  20283. * Gets the spherical harmonics from polynomial
  20284. * @param polynomial the spherical polynomial
  20285. * @returns the spherical harmonics
  20286. */
  20287. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20288. }
  20289. /**
  20290. * Class representing spherical polynomial coefficients to the 3rd degree
  20291. */
  20292. export class SphericalPolynomial {
  20293. private _harmonics;
  20294. /**
  20295. * The spherical harmonics used to create the polynomials.
  20296. */
  20297. get preScaledHarmonics(): SphericalHarmonics;
  20298. /**
  20299. * The x coefficients of the spherical polynomial
  20300. */
  20301. x: Vector3;
  20302. /**
  20303. * The y coefficients of the spherical polynomial
  20304. */
  20305. y: Vector3;
  20306. /**
  20307. * The z coefficients of the spherical polynomial
  20308. */
  20309. z: Vector3;
  20310. /**
  20311. * The xx coefficients of the spherical polynomial
  20312. */
  20313. xx: Vector3;
  20314. /**
  20315. * The yy coefficients of the spherical polynomial
  20316. */
  20317. yy: Vector3;
  20318. /**
  20319. * The zz coefficients of the spherical polynomial
  20320. */
  20321. zz: Vector3;
  20322. /**
  20323. * The xy coefficients of the spherical polynomial
  20324. */
  20325. xy: Vector3;
  20326. /**
  20327. * The yz coefficients of the spherical polynomial
  20328. */
  20329. yz: Vector3;
  20330. /**
  20331. * The zx coefficients of the spherical polynomial
  20332. */
  20333. zx: Vector3;
  20334. /**
  20335. * Adds an ambient color to the spherical polynomial
  20336. * @param color the color to add
  20337. */
  20338. addAmbient(color: Color3): void;
  20339. /**
  20340. * Scales the spherical polynomial by the given amount
  20341. * @param scale the amount to scale
  20342. */
  20343. scaleInPlace(scale: number): void;
  20344. /**
  20345. * Gets the spherical polynomial from harmonics
  20346. * @param harmonics the spherical harmonics
  20347. * @returns the spherical polynomial
  20348. */
  20349. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  20350. /**
  20351. * Constructs a spherical polynomial from an array.
  20352. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  20353. * @returns the spherical polynomial
  20354. */
  20355. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  20356. }
  20357. }
  20358. declare module BABYLON {
  20359. /**
  20360. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  20361. */
  20362. export interface CubeMapInfo {
  20363. /**
  20364. * The pixel array for the front face.
  20365. * This is stored in format, left to right, up to down format.
  20366. */
  20367. front: Nullable<ArrayBufferView>;
  20368. /**
  20369. * The pixel array for the back face.
  20370. * This is stored in format, left to right, up to down format.
  20371. */
  20372. back: Nullable<ArrayBufferView>;
  20373. /**
  20374. * The pixel array for the left face.
  20375. * This is stored in format, left to right, up to down format.
  20376. */
  20377. left: Nullable<ArrayBufferView>;
  20378. /**
  20379. * The pixel array for the right face.
  20380. * This is stored in format, left to right, up to down format.
  20381. */
  20382. right: Nullable<ArrayBufferView>;
  20383. /**
  20384. * The pixel array for the up face.
  20385. * This is stored in format, left to right, up to down format.
  20386. */
  20387. up: Nullable<ArrayBufferView>;
  20388. /**
  20389. * The pixel array for the down face.
  20390. * This is stored in format, left to right, up to down format.
  20391. */
  20392. down: Nullable<ArrayBufferView>;
  20393. /**
  20394. * The size of the cubemap stored.
  20395. *
  20396. * Each faces will be size * size pixels.
  20397. */
  20398. size: number;
  20399. /**
  20400. * The format of the texture.
  20401. *
  20402. * RGBA, RGB.
  20403. */
  20404. format: number;
  20405. /**
  20406. * The type of the texture data.
  20407. *
  20408. * UNSIGNED_INT, FLOAT.
  20409. */
  20410. type: number;
  20411. /**
  20412. * Specifies whether the texture is in gamma space.
  20413. */
  20414. gammaSpace: boolean;
  20415. }
  20416. /**
  20417. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  20418. */
  20419. export class PanoramaToCubeMapTools {
  20420. private static FACE_LEFT;
  20421. private static FACE_RIGHT;
  20422. private static FACE_FRONT;
  20423. private static FACE_BACK;
  20424. private static FACE_DOWN;
  20425. private static FACE_UP;
  20426. /**
  20427. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  20428. *
  20429. * @param float32Array The source data.
  20430. * @param inputWidth The width of the input panorama.
  20431. * @param inputHeight The height of the input panorama.
  20432. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  20433. * @return The cubemap data
  20434. */
  20435. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  20436. private static CreateCubemapTexture;
  20437. private static CalcProjectionSpherical;
  20438. }
  20439. }
  20440. declare module BABYLON {
  20441. /**
  20442. * Helper class dealing with the extraction of spherical polynomial dataArray
  20443. * from a cube map.
  20444. */
  20445. export class CubeMapToSphericalPolynomialTools {
  20446. private static FileFaces;
  20447. /**
  20448. * Converts a texture to the according Spherical Polynomial data.
  20449. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20450. *
  20451. * @param texture The texture to extract the information from.
  20452. * @return The Spherical Polynomial data.
  20453. */
  20454. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  20455. /**
  20456. * Converts a cubemap to the according Spherical Polynomial data.
  20457. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20458. *
  20459. * @param cubeInfo The Cube map to extract the information from.
  20460. * @return The Spherical Polynomial data.
  20461. */
  20462. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  20463. }
  20464. }
  20465. declare module BABYLON {
  20466. interface BaseTexture {
  20467. /**
  20468. * Get the polynomial representation of the texture data.
  20469. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  20470. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  20471. */
  20472. sphericalPolynomial: Nullable<SphericalPolynomial>;
  20473. }
  20474. }
  20475. declare module BABYLON {
  20476. /** @hidden */
  20477. export var pbrFragmentDeclaration: {
  20478. name: string;
  20479. shader: string;
  20480. };
  20481. }
  20482. declare module BABYLON {
  20483. /** @hidden */
  20484. export var pbrUboDeclaration: {
  20485. name: string;
  20486. shader: string;
  20487. };
  20488. }
  20489. declare module BABYLON {
  20490. /** @hidden */
  20491. export var pbrFragmentExtraDeclaration: {
  20492. name: string;
  20493. shader: string;
  20494. };
  20495. }
  20496. declare module BABYLON {
  20497. /** @hidden */
  20498. export var pbrFragmentSamplersDeclaration: {
  20499. name: string;
  20500. shader: string;
  20501. };
  20502. }
  20503. declare module BABYLON {
  20504. /** @hidden */
  20505. export var subSurfaceScatteringFunctions: {
  20506. name: string;
  20507. shader: string;
  20508. };
  20509. }
  20510. declare module BABYLON {
  20511. /** @hidden */
  20512. export var importanceSampling: {
  20513. name: string;
  20514. shader: string;
  20515. };
  20516. }
  20517. declare module BABYLON {
  20518. /** @hidden */
  20519. export var pbrHelperFunctions: {
  20520. name: string;
  20521. shader: string;
  20522. };
  20523. }
  20524. declare module BABYLON {
  20525. /** @hidden */
  20526. export var harmonicsFunctions: {
  20527. name: string;
  20528. shader: string;
  20529. };
  20530. }
  20531. declare module BABYLON {
  20532. /** @hidden */
  20533. export var pbrDirectLightingSetupFunctions: {
  20534. name: string;
  20535. shader: string;
  20536. };
  20537. }
  20538. declare module BABYLON {
  20539. /** @hidden */
  20540. export var pbrDirectLightingFalloffFunctions: {
  20541. name: string;
  20542. shader: string;
  20543. };
  20544. }
  20545. declare module BABYLON {
  20546. /** @hidden */
  20547. export var pbrBRDFFunctions: {
  20548. name: string;
  20549. shader: string;
  20550. };
  20551. }
  20552. declare module BABYLON {
  20553. /** @hidden */
  20554. export var hdrFilteringFunctions: {
  20555. name: string;
  20556. shader: string;
  20557. };
  20558. }
  20559. declare module BABYLON {
  20560. /** @hidden */
  20561. export var pbrDirectLightingFunctions: {
  20562. name: string;
  20563. shader: string;
  20564. };
  20565. }
  20566. declare module BABYLON {
  20567. /** @hidden */
  20568. export var pbrIBLFunctions: {
  20569. name: string;
  20570. shader: string;
  20571. };
  20572. }
  20573. declare module BABYLON {
  20574. /** @hidden */
  20575. export var pbrBlockAlbedoOpacity: {
  20576. name: string;
  20577. shader: string;
  20578. };
  20579. }
  20580. declare module BABYLON {
  20581. /** @hidden */
  20582. export var pbrBlockReflectivity: {
  20583. name: string;
  20584. shader: string;
  20585. };
  20586. }
  20587. declare module BABYLON {
  20588. /** @hidden */
  20589. export var pbrBlockAmbientOcclusion: {
  20590. name: string;
  20591. shader: string;
  20592. };
  20593. }
  20594. declare module BABYLON {
  20595. /** @hidden */
  20596. export var pbrBlockAlphaFresnel: {
  20597. name: string;
  20598. shader: string;
  20599. };
  20600. }
  20601. declare module BABYLON {
  20602. /** @hidden */
  20603. export var pbrBlockAnisotropic: {
  20604. name: string;
  20605. shader: string;
  20606. };
  20607. }
  20608. declare module BABYLON {
  20609. /** @hidden */
  20610. export var pbrBlockReflection: {
  20611. name: string;
  20612. shader: string;
  20613. };
  20614. }
  20615. declare module BABYLON {
  20616. /** @hidden */
  20617. export var pbrBlockSheen: {
  20618. name: string;
  20619. shader: string;
  20620. };
  20621. }
  20622. declare module BABYLON {
  20623. /** @hidden */
  20624. export var pbrBlockClearcoat: {
  20625. name: string;
  20626. shader: string;
  20627. };
  20628. }
  20629. declare module BABYLON {
  20630. /** @hidden */
  20631. export var pbrBlockSubSurface: {
  20632. name: string;
  20633. shader: string;
  20634. };
  20635. }
  20636. declare module BABYLON {
  20637. /** @hidden */
  20638. export var pbrBlockNormalGeometric: {
  20639. name: string;
  20640. shader: string;
  20641. };
  20642. }
  20643. declare module BABYLON {
  20644. /** @hidden */
  20645. export var pbrBlockNormalFinal: {
  20646. name: string;
  20647. shader: string;
  20648. };
  20649. }
  20650. declare module BABYLON {
  20651. /** @hidden */
  20652. export var pbrBlockLightmapInit: {
  20653. name: string;
  20654. shader: string;
  20655. };
  20656. }
  20657. declare module BABYLON {
  20658. /** @hidden */
  20659. export var pbrBlockGeometryInfo: {
  20660. name: string;
  20661. shader: string;
  20662. };
  20663. }
  20664. declare module BABYLON {
  20665. /** @hidden */
  20666. export var pbrBlockReflectance0: {
  20667. name: string;
  20668. shader: string;
  20669. };
  20670. }
  20671. declare module BABYLON {
  20672. /** @hidden */
  20673. export var pbrBlockReflectance: {
  20674. name: string;
  20675. shader: string;
  20676. };
  20677. }
  20678. declare module BABYLON {
  20679. /** @hidden */
  20680. export var pbrBlockDirectLighting: {
  20681. name: string;
  20682. shader: string;
  20683. };
  20684. }
  20685. declare module BABYLON {
  20686. /** @hidden */
  20687. export var pbrBlockFinalLitComponents: {
  20688. name: string;
  20689. shader: string;
  20690. };
  20691. }
  20692. declare module BABYLON {
  20693. /** @hidden */
  20694. export var pbrBlockFinalUnlitComponents: {
  20695. name: string;
  20696. shader: string;
  20697. };
  20698. }
  20699. declare module BABYLON {
  20700. /** @hidden */
  20701. export var pbrBlockFinalColorComposition: {
  20702. name: string;
  20703. shader: string;
  20704. };
  20705. }
  20706. declare module BABYLON {
  20707. /** @hidden */
  20708. export var pbrBlockImageProcessing: {
  20709. name: string;
  20710. shader: string;
  20711. };
  20712. }
  20713. declare module BABYLON {
  20714. /** @hidden */
  20715. export var pbrDebug: {
  20716. name: string;
  20717. shader: string;
  20718. };
  20719. }
  20720. declare module BABYLON {
  20721. /** @hidden */
  20722. export var pbrPixelShader: {
  20723. name: string;
  20724. shader: string;
  20725. };
  20726. }
  20727. declare module BABYLON {
  20728. /** @hidden */
  20729. export var pbrVertexDeclaration: {
  20730. name: string;
  20731. shader: string;
  20732. };
  20733. }
  20734. declare module BABYLON {
  20735. /** @hidden */
  20736. export var pbrVertexShader: {
  20737. name: string;
  20738. shader: string;
  20739. };
  20740. }
  20741. declare module BABYLON {
  20742. /**
  20743. * Manages the defines for the PBR Material.
  20744. * @hidden
  20745. */
  20746. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  20747. PBR: boolean;
  20748. NUM_SAMPLES: string;
  20749. REALTIME_FILTERING: boolean;
  20750. MAINUV1: boolean;
  20751. MAINUV2: boolean;
  20752. UV1: boolean;
  20753. UV2: boolean;
  20754. ALBEDO: boolean;
  20755. GAMMAALBEDO: boolean;
  20756. ALBEDODIRECTUV: number;
  20757. VERTEXCOLOR: boolean;
  20758. DETAIL: boolean;
  20759. DETAILDIRECTUV: number;
  20760. DETAIL_NORMALBLENDMETHOD: number;
  20761. AMBIENT: boolean;
  20762. AMBIENTDIRECTUV: number;
  20763. AMBIENTINGRAYSCALE: boolean;
  20764. OPACITY: boolean;
  20765. VERTEXALPHA: boolean;
  20766. OPACITYDIRECTUV: number;
  20767. OPACITYRGB: boolean;
  20768. ALPHATEST: boolean;
  20769. DEPTHPREPASS: boolean;
  20770. ALPHABLEND: boolean;
  20771. ALPHAFROMALBEDO: boolean;
  20772. ALPHATESTVALUE: string;
  20773. SPECULAROVERALPHA: boolean;
  20774. RADIANCEOVERALPHA: boolean;
  20775. ALPHAFRESNEL: boolean;
  20776. LINEARALPHAFRESNEL: boolean;
  20777. PREMULTIPLYALPHA: boolean;
  20778. EMISSIVE: boolean;
  20779. EMISSIVEDIRECTUV: number;
  20780. REFLECTIVITY: boolean;
  20781. REFLECTIVITYDIRECTUV: number;
  20782. SPECULARTERM: boolean;
  20783. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  20784. MICROSURFACEAUTOMATIC: boolean;
  20785. LODBASEDMICROSFURACE: boolean;
  20786. MICROSURFACEMAP: boolean;
  20787. MICROSURFACEMAPDIRECTUV: number;
  20788. METALLICWORKFLOW: boolean;
  20789. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  20790. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  20791. METALLNESSSTOREINMETALMAPBLUE: boolean;
  20792. AOSTOREINMETALMAPRED: boolean;
  20793. METALLIC_REFLECTANCE: boolean;
  20794. METALLIC_REFLECTANCEDIRECTUV: number;
  20795. ENVIRONMENTBRDF: boolean;
  20796. ENVIRONMENTBRDF_RGBD: boolean;
  20797. NORMAL: boolean;
  20798. TANGENT: boolean;
  20799. BUMP: boolean;
  20800. BUMPDIRECTUV: number;
  20801. OBJECTSPACE_NORMALMAP: boolean;
  20802. PARALLAX: boolean;
  20803. PARALLAXOCCLUSION: boolean;
  20804. NORMALXYSCALE: boolean;
  20805. LIGHTMAP: boolean;
  20806. LIGHTMAPDIRECTUV: number;
  20807. USELIGHTMAPASSHADOWMAP: boolean;
  20808. GAMMALIGHTMAP: boolean;
  20809. RGBDLIGHTMAP: boolean;
  20810. REFLECTION: boolean;
  20811. REFLECTIONMAP_3D: boolean;
  20812. REFLECTIONMAP_SPHERICAL: boolean;
  20813. REFLECTIONMAP_PLANAR: boolean;
  20814. REFLECTIONMAP_CUBIC: boolean;
  20815. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  20816. REFLECTIONMAP_PROJECTION: boolean;
  20817. REFLECTIONMAP_SKYBOX: boolean;
  20818. REFLECTIONMAP_EXPLICIT: boolean;
  20819. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  20820. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  20821. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  20822. INVERTCUBICMAP: boolean;
  20823. USESPHERICALFROMREFLECTIONMAP: boolean;
  20824. USEIRRADIANCEMAP: boolean;
  20825. SPHERICAL_HARMONICS: boolean;
  20826. USESPHERICALINVERTEX: boolean;
  20827. REFLECTIONMAP_OPPOSITEZ: boolean;
  20828. LODINREFLECTIONALPHA: boolean;
  20829. GAMMAREFLECTION: boolean;
  20830. RGBDREFLECTION: boolean;
  20831. LINEARSPECULARREFLECTION: boolean;
  20832. RADIANCEOCCLUSION: boolean;
  20833. HORIZONOCCLUSION: boolean;
  20834. INSTANCES: boolean;
  20835. THIN_INSTANCES: boolean;
  20836. PREPASS: boolean;
  20837. PREPASS_IRRADIANCE: boolean;
  20838. PREPASS_IRRADIANCE_INDEX: number;
  20839. PREPASS_ALBEDO: boolean;
  20840. PREPASS_ALBEDO_INDEX: number;
  20841. PREPASS_DEPTHNORMAL: boolean;
  20842. PREPASS_DEPTHNORMAL_INDEX: number;
  20843. PREPASS_POSITION: boolean;
  20844. PREPASS_POSITION_INDEX: number;
  20845. PREPASS_VELOCITY: boolean;
  20846. PREPASS_VELOCITY_INDEX: number;
  20847. PREPASS_REFLECTIVITY: boolean;
  20848. PREPASS_REFLECTIVITY_INDEX: number;
  20849. SCENE_MRT_COUNT: number;
  20850. NUM_BONE_INFLUENCERS: number;
  20851. BonesPerMesh: number;
  20852. BONETEXTURE: boolean;
  20853. BONES_VELOCITY_ENABLED: boolean;
  20854. NONUNIFORMSCALING: boolean;
  20855. MORPHTARGETS: boolean;
  20856. MORPHTARGETS_NORMAL: boolean;
  20857. MORPHTARGETS_TANGENT: boolean;
  20858. MORPHTARGETS_UV: boolean;
  20859. NUM_MORPH_INFLUENCERS: number;
  20860. IMAGEPROCESSING: boolean;
  20861. VIGNETTE: boolean;
  20862. VIGNETTEBLENDMODEMULTIPLY: boolean;
  20863. VIGNETTEBLENDMODEOPAQUE: boolean;
  20864. TONEMAPPING: boolean;
  20865. TONEMAPPING_ACES: boolean;
  20866. CONTRAST: boolean;
  20867. COLORCURVES: boolean;
  20868. COLORGRADING: boolean;
  20869. COLORGRADING3D: boolean;
  20870. SAMPLER3DGREENDEPTH: boolean;
  20871. SAMPLER3DBGRMAP: boolean;
  20872. IMAGEPROCESSINGPOSTPROCESS: boolean;
  20873. EXPOSURE: boolean;
  20874. MULTIVIEW: boolean;
  20875. USEPHYSICALLIGHTFALLOFF: boolean;
  20876. USEGLTFLIGHTFALLOFF: boolean;
  20877. TWOSIDEDLIGHTING: boolean;
  20878. SHADOWFLOAT: boolean;
  20879. CLIPPLANE: boolean;
  20880. CLIPPLANE2: boolean;
  20881. CLIPPLANE3: boolean;
  20882. CLIPPLANE4: boolean;
  20883. CLIPPLANE5: boolean;
  20884. CLIPPLANE6: boolean;
  20885. POINTSIZE: boolean;
  20886. FOG: boolean;
  20887. LOGARITHMICDEPTH: boolean;
  20888. FORCENORMALFORWARD: boolean;
  20889. SPECULARAA: boolean;
  20890. CLEARCOAT: boolean;
  20891. CLEARCOAT_DEFAULTIOR: boolean;
  20892. CLEARCOAT_TEXTURE: boolean;
  20893. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20894. CLEARCOAT_TEXTUREDIRECTUV: number;
  20895. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20896. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20897. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20898. CLEARCOAT_BUMP: boolean;
  20899. CLEARCOAT_BUMPDIRECTUV: number;
  20900. CLEARCOAT_REMAP_F0: boolean;
  20901. CLEARCOAT_TINT: boolean;
  20902. CLEARCOAT_TINT_TEXTURE: boolean;
  20903. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20904. ANISOTROPIC: boolean;
  20905. ANISOTROPIC_TEXTURE: boolean;
  20906. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20907. BRDF_V_HEIGHT_CORRELATED: boolean;
  20908. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20909. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20910. SHEEN: boolean;
  20911. SHEEN_TEXTURE: boolean;
  20912. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20913. SHEEN_TEXTUREDIRECTUV: number;
  20914. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20915. SHEEN_LINKWITHALBEDO: boolean;
  20916. SHEEN_ROUGHNESS: boolean;
  20917. SHEEN_ALBEDOSCALING: boolean;
  20918. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20919. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20920. SUBSURFACE: boolean;
  20921. SS_REFRACTION: boolean;
  20922. SS_TRANSLUCENCY: boolean;
  20923. SS_SCATTERING: boolean;
  20924. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20925. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20926. SS_REFRACTIONMAP_3D: boolean;
  20927. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20928. SS_LODINREFRACTIONALPHA: boolean;
  20929. SS_GAMMAREFRACTION: boolean;
  20930. SS_RGBDREFRACTION: boolean;
  20931. SS_LINEARSPECULARREFRACTION: boolean;
  20932. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20933. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20934. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20935. UNLIT: boolean;
  20936. DEBUGMODE: number;
  20937. /**
  20938. * Initializes the PBR Material defines.
  20939. */
  20940. constructor();
  20941. /**
  20942. * Resets the PBR Material defines.
  20943. */
  20944. reset(): void;
  20945. }
  20946. /**
  20947. * The Physically based material base class of BJS.
  20948. *
  20949. * This offers the main features of a standard PBR material.
  20950. * For more information, please refer to the documentation :
  20951. * https://doc.babylonjs.com/how_to/physically_based_rendering
  20952. */
  20953. export abstract class PBRBaseMaterial extends PushMaterial {
  20954. /**
  20955. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  20956. */
  20957. static readonly PBRMATERIAL_OPAQUE: number;
  20958. /**
  20959. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  20960. */
  20961. static readonly PBRMATERIAL_ALPHATEST: number;
  20962. /**
  20963. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20964. */
  20965. static readonly PBRMATERIAL_ALPHABLEND: number;
  20966. /**
  20967. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20968. * They are also discarded below the alpha cutoff threshold to improve performances.
  20969. */
  20970. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  20971. /**
  20972. * Defines the default value of how much AO map is occluding the analytical lights
  20973. * (point spot...).
  20974. */
  20975. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  20976. /**
  20977. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  20978. */
  20979. static readonly LIGHTFALLOFF_PHYSICAL: number;
  20980. /**
  20981. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  20982. * to enhance interoperability with other engines.
  20983. */
  20984. static readonly LIGHTFALLOFF_GLTF: number;
  20985. /**
  20986. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  20987. * to enhance interoperability with other materials.
  20988. */
  20989. static readonly LIGHTFALLOFF_STANDARD: number;
  20990. /**
  20991. * Intensity of the direct lights e.g. the four lights available in your scene.
  20992. * This impacts both the direct diffuse and specular highlights.
  20993. */
  20994. protected _directIntensity: number;
  20995. /**
  20996. * Intensity of the emissive part of the material.
  20997. * This helps controlling the emissive effect without modifying the emissive color.
  20998. */
  20999. protected _emissiveIntensity: number;
  21000. /**
  21001. * Intensity of the environment e.g. how much the environment will light the object
  21002. * either through harmonics for rough material or through the refelction for shiny ones.
  21003. */
  21004. protected _environmentIntensity: number;
  21005. /**
  21006. * This is a special control allowing the reduction of the specular highlights coming from the
  21007. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21008. */
  21009. protected _specularIntensity: number;
  21010. /**
  21011. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21012. */
  21013. private _lightingInfos;
  21014. /**
  21015. * Debug Control allowing disabling the bump map on this material.
  21016. */
  21017. protected _disableBumpMap: boolean;
  21018. /**
  21019. * AKA Diffuse Texture in standard nomenclature.
  21020. */
  21021. protected _albedoTexture: Nullable<BaseTexture>;
  21022. /**
  21023. * AKA Occlusion Texture in other nomenclature.
  21024. */
  21025. protected _ambientTexture: Nullable<BaseTexture>;
  21026. /**
  21027. * AKA Occlusion Texture Intensity in other nomenclature.
  21028. */
  21029. protected _ambientTextureStrength: number;
  21030. /**
  21031. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21032. * 1 means it completely occludes it
  21033. * 0 mean it has no impact
  21034. */
  21035. protected _ambientTextureImpactOnAnalyticalLights: number;
  21036. /**
  21037. * Stores the alpha values in a texture.
  21038. */
  21039. protected _opacityTexture: Nullable<BaseTexture>;
  21040. /**
  21041. * Stores the reflection values in a texture.
  21042. */
  21043. protected _reflectionTexture: Nullable<BaseTexture>;
  21044. /**
  21045. * Stores the emissive values in a texture.
  21046. */
  21047. protected _emissiveTexture: Nullable<BaseTexture>;
  21048. /**
  21049. * AKA Specular texture in other nomenclature.
  21050. */
  21051. protected _reflectivityTexture: Nullable<BaseTexture>;
  21052. /**
  21053. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21054. */
  21055. protected _metallicTexture: Nullable<BaseTexture>;
  21056. /**
  21057. * Specifies the metallic scalar of the metallic/roughness workflow.
  21058. * Can also be used to scale the metalness values of the metallic texture.
  21059. */
  21060. protected _metallic: Nullable<number>;
  21061. /**
  21062. * Specifies the roughness scalar of the metallic/roughness workflow.
  21063. * Can also be used to scale the roughness values of the metallic texture.
  21064. */
  21065. protected _roughness: Nullable<number>;
  21066. /**
  21067. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21068. * By default the indexOfrefraction is used to compute F0;
  21069. *
  21070. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21071. *
  21072. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21073. * F90 = metallicReflectanceColor;
  21074. */
  21075. protected _metallicF0Factor: number;
  21076. /**
  21077. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21078. * By default the F90 is always 1;
  21079. *
  21080. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21081. *
  21082. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21083. * F90 = metallicReflectanceColor;
  21084. */
  21085. protected _metallicReflectanceColor: Color3;
  21086. /**
  21087. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21088. * This is multiply against the scalar values defined in the material.
  21089. */
  21090. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21091. /**
  21092. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21093. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21094. */
  21095. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21096. /**
  21097. * Stores surface normal data used to displace a mesh in a texture.
  21098. */
  21099. protected _bumpTexture: Nullable<BaseTexture>;
  21100. /**
  21101. * Stores the pre-calculated light information of a mesh in a texture.
  21102. */
  21103. protected _lightmapTexture: Nullable<BaseTexture>;
  21104. /**
  21105. * The color of a material in ambient lighting.
  21106. */
  21107. protected _ambientColor: Color3;
  21108. /**
  21109. * AKA Diffuse Color in other nomenclature.
  21110. */
  21111. protected _albedoColor: Color3;
  21112. /**
  21113. * AKA Specular Color in other nomenclature.
  21114. */
  21115. protected _reflectivityColor: Color3;
  21116. /**
  21117. * The color applied when light is reflected from a material.
  21118. */
  21119. protected _reflectionColor: Color3;
  21120. /**
  21121. * The color applied when light is emitted from a material.
  21122. */
  21123. protected _emissiveColor: Color3;
  21124. /**
  21125. * AKA Glossiness in other nomenclature.
  21126. */
  21127. protected _microSurface: number;
  21128. /**
  21129. * Specifies that the material will use the light map as a show map.
  21130. */
  21131. protected _useLightmapAsShadowmap: boolean;
  21132. /**
  21133. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21134. * makes the reflect vector face the model (under horizon).
  21135. */
  21136. protected _useHorizonOcclusion: boolean;
  21137. /**
  21138. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21139. * too much the area relying on ambient texture to define their ambient occlusion.
  21140. */
  21141. protected _useRadianceOcclusion: boolean;
  21142. /**
  21143. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21144. */
  21145. protected _useAlphaFromAlbedoTexture: boolean;
  21146. /**
  21147. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21148. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21149. */
  21150. protected _useSpecularOverAlpha: boolean;
  21151. /**
  21152. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21153. */
  21154. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21155. /**
  21156. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21157. */
  21158. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21159. /**
  21160. * Specifies if the metallic texture contains the roughness information in its green channel.
  21161. */
  21162. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21163. /**
  21164. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21165. */
  21166. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21167. /**
  21168. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21169. */
  21170. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21171. /**
  21172. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21173. */
  21174. protected _useAmbientInGrayScale: boolean;
  21175. /**
  21176. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21177. * The material will try to infer what glossiness each pixel should be.
  21178. */
  21179. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21180. /**
  21181. * Defines the falloff type used in this material.
  21182. * It by default is Physical.
  21183. */
  21184. protected _lightFalloff: number;
  21185. /**
  21186. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21187. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21188. */
  21189. protected _useRadianceOverAlpha: boolean;
  21190. /**
  21191. * Allows using an object space normal map (instead of tangent space).
  21192. */
  21193. protected _useObjectSpaceNormalMap: boolean;
  21194. /**
  21195. * Allows using the bump map in parallax mode.
  21196. */
  21197. protected _useParallax: boolean;
  21198. /**
  21199. * Allows using the bump map in parallax occlusion mode.
  21200. */
  21201. protected _useParallaxOcclusion: boolean;
  21202. /**
  21203. * Controls the scale bias of the parallax mode.
  21204. */
  21205. protected _parallaxScaleBias: number;
  21206. /**
  21207. * If sets to true, disables all the lights affecting the material.
  21208. */
  21209. protected _disableLighting: boolean;
  21210. /**
  21211. * Number of Simultaneous lights allowed on the material.
  21212. */
  21213. protected _maxSimultaneousLights: number;
  21214. /**
  21215. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21216. */
  21217. protected _invertNormalMapX: boolean;
  21218. /**
  21219. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  21220. */
  21221. protected _invertNormalMapY: boolean;
  21222. /**
  21223. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21224. */
  21225. protected _twoSidedLighting: boolean;
  21226. /**
  21227. * Defines the alpha limits in alpha test mode.
  21228. */
  21229. protected _alphaCutOff: number;
  21230. /**
  21231. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21232. */
  21233. protected _forceAlphaTest: boolean;
  21234. /**
  21235. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21236. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21237. */
  21238. protected _useAlphaFresnel: boolean;
  21239. /**
  21240. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21241. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21242. */
  21243. protected _useLinearAlphaFresnel: boolean;
  21244. /**
  21245. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  21246. * from cos thetav and roughness:
  21247. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  21248. */
  21249. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  21250. /**
  21251. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21252. */
  21253. protected _forceIrradianceInFragment: boolean;
  21254. private _realTimeFiltering;
  21255. /**
  21256. * Enables realtime filtering on the texture.
  21257. */
  21258. get realTimeFiltering(): boolean;
  21259. set realTimeFiltering(b: boolean);
  21260. private _realTimeFilteringQuality;
  21261. /**
  21262. * Quality switch for realtime filtering
  21263. */
  21264. get realTimeFilteringQuality(): number;
  21265. set realTimeFilteringQuality(n: number);
  21266. /**
  21267. * Can this material render to several textures at once
  21268. */
  21269. get canRenderToMRT(): boolean;
  21270. /**
  21271. * Force normal to face away from face.
  21272. */
  21273. protected _forceNormalForward: boolean;
  21274. /**
  21275. * Enables specular anti aliasing in the PBR shader.
  21276. * It will both interacts on the Geometry for analytical and IBL lighting.
  21277. * It also prefilter the roughness map based on the bump values.
  21278. */
  21279. protected _enableSpecularAntiAliasing: boolean;
  21280. /**
  21281. * Default configuration related to image processing available in the PBR Material.
  21282. */
  21283. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  21284. /**
  21285. * Keep track of the image processing observer to allow dispose and replace.
  21286. */
  21287. private _imageProcessingObserver;
  21288. /**
  21289. * Attaches a new image processing configuration to the PBR Material.
  21290. * @param configuration
  21291. */
  21292. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  21293. /**
  21294. * Stores the available render targets.
  21295. */
  21296. private _renderTargets;
  21297. /**
  21298. * Sets the global ambient color for the material used in lighting calculations.
  21299. */
  21300. private _globalAmbientColor;
  21301. /**
  21302. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  21303. */
  21304. private _useLogarithmicDepth;
  21305. /**
  21306. * If set to true, no lighting calculations will be applied.
  21307. */
  21308. private _unlit;
  21309. private _debugMode;
  21310. /**
  21311. * @hidden
  21312. * This is reserved for the inspector.
  21313. * Defines the material debug mode.
  21314. * It helps seeing only some components of the material while troubleshooting.
  21315. */
  21316. debugMode: number;
  21317. /**
  21318. * @hidden
  21319. * This is reserved for the inspector.
  21320. * Specify from where on screen the debug mode should start.
  21321. * The value goes from -1 (full screen) to 1 (not visible)
  21322. * It helps with side by side comparison against the final render
  21323. * This defaults to -1
  21324. */
  21325. private debugLimit;
  21326. /**
  21327. * @hidden
  21328. * This is reserved for the inspector.
  21329. * As the default viewing range might not be enough (if the ambient is really small for instance)
  21330. * You can use the factor to better multiply the final value.
  21331. */
  21332. private debugFactor;
  21333. /**
  21334. * Defines the clear coat layer parameters for the material.
  21335. */
  21336. readonly clearCoat: PBRClearCoatConfiguration;
  21337. /**
  21338. * Defines the anisotropic parameters for the material.
  21339. */
  21340. readonly anisotropy: PBRAnisotropicConfiguration;
  21341. /**
  21342. * Defines the BRDF parameters for the material.
  21343. */
  21344. readonly brdf: PBRBRDFConfiguration;
  21345. /**
  21346. * Defines the Sheen parameters for the material.
  21347. */
  21348. readonly sheen: PBRSheenConfiguration;
  21349. /**
  21350. * Defines the SubSurface parameters for the material.
  21351. */
  21352. readonly subSurface: PBRSubSurfaceConfiguration;
  21353. /**
  21354. * Defines additionnal PrePass parameters for the material.
  21355. */
  21356. readonly prePassConfiguration: PrePassConfiguration;
  21357. /**
  21358. * Defines the detail map parameters for the material.
  21359. */
  21360. readonly detailMap: DetailMapConfiguration;
  21361. protected _rebuildInParallel: boolean;
  21362. /**
  21363. * Instantiates a new PBRMaterial instance.
  21364. *
  21365. * @param name The material name
  21366. * @param scene The scene the material will be use in.
  21367. */
  21368. constructor(name: string, scene: Scene);
  21369. /**
  21370. * Gets a boolean indicating that current material needs to register RTT
  21371. */
  21372. get hasRenderTargetTextures(): boolean;
  21373. /**
  21374. * Gets the name of the material class.
  21375. */
  21376. getClassName(): string;
  21377. /**
  21378. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21379. */
  21380. get useLogarithmicDepth(): boolean;
  21381. /**
  21382. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21383. */
  21384. set useLogarithmicDepth(value: boolean);
  21385. /**
  21386. * Returns true if alpha blending should be disabled.
  21387. */
  21388. protected get _disableAlphaBlending(): boolean;
  21389. /**
  21390. * Specifies whether or not this material should be rendered in alpha blend mode.
  21391. */
  21392. needAlphaBlending(): boolean;
  21393. /**
  21394. * Specifies whether or not this material should be rendered in alpha test mode.
  21395. */
  21396. needAlphaTesting(): boolean;
  21397. /**
  21398. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  21399. */
  21400. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  21401. /**
  21402. * Specifies whether or not there is a usable alpha channel for transparency.
  21403. */
  21404. protected _hasAlphaChannel(): boolean;
  21405. /**
  21406. * Gets the texture used for the alpha test.
  21407. */
  21408. getAlphaTestTexture(): Nullable<BaseTexture>;
  21409. /**
  21410. * Specifies that the submesh is ready to be used.
  21411. * @param mesh - BJS mesh.
  21412. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  21413. * @param useInstances - Specifies that instances should be used.
  21414. * @returns - boolean indicating that the submesh is ready or not.
  21415. */
  21416. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  21417. /**
  21418. * Specifies if the material uses metallic roughness workflow.
  21419. * @returns boolean specifiying if the material uses metallic roughness workflow.
  21420. */
  21421. isMetallicWorkflow(): boolean;
  21422. private _prepareEffect;
  21423. private _prepareDefines;
  21424. /**
  21425. * Force shader compilation
  21426. */
  21427. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  21428. /**
  21429. * Initializes the uniform buffer layout for the shader.
  21430. */
  21431. buildUniformLayout(): void;
  21432. /**
  21433. * Unbinds the material from the mesh
  21434. */
  21435. unbind(): void;
  21436. /**
  21437. * Binds the submesh data.
  21438. * @param world - The world matrix.
  21439. * @param mesh - The BJS mesh.
  21440. * @param subMesh - A submesh of the BJS mesh.
  21441. */
  21442. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21443. /**
  21444. * Returns the animatable textures.
  21445. * @returns - Array of animatable textures.
  21446. */
  21447. getAnimatables(): IAnimatable[];
  21448. /**
  21449. * Returns the texture used for reflections.
  21450. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  21451. */
  21452. private _getReflectionTexture;
  21453. /**
  21454. * Returns an array of the actively used textures.
  21455. * @returns - Array of BaseTextures
  21456. */
  21457. getActiveTextures(): BaseTexture[];
  21458. /**
  21459. * Checks to see if a texture is used in the material.
  21460. * @param texture - Base texture to use.
  21461. * @returns - Boolean specifying if a texture is used in the material.
  21462. */
  21463. hasTexture(texture: BaseTexture): boolean;
  21464. /**
  21465. * Sets the required values to the prepass renderer.
  21466. * @param prePassRenderer defines the prepass renderer to setup
  21467. */
  21468. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  21469. /**
  21470. * Disposes the resources of the material.
  21471. * @param forceDisposeEffect - Forces the disposal of effects.
  21472. * @param forceDisposeTextures - Forces the disposal of all textures.
  21473. */
  21474. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  21475. }
  21476. }
  21477. declare module BABYLON {
  21478. /**
  21479. * The Physically based material of BJS.
  21480. *
  21481. * This offers the main features of a standard PBR material.
  21482. * For more information, please refer to the documentation :
  21483. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21484. */
  21485. export class PBRMaterial extends PBRBaseMaterial {
  21486. /**
  21487. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21488. */
  21489. static readonly PBRMATERIAL_OPAQUE: number;
  21490. /**
  21491. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21492. */
  21493. static readonly PBRMATERIAL_ALPHATEST: number;
  21494. /**
  21495. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21496. */
  21497. static readonly PBRMATERIAL_ALPHABLEND: number;
  21498. /**
  21499. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21500. * They are also discarded below the alpha cutoff threshold to improve performances.
  21501. */
  21502. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21503. /**
  21504. * Defines the default value of how much AO map is occluding the analytical lights
  21505. * (point spot...).
  21506. */
  21507. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21508. /**
  21509. * Intensity of the direct lights e.g. the four lights available in your scene.
  21510. * This impacts both the direct diffuse and specular highlights.
  21511. */
  21512. directIntensity: number;
  21513. /**
  21514. * Intensity of the emissive part of the material.
  21515. * This helps controlling the emissive effect without modifying the emissive color.
  21516. */
  21517. emissiveIntensity: number;
  21518. /**
  21519. * Intensity of the environment e.g. how much the environment will light the object
  21520. * either through harmonics for rough material or through the refelction for shiny ones.
  21521. */
  21522. environmentIntensity: number;
  21523. /**
  21524. * This is a special control allowing the reduction of the specular highlights coming from the
  21525. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21526. */
  21527. specularIntensity: number;
  21528. /**
  21529. * Debug Control allowing disabling the bump map on this material.
  21530. */
  21531. disableBumpMap: boolean;
  21532. /**
  21533. * AKA Diffuse Texture in standard nomenclature.
  21534. */
  21535. albedoTexture: BaseTexture;
  21536. /**
  21537. * AKA Occlusion Texture in other nomenclature.
  21538. */
  21539. ambientTexture: BaseTexture;
  21540. /**
  21541. * AKA Occlusion Texture Intensity in other nomenclature.
  21542. */
  21543. ambientTextureStrength: number;
  21544. /**
  21545. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21546. * 1 means it completely occludes it
  21547. * 0 mean it has no impact
  21548. */
  21549. ambientTextureImpactOnAnalyticalLights: number;
  21550. /**
  21551. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  21552. */
  21553. opacityTexture: BaseTexture;
  21554. /**
  21555. * Stores the reflection values in a texture.
  21556. */
  21557. reflectionTexture: Nullable<BaseTexture>;
  21558. /**
  21559. * Stores the emissive values in a texture.
  21560. */
  21561. emissiveTexture: BaseTexture;
  21562. /**
  21563. * AKA Specular texture in other nomenclature.
  21564. */
  21565. reflectivityTexture: BaseTexture;
  21566. /**
  21567. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21568. */
  21569. metallicTexture: BaseTexture;
  21570. /**
  21571. * Specifies the metallic scalar of the metallic/roughness workflow.
  21572. * Can also be used to scale the metalness values of the metallic texture.
  21573. */
  21574. metallic: Nullable<number>;
  21575. /**
  21576. * Specifies the roughness scalar of the metallic/roughness workflow.
  21577. * Can also be used to scale the roughness values of the metallic texture.
  21578. */
  21579. roughness: Nullable<number>;
  21580. /**
  21581. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21582. * By default the indexOfrefraction is used to compute F0;
  21583. *
  21584. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21585. *
  21586. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21587. * F90 = metallicReflectanceColor;
  21588. */
  21589. metallicF0Factor: number;
  21590. /**
  21591. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21592. * By default the F90 is always 1;
  21593. *
  21594. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21595. *
  21596. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21597. * F90 = metallicReflectanceColor;
  21598. */
  21599. metallicReflectanceColor: Color3;
  21600. /**
  21601. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21602. * This is multiply against the scalar values defined in the material.
  21603. */
  21604. metallicReflectanceTexture: Nullable<BaseTexture>;
  21605. /**
  21606. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21607. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21608. */
  21609. microSurfaceTexture: BaseTexture;
  21610. /**
  21611. * Stores surface normal data used to displace a mesh in a texture.
  21612. */
  21613. bumpTexture: BaseTexture;
  21614. /**
  21615. * Stores the pre-calculated light information of a mesh in a texture.
  21616. */
  21617. lightmapTexture: BaseTexture;
  21618. /**
  21619. * Stores the refracted light information in a texture.
  21620. */
  21621. get refractionTexture(): Nullable<BaseTexture>;
  21622. set refractionTexture(value: Nullable<BaseTexture>);
  21623. /**
  21624. * The color of a material in ambient lighting.
  21625. */
  21626. ambientColor: Color3;
  21627. /**
  21628. * AKA Diffuse Color in other nomenclature.
  21629. */
  21630. albedoColor: Color3;
  21631. /**
  21632. * AKA Specular Color in other nomenclature.
  21633. */
  21634. reflectivityColor: Color3;
  21635. /**
  21636. * The color reflected from the material.
  21637. */
  21638. reflectionColor: Color3;
  21639. /**
  21640. * The color emitted from the material.
  21641. */
  21642. emissiveColor: Color3;
  21643. /**
  21644. * AKA Glossiness in other nomenclature.
  21645. */
  21646. microSurface: number;
  21647. /**
  21648. * Index of refraction of the material base layer.
  21649. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21650. *
  21651. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21652. *
  21653. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21654. */
  21655. get indexOfRefraction(): number;
  21656. set indexOfRefraction(value: number);
  21657. /**
  21658. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21659. */
  21660. get invertRefractionY(): boolean;
  21661. set invertRefractionY(value: boolean);
  21662. /**
  21663. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21664. * Materials half opaque for instance using refraction could benefit from this control.
  21665. */
  21666. get linkRefractionWithTransparency(): boolean;
  21667. set linkRefractionWithTransparency(value: boolean);
  21668. /**
  21669. * If true, the light map contains occlusion information instead of lighting info.
  21670. */
  21671. useLightmapAsShadowmap: boolean;
  21672. /**
  21673. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21674. */
  21675. useAlphaFromAlbedoTexture: boolean;
  21676. /**
  21677. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21678. */
  21679. forceAlphaTest: boolean;
  21680. /**
  21681. * Defines the alpha limits in alpha test mode.
  21682. */
  21683. alphaCutOff: number;
  21684. /**
  21685. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  21686. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21687. */
  21688. useSpecularOverAlpha: boolean;
  21689. /**
  21690. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21691. */
  21692. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21693. /**
  21694. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21695. */
  21696. useRoughnessFromMetallicTextureAlpha: boolean;
  21697. /**
  21698. * Specifies if the metallic texture contains the roughness information in its green channel.
  21699. */
  21700. useRoughnessFromMetallicTextureGreen: boolean;
  21701. /**
  21702. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21703. */
  21704. useMetallnessFromMetallicTextureBlue: boolean;
  21705. /**
  21706. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21707. */
  21708. useAmbientOcclusionFromMetallicTextureRed: boolean;
  21709. /**
  21710. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21711. */
  21712. useAmbientInGrayScale: boolean;
  21713. /**
  21714. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21715. * The material will try to infer what glossiness each pixel should be.
  21716. */
  21717. useAutoMicroSurfaceFromReflectivityMap: boolean;
  21718. /**
  21719. * BJS is using an harcoded light falloff based on a manually sets up range.
  21720. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21721. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21722. */
  21723. get usePhysicalLightFalloff(): boolean;
  21724. /**
  21725. * BJS is using an harcoded light falloff based on a manually sets up range.
  21726. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21727. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21728. */
  21729. set usePhysicalLightFalloff(value: boolean);
  21730. /**
  21731. * In order to support the falloff compatibility with gltf, a special mode has been added
  21732. * to reproduce the gltf light falloff.
  21733. */
  21734. get useGLTFLightFalloff(): boolean;
  21735. /**
  21736. * In order to support the falloff compatibility with gltf, a special mode has been added
  21737. * to reproduce the gltf light falloff.
  21738. */
  21739. set useGLTFLightFalloff(value: boolean);
  21740. /**
  21741. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21742. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21743. */
  21744. useRadianceOverAlpha: boolean;
  21745. /**
  21746. * Allows using an object space normal map (instead of tangent space).
  21747. */
  21748. useObjectSpaceNormalMap: boolean;
  21749. /**
  21750. * Allows using the bump map in parallax mode.
  21751. */
  21752. useParallax: boolean;
  21753. /**
  21754. * Allows using the bump map in parallax occlusion mode.
  21755. */
  21756. useParallaxOcclusion: boolean;
  21757. /**
  21758. * Controls the scale bias of the parallax mode.
  21759. */
  21760. parallaxScaleBias: number;
  21761. /**
  21762. * If sets to true, disables all the lights affecting the material.
  21763. */
  21764. disableLighting: boolean;
  21765. /**
  21766. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21767. */
  21768. forceIrradianceInFragment: boolean;
  21769. /**
  21770. * Number of Simultaneous lights allowed on the material.
  21771. */
  21772. maxSimultaneousLights: number;
  21773. /**
  21774. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  21775. */
  21776. invertNormalMapX: boolean;
  21777. /**
  21778. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  21779. */
  21780. invertNormalMapY: boolean;
  21781. /**
  21782. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21783. */
  21784. twoSidedLighting: boolean;
  21785. /**
  21786. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21787. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21788. */
  21789. useAlphaFresnel: boolean;
  21790. /**
  21791. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21792. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21793. */
  21794. useLinearAlphaFresnel: boolean;
  21795. /**
  21796. * Let user defines the brdf lookup texture used for IBL.
  21797. * A default 8bit version is embedded but you could point at :
  21798. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  21799. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  21800. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  21801. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  21802. */
  21803. environmentBRDFTexture: Nullable<BaseTexture>;
  21804. /**
  21805. * Force normal to face away from face.
  21806. */
  21807. forceNormalForward: boolean;
  21808. /**
  21809. * Enables specular anti aliasing in the PBR shader.
  21810. * It will both interacts on the Geometry for analytical and IBL lighting.
  21811. * It also prefilter the roughness map based on the bump values.
  21812. */
  21813. enableSpecularAntiAliasing: boolean;
  21814. /**
  21815. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21816. * makes the reflect vector face the model (under horizon).
  21817. */
  21818. useHorizonOcclusion: boolean;
  21819. /**
  21820. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21821. * too much the area relying on ambient texture to define their ambient occlusion.
  21822. */
  21823. useRadianceOcclusion: boolean;
  21824. /**
  21825. * If set to true, no lighting calculations will be applied.
  21826. */
  21827. unlit: boolean;
  21828. /**
  21829. * Gets the image processing configuration used either in this material.
  21830. */
  21831. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  21832. /**
  21833. * Sets the Default image processing configuration used either in the this material.
  21834. *
  21835. * If sets to null, the scene one is in use.
  21836. */
  21837. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  21838. /**
  21839. * Gets wether the color curves effect is enabled.
  21840. */
  21841. get cameraColorCurvesEnabled(): boolean;
  21842. /**
  21843. * Sets wether the color curves effect is enabled.
  21844. */
  21845. set cameraColorCurvesEnabled(value: boolean);
  21846. /**
  21847. * Gets wether the color grading effect is enabled.
  21848. */
  21849. get cameraColorGradingEnabled(): boolean;
  21850. /**
  21851. * Gets wether the color grading effect is enabled.
  21852. */
  21853. set cameraColorGradingEnabled(value: boolean);
  21854. /**
  21855. * Gets wether tonemapping is enabled or not.
  21856. */
  21857. get cameraToneMappingEnabled(): boolean;
  21858. /**
  21859. * Sets wether tonemapping is enabled or not
  21860. */
  21861. set cameraToneMappingEnabled(value: boolean);
  21862. /**
  21863. * The camera exposure used on this material.
  21864. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21865. * This corresponds to a photographic exposure.
  21866. */
  21867. get cameraExposure(): number;
  21868. /**
  21869. * The camera exposure used on this material.
  21870. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21871. * This corresponds to a photographic exposure.
  21872. */
  21873. set cameraExposure(value: number);
  21874. /**
  21875. * Gets The camera contrast used on this material.
  21876. */
  21877. get cameraContrast(): number;
  21878. /**
  21879. * Sets The camera contrast used on this material.
  21880. */
  21881. set cameraContrast(value: number);
  21882. /**
  21883. * Gets the Color Grading 2D Lookup Texture.
  21884. */
  21885. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  21886. /**
  21887. * Sets the Color Grading 2D Lookup Texture.
  21888. */
  21889. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  21890. /**
  21891. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21892. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21893. * 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;
  21894. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21895. */
  21896. get cameraColorCurves(): Nullable<ColorCurves>;
  21897. /**
  21898. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21899. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21900. * 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;
  21901. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21902. */
  21903. set cameraColorCurves(value: Nullable<ColorCurves>);
  21904. /**
  21905. * Instantiates a new PBRMaterial instance.
  21906. *
  21907. * @param name The material name
  21908. * @param scene The scene the material will be use in.
  21909. */
  21910. constructor(name: string, scene: Scene);
  21911. /**
  21912. * Returns the name of this material class.
  21913. */
  21914. getClassName(): string;
  21915. /**
  21916. * Makes a duplicate of the current material.
  21917. * @param name - name to use for the new material.
  21918. */
  21919. clone(name: string): PBRMaterial;
  21920. /**
  21921. * Serializes this PBR Material.
  21922. * @returns - An object with the serialized material.
  21923. */
  21924. serialize(): any;
  21925. /**
  21926. * Parses a PBR Material from a serialized object.
  21927. * @param source - Serialized object.
  21928. * @param scene - BJS scene instance.
  21929. * @param rootUrl - url for the scene object
  21930. * @returns - PBRMaterial
  21931. */
  21932. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  21933. }
  21934. }
  21935. declare module BABYLON {
  21936. /** @hidden */
  21937. export var mrtFragmentDeclaration: {
  21938. name: string;
  21939. shader: string;
  21940. };
  21941. }
  21942. declare module BABYLON {
  21943. /** @hidden */
  21944. export var geometryPixelShader: {
  21945. name: string;
  21946. shader: string;
  21947. };
  21948. }
  21949. declare module BABYLON {
  21950. /** @hidden */
  21951. export var geometryVertexShader: {
  21952. name: string;
  21953. shader: string;
  21954. };
  21955. }
  21956. declare module BABYLON {
  21957. /** @hidden */
  21958. interface ISavedTransformationMatrix {
  21959. world: Matrix;
  21960. viewProjection: Matrix;
  21961. }
  21962. /**
  21963. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  21964. */
  21965. export class GeometryBufferRenderer {
  21966. /**
  21967. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  21968. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  21969. */
  21970. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  21971. /**
  21972. * Constant used to retrieve the position texture index in the G-Buffer textures array
  21973. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  21974. */
  21975. static readonly POSITION_TEXTURE_TYPE: number;
  21976. /**
  21977. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  21978. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  21979. */
  21980. static readonly VELOCITY_TEXTURE_TYPE: number;
  21981. /**
  21982. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  21983. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  21984. */
  21985. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  21986. /**
  21987. * Dictionary used to store the previous transformation matrices of each rendered mesh
  21988. * in order to compute objects velocities when enableVelocity is set to "true"
  21989. * @hidden
  21990. */
  21991. _previousTransformationMatrices: {
  21992. [index: number]: ISavedTransformationMatrix;
  21993. };
  21994. /**
  21995. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  21996. * in order to compute objects velocities when enableVelocity is set to "true"
  21997. * @hidden
  21998. */
  21999. _previousBonesTransformationMatrices: {
  22000. [index: number]: Float32Array;
  22001. };
  22002. /**
  22003. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22004. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22005. */
  22006. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22007. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22008. renderTransparentMeshes: boolean;
  22009. private _scene;
  22010. private _resizeObserver;
  22011. private _multiRenderTarget;
  22012. private _ratio;
  22013. private _enablePosition;
  22014. private _enableVelocity;
  22015. private _enableReflectivity;
  22016. private _positionIndex;
  22017. private _velocityIndex;
  22018. private _reflectivityIndex;
  22019. private _depthNormalIndex;
  22020. private _linkedWithPrePass;
  22021. private _prePassRenderer;
  22022. private _attachments;
  22023. protected _effect: Effect;
  22024. protected _cachedDefines: string;
  22025. /**
  22026. * @hidden
  22027. * Sets up internal structures to share outputs with PrePassRenderer
  22028. * This method should only be called by the PrePassRenderer itself
  22029. */
  22030. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22031. /**
  22032. * @hidden
  22033. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22034. * This method should only be called by the PrePassRenderer itself
  22035. */
  22036. _unlinkPrePassRenderer(): void;
  22037. /**
  22038. * @hidden
  22039. * Resets the geometry buffer layout
  22040. */
  22041. _resetLayout(): void;
  22042. /**
  22043. * @hidden
  22044. * Replaces a texture in the geometry buffer renderer
  22045. * Useful when linking textures of the prepass renderer
  22046. */
  22047. _forceTextureType(geometryBufferType: number, index: number): void;
  22048. /**
  22049. * @hidden
  22050. * Sets texture attachments
  22051. * Useful when linking textures of the prepass renderer
  22052. */
  22053. _setAttachments(attachments: number[]): void;
  22054. /**
  22055. * @hidden
  22056. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22057. * Useful when linking textures of the prepass renderer
  22058. */
  22059. _linkInternalTexture(internalTexture: InternalTexture): void;
  22060. /**
  22061. * Gets the render list (meshes to be rendered) used in the G buffer.
  22062. */
  22063. get renderList(): Nullable<AbstractMesh[]>;
  22064. /**
  22065. * Set the render list (meshes to be rendered) used in the G buffer.
  22066. */
  22067. set renderList(meshes: Nullable<AbstractMesh[]>);
  22068. /**
  22069. * Gets wether or not G buffer are supported by the running hardware.
  22070. * This requires draw buffer supports
  22071. */
  22072. get isSupported(): boolean;
  22073. /**
  22074. * Returns the index of the given texture type in the G-Buffer textures array
  22075. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22076. * @returns the index of the given texture type in the G-Buffer textures array
  22077. */
  22078. getTextureIndex(textureType: number): number;
  22079. /**
  22080. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22081. */
  22082. get enablePosition(): boolean;
  22083. /**
  22084. * Sets whether or not objects positions are enabled for the G buffer.
  22085. */
  22086. set enablePosition(enable: boolean);
  22087. /**
  22088. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22089. */
  22090. get enableVelocity(): boolean;
  22091. /**
  22092. * Sets wether or not objects velocities are enabled for the G buffer.
  22093. */
  22094. set enableVelocity(enable: boolean);
  22095. /**
  22096. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22097. */
  22098. get enableReflectivity(): boolean;
  22099. /**
  22100. * Sets wether or not objects roughness are enabled for the G buffer.
  22101. */
  22102. set enableReflectivity(enable: boolean);
  22103. /**
  22104. * Gets the scene associated with the buffer.
  22105. */
  22106. get scene(): Scene;
  22107. /**
  22108. * Gets the ratio used by the buffer during its creation.
  22109. * How big is the buffer related to the main canvas.
  22110. */
  22111. get ratio(): number;
  22112. /** @hidden */
  22113. static _SceneComponentInitialization: (scene: Scene) => void;
  22114. /**
  22115. * Creates a new G Buffer for the scene
  22116. * @param scene The scene the buffer belongs to
  22117. * @param ratio How big is the buffer related to the main canvas.
  22118. */
  22119. constructor(scene: Scene, ratio?: number);
  22120. /**
  22121. * Checks wether everything is ready to render a submesh to the G buffer.
  22122. * @param subMesh the submesh to check readiness for
  22123. * @param useInstances is the mesh drawn using instance or not
  22124. * @returns true if ready otherwise false
  22125. */
  22126. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22127. /**
  22128. * Gets the current underlying G Buffer.
  22129. * @returns the buffer
  22130. */
  22131. getGBuffer(): MultiRenderTarget;
  22132. /**
  22133. * Gets the number of samples used to render the buffer (anti aliasing).
  22134. */
  22135. get samples(): number;
  22136. /**
  22137. * Sets the number of samples used to render the buffer (anti aliasing).
  22138. */
  22139. set samples(value: number);
  22140. /**
  22141. * Disposes the renderer and frees up associated resources.
  22142. */
  22143. dispose(): void;
  22144. private _assignRenderTargetIndices;
  22145. protected _createRenderTargets(): void;
  22146. private _copyBonesTransformationMatrices;
  22147. }
  22148. }
  22149. declare module BABYLON {
  22150. /**
  22151. * Renders a pre pass of the scene
  22152. * This means every mesh in the scene will be rendered to a render target texture
  22153. * And then this texture will be composited to the rendering canvas with post processes
  22154. * It is necessary for effects like subsurface scattering or deferred shading
  22155. */
  22156. export class PrePassRenderer {
  22157. /** @hidden */
  22158. static _SceneComponentInitialization: (scene: Scene) => void;
  22159. private _textureFormats;
  22160. /**
  22161. * To save performance, we can excluded skinned meshes from the prepass
  22162. */
  22163. excludedSkinnedMesh: AbstractMesh[];
  22164. /**
  22165. * Force material to be excluded from the prepass
  22166. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22167. * and you don't want a material to show in the effect.
  22168. */
  22169. excludedMaterials: Material[];
  22170. private _textureIndices;
  22171. private _scene;
  22172. private _engine;
  22173. private _isDirty;
  22174. /**
  22175. * Number of textures in the multi render target texture where the scene is directly rendered
  22176. */
  22177. mrtCount: number;
  22178. /**
  22179. * The render target where the scene is directly rendered
  22180. */
  22181. prePassRT: MultiRenderTarget;
  22182. private _multiRenderAttachments;
  22183. private _defaultAttachments;
  22184. private _clearAttachments;
  22185. private _postProcesses;
  22186. private readonly _clearColor;
  22187. /**
  22188. * Image processing post process for composition
  22189. */
  22190. imageProcessingPostProcess: ImageProcessingPostProcess;
  22191. /**
  22192. * Configuration for prepass effects
  22193. */
  22194. private _effectConfigurations;
  22195. private _mrtFormats;
  22196. private _mrtLayout;
  22197. private _enabled;
  22198. /**
  22199. * Indicates if the prepass is enabled
  22200. */
  22201. get enabled(): boolean;
  22202. /**
  22203. * How many samples are used for MSAA of the scene render target
  22204. */
  22205. get samples(): number;
  22206. set samples(n: number);
  22207. private _geometryBuffer;
  22208. private _useGeometryBufferFallback;
  22209. /**
  22210. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  22211. */
  22212. get useGeometryBufferFallback(): boolean;
  22213. set useGeometryBufferFallback(value: boolean);
  22214. /**
  22215. * Instanciates a prepass renderer
  22216. * @param scene The scene
  22217. */
  22218. constructor(scene: Scene);
  22219. private _initializeAttachments;
  22220. private _createCompositionEffect;
  22221. /**
  22222. * Indicates if rendering a prepass is supported
  22223. */
  22224. get isSupported(): boolean;
  22225. /**
  22226. * Sets the proper output textures to draw in the engine.
  22227. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  22228. * @param subMesh Submesh on which the effect is applied
  22229. */
  22230. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  22231. /**
  22232. * @hidden
  22233. */
  22234. _beforeCameraDraw(): void;
  22235. /**
  22236. * @hidden
  22237. */
  22238. _afterCameraDraw(): void;
  22239. private _checkRTSize;
  22240. private _bindFrameBuffer;
  22241. /**
  22242. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  22243. */
  22244. clear(): void;
  22245. private _setState;
  22246. private _updateGeometryBufferLayout;
  22247. /**
  22248. * Adds an effect configuration to the prepass.
  22249. * If an effect has already been added, it won't add it twice and will return the configuration
  22250. * already present.
  22251. * @param cfg the effect configuration
  22252. * @return the effect configuration now used by the prepass
  22253. */
  22254. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  22255. /**
  22256. * Returns the index of a texture in the multi render target texture array.
  22257. * @param type Texture type
  22258. * @return The index
  22259. */
  22260. getIndex(type: number): number;
  22261. private _enable;
  22262. private _disable;
  22263. private _resetLayout;
  22264. private _resetPostProcessChain;
  22265. private _bindPostProcessChain;
  22266. /**
  22267. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  22268. */
  22269. markAsDirty(): void;
  22270. /**
  22271. * Enables a texture on the MultiRenderTarget for prepass
  22272. */
  22273. private _enableTextures;
  22274. private _update;
  22275. private _markAllMaterialsAsPrePassDirty;
  22276. /**
  22277. * Disposes the prepass renderer.
  22278. */
  22279. dispose(): void;
  22280. }
  22281. }
  22282. declare module BABYLON {
  22283. /**
  22284. * Size options for a post process
  22285. */
  22286. export type PostProcessOptions = {
  22287. width: number;
  22288. height: number;
  22289. };
  22290. /**
  22291. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22292. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22293. */
  22294. export class PostProcess {
  22295. /**
  22296. * Gets or sets the unique id of the post process
  22297. */
  22298. uniqueId: number;
  22299. /** Name of the PostProcess. */
  22300. name: string;
  22301. /**
  22302. * Width of the texture to apply the post process on
  22303. */
  22304. width: number;
  22305. /**
  22306. * Height of the texture to apply the post process on
  22307. */
  22308. height: number;
  22309. /**
  22310. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22311. */
  22312. nodeMaterialSource: Nullable<NodeMaterial>;
  22313. /**
  22314. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22315. * @hidden
  22316. */
  22317. _outputTexture: Nullable<InternalTexture>;
  22318. /**
  22319. * Sampling mode used by the shader
  22320. * See https://doc.babylonjs.com/classes/3.1/texture
  22321. */
  22322. renderTargetSamplingMode: number;
  22323. /**
  22324. * Clear color to use when screen clearing
  22325. */
  22326. clearColor: Color4;
  22327. /**
  22328. * If the buffer needs to be cleared before applying the post process. (default: true)
  22329. * Should be set to false if shader will overwrite all previous pixels.
  22330. */
  22331. autoClear: boolean;
  22332. /**
  22333. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22334. */
  22335. alphaMode: number;
  22336. /**
  22337. * Sets the setAlphaBlendConstants of the babylon engine
  22338. */
  22339. alphaConstants: Color4;
  22340. /**
  22341. * Animations to be used for the post processing
  22342. */
  22343. animations: Animation[];
  22344. /**
  22345. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22346. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22347. */
  22348. enablePixelPerfectMode: boolean;
  22349. /**
  22350. * Force the postprocess to be applied without taking in account viewport
  22351. */
  22352. forceFullscreenViewport: boolean;
  22353. /**
  22354. * List of inspectable custom properties (used by the Inspector)
  22355. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22356. */
  22357. inspectableCustomProperties: IInspectable[];
  22358. /**
  22359. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22360. *
  22361. * | Value | Type | Description |
  22362. * | ----- | ----------------------------------- | ----------- |
  22363. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22364. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22365. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22366. *
  22367. */
  22368. scaleMode: number;
  22369. /**
  22370. * Force textures to be a power of two (default: false)
  22371. */
  22372. alwaysForcePOT: boolean;
  22373. private _samples;
  22374. /**
  22375. * Number of sample textures (default: 1)
  22376. */
  22377. get samples(): number;
  22378. set samples(n: number);
  22379. /**
  22380. * Modify the scale of the post process to be the same as the viewport (default: false)
  22381. */
  22382. adaptScaleToCurrentViewport: boolean;
  22383. private _camera;
  22384. protected _scene: Scene;
  22385. private _engine;
  22386. private _options;
  22387. private _reusable;
  22388. private _textureType;
  22389. private _textureFormat;
  22390. /**
  22391. * Smart array of input and output textures for the post process.
  22392. * @hidden
  22393. */
  22394. _textures: SmartArray<InternalTexture>;
  22395. /**
  22396. * The index in _textures that corresponds to the output texture.
  22397. * @hidden
  22398. */
  22399. _currentRenderTextureInd: number;
  22400. private _effect;
  22401. private _samplers;
  22402. private _fragmentUrl;
  22403. private _vertexUrl;
  22404. private _parameters;
  22405. private _scaleRatio;
  22406. protected _indexParameters: any;
  22407. private _shareOutputWithPostProcess;
  22408. private _texelSize;
  22409. private _forcedOutputTexture;
  22410. /**
  22411. * Prepass configuration in case this post process needs a texture from prepass
  22412. * @hidden
  22413. */
  22414. _prePassEffectConfiguration: PrePassEffectConfiguration;
  22415. /**
  22416. * Returns the fragment url or shader name used in the post process.
  22417. * @returns the fragment url or name in the shader store.
  22418. */
  22419. getEffectName(): string;
  22420. /**
  22421. * An event triggered when the postprocess is activated.
  22422. */
  22423. onActivateObservable: Observable<Camera>;
  22424. private _onActivateObserver;
  22425. /**
  22426. * A function that is added to the onActivateObservable
  22427. */
  22428. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22429. /**
  22430. * An event triggered when the postprocess changes its size.
  22431. */
  22432. onSizeChangedObservable: Observable<PostProcess>;
  22433. private _onSizeChangedObserver;
  22434. /**
  22435. * A function that is added to the onSizeChangedObservable
  22436. */
  22437. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22438. /**
  22439. * An event triggered when the postprocess applies its effect.
  22440. */
  22441. onApplyObservable: Observable<Effect>;
  22442. private _onApplyObserver;
  22443. /**
  22444. * A function that is added to the onApplyObservable
  22445. */
  22446. set onApply(callback: (effect: Effect) => void);
  22447. /**
  22448. * An event triggered before rendering the postprocess
  22449. */
  22450. onBeforeRenderObservable: Observable<Effect>;
  22451. private _onBeforeRenderObserver;
  22452. /**
  22453. * A function that is added to the onBeforeRenderObservable
  22454. */
  22455. set onBeforeRender(callback: (effect: Effect) => void);
  22456. /**
  22457. * An event triggered after rendering the postprocess
  22458. */
  22459. onAfterRenderObservable: Observable<Effect>;
  22460. private _onAfterRenderObserver;
  22461. /**
  22462. * A function that is added to the onAfterRenderObservable
  22463. */
  22464. set onAfterRender(callback: (efect: Effect) => void);
  22465. /**
  22466. * 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
  22467. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22468. */
  22469. get inputTexture(): InternalTexture;
  22470. set inputTexture(value: InternalTexture);
  22471. /**
  22472. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22473. * the only way to unset it is to use this function to restore its internal state
  22474. */
  22475. restoreDefaultInputTexture(): void;
  22476. /**
  22477. * Gets the camera which post process is applied to.
  22478. * @returns The camera the post process is applied to.
  22479. */
  22480. getCamera(): Camera;
  22481. /**
  22482. * Gets the texel size of the postprocess.
  22483. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22484. */
  22485. get texelSize(): Vector2;
  22486. /**
  22487. * Creates a new instance PostProcess
  22488. * @param name The name of the PostProcess.
  22489. * @param fragmentUrl The url of the fragment shader to be used.
  22490. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22491. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22492. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22493. * @param camera The camera to apply the render pass to.
  22494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22495. * @param engine The engine which the post process will be applied. (default: current engine)
  22496. * @param reusable If the post process can be reused on the same frame. (default: false)
  22497. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22498. * @param textureType Type of textures used when performing the post process. (default: 0)
  22499. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22500. * @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
  22501. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  22502. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22503. */
  22504. 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);
  22505. /**
  22506. * Gets a string identifying the name of the class
  22507. * @returns "PostProcess" string
  22508. */
  22509. getClassName(): string;
  22510. /**
  22511. * Gets the engine which this post process belongs to.
  22512. * @returns The engine the post process was enabled with.
  22513. */
  22514. getEngine(): Engine;
  22515. /**
  22516. * The effect that is created when initializing the post process.
  22517. * @returns The created effect corresponding the the postprocess.
  22518. */
  22519. getEffect(): Effect;
  22520. /**
  22521. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22522. * @param postProcess The post process to share the output with.
  22523. * @returns This post process.
  22524. */
  22525. shareOutputWith(postProcess: PostProcess): PostProcess;
  22526. /**
  22527. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22528. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22529. */
  22530. useOwnOutput(): void;
  22531. /**
  22532. * Updates the effect with the current post process compile time values and recompiles the shader.
  22533. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22534. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22535. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22536. * @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
  22537. * @param onCompiled Called when the shader has been compiled.
  22538. * @param onError Called if there is an error when compiling a shader.
  22539. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22540. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22541. */
  22542. 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;
  22543. /**
  22544. * The post process is reusable if it can be used multiple times within one frame.
  22545. * @returns If the post process is reusable
  22546. */
  22547. isReusable(): boolean;
  22548. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22549. markTextureDirty(): void;
  22550. /**
  22551. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22552. * 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.
  22553. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22554. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22555. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22556. * @returns The target texture that was bound to be written to.
  22557. */
  22558. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22559. /**
  22560. * If the post process is supported.
  22561. */
  22562. get isSupported(): boolean;
  22563. /**
  22564. * The aspect ratio of the output texture.
  22565. */
  22566. get aspectRatio(): number;
  22567. /**
  22568. * Get a value indicating if the post-process is ready to be used
  22569. * @returns true if the post-process is ready (shader is compiled)
  22570. */
  22571. isReady(): boolean;
  22572. /**
  22573. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22574. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22575. */
  22576. apply(): Nullable<Effect>;
  22577. private _disposeTextures;
  22578. /**
  22579. * Sets the required values to the prepass renderer.
  22580. * @param prePassRenderer defines the prepass renderer to setup.
  22581. * @returns true if the pre pass is needed.
  22582. */
  22583. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22584. /**
  22585. * Disposes the post process.
  22586. * @param camera The camera to dispose the post process on.
  22587. */
  22588. dispose(camera?: Camera): void;
  22589. /**
  22590. * Serializes the particle system to a JSON object
  22591. * @returns the JSON object
  22592. */
  22593. serialize(): any;
  22594. /**
  22595. * Creates a material from parsed material data
  22596. * @param parsedPostProcess defines parsed post process data
  22597. * @param scene defines the hosting scene
  22598. * @param rootUrl defines the root URL to use to load textures
  22599. * @returns a new post process
  22600. */
  22601. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22602. }
  22603. }
  22604. declare module BABYLON {
  22605. /** @hidden */
  22606. export var kernelBlurVaryingDeclaration: {
  22607. name: string;
  22608. shader: string;
  22609. };
  22610. }
  22611. declare module BABYLON {
  22612. /** @hidden */
  22613. export var packingFunctions: {
  22614. name: string;
  22615. shader: string;
  22616. };
  22617. }
  22618. declare module BABYLON {
  22619. /** @hidden */
  22620. export var kernelBlurFragment: {
  22621. name: string;
  22622. shader: string;
  22623. };
  22624. }
  22625. declare module BABYLON {
  22626. /** @hidden */
  22627. export var kernelBlurFragment2: {
  22628. name: string;
  22629. shader: string;
  22630. };
  22631. }
  22632. declare module BABYLON {
  22633. /** @hidden */
  22634. export var kernelBlurPixelShader: {
  22635. name: string;
  22636. shader: string;
  22637. };
  22638. }
  22639. declare module BABYLON {
  22640. /** @hidden */
  22641. export var kernelBlurVertex: {
  22642. name: string;
  22643. shader: string;
  22644. };
  22645. }
  22646. declare module BABYLON {
  22647. /** @hidden */
  22648. export var kernelBlurVertexShader: {
  22649. name: string;
  22650. shader: string;
  22651. };
  22652. }
  22653. declare module BABYLON {
  22654. /**
  22655. * The Blur Post Process which blurs an image based on a kernel and direction.
  22656. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22657. */
  22658. export class BlurPostProcess extends PostProcess {
  22659. private blockCompilation;
  22660. protected _kernel: number;
  22661. protected _idealKernel: number;
  22662. protected _packedFloat: boolean;
  22663. private _staticDefines;
  22664. /** The direction in which to blur the image. */
  22665. direction: Vector2;
  22666. /**
  22667. * Sets the length in pixels of the blur sample region
  22668. */
  22669. set kernel(v: number);
  22670. /**
  22671. * Gets the length in pixels of the blur sample region
  22672. */
  22673. get kernel(): number;
  22674. /**
  22675. * Sets wether or not the blur needs to unpack/repack floats
  22676. */
  22677. set packedFloat(v: boolean);
  22678. /**
  22679. * Gets wether or not the blur is unpacking/repacking floats
  22680. */
  22681. get packedFloat(): boolean;
  22682. /**
  22683. * Gets a string identifying the name of the class
  22684. * @returns "BlurPostProcess" string
  22685. */
  22686. getClassName(): string;
  22687. /**
  22688. * Creates a new instance BlurPostProcess
  22689. * @param name The name of the effect.
  22690. * @param direction The direction in which to blur the image.
  22691. * @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.
  22692. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22693. * @param camera The camera to apply the render pass to.
  22694. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22695. * @param engine The engine which the post process will be applied. (default: current engine)
  22696. * @param reusable If the post process can be reused on the same frame. (default: false)
  22697. * @param textureType Type of textures used when performing the post process. (default: 0)
  22698. * @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)
  22699. */
  22700. 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);
  22701. /**
  22702. * Updates the effect with the current post process compile time values and recompiles the shader.
  22703. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22704. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22705. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22706. * @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
  22707. * @param onCompiled Called when the shader has been compiled.
  22708. * @param onError Called if there is an error when compiling a shader.
  22709. */
  22710. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22711. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22712. /**
  22713. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22714. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22715. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22716. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22717. * The gaps between physical kernels are compensated for in the weighting of the samples
  22718. * @param idealKernel Ideal blur kernel.
  22719. * @return Nearest best kernel.
  22720. */
  22721. protected _nearestBestKernel(idealKernel: number): number;
  22722. /**
  22723. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22724. * @param x The point on the Gaussian distribution to sample.
  22725. * @return the value of the Gaussian function at x.
  22726. */
  22727. protected _gaussianWeight(x: number): number;
  22728. /**
  22729. * Generates a string that can be used as a floating point number in GLSL.
  22730. * @param x Value to print.
  22731. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22732. * @return GLSL float string.
  22733. */
  22734. protected _glslFloat(x: number, decimalFigures?: number): string;
  22735. /** @hidden */
  22736. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  22737. }
  22738. }
  22739. declare module BABYLON {
  22740. /**
  22741. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22742. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22743. * You can then easily use it as a reflectionTexture on a flat surface.
  22744. * In case the surface is not a plane, please consider relying on reflection probes.
  22745. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22746. */
  22747. export class MirrorTexture extends RenderTargetTexture {
  22748. private scene;
  22749. /**
  22750. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22751. * 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.
  22752. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22753. */
  22754. mirrorPlane: Plane;
  22755. /**
  22756. * Define the blur ratio used to blur the reflection if needed.
  22757. */
  22758. set blurRatio(value: number);
  22759. get blurRatio(): number;
  22760. /**
  22761. * Define the adaptive blur kernel used to blur the reflection if needed.
  22762. * This will autocompute the closest best match for the `blurKernel`
  22763. */
  22764. set adaptiveBlurKernel(value: number);
  22765. /**
  22766. * Define the blur kernel used to blur the reflection if needed.
  22767. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22768. */
  22769. set blurKernel(value: number);
  22770. /**
  22771. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22772. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22773. */
  22774. set blurKernelX(value: number);
  22775. get blurKernelX(): number;
  22776. /**
  22777. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22778. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22779. */
  22780. set blurKernelY(value: number);
  22781. get blurKernelY(): number;
  22782. private _autoComputeBlurKernel;
  22783. protected _onRatioRescale(): void;
  22784. private _updateGammaSpace;
  22785. private _imageProcessingConfigChangeObserver;
  22786. private _transformMatrix;
  22787. private _mirrorMatrix;
  22788. private _savedViewMatrix;
  22789. private _blurX;
  22790. private _blurY;
  22791. private _adaptiveBlurKernel;
  22792. private _blurKernelX;
  22793. private _blurKernelY;
  22794. private _blurRatio;
  22795. /**
  22796. * Instantiates a Mirror Texture.
  22797. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22798. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22799. * You can then easily use it as a reflectionTexture on a flat surface.
  22800. * In case the surface is not a plane, please consider relying on reflection probes.
  22801. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22802. * @param name
  22803. * @param size
  22804. * @param scene
  22805. * @param generateMipMaps
  22806. * @param type
  22807. * @param samplingMode
  22808. * @param generateDepthBuffer
  22809. */
  22810. constructor(name: string, size: number | {
  22811. width: number;
  22812. height: number;
  22813. } | {
  22814. ratio: number;
  22815. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22816. private _preparePostProcesses;
  22817. /**
  22818. * Clone the mirror texture.
  22819. * @returns the cloned texture
  22820. */
  22821. clone(): MirrorTexture;
  22822. /**
  22823. * Serialize the texture to a JSON representation you could use in Parse later on
  22824. * @returns the serialized JSON representation
  22825. */
  22826. serialize(): any;
  22827. /**
  22828. * Dispose the texture and release its associated resources.
  22829. */
  22830. dispose(): void;
  22831. }
  22832. }
  22833. declare module BABYLON {
  22834. /**
  22835. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22836. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22837. */
  22838. export class Texture extends BaseTexture {
  22839. /**
  22840. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22841. */
  22842. static SerializeBuffers: boolean;
  22843. /**
  22844. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  22845. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  22846. */
  22847. static ForceSerializeBuffers: boolean;
  22848. /** @hidden */
  22849. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22850. /** @hidden */
  22851. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22852. /** @hidden */
  22853. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22854. /** nearest is mag = nearest and min = nearest and mip = linear */
  22855. static readonly NEAREST_SAMPLINGMODE: number;
  22856. /** nearest is mag = nearest and min = nearest and mip = linear */
  22857. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22858. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22859. static readonly BILINEAR_SAMPLINGMODE: number;
  22860. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22861. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22862. /** Trilinear is mag = linear and min = linear and mip = linear */
  22863. static readonly TRILINEAR_SAMPLINGMODE: number;
  22864. /** Trilinear is mag = linear and min = linear and mip = linear */
  22865. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22866. /** mag = nearest and min = nearest and mip = nearest */
  22867. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22868. /** mag = nearest and min = linear and mip = nearest */
  22869. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22870. /** mag = nearest and min = linear and mip = linear */
  22871. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22872. /** mag = nearest and min = linear and mip = none */
  22873. static readonly NEAREST_LINEAR: number;
  22874. /** mag = nearest and min = nearest and mip = none */
  22875. static readonly NEAREST_NEAREST: number;
  22876. /** mag = linear and min = nearest and mip = nearest */
  22877. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22878. /** mag = linear and min = nearest and mip = linear */
  22879. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22880. /** mag = linear and min = linear and mip = none */
  22881. static readonly LINEAR_LINEAR: number;
  22882. /** mag = linear and min = nearest and mip = none */
  22883. static readonly LINEAR_NEAREST: number;
  22884. /** Explicit coordinates mode */
  22885. static readonly EXPLICIT_MODE: number;
  22886. /** Spherical coordinates mode */
  22887. static readonly SPHERICAL_MODE: number;
  22888. /** Planar coordinates mode */
  22889. static readonly PLANAR_MODE: number;
  22890. /** Cubic coordinates mode */
  22891. static readonly CUBIC_MODE: number;
  22892. /** Projection coordinates mode */
  22893. static readonly PROJECTION_MODE: number;
  22894. /** Inverse Cubic coordinates mode */
  22895. static readonly SKYBOX_MODE: number;
  22896. /** Inverse Cubic coordinates mode */
  22897. static readonly INVCUBIC_MODE: number;
  22898. /** Equirectangular coordinates mode */
  22899. static readonly EQUIRECTANGULAR_MODE: number;
  22900. /** Equirectangular Fixed coordinates mode */
  22901. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22902. /** Equirectangular Fixed Mirrored coordinates mode */
  22903. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22904. /** Texture is not repeating outside of 0..1 UVs */
  22905. static readonly CLAMP_ADDRESSMODE: number;
  22906. /** Texture is repeating outside of 0..1 UVs */
  22907. static readonly WRAP_ADDRESSMODE: number;
  22908. /** Texture is repeating and mirrored */
  22909. static readonly MIRROR_ADDRESSMODE: number;
  22910. /**
  22911. * 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
  22912. */
  22913. static UseSerializedUrlIfAny: boolean;
  22914. /**
  22915. * Define the url of the texture.
  22916. */
  22917. url: Nullable<string>;
  22918. /**
  22919. * Define an offset on the texture to offset the u coordinates of the UVs
  22920. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22921. */
  22922. uOffset: number;
  22923. /**
  22924. * Define an offset on the texture to offset the v coordinates of the UVs
  22925. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22926. */
  22927. vOffset: number;
  22928. /**
  22929. * Define an offset on the texture to scale the u coordinates of the UVs
  22930. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22931. */
  22932. uScale: number;
  22933. /**
  22934. * Define an offset on the texture to scale the v coordinates of the UVs
  22935. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22936. */
  22937. vScale: number;
  22938. /**
  22939. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22940. * @see https://doc.babylonjs.com/how_to/more_materials
  22941. */
  22942. uAng: number;
  22943. /**
  22944. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22945. * @see https://doc.babylonjs.com/how_to/more_materials
  22946. */
  22947. vAng: number;
  22948. /**
  22949. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22950. * @see https://doc.babylonjs.com/how_to/more_materials
  22951. */
  22952. wAng: number;
  22953. /**
  22954. * Defines the center of rotation (U)
  22955. */
  22956. uRotationCenter: number;
  22957. /**
  22958. * Defines the center of rotation (V)
  22959. */
  22960. vRotationCenter: number;
  22961. /**
  22962. * Defines the center of rotation (W)
  22963. */
  22964. wRotationCenter: number;
  22965. /**
  22966. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  22967. */
  22968. homogeneousRotationInUVTransform: boolean;
  22969. /**
  22970. * Are mip maps generated for this texture or not.
  22971. */
  22972. get noMipmap(): boolean;
  22973. /**
  22974. * List of inspectable custom properties (used by the Inspector)
  22975. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22976. */
  22977. inspectableCustomProperties: Nullable<IInspectable[]>;
  22978. private _noMipmap;
  22979. /** @hidden */
  22980. _invertY: boolean;
  22981. private _rowGenerationMatrix;
  22982. private _cachedTextureMatrix;
  22983. private _projectionModeMatrix;
  22984. private _t0;
  22985. private _t1;
  22986. private _t2;
  22987. private _cachedUOffset;
  22988. private _cachedVOffset;
  22989. private _cachedUScale;
  22990. private _cachedVScale;
  22991. private _cachedUAng;
  22992. private _cachedVAng;
  22993. private _cachedWAng;
  22994. private _cachedProjectionMatrixId;
  22995. private _cachedURotationCenter;
  22996. private _cachedVRotationCenter;
  22997. private _cachedWRotationCenter;
  22998. private _cachedHomogeneousRotationInUVTransform;
  22999. private _cachedCoordinatesMode;
  23000. /** @hidden */
  23001. protected _initialSamplingMode: number;
  23002. /** @hidden */
  23003. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23004. private _deleteBuffer;
  23005. protected _format: Nullable<number>;
  23006. private _delayedOnLoad;
  23007. private _delayedOnError;
  23008. private _mimeType?;
  23009. private _loaderOptions?;
  23010. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23011. get mimeType(): string | undefined;
  23012. /**
  23013. * Observable triggered once the texture has been loaded.
  23014. */
  23015. onLoadObservable: Observable<Texture>;
  23016. protected _isBlocking: boolean;
  23017. /**
  23018. * Is the texture preventing material to render while loading.
  23019. * If false, a default texture will be used instead of the loading one during the preparation step.
  23020. */
  23021. set isBlocking(value: boolean);
  23022. get isBlocking(): boolean;
  23023. /**
  23024. * Get the current sampling mode associated with the texture.
  23025. */
  23026. get samplingMode(): number;
  23027. /**
  23028. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23029. */
  23030. get invertY(): boolean;
  23031. /**
  23032. * Instantiates a new texture.
  23033. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23034. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23035. * @param url defines the url of the picture to load as a texture
  23036. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23037. * @param noMipmap defines if the texture will require mip maps or not
  23038. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23039. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23040. * @param onLoad defines a callback triggered when the texture has been loaded
  23041. * @param onError defines a callback triggered when an error occurred during the loading session
  23042. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23043. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23044. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23045. * @param mimeType defines an optional mime type information
  23046. * @param loaderOptions options to be passed to the loader
  23047. */
  23048. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string, loaderOptions?: any);
  23049. /**
  23050. * Update the url (and optional buffer) of this texture if url was null during construction.
  23051. * @param url the url of the texture
  23052. * @param buffer the buffer of the texture (defaults to null)
  23053. * @param onLoad callback called when the texture is loaded (defaults to null)
  23054. */
  23055. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23056. /**
  23057. * Finish the loading sequence of a texture flagged as delayed load.
  23058. * @hidden
  23059. */
  23060. delayLoad(): void;
  23061. private _prepareRowForTextureGeneration;
  23062. /**
  23063. * Checks if the texture has the same transform matrix than another texture
  23064. * @param texture texture to check against
  23065. * @returns true if the transforms are the same, else false
  23066. */
  23067. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23068. /**
  23069. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23070. * @returns the transform matrix of the texture.
  23071. */
  23072. getTextureMatrix(uBase?: number): Matrix;
  23073. /**
  23074. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23075. * @returns The reflection texture transform
  23076. */
  23077. getReflectionTextureMatrix(): Matrix;
  23078. /**
  23079. * Clones the texture.
  23080. * @returns the cloned texture
  23081. */
  23082. clone(): Texture;
  23083. /**
  23084. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23085. * @returns The JSON representation of the texture
  23086. */
  23087. serialize(): any;
  23088. /**
  23089. * Get the current class name of the texture useful for serialization or dynamic coding.
  23090. * @returns "Texture"
  23091. */
  23092. getClassName(): string;
  23093. /**
  23094. * Dispose the texture and release its associated resources.
  23095. */
  23096. dispose(): void;
  23097. /**
  23098. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23099. * @param parsedTexture Define the JSON representation of the texture
  23100. * @param scene Define the scene the parsed texture should be instantiated in
  23101. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23102. * @returns The parsed texture if successful
  23103. */
  23104. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23105. /**
  23106. * Creates a texture from its base 64 representation.
  23107. * @param data Define the base64 payload without the data: prefix
  23108. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23109. * @param scene Define the scene the texture should belong to
  23110. * @param noMipmap Forces the texture to not create mip map information if true
  23111. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23112. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23113. * @param onLoad define a callback triggered when the texture has been loaded
  23114. * @param onError define a callback triggered when an error occurred during the loading session
  23115. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23116. * @returns the created texture
  23117. */
  23118. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23119. /**
  23120. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23121. * @param data Define the base64 payload without the data: prefix
  23122. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23123. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23124. * @param scene Define the scene the texture should belong to
  23125. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23126. * @param noMipmap Forces the texture to not create mip map information if true
  23127. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23128. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23129. * @param onLoad define a callback triggered when the texture has been loaded
  23130. * @param onError define a callback triggered when an error occurred during the loading session
  23131. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23132. * @returns the created texture
  23133. */
  23134. 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;
  23135. }
  23136. }
  23137. declare module BABYLON {
  23138. /** @hidden */
  23139. export var imageProcessingCompatibility: {
  23140. name: string;
  23141. shader: string;
  23142. };
  23143. }
  23144. declare module BABYLON {
  23145. /** @hidden */
  23146. export var spritesPixelShader: {
  23147. name: string;
  23148. shader: string;
  23149. };
  23150. }
  23151. declare module BABYLON {
  23152. /** @hidden */
  23153. export var spritesVertexShader: {
  23154. name: string;
  23155. shader: string;
  23156. };
  23157. }
  23158. declare module BABYLON {
  23159. /**
  23160. * ThinSprite Class used to represent a thin sprite
  23161. * This is the base class for sprites but can also directly be used with ThinEngine
  23162. * @see https://doc.babylonjs.com/babylon101/sprites
  23163. */
  23164. export class ThinSprite {
  23165. /** Gets or sets the cell index in the sprite sheet */
  23166. cellIndex: number;
  23167. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23168. cellRef: string;
  23169. /** Gets or sets the current world position */
  23170. position: IVector3Like;
  23171. /** Gets or sets the main color */
  23172. color: IColor4Like;
  23173. /** Gets or sets the width */
  23174. width: number;
  23175. /** Gets or sets the height */
  23176. height: number;
  23177. /** Gets or sets rotation angle */
  23178. angle: number;
  23179. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23180. invertU: boolean;
  23181. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23182. invertV: boolean;
  23183. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  23184. isVisible: boolean;
  23185. /**
  23186. * Returns a boolean indicating if the animation is started
  23187. */
  23188. get animationStarted(): boolean;
  23189. /** Gets the initial key for the animation (setting it will restart the animation) */
  23190. get fromIndex(): number;
  23191. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23192. get toIndex(): number;
  23193. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23194. get loopAnimation(): boolean;
  23195. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23196. get delay(): number;
  23197. /** @hidden */
  23198. _xOffset: number;
  23199. /** @hidden */
  23200. _yOffset: number;
  23201. /** @hidden */
  23202. _xSize: number;
  23203. /** @hidden */
  23204. _ySize: number;
  23205. private _animationStarted;
  23206. private _loopAnimation;
  23207. private _fromIndex;
  23208. private _toIndex;
  23209. private _delay;
  23210. private _direction;
  23211. private _time;
  23212. private _onBaseAnimationEnd;
  23213. /**
  23214. * Creates a new Thin Sprite
  23215. */
  23216. constructor();
  23217. /**
  23218. * Starts an animation
  23219. * @param from defines the initial key
  23220. * @param to defines the end key
  23221. * @param loop defines if the animation must loop
  23222. * @param delay defines the start delay (in ms)
  23223. * @param onAnimationEnd defines a callback for when the animation ends
  23224. */
  23225. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  23226. /** Stops current animation (if any) */
  23227. stopAnimation(): void;
  23228. /** @hidden */
  23229. _animate(deltaTime: number): void;
  23230. }
  23231. }
  23232. declare module BABYLON {
  23233. /**
  23234. * Class used to render sprites.
  23235. *
  23236. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  23237. */
  23238. export class SpriteRenderer {
  23239. /**
  23240. * Defines the texture of the spritesheet
  23241. */
  23242. texture: Nullable<ThinTexture>;
  23243. /**
  23244. * Defines the default width of a cell in the spritesheet
  23245. */
  23246. cellWidth: number;
  23247. /**
  23248. * Defines the default height of a cell in the spritesheet
  23249. */
  23250. cellHeight: number;
  23251. /**
  23252. * Blend mode use to render the particle, it can be any of
  23253. * the static Constants.ALPHA_x properties provided in this class.
  23254. * Default value is Constants.ALPHA_COMBINE
  23255. */
  23256. blendMode: number;
  23257. /**
  23258. * Gets or sets a boolean indicating if alpha mode is automatically
  23259. * reset.
  23260. */
  23261. autoResetAlpha: boolean;
  23262. /**
  23263. * Disables writing to the depth buffer when rendering the sprites.
  23264. * It can be handy to disable depth writing when using textures without alpha channel
  23265. * and setting some specific blend modes.
  23266. */
  23267. disableDepthWrite: boolean;
  23268. /**
  23269. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  23270. */
  23271. fogEnabled: boolean;
  23272. /**
  23273. * Gets the capacity of the manager
  23274. */
  23275. get capacity(): number;
  23276. private readonly _engine;
  23277. private readonly _useVAO;
  23278. private readonly _useInstancing;
  23279. private readonly _scene;
  23280. private readonly _capacity;
  23281. private readonly _epsilon;
  23282. private _vertexBufferSize;
  23283. private _vertexData;
  23284. private _buffer;
  23285. private _vertexBuffers;
  23286. private _spriteBuffer;
  23287. private _indexBuffer;
  23288. private _effectBase;
  23289. private _effectFog;
  23290. private _vertexArrayObject;
  23291. /**
  23292. * Creates a new sprite Renderer
  23293. * @param engine defines the engine the renderer works with
  23294. * @param capacity defines the maximum allowed number of sprites
  23295. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23296. * @param scene defines the hosting scene
  23297. */
  23298. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  23299. /**
  23300. * Render all child sprites
  23301. * @param sprites defines the list of sprites to render
  23302. * @param deltaTime defines the time since last frame
  23303. * @param viewMatrix defines the viewMatrix to use to render the sprites
  23304. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  23305. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  23306. */
  23307. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  23308. private _appendSpriteVertex;
  23309. /**
  23310. * Release associated resources
  23311. */
  23312. dispose(): void;
  23313. }
  23314. }
  23315. declare module BABYLON {
  23316. /**
  23317. * Defines the minimum interface to fullfil in order to be a sprite manager.
  23318. */
  23319. export interface ISpriteManager extends IDisposable {
  23320. /**
  23321. * Gets manager's name
  23322. */
  23323. name: string;
  23324. /**
  23325. * Restricts the camera to viewing objects with the same layerMask.
  23326. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  23327. */
  23328. layerMask: number;
  23329. /**
  23330. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23331. */
  23332. isPickable: boolean;
  23333. /**
  23334. * Gets the hosting scene
  23335. */
  23336. scene: Scene;
  23337. /**
  23338. * Specifies the rendering group id for this mesh (0 by default)
  23339. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23340. */
  23341. renderingGroupId: number;
  23342. /**
  23343. * Defines the list of sprites managed by the manager.
  23344. */
  23345. sprites: Array<Sprite>;
  23346. /**
  23347. * Gets or sets the spritesheet texture
  23348. */
  23349. texture: Texture;
  23350. /** Defines the default width of a cell in the spritesheet */
  23351. cellWidth: number;
  23352. /** Defines the default height of a cell in the spritesheet */
  23353. cellHeight: number;
  23354. /**
  23355. * Tests the intersection of a sprite with a specific ray.
  23356. * @param ray The ray we are sending to test the collision
  23357. * @param camera The camera space we are sending rays in
  23358. * @param predicate A predicate allowing excluding sprites from the list of object to test
  23359. * @param fastCheck defines if the first intersection will be used (and not the closest)
  23360. * @returns picking info or null.
  23361. */
  23362. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23363. /**
  23364. * Intersects the sprites with a ray
  23365. * @param ray defines the ray to intersect with
  23366. * @param camera defines the current active camera
  23367. * @param predicate defines a predicate used to select candidate sprites
  23368. * @returns null if no hit or a PickingInfo array
  23369. */
  23370. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23371. /**
  23372. * Renders the list of sprites on screen.
  23373. */
  23374. render(): void;
  23375. }
  23376. /**
  23377. * Class used to manage multiple sprites on the same spritesheet
  23378. * @see https://doc.babylonjs.com/babylon101/sprites
  23379. */
  23380. export class SpriteManager implements ISpriteManager {
  23381. /** defines the manager's name */
  23382. name: string;
  23383. /** Define the Url to load snippets */
  23384. static SnippetUrl: string;
  23385. /** Snippet ID if the manager was created from the snippet server */
  23386. snippetId: string;
  23387. /** Gets the list of sprites */
  23388. sprites: Sprite[];
  23389. /** Gets or sets the rendering group id (0 by default) */
  23390. renderingGroupId: number;
  23391. /** Gets or sets camera layer mask */
  23392. layerMask: number;
  23393. /** Gets or sets a boolean indicating if the sprites are pickable */
  23394. isPickable: boolean;
  23395. /**
  23396. * An event triggered when the manager is disposed.
  23397. */
  23398. onDisposeObservable: Observable<SpriteManager>;
  23399. /**
  23400. * Callback called when the manager is disposed
  23401. */
  23402. set onDispose(callback: () => void);
  23403. /**
  23404. * Gets or sets the unique id of the sprite
  23405. */
  23406. uniqueId: number;
  23407. /**
  23408. * Gets the array of sprites
  23409. */
  23410. get children(): Sprite[];
  23411. /**
  23412. * Gets the hosting scene
  23413. */
  23414. get scene(): Scene;
  23415. /**
  23416. * Gets the capacity of the manager
  23417. */
  23418. get capacity(): number;
  23419. /**
  23420. * Gets or sets the spritesheet texture
  23421. */
  23422. get texture(): Texture;
  23423. set texture(value: Texture);
  23424. /** Defines the default width of a cell in the spritesheet */
  23425. get cellWidth(): number;
  23426. set cellWidth(value: number);
  23427. /** Defines the default height of a cell in the spritesheet */
  23428. get cellHeight(): number;
  23429. set cellHeight(value: number);
  23430. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  23431. get fogEnabled(): boolean;
  23432. set fogEnabled(value: boolean);
  23433. /**
  23434. * Blend mode use to render the particle, it can be any of
  23435. * the static Constants.ALPHA_x properties provided in this class.
  23436. * Default value is Constants.ALPHA_COMBINE
  23437. */
  23438. get blendMode(): number;
  23439. set blendMode(blendMode: number);
  23440. /** Disables writing to the depth buffer when rendering the sprites.
  23441. * It can be handy to disable depth writing when using textures without alpha channel
  23442. * and setting some specific blend modes.
  23443. */
  23444. disableDepthWrite: boolean;
  23445. private _spriteRenderer;
  23446. /** Associative array from JSON sprite data file */
  23447. private _cellData;
  23448. /** Array of sprite names from JSON sprite data file */
  23449. private _spriteMap;
  23450. /** True when packed cell data from JSON file is ready*/
  23451. private _packedAndReady;
  23452. private _textureContent;
  23453. private _onDisposeObserver;
  23454. private _fromPacked;
  23455. private _scene;
  23456. /**
  23457. * Creates a new sprite manager
  23458. * @param name defines the manager's name
  23459. * @param imgUrl defines the sprite sheet url
  23460. * @param capacity defines the maximum allowed number of sprites
  23461. * @param cellSize defines the size of a sprite cell
  23462. * @param scene defines the hosting scene
  23463. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23464. * @param samplingMode defines the smapling mode to use with spritesheet
  23465. * @param fromPacked set to false; do not alter
  23466. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  23467. */
  23468. constructor(
  23469. /** defines the manager's name */
  23470. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  23471. /**
  23472. * Returns the string "SpriteManager"
  23473. * @returns "SpriteManager"
  23474. */
  23475. getClassName(): string;
  23476. private _makePacked;
  23477. private _checkTextureAlpha;
  23478. /**
  23479. * Intersects the sprites with a ray
  23480. * @param ray defines the ray to intersect with
  23481. * @param camera defines the current active camera
  23482. * @param predicate defines a predicate used to select candidate sprites
  23483. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  23484. * @returns null if no hit or a PickingInfo
  23485. */
  23486. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23487. /**
  23488. * Intersects the sprites with a ray
  23489. * @param ray defines the ray to intersect with
  23490. * @param camera defines the current active camera
  23491. * @param predicate defines a predicate used to select candidate sprites
  23492. * @returns null if no hit or a PickingInfo array
  23493. */
  23494. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23495. /**
  23496. * Render all child sprites
  23497. */
  23498. render(): void;
  23499. private _customUpdate;
  23500. /**
  23501. * Release associated resources
  23502. */
  23503. dispose(): void;
  23504. /**
  23505. * Serializes the sprite manager to a JSON object
  23506. * @param serializeTexture defines if the texture must be serialized as well
  23507. * @returns the JSON object
  23508. */
  23509. serialize(serializeTexture?: boolean): any;
  23510. /**
  23511. * Parses a JSON object to create a new sprite manager.
  23512. * @param parsedManager The JSON object to parse
  23513. * @param scene The scene to create the sprite managerin
  23514. * @param rootUrl The root url to use to load external dependencies like texture
  23515. * @returns the new sprite manager
  23516. */
  23517. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  23518. /**
  23519. * Creates a sprite manager from a snippet saved in a remote file
  23520. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  23521. * @param url defines the url to load from
  23522. * @param scene defines the hosting scene
  23523. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23524. * @returns a promise that will resolve to the new sprite manager
  23525. */
  23526. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23527. /**
  23528. * Creates a sprite manager from a snippet saved by the sprite editor
  23529. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  23530. * @param scene defines the hosting scene
  23531. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23532. * @returns a promise that will resolve to the new sprite manager
  23533. */
  23534. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23535. }
  23536. }
  23537. declare module BABYLON {
  23538. /**
  23539. * Class used to represent a sprite
  23540. * @see https://doc.babylonjs.com/babylon101/sprites
  23541. */
  23542. export class Sprite extends ThinSprite implements IAnimatable {
  23543. /** defines the name */
  23544. name: string;
  23545. /** Gets or sets the current world position */
  23546. position: Vector3;
  23547. /** Gets or sets the main color */
  23548. color: Color4;
  23549. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  23550. disposeWhenFinishedAnimating: boolean;
  23551. /** Gets the list of attached animations */
  23552. animations: Nullable<Array<Animation>>;
  23553. /** Gets or sets a boolean indicating if the sprite can be picked */
  23554. isPickable: boolean;
  23555. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  23556. useAlphaForPicking: boolean;
  23557. /**
  23558. * Gets or sets the associated action manager
  23559. */
  23560. actionManager: Nullable<ActionManager>;
  23561. /**
  23562. * An event triggered when the control has been disposed
  23563. */
  23564. onDisposeObservable: Observable<Sprite>;
  23565. private _manager;
  23566. private _onAnimationEnd;
  23567. /**
  23568. * Gets or sets the sprite size
  23569. */
  23570. get size(): number;
  23571. set size(value: number);
  23572. /**
  23573. * Gets or sets the unique id of the sprite
  23574. */
  23575. uniqueId: number;
  23576. /**
  23577. * Gets the manager of this sprite
  23578. */
  23579. get manager(): ISpriteManager;
  23580. /**
  23581. * Creates a new Sprite
  23582. * @param name defines the name
  23583. * @param manager defines the manager
  23584. */
  23585. constructor(
  23586. /** defines the name */
  23587. name: string, manager: ISpriteManager);
  23588. /**
  23589. * Returns the string "Sprite"
  23590. * @returns "Sprite"
  23591. */
  23592. getClassName(): string;
  23593. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  23594. set fromIndex(value: number);
  23595. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23596. set toIndex(value: number);
  23597. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23598. set loopAnimation(value: boolean);
  23599. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23600. set delay(value: number);
  23601. /**
  23602. * Starts an animation
  23603. * @param from defines the initial key
  23604. * @param to defines the end key
  23605. * @param loop defines if the animation must loop
  23606. * @param delay defines the start delay (in ms)
  23607. * @param onAnimationEnd defines a callback to call when animation ends
  23608. */
  23609. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  23610. private _endAnimation;
  23611. /** Release associated resources */
  23612. dispose(): void;
  23613. /**
  23614. * Serializes the sprite to a JSON object
  23615. * @returns the JSON object
  23616. */
  23617. serialize(): any;
  23618. /**
  23619. * Parses a JSON object to create a new sprite
  23620. * @param parsedSprite The JSON object to parse
  23621. * @param manager defines the hosting manager
  23622. * @returns the new sprite
  23623. */
  23624. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  23625. }
  23626. }
  23627. declare module BABYLON {
  23628. /**
  23629. * Information about the result of picking within a scene
  23630. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23631. */
  23632. export class PickingInfo {
  23633. /** @hidden */
  23634. _pickingUnavailable: boolean;
  23635. /**
  23636. * If the pick collided with an object
  23637. */
  23638. hit: boolean;
  23639. /**
  23640. * Distance away where the pick collided
  23641. */
  23642. distance: number;
  23643. /**
  23644. * The location of pick collision
  23645. */
  23646. pickedPoint: Nullable<Vector3>;
  23647. /**
  23648. * The mesh corresponding the the pick collision
  23649. */
  23650. pickedMesh: Nullable<AbstractMesh>;
  23651. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  23652. bu: number;
  23653. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  23654. bv: number;
  23655. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23656. faceId: number;
  23657. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23658. subMeshFaceId: number;
  23659. /** Id of the the submesh that was picked */
  23660. subMeshId: number;
  23661. /** If a sprite was picked, this will be the sprite the pick collided with */
  23662. pickedSprite: Nullable<Sprite>;
  23663. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  23664. thinInstanceIndex: number;
  23665. /**
  23666. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23667. */
  23668. originMesh: Nullable<AbstractMesh>;
  23669. /**
  23670. * The ray that was used to perform the picking.
  23671. */
  23672. ray: Nullable<Ray>;
  23673. /**
  23674. * Gets the normal correspodning to the face the pick collided with
  23675. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23676. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23677. * @returns The normal correspodning to the face the pick collided with
  23678. */
  23679. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  23680. /**
  23681. * Gets the texture coordinates of where the pick occured
  23682. * @returns the vector containing the coordnates of the texture
  23683. */
  23684. getTextureCoordinates(): Nullable<Vector2>;
  23685. }
  23686. }
  23687. declare module BABYLON {
  23688. /**
  23689. * Gather the list of pointer event types as constants.
  23690. */
  23691. export class PointerEventTypes {
  23692. /**
  23693. * 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.
  23694. */
  23695. static readonly POINTERDOWN: number;
  23696. /**
  23697. * The pointerup event is fired when a pointer is no longer active.
  23698. */
  23699. static readonly POINTERUP: number;
  23700. /**
  23701. * The pointermove event is fired when a pointer changes coordinates.
  23702. */
  23703. static readonly POINTERMOVE: number;
  23704. /**
  23705. * The pointerwheel event is fired when a mouse wheel has been rotated.
  23706. */
  23707. static readonly POINTERWHEEL: number;
  23708. /**
  23709. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  23710. */
  23711. static readonly POINTERPICK: number;
  23712. /**
  23713. * The pointertap event is fired when a the object has been touched and released without drag.
  23714. */
  23715. static readonly POINTERTAP: number;
  23716. /**
  23717. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  23718. */
  23719. static readonly POINTERDOUBLETAP: number;
  23720. }
  23721. /**
  23722. * Base class of pointer info types.
  23723. */
  23724. export class PointerInfoBase {
  23725. /**
  23726. * Defines the type of event (PointerEventTypes)
  23727. */
  23728. type: number;
  23729. /**
  23730. * Defines the related dom event
  23731. */
  23732. event: PointerEvent | MouseWheelEvent;
  23733. /**
  23734. * Instantiates the base class of pointers info.
  23735. * @param type Defines the type of event (PointerEventTypes)
  23736. * @param event Defines the related dom event
  23737. */
  23738. constructor(
  23739. /**
  23740. * Defines the type of event (PointerEventTypes)
  23741. */
  23742. type: number,
  23743. /**
  23744. * Defines the related dom event
  23745. */
  23746. event: PointerEvent | MouseWheelEvent);
  23747. }
  23748. /**
  23749. * This class is used to store pointer related info for the onPrePointerObservable event.
  23750. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  23751. */
  23752. export class PointerInfoPre extends PointerInfoBase {
  23753. /**
  23754. * Ray from a pointer if availible (eg. 6dof controller)
  23755. */
  23756. ray: Nullable<Ray>;
  23757. /**
  23758. * Defines the local position of the pointer on the canvas.
  23759. */
  23760. localPosition: Vector2;
  23761. /**
  23762. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  23763. */
  23764. skipOnPointerObservable: boolean;
  23765. /**
  23766. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  23767. * @param type Defines the type of event (PointerEventTypes)
  23768. * @param event Defines the related dom event
  23769. * @param localX Defines the local x coordinates of the pointer when the event occured
  23770. * @param localY Defines the local y coordinates of the pointer when the event occured
  23771. */
  23772. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  23773. }
  23774. /**
  23775. * This type contains all the data related to a pointer event in Babylon.js.
  23776. * 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.
  23777. */
  23778. export class PointerInfo extends PointerInfoBase {
  23779. /**
  23780. * Defines the picking info associated to the info (if any)\
  23781. */
  23782. pickInfo: Nullable<PickingInfo>;
  23783. /**
  23784. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  23785. * @param type Defines the type of event (PointerEventTypes)
  23786. * @param event Defines the related dom event
  23787. * @param pickInfo Defines the picking info associated to the info (if any)\
  23788. */
  23789. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  23790. /**
  23791. * Defines the picking info associated to the info (if any)\
  23792. */
  23793. pickInfo: Nullable<PickingInfo>);
  23794. }
  23795. /**
  23796. * Data relating to a touch event on the screen.
  23797. */
  23798. export interface PointerTouch {
  23799. /**
  23800. * X coordinate of touch.
  23801. */
  23802. x: number;
  23803. /**
  23804. * Y coordinate of touch.
  23805. */
  23806. y: number;
  23807. /**
  23808. * Id of touch. Unique for each finger.
  23809. */
  23810. pointerId: number;
  23811. /**
  23812. * Event type passed from DOM.
  23813. */
  23814. type: any;
  23815. }
  23816. }
  23817. declare module BABYLON {
  23818. /**
  23819. * Manage the mouse inputs to control the movement of a free camera.
  23820. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23821. */
  23822. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  23823. /**
  23824. * Define if touch is enabled in the mouse input
  23825. */
  23826. touchEnabled: boolean;
  23827. /**
  23828. * Defines the camera the input is attached to.
  23829. */
  23830. camera: FreeCamera;
  23831. /**
  23832. * Defines the buttons associated with the input to handle camera move.
  23833. */
  23834. buttons: number[];
  23835. /**
  23836. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  23837. */
  23838. angularSensibility: number;
  23839. private _pointerInput;
  23840. private _onMouseMove;
  23841. private _observer;
  23842. private previousPosition;
  23843. /**
  23844. * Observable for when a pointer move event occurs containing the move offset
  23845. */
  23846. onPointerMovedObservable: Observable<{
  23847. offsetX: number;
  23848. offsetY: number;
  23849. }>;
  23850. /**
  23851. * @hidden
  23852. * If the camera should be rotated automatically based on pointer movement
  23853. */
  23854. _allowCameraRotation: boolean;
  23855. /**
  23856. * Manage the mouse inputs to control the movement of a free camera.
  23857. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23858. * @param touchEnabled Defines if touch is enabled or not
  23859. */
  23860. constructor(
  23861. /**
  23862. * Define if touch is enabled in the mouse input
  23863. */
  23864. touchEnabled?: boolean);
  23865. /**
  23866. * Attach the input controls to a specific dom element to get the input from.
  23867. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23868. */
  23869. attachControl(noPreventDefault?: boolean): void;
  23870. /**
  23871. * Called on JS contextmenu event.
  23872. * Override this method to provide functionality.
  23873. */
  23874. protected onContextMenu(evt: PointerEvent): void;
  23875. /**
  23876. * Detach the current controls from the specified dom element.
  23877. */
  23878. detachControl(): void;
  23879. /**
  23880. * Gets the class name of the current intput.
  23881. * @returns the class name
  23882. */
  23883. getClassName(): string;
  23884. /**
  23885. * Get the friendly name associated with the input class.
  23886. * @returns the input friendly name
  23887. */
  23888. getSimpleName(): string;
  23889. }
  23890. }
  23891. declare module BABYLON {
  23892. /**
  23893. * Base class for mouse wheel input..
  23894. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  23895. * for example usage.
  23896. */
  23897. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  23898. /**
  23899. * Defines the camera the input is attached to.
  23900. */
  23901. abstract camera: Camera;
  23902. /**
  23903. * How fast is the camera moves in relation to X axis mouseWheel events.
  23904. * Use negative value to reverse direction.
  23905. */
  23906. wheelPrecisionX: number;
  23907. /**
  23908. * How fast is the camera moves in relation to Y axis mouseWheel events.
  23909. * Use negative value to reverse direction.
  23910. */
  23911. wheelPrecisionY: number;
  23912. /**
  23913. * How fast is the camera moves in relation to Z axis mouseWheel events.
  23914. * Use negative value to reverse direction.
  23915. */
  23916. wheelPrecisionZ: number;
  23917. /**
  23918. * Observable for when a mouse wheel move event occurs.
  23919. */
  23920. onChangedObservable: Observable<{
  23921. wheelDeltaX: number;
  23922. wheelDeltaY: number;
  23923. wheelDeltaZ: number;
  23924. }>;
  23925. private _wheel;
  23926. private _observer;
  23927. /**
  23928. * Attach the input controls to a specific dom element to get the input from.
  23929. * @param noPreventDefault Defines whether event caught by the controls
  23930. * should call preventdefault().
  23931. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23932. */
  23933. attachControl(noPreventDefault?: boolean): void;
  23934. /**
  23935. * Detach the current controls from the specified dom element.
  23936. */
  23937. detachControl(): void;
  23938. /**
  23939. * Called for each rendered frame.
  23940. */
  23941. checkInputs(): void;
  23942. /**
  23943. * Gets the class name of the current intput.
  23944. * @returns the class name
  23945. */
  23946. getClassName(): string;
  23947. /**
  23948. * Get the friendly name associated with the input class.
  23949. * @returns the input friendly name
  23950. */
  23951. getSimpleName(): string;
  23952. /**
  23953. * Incremental value of multiple mouse wheel movements of the X axis.
  23954. * Should be zero-ed when read.
  23955. */
  23956. protected _wheelDeltaX: number;
  23957. /**
  23958. * Incremental value of multiple mouse wheel movements of the Y axis.
  23959. * Should be zero-ed when read.
  23960. */
  23961. protected _wheelDeltaY: number;
  23962. /**
  23963. * Incremental value of multiple mouse wheel movements of the Z axis.
  23964. * Should be zero-ed when read.
  23965. */
  23966. protected _wheelDeltaZ: number;
  23967. /**
  23968. * Firefox uses a different scheme to report scroll distances to other
  23969. * browsers. Rather than use complicated methods to calculate the exact
  23970. * multiple we need to apply, let's just cheat and use a constant.
  23971. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  23972. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  23973. */
  23974. private readonly _ffMultiplier;
  23975. /**
  23976. * Different event attributes for wheel data fall into a few set ranges.
  23977. * Some relevant but dated date here:
  23978. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  23979. */
  23980. private readonly _normalize;
  23981. }
  23982. }
  23983. declare module BABYLON {
  23984. /**
  23985. * Manage the mouse wheel inputs to control a free camera.
  23986. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23987. */
  23988. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  23989. /**
  23990. * Defines the camera the input is attached to.
  23991. */
  23992. camera: FreeCamera;
  23993. /**
  23994. * Gets the class name of the current input.
  23995. * @returns the class name
  23996. */
  23997. getClassName(): string;
  23998. /**
  23999. * Set which movement axis (relative to camera's orientation) the mouse
  24000. * wheel's X axis controls.
  24001. * @param axis The axis to be moved. Set null to clear.
  24002. */
  24003. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24004. /**
  24005. * Get the configured movement axis (relative to camera's orientation) the
  24006. * mouse wheel's X axis controls.
  24007. * @returns The configured axis or null if none.
  24008. */
  24009. get wheelXMoveRelative(): Nullable<Coordinate>;
  24010. /**
  24011. * Set which movement axis (relative to camera's orientation) the mouse
  24012. * wheel's Y axis controls.
  24013. * @param axis The axis to be moved. Set null to clear.
  24014. */
  24015. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24016. /**
  24017. * Get the configured movement axis (relative to camera's orientation) the
  24018. * mouse wheel's Y axis controls.
  24019. * @returns The configured axis or null if none.
  24020. */
  24021. get wheelYMoveRelative(): Nullable<Coordinate>;
  24022. /**
  24023. * Set which movement axis (relative to camera's orientation) the mouse
  24024. * wheel's Z axis controls.
  24025. * @param axis The axis to be moved. Set null to clear.
  24026. */
  24027. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24028. /**
  24029. * Get the configured movement axis (relative to camera's orientation) the
  24030. * mouse wheel's Z axis controls.
  24031. * @returns The configured axis or null if none.
  24032. */
  24033. get wheelZMoveRelative(): Nullable<Coordinate>;
  24034. /**
  24035. * Set which rotation axis (relative to camera's orientation) the mouse
  24036. * wheel's X axis controls.
  24037. * @param axis The axis to be moved. Set null to clear.
  24038. */
  24039. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24040. /**
  24041. * Get the configured rotation axis (relative to camera's orientation) the
  24042. * mouse wheel's X axis controls.
  24043. * @returns The configured axis or null if none.
  24044. */
  24045. get wheelXRotateRelative(): Nullable<Coordinate>;
  24046. /**
  24047. * Set which rotation axis (relative to camera's orientation) the mouse
  24048. * wheel's Y axis controls.
  24049. * @param axis The axis to be moved. Set null to clear.
  24050. */
  24051. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24052. /**
  24053. * Get the configured rotation axis (relative to camera's orientation) the
  24054. * mouse wheel's Y axis controls.
  24055. * @returns The configured axis or null if none.
  24056. */
  24057. get wheelYRotateRelative(): Nullable<Coordinate>;
  24058. /**
  24059. * Set which rotation axis (relative to camera's orientation) the mouse
  24060. * wheel's Z axis controls.
  24061. * @param axis The axis to be moved. Set null to clear.
  24062. */
  24063. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24064. /**
  24065. * Get the configured rotation axis (relative to camera's orientation) the
  24066. * mouse wheel's Z axis controls.
  24067. * @returns The configured axis or null if none.
  24068. */
  24069. get wheelZRotateRelative(): Nullable<Coordinate>;
  24070. /**
  24071. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24072. * controls.
  24073. * @param axis The axis to be moved. Set null to clear.
  24074. */
  24075. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24076. /**
  24077. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24078. * X axis controls.
  24079. * @returns The configured axis or null if none.
  24080. */
  24081. get wheelXMoveScene(): Nullable<Coordinate>;
  24082. /**
  24083. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24084. * controls.
  24085. * @param axis The axis to be moved. Set null to clear.
  24086. */
  24087. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24088. /**
  24089. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24090. * Y axis controls.
  24091. * @returns The configured axis or null if none.
  24092. */
  24093. get wheelYMoveScene(): Nullable<Coordinate>;
  24094. /**
  24095. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24096. * controls.
  24097. * @param axis The axis to be moved. Set null to clear.
  24098. */
  24099. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24100. /**
  24101. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24102. * Z axis controls.
  24103. * @returns The configured axis or null if none.
  24104. */
  24105. get wheelZMoveScene(): Nullable<Coordinate>;
  24106. /**
  24107. * Called for each rendered frame.
  24108. */
  24109. checkInputs(): void;
  24110. private _moveRelative;
  24111. private _rotateRelative;
  24112. private _moveScene;
  24113. /**
  24114. * These are set to the desired default behaviour.
  24115. */
  24116. private _wheelXAction;
  24117. private _wheelXActionCoordinate;
  24118. private _wheelYAction;
  24119. private _wheelYActionCoordinate;
  24120. private _wheelZAction;
  24121. private _wheelZActionCoordinate;
  24122. /**
  24123. * Update the camera according to any configured properties for the 3
  24124. * mouse-wheel axis.
  24125. */
  24126. private _updateCamera;
  24127. }
  24128. }
  24129. declare module BABYLON {
  24130. /**
  24131. * Manage the touch inputs to control the movement of a free camera.
  24132. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24133. */
  24134. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24135. /**
  24136. * Define if mouse events can be treated as touch events
  24137. */
  24138. allowMouse: boolean;
  24139. /**
  24140. * Defines the camera the input is attached to.
  24141. */
  24142. camera: FreeCamera;
  24143. /**
  24144. * Defines the touch sensibility for rotation.
  24145. * The higher the faster.
  24146. */
  24147. touchAngularSensibility: number;
  24148. /**
  24149. * Defines the touch sensibility for move.
  24150. * The higher the faster.
  24151. */
  24152. touchMoveSensibility: number;
  24153. private _offsetX;
  24154. private _offsetY;
  24155. private _pointerPressed;
  24156. private _pointerInput?;
  24157. private _observer;
  24158. private _onLostFocus;
  24159. /**
  24160. * Manage the touch inputs to control the movement of a free camera.
  24161. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24162. * @param allowMouse Defines if mouse events can be treated as touch events
  24163. */
  24164. constructor(
  24165. /**
  24166. * Define if mouse events can be treated as touch events
  24167. */
  24168. allowMouse?: boolean);
  24169. /**
  24170. * Attach the input controls to a specific dom element to get the input from.
  24171. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24172. */
  24173. attachControl(noPreventDefault?: boolean): void;
  24174. /**
  24175. * Detach the current controls from the specified dom element.
  24176. */
  24177. detachControl(): void;
  24178. /**
  24179. * Update the current camera state depending on the inputs that have been used this frame.
  24180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24181. */
  24182. checkInputs(): void;
  24183. /**
  24184. * Gets the class name of the current intput.
  24185. * @returns the class name
  24186. */
  24187. getClassName(): string;
  24188. /**
  24189. * Get the friendly name associated with the input class.
  24190. * @returns the input friendly name
  24191. */
  24192. getSimpleName(): string;
  24193. }
  24194. }
  24195. declare module BABYLON {
  24196. /**
  24197. * Default Inputs manager for the FreeCamera.
  24198. * It groups all the default supported inputs for ease of use.
  24199. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24200. */
  24201. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  24202. /**
  24203. * @hidden
  24204. */
  24205. _mouseInput: Nullable<FreeCameraMouseInput>;
  24206. /**
  24207. * @hidden
  24208. */
  24209. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  24210. /**
  24211. * Instantiates a new FreeCameraInputsManager.
  24212. * @param camera Defines the camera the inputs belong to
  24213. */
  24214. constructor(camera: FreeCamera);
  24215. /**
  24216. * Add keyboard input support to the input manager.
  24217. * @returns the current input manager
  24218. */
  24219. addKeyboard(): FreeCameraInputsManager;
  24220. /**
  24221. * Add mouse input support to the input manager.
  24222. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  24223. * @returns the current input manager
  24224. */
  24225. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  24226. /**
  24227. * Removes the mouse input support from the manager
  24228. * @returns the current input manager
  24229. */
  24230. removeMouse(): FreeCameraInputsManager;
  24231. /**
  24232. * Add mouse wheel input support to the input manager.
  24233. * @returns the current input manager
  24234. */
  24235. addMouseWheel(): FreeCameraInputsManager;
  24236. /**
  24237. * Removes the mouse wheel input support from the manager
  24238. * @returns the current input manager
  24239. */
  24240. removeMouseWheel(): FreeCameraInputsManager;
  24241. /**
  24242. * Add touch input support to the input manager.
  24243. * @returns the current input manager
  24244. */
  24245. addTouch(): FreeCameraInputsManager;
  24246. /**
  24247. * Remove all attached input methods from a camera
  24248. */
  24249. clear(): void;
  24250. }
  24251. }
  24252. declare module BABYLON {
  24253. /**
  24254. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24255. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  24256. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24257. */
  24258. export class FreeCamera extends TargetCamera {
  24259. /**
  24260. * Define the collision ellipsoid of the camera.
  24261. * This is helpful to simulate a camera body like the player body around the camera
  24262. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  24263. */
  24264. ellipsoid: Vector3;
  24265. /**
  24266. * Define an offset for the position of the ellipsoid around the camera.
  24267. * This can be helpful to determine the center of the body near the gravity center of the body
  24268. * instead of its head.
  24269. */
  24270. ellipsoidOffset: Vector3;
  24271. /**
  24272. * Enable or disable collisions of the camera with the rest of the scene objects.
  24273. */
  24274. checkCollisions: boolean;
  24275. /**
  24276. * Enable or disable gravity on the camera.
  24277. */
  24278. applyGravity: boolean;
  24279. /**
  24280. * Define the input manager associated to the camera.
  24281. */
  24282. inputs: FreeCameraInputsManager;
  24283. /**
  24284. * Gets the input sensibility for a mouse input. (default is 2000.0)
  24285. * Higher values reduce sensitivity.
  24286. */
  24287. get angularSensibility(): number;
  24288. /**
  24289. * Sets the input sensibility for a mouse input. (default is 2000.0)
  24290. * Higher values reduce sensitivity.
  24291. */
  24292. set angularSensibility(value: number);
  24293. /**
  24294. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  24295. */
  24296. get keysUp(): number[];
  24297. set keysUp(value: number[]);
  24298. /**
  24299. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  24300. */
  24301. get keysUpward(): number[];
  24302. set keysUpward(value: number[]);
  24303. /**
  24304. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  24305. */
  24306. get keysDown(): number[];
  24307. set keysDown(value: number[]);
  24308. /**
  24309. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  24310. */
  24311. get keysDownward(): number[];
  24312. set keysDownward(value: number[]);
  24313. /**
  24314. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  24315. */
  24316. get keysLeft(): number[];
  24317. set keysLeft(value: number[]);
  24318. /**
  24319. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  24320. */
  24321. get keysRight(): number[];
  24322. set keysRight(value: number[]);
  24323. /**
  24324. * Event raised when the camera collide with a mesh in the scene.
  24325. */
  24326. onCollide: (collidedMesh: AbstractMesh) => void;
  24327. private _collider;
  24328. private _needMoveForGravity;
  24329. private _oldPosition;
  24330. private _diffPosition;
  24331. private _newPosition;
  24332. /** @hidden */
  24333. _localDirection: Vector3;
  24334. /** @hidden */
  24335. _transformedDirection: Vector3;
  24336. /**
  24337. * Instantiates a Free Camera.
  24338. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24339. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  24340. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24341. * @param name Define the name of the camera in the scene
  24342. * @param position Define the start position of the camera in the scene
  24343. * @param scene Define the scene the camera belongs to
  24344. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  24345. */
  24346. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24347. /**
  24348. * Attach the input controls to a specific dom element to get the input from.
  24349. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24350. */
  24351. attachControl(noPreventDefault?: boolean): void;
  24352. /**
  24353. * Attach the input controls to a specific dom element to get the input from.
  24354. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  24355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24356. * BACK COMPAT SIGNATURE ONLY.
  24357. */
  24358. attachControl(ignored: any, noPreventDefault?: boolean): void;
  24359. /**
  24360. * Detach the current controls from the specified dom element.
  24361. */
  24362. detachControl(): void;
  24363. /**
  24364. * Detach the current controls from the specified dom element.
  24365. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  24366. */
  24367. detachControl(ignored: any): void;
  24368. private _collisionMask;
  24369. /**
  24370. * Define a collision mask to limit the list of object the camera can collide with
  24371. */
  24372. get collisionMask(): number;
  24373. set collisionMask(mask: number);
  24374. /** @hidden */
  24375. _collideWithWorld(displacement: Vector3): void;
  24376. private _onCollisionPositionChange;
  24377. /** @hidden */
  24378. _checkInputs(): void;
  24379. /** @hidden */
  24380. _decideIfNeedsToMove(): boolean;
  24381. /** @hidden */
  24382. _updatePosition(): void;
  24383. /**
  24384. * Destroy the camera and release the current resources hold by it.
  24385. */
  24386. dispose(): void;
  24387. /**
  24388. * Gets the current object class name.
  24389. * @return the class name
  24390. */
  24391. getClassName(): string;
  24392. }
  24393. }
  24394. declare module BABYLON {
  24395. /**
  24396. * Represents a gamepad control stick position
  24397. */
  24398. export class StickValues {
  24399. /**
  24400. * The x component of the control stick
  24401. */
  24402. x: number;
  24403. /**
  24404. * The y component of the control stick
  24405. */
  24406. y: number;
  24407. /**
  24408. * Initializes the gamepad x and y control stick values
  24409. * @param x The x component of the gamepad control stick value
  24410. * @param y The y component of the gamepad control stick value
  24411. */
  24412. constructor(
  24413. /**
  24414. * The x component of the control stick
  24415. */
  24416. x: number,
  24417. /**
  24418. * The y component of the control stick
  24419. */
  24420. y: number);
  24421. }
  24422. /**
  24423. * An interface which manages callbacks for gamepad button changes
  24424. */
  24425. export interface GamepadButtonChanges {
  24426. /**
  24427. * Called when a gamepad has been changed
  24428. */
  24429. changed: boolean;
  24430. /**
  24431. * Called when a gamepad press event has been triggered
  24432. */
  24433. pressChanged: boolean;
  24434. /**
  24435. * Called when a touch event has been triggered
  24436. */
  24437. touchChanged: boolean;
  24438. /**
  24439. * Called when a value has changed
  24440. */
  24441. valueChanged: boolean;
  24442. }
  24443. /**
  24444. * Represents a gamepad
  24445. */
  24446. export class Gamepad {
  24447. /**
  24448. * The id of the gamepad
  24449. */
  24450. id: string;
  24451. /**
  24452. * The index of the gamepad
  24453. */
  24454. index: number;
  24455. /**
  24456. * The browser gamepad
  24457. */
  24458. browserGamepad: any;
  24459. /**
  24460. * Specifies what type of gamepad this represents
  24461. */
  24462. type: number;
  24463. private _leftStick;
  24464. private _rightStick;
  24465. /** @hidden */
  24466. _isConnected: boolean;
  24467. private _leftStickAxisX;
  24468. private _leftStickAxisY;
  24469. private _rightStickAxisX;
  24470. private _rightStickAxisY;
  24471. /**
  24472. * Triggered when the left control stick has been changed
  24473. */
  24474. private _onleftstickchanged;
  24475. /**
  24476. * Triggered when the right control stick has been changed
  24477. */
  24478. private _onrightstickchanged;
  24479. /**
  24480. * Represents a gamepad controller
  24481. */
  24482. static GAMEPAD: number;
  24483. /**
  24484. * Represents a generic controller
  24485. */
  24486. static GENERIC: number;
  24487. /**
  24488. * Represents an XBox controller
  24489. */
  24490. static XBOX: number;
  24491. /**
  24492. * Represents a pose-enabled controller
  24493. */
  24494. static POSE_ENABLED: number;
  24495. /**
  24496. * Represents an Dual Shock controller
  24497. */
  24498. static DUALSHOCK: number;
  24499. /**
  24500. * Specifies whether the left control stick should be Y-inverted
  24501. */
  24502. protected _invertLeftStickY: boolean;
  24503. /**
  24504. * Specifies if the gamepad has been connected
  24505. */
  24506. get isConnected(): boolean;
  24507. /**
  24508. * Initializes the gamepad
  24509. * @param id The id of the gamepad
  24510. * @param index The index of the gamepad
  24511. * @param browserGamepad The browser gamepad
  24512. * @param leftStickX The x component of the left joystick
  24513. * @param leftStickY The y component of the left joystick
  24514. * @param rightStickX The x component of the right joystick
  24515. * @param rightStickY The y component of the right joystick
  24516. */
  24517. constructor(
  24518. /**
  24519. * The id of the gamepad
  24520. */
  24521. id: string,
  24522. /**
  24523. * The index of the gamepad
  24524. */
  24525. index: number,
  24526. /**
  24527. * The browser gamepad
  24528. */
  24529. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  24530. /**
  24531. * Callback triggered when the left joystick has changed
  24532. * @param callback
  24533. */
  24534. onleftstickchanged(callback: (values: StickValues) => void): void;
  24535. /**
  24536. * Callback triggered when the right joystick has changed
  24537. * @param callback
  24538. */
  24539. onrightstickchanged(callback: (values: StickValues) => void): void;
  24540. /**
  24541. * Gets the left joystick
  24542. */
  24543. get leftStick(): StickValues;
  24544. /**
  24545. * Sets the left joystick values
  24546. */
  24547. set leftStick(newValues: StickValues);
  24548. /**
  24549. * Gets the right joystick
  24550. */
  24551. get rightStick(): StickValues;
  24552. /**
  24553. * Sets the right joystick value
  24554. */
  24555. set rightStick(newValues: StickValues);
  24556. /**
  24557. * Updates the gamepad joystick positions
  24558. */
  24559. update(): void;
  24560. /**
  24561. * Disposes the gamepad
  24562. */
  24563. dispose(): void;
  24564. }
  24565. /**
  24566. * Represents a generic gamepad
  24567. */
  24568. export class GenericPad extends Gamepad {
  24569. private _buttons;
  24570. private _onbuttondown;
  24571. private _onbuttonup;
  24572. /**
  24573. * Observable triggered when a button has been pressed
  24574. */
  24575. onButtonDownObservable: Observable<number>;
  24576. /**
  24577. * Observable triggered when a button has been released
  24578. */
  24579. onButtonUpObservable: Observable<number>;
  24580. /**
  24581. * Callback triggered when a button has been pressed
  24582. * @param callback Called when a button has been pressed
  24583. */
  24584. onbuttondown(callback: (buttonPressed: number) => void): void;
  24585. /**
  24586. * Callback triggered when a button has been released
  24587. * @param callback Called when a button has been released
  24588. */
  24589. onbuttonup(callback: (buttonReleased: number) => void): void;
  24590. /**
  24591. * Initializes the generic gamepad
  24592. * @param id The id of the generic gamepad
  24593. * @param index The index of the generic gamepad
  24594. * @param browserGamepad The browser gamepad
  24595. */
  24596. constructor(id: string, index: number, browserGamepad: any);
  24597. private _setButtonValue;
  24598. /**
  24599. * Updates the generic gamepad
  24600. */
  24601. update(): void;
  24602. /**
  24603. * Disposes the generic gamepad
  24604. */
  24605. dispose(): void;
  24606. }
  24607. }
  24608. declare module BABYLON {
  24609. /**
  24610. * Defines a runtime animation
  24611. */
  24612. export class RuntimeAnimation {
  24613. private _events;
  24614. /**
  24615. * The current frame of the runtime animation
  24616. */
  24617. private _currentFrame;
  24618. /**
  24619. * The animation used by the runtime animation
  24620. */
  24621. private _animation;
  24622. /**
  24623. * The target of the runtime animation
  24624. */
  24625. private _target;
  24626. /**
  24627. * The initiating animatable
  24628. */
  24629. private _host;
  24630. /**
  24631. * The original value of the runtime animation
  24632. */
  24633. private _originalValue;
  24634. /**
  24635. * The original blend value of the runtime animation
  24636. */
  24637. private _originalBlendValue;
  24638. /**
  24639. * The offsets cache of the runtime animation
  24640. */
  24641. private _offsetsCache;
  24642. /**
  24643. * The high limits cache of the runtime animation
  24644. */
  24645. private _highLimitsCache;
  24646. /**
  24647. * Specifies if the runtime animation has been stopped
  24648. */
  24649. private _stopped;
  24650. /**
  24651. * The blending factor of the runtime animation
  24652. */
  24653. private _blendingFactor;
  24654. /**
  24655. * The BabylonJS scene
  24656. */
  24657. private _scene;
  24658. /**
  24659. * The current value of the runtime animation
  24660. */
  24661. private _currentValue;
  24662. /** @hidden */
  24663. _animationState: _IAnimationState;
  24664. /**
  24665. * The active target of the runtime animation
  24666. */
  24667. private _activeTargets;
  24668. private _currentActiveTarget;
  24669. private _directTarget;
  24670. /**
  24671. * The target path of the runtime animation
  24672. */
  24673. private _targetPath;
  24674. /**
  24675. * The weight of the runtime animation
  24676. */
  24677. private _weight;
  24678. /**
  24679. * The ratio offset of the runtime animation
  24680. */
  24681. private _ratioOffset;
  24682. /**
  24683. * The previous delay of the runtime animation
  24684. */
  24685. private _previousDelay;
  24686. /**
  24687. * The previous ratio of the runtime animation
  24688. */
  24689. private _previousRatio;
  24690. private _enableBlending;
  24691. private _keys;
  24692. private _minFrame;
  24693. private _maxFrame;
  24694. private _minValue;
  24695. private _maxValue;
  24696. private _targetIsArray;
  24697. /**
  24698. * Gets the current frame of the runtime animation
  24699. */
  24700. get currentFrame(): number;
  24701. /**
  24702. * Gets the weight of the runtime animation
  24703. */
  24704. get weight(): number;
  24705. /**
  24706. * Gets the current value of the runtime animation
  24707. */
  24708. get currentValue(): any;
  24709. /**
  24710. * Gets the target path of the runtime animation
  24711. */
  24712. get targetPath(): string;
  24713. /**
  24714. * Gets the actual target of the runtime animation
  24715. */
  24716. get target(): any;
  24717. /**
  24718. * Gets the additive state of the runtime animation
  24719. */
  24720. get isAdditive(): boolean;
  24721. /** @hidden */
  24722. _onLoop: () => void;
  24723. /**
  24724. * Create a new RuntimeAnimation object
  24725. * @param target defines the target of the animation
  24726. * @param animation defines the source animation object
  24727. * @param scene defines the hosting scene
  24728. * @param host defines the initiating Animatable
  24729. */
  24730. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  24731. private _preparePath;
  24732. /**
  24733. * Gets the animation from the runtime animation
  24734. */
  24735. get animation(): Animation;
  24736. /**
  24737. * Resets the runtime animation to the beginning
  24738. * @param restoreOriginal defines whether to restore the target property to the original value
  24739. */
  24740. reset(restoreOriginal?: boolean): void;
  24741. /**
  24742. * Specifies if the runtime animation is stopped
  24743. * @returns Boolean specifying if the runtime animation is stopped
  24744. */
  24745. isStopped(): boolean;
  24746. /**
  24747. * Disposes of the runtime animation
  24748. */
  24749. dispose(): void;
  24750. /**
  24751. * Apply the interpolated value to the target
  24752. * @param currentValue defines the value computed by the animation
  24753. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  24754. */
  24755. setValue(currentValue: any, weight: number): void;
  24756. private _getOriginalValues;
  24757. private _setValue;
  24758. /**
  24759. * Gets the loop pmode of the runtime animation
  24760. * @returns Loop Mode
  24761. */
  24762. private _getCorrectLoopMode;
  24763. /**
  24764. * Move the current animation to a given frame
  24765. * @param frame defines the frame to move to
  24766. */
  24767. goToFrame(frame: number): void;
  24768. /**
  24769. * @hidden Internal use only
  24770. */
  24771. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  24772. /**
  24773. * Execute the current animation
  24774. * @param delay defines the delay to add to the current frame
  24775. * @param from defines the lower bound of the animation range
  24776. * @param to defines the upper bound of the animation range
  24777. * @param loop defines if the current animation must loop
  24778. * @param speedRatio defines the current speed ratio
  24779. * @param weight defines the weight of the animation (default is -1 so no weight)
  24780. * @param onLoop optional callback called when animation loops
  24781. * @returns a boolean indicating if the animation is running
  24782. */
  24783. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  24784. }
  24785. }
  24786. declare module BABYLON {
  24787. /**
  24788. * Class used to store an actual running animation
  24789. */
  24790. export class Animatable {
  24791. /** defines the target object */
  24792. target: any;
  24793. /** defines the starting frame number (default is 0) */
  24794. fromFrame: number;
  24795. /** defines the ending frame number (default is 100) */
  24796. toFrame: number;
  24797. /** defines if the animation must loop (default is false) */
  24798. loopAnimation: boolean;
  24799. /** defines a callback to call when animation ends if it is not looping */
  24800. onAnimationEnd?: (() => void) | null | undefined;
  24801. /** defines a callback to call when animation loops */
  24802. onAnimationLoop?: (() => void) | null | undefined;
  24803. /** defines whether the animation should be evaluated additively */
  24804. isAdditive: boolean;
  24805. private _localDelayOffset;
  24806. private _pausedDelay;
  24807. private _runtimeAnimations;
  24808. private _paused;
  24809. private _scene;
  24810. private _speedRatio;
  24811. private _weight;
  24812. private _syncRoot;
  24813. /**
  24814. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  24815. * This will only apply for non looping animation (default is true)
  24816. */
  24817. disposeOnEnd: boolean;
  24818. /**
  24819. * Gets a boolean indicating if the animation has started
  24820. */
  24821. animationStarted: boolean;
  24822. /**
  24823. * Observer raised when the animation ends
  24824. */
  24825. onAnimationEndObservable: Observable<Animatable>;
  24826. /**
  24827. * Observer raised when the animation loops
  24828. */
  24829. onAnimationLoopObservable: Observable<Animatable>;
  24830. /**
  24831. * Gets the root Animatable used to synchronize and normalize animations
  24832. */
  24833. get syncRoot(): Nullable<Animatable>;
  24834. /**
  24835. * Gets the current frame of the first RuntimeAnimation
  24836. * Used to synchronize Animatables
  24837. */
  24838. get masterFrame(): number;
  24839. /**
  24840. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  24841. */
  24842. get weight(): number;
  24843. set weight(value: number);
  24844. /**
  24845. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  24846. */
  24847. get speedRatio(): number;
  24848. set speedRatio(value: number);
  24849. /**
  24850. * Creates a new Animatable
  24851. * @param scene defines the hosting scene
  24852. * @param target defines the target object
  24853. * @param fromFrame defines the starting frame number (default is 0)
  24854. * @param toFrame defines the ending frame number (default is 100)
  24855. * @param loopAnimation defines if the animation must loop (default is false)
  24856. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  24857. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  24858. * @param animations defines a group of animation to add to the new Animatable
  24859. * @param onAnimationLoop defines a callback to call when animation loops
  24860. * @param isAdditive defines whether the animation should be evaluated additively
  24861. */
  24862. constructor(scene: Scene,
  24863. /** defines the target object */
  24864. target: any,
  24865. /** defines the starting frame number (default is 0) */
  24866. fromFrame?: number,
  24867. /** defines the ending frame number (default is 100) */
  24868. toFrame?: number,
  24869. /** defines if the animation must loop (default is false) */
  24870. loopAnimation?: boolean, speedRatio?: number,
  24871. /** defines a callback to call when animation ends if it is not looping */
  24872. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  24873. /** defines a callback to call when animation loops */
  24874. onAnimationLoop?: (() => void) | null | undefined,
  24875. /** defines whether the animation should be evaluated additively */
  24876. isAdditive?: boolean);
  24877. /**
  24878. * Synchronize and normalize current Animatable with a source Animatable
  24879. * This is useful when using animation weights and when animations are not of the same length
  24880. * @param root defines the root Animatable to synchronize with
  24881. * @returns the current Animatable
  24882. */
  24883. syncWith(root: Animatable): Animatable;
  24884. /**
  24885. * Gets the list of runtime animations
  24886. * @returns an array of RuntimeAnimation
  24887. */
  24888. getAnimations(): RuntimeAnimation[];
  24889. /**
  24890. * Adds more animations to the current animatable
  24891. * @param target defines the target of the animations
  24892. * @param animations defines the new animations to add
  24893. */
  24894. appendAnimations(target: any, animations: Animation[]): void;
  24895. /**
  24896. * Gets the source animation for a specific property
  24897. * @param property defines the propertyu to look for
  24898. * @returns null or the source animation for the given property
  24899. */
  24900. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  24901. /**
  24902. * Gets the runtime animation for a specific property
  24903. * @param property defines the propertyu to look for
  24904. * @returns null or the runtime animation for the given property
  24905. */
  24906. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  24907. /**
  24908. * Resets the animatable to its original state
  24909. */
  24910. reset(): void;
  24911. /**
  24912. * Allows the animatable to blend with current running animations
  24913. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24914. * @param blendingSpeed defines the blending speed to use
  24915. */
  24916. enableBlending(blendingSpeed: number): void;
  24917. /**
  24918. * Disable animation blending
  24919. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24920. */
  24921. disableBlending(): void;
  24922. /**
  24923. * Jump directly to a given frame
  24924. * @param frame defines the frame to jump to
  24925. */
  24926. goToFrame(frame: number): void;
  24927. /**
  24928. * Pause the animation
  24929. */
  24930. pause(): void;
  24931. /**
  24932. * Restart the animation
  24933. */
  24934. restart(): void;
  24935. private _raiseOnAnimationEnd;
  24936. /**
  24937. * Stop and delete the current animation
  24938. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  24939. * @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)
  24940. */
  24941. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  24942. /**
  24943. * Wait asynchronously for the animation to end
  24944. * @returns a promise which will be fullfilled when the animation ends
  24945. */
  24946. waitAsync(): Promise<Animatable>;
  24947. /** @hidden */
  24948. _animate(delay: number): boolean;
  24949. }
  24950. interface Scene {
  24951. /** @hidden */
  24952. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  24953. /** @hidden */
  24954. _processLateAnimationBindingsForMatrices(holder: {
  24955. totalWeight: number;
  24956. totalAdditiveWeight: number;
  24957. animations: RuntimeAnimation[];
  24958. additiveAnimations: RuntimeAnimation[];
  24959. originalValue: Matrix;
  24960. }): any;
  24961. /** @hidden */
  24962. _processLateAnimationBindingsForQuaternions(holder: {
  24963. totalWeight: number;
  24964. totalAdditiveWeight: number;
  24965. animations: RuntimeAnimation[];
  24966. additiveAnimations: RuntimeAnimation[];
  24967. originalValue: Quaternion;
  24968. }, refQuaternion: Quaternion): Quaternion;
  24969. /** @hidden */
  24970. _processLateAnimationBindings(): void;
  24971. /**
  24972. * Will start the animation sequence of a given target
  24973. * @param target defines the target
  24974. * @param from defines from which frame should animation start
  24975. * @param to defines until which frame should animation run.
  24976. * @param weight defines the weight to apply to the animation (1.0 by default)
  24977. * @param loop defines if the animation loops
  24978. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24979. * @param onAnimationEnd defines the function to be executed when the animation ends
  24980. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24981. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  24982. * @param onAnimationLoop defines the callback to call when an animation loops
  24983. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  24984. * @returns the animatable object created for this animation
  24985. */
  24986. 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;
  24987. /**
  24988. * Will start the animation sequence of a given target
  24989. * @param target defines the target
  24990. * @param from defines from which frame should animation start
  24991. * @param to defines until which frame should animation run.
  24992. * @param loop defines if the animation loops
  24993. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24994. * @param onAnimationEnd defines the function to be executed when the animation ends
  24995. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24996. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  24997. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  24998. * @param onAnimationLoop defines the callback to call when an animation loops
  24999. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25000. * @returns the animatable object created for this animation
  25001. */
  25002. 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;
  25003. /**
  25004. * Will start the animation sequence of a given target and its hierarchy
  25005. * @param target defines the target
  25006. * @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.
  25007. * @param from defines from which frame should animation start
  25008. * @param to defines until which frame should animation run.
  25009. * @param loop defines if the animation loops
  25010. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25011. * @param onAnimationEnd defines the function to be executed when the animation ends
  25012. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25013. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25014. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25015. * @param onAnimationLoop defines the callback to call when an animation loops
  25016. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25017. * @returns the list of created animatables
  25018. */
  25019. 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[];
  25020. /**
  25021. * Begin a new animation on a given node
  25022. * @param target defines the target where the animation will take place
  25023. * @param animations defines the list of animations to start
  25024. * @param from defines the initial value
  25025. * @param to defines the final value
  25026. * @param loop defines if you want animation to loop (off by default)
  25027. * @param speedRatio defines the speed ratio to apply to all animations
  25028. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25029. * @param onAnimationLoop defines the callback to call when an animation loops
  25030. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25031. * @returns the list of created animatables
  25032. */
  25033. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25034. /**
  25035. * Begin a new animation on a given node and its hierarchy
  25036. * @param target defines the root node where the animation will take place
  25037. * @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.
  25038. * @param animations defines the list of animations to start
  25039. * @param from defines the initial value
  25040. * @param to defines the final value
  25041. * @param loop defines if you want animation to loop (off by default)
  25042. * @param speedRatio defines the speed ratio to apply to all animations
  25043. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25044. * @param onAnimationLoop defines the callback to call when an animation loops
  25045. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25046. * @returns the list of animatables created for all nodes
  25047. */
  25048. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25049. /**
  25050. * Gets the animatable associated with a specific target
  25051. * @param target defines the target of the animatable
  25052. * @returns the required animatable if found
  25053. */
  25054. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25055. /**
  25056. * Gets all animatables associated with a given target
  25057. * @param target defines the target to look animatables for
  25058. * @returns an array of Animatables
  25059. */
  25060. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25061. /**
  25062. * Stops and removes all animations that have been applied to the scene
  25063. */
  25064. stopAllAnimations(): void;
  25065. /**
  25066. * Gets the current delta time used by animation engine
  25067. */
  25068. deltaTime: number;
  25069. }
  25070. interface Bone {
  25071. /**
  25072. * Copy an animation range from another bone
  25073. * @param source defines the source bone
  25074. * @param rangeName defines the range name to copy
  25075. * @param frameOffset defines the frame offset
  25076. * @param rescaleAsRequired defines if rescaling must be applied if required
  25077. * @param skelDimensionsRatio defines the scaling ratio
  25078. * @returns true if operation was successful
  25079. */
  25080. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25081. }
  25082. }
  25083. declare module BABYLON {
  25084. /**
  25085. * Class used to override all child animations of a given target
  25086. */
  25087. export class AnimationPropertiesOverride {
  25088. /**
  25089. * Gets or sets a value indicating if animation blending must be used
  25090. */
  25091. enableBlending: boolean;
  25092. /**
  25093. * Gets or sets the blending speed to use when enableBlending is true
  25094. */
  25095. blendingSpeed: number;
  25096. /**
  25097. * Gets or sets the default loop mode to use
  25098. */
  25099. loopMode: number;
  25100. }
  25101. }
  25102. declare module BABYLON {
  25103. /**
  25104. * Class used to handle skinning animations
  25105. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25106. */
  25107. export class Skeleton implements IAnimatable {
  25108. /** defines the skeleton name */
  25109. name: string;
  25110. /** defines the skeleton Id */
  25111. id: string;
  25112. /**
  25113. * Defines the list of child bones
  25114. */
  25115. bones: Bone[];
  25116. /**
  25117. * Defines an estimate of the dimension of the skeleton at rest
  25118. */
  25119. dimensionsAtRest: Vector3;
  25120. /**
  25121. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25122. */
  25123. needInitialSkinMatrix: boolean;
  25124. /**
  25125. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25126. */
  25127. overrideMesh: Nullable<AbstractMesh>;
  25128. /**
  25129. * Gets the list of animations attached to this skeleton
  25130. */
  25131. animations: Array<Animation>;
  25132. private _scene;
  25133. private _isDirty;
  25134. private _transformMatrices;
  25135. private _transformMatrixTexture;
  25136. private _meshesWithPoseMatrix;
  25137. private _animatables;
  25138. private _identity;
  25139. private _synchronizedWithMesh;
  25140. private _ranges;
  25141. private _lastAbsoluteTransformsUpdateId;
  25142. private _canUseTextureForBones;
  25143. private _uniqueId;
  25144. /** @hidden */
  25145. _numBonesWithLinkedTransformNode: number;
  25146. /** @hidden */
  25147. _hasWaitingData: Nullable<boolean>;
  25148. /** @hidden */
  25149. _waitingOverrideMeshId: Nullable<string>;
  25150. /**
  25151. * Specifies if the skeleton should be serialized
  25152. */
  25153. doNotSerialize: boolean;
  25154. private _useTextureToStoreBoneMatrices;
  25155. /**
  25156. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25157. * Please note that this option is not available if the hardware does not support it
  25158. */
  25159. get useTextureToStoreBoneMatrices(): boolean;
  25160. set useTextureToStoreBoneMatrices(value: boolean);
  25161. private _animationPropertiesOverride;
  25162. /**
  25163. * Gets or sets the animation properties override
  25164. */
  25165. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25166. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25167. /**
  25168. * List of inspectable custom properties (used by the Inspector)
  25169. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25170. */
  25171. inspectableCustomProperties: IInspectable[];
  25172. /**
  25173. * An observable triggered before computing the skeleton's matrices
  25174. */
  25175. onBeforeComputeObservable: Observable<Skeleton>;
  25176. /**
  25177. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25178. */
  25179. get isUsingTextureForMatrices(): boolean;
  25180. /**
  25181. * Gets the unique ID of this skeleton
  25182. */
  25183. get uniqueId(): number;
  25184. /**
  25185. * Creates a new skeleton
  25186. * @param name defines the skeleton name
  25187. * @param id defines the skeleton Id
  25188. * @param scene defines the hosting scene
  25189. */
  25190. constructor(
  25191. /** defines the skeleton name */
  25192. name: string,
  25193. /** defines the skeleton Id */
  25194. id: string, scene: Scene);
  25195. /**
  25196. * Gets the current object class name.
  25197. * @return the class name
  25198. */
  25199. getClassName(): string;
  25200. /**
  25201. * Returns an array containing the root bones
  25202. * @returns an array containing the root bones
  25203. */
  25204. getChildren(): Array<Bone>;
  25205. /**
  25206. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25207. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25208. * @returns a Float32Array containing matrices data
  25209. */
  25210. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  25211. /**
  25212. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  25213. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25214. * @returns a raw texture containing the data
  25215. */
  25216. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  25217. /**
  25218. * Gets the current hosting scene
  25219. * @returns a scene object
  25220. */
  25221. getScene(): Scene;
  25222. /**
  25223. * Gets a string representing the current skeleton data
  25224. * @param fullDetails defines a boolean indicating if we want a verbose version
  25225. * @returns a string representing the current skeleton data
  25226. */
  25227. toString(fullDetails?: boolean): string;
  25228. /**
  25229. * Get bone's index searching by name
  25230. * @param name defines bone's name to search for
  25231. * @return the indice of the bone. Returns -1 if not found
  25232. */
  25233. getBoneIndexByName(name: string): number;
  25234. /**
  25235. * Creater a new animation range
  25236. * @param name defines the name of the range
  25237. * @param from defines the start key
  25238. * @param to defines the end key
  25239. */
  25240. createAnimationRange(name: string, from: number, to: number): void;
  25241. /**
  25242. * Delete a specific animation range
  25243. * @param name defines the name of the range
  25244. * @param deleteFrames defines if frames must be removed as well
  25245. */
  25246. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25247. /**
  25248. * Gets a specific animation range
  25249. * @param name defines the name of the range to look for
  25250. * @returns the requested animation range or null if not found
  25251. */
  25252. getAnimationRange(name: string): Nullable<AnimationRange>;
  25253. /**
  25254. * Gets the list of all animation ranges defined on this skeleton
  25255. * @returns an array
  25256. */
  25257. getAnimationRanges(): Nullable<AnimationRange>[];
  25258. /**
  25259. * Copy animation range from a source skeleton.
  25260. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  25261. * @param source defines the source skeleton
  25262. * @param name defines the name of the range to copy
  25263. * @param rescaleAsRequired defines if rescaling must be applied if required
  25264. * @returns true if operation was successful
  25265. */
  25266. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  25267. /**
  25268. * Forces the skeleton to go to rest pose
  25269. */
  25270. returnToRest(): void;
  25271. private _getHighestAnimationFrame;
  25272. /**
  25273. * Begin a specific animation range
  25274. * @param name defines the name of the range to start
  25275. * @param loop defines if looping must be turned on (false by default)
  25276. * @param speedRatio defines the speed ratio to apply (1 by default)
  25277. * @param onAnimationEnd defines a callback which will be called when animation will end
  25278. * @returns a new animatable
  25279. */
  25280. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25281. /**
  25282. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  25283. * @param skeleton defines the Skeleton containing the animation range to convert
  25284. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  25285. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  25286. * @returns the original skeleton
  25287. */
  25288. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  25289. /** @hidden */
  25290. _markAsDirty(): void;
  25291. /** @hidden */
  25292. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25293. /** @hidden */
  25294. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25295. private _computeTransformMatrices;
  25296. /**
  25297. * Build all resources required to render a skeleton
  25298. */
  25299. prepare(): void;
  25300. /**
  25301. * Gets the list of animatables currently running for this skeleton
  25302. * @returns an array of animatables
  25303. */
  25304. getAnimatables(): IAnimatable[];
  25305. /**
  25306. * Clone the current skeleton
  25307. * @param name defines the name of the new skeleton
  25308. * @param id defines the id of the new skeleton
  25309. * @returns the new skeleton
  25310. */
  25311. clone(name: string, id?: string): Skeleton;
  25312. /**
  25313. * Enable animation blending for this skeleton
  25314. * @param blendingSpeed defines the blending speed to apply
  25315. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25316. */
  25317. enableBlending(blendingSpeed?: number): void;
  25318. /**
  25319. * Releases all resources associated with the current skeleton
  25320. */
  25321. dispose(): void;
  25322. /**
  25323. * Serialize the skeleton in a JSON object
  25324. * @returns a JSON object
  25325. */
  25326. serialize(): any;
  25327. /**
  25328. * Creates a new skeleton from serialized data
  25329. * @param parsedSkeleton defines the serialized data
  25330. * @param scene defines the hosting scene
  25331. * @returns a new skeleton
  25332. */
  25333. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  25334. /**
  25335. * Compute all node absolute transforms
  25336. * @param forceUpdate defines if computation must be done even if cache is up to date
  25337. */
  25338. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  25339. /**
  25340. * Gets the root pose matrix
  25341. * @returns a matrix
  25342. */
  25343. getPoseMatrix(): Nullable<Matrix>;
  25344. /**
  25345. * Sorts bones per internal index
  25346. */
  25347. sortBones(): void;
  25348. private _sortBones;
  25349. /**
  25350. * Set the current local matrix as the restPose for all bones in the skeleton.
  25351. */
  25352. setCurrentPoseAsRest(): void;
  25353. }
  25354. }
  25355. declare module BABYLON {
  25356. /**
  25357. * Class used to store bone information
  25358. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25359. */
  25360. export class Bone extends Node {
  25361. /**
  25362. * defines the bone name
  25363. */
  25364. name: string;
  25365. private static _tmpVecs;
  25366. private static _tmpQuat;
  25367. private static _tmpMats;
  25368. /**
  25369. * Gets the list of child bones
  25370. */
  25371. children: Bone[];
  25372. /** Gets the animations associated with this bone */
  25373. animations: Animation[];
  25374. /**
  25375. * Gets or sets bone length
  25376. */
  25377. length: number;
  25378. /**
  25379. * @hidden Internal only
  25380. * Set this value to map this bone to a different index in the transform matrices
  25381. * Set this value to -1 to exclude the bone from the transform matrices
  25382. */
  25383. _index: Nullable<number>;
  25384. private _skeleton;
  25385. private _localMatrix;
  25386. private _restPose;
  25387. private _bindPose;
  25388. private _baseMatrix;
  25389. private _absoluteTransform;
  25390. private _invertedAbsoluteTransform;
  25391. private _parent;
  25392. private _scalingDeterminant;
  25393. private _worldTransform;
  25394. private _localScaling;
  25395. private _localRotation;
  25396. private _localPosition;
  25397. private _needToDecompose;
  25398. private _needToCompose;
  25399. /** @hidden */
  25400. _linkedTransformNode: Nullable<TransformNode>;
  25401. /** @hidden */
  25402. _waitingTransformNodeId: Nullable<string>;
  25403. /** @hidden */
  25404. get _matrix(): Matrix;
  25405. /** @hidden */
  25406. set _matrix(value: Matrix);
  25407. /**
  25408. * Create a new bone
  25409. * @param name defines the bone name
  25410. * @param skeleton defines the parent skeleton
  25411. * @param parentBone defines the parent (can be null if the bone is the root)
  25412. * @param localMatrix defines the local matrix
  25413. * @param restPose defines the rest pose matrix
  25414. * @param baseMatrix defines the base matrix
  25415. * @param index defines index of the bone in the hiearchy
  25416. */
  25417. constructor(
  25418. /**
  25419. * defines the bone name
  25420. */
  25421. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  25422. /**
  25423. * Gets the current object class name.
  25424. * @return the class name
  25425. */
  25426. getClassName(): string;
  25427. /**
  25428. * Gets the parent skeleton
  25429. * @returns a skeleton
  25430. */
  25431. getSkeleton(): Skeleton;
  25432. /**
  25433. * Gets parent bone
  25434. * @returns a bone or null if the bone is the root of the bone hierarchy
  25435. */
  25436. getParent(): Nullable<Bone>;
  25437. /**
  25438. * Returns an array containing the root bones
  25439. * @returns an array containing the root bones
  25440. */
  25441. getChildren(): Array<Bone>;
  25442. /**
  25443. * Gets the node index in matrix array generated for rendering
  25444. * @returns the node index
  25445. */
  25446. getIndex(): number;
  25447. /**
  25448. * Sets the parent bone
  25449. * @param parent defines the parent (can be null if the bone is the root)
  25450. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25451. */
  25452. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  25453. /**
  25454. * Gets the local matrix
  25455. * @returns a matrix
  25456. */
  25457. getLocalMatrix(): Matrix;
  25458. /**
  25459. * Gets the base matrix (initial matrix which remains unchanged)
  25460. * @returns a matrix
  25461. */
  25462. getBaseMatrix(): Matrix;
  25463. /**
  25464. * Gets the rest pose matrix
  25465. * @returns a matrix
  25466. */
  25467. getRestPose(): Matrix;
  25468. /**
  25469. * Sets the rest pose matrix
  25470. * @param matrix the local-space rest pose to set for this bone
  25471. */
  25472. setRestPose(matrix: Matrix): void;
  25473. /**
  25474. * Gets the bind pose matrix
  25475. * @returns the bind pose matrix
  25476. */
  25477. getBindPose(): Matrix;
  25478. /**
  25479. * Sets the bind pose matrix
  25480. * @param matrix the local-space bind pose to set for this bone
  25481. */
  25482. setBindPose(matrix: Matrix): void;
  25483. /**
  25484. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  25485. */
  25486. getWorldMatrix(): Matrix;
  25487. /**
  25488. * Sets the local matrix to rest pose matrix
  25489. */
  25490. returnToRest(): void;
  25491. /**
  25492. * Gets the inverse of the absolute transform matrix.
  25493. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  25494. * @returns a matrix
  25495. */
  25496. getInvertedAbsoluteTransform(): Matrix;
  25497. /**
  25498. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  25499. * @returns a matrix
  25500. */
  25501. getAbsoluteTransform(): Matrix;
  25502. /**
  25503. * Links with the given transform node.
  25504. * The local matrix of this bone is copied from the transform node every frame.
  25505. * @param transformNode defines the transform node to link to
  25506. */
  25507. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  25508. /**
  25509. * Gets the node used to drive the bone's transformation
  25510. * @returns a transform node or null
  25511. */
  25512. getTransformNode(): Nullable<TransformNode>;
  25513. /** Gets or sets current position (in local space) */
  25514. get position(): Vector3;
  25515. set position(newPosition: Vector3);
  25516. /** Gets or sets current rotation (in local space) */
  25517. get rotation(): Vector3;
  25518. set rotation(newRotation: Vector3);
  25519. /** Gets or sets current rotation quaternion (in local space) */
  25520. get rotationQuaternion(): Quaternion;
  25521. set rotationQuaternion(newRotation: Quaternion);
  25522. /** Gets or sets current scaling (in local space) */
  25523. get scaling(): Vector3;
  25524. set scaling(newScaling: Vector3);
  25525. /**
  25526. * Gets the animation properties override
  25527. */
  25528. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25529. private _decompose;
  25530. private _compose;
  25531. /**
  25532. * Update the base and local matrices
  25533. * @param matrix defines the new base or local matrix
  25534. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25535. * @param updateLocalMatrix defines if the local matrix should be updated
  25536. */
  25537. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  25538. /** @hidden */
  25539. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  25540. /**
  25541. * Flag the bone as dirty (Forcing it to update everything)
  25542. */
  25543. markAsDirty(): void;
  25544. /** @hidden */
  25545. _markAsDirtyAndCompose(): void;
  25546. private _markAsDirtyAndDecompose;
  25547. /**
  25548. * Translate the bone in local or world space
  25549. * @param vec The amount to translate the bone
  25550. * @param space The space that the translation is in
  25551. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25552. */
  25553. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25554. /**
  25555. * Set the postion of the bone in local or world space
  25556. * @param position The position to set the bone
  25557. * @param space The space that the position is in
  25558. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25559. */
  25560. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25561. /**
  25562. * Set the absolute position of the bone (world space)
  25563. * @param position The position to set the bone
  25564. * @param mesh The mesh that this bone is attached to
  25565. */
  25566. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  25567. /**
  25568. * Scale the bone on the x, y and z axes (in local space)
  25569. * @param x The amount to scale the bone on the x axis
  25570. * @param y The amount to scale the bone on the y axis
  25571. * @param z The amount to scale the bone on the z axis
  25572. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  25573. */
  25574. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  25575. /**
  25576. * Set the bone scaling in local space
  25577. * @param scale defines the scaling vector
  25578. */
  25579. setScale(scale: Vector3): void;
  25580. /**
  25581. * Gets the current scaling in local space
  25582. * @returns the current scaling vector
  25583. */
  25584. getScale(): Vector3;
  25585. /**
  25586. * Gets the current scaling in local space and stores it in a target vector
  25587. * @param result defines the target vector
  25588. */
  25589. getScaleToRef(result: Vector3): void;
  25590. /**
  25591. * Set the yaw, pitch, and roll of the bone in local or world space
  25592. * @param yaw The rotation of the bone on the y axis
  25593. * @param pitch The rotation of the bone on the x axis
  25594. * @param roll The rotation of the bone on the z axis
  25595. * @param space The space that the axes of rotation are in
  25596. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25597. */
  25598. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  25599. /**
  25600. * Add a rotation to the bone on an axis in local or world space
  25601. * @param axis The axis to rotate the bone on
  25602. * @param amount The amount to rotate the bone
  25603. * @param space The space that the axis is in
  25604. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25605. */
  25606. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  25607. /**
  25608. * Set the rotation of the bone to a particular axis angle in local or world space
  25609. * @param axis The axis to rotate the bone on
  25610. * @param angle The angle that the bone should be rotated to
  25611. * @param space The space that the axis is in
  25612. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25613. */
  25614. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  25615. /**
  25616. * Set the euler rotation of the bone in local or world space
  25617. * @param rotation The euler rotation that the bone should be set to
  25618. * @param space The space that the rotation is in
  25619. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25620. */
  25621. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25622. /**
  25623. * Set the quaternion rotation of the bone in local or world space
  25624. * @param quat The quaternion rotation that the bone should be set to
  25625. * @param space The space that the rotation is in
  25626. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25627. */
  25628. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  25629. /**
  25630. * Set the rotation matrix of the bone in local or world space
  25631. * @param rotMat The rotation matrix that the bone should be set to
  25632. * @param space The space that the rotation is in
  25633. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25634. */
  25635. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  25636. private _rotateWithMatrix;
  25637. private _getNegativeRotationToRef;
  25638. /**
  25639. * Get the position of the bone in local or world space
  25640. * @param space The space that the returned position is in
  25641. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25642. * @returns The position of the bone
  25643. */
  25644. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25645. /**
  25646. * Copy the position of the bone to a vector3 in local or world space
  25647. * @param space The space that the returned position is in
  25648. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25649. * @param result The vector3 to copy the position to
  25650. */
  25651. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  25652. /**
  25653. * Get the absolute position of the bone (world space)
  25654. * @param mesh The mesh that this bone is attached to
  25655. * @returns The absolute position of the bone
  25656. */
  25657. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  25658. /**
  25659. * Copy the absolute position of the bone (world space) to the result param
  25660. * @param mesh The mesh that this bone is attached to
  25661. * @param result The vector3 to copy the absolute position to
  25662. */
  25663. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  25664. /**
  25665. * Compute the absolute transforms of this bone and its children
  25666. */
  25667. computeAbsoluteTransforms(): void;
  25668. /**
  25669. * Get the world direction from an axis that is in the local space of the bone
  25670. * @param localAxis The local direction that is used to compute the world direction
  25671. * @param mesh The mesh that this bone is attached to
  25672. * @returns The world direction
  25673. */
  25674. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25675. /**
  25676. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  25677. * @param localAxis The local direction that is used to compute the world direction
  25678. * @param mesh The mesh that this bone is attached to
  25679. * @param result The vector3 that the world direction will be copied to
  25680. */
  25681. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25682. /**
  25683. * Get the euler rotation of the bone in local or world space
  25684. * @param space The space that the rotation should be in
  25685. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25686. * @returns The euler rotation
  25687. */
  25688. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25689. /**
  25690. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  25691. * @param space The space that the rotation should be in
  25692. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25693. * @param result The vector3 that the rotation should be copied to
  25694. */
  25695. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25696. /**
  25697. * Get the quaternion rotation of the bone in either local or world space
  25698. * @param space The space that the rotation should be in
  25699. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25700. * @returns The quaternion rotation
  25701. */
  25702. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  25703. /**
  25704. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  25705. * @param space The space that the rotation should be in
  25706. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25707. * @param result The quaternion that the rotation should be copied to
  25708. */
  25709. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  25710. /**
  25711. * Get the rotation matrix of the bone in local or world space
  25712. * @param space The space that the rotation should be in
  25713. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25714. * @returns The rotation matrix
  25715. */
  25716. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  25717. /**
  25718. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  25719. * @param space The space that the rotation should be in
  25720. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25721. * @param result The quaternion that the rotation should be copied to
  25722. */
  25723. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  25724. /**
  25725. * Get the world position of a point that is in the local space of the bone
  25726. * @param position The local position
  25727. * @param mesh The mesh that this bone is attached to
  25728. * @returns The world position
  25729. */
  25730. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25731. /**
  25732. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  25733. * @param position The local position
  25734. * @param mesh The mesh that this bone is attached to
  25735. * @param result The vector3 that the world position should be copied to
  25736. */
  25737. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25738. /**
  25739. * Get the local position of a point that is in world space
  25740. * @param position The world position
  25741. * @param mesh The mesh that this bone is attached to
  25742. * @returns The local position
  25743. */
  25744. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25745. /**
  25746. * Get the local position of a point that is in world space and copy it to the result param
  25747. * @param position The world position
  25748. * @param mesh The mesh that this bone is attached to
  25749. * @param result The vector3 that the local position should be copied to
  25750. */
  25751. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25752. /**
  25753. * Set the current local matrix as the restPose for this bone.
  25754. */
  25755. setCurrentPoseAsRest(): void;
  25756. }
  25757. }
  25758. declare module BABYLON {
  25759. /**
  25760. * 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.
  25761. * @see https://doc.babylonjs.com/how_to/transformnode
  25762. */
  25763. export class TransformNode extends Node {
  25764. /**
  25765. * Object will not rotate to face the camera
  25766. */
  25767. static BILLBOARDMODE_NONE: number;
  25768. /**
  25769. * Object will rotate to face the camera but only on the x axis
  25770. */
  25771. static BILLBOARDMODE_X: number;
  25772. /**
  25773. * Object will rotate to face the camera but only on the y axis
  25774. */
  25775. static BILLBOARDMODE_Y: number;
  25776. /**
  25777. * Object will rotate to face the camera but only on the z axis
  25778. */
  25779. static BILLBOARDMODE_Z: number;
  25780. /**
  25781. * Object will rotate to face the camera
  25782. */
  25783. static BILLBOARDMODE_ALL: number;
  25784. /**
  25785. * Object will rotate to face the camera's position instead of orientation
  25786. */
  25787. static BILLBOARDMODE_USE_POSITION: number;
  25788. private static _TmpRotation;
  25789. private static _TmpScaling;
  25790. private static _TmpTranslation;
  25791. private _forward;
  25792. private _forwardInverted;
  25793. private _up;
  25794. private _right;
  25795. private _rightInverted;
  25796. private _position;
  25797. private _rotation;
  25798. private _rotationQuaternion;
  25799. protected _scaling: Vector3;
  25800. protected _isDirty: boolean;
  25801. private _transformToBoneReferal;
  25802. private _isAbsoluteSynced;
  25803. private _billboardMode;
  25804. /**
  25805. * Gets or sets the billboard mode. Default is 0.
  25806. *
  25807. * | Value | Type | Description |
  25808. * | --- | --- | --- |
  25809. * | 0 | BILLBOARDMODE_NONE | |
  25810. * | 1 | BILLBOARDMODE_X | |
  25811. * | 2 | BILLBOARDMODE_Y | |
  25812. * | 4 | BILLBOARDMODE_Z | |
  25813. * | 7 | BILLBOARDMODE_ALL | |
  25814. *
  25815. */
  25816. get billboardMode(): number;
  25817. set billboardMode(value: number);
  25818. private _preserveParentRotationForBillboard;
  25819. /**
  25820. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  25821. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  25822. */
  25823. get preserveParentRotationForBillboard(): boolean;
  25824. set preserveParentRotationForBillboard(value: boolean);
  25825. /**
  25826. * 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
  25827. */
  25828. scalingDeterminant: number;
  25829. private _infiniteDistance;
  25830. /**
  25831. * Gets or sets the distance of the object to max, often used by skybox
  25832. */
  25833. get infiniteDistance(): boolean;
  25834. set infiniteDistance(value: boolean);
  25835. /**
  25836. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  25837. * By default the system will update normals to compensate
  25838. */
  25839. ignoreNonUniformScaling: boolean;
  25840. /**
  25841. * 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
  25842. */
  25843. reIntegrateRotationIntoRotationQuaternion: boolean;
  25844. /** @hidden */
  25845. _poseMatrix: Nullable<Matrix>;
  25846. /** @hidden */
  25847. _localMatrix: Matrix;
  25848. private _usePivotMatrix;
  25849. private _absolutePosition;
  25850. private _absoluteScaling;
  25851. private _absoluteRotationQuaternion;
  25852. private _pivotMatrix;
  25853. private _pivotMatrixInverse;
  25854. /** @hidden */
  25855. _postMultiplyPivotMatrix: boolean;
  25856. protected _isWorldMatrixFrozen: boolean;
  25857. /** @hidden */
  25858. _indexInSceneTransformNodesArray: number;
  25859. /**
  25860. * An event triggered after the world matrix is updated
  25861. */
  25862. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  25863. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  25864. /**
  25865. * Gets a string identifying the name of the class
  25866. * @returns "TransformNode" string
  25867. */
  25868. getClassName(): string;
  25869. /**
  25870. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  25871. */
  25872. get position(): Vector3;
  25873. set position(newPosition: Vector3);
  25874. /**
  25875. * 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)).
  25876. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  25877. */
  25878. get rotation(): Vector3;
  25879. set rotation(newRotation: Vector3);
  25880. /**
  25881. * 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)).
  25882. */
  25883. get scaling(): Vector3;
  25884. set scaling(newScaling: Vector3);
  25885. /**
  25886. * 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).
  25887. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  25888. */
  25889. get rotationQuaternion(): Nullable<Quaternion>;
  25890. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  25891. /**
  25892. * The forward direction of that transform in world space.
  25893. */
  25894. get forward(): Vector3;
  25895. /**
  25896. * The up direction of that transform in world space.
  25897. */
  25898. get up(): Vector3;
  25899. /**
  25900. * The right direction of that transform in world space.
  25901. */
  25902. get right(): Vector3;
  25903. /**
  25904. * Copies the parameter passed Matrix into the mesh Pose matrix.
  25905. * @param matrix the matrix to copy the pose from
  25906. * @returns this TransformNode.
  25907. */
  25908. updatePoseMatrix(matrix: Matrix): TransformNode;
  25909. /**
  25910. * Returns the mesh Pose matrix.
  25911. * @returns the pose matrix
  25912. */
  25913. getPoseMatrix(): Matrix;
  25914. /** @hidden */
  25915. _isSynchronized(): boolean;
  25916. /** @hidden */
  25917. _initCache(): void;
  25918. /**
  25919. * Flag the transform node as dirty (Forcing it to update everything)
  25920. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  25921. * @returns this transform node
  25922. */
  25923. markAsDirty(property: string): TransformNode;
  25924. /**
  25925. * Returns the current mesh absolute position.
  25926. * Returns a Vector3.
  25927. */
  25928. get absolutePosition(): Vector3;
  25929. /**
  25930. * Returns the current mesh absolute scaling.
  25931. * Returns a Vector3.
  25932. */
  25933. get absoluteScaling(): Vector3;
  25934. /**
  25935. * Returns the current mesh absolute rotation.
  25936. * Returns a Quaternion.
  25937. */
  25938. get absoluteRotationQuaternion(): Quaternion;
  25939. /**
  25940. * Sets a new matrix to apply before all other transformation
  25941. * @param matrix defines the transform matrix
  25942. * @returns the current TransformNode
  25943. */
  25944. setPreTransformMatrix(matrix: Matrix): TransformNode;
  25945. /**
  25946. * Sets a new pivot matrix to the current node
  25947. * @param matrix defines the new pivot matrix to use
  25948. * @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
  25949. * @returns the current TransformNode
  25950. */
  25951. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  25952. /**
  25953. * Returns the mesh pivot matrix.
  25954. * Default : Identity.
  25955. * @returns the matrix
  25956. */
  25957. getPivotMatrix(): Matrix;
  25958. /**
  25959. * Instantiate (when possible) or clone that node with its hierarchy
  25960. * @param newParent defines the new parent to use for the instance (or clone)
  25961. * @param options defines options to configure how copy is done
  25962. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  25963. * @returns an instance (or a clone) of the current node with its hiearchy
  25964. */
  25965. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25966. doNotInstantiate: boolean;
  25967. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25968. /**
  25969. * Prevents the World matrix to be computed any longer
  25970. * @param newWorldMatrix defines an optional matrix to use as world matrix
  25971. * @returns the TransformNode.
  25972. */
  25973. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  25974. /**
  25975. * Allows back the World matrix computation.
  25976. * @returns the TransformNode.
  25977. */
  25978. unfreezeWorldMatrix(): this;
  25979. /**
  25980. * True if the World matrix has been frozen.
  25981. */
  25982. get isWorldMatrixFrozen(): boolean;
  25983. /**
  25984. * Retuns the mesh absolute position in the World.
  25985. * @returns a Vector3.
  25986. */
  25987. getAbsolutePosition(): Vector3;
  25988. /**
  25989. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  25990. * @param absolutePosition the absolute position to set
  25991. * @returns the TransformNode.
  25992. */
  25993. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  25994. /**
  25995. * Sets the mesh position in its local space.
  25996. * @param vector3 the position to set in localspace
  25997. * @returns the TransformNode.
  25998. */
  25999. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26000. /**
  26001. * Returns the mesh position in the local space from the current World matrix values.
  26002. * @returns a new Vector3.
  26003. */
  26004. getPositionExpressedInLocalSpace(): Vector3;
  26005. /**
  26006. * Translates the mesh along the passed Vector3 in its local space.
  26007. * @param vector3 the distance to translate in localspace
  26008. * @returns the TransformNode.
  26009. */
  26010. locallyTranslate(vector3: Vector3): TransformNode;
  26011. private static _lookAtVectorCache;
  26012. /**
  26013. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26014. * @param targetPoint the position (must be in same space as current mesh) to look at
  26015. * @param yawCor optional yaw (y-axis) correction in radians
  26016. * @param pitchCor optional pitch (x-axis) correction in radians
  26017. * @param rollCor optional roll (z-axis) correction in radians
  26018. * @param space the choosen space of the target
  26019. * @returns the TransformNode.
  26020. */
  26021. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26022. /**
  26023. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26024. * This Vector3 is expressed in the World space.
  26025. * @param localAxis axis to rotate
  26026. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26027. */
  26028. getDirection(localAxis: Vector3): Vector3;
  26029. /**
  26030. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26031. * localAxis is expressed in the mesh local space.
  26032. * result is computed in the Wordl space from the mesh World matrix.
  26033. * @param localAxis axis to rotate
  26034. * @param result the resulting transformnode
  26035. * @returns this TransformNode.
  26036. */
  26037. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26038. /**
  26039. * Sets this transform node rotation to the given local axis.
  26040. * @param localAxis the axis in local space
  26041. * @param yawCor optional yaw (y-axis) correction in radians
  26042. * @param pitchCor optional pitch (x-axis) correction in radians
  26043. * @param rollCor optional roll (z-axis) correction in radians
  26044. * @returns this TransformNode
  26045. */
  26046. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26047. /**
  26048. * Sets a new pivot point to the current node
  26049. * @param point defines the new pivot point to use
  26050. * @param space defines if the point is in world or local space (local by default)
  26051. * @returns the current TransformNode
  26052. */
  26053. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26054. /**
  26055. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26056. * @returns the pivot point
  26057. */
  26058. getPivotPoint(): Vector3;
  26059. /**
  26060. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26061. * @param result the vector3 to store the result
  26062. * @returns this TransformNode.
  26063. */
  26064. getPivotPointToRef(result: Vector3): TransformNode;
  26065. /**
  26066. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26067. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26068. */
  26069. getAbsolutePivotPoint(): Vector3;
  26070. /**
  26071. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26072. * @param result vector3 to store the result
  26073. * @returns this TransformNode.
  26074. */
  26075. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26076. /**
  26077. * Defines the passed node as the parent of the current node.
  26078. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26079. * @see https://doc.babylonjs.com/how_to/parenting
  26080. * @param node the node ot set as the parent
  26081. * @returns this TransformNode.
  26082. */
  26083. setParent(node: Nullable<Node>): TransformNode;
  26084. private _nonUniformScaling;
  26085. /**
  26086. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26087. */
  26088. get nonUniformScaling(): boolean;
  26089. /** @hidden */
  26090. _updateNonUniformScalingState(value: boolean): boolean;
  26091. /**
  26092. * Attach the current TransformNode to another TransformNode associated with a bone
  26093. * @param bone Bone affecting the TransformNode
  26094. * @param affectedTransformNode TransformNode associated with the bone
  26095. * @returns this object
  26096. */
  26097. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26098. /**
  26099. * Detach the transform node if its associated with a bone
  26100. * @returns this object
  26101. */
  26102. detachFromBone(): TransformNode;
  26103. private static _rotationAxisCache;
  26104. /**
  26105. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26106. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26107. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26108. * The passed axis is also normalized.
  26109. * @param axis the axis to rotate around
  26110. * @param amount the amount to rotate in radians
  26111. * @param space Space to rotate in (Default: local)
  26112. * @returns the TransformNode.
  26113. */
  26114. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26115. /**
  26116. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26117. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26118. * The passed axis is also normalized. .
  26119. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26120. * @param point the point to rotate around
  26121. * @param axis the axis to rotate around
  26122. * @param amount the amount to rotate in radians
  26123. * @returns the TransformNode
  26124. */
  26125. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26126. /**
  26127. * Translates the mesh along the axis vector for the passed distance in the given space.
  26128. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26129. * @param axis the axis to translate in
  26130. * @param distance the distance to translate
  26131. * @param space Space to rotate in (Default: local)
  26132. * @returns the TransformNode.
  26133. */
  26134. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26135. /**
  26136. * Adds a rotation step to the mesh current rotation.
  26137. * x, y, z are Euler angles expressed in radians.
  26138. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26139. * This means this rotation is made in the mesh local space only.
  26140. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26141. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26142. * ```javascript
  26143. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26144. * ```
  26145. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26146. * 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.
  26147. * @param x Rotation to add
  26148. * @param y Rotation to add
  26149. * @param z Rotation to add
  26150. * @returns the TransformNode.
  26151. */
  26152. addRotation(x: number, y: number, z: number): TransformNode;
  26153. /**
  26154. * @hidden
  26155. */
  26156. protected _getEffectiveParent(): Nullable<Node>;
  26157. /**
  26158. * Computes the world matrix of the node
  26159. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26160. * @returns the world matrix
  26161. */
  26162. computeWorldMatrix(force?: boolean): Matrix;
  26163. /**
  26164. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26165. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26166. */
  26167. resetLocalMatrix(independentOfChildren?: boolean): void;
  26168. protected _afterComputeWorldMatrix(): void;
  26169. /**
  26170. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26171. * @param func callback function to add
  26172. *
  26173. * @returns the TransformNode.
  26174. */
  26175. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26176. /**
  26177. * Removes a registered callback function.
  26178. * @param func callback function to remove
  26179. * @returns the TransformNode.
  26180. */
  26181. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26182. /**
  26183. * Gets the position of the current mesh in camera space
  26184. * @param camera defines the camera to use
  26185. * @returns a position
  26186. */
  26187. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26188. /**
  26189. * Returns the distance from the mesh to the active camera
  26190. * @param camera defines the camera to use
  26191. * @returns the distance
  26192. */
  26193. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26194. /**
  26195. * Clone the current transform node
  26196. * @param name Name of the new clone
  26197. * @param newParent New parent for the clone
  26198. * @param doNotCloneChildren Do not clone children hierarchy
  26199. * @returns the new transform node
  26200. */
  26201. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26202. /**
  26203. * Serializes the objects information.
  26204. * @param currentSerializationObject defines the object to serialize in
  26205. * @returns the serialized object
  26206. */
  26207. serialize(currentSerializationObject?: any): any;
  26208. /**
  26209. * Returns a new TransformNode object parsed from the source provided.
  26210. * @param parsedTransformNode is the source.
  26211. * @param scene the scne the object belongs to
  26212. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26213. * @returns a new TransformNode object parsed from the source provided.
  26214. */
  26215. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26216. /**
  26217. * Get all child-transformNodes of this node
  26218. * @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
  26219. * @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
  26220. * @returns an array of TransformNode
  26221. */
  26222. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  26223. /**
  26224. * Releases resources associated with this transform node.
  26225. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26226. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26227. */
  26228. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26229. /**
  26230. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26231. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26232. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26233. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26234. * @returns the current mesh
  26235. */
  26236. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  26237. private _syncAbsoluteScalingAndRotation;
  26238. }
  26239. }
  26240. declare module BABYLON {
  26241. /**
  26242. * Defines the types of pose enabled controllers that are supported
  26243. */
  26244. export enum PoseEnabledControllerType {
  26245. /**
  26246. * HTC Vive
  26247. */
  26248. VIVE = 0,
  26249. /**
  26250. * Oculus Rift
  26251. */
  26252. OCULUS = 1,
  26253. /**
  26254. * Windows mixed reality
  26255. */
  26256. WINDOWS = 2,
  26257. /**
  26258. * Samsung gear VR
  26259. */
  26260. GEAR_VR = 3,
  26261. /**
  26262. * Google Daydream
  26263. */
  26264. DAYDREAM = 4,
  26265. /**
  26266. * Generic
  26267. */
  26268. GENERIC = 5
  26269. }
  26270. /**
  26271. * Defines the MutableGamepadButton interface for the state of a gamepad button
  26272. */
  26273. export interface MutableGamepadButton {
  26274. /**
  26275. * Value of the button/trigger
  26276. */
  26277. value: number;
  26278. /**
  26279. * If the button/trigger is currently touched
  26280. */
  26281. touched: boolean;
  26282. /**
  26283. * If the button/trigger is currently pressed
  26284. */
  26285. pressed: boolean;
  26286. }
  26287. /**
  26288. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  26289. * @hidden
  26290. */
  26291. export interface ExtendedGamepadButton extends GamepadButton {
  26292. /**
  26293. * If the button/trigger is currently pressed
  26294. */
  26295. readonly pressed: boolean;
  26296. /**
  26297. * If the button/trigger is currently touched
  26298. */
  26299. readonly touched: boolean;
  26300. /**
  26301. * Value of the button/trigger
  26302. */
  26303. readonly value: number;
  26304. }
  26305. /** @hidden */
  26306. export interface _GamePadFactory {
  26307. /**
  26308. * Returns whether or not the current gamepad can be created for this type of controller.
  26309. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26310. * @returns true if it can be created, otherwise false
  26311. */
  26312. canCreate(gamepadInfo: any): boolean;
  26313. /**
  26314. * Creates a new instance of the Gamepad.
  26315. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26316. * @returns the new gamepad instance
  26317. */
  26318. create(gamepadInfo: any): Gamepad;
  26319. }
  26320. /**
  26321. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26322. */
  26323. export class PoseEnabledControllerHelper {
  26324. /** @hidden */
  26325. static _ControllerFactories: _GamePadFactory[];
  26326. /** @hidden */
  26327. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  26328. /**
  26329. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26330. * @param vrGamepad the gamepad to initialized
  26331. * @returns a vr controller of the type the gamepad identified as
  26332. */
  26333. static InitiateController(vrGamepad: any): Gamepad;
  26334. }
  26335. /**
  26336. * Defines the PoseEnabledController object that contains state of a vr capable controller
  26337. */
  26338. export class PoseEnabledController extends Gamepad implements PoseControlled {
  26339. /**
  26340. * If the controller is used in a webXR session
  26341. */
  26342. isXR: boolean;
  26343. private _deviceRoomPosition;
  26344. private _deviceRoomRotationQuaternion;
  26345. /**
  26346. * The device position in babylon space
  26347. */
  26348. devicePosition: Vector3;
  26349. /**
  26350. * The device rotation in babylon space
  26351. */
  26352. deviceRotationQuaternion: Quaternion;
  26353. /**
  26354. * The scale factor of the device in babylon space
  26355. */
  26356. deviceScaleFactor: number;
  26357. /**
  26358. * (Likely devicePosition should be used instead) The device position in its room space
  26359. */
  26360. position: Vector3;
  26361. /**
  26362. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  26363. */
  26364. rotationQuaternion: Quaternion;
  26365. /**
  26366. * The type of controller (Eg. Windows mixed reality)
  26367. */
  26368. controllerType: PoseEnabledControllerType;
  26369. protected _calculatedPosition: Vector3;
  26370. private _calculatedRotation;
  26371. /**
  26372. * The raw pose from the device
  26373. */
  26374. rawPose: DevicePose;
  26375. private _trackPosition;
  26376. private _maxRotationDistFromHeadset;
  26377. private _draggedRoomRotation;
  26378. /**
  26379. * @hidden
  26380. */
  26381. _disableTrackPosition(fixedPosition: Vector3): void;
  26382. /**
  26383. * Internal, the mesh attached to the controller
  26384. * @hidden
  26385. */
  26386. _mesh: Nullable<AbstractMesh>;
  26387. private _poseControlledCamera;
  26388. private _leftHandSystemQuaternion;
  26389. /**
  26390. * Internal, matrix used to convert room space to babylon space
  26391. * @hidden
  26392. */
  26393. _deviceToWorld: Matrix;
  26394. /**
  26395. * Node to be used when casting a ray from the controller
  26396. * @hidden
  26397. */
  26398. _pointingPoseNode: Nullable<TransformNode>;
  26399. /**
  26400. * Name of the child mesh that can be used to cast a ray from the controller
  26401. */
  26402. static readonly POINTING_POSE: string;
  26403. /**
  26404. * Creates a new PoseEnabledController from a gamepad
  26405. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  26406. */
  26407. constructor(browserGamepad: any);
  26408. private _workingMatrix;
  26409. /**
  26410. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  26411. */
  26412. update(): void;
  26413. /**
  26414. * Updates only the pose device and mesh without doing any button event checking
  26415. */
  26416. protected _updatePoseAndMesh(): void;
  26417. /**
  26418. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  26419. * @param poseData raw pose fromthe device
  26420. */
  26421. updateFromDevice(poseData: DevicePose): void;
  26422. /**
  26423. * @hidden
  26424. */
  26425. _meshAttachedObservable: Observable<AbstractMesh>;
  26426. /**
  26427. * Attaches a mesh to the controller
  26428. * @param mesh the mesh to be attached
  26429. */
  26430. attachToMesh(mesh: AbstractMesh): void;
  26431. /**
  26432. * Attaches the controllers mesh to a camera
  26433. * @param camera the camera the mesh should be attached to
  26434. */
  26435. attachToPoseControlledCamera(camera: TargetCamera): void;
  26436. /**
  26437. * Disposes of the controller
  26438. */
  26439. dispose(): void;
  26440. /**
  26441. * The mesh that is attached to the controller
  26442. */
  26443. get mesh(): Nullable<AbstractMesh>;
  26444. /**
  26445. * Gets the ray of the controller in the direction the controller is pointing
  26446. * @param length the length the resulting ray should be
  26447. * @returns a ray in the direction the controller is pointing
  26448. */
  26449. getForwardRay(length?: number): Ray;
  26450. }
  26451. }
  26452. declare module BABYLON {
  26453. /**
  26454. * Defines the WebVRController object that represents controllers tracked in 3D space
  26455. */
  26456. export abstract class WebVRController extends PoseEnabledController {
  26457. /**
  26458. * Internal, the default controller model for the controller
  26459. */
  26460. protected _defaultModel: Nullable<AbstractMesh>;
  26461. /**
  26462. * Fired when the trigger state has changed
  26463. */
  26464. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  26465. /**
  26466. * Fired when the main button state has changed
  26467. */
  26468. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26469. /**
  26470. * Fired when the secondary button state has changed
  26471. */
  26472. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26473. /**
  26474. * Fired when the pad state has changed
  26475. */
  26476. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  26477. /**
  26478. * Fired when controllers stick values have changed
  26479. */
  26480. onPadValuesChangedObservable: Observable<StickValues>;
  26481. /**
  26482. * Array of button availible on the controller
  26483. */
  26484. protected _buttons: Array<MutableGamepadButton>;
  26485. private _onButtonStateChange;
  26486. /**
  26487. * Fired when a controller button's state has changed
  26488. * @param callback the callback containing the button that was modified
  26489. */
  26490. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  26491. /**
  26492. * X and Y axis corresponding to the controllers joystick
  26493. */
  26494. pad: StickValues;
  26495. /**
  26496. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  26497. */
  26498. hand: string;
  26499. /**
  26500. * The default controller model for the controller
  26501. */
  26502. get defaultModel(): Nullable<AbstractMesh>;
  26503. /**
  26504. * Creates a new WebVRController from a gamepad
  26505. * @param vrGamepad the gamepad that the WebVRController should be created from
  26506. */
  26507. constructor(vrGamepad: any);
  26508. /**
  26509. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  26510. */
  26511. update(): void;
  26512. /**
  26513. * Function to be called when a button is modified
  26514. */
  26515. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26516. /**
  26517. * Loads a mesh and attaches it to the controller
  26518. * @param scene the scene the mesh should be added to
  26519. * @param meshLoaded callback for when the mesh has been loaded
  26520. */
  26521. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26522. private _setButtonValue;
  26523. private _changes;
  26524. private _checkChanges;
  26525. /**
  26526. * Disposes of th webVRCOntroller
  26527. */
  26528. dispose(): void;
  26529. }
  26530. }
  26531. declare module BABYLON {
  26532. /**
  26533. * The HemisphericLight simulates the ambient environment light,
  26534. * so the passed direction is the light reflection direction, not the incoming direction.
  26535. */
  26536. export class HemisphericLight extends Light {
  26537. /**
  26538. * The groundColor is the light in the opposite direction to the one specified during creation.
  26539. * 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.
  26540. */
  26541. groundColor: Color3;
  26542. /**
  26543. * The light reflection direction, not the incoming direction.
  26544. */
  26545. direction: Vector3;
  26546. /**
  26547. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  26548. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  26549. * The HemisphericLight can't cast shadows.
  26550. * Documentation : https://doc.babylonjs.com/babylon101/lights
  26551. * @param name The friendly name of the light
  26552. * @param direction The direction of the light reflection
  26553. * @param scene The scene the light belongs to
  26554. */
  26555. constructor(name: string, direction: Vector3, scene: Scene);
  26556. protected _buildUniformLayout(): void;
  26557. /**
  26558. * Returns the string "HemisphericLight".
  26559. * @return The class name
  26560. */
  26561. getClassName(): string;
  26562. /**
  26563. * Sets the HemisphericLight direction towards the passed target (Vector3).
  26564. * Returns the updated direction.
  26565. * @param target The target the direction should point to
  26566. * @return The computed direction
  26567. */
  26568. setDirectionToTarget(target: Vector3): Vector3;
  26569. /**
  26570. * Returns the shadow generator associated to the light.
  26571. * @returns Always null for hemispheric lights because it does not support shadows.
  26572. */
  26573. getShadowGenerator(): Nullable<IShadowGenerator>;
  26574. /**
  26575. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  26576. * @param effect The effect to update
  26577. * @param lightIndex The index of the light in the effect to update
  26578. * @returns The hemispheric light
  26579. */
  26580. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  26581. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  26582. /**
  26583. * Computes the world matrix of the node
  26584. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26585. * @param useWasUpdatedFlag defines a reserved property
  26586. * @returns the world matrix
  26587. */
  26588. computeWorldMatrix(): Matrix;
  26589. /**
  26590. * Returns the integer 3.
  26591. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  26592. */
  26593. getTypeID(): number;
  26594. /**
  26595. * Prepares the list of defines specific to the light type.
  26596. * @param defines the list of defines
  26597. * @param lightIndex defines the index of the light for the effect
  26598. */
  26599. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  26600. }
  26601. }
  26602. declare module BABYLON {
  26603. /** @hidden */
  26604. export var vrMultiviewToSingleviewPixelShader: {
  26605. name: string;
  26606. shader: string;
  26607. };
  26608. }
  26609. declare module BABYLON {
  26610. /**
  26611. * Renders to multiple views with a single draw call
  26612. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  26613. */
  26614. export class MultiviewRenderTarget extends RenderTargetTexture {
  26615. /**
  26616. * Creates a multiview render target
  26617. * @param scene scene used with the render target
  26618. * @param size the size of the render target (used for each view)
  26619. */
  26620. constructor(scene: Scene, size?: number | {
  26621. width: number;
  26622. height: number;
  26623. } | {
  26624. ratio: number;
  26625. });
  26626. /**
  26627. * @hidden
  26628. * @param faceIndex the face index, if its a cube texture
  26629. */
  26630. _bindFrameBuffer(faceIndex?: number): void;
  26631. /**
  26632. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  26633. * @returns the view count
  26634. */
  26635. getViewCount(): number;
  26636. }
  26637. }
  26638. declare module BABYLON {
  26639. interface Engine {
  26640. /**
  26641. * Creates a new multiview render target
  26642. * @param width defines the width of the texture
  26643. * @param height defines the height of the texture
  26644. * @returns the created multiview texture
  26645. */
  26646. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  26647. /**
  26648. * Binds a multiview framebuffer to be drawn to
  26649. * @param multiviewTexture texture to bind
  26650. */
  26651. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  26652. }
  26653. interface Camera {
  26654. /**
  26655. * @hidden
  26656. * 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)
  26657. */
  26658. _useMultiviewToSingleView: boolean;
  26659. /**
  26660. * @hidden
  26661. * 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)
  26662. */
  26663. _multiviewTexture: Nullable<RenderTargetTexture>;
  26664. /**
  26665. * @hidden
  26666. * ensures the multiview texture of the camera exists and has the specified width/height
  26667. * @param width height to set on the multiview texture
  26668. * @param height width to set on the multiview texture
  26669. */
  26670. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  26671. }
  26672. interface Scene {
  26673. /** @hidden */
  26674. _transformMatrixR: Matrix;
  26675. /** @hidden */
  26676. _multiviewSceneUbo: Nullable<UniformBuffer>;
  26677. /** @hidden */
  26678. _createMultiviewUbo(): void;
  26679. /** @hidden */
  26680. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  26681. /** @hidden */
  26682. _renderMultiviewToSingleView(camera: Camera): void;
  26683. }
  26684. }
  26685. declare module BABYLON {
  26686. /**
  26687. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  26688. * This will not be used for webXR as it supports displaying texture arrays directly
  26689. */
  26690. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  26691. /**
  26692. * Gets a string identifying the name of the class
  26693. * @returns "VRMultiviewToSingleviewPostProcess" string
  26694. */
  26695. getClassName(): string;
  26696. /**
  26697. * Initializes a VRMultiviewToSingleview
  26698. * @param name name of the post process
  26699. * @param camera camera to be applied to
  26700. * @param scaleFactor scaling factor to the size of the output texture
  26701. */
  26702. constructor(name: string, camera: Camera, scaleFactor: number);
  26703. }
  26704. }
  26705. declare module BABYLON {
  26706. /**
  26707. * Interface used to define additional presentation attributes
  26708. */
  26709. export interface IVRPresentationAttributes {
  26710. /**
  26711. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  26712. */
  26713. highRefreshRate: boolean;
  26714. /**
  26715. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  26716. */
  26717. foveationLevel: number;
  26718. }
  26719. interface Engine {
  26720. /** @hidden */
  26721. _vrDisplay: any;
  26722. /** @hidden */
  26723. _vrSupported: boolean;
  26724. /** @hidden */
  26725. _oldSize: Size;
  26726. /** @hidden */
  26727. _oldHardwareScaleFactor: number;
  26728. /** @hidden */
  26729. _vrExclusivePointerMode: boolean;
  26730. /** @hidden */
  26731. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  26732. /** @hidden */
  26733. _onVRDisplayPointerRestricted: () => void;
  26734. /** @hidden */
  26735. _onVRDisplayPointerUnrestricted: () => void;
  26736. /** @hidden */
  26737. _onVrDisplayConnect: Nullable<(display: any) => void>;
  26738. /** @hidden */
  26739. _onVrDisplayDisconnect: Nullable<() => void>;
  26740. /** @hidden */
  26741. _onVrDisplayPresentChange: Nullable<() => void>;
  26742. /**
  26743. * Observable signaled when VR display mode changes
  26744. */
  26745. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26746. /**
  26747. * Observable signaled when VR request present is complete
  26748. */
  26749. onVRRequestPresentComplete: Observable<boolean>;
  26750. /**
  26751. * Observable signaled when VR request present starts
  26752. */
  26753. onVRRequestPresentStart: Observable<Engine>;
  26754. /**
  26755. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26756. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26757. */
  26758. isInVRExclusivePointerMode: boolean;
  26759. /**
  26760. * Gets a boolean indicating if a webVR device was detected
  26761. * @returns true if a webVR device was detected
  26762. */
  26763. isVRDevicePresent(): boolean;
  26764. /**
  26765. * Gets the current webVR device
  26766. * @returns the current webVR device (or null)
  26767. */
  26768. getVRDevice(): any;
  26769. /**
  26770. * Initializes a webVR display and starts listening to display change events
  26771. * The onVRDisplayChangedObservable will be notified upon these changes
  26772. * @returns A promise containing a VRDisplay and if vr is supported
  26773. */
  26774. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  26775. /** @hidden */
  26776. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  26777. /**
  26778. * Gets or sets the presentation attributes used to configure VR rendering
  26779. */
  26780. vrPresentationAttributes?: IVRPresentationAttributes;
  26781. /**
  26782. * Call this function to switch to webVR mode
  26783. * Will do nothing if webVR is not supported or if there is no webVR device
  26784. * @param options the webvr options provided to the camera. mainly used for multiview
  26785. * @see https://doc.babylonjs.com/how_to/webvr_camera
  26786. */
  26787. enableVR(options: WebVROptions): void;
  26788. /** @hidden */
  26789. _onVRFullScreenTriggered(): void;
  26790. }
  26791. }
  26792. declare module BABYLON {
  26793. /**
  26794. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  26795. * IMPORTANT!! The data is right-hand data.
  26796. * @export
  26797. * @interface DevicePose
  26798. */
  26799. export interface DevicePose {
  26800. /**
  26801. * The position of the device, values in array are [x,y,z].
  26802. */
  26803. readonly position: Nullable<Float32Array>;
  26804. /**
  26805. * The linearVelocity of the device, values in array are [x,y,z].
  26806. */
  26807. readonly linearVelocity: Nullable<Float32Array>;
  26808. /**
  26809. * The linearAcceleration of the device, values in array are [x,y,z].
  26810. */
  26811. readonly linearAcceleration: Nullable<Float32Array>;
  26812. /**
  26813. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  26814. */
  26815. readonly orientation: Nullable<Float32Array>;
  26816. /**
  26817. * The angularVelocity of the device, values in array are [x,y,z].
  26818. */
  26819. readonly angularVelocity: Nullable<Float32Array>;
  26820. /**
  26821. * The angularAcceleration of the device, values in array are [x,y,z].
  26822. */
  26823. readonly angularAcceleration: Nullable<Float32Array>;
  26824. }
  26825. /**
  26826. * Interface representing a pose controlled object in Babylon.
  26827. * A pose controlled object has both regular pose values as well as pose values
  26828. * from an external device such as a VR head mounted display
  26829. */
  26830. export interface PoseControlled {
  26831. /**
  26832. * The position of the object in babylon space.
  26833. */
  26834. position: Vector3;
  26835. /**
  26836. * The rotation quaternion of the object in babylon space.
  26837. */
  26838. rotationQuaternion: Quaternion;
  26839. /**
  26840. * The position of the device in babylon space.
  26841. */
  26842. devicePosition?: Vector3;
  26843. /**
  26844. * The rotation quaternion of the device in babylon space.
  26845. */
  26846. deviceRotationQuaternion: Quaternion;
  26847. /**
  26848. * The raw pose coming from the device.
  26849. */
  26850. rawPose: Nullable<DevicePose>;
  26851. /**
  26852. * The scale of the device to be used when translating from device space to babylon space.
  26853. */
  26854. deviceScaleFactor: number;
  26855. /**
  26856. * Updates the poseControlled values based on the input device pose.
  26857. * @param poseData the pose data to update the object with
  26858. */
  26859. updateFromDevice(poseData: DevicePose): void;
  26860. }
  26861. /**
  26862. * Set of options to customize the webVRCamera
  26863. */
  26864. export interface WebVROptions {
  26865. /**
  26866. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  26867. */
  26868. trackPosition?: boolean;
  26869. /**
  26870. * Sets the scale of the vrDevice in babylon space. (default: 1)
  26871. */
  26872. positionScale?: number;
  26873. /**
  26874. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  26875. */
  26876. displayName?: string;
  26877. /**
  26878. * Should the native controller meshes be initialized. (default: true)
  26879. */
  26880. controllerMeshes?: boolean;
  26881. /**
  26882. * Creating a default HemiLight only on controllers. (default: true)
  26883. */
  26884. defaultLightingOnControllers?: boolean;
  26885. /**
  26886. * If you don't want to use the default VR button of the helper. (default: false)
  26887. */
  26888. useCustomVRButton?: boolean;
  26889. /**
  26890. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  26891. */
  26892. customVRButton?: HTMLButtonElement;
  26893. /**
  26894. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  26895. */
  26896. rayLength?: number;
  26897. /**
  26898. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  26899. */
  26900. defaultHeight?: number;
  26901. /**
  26902. * If multiview should be used if availible (default: false)
  26903. */
  26904. useMultiview?: boolean;
  26905. }
  26906. /**
  26907. * This represents a WebVR camera.
  26908. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  26909. * @example https://doc.babylonjs.com/how_to/webvr_camera
  26910. */
  26911. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  26912. private webVROptions;
  26913. /**
  26914. * @hidden
  26915. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  26916. */
  26917. _vrDevice: any;
  26918. /**
  26919. * The rawPose of the vrDevice.
  26920. */
  26921. rawPose: Nullable<DevicePose>;
  26922. private _onVREnabled;
  26923. private _specsVersion;
  26924. private _attached;
  26925. private _frameData;
  26926. protected _descendants: Array<Node>;
  26927. private _deviceRoomPosition;
  26928. /** @hidden */
  26929. _deviceRoomRotationQuaternion: Quaternion;
  26930. private _standingMatrix;
  26931. /**
  26932. * Represents device position in babylon space.
  26933. */
  26934. devicePosition: Vector3;
  26935. /**
  26936. * Represents device rotation in babylon space.
  26937. */
  26938. deviceRotationQuaternion: Quaternion;
  26939. /**
  26940. * The scale of the device to be used when translating from device space to babylon space.
  26941. */
  26942. deviceScaleFactor: number;
  26943. private _deviceToWorld;
  26944. private _worldToDevice;
  26945. /**
  26946. * References to the webVR controllers for the vrDevice.
  26947. */
  26948. controllers: Array<WebVRController>;
  26949. /**
  26950. * Emits an event when a controller is attached.
  26951. */
  26952. onControllersAttachedObservable: Observable<WebVRController[]>;
  26953. /**
  26954. * Emits an event when a controller's mesh has been loaded;
  26955. */
  26956. onControllerMeshLoadedObservable: Observable<WebVRController>;
  26957. /**
  26958. * Emits an event when the HMD's pose has been updated.
  26959. */
  26960. onPoseUpdatedFromDeviceObservable: Observable<any>;
  26961. private _poseSet;
  26962. /**
  26963. * If the rig cameras be used as parent instead of this camera.
  26964. */
  26965. rigParenting: boolean;
  26966. private _lightOnControllers;
  26967. private _defaultHeight?;
  26968. /**
  26969. * Instantiates a WebVRFreeCamera.
  26970. * @param name The name of the WebVRFreeCamera
  26971. * @param position The starting anchor position for the camera
  26972. * @param scene The scene the camera belongs to
  26973. * @param webVROptions a set of customizable options for the webVRCamera
  26974. */
  26975. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  26976. /**
  26977. * Gets the device distance from the ground in meters.
  26978. * @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.
  26979. */
  26980. deviceDistanceToRoomGround(): number;
  26981. /**
  26982. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  26983. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  26984. */
  26985. useStandingMatrix(callback?: (bool: boolean) => void): void;
  26986. /**
  26987. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  26988. * @returns A promise with a boolean set to if the standing matrix is supported.
  26989. */
  26990. useStandingMatrixAsync(): Promise<boolean>;
  26991. /**
  26992. * Disposes the camera
  26993. */
  26994. dispose(): void;
  26995. /**
  26996. * Gets a vrController by name.
  26997. * @param name The name of the controller to retreive
  26998. * @returns the controller matching the name specified or null if not found
  26999. */
  27000. getControllerByName(name: string): Nullable<WebVRController>;
  27001. private _leftController;
  27002. /**
  27003. * The controller corresponding to the users left hand.
  27004. */
  27005. get leftController(): Nullable<WebVRController>;
  27006. private _rightController;
  27007. /**
  27008. * The controller corresponding to the users right hand.
  27009. */
  27010. get rightController(): Nullable<WebVRController>;
  27011. /**
  27012. * Casts a ray forward from the vrCamera's gaze.
  27013. * @param length Length of the ray (default: 100)
  27014. * @returns the ray corresponding to the gaze
  27015. */
  27016. getForwardRay(length?: number): Ray;
  27017. /**
  27018. * @hidden
  27019. * Updates the camera based on device's frame data
  27020. */
  27021. _checkInputs(): void;
  27022. /**
  27023. * Updates the poseControlled values based on the input device pose.
  27024. * @param poseData Pose coming from the device
  27025. */
  27026. updateFromDevice(poseData: DevicePose): void;
  27027. private _detachIfAttached;
  27028. /**
  27029. * WebVR's attach control will start broadcasting frames to the device.
  27030. * Note that in certain browsers (chrome for example) this function must be called
  27031. * within a user-interaction callback. Example:
  27032. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27033. *
  27034. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27035. */
  27036. attachControl(noPreventDefault?: boolean): void;
  27037. /**
  27038. * Detach the current controls from the specified dom element.
  27039. */
  27040. detachControl(): void;
  27041. /**
  27042. * @returns the name of this class
  27043. */
  27044. getClassName(): string;
  27045. /**
  27046. * Calls resetPose on the vrDisplay
  27047. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27048. */
  27049. resetToCurrentRotation(): void;
  27050. /**
  27051. * @hidden
  27052. * Updates the rig cameras (left and right eye)
  27053. */
  27054. _updateRigCameras(): void;
  27055. private _workingVector;
  27056. private _oneVector;
  27057. private _workingMatrix;
  27058. private updateCacheCalled;
  27059. private _correctPositionIfNotTrackPosition;
  27060. /**
  27061. * @hidden
  27062. * Updates the cached values of the camera
  27063. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27064. */
  27065. _updateCache(ignoreParentClass?: boolean): void;
  27066. /**
  27067. * @hidden
  27068. * Get current device position in babylon world
  27069. */
  27070. _computeDevicePosition(): void;
  27071. /**
  27072. * Updates the current device position and rotation in the babylon world
  27073. */
  27074. update(): void;
  27075. /**
  27076. * @hidden
  27077. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27078. * @returns an identity matrix
  27079. */
  27080. _getViewMatrix(): Matrix;
  27081. private _tmpMatrix;
  27082. /**
  27083. * This function is called by the two RIG cameras.
  27084. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27085. * @hidden
  27086. */
  27087. _getWebVRViewMatrix(): Matrix;
  27088. /** @hidden */
  27089. _getWebVRProjectionMatrix(): Matrix;
  27090. private _onGamepadConnectedObserver;
  27091. private _onGamepadDisconnectedObserver;
  27092. private _updateCacheWhenTrackingDisabledObserver;
  27093. /**
  27094. * Initializes the controllers and their meshes
  27095. */
  27096. initControllers(): void;
  27097. }
  27098. }
  27099. declare module BABYLON {
  27100. /**
  27101. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27102. *
  27103. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27104. *
  27105. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27106. */
  27107. export class MaterialHelper {
  27108. /**
  27109. * Bind the current view position to an effect.
  27110. * @param effect The effect to be bound
  27111. * @param scene The scene the eyes position is used from
  27112. * @param variableName name of the shader variable that will hold the eye position
  27113. */
  27114. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  27115. /**
  27116. * Helps preparing the defines values about the UVs in used in the effect.
  27117. * UVs are shared as much as we can accross channels in the shaders.
  27118. * @param texture The texture we are preparing the UVs for
  27119. * @param defines The defines to update
  27120. * @param key The channel key "diffuse", "specular"... used in the shader
  27121. */
  27122. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27123. /**
  27124. * Binds a texture matrix value to its corrsponding uniform
  27125. * @param texture The texture to bind the matrix for
  27126. * @param uniformBuffer The uniform buffer receivin the data
  27127. * @param key The channel key "diffuse", "specular"... used in the shader
  27128. */
  27129. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27130. /**
  27131. * Gets the current status of the fog (should it be enabled?)
  27132. * @param mesh defines the mesh to evaluate for fog support
  27133. * @param scene defines the hosting scene
  27134. * @returns true if fog must be enabled
  27135. */
  27136. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27137. /**
  27138. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27139. * @param mesh defines the current mesh
  27140. * @param scene defines the current scene
  27141. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27142. * @param pointsCloud defines if point cloud rendering has to be turned on
  27143. * @param fogEnabled defines if fog has to be turned on
  27144. * @param alphaTest defines if alpha testing has to be turned on
  27145. * @param defines defines the current list of defines
  27146. */
  27147. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27148. /**
  27149. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27150. * @param scene defines the current scene
  27151. * @param engine defines the current engine
  27152. * @param defines specifies the list of active defines
  27153. * @param useInstances defines if instances have to be turned on
  27154. * @param useClipPlane defines if clip plane have to be turned on
  27155. * @param useInstances defines if instances have to be turned on
  27156. * @param useThinInstances defines if thin instances have to be turned on
  27157. */
  27158. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27159. /**
  27160. * Prepares the defines for bones
  27161. * @param mesh The mesh containing the geometry data we will draw
  27162. * @param defines The defines to update
  27163. */
  27164. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27165. /**
  27166. * Prepares the defines for morph targets
  27167. * @param mesh The mesh containing the geometry data we will draw
  27168. * @param defines The defines to update
  27169. */
  27170. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27171. /**
  27172. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27173. * @param mesh The mesh containing the geometry data we will draw
  27174. * @param defines The defines to update
  27175. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27176. * @param useBones Precise whether bones should be used or not (override mesh info)
  27177. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27178. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27179. * @returns false if defines are considered not dirty and have not been checked
  27180. */
  27181. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27182. /**
  27183. * Prepares the defines related to multiview
  27184. * @param scene The scene we are intending to draw
  27185. * @param defines The defines to update
  27186. */
  27187. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27188. /**
  27189. * Prepares the defines related to the prepass
  27190. * @param scene The scene we are intending to draw
  27191. * @param defines The defines to update
  27192. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27193. */
  27194. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27195. /**
  27196. * Prepares the defines related to the light information passed in parameter
  27197. * @param scene The scene we are intending to draw
  27198. * @param mesh The mesh the effect is compiling for
  27199. * @param light The light the effect is compiling for
  27200. * @param lightIndex The index of the light
  27201. * @param defines The defines to update
  27202. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27203. * @param state Defines the current state regarding what is needed (normals, etc...)
  27204. */
  27205. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  27206. needNormals: boolean;
  27207. needRebuild: boolean;
  27208. shadowEnabled: boolean;
  27209. specularEnabled: boolean;
  27210. lightmapMode: boolean;
  27211. }): void;
  27212. /**
  27213. * Prepares the defines related to the light information passed in parameter
  27214. * @param scene The scene we are intending to draw
  27215. * @param mesh The mesh the effect is compiling for
  27216. * @param defines The defines to update
  27217. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27218. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  27219. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  27220. * @returns true if normals will be required for the rest of the effect
  27221. */
  27222. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  27223. /**
  27224. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  27225. * @param lightIndex defines the light index
  27226. * @param uniformsList The uniform list
  27227. * @param samplersList The sampler list
  27228. * @param projectedLightTexture defines if projected texture must be used
  27229. * @param uniformBuffersList defines an optional list of uniform buffers
  27230. */
  27231. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  27232. /**
  27233. * Prepares the uniforms and samplers list to be used in the effect
  27234. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  27235. * @param samplersList The sampler list
  27236. * @param defines The defines helping in the list generation
  27237. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  27238. */
  27239. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  27240. /**
  27241. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  27242. * @param defines The defines to update while falling back
  27243. * @param fallbacks The authorized effect fallbacks
  27244. * @param maxSimultaneousLights The maximum number of lights allowed
  27245. * @param rank the current rank of the Effect
  27246. * @returns The newly affected rank
  27247. */
  27248. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  27249. private static _TmpMorphInfluencers;
  27250. /**
  27251. * Prepares the list of attributes required for morph targets according to the effect defines.
  27252. * @param attribs The current list of supported attribs
  27253. * @param mesh The mesh to prepare the morph targets attributes for
  27254. * @param influencers The number of influencers
  27255. */
  27256. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  27257. /**
  27258. * Prepares the list of attributes required for morph targets according to the effect defines.
  27259. * @param attribs The current list of supported attribs
  27260. * @param mesh The mesh to prepare the morph targets attributes for
  27261. * @param defines The current Defines of the effect
  27262. */
  27263. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  27264. /**
  27265. * Prepares the list of attributes required for bones according to the effect defines.
  27266. * @param attribs The current list of supported attribs
  27267. * @param mesh The mesh to prepare the bones attributes for
  27268. * @param defines The current Defines of the effect
  27269. * @param fallbacks The current efffect fallback strategy
  27270. */
  27271. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  27272. /**
  27273. * Check and prepare the list of attributes required for instances according to the effect defines.
  27274. * @param attribs The current list of supported attribs
  27275. * @param defines The current MaterialDefines of the effect
  27276. */
  27277. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  27278. /**
  27279. * Add the list of attributes required for instances to the attribs array.
  27280. * @param attribs The current list of supported attribs
  27281. */
  27282. static PushAttributesForInstances(attribs: string[]): void;
  27283. /**
  27284. * Binds the light information to the effect.
  27285. * @param light The light containing the generator
  27286. * @param effect The effect we are binding the data to
  27287. * @param lightIndex The light index in the effect used to render
  27288. */
  27289. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  27290. /**
  27291. * Binds the lights information from the scene to the effect for the given mesh.
  27292. * @param light Light to bind
  27293. * @param lightIndex Light index
  27294. * @param scene The scene where the light belongs to
  27295. * @param effect The effect we are binding the data to
  27296. * @param useSpecular Defines if specular is supported
  27297. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27298. */
  27299. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  27300. /**
  27301. * Binds the lights information from the scene to the effect for the given mesh.
  27302. * @param scene The scene the lights belongs to
  27303. * @param mesh The mesh we are binding the information to render
  27304. * @param effect The effect we are binding the data to
  27305. * @param defines The generated defines for the effect
  27306. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  27307. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27308. */
  27309. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  27310. private static _tempFogColor;
  27311. /**
  27312. * Binds the fog information from the scene to the effect for the given mesh.
  27313. * @param scene The scene the lights belongs to
  27314. * @param mesh The mesh we are binding the information to render
  27315. * @param effect The effect we are binding the data to
  27316. * @param linearSpace Defines if the fog effect is applied in linear space
  27317. */
  27318. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  27319. /**
  27320. * Binds the bones information from the mesh to the effect.
  27321. * @param mesh The mesh we are binding the information to render
  27322. * @param effect The effect we are binding the data to
  27323. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  27324. */
  27325. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  27326. private static _CopyBonesTransformationMatrices;
  27327. /**
  27328. * Binds the morph targets information from the mesh to the effect.
  27329. * @param abstractMesh The mesh we are binding the information to render
  27330. * @param effect The effect we are binding the data to
  27331. */
  27332. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  27333. /**
  27334. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  27335. * @param defines The generated defines used in the effect
  27336. * @param effect The effect we are binding the data to
  27337. * @param scene The scene we are willing to render with logarithmic scale for
  27338. */
  27339. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  27340. /**
  27341. * Binds the clip plane information from the scene to the effect.
  27342. * @param scene The scene the clip plane information are extracted from
  27343. * @param effect The effect we are binding the data to
  27344. */
  27345. static BindClipPlane(effect: Effect, scene: Scene): void;
  27346. }
  27347. }
  27348. declare module BABYLON {
  27349. /** @hidden */
  27350. export var bayerDitherFunctions: {
  27351. name: string;
  27352. shader: string;
  27353. };
  27354. }
  27355. declare module BABYLON {
  27356. /** @hidden */
  27357. export var shadowMapFragmentDeclaration: {
  27358. name: string;
  27359. shader: string;
  27360. };
  27361. }
  27362. declare module BABYLON {
  27363. /** @hidden */
  27364. export var shadowMapFragment: {
  27365. name: string;
  27366. shader: string;
  27367. };
  27368. }
  27369. declare module BABYLON {
  27370. /** @hidden */
  27371. export var shadowMapPixelShader: {
  27372. name: string;
  27373. shader: string;
  27374. };
  27375. }
  27376. declare module BABYLON {
  27377. /** @hidden */
  27378. export var shadowMapVertexDeclaration: {
  27379. name: string;
  27380. shader: string;
  27381. };
  27382. }
  27383. declare module BABYLON {
  27384. /** @hidden */
  27385. export var shadowMapVertexNormalBias: {
  27386. name: string;
  27387. shader: string;
  27388. };
  27389. }
  27390. declare module BABYLON {
  27391. /** @hidden */
  27392. export var shadowMapVertexMetric: {
  27393. name: string;
  27394. shader: string;
  27395. };
  27396. }
  27397. declare module BABYLON {
  27398. /** @hidden */
  27399. export var shadowMapVertexShader: {
  27400. name: string;
  27401. shader: string;
  27402. };
  27403. }
  27404. declare module BABYLON {
  27405. /** @hidden */
  27406. export var depthBoxBlurPixelShader: {
  27407. name: string;
  27408. shader: string;
  27409. };
  27410. }
  27411. declare module BABYLON {
  27412. /** @hidden */
  27413. export var shadowMapFragmentSoftTransparentShadow: {
  27414. name: string;
  27415. shader: string;
  27416. };
  27417. }
  27418. declare module BABYLON {
  27419. /**
  27420. * Creates an instance based on a source mesh.
  27421. */
  27422. export class InstancedMesh extends AbstractMesh {
  27423. private _sourceMesh;
  27424. private _currentLOD;
  27425. /** @hidden */
  27426. _indexInSourceMeshInstanceArray: number;
  27427. constructor(name: string, source: Mesh);
  27428. /**
  27429. * Returns the string "InstancedMesh".
  27430. */
  27431. getClassName(): string;
  27432. /** Gets the list of lights affecting that mesh */
  27433. get lightSources(): Light[];
  27434. _resyncLightSources(): void;
  27435. _resyncLightSource(light: Light): void;
  27436. _removeLightSource(light: Light, dispose: boolean): void;
  27437. /**
  27438. * If the source mesh receives shadows
  27439. */
  27440. get receiveShadows(): boolean;
  27441. /**
  27442. * The material of the source mesh
  27443. */
  27444. get material(): Nullable<Material>;
  27445. /**
  27446. * Visibility of the source mesh
  27447. */
  27448. get visibility(): number;
  27449. /**
  27450. * Skeleton of the source mesh
  27451. */
  27452. get skeleton(): Nullable<Skeleton>;
  27453. /**
  27454. * Rendering ground id of the source mesh
  27455. */
  27456. get renderingGroupId(): number;
  27457. set renderingGroupId(value: number);
  27458. /**
  27459. * Returns the total number of vertices (integer).
  27460. */
  27461. getTotalVertices(): number;
  27462. /**
  27463. * Returns a positive integer : the total number of indices in this mesh geometry.
  27464. * @returns the numner of indices or zero if the mesh has no geometry.
  27465. */
  27466. getTotalIndices(): number;
  27467. /**
  27468. * The source mesh of the instance
  27469. */
  27470. get sourceMesh(): Mesh;
  27471. /**
  27472. * Creates a new InstancedMesh object from the mesh model.
  27473. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27474. * @param name defines the name of the new instance
  27475. * @returns a new InstancedMesh
  27476. */
  27477. createInstance(name: string): InstancedMesh;
  27478. /**
  27479. * Is this node ready to be used/rendered
  27480. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27481. * @return {boolean} is it ready
  27482. */
  27483. isReady(completeCheck?: boolean): boolean;
  27484. /**
  27485. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27486. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  27487. * @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.
  27488. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  27489. */
  27490. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  27491. /**
  27492. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27493. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27494. * The `data` are either a numeric array either a Float32Array.
  27495. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  27496. * 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).
  27497. * Note that a new underlying VertexBuffer object is created each call.
  27498. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27499. *
  27500. * Possible `kind` values :
  27501. * - VertexBuffer.PositionKind
  27502. * - VertexBuffer.UVKind
  27503. * - VertexBuffer.UV2Kind
  27504. * - VertexBuffer.UV3Kind
  27505. * - VertexBuffer.UV4Kind
  27506. * - VertexBuffer.UV5Kind
  27507. * - VertexBuffer.UV6Kind
  27508. * - VertexBuffer.ColorKind
  27509. * - VertexBuffer.MatricesIndicesKind
  27510. * - VertexBuffer.MatricesIndicesExtraKind
  27511. * - VertexBuffer.MatricesWeightsKind
  27512. * - VertexBuffer.MatricesWeightsExtraKind
  27513. *
  27514. * Returns the Mesh.
  27515. */
  27516. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27517. /**
  27518. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27519. * If the mesh has no geometry, it is simply returned as it is.
  27520. * The `data` are either a numeric array either a Float32Array.
  27521. * No new underlying VertexBuffer object is created.
  27522. * 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.
  27523. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  27524. *
  27525. * Possible `kind` values :
  27526. * - VertexBuffer.PositionKind
  27527. * - VertexBuffer.UVKind
  27528. * - VertexBuffer.UV2Kind
  27529. * - VertexBuffer.UV3Kind
  27530. * - VertexBuffer.UV4Kind
  27531. * - VertexBuffer.UV5Kind
  27532. * - VertexBuffer.UV6Kind
  27533. * - VertexBuffer.ColorKind
  27534. * - VertexBuffer.MatricesIndicesKind
  27535. * - VertexBuffer.MatricesIndicesExtraKind
  27536. * - VertexBuffer.MatricesWeightsKind
  27537. * - VertexBuffer.MatricesWeightsExtraKind
  27538. *
  27539. * Returns the Mesh.
  27540. */
  27541. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27542. /**
  27543. * Sets the mesh indices.
  27544. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  27545. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27546. * This method creates a new index buffer each call.
  27547. * Returns the Mesh.
  27548. */
  27549. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  27550. /**
  27551. * Boolean : True if the mesh owns the requested kind of data.
  27552. */
  27553. isVerticesDataPresent(kind: string): boolean;
  27554. /**
  27555. * Returns an array of indices (IndicesArray).
  27556. */
  27557. getIndices(): Nullable<IndicesArray>;
  27558. get _positions(): Nullable<Vector3[]>;
  27559. /**
  27560. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27561. * This means the mesh underlying bounding box and sphere are recomputed.
  27562. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27563. * @returns the current mesh
  27564. */
  27565. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  27566. /** @hidden */
  27567. _preActivate(): InstancedMesh;
  27568. /** @hidden */
  27569. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27570. /** @hidden */
  27571. _postActivate(): void;
  27572. getWorldMatrix(): Matrix;
  27573. get isAnInstance(): boolean;
  27574. /**
  27575. * Returns the current associated LOD AbstractMesh.
  27576. */
  27577. getLOD(camera: Camera): AbstractMesh;
  27578. /** @hidden */
  27579. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27580. /** @hidden */
  27581. _syncSubMeshes(): InstancedMesh;
  27582. /** @hidden */
  27583. _generatePointsArray(): boolean;
  27584. /** @hidden */
  27585. _updateBoundingInfo(): AbstractMesh;
  27586. /**
  27587. * Creates a new InstancedMesh from the current mesh.
  27588. * - name (string) : the cloned mesh name
  27589. * - newParent (optional Node) : the optional Node to parent the clone to.
  27590. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  27591. *
  27592. * Returns the clone.
  27593. */
  27594. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  27595. /**
  27596. * Disposes the InstancedMesh.
  27597. * Returns nothing.
  27598. */
  27599. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27600. }
  27601. interface Mesh {
  27602. /**
  27603. * Register a custom buffer that will be instanced
  27604. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27605. * @param kind defines the buffer kind
  27606. * @param stride defines the stride in floats
  27607. */
  27608. registerInstancedBuffer(kind: string, stride: number): void;
  27609. /**
  27610. * true to use the edge renderer for all instances of this mesh
  27611. */
  27612. edgesShareWithInstances: boolean;
  27613. /** @hidden */
  27614. _userInstancedBuffersStorage: {
  27615. data: {
  27616. [key: string]: Float32Array;
  27617. };
  27618. sizes: {
  27619. [key: string]: number;
  27620. };
  27621. vertexBuffers: {
  27622. [key: string]: Nullable<VertexBuffer>;
  27623. };
  27624. strides: {
  27625. [key: string]: number;
  27626. };
  27627. };
  27628. }
  27629. interface AbstractMesh {
  27630. /**
  27631. * Object used to store instanced buffers defined by user
  27632. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27633. */
  27634. instancedBuffers: {
  27635. [key: string]: any;
  27636. };
  27637. }
  27638. }
  27639. declare module BABYLON {
  27640. /**
  27641. * Defines the options associated with the creation of a shader material.
  27642. */
  27643. export interface IShaderMaterialOptions {
  27644. /**
  27645. * Does the material work in alpha blend mode
  27646. */
  27647. needAlphaBlending: boolean;
  27648. /**
  27649. * Does the material work in alpha test mode
  27650. */
  27651. needAlphaTesting: boolean;
  27652. /**
  27653. * The list of attribute names used in the shader
  27654. */
  27655. attributes: string[];
  27656. /**
  27657. * The list of unifrom names used in the shader
  27658. */
  27659. uniforms: string[];
  27660. /**
  27661. * The list of UBO names used in the shader
  27662. */
  27663. uniformBuffers: string[];
  27664. /**
  27665. * The list of sampler names used in the shader
  27666. */
  27667. samplers: string[];
  27668. /**
  27669. * The list of defines used in the shader
  27670. */
  27671. defines: string[];
  27672. }
  27673. /**
  27674. * 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.
  27675. *
  27676. * This returned material effects how the mesh will look based on the code in the shaders.
  27677. *
  27678. * @see https://doc.babylonjs.com/how_to/shader_material
  27679. */
  27680. export class ShaderMaterial extends Material {
  27681. private _shaderPath;
  27682. private _options;
  27683. private _textures;
  27684. private _textureArrays;
  27685. private _floats;
  27686. private _ints;
  27687. private _floatsArrays;
  27688. private _colors3;
  27689. private _colors3Arrays;
  27690. private _colors4;
  27691. private _colors4Arrays;
  27692. private _vectors2;
  27693. private _vectors3;
  27694. private _vectors4;
  27695. private _matrices;
  27696. private _matrixArrays;
  27697. private _matrices3x3;
  27698. private _matrices2x2;
  27699. private _vectors2Arrays;
  27700. private _vectors3Arrays;
  27701. private _vectors4Arrays;
  27702. private _cachedWorldViewMatrix;
  27703. private _cachedWorldViewProjectionMatrix;
  27704. private _renderId;
  27705. private _multiview;
  27706. private _cachedDefines;
  27707. /** Define the Url to load snippets */
  27708. static SnippetUrl: string;
  27709. /** Snippet ID if the material was created from the snippet server */
  27710. snippetId: string;
  27711. /**
  27712. * Instantiate a new shader material.
  27713. * 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.
  27714. * This returned material effects how the mesh will look based on the code in the shaders.
  27715. * @see https://doc.babylonjs.com/how_to/shader_material
  27716. * @param name Define the name of the material in the scene
  27717. * @param scene Define the scene the material belongs to
  27718. * @param shaderPath Defines the route to the shader code in one of three ways:
  27719. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  27720. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  27721. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  27722. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  27723. * @param options Define the options used to create the shader
  27724. */
  27725. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  27726. /**
  27727. * Gets the shader path used to define the shader code
  27728. * It can be modified to trigger a new compilation
  27729. */
  27730. get shaderPath(): any;
  27731. /**
  27732. * Sets the shader path used to define the shader code
  27733. * It can be modified to trigger a new compilation
  27734. */
  27735. set shaderPath(shaderPath: any);
  27736. /**
  27737. * Gets the options used to compile the shader.
  27738. * They can be modified to trigger a new compilation
  27739. */
  27740. get options(): IShaderMaterialOptions;
  27741. /**
  27742. * Gets the current class name of the material e.g. "ShaderMaterial"
  27743. * Mainly use in serialization.
  27744. * @returns the class name
  27745. */
  27746. getClassName(): string;
  27747. /**
  27748. * Specifies if the material will require alpha blending
  27749. * @returns a boolean specifying if alpha blending is needed
  27750. */
  27751. needAlphaBlending(): boolean;
  27752. /**
  27753. * Specifies if this material should be rendered in alpha test mode
  27754. * @returns a boolean specifying if an alpha test is needed.
  27755. */
  27756. needAlphaTesting(): boolean;
  27757. private _checkUniform;
  27758. /**
  27759. * Set a texture in the shader.
  27760. * @param name Define the name of the uniform samplers as defined in the shader
  27761. * @param texture Define the texture to bind to this sampler
  27762. * @return the material itself allowing "fluent" like uniform updates
  27763. */
  27764. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  27765. /**
  27766. * Set a texture array in the shader.
  27767. * @param name Define the name of the uniform sampler array as defined in the shader
  27768. * @param textures Define the list of textures to bind to this sampler
  27769. * @return the material itself allowing "fluent" like uniform updates
  27770. */
  27771. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  27772. /**
  27773. * Set a float in the shader.
  27774. * @param name Define the name of the uniform as defined in the shader
  27775. * @param value Define the value to give to the uniform
  27776. * @return the material itself allowing "fluent" like uniform updates
  27777. */
  27778. setFloat(name: string, value: number): ShaderMaterial;
  27779. /**
  27780. * Set a int in the shader.
  27781. * @param name Define the name of the uniform as defined in the shader
  27782. * @param value Define the value to give to the uniform
  27783. * @return the material itself allowing "fluent" like uniform updates
  27784. */
  27785. setInt(name: string, value: number): ShaderMaterial;
  27786. /**
  27787. * Set an array of floats in the shader.
  27788. * @param name Define the name of the uniform as defined in the shader
  27789. * @param value Define the value to give to the uniform
  27790. * @return the material itself allowing "fluent" like uniform updates
  27791. */
  27792. setFloats(name: string, value: number[]): ShaderMaterial;
  27793. /**
  27794. * Set a vec3 in the shader from a Color3.
  27795. * @param name Define the name of the uniform as defined in the shader
  27796. * @param value Define the value to give to the uniform
  27797. * @return the material itself allowing "fluent" like uniform updates
  27798. */
  27799. setColor3(name: string, value: Color3): ShaderMaterial;
  27800. /**
  27801. * Set a vec3 array in the shader from a Color3 array.
  27802. * @param name Define the name of the uniform as defined in the shader
  27803. * @param value Define the value to give to the uniform
  27804. * @return the material itself allowing "fluent" like uniform updates
  27805. */
  27806. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  27807. /**
  27808. * Set a vec4 in the shader from a Color4.
  27809. * @param name Define the name of the uniform as defined in the shader
  27810. * @param value Define the value to give to the uniform
  27811. * @return the material itself allowing "fluent" like uniform updates
  27812. */
  27813. setColor4(name: string, value: Color4): ShaderMaterial;
  27814. /**
  27815. * Set a vec4 array in the shader from a Color4 array.
  27816. * @param name Define the name of the uniform as defined in the shader
  27817. * @param value Define the value to give to the uniform
  27818. * @return the material itself allowing "fluent" like uniform updates
  27819. */
  27820. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  27821. /**
  27822. * Set a vec2 in the shader from a Vector2.
  27823. * @param name Define the name of the uniform as defined in the shader
  27824. * @param value Define the value to give to the uniform
  27825. * @return the material itself allowing "fluent" like uniform updates
  27826. */
  27827. setVector2(name: string, value: Vector2): ShaderMaterial;
  27828. /**
  27829. * Set a vec3 in the shader from a Vector3.
  27830. * @param name Define the name of the uniform as defined in the shader
  27831. * @param value Define the value to give to the uniform
  27832. * @return the material itself allowing "fluent" like uniform updates
  27833. */
  27834. setVector3(name: string, value: Vector3): ShaderMaterial;
  27835. /**
  27836. * Set a vec4 in the shader from a Vector4.
  27837. * @param name Define the name of the uniform as defined in the shader
  27838. * @param value Define the value to give to the uniform
  27839. * @return the material itself allowing "fluent" like uniform updates
  27840. */
  27841. setVector4(name: string, value: Vector4): ShaderMaterial;
  27842. /**
  27843. * Set a mat4 in the shader from a Matrix.
  27844. * @param name Define the name of the uniform as defined in the shader
  27845. * @param value Define the value to give to the uniform
  27846. * @return the material itself allowing "fluent" like uniform updates
  27847. */
  27848. setMatrix(name: string, value: Matrix): ShaderMaterial;
  27849. /**
  27850. * Set a float32Array in the shader from a matrix array.
  27851. * @param name Define the name of the uniform as defined in the shader
  27852. * @param value Define the value to give to the uniform
  27853. * @return the material itself allowing "fluent" like uniform updates
  27854. */
  27855. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  27856. /**
  27857. * Set a mat3 in the shader from a Float32Array.
  27858. * @param name Define the name of the uniform as defined in the shader
  27859. * @param value Define the value to give to the uniform
  27860. * @return the material itself allowing "fluent" like uniform updates
  27861. */
  27862. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27863. /**
  27864. * Set a mat2 in the shader from a Float32Array.
  27865. * @param name Define the name of the uniform as defined in the shader
  27866. * @param value Define the value to give to the uniform
  27867. * @return the material itself allowing "fluent" like uniform updates
  27868. */
  27869. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27870. /**
  27871. * Set a vec2 array in the shader from a number array.
  27872. * @param name Define the name of the uniform as defined in the shader
  27873. * @param value Define the value to give to the uniform
  27874. * @return the material itself allowing "fluent" like uniform updates
  27875. */
  27876. setArray2(name: string, value: number[]): ShaderMaterial;
  27877. /**
  27878. * Set a vec3 array in the shader from a number array.
  27879. * @param name Define the name of the uniform as defined in the shader
  27880. * @param value Define the value to give to the uniform
  27881. * @return the material itself allowing "fluent" like uniform updates
  27882. */
  27883. setArray3(name: string, value: number[]): ShaderMaterial;
  27884. /**
  27885. * Set a vec4 array in the shader from a number array.
  27886. * @param name Define the name of the uniform as defined in the shader
  27887. * @param value Define the value to give to the uniform
  27888. * @return the material itself allowing "fluent" like uniform updates
  27889. */
  27890. setArray4(name: string, value: number[]): ShaderMaterial;
  27891. private _checkCache;
  27892. /**
  27893. * Specifies that the submesh is ready to be used
  27894. * @param mesh defines the mesh to check
  27895. * @param subMesh defines which submesh to check
  27896. * @param useInstances specifies that instances should be used
  27897. * @returns a boolean indicating that the submesh is ready or not
  27898. */
  27899. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27900. /**
  27901. * Checks if the material is ready to render the requested mesh
  27902. * @param mesh Define the mesh to render
  27903. * @param useInstances Define whether or not the material is used with instances
  27904. * @returns true if ready, otherwise false
  27905. */
  27906. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27907. /**
  27908. * Binds the world matrix to the material
  27909. * @param world defines the world transformation matrix
  27910. * @param effectOverride - If provided, use this effect instead of internal effect
  27911. */
  27912. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  27913. /**
  27914. * Binds the submesh to this material by preparing the effect and shader to draw
  27915. * @param world defines the world transformation matrix
  27916. * @param mesh defines the mesh containing the submesh
  27917. * @param subMesh defines the submesh to bind the material to
  27918. */
  27919. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27920. /**
  27921. * Binds the material to the mesh
  27922. * @param world defines the world transformation matrix
  27923. * @param mesh defines the mesh to bind the material to
  27924. * @param effectOverride - If provided, use this effect instead of internal effect
  27925. */
  27926. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  27927. protected _afterBind(mesh?: Mesh): void;
  27928. /**
  27929. * Gets the active textures from the material
  27930. * @returns an array of textures
  27931. */
  27932. getActiveTextures(): BaseTexture[];
  27933. /**
  27934. * Specifies if the material uses a texture
  27935. * @param texture defines the texture to check against the material
  27936. * @returns a boolean specifying if the material uses the texture
  27937. */
  27938. hasTexture(texture: BaseTexture): boolean;
  27939. /**
  27940. * Makes a duplicate of the material, and gives it a new name
  27941. * @param name defines the new name for the duplicated material
  27942. * @returns the cloned material
  27943. */
  27944. clone(name: string): ShaderMaterial;
  27945. /**
  27946. * Disposes the material
  27947. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27948. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27949. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  27950. */
  27951. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  27952. /**
  27953. * Serializes this material in a JSON representation
  27954. * @returns the serialized material object
  27955. */
  27956. serialize(): any;
  27957. /**
  27958. * Creates a shader material from parsed shader material data
  27959. * @param source defines the JSON represnetation of the material
  27960. * @param scene defines the hosting scene
  27961. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27962. * @returns a new material
  27963. */
  27964. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  27965. /**
  27966. * Creates a new ShaderMaterial from a snippet saved in a remote file
  27967. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  27968. * @param url defines the url to load from
  27969. * @param scene defines the hosting scene
  27970. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27971. * @returns a promise that will resolve to the new ShaderMaterial
  27972. */
  27973. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  27974. /**
  27975. * Creates a ShaderMaterial from a snippet saved by the Inspector
  27976. * @param snippetId defines the snippet to load
  27977. * @param scene defines the hosting scene
  27978. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27979. * @returns a promise that will resolve to the new ShaderMaterial
  27980. */
  27981. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  27982. }
  27983. }
  27984. declare module BABYLON {
  27985. /** @hidden */
  27986. export var colorPixelShader: {
  27987. name: string;
  27988. shader: string;
  27989. };
  27990. }
  27991. declare module BABYLON {
  27992. /** @hidden */
  27993. export var colorVertexShader: {
  27994. name: string;
  27995. shader: string;
  27996. };
  27997. }
  27998. declare module BABYLON {
  27999. /**
  28000. * Line mesh
  28001. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28002. */
  28003. export class LinesMesh extends Mesh {
  28004. /**
  28005. * If vertex color should be applied to the mesh
  28006. */
  28007. readonly useVertexColor?: boolean | undefined;
  28008. /**
  28009. * If vertex alpha should be applied to the mesh
  28010. */
  28011. readonly useVertexAlpha?: boolean | undefined;
  28012. /**
  28013. * Color of the line (Default: White)
  28014. */
  28015. color: Color3;
  28016. /**
  28017. * Alpha of the line (Default: 1)
  28018. */
  28019. alpha: number;
  28020. /**
  28021. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28022. * This margin is expressed in world space coordinates, so its value may vary.
  28023. * Default value is 0.1
  28024. */
  28025. intersectionThreshold: number;
  28026. private _colorShader;
  28027. private color4;
  28028. /**
  28029. * Creates a new LinesMesh
  28030. * @param name defines the name
  28031. * @param scene defines the hosting scene
  28032. * @param parent defines the parent mesh if any
  28033. * @param source defines the optional source LinesMesh used to clone data from
  28034. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28035. * When false, achieved by calling a clone(), also passing False.
  28036. * This will make creation of children, recursive.
  28037. * @param useVertexColor defines if this LinesMesh supports vertex color
  28038. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28039. */
  28040. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28041. /**
  28042. * If vertex color should be applied to the mesh
  28043. */
  28044. useVertexColor?: boolean | undefined,
  28045. /**
  28046. * If vertex alpha should be applied to the mesh
  28047. */
  28048. useVertexAlpha?: boolean | undefined);
  28049. private _addClipPlaneDefine;
  28050. private _removeClipPlaneDefine;
  28051. isReady(): boolean;
  28052. /**
  28053. * Returns the string "LineMesh"
  28054. */
  28055. getClassName(): string;
  28056. /**
  28057. * @hidden
  28058. */
  28059. get material(): Material;
  28060. /**
  28061. * @hidden
  28062. */
  28063. set material(value: Material);
  28064. /**
  28065. * @hidden
  28066. */
  28067. get checkCollisions(): boolean;
  28068. /** @hidden */
  28069. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28070. /** @hidden */
  28071. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28072. /**
  28073. * Disposes of the line mesh
  28074. * @param doNotRecurse If children should be disposed
  28075. */
  28076. dispose(doNotRecurse?: boolean): void;
  28077. /**
  28078. * Returns a new LineMesh object cloned from the current one.
  28079. */
  28080. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28081. /**
  28082. * Creates a new InstancedLinesMesh object from the mesh model.
  28083. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28084. * @param name defines the name of the new instance
  28085. * @returns a new InstancedLinesMesh
  28086. */
  28087. createInstance(name: string): InstancedLinesMesh;
  28088. }
  28089. /**
  28090. * Creates an instance based on a source LinesMesh
  28091. */
  28092. export class InstancedLinesMesh extends InstancedMesh {
  28093. /**
  28094. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28095. * This margin is expressed in world space coordinates, so its value may vary.
  28096. * Initilized with the intersectionThreshold value of the source LinesMesh
  28097. */
  28098. intersectionThreshold: number;
  28099. constructor(name: string, source: LinesMesh);
  28100. /**
  28101. * Returns the string "InstancedLinesMesh".
  28102. */
  28103. getClassName(): string;
  28104. }
  28105. }
  28106. declare module BABYLON {
  28107. /** @hidden */
  28108. export var linePixelShader: {
  28109. name: string;
  28110. shader: string;
  28111. };
  28112. }
  28113. declare module BABYLON {
  28114. /** @hidden */
  28115. export var lineVertexShader: {
  28116. name: string;
  28117. shader: string;
  28118. };
  28119. }
  28120. declare module BABYLON {
  28121. interface Scene {
  28122. /** @hidden */
  28123. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28124. }
  28125. interface AbstractMesh {
  28126. /**
  28127. * Gets the edgesRenderer associated with the mesh
  28128. */
  28129. edgesRenderer: Nullable<EdgesRenderer>;
  28130. }
  28131. interface LinesMesh {
  28132. /**
  28133. * Enables the edge rendering mode on the mesh.
  28134. * This mode makes the mesh edges visible
  28135. * @param epsilon defines the maximal distance between two angles to detect a face
  28136. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28137. * @returns the currentAbstractMesh
  28138. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28139. */
  28140. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28141. }
  28142. interface InstancedLinesMesh {
  28143. /**
  28144. * Enables the edge rendering mode on the mesh.
  28145. * This mode makes the mesh edges visible
  28146. * @param epsilon defines the maximal distance between two angles to detect a face
  28147. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28148. * @returns the current InstancedLinesMesh
  28149. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28150. */
  28151. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28152. }
  28153. /**
  28154. * Defines the minimum contract an Edges renderer should follow.
  28155. */
  28156. export interface IEdgesRenderer extends IDisposable {
  28157. /**
  28158. * Gets or sets a boolean indicating if the edgesRenderer is active
  28159. */
  28160. isEnabled: boolean;
  28161. /**
  28162. * Renders the edges of the attached mesh,
  28163. */
  28164. render(): void;
  28165. /**
  28166. * Checks wether or not the edges renderer is ready to render.
  28167. * @return true if ready, otherwise false.
  28168. */
  28169. isReady(): boolean;
  28170. /**
  28171. * List of instances to render in case the source mesh has instances
  28172. */
  28173. customInstances: SmartArray<Matrix>;
  28174. }
  28175. /**
  28176. * Defines the additional options of the edges renderer
  28177. */
  28178. export interface IEdgesRendererOptions {
  28179. /**
  28180. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28181. * If not defined, the default value is true
  28182. */
  28183. useAlternateEdgeFinder?: boolean;
  28184. /**
  28185. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28186. * If not defined, the default value is true.
  28187. * 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)
  28188. * This option is used only if useAlternateEdgeFinder = true
  28189. */
  28190. useFastVertexMerger?: boolean;
  28191. /**
  28192. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28193. * The default value is 1e-6
  28194. * This option is used only if useAlternateEdgeFinder = true
  28195. */
  28196. epsilonVertexMerge?: number;
  28197. /**
  28198. * 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
  28199. * 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.
  28200. * This option is used only if useAlternateEdgeFinder = true
  28201. */
  28202. applyTessellation?: boolean;
  28203. /**
  28204. * 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
  28205. * The default value is 1e-6
  28206. * This option is used only if useAlternateEdgeFinder = true
  28207. */
  28208. epsilonVertexAligned?: number;
  28209. }
  28210. /**
  28211. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28212. */
  28213. export class EdgesRenderer implements IEdgesRenderer {
  28214. /**
  28215. * Define the size of the edges with an orthographic camera
  28216. */
  28217. edgesWidthScalerForOrthographic: number;
  28218. /**
  28219. * Define the size of the edges with a perspective camera
  28220. */
  28221. edgesWidthScalerForPerspective: number;
  28222. protected _source: AbstractMesh;
  28223. protected _linesPositions: number[];
  28224. protected _linesNormals: number[];
  28225. protected _linesIndices: number[];
  28226. protected _epsilon: number;
  28227. protected _indicesCount: number;
  28228. protected _lineShader: ShaderMaterial;
  28229. protected _ib: DataBuffer;
  28230. protected _buffers: {
  28231. [key: string]: Nullable<VertexBuffer>;
  28232. };
  28233. protected _buffersForInstances: {
  28234. [key: string]: Nullable<VertexBuffer>;
  28235. };
  28236. protected _checkVerticesInsteadOfIndices: boolean;
  28237. protected _options: Nullable<IEdgesRendererOptions>;
  28238. private _meshRebuildObserver;
  28239. private _meshDisposeObserver;
  28240. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28241. isEnabled: boolean;
  28242. /** Gets the vertices generated by the edge renderer */
  28243. get linesPositions(): Immutable<Array<number>>;
  28244. /** Gets the normals generated by the edge renderer */
  28245. get linesNormals(): Immutable<Array<number>>;
  28246. /** Gets the indices generated by the edge renderer */
  28247. get linesIndices(): Immutable<Array<number>>;
  28248. /**
  28249. * List of instances to render in case the source mesh has instances
  28250. */
  28251. customInstances: SmartArray<Matrix>;
  28252. private static GetShader;
  28253. /**
  28254. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28255. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28256. * @param source Mesh used to create edges
  28257. * @param epsilon sum of angles in adjacency to check for edge
  28258. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  28259. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28260. * @param options The options to apply when generating the edges
  28261. */
  28262. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  28263. protected _prepareRessources(): void;
  28264. /** @hidden */
  28265. _rebuild(): void;
  28266. /**
  28267. * Releases the required resources for the edges renderer
  28268. */
  28269. dispose(): void;
  28270. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28271. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28272. /**
  28273. * Checks if the pair of p0 and p1 is en edge
  28274. * @param faceIndex
  28275. * @param edge
  28276. * @param faceNormals
  28277. * @param p0
  28278. * @param p1
  28279. * @private
  28280. */
  28281. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28282. /**
  28283. * push line into the position, normal and index buffer
  28284. * @protected
  28285. */
  28286. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  28287. /**
  28288. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  28289. */
  28290. private _tessellateTriangle;
  28291. private _generateEdgesLinesAlternate;
  28292. /**
  28293. * Generates lines edges from adjacencjes
  28294. * @private
  28295. */
  28296. _generateEdgesLines(): void;
  28297. /**
  28298. * Checks wether or not the edges renderer is ready to render.
  28299. * @return true if ready, otherwise false.
  28300. */
  28301. isReady(): boolean;
  28302. /**
  28303. * Renders the edges of the attached mesh,
  28304. */
  28305. render(): void;
  28306. }
  28307. /**
  28308. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  28309. */
  28310. export class LineEdgesRenderer extends EdgesRenderer {
  28311. /**
  28312. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  28313. * @param source LineMesh used to generate edges
  28314. * @param epsilon not important (specified angle for edge detection)
  28315. * @param checkVerticesInsteadOfIndices not important for LineMesh
  28316. */
  28317. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28318. /**
  28319. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  28320. */
  28321. _generateEdgesLines(): void;
  28322. }
  28323. }
  28324. declare module BABYLON {
  28325. /**
  28326. * This represents the object necessary to create a rendering group.
  28327. * This is exclusively used and created by the rendering manager.
  28328. * To modify the behavior, you use the available helpers in your scene or meshes.
  28329. * @hidden
  28330. */
  28331. export class RenderingGroup {
  28332. index: number;
  28333. private static _zeroVector;
  28334. private _scene;
  28335. private _opaqueSubMeshes;
  28336. private _transparentSubMeshes;
  28337. private _alphaTestSubMeshes;
  28338. private _depthOnlySubMeshes;
  28339. private _particleSystems;
  28340. private _spriteManagers;
  28341. private _opaqueSortCompareFn;
  28342. private _alphaTestSortCompareFn;
  28343. private _transparentSortCompareFn;
  28344. private _renderOpaque;
  28345. private _renderAlphaTest;
  28346. private _renderTransparent;
  28347. /** @hidden */
  28348. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  28349. onBeforeTransparentRendering: () => void;
  28350. /**
  28351. * Set the opaque sort comparison function.
  28352. * If null the sub meshes will be render in the order they were created
  28353. */
  28354. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28355. /**
  28356. * Set the alpha test sort comparison function.
  28357. * If null the sub meshes will be render in the order they were created
  28358. */
  28359. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28360. /**
  28361. * Set the transparent sort comparison function.
  28362. * If null the sub meshes will be render in the order they were created
  28363. */
  28364. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28365. /**
  28366. * Creates a new rendering group.
  28367. * @param index The rendering group index
  28368. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  28369. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  28370. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  28371. */
  28372. 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>);
  28373. /**
  28374. * Render all the sub meshes contained in the group.
  28375. * @param customRenderFunction Used to override the default render behaviour of the group.
  28376. * @returns true if rendered some submeshes.
  28377. */
  28378. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  28379. /**
  28380. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  28381. * @param subMeshes The submeshes to render
  28382. */
  28383. private renderOpaqueSorted;
  28384. /**
  28385. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  28386. * @param subMeshes The submeshes to render
  28387. */
  28388. private renderAlphaTestSorted;
  28389. /**
  28390. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  28391. * @param subMeshes The submeshes to render
  28392. */
  28393. private renderTransparentSorted;
  28394. /**
  28395. * Renders the submeshes in a specified order.
  28396. * @param subMeshes The submeshes to sort before render
  28397. * @param sortCompareFn The comparison function use to sort
  28398. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  28399. * @param transparent Specifies to activate blending if true
  28400. */
  28401. private static renderSorted;
  28402. /**
  28403. * Renders the submeshes in the order they were dispatched (no sort applied).
  28404. * @param subMeshes The submeshes to render
  28405. */
  28406. private static renderUnsorted;
  28407. /**
  28408. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28409. * are rendered back to front if in the same alpha index.
  28410. *
  28411. * @param a The first submesh
  28412. * @param b The second submesh
  28413. * @returns The result of the comparison
  28414. */
  28415. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  28416. /**
  28417. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28418. * are rendered back to front.
  28419. *
  28420. * @param a The first submesh
  28421. * @param b The second submesh
  28422. * @returns The result of the comparison
  28423. */
  28424. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  28425. /**
  28426. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28427. * are rendered front to back (prevent overdraw).
  28428. *
  28429. * @param a The first submesh
  28430. * @param b The second submesh
  28431. * @returns The result of the comparison
  28432. */
  28433. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  28434. /**
  28435. * Resets the different lists of submeshes to prepare a new frame.
  28436. */
  28437. prepare(): void;
  28438. dispose(): void;
  28439. /**
  28440. * Inserts the submesh in its correct queue depending on its material.
  28441. * @param subMesh The submesh to dispatch
  28442. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28443. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28444. */
  28445. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28446. dispatchSprites(spriteManager: ISpriteManager): void;
  28447. dispatchParticles(particleSystem: IParticleSystem): void;
  28448. private _renderParticles;
  28449. private _renderSprites;
  28450. }
  28451. }
  28452. declare module BABYLON {
  28453. /**
  28454. * Interface describing the different options available in the rendering manager
  28455. * regarding Auto Clear between groups.
  28456. */
  28457. export interface IRenderingManagerAutoClearSetup {
  28458. /**
  28459. * Defines whether or not autoclear is enable.
  28460. */
  28461. autoClear: boolean;
  28462. /**
  28463. * Defines whether or not to autoclear the depth buffer.
  28464. */
  28465. depth: boolean;
  28466. /**
  28467. * Defines whether or not to autoclear the stencil buffer.
  28468. */
  28469. stencil: boolean;
  28470. }
  28471. /**
  28472. * This class is used by the onRenderingGroupObservable
  28473. */
  28474. export class RenderingGroupInfo {
  28475. /**
  28476. * The Scene that being rendered
  28477. */
  28478. scene: Scene;
  28479. /**
  28480. * The camera currently used for the rendering pass
  28481. */
  28482. camera: Nullable<Camera>;
  28483. /**
  28484. * The ID of the renderingGroup being processed
  28485. */
  28486. renderingGroupId: number;
  28487. }
  28488. /**
  28489. * This is the manager responsible of all the rendering for meshes sprites and particles.
  28490. * It is enable to manage the different groups as well as the different necessary sort functions.
  28491. * This should not be used directly aside of the few static configurations
  28492. */
  28493. export class RenderingManager {
  28494. /**
  28495. * The max id used for rendering groups (not included)
  28496. */
  28497. static MAX_RENDERINGGROUPS: number;
  28498. /**
  28499. * The min id used for rendering groups (included)
  28500. */
  28501. static MIN_RENDERINGGROUPS: number;
  28502. /**
  28503. * Used to globally prevent autoclearing scenes.
  28504. */
  28505. static AUTOCLEAR: boolean;
  28506. /**
  28507. * @hidden
  28508. */
  28509. _useSceneAutoClearSetup: boolean;
  28510. private _scene;
  28511. private _renderingGroups;
  28512. private _depthStencilBufferAlreadyCleaned;
  28513. private _autoClearDepthStencil;
  28514. private _customOpaqueSortCompareFn;
  28515. private _customAlphaTestSortCompareFn;
  28516. private _customTransparentSortCompareFn;
  28517. private _renderingGroupInfo;
  28518. /**
  28519. * Instantiates a new rendering group for a particular scene
  28520. * @param scene Defines the scene the groups belongs to
  28521. */
  28522. constructor(scene: Scene);
  28523. private _clearDepthStencilBuffer;
  28524. /**
  28525. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  28526. * @hidden
  28527. */
  28528. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  28529. /**
  28530. * Resets the different information of the group to prepare a new frame
  28531. * @hidden
  28532. */
  28533. reset(): void;
  28534. /**
  28535. * Dispose and release the group and its associated resources.
  28536. * @hidden
  28537. */
  28538. dispose(): void;
  28539. /**
  28540. * Clear the info related to rendering groups preventing retention points during dispose.
  28541. */
  28542. freeRenderingGroups(): void;
  28543. private _prepareRenderingGroup;
  28544. /**
  28545. * Add a sprite manager to the rendering manager in order to render it this frame.
  28546. * @param spriteManager Define the sprite manager to render
  28547. */
  28548. dispatchSprites(spriteManager: ISpriteManager): void;
  28549. /**
  28550. * Add a particle system to the rendering manager in order to render it this frame.
  28551. * @param particleSystem Define the particle system to render
  28552. */
  28553. dispatchParticles(particleSystem: IParticleSystem): void;
  28554. /**
  28555. * Add a submesh to the manager in order to render it this frame
  28556. * @param subMesh The submesh to dispatch
  28557. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28558. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28559. */
  28560. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28561. /**
  28562. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28563. * This allowed control for front to back rendering or reversly depending of the special needs.
  28564. *
  28565. * @param renderingGroupId The rendering group id corresponding to its index
  28566. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28567. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28568. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28569. */
  28570. 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;
  28571. /**
  28572. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28573. *
  28574. * @param renderingGroupId The rendering group id corresponding to its index
  28575. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28576. * @param depth Automatically clears depth between groups if true and autoClear is true.
  28577. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  28578. */
  28579. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  28580. /**
  28581. * Gets the current auto clear configuration for one rendering group of the rendering
  28582. * manager.
  28583. * @param index the rendering group index to get the information for
  28584. * @returns The auto clear setup for the requested rendering group
  28585. */
  28586. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  28587. }
  28588. }
  28589. declare module BABYLON {
  28590. /**
  28591. * Defines the options associated with the creation of a custom shader for a shadow generator.
  28592. */
  28593. export interface ICustomShaderOptions {
  28594. /**
  28595. * Gets or sets the custom shader name to use
  28596. */
  28597. shaderName: string;
  28598. /**
  28599. * The list of attribute names used in the shader
  28600. */
  28601. attributes?: string[];
  28602. /**
  28603. * The list of unifrom names used in the shader
  28604. */
  28605. uniforms?: string[];
  28606. /**
  28607. * The list of sampler names used in the shader
  28608. */
  28609. samplers?: string[];
  28610. /**
  28611. * The list of defines used in the shader
  28612. */
  28613. defines?: string[];
  28614. }
  28615. /**
  28616. * Interface to implement to create a shadow generator compatible with BJS.
  28617. */
  28618. export interface IShadowGenerator {
  28619. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28620. id: string;
  28621. /**
  28622. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  28623. * @returns The render target texture if present otherwise, null
  28624. */
  28625. getShadowMap(): Nullable<RenderTargetTexture>;
  28626. /**
  28627. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  28628. * @param subMesh The submesh we want to render in the shadow map
  28629. * @param useInstances Defines wether will draw in the map using instances
  28630. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  28631. * @returns true if ready otherwise, false
  28632. */
  28633. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  28634. /**
  28635. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  28636. * @param defines Defines of the material we want to update
  28637. * @param lightIndex Index of the light in the enabled light list of the material
  28638. */
  28639. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  28640. /**
  28641. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  28642. * defined in the generator but impacting the effect).
  28643. * It implies the unifroms available on the materials are the standard BJS ones.
  28644. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  28645. * @param effect The effect we are binfing the information for
  28646. */
  28647. bindShadowLight(lightIndex: string, effect: Effect): void;
  28648. /**
  28649. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  28650. * (eq to shadow prjection matrix * light transform matrix)
  28651. * @returns The transform matrix used to create the shadow map
  28652. */
  28653. getTransformMatrix(): Matrix;
  28654. /**
  28655. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  28656. * Cube and 2D textures for instance.
  28657. */
  28658. recreateShadowMap(): void;
  28659. /**
  28660. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28661. * @param onCompiled Callback triggered at the and of the effects compilation
  28662. * @param options Sets of optional options forcing the compilation with different modes
  28663. */
  28664. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  28665. useInstances: boolean;
  28666. }>): void;
  28667. /**
  28668. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28669. * @param options Sets of optional options forcing the compilation with different modes
  28670. * @returns A promise that resolves when the compilation completes
  28671. */
  28672. forceCompilationAsync(options?: Partial<{
  28673. useInstances: boolean;
  28674. }>): Promise<void>;
  28675. /**
  28676. * Serializes the shadow generator setup to a json object.
  28677. * @returns The serialized JSON object
  28678. */
  28679. serialize(): any;
  28680. /**
  28681. * Disposes the Shadow map and related Textures and effects.
  28682. */
  28683. dispose(): void;
  28684. }
  28685. /**
  28686. * Default implementation IShadowGenerator.
  28687. * This is the main object responsible of generating shadows in the framework.
  28688. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  28689. */
  28690. export class ShadowGenerator implements IShadowGenerator {
  28691. /**
  28692. * Name of the shadow generator class
  28693. */
  28694. static CLASSNAME: string;
  28695. /**
  28696. * Shadow generator mode None: no filtering applied.
  28697. */
  28698. static readonly FILTER_NONE: number;
  28699. /**
  28700. * Shadow generator mode ESM: Exponential Shadow Mapping.
  28701. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28702. */
  28703. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  28704. /**
  28705. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  28706. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  28707. */
  28708. static readonly FILTER_POISSONSAMPLING: number;
  28709. /**
  28710. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  28711. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28712. */
  28713. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  28714. /**
  28715. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  28716. * edge artifacts on steep falloff.
  28717. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28718. */
  28719. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  28720. /**
  28721. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  28722. * edge artifacts on steep falloff.
  28723. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28724. */
  28725. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  28726. /**
  28727. * Shadow generator mode PCF: Percentage Closer Filtering
  28728. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28729. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  28730. */
  28731. static readonly FILTER_PCF: number;
  28732. /**
  28733. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  28734. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28735. * Contact Hardening
  28736. */
  28737. static readonly FILTER_PCSS: number;
  28738. /**
  28739. * Reserved for PCF and PCSS
  28740. * Highest Quality.
  28741. *
  28742. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  28743. *
  28744. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  28745. */
  28746. static readonly QUALITY_HIGH: number;
  28747. /**
  28748. * Reserved for PCF and PCSS
  28749. * Good tradeoff for quality/perf cross devices
  28750. *
  28751. * Execute PCF on a 3*3 kernel.
  28752. *
  28753. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  28754. */
  28755. static readonly QUALITY_MEDIUM: number;
  28756. /**
  28757. * Reserved for PCF and PCSS
  28758. * The lowest quality but the fastest.
  28759. *
  28760. * Execute PCF on a 1*1 kernel.
  28761. *
  28762. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  28763. */
  28764. static readonly QUALITY_LOW: number;
  28765. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28766. id: string;
  28767. /** Gets or sets the custom shader name to use */
  28768. customShaderOptions: ICustomShaderOptions;
  28769. /**
  28770. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  28771. */
  28772. onBeforeShadowMapRenderObservable: Observable<Effect>;
  28773. /**
  28774. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  28775. */
  28776. onAfterShadowMapRenderObservable: Observable<Effect>;
  28777. /**
  28778. * Observable triggered before a mesh is rendered in the shadow map.
  28779. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  28780. */
  28781. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  28782. /**
  28783. * Observable triggered after a mesh is rendered in the shadow map.
  28784. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  28785. */
  28786. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  28787. protected _bias: number;
  28788. /**
  28789. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  28790. */
  28791. get bias(): number;
  28792. /**
  28793. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  28794. */
  28795. set bias(bias: number);
  28796. protected _normalBias: number;
  28797. /**
  28798. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28799. */
  28800. get normalBias(): number;
  28801. /**
  28802. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28803. */
  28804. set normalBias(normalBias: number);
  28805. protected _blurBoxOffset: number;
  28806. /**
  28807. * Gets the blur box offset: offset applied during the blur pass.
  28808. * Only useful if useKernelBlur = false
  28809. */
  28810. get blurBoxOffset(): number;
  28811. /**
  28812. * Sets the blur box offset: offset applied during the blur pass.
  28813. * Only useful if useKernelBlur = false
  28814. */
  28815. set blurBoxOffset(value: number);
  28816. protected _blurScale: number;
  28817. /**
  28818. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  28819. * 2 means half of the size.
  28820. */
  28821. get blurScale(): number;
  28822. /**
  28823. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  28824. * 2 means half of the size.
  28825. */
  28826. set blurScale(value: number);
  28827. protected _blurKernel: number;
  28828. /**
  28829. * Gets the blur kernel: kernel size of the blur pass.
  28830. * Only useful if useKernelBlur = true
  28831. */
  28832. get blurKernel(): number;
  28833. /**
  28834. * Sets the blur kernel: kernel size of the blur pass.
  28835. * Only useful if useKernelBlur = true
  28836. */
  28837. set blurKernel(value: number);
  28838. protected _useKernelBlur: boolean;
  28839. /**
  28840. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  28841. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28842. */
  28843. get useKernelBlur(): boolean;
  28844. /**
  28845. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  28846. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28847. */
  28848. set useKernelBlur(value: boolean);
  28849. protected _depthScale: number;
  28850. /**
  28851. * Gets the depth scale used in ESM mode.
  28852. */
  28853. get depthScale(): number;
  28854. /**
  28855. * Sets the depth scale used in ESM mode.
  28856. * This can override the scale stored on the light.
  28857. */
  28858. set depthScale(value: number);
  28859. protected _validateFilter(filter: number): number;
  28860. protected _filter: number;
  28861. /**
  28862. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  28863. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28864. */
  28865. get filter(): number;
  28866. /**
  28867. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  28868. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28869. */
  28870. set filter(value: number);
  28871. /**
  28872. * Gets if the current filter is set to Poisson Sampling.
  28873. */
  28874. get usePoissonSampling(): boolean;
  28875. /**
  28876. * Sets the current filter to Poisson Sampling.
  28877. */
  28878. set usePoissonSampling(value: boolean);
  28879. /**
  28880. * Gets if the current filter is set to ESM.
  28881. */
  28882. get useExponentialShadowMap(): boolean;
  28883. /**
  28884. * Sets the current filter is to ESM.
  28885. */
  28886. set useExponentialShadowMap(value: boolean);
  28887. /**
  28888. * Gets if the current filter is set to filtered ESM.
  28889. */
  28890. get useBlurExponentialShadowMap(): boolean;
  28891. /**
  28892. * Gets if the current filter is set to filtered ESM.
  28893. */
  28894. set useBlurExponentialShadowMap(value: boolean);
  28895. /**
  28896. * Gets if the current filter is set to "close ESM" (using the inverse of the
  28897. * exponential to prevent steep falloff artifacts).
  28898. */
  28899. get useCloseExponentialShadowMap(): boolean;
  28900. /**
  28901. * Sets the current filter to "close ESM" (using the inverse of the
  28902. * exponential to prevent steep falloff artifacts).
  28903. */
  28904. set useCloseExponentialShadowMap(value: boolean);
  28905. /**
  28906. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  28907. * exponential to prevent steep falloff artifacts).
  28908. */
  28909. get useBlurCloseExponentialShadowMap(): boolean;
  28910. /**
  28911. * Sets the current filter to filtered "close ESM" (using the inverse of the
  28912. * exponential to prevent steep falloff artifacts).
  28913. */
  28914. set useBlurCloseExponentialShadowMap(value: boolean);
  28915. /**
  28916. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  28917. */
  28918. get usePercentageCloserFiltering(): boolean;
  28919. /**
  28920. * Sets the current filter to "PCF" (percentage closer filtering).
  28921. */
  28922. set usePercentageCloserFiltering(value: boolean);
  28923. protected _filteringQuality: number;
  28924. /**
  28925. * Gets the PCF or PCSS Quality.
  28926. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28927. */
  28928. get filteringQuality(): number;
  28929. /**
  28930. * Sets the PCF or PCSS Quality.
  28931. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28932. */
  28933. set filteringQuality(filteringQuality: number);
  28934. /**
  28935. * Gets if the current filter is set to "PCSS" (contact hardening).
  28936. */
  28937. get useContactHardeningShadow(): boolean;
  28938. /**
  28939. * Sets the current filter to "PCSS" (contact hardening).
  28940. */
  28941. set useContactHardeningShadow(value: boolean);
  28942. protected _contactHardeningLightSizeUVRatio: number;
  28943. /**
  28944. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28945. * Using a ratio helps keeping shape stability independently of the map size.
  28946. *
  28947. * It does not account for the light projection as it was having too much
  28948. * instability during the light setup or during light position changes.
  28949. *
  28950. * Only valid if useContactHardeningShadow is true.
  28951. */
  28952. get contactHardeningLightSizeUVRatio(): number;
  28953. /**
  28954. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28955. * Using a ratio helps keeping shape stability independently of the map size.
  28956. *
  28957. * It does not account for the light projection as it was having too much
  28958. * instability during the light setup or during light position changes.
  28959. *
  28960. * Only valid if useContactHardeningShadow is true.
  28961. */
  28962. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  28963. protected _darkness: number;
  28964. /** Gets or sets the actual darkness of a shadow */
  28965. get darkness(): number;
  28966. set darkness(value: number);
  28967. /**
  28968. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  28969. * 0 means strongest and 1 would means no shadow.
  28970. * @returns the darkness.
  28971. */
  28972. getDarkness(): number;
  28973. /**
  28974. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  28975. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  28976. * @returns the shadow generator allowing fluent coding.
  28977. */
  28978. setDarkness(darkness: number): ShadowGenerator;
  28979. protected _transparencyShadow: boolean;
  28980. /** Gets or sets the ability to have transparent shadow */
  28981. get transparencyShadow(): boolean;
  28982. set transparencyShadow(value: boolean);
  28983. /**
  28984. * Sets the ability to have transparent shadow (boolean).
  28985. * @param transparent True if transparent else False
  28986. * @returns the shadow generator allowing fluent coding
  28987. */
  28988. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  28989. /**
  28990. * Enables or disables shadows with varying strength based on the transparency
  28991. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  28992. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  28993. * mesh.visibility * alphaTexture.a
  28994. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  28995. */
  28996. enableSoftTransparentShadow: boolean;
  28997. protected _shadowMap: Nullable<RenderTargetTexture>;
  28998. protected _shadowMap2: Nullable<RenderTargetTexture>;
  28999. /**
  29000. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29001. * @returns The render target texture if present otherwise, null
  29002. */
  29003. getShadowMap(): Nullable<RenderTargetTexture>;
  29004. /**
  29005. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29006. * @returns The render target texture if the shadow map is present otherwise, null
  29007. */
  29008. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29009. /**
  29010. * Gets the class name of that object
  29011. * @returns "ShadowGenerator"
  29012. */
  29013. getClassName(): string;
  29014. /**
  29015. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29016. * @param mesh Mesh to add
  29017. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29018. * @returns the Shadow Generator itself
  29019. */
  29020. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29021. /**
  29022. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29023. * @param mesh Mesh to remove
  29024. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29025. * @returns the Shadow Generator itself
  29026. */
  29027. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29028. /**
  29029. * Controls the extent to which the shadows fade out at the edge of the frustum
  29030. */
  29031. frustumEdgeFalloff: number;
  29032. protected _light: IShadowLight;
  29033. /**
  29034. * Returns the associated light object.
  29035. * @returns the light generating the shadow
  29036. */
  29037. getLight(): IShadowLight;
  29038. /**
  29039. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29040. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29041. * It might on the other hand introduce peter panning.
  29042. */
  29043. forceBackFacesOnly: boolean;
  29044. protected _scene: Scene;
  29045. protected _lightDirection: Vector3;
  29046. protected _effect: Effect;
  29047. protected _viewMatrix: Matrix;
  29048. protected _projectionMatrix: Matrix;
  29049. protected _transformMatrix: Matrix;
  29050. protected _cachedPosition: Vector3;
  29051. protected _cachedDirection: Vector3;
  29052. protected _cachedDefines: string;
  29053. protected _currentRenderID: number;
  29054. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29055. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29056. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29057. protected _blurPostProcesses: PostProcess[];
  29058. protected _mapSize: number;
  29059. protected _currentFaceIndex: number;
  29060. protected _currentFaceIndexCache: number;
  29061. protected _textureType: number;
  29062. protected _defaultTextureMatrix: Matrix;
  29063. protected _storedUniqueId: Nullable<number>;
  29064. /** @hidden */
  29065. static _SceneComponentInitialization: (scene: Scene) => void;
  29066. /**
  29067. * Gets or sets the size of the texture what stores the shadows
  29068. */
  29069. get mapSize(): number;
  29070. set mapSize(size: number);
  29071. /**
  29072. * Creates a ShadowGenerator object.
  29073. * A ShadowGenerator is the required tool to use the shadows.
  29074. * Each light casting shadows needs to use its own ShadowGenerator.
  29075. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29076. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29077. * @param light The light object generating the shadows.
  29078. * @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.
  29079. */
  29080. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29081. protected _initializeGenerator(): void;
  29082. protected _createTargetRenderTexture(): void;
  29083. protected _initializeShadowMap(): void;
  29084. protected _initializeBlurRTTAndPostProcesses(): void;
  29085. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29086. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29087. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29088. protected _applyFilterValues(): void;
  29089. /**
  29090. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29091. * @param onCompiled Callback triggered at the and of the effects compilation
  29092. * @param options Sets of optional options forcing the compilation with different modes
  29093. */
  29094. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29095. useInstances: boolean;
  29096. }>): void;
  29097. /**
  29098. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29099. * @param options Sets of optional options forcing the compilation with different modes
  29100. * @returns A promise that resolves when the compilation completes
  29101. */
  29102. forceCompilationAsync(options?: Partial<{
  29103. useInstances: boolean;
  29104. }>): Promise<void>;
  29105. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29106. private _prepareShadowDefines;
  29107. /**
  29108. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29109. * @param subMesh The submesh we want to render in the shadow map
  29110. * @param useInstances Defines wether will draw in the map using instances
  29111. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29112. * @returns true if ready otherwise, false
  29113. */
  29114. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29115. /**
  29116. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29117. * @param defines Defines of the material we want to update
  29118. * @param lightIndex Index of the light in the enabled light list of the material
  29119. */
  29120. prepareDefines(defines: any, lightIndex: number): void;
  29121. /**
  29122. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29123. * defined in the generator but impacting the effect).
  29124. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29125. * @param effect The effect we are binfing the information for
  29126. */
  29127. bindShadowLight(lightIndex: string, effect: Effect): void;
  29128. /**
  29129. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29130. * (eq to shadow prjection matrix * light transform matrix)
  29131. * @returns The transform matrix used to create the shadow map
  29132. */
  29133. getTransformMatrix(): Matrix;
  29134. /**
  29135. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29136. * Cube and 2D textures for instance.
  29137. */
  29138. recreateShadowMap(): void;
  29139. protected _disposeBlurPostProcesses(): void;
  29140. protected _disposeRTTandPostProcesses(): void;
  29141. /**
  29142. * Disposes the ShadowGenerator.
  29143. * Returns nothing.
  29144. */
  29145. dispose(): void;
  29146. /**
  29147. * Serializes the shadow generator setup to a json object.
  29148. * @returns The serialized JSON object
  29149. */
  29150. serialize(): any;
  29151. /**
  29152. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29153. * @param parsedShadowGenerator The JSON object to parse
  29154. * @param scene The scene to create the shadow map for
  29155. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29156. * @returns The parsed shadow generator
  29157. */
  29158. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29159. }
  29160. }
  29161. declare module BABYLON {
  29162. /**
  29163. * Options to be used when creating a shadow depth material
  29164. */
  29165. export interface IIOptionShadowDepthMaterial {
  29166. /** Variables in the vertex shader code that need to have their names remapped.
  29167. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29168. * "var_name" should be either: worldPos or vNormalW
  29169. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29170. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29171. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29172. */
  29173. remappedVariables?: string[];
  29174. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29175. standalone?: boolean;
  29176. }
  29177. /**
  29178. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29179. */
  29180. export class ShadowDepthWrapper {
  29181. private _scene;
  29182. private _options?;
  29183. private _baseMaterial;
  29184. private _onEffectCreatedObserver;
  29185. private _subMeshToEffect;
  29186. private _subMeshToDepthEffect;
  29187. private _meshes;
  29188. /** @hidden */
  29189. _matriceNames: any;
  29190. /** Gets the standalone status of the wrapper */
  29191. get standalone(): boolean;
  29192. /** Gets the base material the wrapper is built upon */
  29193. get baseMaterial(): Material;
  29194. /**
  29195. * Instantiate a new shadow depth wrapper.
  29196. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29197. * generate the shadow depth map. For more information, please refer to the documentation:
  29198. * https://doc.babylonjs.com/babylon101/shadows
  29199. * @param baseMaterial Material to wrap
  29200. * @param scene Define the scene the material belongs to
  29201. * @param options Options used to create the wrapper
  29202. */
  29203. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29204. /**
  29205. * Gets the effect to use to generate the depth map
  29206. * @param subMesh subMesh to get the effect for
  29207. * @param shadowGenerator shadow generator to get the effect for
  29208. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29209. */
  29210. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29211. /**
  29212. * Specifies that the submesh is ready to be used for depth rendering
  29213. * @param subMesh submesh to check
  29214. * @param defines the list of defines to take into account when checking the effect
  29215. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29216. * @param useInstances specifies that instances should be used
  29217. * @returns a boolean indicating that the submesh is ready or not
  29218. */
  29219. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29220. /**
  29221. * Disposes the resources
  29222. */
  29223. dispose(): void;
  29224. private _makeEffect;
  29225. }
  29226. }
  29227. declare module BABYLON {
  29228. /**
  29229. * Options for compiling materials.
  29230. */
  29231. export interface IMaterialCompilationOptions {
  29232. /**
  29233. * Defines whether clip planes are enabled.
  29234. */
  29235. clipPlane: boolean;
  29236. /**
  29237. * Defines whether instances are enabled.
  29238. */
  29239. useInstances: boolean;
  29240. }
  29241. /**
  29242. * Options passed when calling customShaderNameResolve
  29243. */
  29244. export interface ICustomShaderNameResolveOptions {
  29245. /**
  29246. * 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
  29247. */
  29248. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29249. }
  29250. /**
  29251. * Base class for the main features of a material in Babylon.js
  29252. */
  29253. export class Material implements IAnimatable {
  29254. /**
  29255. * Returns the triangle fill mode
  29256. */
  29257. static readonly TriangleFillMode: number;
  29258. /**
  29259. * Returns the wireframe mode
  29260. */
  29261. static readonly WireFrameFillMode: number;
  29262. /**
  29263. * Returns the point fill mode
  29264. */
  29265. static readonly PointFillMode: number;
  29266. /**
  29267. * Returns the point list draw mode
  29268. */
  29269. static readonly PointListDrawMode: number;
  29270. /**
  29271. * Returns the line list draw mode
  29272. */
  29273. static readonly LineListDrawMode: number;
  29274. /**
  29275. * Returns the line loop draw mode
  29276. */
  29277. static readonly LineLoopDrawMode: number;
  29278. /**
  29279. * Returns the line strip draw mode
  29280. */
  29281. static readonly LineStripDrawMode: number;
  29282. /**
  29283. * Returns the triangle strip draw mode
  29284. */
  29285. static readonly TriangleStripDrawMode: number;
  29286. /**
  29287. * Returns the triangle fan draw mode
  29288. */
  29289. static readonly TriangleFanDrawMode: number;
  29290. /**
  29291. * Stores the clock-wise side orientation
  29292. */
  29293. static readonly ClockWiseSideOrientation: number;
  29294. /**
  29295. * Stores the counter clock-wise side orientation
  29296. */
  29297. static readonly CounterClockWiseSideOrientation: number;
  29298. /**
  29299. * The dirty texture flag value
  29300. */
  29301. static readonly TextureDirtyFlag: number;
  29302. /**
  29303. * The dirty light flag value
  29304. */
  29305. static readonly LightDirtyFlag: number;
  29306. /**
  29307. * The dirty fresnel flag value
  29308. */
  29309. static readonly FresnelDirtyFlag: number;
  29310. /**
  29311. * The dirty attribute flag value
  29312. */
  29313. static readonly AttributesDirtyFlag: number;
  29314. /**
  29315. * The dirty misc flag value
  29316. */
  29317. static readonly MiscDirtyFlag: number;
  29318. /**
  29319. * The dirty prepass flag value
  29320. */
  29321. static readonly PrePassDirtyFlag: number;
  29322. /**
  29323. * The all dirty flag value
  29324. */
  29325. static readonly AllDirtyFlag: number;
  29326. /**
  29327. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29328. */
  29329. static readonly MATERIAL_OPAQUE: number;
  29330. /**
  29331. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29332. */
  29333. static readonly MATERIAL_ALPHATEST: number;
  29334. /**
  29335. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29336. */
  29337. static readonly MATERIAL_ALPHABLEND: number;
  29338. /**
  29339. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29340. * They are also discarded below the alpha cutoff threshold to improve performances.
  29341. */
  29342. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29343. /**
  29344. * The Whiteout method is used to blend normals.
  29345. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29346. */
  29347. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29348. /**
  29349. * The Reoriented Normal Mapping method is used to blend normals.
  29350. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29351. */
  29352. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29353. /**
  29354. * Custom callback helping to override the default shader used in the material.
  29355. */
  29356. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29357. /**
  29358. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29359. */
  29360. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29361. /**
  29362. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29363. * This means that the material can keep using a previous shader while a new one is being compiled.
  29364. * This is mostly used when shader parallel compilation is supported (true by default)
  29365. */
  29366. allowShaderHotSwapping: boolean;
  29367. /**
  29368. * The ID of the material
  29369. */
  29370. id: string;
  29371. /**
  29372. * Gets or sets the unique id of the material
  29373. */
  29374. uniqueId: number;
  29375. /**
  29376. * The name of the material
  29377. */
  29378. name: string;
  29379. /**
  29380. * Gets or sets user defined metadata
  29381. */
  29382. metadata: any;
  29383. /**
  29384. * For internal use only. Please do not use.
  29385. */
  29386. reservedDataStore: any;
  29387. /**
  29388. * Specifies if the ready state should be checked on each call
  29389. */
  29390. checkReadyOnEveryCall: boolean;
  29391. /**
  29392. * Specifies if the ready state should be checked once
  29393. */
  29394. checkReadyOnlyOnce: boolean;
  29395. /**
  29396. * The state of the material
  29397. */
  29398. state: string;
  29399. /**
  29400. * If the material can be rendered to several textures with MRT extension
  29401. */
  29402. get canRenderToMRT(): boolean;
  29403. /**
  29404. * The alpha value of the material
  29405. */
  29406. protected _alpha: number;
  29407. /**
  29408. * List of inspectable custom properties (used by the Inspector)
  29409. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29410. */
  29411. inspectableCustomProperties: IInspectable[];
  29412. /**
  29413. * Sets the alpha value of the material
  29414. */
  29415. set alpha(value: number);
  29416. /**
  29417. * Gets the alpha value of the material
  29418. */
  29419. get alpha(): number;
  29420. /**
  29421. * Specifies if back face culling is enabled
  29422. */
  29423. protected _backFaceCulling: boolean;
  29424. /**
  29425. * Sets the back-face culling state
  29426. */
  29427. set backFaceCulling(value: boolean);
  29428. /**
  29429. * Gets the back-face culling state
  29430. */
  29431. get backFaceCulling(): boolean;
  29432. /**
  29433. * Stores the value for side orientation
  29434. */
  29435. sideOrientation: number;
  29436. /**
  29437. * Callback triggered when the material is compiled
  29438. */
  29439. onCompiled: Nullable<(effect: Effect) => void>;
  29440. /**
  29441. * Callback triggered when an error occurs
  29442. */
  29443. onError: Nullable<(effect: Effect, errors: string) => void>;
  29444. /**
  29445. * Callback triggered to get the render target textures
  29446. */
  29447. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29448. /**
  29449. * Gets a boolean indicating that current material needs to register RTT
  29450. */
  29451. get hasRenderTargetTextures(): boolean;
  29452. /**
  29453. * Specifies if the material should be serialized
  29454. */
  29455. doNotSerialize: boolean;
  29456. /**
  29457. * @hidden
  29458. */
  29459. _storeEffectOnSubMeshes: boolean;
  29460. /**
  29461. * Stores the animations for the material
  29462. */
  29463. animations: Nullable<Array<Animation>>;
  29464. /**
  29465. * An event triggered when the material is disposed
  29466. */
  29467. onDisposeObservable: Observable<Material>;
  29468. /**
  29469. * An observer which watches for dispose events
  29470. */
  29471. private _onDisposeObserver;
  29472. private _onUnBindObservable;
  29473. /**
  29474. * Called during a dispose event
  29475. */
  29476. set onDispose(callback: () => void);
  29477. private _onBindObservable;
  29478. /**
  29479. * An event triggered when the material is bound
  29480. */
  29481. get onBindObservable(): Observable<AbstractMesh>;
  29482. /**
  29483. * An observer which watches for bind events
  29484. */
  29485. private _onBindObserver;
  29486. /**
  29487. * Called during a bind event
  29488. */
  29489. set onBind(callback: (Mesh: AbstractMesh) => void);
  29490. /**
  29491. * An event triggered when the material is unbound
  29492. */
  29493. get onUnBindObservable(): Observable<Material>;
  29494. protected _onEffectCreatedObservable: Nullable<Observable<{
  29495. effect: Effect;
  29496. subMesh: Nullable<SubMesh>;
  29497. }>>;
  29498. /**
  29499. * An event triggered when the effect is (re)created
  29500. */
  29501. get onEffectCreatedObservable(): Observable<{
  29502. effect: Effect;
  29503. subMesh: Nullable<SubMesh>;
  29504. }>;
  29505. /**
  29506. * Stores the value of the alpha mode
  29507. */
  29508. private _alphaMode;
  29509. /**
  29510. * Sets the value of the alpha mode.
  29511. *
  29512. * | Value | Type | Description |
  29513. * | --- | --- | --- |
  29514. * | 0 | ALPHA_DISABLE | |
  29515. * | 1 | ALPHA_ADD | |
  29516. * | 2 | ALPHA_COMBINE | |
  29517. * | 3 | ALPHA_SUBTRACT | |
  29518. * | 4 | ALPHA_MULTIPLY | |
  29519. * | 5 | ALPHA_MAXIMIZED | |
  29520. * | 6 | ALPHA_ONEONE | |
  29521. * | 7 | ALPHA_PREMULTIPLIED | |
  29522. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29523. * | 9 | ALPHA_INTERPOLATE | |
  29524. * | 10 | ALPHA_SCREENMODE | |
  29525. *
  29526. */
  29527. set alphaMode(value: number);
  29528. /**
  29529. * Gets the value of the alpha mode
  29530. */
  29531. get alphaMode(): number;
  29532. /**
  29533. * Stores the state of the need depth pre-pass value
  29534. */
  29535. private _needDepthPrePass;
  29536. /**
  29537. * Sets the need depth pre-pass value
  29538. */
  29539. set needDepthPrePass(value: boolean);
  29540. /**
  29541. * Gets the depth pre-pass value
  29542. */
  29543. get needDepthPrePass(): boolean;
  29544. /**
  29545. * Specifies if depth writing should be disabled
  29546. */
  29547. disableDepthWrite: boolean;
  29548. /**
  29549. * Specifies if color writing should be disabled
  29550. */
  29551. disableColorWrite: boolean;
  29552. /**
  29553. * Specifies if depth writing should be forced
  29554. */
  29555. forceDepthWrite: boolean;
  29556. /**
  29557. * Specifies the depth function that should be used. 0 means the default engine function
  29558. */
  29559. depthFunction: number;
  29560. /**
  29561. * Specifies if there should be a separate pass for culling
  29562. */
  29563. separateCullingPass: boolean;
  29564. /**
  29565. * Stores the state specifing if fog should be enabled
  29566. */
  29567. private _fogEnabled;
  29568. /**
  29569. * Sets the state for enabling fog
  29570. */
  29571. set fogEnabled(value: boolean);
  29572. /**
  29573. * Gets the value of the fog enabled state
  29574. */
  29575. get fogEnabled(): boolean;
  29576. /**
  29577. * Stores the size of points
  29578. */
  29579. pointSize: number;
  29580. /**
  29581. * Stores the z offset value
  29582. */
  29583. zOffset: number;
  29584. get wireframe(): boolean;
  29585. /**
  29586. * Sets the state of wireframe mode
  29587. */
  29588. set wireframe(value: boolean);
  29589. /**
  29590. * Gets the value specifying if point clouds are enabled
  29591. */
  29592. get pointsCloud(): boolean;
  29593. /**
  29594. * Sets the state of point cloud mode
  29595. */
  29596. set pointsCloud(value: boolean);
  29597. /**
  29598. * Gets the material fill mode
  29599. */
  29600. get fillMode(): number;
  29601. /**
  29602. * Sets the material fill mode
  29603. */
  29604. set fillMode(value: number);
  29605. /**
  29606. * @hidden
  29607. * Stores the effects for the material
  29608. */
  29609. _effect: Nullable<Effect>;
  29610. /**
  29611. * Specifies if uniform buffers should be used
  29612. */
  29613. private _useUBO;
  29614. /**
  29615. * Stores a reference to the scene
  29616. */
  29617. private _scene;
  29618. /**
  29619. * Stores the fill mode state
  29620. */
  29621. private _fillMode;
  29622. /**
  29623. * Specifies if the depth write state should be cached
  29624. */
  29625. private _cachedDepthWriteState;
  29626. /**
  29627. * Specifies if the color write state should be cached
  29628. */
  29629. private _cachedColorWriteState;
  29630. /**
  29631. * Specifies if the depth function state should be cached
  29632. */
  29633. private _cachedDepthFunctionState;
  29634. /**
  29635. * Stores the uniform buffer
  29636. */
  29637. protected _uniformBuffer: UniformBuffer;
  29638. /** @hidden */
  29639. _indexInSceneMaterialArray: number;
  29640. /** @hidden */
  29641. meshMap: Nullable<{
  29642. [id: string]: AbstractMesh | undefined;
  29643. }>;
  29644. /**
  29645. * Creates a material instance
  29646. * @param name defines the name of the material
  29647. * @param scene defines the scene to reference
  29648. * @param doNotAdd specifies if the material should be added to the scene
  29649. */
  29650. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29651. /**
  29652. * Returns a string representation of the current material
  29653. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29654. * @returns a string with material information
  29655. */
  29656. toString(fullDetails?: boolean): string;
  29657. /**
  29658. * Gets the class name of the material
  29659. * @returns a string with the class name of the material
  29660. */
  29661. getClassName(): string;
  29662. /**
  29663. * Specifies if updates for the material been locked
  29664. */
  29665. get isFrozen(): boolean;
  29666. /**
  29667. * Locks updates for the material
  29668. */
  29669. freeze(): void;
  29670. /**
  29671. * Unlocks updates for the material
  29672. */
  29673. unfreeze(): void;
  29674. /**
  29675. * Specifies if the material is ready to be used
  29676. * @param mesh defines the mesh to check
  29677. * @param useInstances specifies if instances should be used
  29678. * @returns a boolean indicating if the material is ready to be used
  29679. */
  29680. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29681. /**
  29682. * Specifies that the submesh is ready to be used
  29683. * @param mesh defines the mesh to check
  29684. * @param subMesh defines which submesh to check
  29685. * @param useInstances specifies that instances should be used
  29686. * @returns a boolean indicating that the submesh is ready or not
  29687. */
  29688. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29689. /**
  29690. * Returns the material effect
  29691. * @returns the effect associated with the material
  29692. */
  29693. getEffect(): Nullable<Effect>;
  29694. /**
  29695. * Returns the current scene
  29696. * @returns a Scene
  29697. */
  29698. getScene(): Scene;
  29699. /**
  29700. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29701. */
  29702. protected _forceAlphaTest: boolean;
  29703. /**
  29704. * The transparency mode of the material.
  29705. */
  29706. protected _transparencyMode: Nullable<number>;
  29707. /**
  29708. * Gets the current transparency mode.
  29709. */
  29710. get transparencyMode(): Nullable<number>;
  29711. /**
  29712. * Sets the transparency mode of the material.
  29713. *
  29714. * | Value | Type | Description |
  29715. * | ----- | ----------------------------------- | ----------- |
  29716. * | 0 | OPAQUE | |
  29717. * | 1 | ALPHATEST | |
  29718. * | 2 | ALPHABLEND | |
  29719. * | 3 | ALPHATESTANDBLEND | |
  29720. *
  29721. */
  29722. set transparencyMode(value: Nullable<number>);
  29723. /**
  29724. * Returns true if alpha blending should be disabled.
  29725. */
  29726. protected get _disableAlphaBlending(): boolean;
  29727. /**
  29728. * Specifies whether or not this material should be rendered in alpha blend mode.
  29729. * @returns a boolean specifying if alpha blending is needed
  29730. */
  29731. needAlphaBlending(): boolean;
  29732. /**
  29733. * Specifies if the mesh will require alpha blending
  29734. * @param mesh defines the mesh to check
  29735. * @returns a boolean specifying if alpha blending is needed for the mesh
  29736. */
  29737. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29738. /**
  29739. * Specifies whether or not this material should be rendered in alpha test mode.
  29740. * @returns a boolean specifying if an alpha test is needed.
  29741. */
  29742. needAlphaTesting(): boolean;
  29743. /**
  29744. * Specifies if material alpha testing should be turned on for the mesh
  29745. * @param mesh defines the mesh to check
  29746. */
  29747. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29748. /**
  29749. * Gets the texture used for the alpha test
  29750. * @returns the texture to use for alpha testing
  29751. */
  29752. getAlphaTestTexture(): Nullable<BaseTexture>;
  29753. /**
  29754. * Marks the material to indicate that it needs to be re-calculated
  29755. */
  29756. markDirty(): void;
  29757. /** @hidden */
  29758. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29759. /**
  29760. * Binds the material to the mesh
  29761. * @param world defines the world transformation matrix
  29762. * @param mesh defines the mesh to bind the material to
  29763. */
  29764. bind(world: Matrix, mesh?: Mesh): void;
  29765. /**
  29766. * Binds the submesh to the material
  29767. * @param world defines the world transformation matrix
  29768. * @param mesh defines the mesh containing the submesh
  29769. * @param subMesh defines the submesh to bind the material to
  29770. */
  29771. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29772. /**
  29773. * Binds the world matrix to the material
  29774. * @param world defines the world transformation matrix
  29775. */
  29776. bindOnlyWorldMatrix(world: Matrix): void;
  29777. /**
  29778. * Binds the scene's uniform buffer to the effect.
  29779. * @param effect defines the effect to bind to the scene uniform buffer
  29780. * @param sceneUbo defines the uniform buffer storing scene data
  29781. */
  29782. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29783. /**
  29784. * Binds the view matrix to the effect
  29785. * @param effect defines the effect to bind the view matrix to
  29786. */
  29787. bindView(effect: Effect): void;
  29788. /**
  29789. * Binds the view projection matrix to the effect
  29790. * @param effect defines the effect to bind the view projection matrix to
  29791. */
  29792. bindViewProjection(effect: Effect): void;
  29793. /**
  29794. * Processes to execute after binding the material to a mesh
  29795. * @param mesh defines the rendered mesh
  29796. */
  29797. protected _afterBind(mesh?: Mesh): void;
  29798. /**
  29799. * Unbinds the material from the mesh
  29800. */
  29801. unbind(): void;
  29802. /**
  29803. * Gets the active textures from the material
  29804. * @returns an array of textures
  29805. */
  29806. getActiveTextures(): BaseTexture[];
  29807. /**
  29808. * Specifies if the material uses a texture
  29809. * @param texture defines the texture to check against the material
  29810. * @returns a boolean specifying if the material uses the texture
  29811. */
  29812. hasTexture(texture: BaseTexture): boolean;
  29813. /**
  29814. * Makes a duplicate of the material, and gives it a new name
  29815. * @param name defines the new name for the duplicated material
  29816. * @returns the cloned material
  29817. */
  29818. clone(name: string): Nullable<Material>;
  29819. /**
  29820. * Gets the meshes bound to the material
  29821. * @returns an array of meshes bound to the material
  29822. */
  29823. getBindedMeshes(): AbstractMesh[];
  29824. /**
  29825. * Force shader compilation
  29826. * @param mesh defines the mesh associated with this material
  29827. * @param onCompiled defines a function to execute once the material is compiled
  29828. * @param options defines the options to configure the compilation
  29829. * @param onError defines a function to execute if the material fails compiling
  29830. */
  29831. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29832. /**
  29833. * Force shader compilation
  29834. * @param mesh defines the mesh that will use this material
  29835. * @param options defines additional options for compiling the shaders
  29836. * @returns a promise that resolves when the compilation completes
  29837. */
  29838. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29839. private static readonly _AllDirtyCallBack;
  29840. private static readonly _ImageProcessingDirtyCallBack;
  29841. private static readonly _TextureDirtyCallBack;
  29842. private static readonly _FresnelDirtyCallBack;
  29843. private static readonly _MiscDirtyCallBack;
  29844. private static readonly _PrePassDirtyCallBack;
  29845. private static readonly _LightsDirtyCallBack;
  29846. private static readonly _AttributeDirtyCallBack;
  29847. private static _FresnelAndMiscDirtyCallBack;
  29848. private static _TextureAndMiscDirtyCallBack;
  29849. private static readonly _DirtyCallbackArray;
  29850. private static readonly _RunDirtyCallBacks;
  29851. /**
  29852. * Marks a define in the material to indicate that it needs to be re-computed
  29853. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29854. */
  29855. markAsDirty(flag: number): void;
  29856. /**
  29857. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29858. * @param func defines a function which checks material defines against the submeshes
  29859. */
  29860. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29861. /**
  29862. * Indicates that the scene should check if the rendering now needs a prepass
  29863. */
  29864. protected _markScenePrePassDirty(): void;
  29865. /**
  29866. * Indicates that we need to re-calculated for all submeshes
  29867. */
  29868. protected _markAllSubMeshesAsAllDirty(): void;
  29869. /**
  29870. * Indicates that image processing needs to be re-calculated for all submeshes
  29871. */
  29872. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29873. /**
  29874. * Indicates that textures need to be re-calculated for all submeshes
  29875. */
  29876. protected _markAllSubMeshesAsTexturesDirty(): void;
  29877. /**
  29878. * Indicates that fresnel needs to be re-calculated for all submeshes
  29879. */
  29880. protected _markAllSubMeshesAsFresnelDirty(): void;
  29881. /**
  29882. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29883. */
  29884. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29885. /**
  29886. * Indicates that lights need to be re-calculated for all submeshes
  29887. */
  29888. protected _markAllSubMeshesAsLightsDirty(): void;
  29889. /**
  29890. * Indicates that attributes need to be re-calculated for all submeshes
  29891. */
  29892. protected _markAllSubMeshesAsAttributesDirty(): void;
  29893. /**
  29894. * Indicates that misc needs to be re-calculated for all submeshes
  29895. */
  29896. protected _markAllSubMeshesAsMiscDirty(): void;
  29897. /**
  29898. * Indicates that prepass needs to be re-calculated for all submeshes
  29899. */
  29900. protected _markAllSubMeshesAsPrePassDirty(): void;
  29901. /**
  29902. * Indicates that textures and misc need to be re-calculated for all submeshes
  29903. */
  29904. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29905. /**
  29906. * Sets the required values to the prepass renderer.
  29907. * @param prePassRenderer defines the prepass renderer to setup.
  29908. * @returns true if the pre pass is needed.
  29909. */
  29910. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29911. /**
  29912. * Disposes the material
  29913. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29914. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29915. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29916. */
  29917. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29918. /** @hidden */
  29919. private releaseVertexArrayObject;
  29920. /**
  29921. * Serializes this material
  29922. * @returns the serialized material object
  29923. */
  29924. serialize(): any;
  29925. /**
  29926. * Creates a material from parsed material data
  29927. * @param parsedMaterial defines parsed material data
  29928. * @param scene defines the hosting scene
  29929. * @param rootUrl defines the root URL to use to load textures
  29930. * @returns a new material
  29931. */
  29932. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29933. }
  29934. }
  29935. declare module BABYLON {
  29936. /**
  29937. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29938. * separate meshes. This can be use to improve performances.
  29939. * @see https://doc.babylonjs.com/how_to/multi_materials
  29940. */
  29941. export class MultiMaterial extends Material {
  29942. private _subMaterials;
  29943. /**
  29944. * Gets or Sets the list of Materials used within the multi material.
  29945. * They need to be ordered according to the submeshes order in the associated mesh
  29946. */
  29947. get subMaterials(): Nullable<Material>[];
  29948. set subMaterials(value: Nullable<Material>[]);
  29949. /**
  29950. * Function used to align with Node.getChildren()
  29951. * @returns the list of Materials used within the multi material
  29952. */
  29953. getChildren(): Nullable<Material>[];
  29954. /**
  29955. * Instantiates a new Multi Material
  29956. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29957. * separate meshes. This can be use to improve performances.
  29958. * @see https://doc.babylonjs.com/how_to/multi_materials
  29959. * @param name Define the name in the scene
  29960. * @param scene Define the scene the material belongs to
  29961. */
  29962. constructor(name: string, scene: Scene);
  29963. private _hookArray;
  29964. /**
  29965. * Get one of the submaterial by its index in the submaterials array
  29966. * @param index The index to look the sub material at
  29967. * @returns The Material if the index has been defined
  29968. */
  29969. getSubMaterial(index: number): Nullable<Material>;
  29970. /**
  29971. * Get the list of active textures for the whole sub materials list.
  29972. * @returns All the textures that will be used during the rendering
  29973. */
  29974. getActiveTextures(): BaseTexture[];
  29975. /**
  29976. * Gets the current class name of the material e.g. "MultiMaterial"
  29977. * Mainly use in serialization.
  29978. * @returns the class name
  29979. */
  29980. getClassName(): string;
  29981. /**
  29982. * Checks if the material is ready to render the requested sub mesh
  29983. * @param mesh Define the mesh the submesh belongs to
  29984. * @param subMesh Define the sub mesh to look readyness for
  29985. * @param useInstances Define whether or not the material is used with instances
  29986. * @returns true if ready, otherwise false
  29987. */
  29988. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29989. /**
  29990. * Clones the current material and its related sub materials
  29991. * @param name Define the name of the newly cloned material
  29992. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29993. * @returns the cloned material
  29994. */
  29995. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29996. /**
  29997. * Serializes the materials into a JSON representation.
  29998. * @returns the JSON representation
  29999. */
  30000. serialize(): any;
  30001. /**
  30002. * Dispose the material and release its associated resources
  30003. * @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)
  30004. * @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)
  30005. * @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)
  30006. */
  30007. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30008. /**
  30009. * Creates a MultiMaterial from parsed MultiMaterial data.
  30010. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30011. * @param scene defines the hosting scene
  30012. * @returns a new MultiMaterial
  30013. */
  30014. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30015. }
  30016. }
  30017. declare module BABYLON {
  30018. /**
  30019. * Defines a subdivision inside a mesh
  30020. */
  30021. export class SubMesh implements ICullable {
  30022. /** the material index to use */
  30023. materialIndex: number;
  30024. /** vertex index start */
  30025. verticesStart: number;
  30026. /** vertices count */
  30027. verticesCount: number;
  30028. /** index start */
  30029. indexStart: number;
  30030. /** indices count */
  30031. indexCount: number;
  30032. /** @hidden */
  30033. _materialDefines: Nullable<MaterialDefines>;
  30034. /** @hidden */
  30035. _materialEffect: Nullable<Effect>;
  30036. /** @hidden */
  30037. _effectOverride: Nullable<Effect>;
  30038. /**
  30039. * Gets material defines used by the effect associated to the sub mesh
  30040. */
  30041. get materialDefines(): Nullable<MaterialDefines>;
  30042. /**
  30043. * Sets material defines used by the effect associated to the sub mesh
  30044. */
  30045. set materialDefines(defines: Nullable<MaterialDefines>);
  30046. /**
  30047. * Gets associated effect
  30048. */
  30049. get effect(): Nullable<Effect>;
  30050. /**
  30051. * Sets associated effect (effect used to render this submesh)
  30052. * @param effect defines the effect to associate with
  30053. * @param defines defines the set of defines used to compile this effect
  30054. */
  30055. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30056. /** @hidden */
  30057. _linesIndexCount: number;
  30058. private _mesh;
  30059. private _renderingMesh;
  30060. private _boundingInfo;
  30061. private _linesIndexBuffer;
  30062. /** @hidden */
  30063. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30064. /** @hidden */
  30065. _trianglePlanes: Plane[];
  30066. /** @hidden */
  30067. _lastColliderTransformMatrix: Nullable<Matrix>;
  30068. /** @hidden */
  30069. _renderId: number;
  30070. /** @hidden */
  30071. _alphaIndex: number;
  30072. /** @hidden */
  30073. _distanceToCamera: number;
  30074. /** @hidden */
  30075. _id: number;
  30076. private _currentMaterial;
  30077. /**
  30078. * Add a new submesh to a mesh
  30079. * @param materialIndex defines the material index to use
  30080. * @param verticesStart defines vertex index start
  30081. * @param verticesCount defines vertices count
  30082. * @param indexStart defines index start
  30083. * @param indexCount defines indices count
  30084. * @param mesh defines the parent mesh
  30085. * @param renderingMesh defines an optional rendering mesh
  30086. * @param createBoundingBox defines if bounding box should be created for this submesh
  30087. * @returns the new submesh
  30088. */
  30089. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30090. /**
  30091. * Creates a new submesh
  30092. * @param materialIndex defines the material index to use
  30093. * @param verticesStart defines vertex index start
  30094. * @param verticesCount defines vertices count
  30095. * @param indexStart defines index start
  30096. * @param indexCount defines indices count
  30097. * @param mesh defines the parent mesh
  30098. * @param renderingMesh defines an optional rendering mesh
  30099. * @param createBoundingBox defines if bounding box should be created for this submesh
  30100. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30101. */
  30102. constructor(
  30103. /** the material index to use */
  30104. materialIndex: number,
  30105. /** vertex index start */
  30106. verticesStart: number,
  30107. /** vertices count */
  30108. verticesCount: number,
  30109. /** index start */
  30110. indexStart: number,
  30111. /** indices count */
  30112. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30113. /**
  30114. * Returns true if this submesh covers the entire parent mesh
  30115. * @ignorenaming
  30116. */
  30117. get IsGlobal(): boolean;
  30118. /**
  30119. * Returns the submesh BoudingInfo object
  30120. * @returns current bounding info (or mesh's one if the submesh is global)
  30121. */
  30122. getBoundingInfo(): BoundingInfo;
  30123. /**
  30124. * Sets the submesh BoundingInfo
  30125. * @param boundingInfo defines the new bounding info to use
  30126. * @returns the SubMesh
  30127. */
  30128. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30129. /**
  30130. * Returns the mesh of the current submesh
  30131. * @return the parent mesh
  30132. */
  30133. getMesh(): AbstractMesh;
  30134. /**
  30135. * Returns the rendering mesh of the submesh
  30136. * @returns the rendering mesh (could be different from parent mesh)
  30137. */
  30138. getRenderingMesh(): Mesh;
  30139. /**
  30140. * Returns the replacement mesh of the submesh
  30141. * @returns the replacement mesh (could be different from parent mesh)
  30142. */
  30143. getReplacementMesh(): Nullable<AbstractMesh>;
  30144. /**
  30145. * Returns the effective mesh of the submesh
  30146. * @returns the effective mesh (could be different from parent mesh)
  30147. */
  30148. getEffectiveMesh(): AbstractMesh;
  30149. /**
  30150. * Returns the submesh material
  30151. * @returns null or the current material
  30152. */
  30153. getMaterial(): Nullable<Material>;
  30154. private _IsMultiMaterial;
  30155. /**
  30156. * Sets a new updated BoundingInfo object to the submesh
  30157. * @param data defines an optional position array to use to determine the bounding info
  30158. * @returns the SubMesh
  30159. */
  30160. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30161. /** @hidden */
  30162. _checkCollision(collider: Collider): boolean;
  30163. /**
  30164. * Updates the submesh BoundingInfo
  30165. * @param world defines the world matrix to use to update the bounding info
  30166. * @returns the submesh
  30167. */
  30168. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30169. /**
  30170. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30171. * @param frustumPlanes defines the frustum planes
  30172. * @returns true if the submesh is intersecting with the frustum
  30173. */
  30174. isInFrustum(frustumPlanes: Plane[]): boolean;
  30175. /**
  30176. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30177. * @param frustumPlanes defines the frustum planes
  30178. * @returns true if the submesh is inside the frustum
  30179. */
  30180. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30181. /**
  30182. * Renders the submesh
  30183. * @param enableAlphaMode defines if alpha needs to be used
  30184. * @returns the submesh
  30185. */
  30186. render(enableAlphaMode: boolean): SubMesh;
  30187. /**
  30188. * @hidden
  30189. */
  30190. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30191. /**
  30192. * Checks if the submesh intersects with a ray
  30193. * @param ray defines the ray to test
  30194. * @returns true is the passed ray intersects the submesh bounding box
  30195. */
  30196. canIntersects(ray: Ray): boolean;
  30197. /**
  30198. * Intersects current submesh with a ray
  30199. * @param ray defines the ray to test
  30200. * @param positions defines mesh's positions array
  30201. * @param indices defines mesh's indices array
  30202. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30203. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30204. * @returns intersection info or null if no intersection
  30205. */
  30206. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30207. /** @hidden */
  30208. private _intersectLines;
  30209. /** @hidden */
  30210. private _intersectUnIndexedLines;
  30211. /** @hidden */
  30212. private _intersectTriangles;
  30213. /** @hidden */
  30214. private _intersectUnIndexedTriangles;
  30215. /** @hidden */
  30216. _rebuild(): void;
  30217. /**
  30218. * Creates a new submesh from the passed mesh
  30219. * @param newMesh defines the new hosting mesh
  30220. * @param newRenderingMesh defines an optional rendering mesh
  30221. * @returns the new submesh
  30222. */
  30223. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30224. /**
  30225. * Release associated resources
  30226. */
  30227. dispose(): void;
  30228. /**
  30229. * Gets the class name
  30230. * @returns the string "SubMesh".
  30231. */
  30232. getClassName(): string;
  30233. /**
  30234. * Creates a new submesh from indices data
  30235. * @param materialIndex the index of the main mesh material
  30236. * @param startIndex the index where to start the copy in the mesh indices array
  30237. * @param indexCount the number of indices to copy then from the startIndex
  30238. * @param mesh the main mesh to create the submesh from
  30239. * @param renderingMesh the optional rendering mesh
  30240. * @returns a new submesh
  30241. */
  30242. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30243. }
  30244. }
  30245. declare module BABYLON {
  30246. /**
  30247. * Class used to represent data loading progression
  30248. */
  30249. export class SceneLoaderFlags {
  30250. private static _ForceFullSceneLoadingForIncremental;
  30251. private static _ShowLoadingScreen;
  30252. private static _CleanBoneMatrixWeights;
  30253. private static _loggingLevel;
  30254. /**
  30255. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30256. */
  30257. static get ForceFullSceneLoadingForIncremental(): boolean;
  30258. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30259. /**
  30260. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30261. */
  30262. static get ShowLoadingScreen(): boolean;
  30263. static set ShowLoadingScreen(value: boolean);
  30264. /**
  30265. * Defines the current logging level (while loading the scene)
  30266. * @ignorenaming
  30267. */
  30268. static get loggingLevel(): number;
  30269. static set loggingLevel(value: number);
  30270. /**
  30271. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30272. */
  30273. static get CleanBoneMatrixWeights(): boolean;
  30274. static set CleanBoneMatrixWeights(value: boolean);
  30275. }
  30276. }
  30277. declare module BABYLON {
  30278. /**
  30279. * Class used to store geometry data (vertex buffers + index buffer)
  30280. */
  30281. export class Geometry implements IGetSetVerticesData {
  30282. /**
  30283. * Gets or sets the ID of the geometry
  30284. */
  30285. id: string;
  30286. /**
  30287. * Gets or sets the unique ID of the geometry
  30288. */
  30289. uniqueId: number;
  30290. /**
  30291. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30292. */
  30293. delayLoadState: number;
  30294. /**
  30295. * Gets the file containing the data to load when running in delay load state
  30296. */
  30297. delayLoadingFile: Nullable<string>;
  30298. /**
  30299. * Callback called when the geometry is updated
  30300. */
  30301. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30302. private _scene;
  30303. private _engine;
  30304. private _meshes;
  30305. private _totalVertices;
  30306. /** @hidden */
  30307. _indices: IndicesArray;
  30308. /** @hidden */
  30309. _vertexBuffers: {
  30310. [key: string]: VertexBuffer;
  30311. };
  30312. private _isDisposed;
  30313. private _extend;
  30314. private _boundingBias;
  30315. /** @hidden */
  30316. _delayInfo: Array<string>;
  30317. private _indexBuffer;
  30318. private _indexBufferIsUpdatable;
  30319. /** @hidden */
  30320. _boundingInfo: Nullable<BoundingInfo>;
  30321. /** @hidden */
  30322. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30323. /** @hidden */
  30324. _softwareSkinningFrameId: number;
  30325. private _vertexArrayObjects;
  30326. private _updatable;
  30327. /** @hidden */
  30328. _positions: Nullable<Vector3[]>;
  30329. private _positionsCache;
  30330. /**
  30331. * 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
  30332. */
  30333. get boundingBias(): Vector2;
  30334. /**
  30335. * 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
  30336. */
  30337. set boundingBias(value: Vector2);
  30338. /**
  30339. * Static function used to attach a new empty geometry to a mesh
  30340. * @param mesh defines the mesh to attach the geometry to
  30341. * @returns the new Geometry
  30342. */
  30343. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30344. /** Get the list of meshes using this geometry */
  30345. get meshes(): Mesh[];
  30346. /**
  30347. * 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
  30348. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30349. */
  30350. useBoundingInfoFromGeometry: boolean;
  30351. /**
  30352. * Creates a new geometry
  30353. * @param id defines the unique ID
  30354. * @param scene defines the hosting scene
  30355. * @param vertexData defines the VertexData used to get geometry data
  30356. * @param updatable defines if geometry must be updatable (false by default)
  30357. * @param mesh defines the mesh that will be associated with the geometry
  30358. */
  30359. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30360. /**
  30361. * Gets the current extend of the geometry
  30362. */
  30363. get extend(): {
  30364. minimum: Vector3;
  30365. maximum: Vector3;
  30366. };
  30367. /**
  30368. * Gets the hosting scene
  30369. * @returns the hosting Scene
  30370. */
  30371. getScene(): Scene;
  30372. /**
  30373. * Gets the hosting engine
  30374. * @returns the hosting Engine
  30375. */
  30376. getEngine(): Engine;
  30377. /**
  30378. * Defines if the geometry is ready to use
  30379. * @returns true if the geometry is ready to be used
  30380. */
  30381. isReady(): boolean;
  30382. /**
  30383. * Gets a value indicating that the geometry should not be serialized
  30384. */
  30385. get doNotSerialize(): boolean;
  30386. /** @hidden */
  30387. _rebuild(): void;
  30388. /**
  30389. * Affects all geometry data in one call
  30390. * @param vertexData defines the geometry data
  30391. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30392. */
  30393. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30394. /**
  30395. * Set specific vertex data
  30396. * @param kind defines the data kind (Position, normal, etc...)
  30397. * @param data defines the vertex data to use
  30398. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30399. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30400. */
  30401. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30402. /**
  30403. * Removes a specific vertex data
  30404. * @param kind defines the data kind (Position, normal, etc...)
  30405. */
  30406. removeVerticesData(kind: string): void;
  30407. /**
  30408. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30409. * @param buffer defines the vertex buffer to use
  30410. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30411. */
  30412. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30413. /**
  30414. * Update a specific vertex buffer
  30415. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30416. * It will do nothing if the buffer is not updatable
  30417. * @param kind defines the data kind (Position, normal, etc...)
  30418. * @param data defines the data to use
  30419. * @param offset defines the offset in the target buffer where to store the data
  30420. * @param useBytes set to true if the offset is in bytes
  30421. */
  30422. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30423. /**
  30424. * Update a specific vertex buffer
  30425. * This function will create a new buffer if the current one is not updatable
  30426. * @param kind defines the data kind (Position, normal, etc...)
  30427. * @param data defines the data to use
  30428. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30429. */
  30430. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30431. private _updateBoundingInfo;
  30432. /** @hidden */
  30433. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30434. /**
  30435. * Gets total number of vertices
  30436. * @returns the total number of vertices
  30437. */
  30438. getTotalVertices(): number;
  30439. /**
  30440. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30441. * @param kind defines the data kind (Position, normal, etc...)
  30442. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30443. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30444. * @returns a float array containing vertex data
  30445. */
  30446. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30447. /**
  30448. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30449. * @param kind defines the data kind (Position, normal, etc...)
  30450. * @returns true if the vertex buffer with the specified kind is updatable
  30451. */
  30452. isVertexBufferUpdatable(kind: string): boolean;
  30453. /**
  30454. * Gets a specific vertex buffer
  30455. * @param kind defines the data kind (Position, normal, etc...)
  30456. * @returns a VertexBuffer
  30457. */
  30458. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30459. /**
  30460. * Returns all vertex buffers
  30461. * @return an object holding all vertex buffers indexed by kind
  30462. */
  30463. getVertexBuffers(): Nullable<{
  30464. [key: string]: VertexBuffer;
  30465. }>;
  30466. /**
  30467. * Gets a boolean indicating if specific vertex buffer is present
  30468. * @param kind defines the data kind (Position, normal, etc...)
  30469. * @returns true if data is present
  30470. */
  30471. isVerticesDataPresent(kind: string): boolean;
  30472. /**
  30473. * Gets a list of all attached data kinds (Position, normal, etc...)
  30474. * @returns a list of string containing all kinds
  30475. */
  30476. getVerticesDataKinds(): string[];
  30477. /**
  30478. * Update index buffer
  30479. * @param indices defines the indices to store in the index buffer
  30480. * @param offset defines the offset in the target buffer where to store the data
  30481. * @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)
  30482. */
  30483. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30484. /**
  30485. * Creates a new index buffer
  30486. * @param indices defines the indices to store in the index buffer
  30487. * @param totalVertices defines the total number of vertices (could be null)
  30488. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30489. */
  30490. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30491. /**
  30492. * Return the total number of indices
  30493. * @returns the total number of indices
  30494. */
  30495. getTotalIndices(): number;
  30496. /**
  30497. * Gets the index buffer array
  30498. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30499. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30500. * @returns the index buffer array
  30501. */
  30502. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30503. /**
  30504. * Gets the index buffer
  30505. * @return the index buffer
  30506. */
  30507. getIndexBuffer(): Nullable<DataBuffer>;
  30508. /** @hidden */
  30509. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30510. /**
  30511. * Release the associated resources for a specific mesh
  30512. * @param mesh defines the source mesh
  30513. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30514. */
  30515. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30516. /**
  30517. * Apply current geometry to a given mesh
  30518. * @param mesh defines the mesh to apply geometry to
  30519. */
  30520. applyToMesh(mesh: Mesh): void;
  30521. private _updateExtend;
  30522. private _applyToMesh;
  30523. private notifyUpdate;
  30524. /**
  30525. * Load the geometry if it was flagged as delay loaded
  30526. * @param scene defines the hosting scene
  30527. * @param onLoaded defines a callback called when the geometry is loaded
  30528. */
  30529. load(scene: Scene, onLoaded?: () => void): void;
  30530. private _queueLoad;
  30531. /**
  30532. * Invert the geometry to move from a right handed system to a left handed one.
  30533. */
  30534. toLeftHanded(): void;
  30535. /** @hidden */
  30536. _resetPointsArrayCache(): void;
  30537. /** @hidden */
  30538. _generatePointsArray(): boolean;
  30539. /**
  30540. * Gets a value indicating if the geometry is disposed
  30541. * @returns true if the geometry was disposed
  30542. */
  30543. isDisposed(): boolean;
  30544. private _disposeVertexArrayObjects;
  30545. /**
  30546. * Free all associated resources
  30547. */
  30548. dispose(): void;
  30549. /**
  30550. * Clone the current geometry into a new geometry
  30551. * @param id defines the unique ID of the new geometry
  30552. * @returns a new geometry object
  30553. */
  30554. copy(id: string): Geometry;
  30555. /**
  30556. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30557. * @return a JSON representation of the current geometry data (without the vertices data)
  30558. */
  30559. serialize(): any;
  30560. private toNumberArray;
  30561. /**
  30562. * Serialize all vertices data into a JSON oject
  30563. * @returns a JSON representation of the current geometry data
  30564. */
  30565. serializeVerticeData(): any;
  30566. /**
  30567. * Extracts a clone of a mesh geometry
  30568. * @param mesh defines the source mesh
  30569. * @param id defines the unique ID of the new geometry object
  30570. * @returns the new geometry object
  30571. */
  30572. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30573. /**
  30574. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30575. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30576. * Be aware Math.random() could cause collisions, but:
  30577. * "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"
  30578. * @returns a string containing a new GUID
  30579. */
  30580. static RandomId(): string;
  30581. /** @hidden */
  30582. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30583. private static _CleanMatricesWeights;
  30584. /**
  30585. * Create a new geometry from persisted data (Using .babylon file format)
  30586. * @param parsedVertexData defines the persisted data
  30587. * @param scene defines the hosting scene
  30588. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30589. * @returns the new geometry object
  30590. */
  30591. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30592. }
  30593. }
  30594. declare module BABYLON {
  30595. /**
  30596. * Defines a target to use with MorphTargetManager
  30597. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30598. */
  30599. export class MorphTarget implements IAnimatable {
  30600. /** defines the name of the target */
  30601. name: string;
  30602. /**
  30603. * Gets or sets the list of animations
  30604. */
  30605. animations: Animation[];
  30606. private _scene;
  30607. private _positions;
  30608. private _normals;
  30609. private _tangents;
  30610. private _uvs;
  30611. private _influence;
  30612. private _uniqueId;
  30613. /**
  30614. * Observable raised when the influence changes
  30615. */
  30616. onInfluenceChanged: Observable<boolean>;
  30617. /** @hidden */
  30618. _onDataLayoutChanged: Observable<void>;
  30619. /**
  30620. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30621. */
  30622. get influence(): number;
  30623. set influence(influence: number);
  30624. /**
  30625. * Gets or sets the id of the morph Target
  30626. */
  30627. id: string;
  30628. private _animationPropertiesOverride;
  30629. /**
  30630. * Gets or sets the animation properties override
  30631. */
  30632. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30633. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30634. /**
  30635. * Creates a new MorphTarget
  30636. * @param name defines the name of the target
  30637. * @param influence defines the influence to use
  30638. * @param scene defines the scene the morphtarget belongs to
  30639. */
  30640. constructor(
  30641. /** defines the name of the target */
  30642. name: string, influence?: number, scene?: Nullable<Scene>);
  30643. /**
  30644. * Gets the unique ID of this manager
  30645. */
  30646. get uniqueId(): number;
  30647. /**
  30648. * Gets a boolean defining if the target contains position data
  30649. */
  30650. get hasPositions(): boolean;
  30651. /**
  30652. * Gets a boolean defining if the target contains normal data
  30653. */
  30654. get hasNormals(): boolean;
  30655. /**
  30656. * Gets a boolean defining if the target contains tangent data
  30657. */
  30658. get hasTangents(): boolean;
  30659. /**
  30660. * Gets a boolean defining if the target contains texture coordinates data
  30661. */
  30662. get hasUVs(): boolean;
  30663. /**
  30664. * Affects position data to this target
  30665. * @param data defines the position data to use
  30666. */
  30667. setPositions(data: Nullable<FloatArray>): void;
  30668. /**
  30669. * Gets the position data stored in this target
  30670. * @returns a FloatArray containing the position data (or null if not present)
  30671. */
  30672. getPositions(): Nullable<FloatArray>;
  30673. /**
  30674. * Affects normal data to this target
  30675. * @param data defines the normal data to use
  30676. */
  30677. setNormals(data: Nullable<FloatArray>): void;
  30678. /**
  30679. * Gets the normal data stored in this target
  30680. * @returns a FloatArray containing the normal data (or null if not present)
  30681. */
  30682. getNormals(): Nullable<FloatArray>;
  30683. /**
  30684. * Affects tangent data to this target
  30685. * @param data defines the tangent data to use
  30686. */
  30687. setTangents(data: Nullable<FloatArray>): void;
  30688. /**
  30689. * Gets the tangent data stored in this target
  30690. * @returns a FloatArray containing the tangent data (or null if not present)
  30691. */
  30692. getTangents(): Nullable<FloatArray>;
  30693. /**
  30694. * Affects texture coordinates data to this target
  30695. * @param data defines the texture coordinates data to use
  30696. */
  30697. setUVs(data: Nullable<FloatArray>): void;
  30698. /**
  30699. * Gets the texture coordinates data stored in this target
  30700. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30701. */
  30702. getUVs(): Nullable<FloatArray>;
  30703. /**
  30704. * Clone the current target
  30705. * @returns a new MorphTarget
  30706. */
  30707. clone(): MorphTarget;
  30708. /**
  30709. * Serializes the current target into a Serialization object
  30710. * @returns the serialized object
  30711. */
  30712. serialize(): any;
  30713. /**
  30714. * Returns the string "MorphTarget"
  30715. * @returns "MorphTarget"
  30716. */
  30717. getClassName(): string;
  30718. /**
  30719. * Creates a new target from serialized data
  30720. * @param serializationObject defines the serialized data to use
  30721. * @returns a new MorphTarget
  30722. */
  30723. static Parse(serializationObject: any): MorphTarget;
  30724. /**
  30725. * Creates a MorphTarget from mesh data
  30726. * @param mesh defines the source mesh
  30727. * @param name defines the name to use for the new target
  30728. * @param influence defines the influence to attach to the target
  30729. * @returns a new MorphTarget
  30730. */
  30731. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30732. }
  30733. }
  30734. declare module BABYLON {
  30735. /**
  30736. * This class is used to deform meshes using morphing between different targets
  30737. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30738. */
  30739. export class MorphTargetManager {
  30740. private _targets;
  30741. private _targetInfluenceChangedObservers;
  30742. private _targetDataLayoutChangedObservers;
  30743. private _activeTargets;
  30744. private _scene;
  30745. private _influences;
  30746. private _supportsNormals;
  30747. private _supportsTangents;
  30748. private _supportsUVs;
  30749. private _vertexCount;
  30750. private _uniqueId;
  30751. private _tempInfluences;
  30752. /**
  30753. * Gets or sets a boolean indicating if normals must be morphed
  30754. */
  30755. enableNormalMorphing: boolean;
  30756. /**
  30757. * Gets or sets a boolean indicating if tangents must be morphed
  30758. */
  30759. enableTangentMorphing: boolean;
  30760. /**
  30761. * Gets or sets a boolean indicating if UV must be morphed
  30762. */
  30763. enableUVMorphing: boolean;
  30764. /**
  30765. * Creates a new MorphTargetManager
  30766. * @param scene defines the current scene
  30767. */
  30768. constructor(scene?: Nullable<Scene>);
  30769. /**
  30770. * Gets the unique ID of this manager
  30771. */
  30772. get uniqueId(): number;
  30773. /**
  30774. * Gets the number of vertices handled by this manager
  30775. */
  30776. get vertexCount(): number;
  30777. /**
  30778. * Gets a boolean indicating if this manager supports morphing of normals
  30779. */
  30780. get supportsNormals(): boolean;
  30781. /**
  30782. * Gets a boolean indicating if this manager supports morphing of tangents
  30783. */
  30784. get supportsTangents(): boolean;
  30785. /**
  30786. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  30787. */
  30788. get supportsUVs(): boolean;
  30789. /**
  30790. * Gets the number of targets stored in this manager
  30791. */
  30792. get numTargets(): number;
  30793. /**
  30794. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30795. */
  30796. get numInfluencers(): number;
  30797. /**
  30798. * Gets the list of influences (one per target)
  30799. */
  30800. get influences(): Float32Array;
  30801. /**
  30802. * Gets the active target at specified index. An active target is a target with an influence > 0
  30803. * @param index defines the index to check
  30804. * @returns the requested target
  30805. */
  30806. getActiveTarget(index: number): MorphTarget;
  30807. /**
  30808. * Gets the target at specified index
  30809. * @param index defines the index to check
  30810. * @returns the requested target
  30811. */
  30812. getTarget(index: number): MorphTarget;
  30813. /**
  30814. * Add a new target to this manager
  30815. * @param target defines the target to add
  30816. */
  30817. addTarget(target: MorphTarget): void;
  30818. /**
  30819. * Removes a target from the manager
  30820. * @param target defines the target to remove
  30821. */
  30822. removeTarget(target: MorphTarget): void;
  30823. /**
  30824. * Clone the current manager
  30825. * @returns a new MorphTargetManager
  30826. */
  30827. clone(): MorphTargetManager;
  30828. /**
  30829. * Serializes the current manager into a Serialization object
  30830. * @returns the serialized object
  30831. */
  30832. serialize(): any;
  30833. private _syncActiveTargets;
  30834. /**
  30835. * Syncrhonize the targets with all the meshes using this morph target manager
  30836. */
  30837. synchronize(): void;
  30838. /**
  30839. * Creates a new MorphTargetManager from serialized data
  30840. * @param serializationObject defines the serialized data
  30841. * @param scene defines the hosting scene
  30842. * @returns the new MorphTargetManager
  30843. */
  30844. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30845. }
  30846. }
  30847. declare module BABYLON {
  30848. /**
  30849. * Class used to represent a specific level of detail of a mesh
  30850. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  30851. */
  30852. export class MeshLODLevel {
  30853. /** Defines the distance where this level should start being displayed */
  30854. distance: number;
  30855. /** Defines the mesh to use to render this level */
  30856. mesh: Nullable<Mesh>;
  30857. /**
  30858. * Creates a new LOD level
  30859. * @param distance defines the distance where this level should star being displayed
  30860. * @param mesh defines the mesh to use to render this level
  30861. */
  30862. constructor(
  30863. /** Defines the distance where this level should start being displayed */
  30864. distance: number,
  30865. /** Defines the mesh to use to render this level */
  30866. mesh: Nullable<Mesh>);
  30867. }
  30868. }
  30869. declare module BABYLON {
  30870. /**
  30871. * Helper class used to generate a canvas to manipulate images
  30872. */
  30873. export class CanvasGenerator {
  30874. /**
  30875. * Create a new canvas (or offscreen canvas depending on the context)
  30876. * @param width defines the expected width
  30877. * @param height defines the expected height
  30878. * @return a new canvas or offscreen canvas
  30879. */
  30880. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  30881. }
  30882. }
  30883. declare module BABYLON {
  30884. /**
  30885. * Mesh representing the gorund
  30886. */
  30887. export class GroundMesh extends Mesh {
  30888. /** If octree should be generated */
  30889. generateOctree: boolean;
  30890. private _heightQuads;
  30891. /** @hidden */
  30892. _subdivisionsX: number;
  30893. /** @hidden */
  30894. _subdivisionsY: number;
  30895. /** @hidden */
  30896. _width: number;
  30897. /** @hidden */
  30898. _height: number;
  30899. /** @hidden */
  30900. _minX: number;
  30901. /** @hidden */
  30902. _maxX: number;
  30903. /** @hidden */
  30904. _minZ: number;
  30905. /** @hidden */
  30906. _maxZ: number;
  30907. constructor(name: string, scene: Scene);
  30908. /**
  30909. * "GroundMesh"
  30910. * @returns "GroundMesh"
  30911. */
  30912. getClassName(): string;
  30913. /**
  30914. * The minimum of x and y subdivisions
  30915. */
  30916. get subdivisions(): number;
  30917. /**
  30918. * X subdivisions
  30919. */
  30920. get subdivisionsX(): number;
  30921. /**
  30922. * Y subdivisions
  30923. */
  30924. get subdivisionsY(): number;
  30925. /**
  30926. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  30927. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  30928. * @param chunksCount the number of subdivisions for x and y
  30929. * @param octreeBlocksSize (Default: 32)
  30930. */
  30931. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  30932. /**
  30933. * Returns a height (y) value in the Worl system :
  30934. * the ground altitude at the coordinates (x, z) expressed in the World system.
  30935. * @param x x coordinate
  30936. * @param z z coordinate
  30937. * @returns the ground y position if (x, z) are outside the ground surface.
  30938. */
  30939. getHeightAtCoordinates(x: number, z: number): number;
  30940. /**
  30941. * Returns a normalized vector (Vector3) orthogonal to the ground
  30942. * at the ground coordinates (x, z) expressed in the World system.
  30943. * @param x x coordinate
  30944. * @param z z coordinate
  30945. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  30946. */
  30947. getNormalAtCoordinates(x: number, z: number): Vector3;
  30948. /**
  30949. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  30950. * at the ground coordinates (x, z) expressed in the World system.
  30951. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  30952. * @param x x coordinate
  30953. * @param z z coordinate
  30954. * @param ref vector to store the result
  30955. * @returns the GroundMesh.
  30956. */
  30957. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  30958. /**
  30959. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  30960. * if the ground has been updated.
  30961. * This can be used in the render loop.
  30962. * @returns the GroundMesh.
  30963. */
  30964. updateCoordinateHeights(): GroundMesh;
  30965. private _getFacetAt;
  30966. private _initHeightQuads;
  30967. private _computeHeightQuads;
  30968. /**
  30969. * Serializes this ground mesh
  30970. * @param serializationObject object to write serialization to
  30971. */
  30972. serialize(serializationObject: any): void;
  30973. /**
  30974. * Parses a serialized ground mesh
  30975. * @param parsedMesh the serialized mesh
  30976. * @param scene the scene to create the ground mesh in
  30977. * @returns the created ground mesh
  30978. */
  30979. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  30980. }
  30981. }
  30982. declare module BABYLON {
  30983. /**
  30984. * Interface for Physics-Joint data
  30985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30986. */
  30987. export interface PhysicsJointData {
  30988. /**
  30989. * The main pivot of the joint
  30990. */
  30991. mainPivot?: Vector3;
  30992. /**
  30993. * The connected pivot of the joint
  30994. */
  30995. connectedPivot?: Vector3;
  30996. /**
  30997. * The main axis of the joint
  30998. */
  30999. mainAxis?: Vector3;
  31000. /**
  31001. * The connected axis of the joint
  31002. */
  31003. connectedAxis?: Vector3;
  31004. /**
  31005. * The collision of the joint
  31006. */
  31007. collision?: boolean;
  31008. /**
  31009. * Native Oimo/Cannon/Energy data
  31010. */
  31011. nativeParams?: any;
  31012. }
  31013. /**
  31014. * This is a holder class for the physics joint created by the physics plugin
  31015. * It holds a set of functions to control the underlying joint
  31016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31017. */
  31018. export class PhysicsJoint {
  31019. /**
  31020. * The type of the physics joint
  31021. */
  31022. type: number;
  31023. /**
  31024. * The data for the physics joint
  31025. */
  31026. jointData: PhysicsJointData;
  31027. private _physicsJoint;
  31028. protected _physicsPlugin: IPhysicsEnginePlugin;
  31029. /**
  31030. * Initializes the physics joint
  31031. * @param type The type of the physics joint
  31032. * @param jointData The data for the physics joint
  31033. */
  31034. constructor(
  31035. /**
  31036. * The type of the physics joint
  31037. */
  31038. type: number,
  31039. /**
  31040. * The data for the physics joint
  31041. */
  31042. jointData: PhysicsJointData);
  31043. /**
  31044. * Gets the physics joint
  31045. */
  31046. get physicsJoint(): any;
  31047. /**
  31048. * Sets the physics joint
  31049. */
  31050. set physicsJoint(newJoint: any);
  31051. /**
  31052. * Sets the physics plugin
  31053. */
  31054. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31055. /**
  31056. * Execute a function that is physics-plugin specific.
  31057. * @param {Function} func the function that will be executed.
  31058. * It accepts two parameters: the physics world and the physics joint
  31059. */
  31060. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31061. /**
  31062. * Distance-Joint type
  31063. */
  31064. static DistanceJoint: number;
  31065. /**
  31066. * Hinge-Joint type
  31067. */
  31068. static HingeJoint: number;
  31069. /**
  31070. * Ball-and-Socket joint type
  31071. */
  31072. static BallAndSocketJoint: number;
  31073. /**
  31074. * Wheel-Joint type
  31075. */
  31076. static WheelJoint: number;
  31077. /**
  31078. * Slider-Joint type
  31079. */
  31080. static SliderJoint: number;
  31081. /**
  31082. * Prismatic-Joint type
  31083. */
  31084. static PrismaticJoint: number;
  31085. /**
  31086. * Universal-Joint type
  31087. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31088. */
  31089. static UniversalJoint: number;
  31090. /**
  31091. * Hinge-Joint 2 type
  31092. */
  31093. static Hinge2Joint: number;
  31094. /**
  31095. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31096. */
  31097. static PointToPointJoint: number;
  31098. /**
  31099. * Spring-Joint type
  31100. */
  31101. static SpringJoint: number;
  31102. /**
  31103. * Lock-Joint type
  31104. */
  31105. static LockJoint: number;
  31106. }
  31107. /**
  31108. * A class representing a physics distance joint
  31109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31110. */
  31111. export class DistanceJoint extends PhysicsJoint {
  31112. /**
  31113. *
  31114. * @param jointData The data for the Distance-Joint
  31115. */
  31116. constructor(jointData: DistanceJointData);
  31117. /**
  31118. * Update the predefined distance.
  31119. * @param maxDistance The maximum preferred distance
  31120. * @param minDistance The minimum preferred distance
  31121. */
  31122. updateDistance(maxDistance: number, minDistance?: number): void;
  31123. }
  31124. /**
  31125. * Represents a Motor-Enabled Joint
  31126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31127. */
  31128. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31129. /**
  31130. * Initializes the Motor-Enabled Joint
  31131. * @param type The type of the joint
  31132. * @param jointData The physica joint data for the joint
  31133. */
  31134. constructor(type: number, jointData: PhysicsJointData);
  31135. /**
  31136. * Set the motor values.
  31137. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31138. * @param force the force to apply
  31139. * @param maxForce max force for this motor.
  31140. */
  31141. setMotor(force?: number, maxForce?: number): void;
  31142. /**
  31143. * Set the motor's limits.
  31144. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31145. * @param upperLimit The upper limit of the motor
  31146. * @param lowerLimit The lower limit of the motor
  31147. */
  31148. setLimit(upperLimit: number, lowerLimit?: number): void;
  31149. }
  31150. /**
  31151. * This class represents a single physics Hinge-Joint
  31152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31153. */
  31154. export class HingeJoint extends MotorEnabledJoint {
  31155. /**
  31156. * Initializes the Hinge-Joint
  31157. * @param jointData The joint data for the Hinge-Joint
  31158. */
  31159. constructor(jointData: PhysicsJointData);
  31160. /**
  31161. * Set the motor values.
  31162. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31163. * @param {number} force the force to apply
  31164. * @param {number} maxForce max force for this motor.
  31165. */
  31166. setMotor(force?: number, maxForce?: number): void;
  31167. /**
  31168. * Set the motor's limits.
  31169. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31170. * @param upperLimit The upper limit of the motor
  31171. * @param lowerLimit The lower limit of the motor
  31172. */
  31173. setLimit(upperLimit: number, lowerLimit?: number): void;
  31174. }
  31175. /**
  31176. * This class represents a dual hinge physics joint (same as wheel joint)
  31177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31178. */
  31179. export class Hinge2Joint extends MotorEnabledJoint {
  31180. /**
  31181. * Initializes the Hinge2-Joint
  31182. * @param jointData The joint data for the Hinge2-Joint
  31183. */
  31184. constructor(jointData: PhysicsJointData);
  31185. /**
  31186. * Set the motor values.
  31187. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31188. * @param {number} targetSpeed the speed the motor is to reach
  31189. * @param {number} maxForce max force for this motor.
  31190. * @param {motorIndex} the motor's index, 0 or 1.
  31191. */
  31192. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31193. /**
  31194. * Set the motor limits.
  31195. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31196. * @param {number} upperLimit the upper limit
  31197. * @param {number} lowerLimit lower limit
  31198. * @param {motorIndex} the motor's index, 0 or 1.
  31199. */
  31200. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31201. }
  31202. /**
  31203. * Interface for a motor enabled joint
  31204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31205. */
  31206. export interface IMotorEnabledJoint {
  31207. /**
  31208. * Physics joint
  31209. */
  31210. physicsJoint: any;
  31211. /**
  31212. * Sets the motor of the motor-enabled joint
  31213. * @param force The force of the motor
  31214. * @param maxForce The maximum force of the motor
  31215. * @param motorIndex The index of the motor
  31216. */
  31217. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31218. /**
  31219. * Sets the limit of the motor
  31220. * @param upperLimit The upper limit of the motor
  31221. * @param lowerLimit The lower limit of the motor
  31222. * @param motorIndex The index of the motor
  31223. */
  31224. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31225. }
  31226. /**
  31227. * Joint data for a Distance-Joint
  31228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31229. */
  31230. export interface DistanceJointData extends PhysicsJointData {
  31231. /**
  31232. * Max distance the 2 joint objects can be apart
  31233. */
  31234. maxDistance: number;
  31235. }
  31236. /**
  31237. * Joint data from a spring joint
  31238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31239. */
  31240. export interface SpringJointData extends PhysicsJointData {
  31241. /**
  31242. * Length of the spring
  31243. */
  31244. length: number;
  31245. /**
  31246. * Stiffness of the spring
  31247. */
  31248. stiffness: number;
  31249. /**
  31250. * Damping of the spring
  31251. */
  31252. damping: number;
  31253. /** this callback will be called when applying the force to the impostors. */
  31254. forceApplicationCallback: () => void;
  31255. }
  31256. }
  31257. declare module BABYLON {
  31258. /**
  31259. * Holds the data for the raycast result
  31260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31261. */
  31262. export class PhysicsRaycastResult {
  31263. private _hasHit;
  31264. private _hitDistance;
  31265. private _hitNormalWorld;
  31266. private _hitPointWorld;
  31267. private _rayFromWorld;
  31268. private _rayToWorld;
  31269. /**
  31270. * Gets if there was a hit
  31271. */
  31272. get hasHit(): boolean;
  31273. /**
  31274. * Gets the distance from the hit
  31275. */
  31276. get hitDistance(): number;
  31277. /**
  31278. * Gets the hit normal/direction in the world
  31279. */
  31280. get hitNormalWorld(): Vector3;
  31281. /**
  31282. * Gets the hit point in the world
  31283. */
  31284. get hitPointWorld(): Vector3;
  31285. /**
  31286. * Gets the ray "start point" of the ray in the world
  31287. */
  31288. get rayFromWorld(): Vector3;
  31289. /**
  31290. * Gets the ray "end point" of the ray in the world
  31291. */
  31292. get rayToWorld(): Vector3;
  31293. /**
  31294. * Sets the hit data (normal & point in world space)
  31295. * @param hitNormalWorld defines the normal in world space
  31296. * @param hitPointWorld defines the point in world space
  31297. */
  31298. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31299. /**
  31300. * Sets the distance from the start point to the hit point
  31301. * @param distance
  31302. */
  31303. setHitDistance(distance: number): void;
  31304. /**
  31305. * Calculates the distance manually
  31306. */
  31307. calculateHitDistance(): void;
  31308. /**
  31309. * Resets all the values to default
  31310. * @param from The from point on world space
  31311. * @param to The to point on world space
  31312. */
  31313. reset(from?: Vector3, to?: Vector3): void;
  31314. }
  31315. /**
  31316. * Interface for the size containing width and height
  31317. */
  31318. interface IXYZ {
  31319. /**
  31320. * X
  31321. */
  31322. x: number;
  31323. /**
  31324. * Y
  31325. */
  31326. y: number;
  31327. /**
  31328. * Z
  31329. */
  31330. z: number;
  31331. }
  31332. }
  31333. declare module BABYLON {
  31334. /**
  31335. * Interface used to describe a physics joint
  31336. */
  31337. export interface PhysicsImpostorJoint {
  31338. /** Defines the main impostor to which the joint is linked */
  31339. mainImpostor: PhysicsImpostor;
  31340. /** Defines the impostor that is connected to the main impostor using this joint */
  31341. connectedImpostor: PhysicsImpostor;
  31342. /** Defines the joint itself */
  31343. joint: PhysicsJoint;
  31344. }
  31345. /** @hidden */
  31346. export interface IPhysicsEnginePlugin {
  31347. world: any;
  31348. name: string;
  31349. setGravity(gravity: Vector3): void;
  31350. setTimeStep(timeStep: number): void;
  31351. getTimeStep(): number;
  31352. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31353. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31354. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31355. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31356. removePhysicsBody(impostor: PhysicsImpostor): void;
  31357. generateJoint(joint: PhysicsImpostorJoint): void;
  31358. removeJoint(joint: PhysicsImpostorJoint): void;
  31359. isSupported(): boolean;
  31360. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31361. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31362. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31363. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31364. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31365. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31366. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31367. getBodyMass(impostor: PhysicsImpostor): number;
  31368. getBodyFriction(impostor: PhysicsImpostor): number;
  31369. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31370. getBodyRestitution(impostor: PhysicsImpostor): number;
  31371. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31372. getBodyPressure?(impostor: PhysicsImpostor): number;
  31373. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31374. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31375. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31376. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31377. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31378. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31379. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31380. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31381. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31382. sleepBody(impostor: PhysicsImpostor): void;
  31383. wakeUpBody(impostor: PhysicsImpostor): void;
  31384. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31385. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31386. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31387. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31388. getRadius(impostor: PhysicsImpostor): number;
  31389. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31390. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31391. dispose(): void;
  31392. }
  31393. /**
  31394. * Interface used to define a physics engine
  31395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31396. */
  31397. export interface IPhysicsEngine {
  31398. /**
  31399. * Gets the gravity vector used by the simulation
  31400. */
  31401. gravity: Vector3;
  31402. /**
  31403. * Sets the gravity vector used by the simulation
  31404. * @param gravity defines the gravity vector to use
  31405. */
  31406. setGravity(gravity: Vector3): void;
  31407. /**
  31408. * Set the time step of the physics engine.
  31409. * Default is 1/60.
  31410. * To slow it down, enter 1/600 for example.
  31411. * To speed it up, 1/30
  31412. * @param newTimeStep the new timestep to apply to this world.
  31413. */
  31414. setTimeStep(newTimeStep: number): void;
  31415. /**
  31416. * Get the time step of the physics engine.
  31417. * @returns the current time step
  31418. */
  31419. getTimeStep(): number;
  31420. /**
  31421. * Set the sub time step of the physics engine.
  31422. * Default is 0 meaning there is no sub steps
  31423. * To increase physics resolution precision, set a small value (like 1 ms)
  31424. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31425. */
  31426. setSubTimeStep(subTimeStep: number): void;
  31427. /**
  31428. * Get the sub time step of the physics engine.
  31429. * @returns the current sub time step
  31430. */
  31431. getSubTimeStep(): number;
  31432. /**
  31433. * Release all resources
  31434. */
  31435. dispose(): void;
  31436. /**
  31437. * Gets the name of the current physics plugin
  31438. * @returns the name of the plugin
  31439. */
  31440. getPhysicsPluginName(): string;
  31441. /**
  31442. * Adding a new impostor for the impostor tracking.
  31443. * This will be done by the impostor itself.
  31444. * @param impostor the impostor to add
  31445. */
  31446. addImpostor(impostor: PhysicsImpostor): void;
  31447. /**
  31448. * Remove an impostor from the engine.
  31449. * This impostor and its mesh will not longer be updated by the physics engine.
  31450. * @param impostor the impostor to remove
  31451. */
  31452. removeImpostor(impostor: PhysicsImpostor): void;
  31453. /**
  31454. * Add a joint to the physics engine
  31455. * @param mainImpostor defines the main impostor to which the joint is added.
  31456. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31457. * @param joint defines the joint that will connect both impostors.
  31458. */
  31459. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31460. /**
  31461. * Removes a joint from the simulation
  31462. * @param mainImpostor defines the impostor used with the joint
  31463. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31464. * @param joint defines the joint to remove
  31465. */
  31466. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31467. /**
  31468. * Gets the current plugin used to run the simulation
  31469. * @returns current plugin
  31470. */
  31471. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31472. /**
  31473. * Gets the list of physic impostors
  31474. * @returns an array of PhysicsImpostor
  31475. */
  31476. getImpostors(): Array<PhysicsImpostor>;
  31477. /**
  31478. * Gets the impostor for a physics enabled object
  31479. * @param object defines the object impersonated by the impostor
  31480. * @returns the PhysicsImpostor or null if not found
  31481. */
  31482. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31483. /**
  31484. * Gets the impostor for a physics body object
  31485. * @param body defines physics body used by the impostor
  31486. * @returns the PhysicsImpostor or null if not found
  31487. */
  31488. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31489. /**
  31490. * Does a raycast in the physics world
  31491. * @param from when should the ray start?
  31492. * @param to when should the ray end?
  31493. * @returns PhysicsRaycastResult
  31494. */
  31495. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31496. /**
  31497. * Called by the scene. No need to call it.
  31498. * @param delta defines the timespam between frames
  31499. */
  31500. _step(delta: number): void;
  31501. }
  31502. }
  31503. declare module BABYLON {
  31504. /**
  31505. * The interface for the physics imposter parameters
  31506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31507. */
  31508. export interface PhysicsImpostorParameters {
  31509. /**
  31510. * The mass of the physics imposter
  31511. */
  31512. mass: number;
  31513. /**
  31514. * The friction of the physics imposter
  31515. */
  31516. friction?: number;
  31517. /**
  31518. * The coefficient of restitution of the physics imposter
  31519. */
  31520. restitution?: number;
  31521. /**
  31522. * The native options of the physics imposter
  31523. */
  31524. nativeOptions?: any;
  31525. /**
  31526. * Specifies if the parent should be ignored
  31527. */
  31528. ignoreParent?: boolean;
  31529. /**
  31530. * Specifies if bi-directional transformations should be disabled
  31531. */
  31532. disableBidirectionalTransformation?: boolean;
  31533. /**
  31534. * The pressure inside the physics imposter, soft object only
  31535. */
  31536. pressure?: number;
  31537. /**
  31538. * The stiffness the physics imposter, soft object only
  31539. */
  31540. stiffness?: number;
  31541. /**
  31542. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31543. */
  31544. velocityIterations?: number;
  31545. /**
  31546. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31547. */
  31548. positionIterations?: number;
  31549. /**
  31550. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31551. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31552. * Add to fix multiple points
  31553. */
  31554. fixedPoints?: number;
  31555. /**
  31556. * The collision margin around a soft object
  31557. */
  31558. margin?: number;
  31559. /**
  31560. * The collision margin around a soft object
  31561. */
  31562. damping?: number;
  31563. /**
  31564. * The path for a rope based on an extrusion
  31565. */
  31566. path?: any;
  31567. /**
  31568. * The shape of an extrusion used for a rope based on an extrusion
  31569. */
  31570. shape?: any;
  31571. }
  31572. /**
  31573. * Interface for a physics-enabled object
  31574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31575. */
  31576. export interface IPhysicsEnabledObject {
  31577. /**
  31578. * The position of the physics-enabled object
  31579. */
  31580. position: Vector3;
  31581. /**
  31582. * The rotation of the physics-enabled object
  31583. */
  31584. rotationQuaternion: Nullable<Quaternion>;
  31585. /**
  31586. * The scale of the physics-enabled object
  31587. */
  31588. scaling: Vector3;
  31589. /**
  31590. * The rotation of the physics-enabled object
  31591. */
  31592. rotation?: Vector3;
  31593. /**
  31594. * The parent of the physics-enabled object
  31595. */
  31596. parent?: any;
  31597. /**
  31598. * The bounding info of the physics-enabled object
  31599. * @returns The bounding info of the physics-enabled object
  31600. */
  31601. getBoundingInfo(): BoundingInfo;
  31602. /**
  31603. * Computes the world matrix
  31604. * @param force Specifies if the world matrix should be computed by force
  31605. * @returns A world matrix
  31606. */
  31607. computeWorldMatrix(force: boolean): Matrix;
  31608. /**
  31609. * Gets the world matrix
  31610. * @returns A world matrix
  31611. */
  31612. getWorldMatrix?(): Matrix;
  31613. /**
  31614. * Gets the child meshes
  31615. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31616. * @returns An array of abstract meshes
  31617. */
  31618. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31619. /**
  31620. * Gets the vertex data
  31621. * @param kind The type of vertex data
  31622. * @returns A nullable array of numbers, or a float32 array
  31623. */
  31624. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31625. /**
  31626. * Gets the indices from the mesh
  31627. * @returns A nullable array of index arrays
  31628. */
  31629. getIndices?(): Nullable<IndicesArray>;
  31630. /**
  31631. * Gets the scene from the mesh
  31632. * @returns the indices array or null
  31633. */
  31634. getScene?(): Scene;
  31635. /**
  31636. * Gets the absolute position from the mesh
  31637. * @returns the absolute position
  31638. */
  31639. getAbsolutePosition(): Vector3;
  31640. /**
  31641. * Gets the absolute pivot point from the mesh
  31642. * @returns the absolute pivot point
  31643. */
  31644. getAbsolutePivotPoint(): Vector3;
  31645. /**
  31646. * Rotates the mesh
  31647. * @param axis The axis of rotation
  31648. * @param amount The amount of rotation
  31649. * @param space The space of the rotation
  31650. * @returns The rotation transform node
  31651. */
  31652. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31653. /**
  31654. * Translates the mesh
  31655. * @param axis The axis of translation
  31656. * @param distance The distance of translation
  31657. * @param space The space of the translation
  31658. * @returns The transform node
  31659. */
  31660. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31661. /**
  31662. * Sets the absolute position of the mesh
  31663. * @param absolutePosition The absolute position of the mesh
  31664. * @returns The transform node
  31665. */
  31666. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31667. /**
  31668. * Gets the class name of the mesh
  31669. * @returns The class name
  31670. */
  31671. getClassName(): string;
  31672. }
  31673. /**
  31674. * Represents a physics imposter
  31675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31676. */
  31677. export class PhysicsImpostor {
  31678. /**
  31679. * The physics-enabled object used as the physics imposter
  31680. */
  31681. object: IPhysicsEnabledObject;
  31682. /**
  31683. * The type of the physics imposter
  31684. */
  31685. type: number;
  31686. private _options;
  31687. private _scene?;
  31688. /**
  31689. * The default object size of the imposter
  31690. */
  31691. static DEFAULT_OBJECT_SIZE: Vector3;
  31692. /**
  31693. * The identity quaternion of the imposter
  31694. */
  31695. static IDENTITY_QUATERNION: Quaternion;
  31696. /** @hidden */
  31697. _pluginData: any;
  31698. private _physicsEngine;
  31699. private _physicsBody;
  31700. private _bodyUpdateRequired;
  31701. private _onBeforePhysicsStepCallbacks;
  31702. private _onAfterPhysicsStepCallbacks;
  31703. /** @hidden */
  31704. _onPhysicsCollideCallbacks: Array<{
  31705. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  31706. otherImpostors: Array<PhysicsImpostor>;
  31707. }>;
  31708. private _deltaPosition;
  31709. private _deltaRotation;
  31710. private _deltaRotationConjugated;
  31711. /** @hidden */
  31712. _isFromLine: boolean;
  31713. private _parent;
  31714. private _isDisposed;
  31715. private static _tmpVecs;
  31716. private static _tmpQuat;
  31717. /**
  31718. * Specifies if the physics imposter is disposed
  31719. */
  31720. get isDisposed(): boolean;
  31721. /**
  31722. * Gets the mass of the physics imposter
  31723. */
  31724. get mass(): number;
  31725. set mass(value: number);
  31726. /**
  31727. * Gets the coefficient of friction
  31728. */
  31729. get friction(): number;
  31730. /**
  31731. * Sets the coefficient of friction
  31732. */
  31733. set friction(value: number);
  31734. /**
  31735. * Gets the coefficient of restitution
  31736. */
  31737. get restitution(): number;
  31738. /**
  31739. * Sets the coefficient of restitution
  31740. */
  31741. set restitution(value: number);
  31742. /**
  31743. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  31744. */
  31745. get pressure(): number;
  31746. /**
  31747. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  31748. */
  31749. set pressure(value: number);
  31750. /**
  31751. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31752. */
  31753. get stiffness(): number;
  31754. /**
  31755. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31756. */
  31757. set stiffness(value: number);
  31758. /**
  31759. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31760. */
  31761. get velocityIterations(): number;
  31762. /**
  31763. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31764. */
  31765. set velocityIterations(value: number);
  31766. /**
  31767. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31768. */
  31769. get positionIterations(): number;
  31770. /**
  31771. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31772. */
  31773. set positionIterations(value: number);
  31774. /**
  31775. * The unique id of the physics imposter
  31776. * set by the physics engine when adding this impostor to the array
  31777. */
  31778. uniqueId: number;
  31779. /**
  31780. * @hidden
  31781. */
  31782. soft: boolean;
  31783. /**
  31784. * @hidden
  31785. */
  31786. segments: number;
  31787. private _joints;
  31788. /**
  31789. * Initializes the physics imposter
  31790. * @param object The physics-enabled object used as the physics imposter
  31791. * @param type The type of the physics imposter
  31792. * @param _options The options for the physics imposter
  31793. * @param _scene The Babylon scene
  31794. */
  31795. constructor(
  31796. /**
  31797. * The physics-enabled object used as the physics imposter
  31798. */
  31799. object: IPhysicsEnabledObject,
  31800. /**
  31801. * The type of the physics imposter
  31802. */
  31803. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31804. /**
  31805. * This function will completly initialize this impostor.
  31806. * It will create a new body - but only if this mesh has no parent.
  31807. * If it has, this impostor will not be used other than to define the impostor
  31808. * of the child mesh.
  31809. * @hidden
  31810. */
  31811. _init(): void;
  31812. private _getPhysicsParent;
  31813. /**
  31814. * Should a new body be generated.
  31815. * @returns boolean specifying if body initialization is required
  31816. */
  31817. isBodyInitRequired(): boolean;
  31818. /**
  31819. * Sets the updated scaling
  31820. * @param updated Specifies if the scaling is updated
  31821. */
  31822. setScalingUpdated(): void;
  31823. /**
  31824. * Force a regeneration of this or the parent's impostor's body.
  31825. * Use under cautious - This will remove all joints already implemented.
  31826. */
  31827. forceUpdate(): void;
  31828. /**
  31829. * Gets the body that holds this impostor. Either its own, or its parent.
  31830. */
  31831. get physicsBody(): any;
  31832. /**
  31833. * Get the parent of the physics imposter
  31834. * @returns Physics imposter or null
  31835. */
  31836. get parent(): Nullable<PhysicsImpostor>;
  31837. /**
  31838. * Sets the parent of the physics imposter
  31839. */
  31840. set parent(value: Nullable<PhysicsImpostor>);
  31841. /**
  31842. * Set the physics body. Used mainly by the physics engine/plugin
  31843. */
  31844. set physicsBody(physicsBody: any);
  31845. /**
  31846. * Resets the update flags
  31847. */
  31848. resetUpdateFlags(): void;
  31849. /**
  31850. * Gets the object extend size
  31851. * @returns the object extend size
  31852. */
  31853. getObjectExtendSize(): Vector3;
  31854. /**
  31855. * Gets the object center
  31856. * @returns The object center
  31857. */
  31858. getObjectCenter(): Vector3;
  31859. /**
  31860. * Get a specific parameter from the options parameters
  31861. * @param paramName The object parameter name
  31862. * @returns The object parameter
  31863. */
  31864. getParam(paramName: string): any;
  31865. /**
  31866. * Sets a specific parameter in the options given to the physics plugin
  31867. * @param paramName The parameter name
  31868. * @param value The value of the parameter
  31869. */
  31870. setParam(paramName: string, value: number): void;
  31871. /**
  31872. * Specifically change the body's mass option. Won't recreate the physics body object
  31873. * @param mass The mass of the physics imposter
  31874. */
  31875. setMass(mass: number): void;
  31876. /**
  31877. * Gets the linear velocity
  31878. * @returns linear velocity or null
  31879. */
  31880. getLinearVelocity(): Nullable<Vector3>;
  31881. /**
  31882. * Sets the linear velocity
  31883. * @param velocity linear velocity or null
  31884. */
  31885. setLinearVelocity(velocity: Nullable<Vector3>): void;
  31886. /**
  31887. * Gets the angular velocity
  31888. * @returns angular velocity or null
  31889. */
  31890. getAngularVelocity(): Nullable<Vector3>;
  31891. /**
  31892. * Sets the angular velocity
  31893. * @param velocity The velocity or null
  31894. */
  31895. setAngularVelocity(velocity: Nullable<Vector3>): void;
  31896. /**
  31897. * Execute a function with the physics plugin native code
  31898. * Provide a function the will have two variables - the world object and the physics body object
  31899. * @param func The function to execute with the physics plugin native code
  31900. */
  31901. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  31902. /**
  31903. * Register a function that will be executed before the physics world is stepping forward
  31904. * @param func The function to execute before the physics world is stepped forward
  31905. */
  31906. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31907. /**
  31908. * Unregister a function that will be executed before the physics world is stepping forward
  31909. * @param func The function to execute before the physics world is stepped forward
  31910. */
  31911. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31912. /**
  31913. * Register a function that will be executed after the physics step
  31914. * @param func The function to execute after physics step
  31915. */
  31916. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31917. /**
  31918. * Unregisters a function that will be executed after the physics step
  31919. * @param func The function to execute after physics step
  31920. */
  31921. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31922. /**
  31923. * register a function that will be executed when this impostor collides against a different body
  31924. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  31925. * @param func Callback that is executed on collision
  31926. */
  31927. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  31928. /**
  31929. * Unregisters the physics imposter on contact
  31930. * @param collideAgainst The physics object to collide against
  31931. * @param func Callback to execute on collision
  31932. */
  31933. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  31934. private _tmpQuat;
  31935. private _tmpQuat2;
  31936. /**
  31937. * Get the parent rotation
  31938. * @returns The parent rotation
  31939. */
  31940. getParentsRotation(): Quaternion;
  31941. /**
  31942. * this function is executed by the physics engine.
  31943. */
  31944. beforeStep: () => void;
  31945. /**
  31946. * this function is executed by the physics engine
  31947. */
  31948. afterStep: () => void;
  31949. /**
  31950. * Legacy collision detection event support
  31951. */
  31952. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  31953. /**
  31954. * event and body object due to cannon's event-based architecture.
  31955. */
  31956. onCollide: (e: {
  31957. body: any;
  31958. point: Nullable<Vector3>;
  31959. }) => void;
  31960. /**
  31961. * Apply a force
  31962. * @param force The force to apply
  31963. * @param contactPoint The contact point for the force
  31964. * @returns The physics imposter
  31965. */
  31966. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  31967. /**
  31968. * Apply an impulse
  31969. * @param force The impulse force
  31970. * @param contactPoint The contact point for the impulse force
  31971. * @returns The physics imposter
  31972. */
  31973. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  31974. /**
  31975. * A help function to create a joint
  31976. * @param otherImpostor A physics imposter used to create a joint
  31977. * @param jointType The type of joint
  31978. * @param jointData The data for the joint
  31979. * @returns The physics imposter
  31980. */
  31981. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  31982. /**
  31983. * Add a joint to this impostor with a different impostor
  31984. * @param otherImpostor A physics imposter used to add a joint
  31985. * @param joint The joint to add
  31986. * @returns The physics imposter
  31987. */
  31988. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  31989. /**
  31990. * Add an anchor to a cloth impostor
  31991. * @param otherImpostor rigid impostor to anchor to
  31992. * @param width ratio across width from 0 to 1
  31993. * @param height ratio up height from 0 to 1
  31994. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  31995. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  31996. * @returns impostor the soft imposter
  31997. */
  31998. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  31999. /**
  32000. * Add a hook to a rope impostor
  32001. * @param otherImpostor rigid impostor to anchor to
  32002. * @param length ratio across rope from 0 to 1
  32003. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32004. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32005. * @returns impostor the rope imposter
  32006. */
  32007. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32008. /**
  32009. * Will keep this body still, in a sleep mode.
  32010. * @returns the physics imposter
  32011. */
  32012. sleep(): PhysicsImpostor;
  32013. /**
  32014. * Wake the body up.
  32015. * @returns The physics imposter
  32016. */
  32017. wakeUp(): PhysicsImpostor;
  32018. /**
  32019. * Clones the physics imposter
  32020. * @param newObject The physics imposter clones to this physics-enabled object
  32021. * @returns A nullable physics imposter
  32022. */
  32023. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32024. /**
  32025. * Disposes the physics imposter
  32026. */
  32027. dispose(): void;
  32028. /**
  32029. * Sets the delta position
  32030. * @param position The delta position amount
  32031. */
  32032. setDeltaPosition(position: Vector3): void;
  32033. /**
  32034. * Sets the delta rotation
  32035. * @param rotation The delta rotation amount
  32036. */
  32037. setDeltaRotation(rotation: Quaternion): void;
  32038. /**
  32039. * Gets the box size of the physics imposter and stores the result in the input parameter
  32040. * @param result Stores the box size
  32041. * @returns The physics imposter
  32042. */
  32043. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32044. /**
  32045. * Gets the radius of the physics imposter
  32046. * @returns Radius of the physics imposter
  32047. */
  32048. getRadius(): number;
  32049. /**
  32050. * Sync a bone with this impostor
  32051. * @param bone The bone to sync to the impostor.
  32052. * @param boneMesh The mesh that the bone is influencing.
  32053. * @param jointPivot The pivot of the joint / bone in local space.
  32054. * @param distToJoint Optional distance from the impostor to the joint.
  32055. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32056. */
  32057. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32058. /**
  32059. * Sync impostor to a bone
  32060. * @param bone The bone that the impostor will be synced to.
  32061. * @param boneMesh The mesh that the bone is influencing.
  32062. * @param jointPivot The pivot of the joint / bone in local space.
  32063. * @param distToJoint Optional distance from the impostor to the joint.
  32064. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32065. * @param boneAxis Optional vector3 axis the bone is aligned with
  32066. */
  32067. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32068. /**
  32069. * No-Imposter type
  32070. */
  32071. static NoImpostor: number;
  32072. /**
  32073. * Sphere-Imposter type
  32074. */
  32075. static SphereImpostor: number;
  32076. /**
  32077. * Box-Imposter type
  32078. */
  32079. static BoxImpostor: number;
  32080. /**
  32081. * Plane-Imposter type
  32082. */
  32083. static PlaneImpostor: number;
  32084. /**
  32085. * Mesh-imposter type
  32086. */
  32087. static MeshImpostor: number;
  32088. /**
  32089. * Capsule-Impostor type (Ammo.js plugin only)
  32090. */
  32091. static CapsuleImpostor: number;
  32092. /**
  32093. * Cylinder-Imposter type
  32094. */
  32095. static CylinderImpostor: number;
  32096. /**
  32097. * Particle-Imposter type
  32098. */
  32099. static ParticleImpostor: number;
  32100. /**
  32101. * Heightmap-Imposter type
  32102. */
  32103. static HeightmapImpostor: number;
  32104. /**
  32105. * ConvexHull-Impostor type (Ammo.js plugin only)
  32106. */
  32107. static ConvexHullImpostor: number;
  32108. /**
  32109. * Custom-Imposter type (Ammo.js plugin only)
  32110. */
  32111. static CustomImpostor: number;
  32112. /**
  32113. * Rope-Imposter type
  32114. */
  32115. static RopeImpostor: number;
  32116. /**
  32117. * Cloth-Imposter type
  32118. */
  32119. static ClothImpostor: number;
  32120. /**
  32121. * Softbody-Imposter type
  32122. */
  32123. static SoftbodyImpostor: number;
  32124. }
  32125. }
  32126. declare module BABYLON {
  32127. /**
  32128. * @hidden
  32129. **/
  32130. export class _CreationDataStorage {
  32131. closePath?: boolean;
  32132. closeArray?: boolean;
  32133. idx: number[];
  32134. dashSize: number;
  32135. gapSize: number;
  32136. path3D: Path3D;
  32137. pathArray: Vector3[][];
  32138. arc: number;
  32139. radius: number;
  32140. cap: number;
  32141. tessellation: number;
  32142. }
  32143. /**
  32144. * @hidden
  32145. **/
  32146. class _InstanceDataStorage {
  32147. visibleInstances: any;
  32148. batchCache: _InstancesBatch;
  32149. instancesBufferSize: number;
  32150. instancesBuffer: Nullable<Buffer>;
  32151. instancesData: Float32Array;
  32152. overridenInstanceCount: number;
  32153. isFrozen: boolean;
  32154. previousBatch: Nullable<_InstancesBatch>;
  32155. hardwareInstancedRendering: boolean;
  32156. sideOrientation: number;
  32157. manualUpdate: boolean;
  32158. previousRenderId: number;
  32159. }
  32160. /**
  32161. * @hidden
  32162. **/
  32163. export class _InstancesBatch {
  32164. mustReturn: boolean;
  32165. visibleInstances: Nullable<InstancedMesh[]>[];
  32166. renderSelf: boolean[];
  32167. hardwareInstancedRendering: boolean[];
  32168. }
  32169. /**
  32170. * @hidden
  32171. **/
  32172. class _ThinInstanceDataStorage {
  32173. instancesCount: number;
  32174. matrixBuffer: Nullable<Buffer>;
  32175. matrixBufferSize: number;
  32176. matrixData: Nullable<Float32Array>;
  32177. boundingVectors: Array<Vector3>;
  32178. worldMatrices: Nullable<Matrix[]>;
  32179. }
  32180. /**
  32181. * Class used to represent renderable models
  32182. */
  32183. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32184. /**
  32185. * Mesh side orientation : usually the external or front surface
  32186. */
  32187. static readonly FRONTSIDE: number;
  32188. /**
  32189. * Mesh side orientation : usually the internal or back surface
  32190. */
  32191. static readonly BACKSIDE: number;
  32192. /**
  32193. * Mesh side orientation : both internal and external or front and back surfaces
  32194. */
  32195. static readonly DOUBLESIDE: number;
  32196. /**
  32197. * Mesh side orientation : by default, `FRONTSIDE`
  32198. */
  32199. static readonly DEFAULTSIDE: number;
  32200. /**
  32201. * Mesh cap setting : no cap
  32202. */
  32203. static readonly NO_CAP: number;
  32204. /**
  32205. * Mesh cap setting : one cap at the beginning of the mesh
  32206. */
  32207. static readonly CAP_START: number;
  32208. /**
  32209. * Mesh cap setting : one cap at the end of the mesh
  32210. */
  32211. static readonly CAP_END: number;
  32212. /**
  32213. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32214. */
  32215. static readonly CAP_ALL: number;
  32216. /**
  32217. * Mesh pattern setting : no flip or rotate
  32218. */
  32219. static readonly NO_FLIP: number;
  32220. /**
  32221. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32222. */
  32223. static readonly FLIP_TILE: number;
  32224. /**
  32225. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32226. */
  32227. static readonly ROTATE_TILE: number;
  32228. /**
  32229. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32230. */
  32231. static readonly FLIP_ROW: number;
  32232. /**
  32233. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32234. */
  32235. static readonly ROTATE_ROW: number;
  32236. /**
  32237. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32238. */
  32239. static readonly FLIP_N_ROTATE_TILE: number;
  32240. /**
  32241. * Mesh pattern setting : rotate pattern and rotate
  32242. */
  32243. static readonly FLIP_N_ROTATE_ROW: number;
  32244. /**
  32245. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32246. */
  32247. static readonly CENTER: number;
  32248. /**
  32249. * Mesh tile positioning : part tiles on left
  32250. */
  32251. static readonly LEFT: number;
  32252. /**
  32253. * Mesh tile positioning : part tiles on right
  32254. */
  32255. static readonly RIGHT: number;
  32256. /**
  32257. * Mesh tile positioning : part tiles on top
  32258. */
  32259. static readonly TOP: number;
  32260. /**
  32261. * Mesh tile positioning : part tiles on bottom
  32262. */
  32263. static readonly BOTTOM: number;
  32264. /**
  32265. * Gets the default side orientation.
  32266. * @param orientation the orientation to value to attempt to get
  32267. * @returns the default orientation
  32268. * @hidden
  32269. */
  32270. static _GetDefaultSideOrientation(orientation?: number): number;
  32271. private _internalMeshDataInfo;
  32272. get computeBonesUsingShaders(): boolean;
  32273. set computeBonesUsingShaders(value: boolean);
  32274. /**
  32275. * An event triggered before rendering the mesh
  32276. */
  32277. get onBeforeRenderObservable(): Observable<Mesh>;
  32278. /**
  32279. * An event triggered before binding the mesh
  32280. */
  32281. get onBeforeBindObservable(): Observable<Mesh>;
  32282. /**
  32283. * An event triggered after rendering the mesh
  32284. */
  32285. get onAfterRenderObservable(): Observable<Mesh>;
  32286. /**
  32287. * An event triggered before drawing the mesh
  32288. */
  32289. get onBeforeDrawObservable(): Observable<Mesh>;
  32290. private _onBeforeDrawObserver;
  32291. /**
  32292. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32293. */
  32294. set onBeforeDraw(callback: () => void);
  32295. get hasInstances(): boolean;
  32296. get hasThinInstances(): boolean;
  32297. /**
  32298. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32299. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32300. */
  32301. delayLoadState: number;
  32302. /**
  32303. * Gets the list of instances created from this mesh
  32304. * it is not supposed to be modified manually.
  32305. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32306. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32307. */
  32308. instances: InstancedMesh[];
  32309. /**
  32310. * Gets the file containing delay loading data for this mesh
  32311. */
  32312. delayLoadingFile: string;
  32313. /** @hidden */
  32314. _binaryInfo: any;
  32315. /**
  32316. * User defined function used to change how LOD level selection is done
  32317. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32318. */
  32319. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32320. /**
  32321. * Gets or sets the morph target manager
  32322. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32323. */
  32324. get morphTargetManager(): Nullable<MorphTargetManager>;
  32325. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32326. /** @hidden */
  32327. _creationDataStorage: Nullable<_CreationDataStorage>;
  32328. /** @hidden */
  32329. _geometry: Nullable<Geometry>;
  32330. /** @hidden */
  32331. _delayInfo: Array<string>;
  32332. /** @hidden */
  32333. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32334. /** @hidden */
  32335. _instanceDataStorage: _InstanceDataStorage;
  32336. /** @hidden */
  32337. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32338. private _effectiveMaterial;
  32339. /** @hidden */
  32340. _shouldGenerateFlatShading: boolean;
  32341. /** @hidden */
  32342. _originalBuilderSideOrientation: number;
  32343. /**
  32344. * Use this property to change the original side orientation defined at construction time
  32345. */
  32346. overrideMaterialSideOrientation: Nullable<number>;
  32347. /**
  32348. * Gets the source mesh (the one used to clone this one from)
  32349. */
  32350. get source(): Nullable<Mesh>;
  32351. /**
  32352. * Gets the list of clones of this mesh
  32353. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32354. * Note that useClonedMeshMap=true is the default setting
  32355. */
  32356. get cloneMeshMap(): Nullable<{
  32357. [id: string]: Mesh | undefined;
  32358. }>;
  32359. /**
  32360. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32361. */
  32362. get isUnIndexed(): boolean;
  32363. set isUnIndexed(value: boolean);
  32364. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32365. get worldMatrixInstancedBuffer(): Float32Array;
  32366. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32367. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32368. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32369. /**
  32370. * @constructor
  32371. * @param name The value used by scene.getMeshByName() to do a lookup.
  32372. * @param scene The scene to add this mesh to.
  32373. * @param parent The parent of this mesh, if it has one
  32374. * @param source An optional Mesh from which geometry is shared, cloned.
  32375. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32376. * When false, achieved by calling a clone(), also passing False.
  32377. * This will make creation of children, recursive.
  32378. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32379. */
  32380. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32381. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32382. doNotInstantiate: boolean;
  32383. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32384. /**
  32385. * Gets the class name
  32386. * @returns the string "Mesh".
  32387. */
  32388. getClassName(): string;
  32389. /** @hidden */
  32390. get _isMesh(): boolean;
  32391. /**
  32392. * Returns a description of this mesh
  32393. * @param fullDetails define if full details about this mesh must be used
  32394. * @returns a descriptive string representing this mesh
  32395. */
  32396. toString(fullDetails?: boolean): string;
  32397. /** @hidden */
  32398. _unBindEffect(): void;
  32399. /**
  32400. * Gets a boolean indicating if this mesh has LOD
  32401. */
  32402. get hasLODLevels(): boolean;
  32403. /**
  32404. * Gets the list of MeshLODLevel associated with the current mesh
  32405. * @returns an array of MeshLODLevel
  32406. */
  32407. getLODLevels(): MeshLODLevel[];
  32408. private _sortLODLevels;
  32409. /**
  32410. * Add a mesh as LOD level triggered at the given distance.
  32411. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32412. * @param distance The distance from the center of the object to show this level
  32413. * @param mesh The mesh to be added as LOD level (can be null)
  32414. * @return This mesh (for chaining)
  32415. */
  32416. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32417. /**
  32418. * Returns the LOD level mesh at the passed distance or null if not found.
  32419. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32420. * @param distance The distance from the center of the object to show this level
  32421. * @returns a Mesh or `null`
  32422. */
  32423. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32424. /**
  32425. * Remove a mesh from the LOD array
  32426. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32427. * @param mesh defines the mesh to be removed
  32428. * @return This mesh (for chaining)
  32429. */
  32430. removeLODLevel(mesh: Mesh): Mesh;
  32431. /**
  32432. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32433. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32434. * @param camera defines the camera to use to compute distance
  32435. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32436. * @return This mesh (for chaining)
  32437. */
  32438. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32439. /**
  32440. * Gets the mesh internal Geometry object
  32441. */
  32442. get geometry(): Nullable<Geometry>;
  32443. /**
  32444. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32445. * @returns the total number of vertices
  32446. */
  32447. getTotalVertices(): number;
  32448. /**
  32449. * Returns the content of an associated vertex buffer
  32450. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32451. * - VertexBuffer.PositionKind
  32452. * - VertexBuffer.UVKind
  32453. * - VertexBuffer.UV2Kind
  32454. * - VertexBuffer.UV3Kind
  32455. * - VertexBuffer.UV4Kind
  32456. * - VertexBuffer.UV5Kind
  32457. * - VertexBuffer.UV6Kind
  32458. * - VertexBuffer.ColorKind
  32459. * - VertexBuffer.MatricesIndicesKind
  32460. * - VertexBuffer.MatricesIndicesExtraKind
  32461. * - VertexBuffer.MatricesWeightsKind
  32462. * - VertexBuffer.MatricesWeightsExtraKind
  32463. * @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
  32464. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32465. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32466. */
  32467. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32468. /**
  32469. * Returns the mesh VertexBuffer object from the requested `kind`
  32470. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32471. * - VertexBuffer.PositionKind
  32472. * - VertexBuffer.NormalKind
  32473. * - VertexBuffer.UVKind
  32474. * - VertexBuffer.UV2Kind
  32475. * - VertexBuffer.UV3Kind
  32476. * - VertexBuffer.UV4Kind
  32477. * - VertexBuffer.UV5Kind
  32478. * - VertexBuffer.UV6Kind
  32479. * - VertexBuffer.ColorKind
  32480. * - VertexBuffer.MatricesIndicesKind
  32481. * - VertexBuffer.MatricesIndicesExtraKind
  32482. * - VertexBuffer.MatricesWeightsKind
  32483. * - VertexBuffer.MatricesWeightsExtraKind
  32484. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32485. */
  32486. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32487. /**
  32488. * Tests if a specific vertex buffer is associated with this mesh
  32489. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32490. * - VertexBuffer.PositionKind
  32491. * - VertexBuffer.NormalKind
  32492. * - VertexBuffer.UVKind
  32493. * - VertexBuffer.UV2Kind
  32494. * - VertexBuffer.UV3Kind
  32495. * - VertexBuffer.UV4Kind
  32496. * - VertexBuffer.UV5Kind
  32497. * - VertexBuffer.UV6Kind
  32498. * - VertexBuffer.ColorKind
  32499. * - VertexBuffer.MatricesIndicesKind
  32500. * - VertexBuffer.MatricesIndicesExtraKind
  32501. * - VertexBuffer.MatricesWeightsKind
  32502. * - VertexBuffer.MatricesWeightsExtraKind
  32503. * @returns a boolean
  32504. */
  32505. isVerticesDataPresent(kind: string): boolean;
  32506. /**
  32507. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32508. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32509. * - VertexBuffer.PositionKind
  32510. * - VertexBuffer.UVKind
  32511. * - VertexBuffer.UV2Kind
  32512. * - VertexBuffer.UV3Kind
  32513. * - VertexBuffer.UV4Kind
  32514. * - VertexBuffer.UV5Kind
  32515. * - VertexBuffer.UV6Kind
  32516. * - VertexBuffer.ColorKind
  32517. * - VertexBuffer.MatricesIndicesKind
  32518. * - VertexBuffer.MatricesIndicesExtraKind
  32519. * - VertexBuffer.MatricesWeightsKind
  32520. * - VertexBuffer.MatricesWeightsExtraKind
  32521. * @returns a boolean
  32522. */
  32523. isVertexBufferUpdatable(kind: string): boolean;
  32524. /**
  32525. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32526. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32527. * - VertexBuffer.PositionKind
  32528. * - VertexBuffer.NormalKind
  32529. * - VertexBuffer.UVKind
  32530. * - VertexBuffer.UV2Kind
  32531. * - VertexBuffer.UV3Kind
  32532. * - VertexBuffer.UV4Kind
  32533. * - VertexBuffer.UV5Kind
  32534. * - VertexBuffer.UV6Kind
  32535. * - VertexBuffer.ColorKind
  32536. * - VertexBuffer.MatricesIndicesKind
  32537. * - VertexBuffer.MatricesIndicesExtraKind
  32538. * - VertexBuffer.MatricesWeightsKind
  32539. * - VertexBuffer.MatricesWeightsExtraKind
  32540. * @returns an array of strings
  32541. */
  32542. getVerticesDataKinds(): string[];
  32543. /**
  32544. * Returns a positive integer : the total number of indices in this mesh geometry.
  32545. * @returns the numner of indices or zero if the mesh has no geometry.
  32546. */
  32547. getTotalIndices(): number;
  32548. /**
  32549. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32550. * @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.
  32551. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32552. * @returns the indices array or an empty array if the mesh has no geometry
  32553. */
  32554. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32555. get isBlocked(): boolean;
  32556. /**
  32557. * Determine if the current mesh is ready to be rendered
  32558. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32559. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32560. * @returns true if all associated assets are ready (material, textures, shaders)
  32561. */
  32562. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32563. /**
  32564. * 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.
  32565. */
  32566. get areNormalsFrozen(): boolean;
  32567. /**
  32568. * 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.
  32569. * @returns the current mesh
  32570. */
  32571. freezeNormals(): Mesh;
  32572. /**
  32573. * 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
  32574. * @returns the current mesh
  32575. */
  32576. unfreezeNormals(): Mesh;
  32577. /**
  32578. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32579. */
  32580. set overridenInstanceCount(count: number);
  32581. /** @hidden */
  32582. _preActivate(): Mesh;
  32583. /** @hidden */
  32584. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32585. /** @hidden */
  32586. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32587. protected _afterComputeWorldMatrix(): void;
  32588. /** @hidden */
  32589. _postActivate(): void;
  32590. /**
  32591. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32592. * This means the mesh underlying bounding box and sphere are recomputed.
  32593. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32594. * @returns the current mesh
  32595. */
  32596. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32597. /** @hidden */
  32598. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32599. /**
  32600. * This function will subdivide the mesh into multiple submeshes
  32601. * @param count defines the expected number of submeshes
  32602. */
  32603. subdivide(count: number): void;
  32604. /**
  32605. * Copy a FloatArray into a specific associated vertex buffer
  32606. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32607. * - VertexBuffer.PositionKind
  32608. * - VertexBuffer.UVKind
  32609. * - VertexBuffer.UV2Kind
  32610. * - VertexBuffer.UV3Kind
  32611. * - VertexBuffer.UV4Kind
  32612. * - VertexBuffer.UV5Kind
  32613. * - VertexBuffer.UV6Kind
  32614. * - VertexBuffer.ColorKind
  32615. * - VertexBuffer.MatricesIndicesKind
  32616. * - VertexBuffer.MatricesIndicesExtraKind
  32617. * - VertexBuffer.MatricesWeightsKind
  32618. * - VertexBuffer.MatricesWeightsExtraKind
  32619. * @param data defines the data source
  32620. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32621. * @param stride defines the data stride size (can be null)
  32622. * @returns the current mesh
  32623. */
  32624. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32625. /**
  32626. * Delete a vertex buffer associated with this mesh
  32627. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32628. * - VertexBuffer.PositionKind
  32629. * - VertexBuffer.UVKind
  32630. * - VertexBuffer.UV2Kind
  32631. * - VertexBuffer.UV3Kind
  32632. * - VertexBuffer.UV4Kind
  32633. * - VertexBuffer.UV5Kind
  32634. * - VertexBuffer.UV6Kind
  32635. * - VertexBuffer.ColorKind
  32636. * - VertexBuffer.MatricesIndicesKind
  32637. * - VertexBuffer.MatricesIndicesExtraKind
  32638. * - VertexBuffer.MatricesWeightsKind
  32639. * - VertexBuffer.MatricesWeightsExtraKind
  32640. */
  32641. removeVerticesData(kind: string): void;
  32642. /**
  32643. * Flags an associated vertex buffer as updatable
  32644. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32645. * - VertexBuffer.PositionKind
  32646. * - VertexBuffer.UVKind
  32647. * - VertexBuffer.UV2Kind
  32648. * - VertexBuffer.UV3Kind
  32649. * - VertexBuffer.UV4Kind
  32650. * - VertexBuffer.UV5Kind
  32651. * - VertexBuffer.UV6Kind
  32652. * - VertexBuffer.ColorKind
  32653. * - VertexBuffer.MatricesIndicesKind
  32654. * - VertexBuffer.MatricesIndicesExtraKind
  32655. * - VertexBuffer.MatricesWeightsKind
  32656. * - VertexBuffer.MatricesWeightsExtraKind
  32657. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32658. */
  32659. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32660. /**
  32661. * Sets the mesh global Vertex Buffer
  32662. * @param buffer defines the buffer to use
  32663. * @returns the current mesh
  32664. */
  32665. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32666. /**
  32667. * Update a specific associated vertex buffer
  32668. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32669. * - VertexBuffer.PositionKind
  32670. * - VertexBuffer.UVKind
  32671. * - VertexBuffer.UV2Kind
  32672. * - VertexBuffer.UV3Kind
  32673. * - VertexBuffer.UV4Kind
  32674. * - VertexBuffer.UV5Kind
  32675. * - VertexBuffer.UV6Kind
  32676. * - VertexBuffer.ColorKind
  32677. * - VertexBuffer.MatricesIndicesKind
  32678. * - VertexBuffer.MatricesIndicesExtraKind
  32679. * - VertexBuffer.MatricesWeightsKind
  32680. * - VertexBuffer.MatricesWeightsExtraKind
  32681. * @param data defines the data source
  32682. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32683. * @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)
  32684. * @returns the current mesh
  32685. */
  32686. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32687. /**
  32688. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32689. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32690. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32691. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32692. * @returns the current mesh
  32693. */
  32694. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32695. /**
  32696. * Creates a un-shared specific occurence of the geometry for the mesh.
  32697. * @returns the current mesh
  32698. */
  32699. makeGeometryUnique(): Mesh;
  32700. /**
  32701. * Set the index buffer of this mesh
  32702. * @param indices defines the source data
  32703. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32704. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32705. * @returns the current mesh
  32706. */
  32707. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32708. /**
  32709. * Update the current index buffer
  32710. * @param indices defines the source data
  32711. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32712. * @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)
  32713. * @returns the current mesh
  32714. */
  32715. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32716. /**
  32717. * Invert the geometry to move from a right handed system to a left handed one.
  32718. * @returns the current mesh
  32719. */
  32720. toLeftHanded(): Mesh;
  32721. /** @hidden */
  32722. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32723. /** @hidden */
  32724. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32725. /**
  32726. * Registers for this mesh a javascript function called just before the rendering process
  32727. * @param func defines the function to call before rendering this mesh
  32728. * @returns the current mesh
  32729. */
  32730. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32731. /**
  32732. * Disposes a previously registered javascript function called before the rendering
  32733. * @param func defines the function to remove
  32734. * @returns the current mesh
  32735. */
  32736. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32737. /**
  32738. * Registers for this mesh a javascript function called just after the rendering is complete
  32739. * @param func defines the function to call after rendering this mesh
  32740. * @returns the current mesh
  32741. */
  32742. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32743. /**
  32744. * Disposes a previously registered javascript function called after the rendering.
  32745. * @param func defines the function to remove
  32746. * @returns the current mesh
  32747. */
  32748. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32749. /** @hidden */
  32750. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  32751. /** @hidden */
  32752. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  32753. /** @hidden */
  32754. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  32755. /** @hidden */
  32756. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  32757. /** @hidden */
  32758. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  32759. /** @hidden */
  32760. _rebuild(): void;
  32761. /** @hidden */
  32762. _freeze(): void;
  32763. /** @hidden */
  32764. _unFreeze(): void;
  32765. /**
  32766. * 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
  32767. * @param subMesh defines the subMesh to render
  32768. * @param enableAlphaMode defines if alpha mode can be changed
  32769. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  32770. * @returns the current mesh
  32771. */
  32772. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  32773. private _onBeforeDraw;
  32774. /**
  32775. * Renormalize the mesh and patch it up if there are no weights
  32776. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  32777. * However in the case of zero weights then we set just a single influence to 1.
  32778. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  32779. */
  32780. cleanMatrixWeights(): void;
  32781. private normalizeSkinFourWeights;
  32782. private normalizeSkinWeightsAndExtra;
  32783. /**
  32784. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  32785. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  32786. * the user know there was an issue with importing the mesh
  32787. * @returns a validation object with skinned, valid and report string
  32788. */
  32789. validateSkinning(): {
  32790. skinned: boolean;
  32791. valid: boolean;
  32792. report: string;
  32793. };
  32794. /** @hidden */
  32795. _checkDelayState(): Mesh;
  32796. private _queueLoad;
  32797. /**
  32798. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32799. * A mesh is in the frustum if its bounding box intersects the frustum
  32800. * @param frustumPlanes defines the frustum to test
  32801. * @returns true if the mesh is in the frustum planes
  32802. */
  32803. isInFrustum(frustumPlanes: Plane[]): boolean;
  32804. /**
  32805. * Sets the mesh material by the material or multiMaterial `id` property
  32806. * @param id is a string identifying the material or the multiMaterial
  32807. * @returns the current mesh
  32808. */
  32809. setMaterialByID(id: string): Mesh;
  32810. /**
  32811. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  32812. * @returns an array of IAnimatable
  32813. */
  32814. getAnimatables(): IAnimatable[];
  32815. /**
  32816. * Modifies the mesh geometry according to the passed transformation matrix.
  32817. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  32818. * The mesh normals are modified using the same transformation.
  32819. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32820. * @param transform defines the transform matrix to use
  32821. * @see https://doc.babylonjs.com/resources/baking_transformations
  32822. * @returns the current mesh
  32823. */
  32824. bakeTransformIntoVertices(transform: Matrix): Mesh;
  32825. /**
  32826. * Modifies the mesh geometry according to its own current World Matrix.
  32827. * The mesh World Matrix is then reset.
  32828. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  32829. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32830. * @see https://doc.babylonjs.com/resources/baking_transformations
  32831. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  32832. * @returns the current mesh
  32833. */
  32834. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  32835. /** @hidden */
  32836. get _positions(): Nullable<Vector3[]>;
  32837. /** @hidden */
  32838. _resetPointsArrayCache(): Mesh;
  32839. /** @hidden */
  32840. _generatePointsArray(): boolean;
  32841. /**
  32842. * Returns a new Mesh object generated from the current mesh properties.
  32843. * This method must not get confused with createInstance()
  32844. * @param name is a string, the name given to the new mesh
  32845. * @param newParent can be any Node object (default `null`)
  32846. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  32847. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  32848. * @returns a new mesh
  32849. */
  32850. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  32851. /**
  32852. * Releases resources associated with this mesh.
  32853. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32854. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32855. */
  32856. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32857. /** @hidden */
  32858. _disposeInstanceSpecificData(): void;
  32859. /** @hidden */
  32860. _disposeThinInstanceSpecificData(): void;
  32861. /**
  32862. * Modifies the mesh geometry according to a displacement map.
  32863. * 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.
  32864. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32865. * @param url is a string, the URL from the image file is to be downloaded.
  32866. * @param minHeight is the lower limit of the displacement.
  32867. * @param maxHeight is the upper limit of the displacement.
  32868. * @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.
  32869. * @param uvOffset is an optional vector2 used to offset UV.
  32870. * @param uvScale is an optional vector2 used to scale UV.
  32871. * @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.
  32872. * @returns the Mesh.
  32873. */
  32874. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32875. /**
  32876. * Modifies the mesh geometry according to a displacementMap buffer.
  32877. * 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.
  32878. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32879. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  32880. * @param heightMapWidth is the width of the buffer image.
  32881. * @param heightMapHeight is the height of the buffer image.
  32882. * @param minHeight is the lower limit of the displacement.
  32883. * @param maxHeight is the upper limit of the displacement.
  32884. * @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.
  32885. * @param uvOffset is an optional vector2 used to offset UV.
  32886. * @param uvScale is an optional vector2 used to scale UV.
  32887. * @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.
  32888. * @returns the Mesh.
  32889. */
  32890. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32891. /**
  32892. * Modify the mesh to get a flat shading rendering.
  32893. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  32894. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  32895. * @returns current mesh
  32896. */
  32897. convertToFlatShadedMesh(): Mesh;
  32898. /**
  32899. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  32900. * In other words, more vertices, no more indices and a single bigger VBO.
  32901. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  32902. * @returns current mesh
  32903. */
  32904. convertToUnIndexedMesh(): Mesh;
  32905. /**
  32906. * Inverses facet orientations.
  32907. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32908. * @param flipNormals will also inverts the normals
  32909. * @returns current mesh
  32910. */
  32911. flipFaces(flipNormals?: boolean): Mesh;
  32912. /**
  32913. * Increase the number of facets and hence vertices in a mesh
  32914. * Vertex normals are interpolated from existing vertex normals
  32915. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32916. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  32917. */
  32918. increaseVertices(numberPerEdge: number): void;
  32919. /**
  32920. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  32921. * This will undo any application of covertToFlatShadedMesh
  32922. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32923. */
  32924. forceSharedVertices(): void;
  32925. /** @hidden */
  32926. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  32927. /** @hidden */
  32928. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  32929. /**
  32930. * Creates a new InstancedMesh object from the mesh model.
  32931. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32932. * @param name defines the name of the new instance
  32933. * @returns a new InstancedMesh
  32934. */
  32935. createInstance(name: string): InstancedMesh;
  32936. /**
  32937. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  32938. * After this call, all the mesh instances have the same submeshes than the current mesh.
  32939. * @returns the current mesh
  32940. */
  32941. synchronizeInstances(): Mesh;
  32942. /**
  32943. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  32944. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  32945. * This should be used together with the simplification to avoid disappearing triangles.
  32946. * @param successCallback an optional success callback to be called after the optimization finished.
  32947. * @returns the current mesh
  32948. */
  32949. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  32950. /**
  32951. * Serialize current mesh
  32952. * @param serializationObject defines the object which will receive the serialization data
  32953. */
  32954. serialize(serializationObject: any): void;
  32955. /** @hidden */
  32956. _syncGeometryWithMorphTargetManager(): void;
  32957. /** @hidden */
  32958. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  32959. /**
  32960. * Returns a new Mesh object parsed from the source provided.
  32961. * @param parsedMesh is the source
  32962. * @param scene defines the hosting scene
  32963. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  32964. * @returns a new Mesh
  32965. */
  32966. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  32967. /**
  32968. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  32969. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  32970. * @param name defines the name of the mesh to create
  32971. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  32972. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  32973. * @param closePath creates a seam between the first and the last points of each path of the path array
  32974. * @param offset is taken in account only if the `pathArray` is containing a single path
  32975. * @param scene defines the hosting scene
  32976. * @param updatable defines if the mesh must be flagged as updatable
  32977. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  32978. * @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)
  32979. * @returns a new Mesh
  32980. */
  32981. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  32982. /**
  32983. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  32984. * @param name defines the name of the mesh to create
  32985. * @param radius sets the radius size (float) of the polygon (default 0.5)
  32986. * @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
  32987. * @param scene defines the hosting scene
  32988. * @param updatable defines if the mesh must be flagged as updatable
  32989. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  32990. * @returns a new Mesh
  32991. */
  32992. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  32993. /**
  32994. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  32995. * @param name defines the name of the mesh to create
  32996. * @param size sets the size (float) of each box side (default 1)
  32997. * @param scene defines the hosting scene
  32998. * @param updatable defines if the mesh must be flagged as updatable
  32999. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33000. * @returns a new Mesh
  33001. */
  33002. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33003. /**
  33004. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33005. * @param name defines the name of the mesh to create
  33006. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33007. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33008. * @param scene defines the hosting scene
  33009. * @param updatable defines if the mesh must be flagged as updatable
  33010. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33011. * @returns a new Mesh
  33012. */
  33013. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33014. /**
  33015. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33016. * @param name defines the name of the mesh to create
  33017. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33018. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33019. * @param scene defines the hosting scene
  33020. * @returns a new Mesh
  33021. */
  33022. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33023. /**
  33024. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33025. * @param name defines the name of the mesh to create
  33026. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33027. * @param diameterTop set the top cap diameter (floats, default 1)
  33028. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33029. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33030. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33031. * @param scene defines the hosting scene
  33032. * @param updatable defines if the mesh must be flagged as updatable
  33033. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33034. * @returns a new Mesh
  33035. */
  33036. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33037. /**
  33038. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33039. * @param name defines the name of the mesh to create
  33040. * @param diameter sets the diameter size (float) of the torus (default 1)
  33041. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33042. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33043. * @param scene defines the hosting scene
  33044. * @param updatable defines if the mesh must be flagged as updatable
  33045. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33046. * @returns a new Mesh
  33047. */
  33048. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33049. /**
  33050. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33051. * @param name defines the name of the mesh to create
  33052. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33053. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33054. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33055. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33056. * @param p the number of windings on X axis (positive integers, default 2)
  33057. * @param q the number of windings on Y axis (positive integers, default 3)
  33058. * @param scene defines the hosting scene
  33059. * @param updatable defines if the mesh must be flagged as updatable
  33060. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33061. * @returns a new Mesh
  33062. */
  33063. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33064. /**
  33065. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33066. * @param name defines the name of the mesh to create
  33067. * @param points is an array successive Vector3
  33068. * @param scene defines the hosting scene
  33069. * @param updatable defines if the mesh must be flagged as updatable
  33070. * @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).
  33071. * @returns a new Mesh
  33072. */
  33073. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33074. /**
  33075. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33076. * @param name defines the name of the mesh to create
  33077. * @param points is an array successive Vector3
  33078. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33079. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33080. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33081. * @param scene defines the hosting scene
  33082. * @param updatable defines if the mesh must be flagged as updatable
  33083. * @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)
  33084. * @returns a new Mesh
  33085. */
  33086. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33087. /**
  33088. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33089. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33090. * 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.
  33091. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33092. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33093. * Remember you can only change the shape positions, not their number when updating a polygon.
  33094. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33095. * @param name defines the name of the mesh to create
  33096. * @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
  33097. * @param scene defines the hosting scene
  33098. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33099. * @param updatable defines if the mesh must be flagged as updatable
  33100. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33101. * @param earcutInjection can be used to inject your own earcut reference
  33102. * @returns a new Mesh
  33103. */
  33104. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33105. /**
  33106. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33108. * @param name defines the name of the mesh to create
  33109. * @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
  33110. * @param depth defines the height of extrusion
  33111. * @param scene defines the hosting scene
  33112. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33113. * @param updatable defines if the mesh must be flagged as updatable
  33114. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33115. * @param earcutInjection can be used to inject your own earcut reference
  33116. * @returns a new Mesh
  33117. */
  33118. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33119. /**
  33120. * Creates an extruded shape mesh.
  33121. * 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
  33122. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33123. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33124. * @param name defines the name of the mesh to create
  33125. * @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
  33126. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33127. * @param scale is the value to scale the shape
  33128. * @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
  33129. * @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
  33130. * @param scene defines the hosting scene
  33131. * @param updatable defines if the mesh must be flagged as updatable
  33132. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33133. * @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)
  33134. * @returns a new Mesh
  33135. */
  33136. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33137. /**
  33138. * Creates an custom extruded shape mesh.
  33139. * The custom extrusion is a parametric shape.
  33140. * It has no predefined shape. Its final shape will depend on the input parameters.
  33141. * Please consider using the same method from the MeshBuilder class instead
  33142. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33143. * @param name defines the name of the mesh to create
  33144. * @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
  33145. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33146. * @param scaleFunction is a custom Javascript function called on each path point
  33147. * @param rotationFunction is a custom Javascript function called on each path point
  33148. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33149. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33150. * @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
  33151. * @param scene defines the hosting scene
  33152. * @param updatable defines if the mesh must be flagged as updatable
  33153. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33154. * @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)
  33155. * @returns a new Mesh
  33156. */
  33157. 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;
  33158. /**
  33159. * Creates lathe mesh.
  33160. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33161. * Please consider using the same method from the MeshBuilder class instead
  33162. * @param name defines the name of the mesh to create
  33163. * @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
  33164. * @param radius is the radius value of the lathe
  33165. * @param tessellation is the side number of the lathe.
  33166. * @param scene defines the hosting scene
  33167. * @param updatable defines if the mesh must be flagged as updatable
  33168. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33169. * @returns a new Mesh
  33170. */
  33171. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33172. /**
  33173. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33174. * @param name defines the name of the mesh to create
  33175. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33176. * @param scene defines the hosting scene
  33177. * @param updatable defines if the mesh must be flagged as updatable
  33178. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33179. * @returns a new Mesh
  33180. */
  33181. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33182. /**
  33183. * Creates a ground mesh.
  33184. * Please consider using the same method from the MeshBuilder class instead
  33185. * @param name defines the name of the mesh to create
  33186. * @param width set the width of the ground
  33187. * @param height set the height of the ground
  33188. * @param subdivisions sets the number of subdivisions per side
  33189. * @param scene defines the hosting scene
  33190. * @param updatable defines if the mesh must be flagged as updatable
  33191. * @returns a new Mesh
  33192. */
  33193. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33194. /**
  33195. * Creates a tiled ground mesh.
  33196. * Please consider using the same method from the MeshBuilder class instead
  33197. * @param name defines the name of the mesh to create
  33198. * @param xmin set the ground minimum X coordinate
  33199. * @param zmin set the ground minimum Y coordinate
  33200. * @param xmax set the ground maximum X coordinate
  33201. * @param zmax set the ground maximum Z coordinate
  33202. * @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
  33203. * @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
  33204. * @param scene defines the hosting scene
  33205. * @param updatable defines if the mesh must be flagged as updatable
  33206. * @returns a new Mesh
  33207. */
  33208. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33209. w: number;
  33210. h: number;
  33211. }, precision: {
  33212. w: number;
  33213. h: number;
  33214. }, scene: Scene, updatable?: boolean): Mesh;
  33215. /**
  33216. * Creates a ground mesh from a height map.
  33217. * Please consider using the same method from the MeshBuilder class instead
  33218. * @see https://doc.babylonjs.com/babylon101/height_map
  33219. * @param name defines the name of the mesh to create
  33220. * @param url sets the URL of the height map image resource
  33221. * @param width set the ground width size
  33222. * @param height set the ground height size
  33223. * @param subdivisions sets the number of subdivision per side
  33224. * @param minHeight is the minimum altitude on the ground
  33225. * @param maxHeight is the maximum altitude on the ground
  33226. * @param scene defines the hosting scene
  33227. * @param updatable defines if the mesh must be flagged as updatable
  33228. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33229. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33230. * @returns a new Mesh
  33231. */
  33232. 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;
  33233. /**
  33234. * Creates a tube mesh.
  33235. * The tube is a parametric shape.
  33236. * It has no predefined shape. Its final shape will depend on the input parameters.
  33237. * Please consider using the same method from the MeshBuilder class instead
  33238. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33239. * @param name defines the name of the mesh to create
  33240. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33241. * @param radius sets the tube radius size
  33242. * @param tessellation is the number of sides on the tubular surface
  33243. * @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
  33244. * @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
  33245. * @param scene defines the hosting scene
  33246. * @param updatable defines if the mesh must be flagged as updatable
  33247. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33248. * @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)
  33249. * @returns a new Mesh
  33250. */
  33251. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33252. (i: number, distance: number): number;
  33253. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33254. /**
  33255. * Creates a polyhedron mesh.
  33256. * Please consider using the same method from the MeshBuilder class instead.
  33257. * * 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
  33258. * * The parameter `size` (positive float, default 1) sets the polygon size
  33259. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33260. * * 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`
  33261. * * 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
  33262. * * 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)`)
  33263. * * 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
  33264. * * 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
  33265. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33266. * * 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
  33267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33268. * @param name defines the name of the mesh to create
  33269. * @param options defines the options used to create the mesh
  33270. * @param scene defines the hosting scene
  33271. * @returns a new Mesh
  33272. */
  33273. static CreatePolyhedron(name: string, options: {
  33274. type?: number;
  33275. size?: number;
  33276. sizeX?: number;
  33277. sizeY?: number;
  33278. sizeZ?: number;
  33279. custom?: any;
  33280. faceUV?: Vector4[];
  33281. faceColors?: Color4[];
  33282. updatable?: boolean;
  33283. sideOrientation?: number;
  33284. }, scene: Scene): Mesh;
  33285. /**
  33286. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33287. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33288. * * 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`)
  33289. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33290. * * 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
  33291. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33292. * * 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
  33293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33294. * @param name defines the name of the mesh
  33295. * @param options defines the options used to create the mesh
  33296. * @param scene defines the hosting scene
  33297. * @returns a new Mesh
  33298. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33299. */
  33300. static CreateIcoSphere(name: string, options: {
  33301. radius?: number;
  33302. flat?: boolean;
  33303. subdivisions?: number;
  33304. sideOrientation?: number;
  33305. updatable?: boolean;
  33306. }, scene: Scene): Mesh;
  33307. /**
  33308. * Creates a decal mesh.
  33309. * Please consider using the same method from the MeshBuilder class instead.
  33310. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33311. * @param name defines the name of the mesh
  33312. * @param sourceMesh defines the mesh receiving the decal
  33313. * @param position sets the position of the decal in world coordinates
  33314. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33315. * @param size sets the decal scaling
  33316. * @param angle sets the angle to rotate the decal
  33317. * @returns a new Mesh
  33318. */
  33319. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33320. /** Creates a Capsule Mesh
  33321. * @param name defines the name of the mesh.
  33322. * @param options the constructors options used to shape the mesh.
  33323. * @param scene defines the scene the mesh is scoped to.
  33324. * @returns the capsule mesh
  33325. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33326. */
  33327. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33328. /**
  33329. * Prepare internal position array for software CPU skinning
  33330. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33331. */
  33332. setPositionsForCPUSkinning(): Float32Array;
  33333. /**
  33334. * Prepare internal normal array for software CPU skinning
  33335. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33336. */
  33337. setNormalsForCPUSkinning(): Float32Array;
  33338. /**
  33339. * Updates the vertex buffer by applying transformation from the bones
  33340. * @param skeleton defines the skeleton to apply to current mesh
  33341. * @returns the current mesh
  33342. */
  33343. applySkeleton(skeleton: Skeleton): Mesh;
  33344. /**
  33345. * 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
  33346. * @param meshes defines the list of meshes to scan
  33347. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33348. */
  33349. static MinMax(meshes: AbstractMesh[]): {
  33350. min: Vector3;
  33351. max: Vector3;
  33352. };
  33353. /**
  33354. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33355. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33356. * @returns a vector3
  33357. */
  33358. static Center(meshesOrMinMaxVector: {
  33359. min: Vector3;
  33360. max: Vector3;
  33361. } | AbstractMesh[]): Vector3;
  33362. /**
  33363. * Merge the array of meshes into a single mesh for performance reasons.
  33364. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33365. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33366. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33367. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33368. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33369. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33370. * @returns a new mesh
  33371. */
  33372. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33373. /** @hidden */
  33374. addInstance(instance: InstancedMesh): void;
  33375. /** @hidden */
  33376. removeInstance(instance: InstancedMesh): void;
  33377. }
  33378. }
  33379. declare module BABYLON {
  33380. /**
  33381. * The options Interface for creating a Capsule Mesh
  33382. */
  33383. export interface ICreateCapsuleOptions {
  33384. /** The Orientation of the capsule. Default : Vector3.Up() */
  33385. orientation?: Vector3;
  33386. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  33387. subdivisions: number;
  33388. /** Number of cylindrical segments on the capsule. */
  33389. tessellation: number;
  33390. /** Height or Length of the capsule. */
  33391. height: number;
  33392. /** Radius of the capsule. */
  33393. radius: number;
  33394. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  33395. capSubdivisions: number;
  33396. /** Overwrite for the top radius. */
  33397. radiusTop?: number;
  33398. /** Overwrite for the bottom radius. */
  33399. radiusBottom?: number;
  33400. /** Overwrite for the top capSubdivisions. */
  33401. topCapSubdivisions?: number;
  33402. /** Overwrite for the bottom capSubdivisions. */
  33403. bottomCapSubdivisions?: number;
  33404. }
  33405. /**
  33406. * Class containing static functions to help procedurally build meshes
  33407. */
  33408. export class CapsuleBuilder {
  33409. /**
  33410. * Creates a capsule or a pill mesh
  33411. * @param name defines the name of the mesh
  33412. * @param options The constructors options.
  33413. * @param scene The scene the mesh is scoped to.
  33414. * @returns Capsule Mesh
  33415. */
  33416. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  33417. }
  33418. }
  33419. declare module BABYLON {
  33420. /**
  33421. * Define an interface for all classes that will get and set the data on vertices
  33422. */
  33423. export interface IGetSetVerticesData {
  33424. /**
  33425. * Gets a boolean indicating if specific vertex data is present
  33426. * @param kind defines the vertex data kind to use
  33427. * @returns true is data kind is present
  33428. */
  33429. isVerticesDataPresent(kind: string): boolean;
  33430. /**
  33431. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  33432. * @param kind defines the data kind (Position, normal, etc...)
  33433. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  33434. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33435. * @returns a float array containing vertex data
  33436. */
  33437. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33438. /**
  33439. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33440. * @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.
  33441. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33442. * @returns the indices array or an empty array if the mesh has no geometry
  33443. */
  33444. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33445. /**
  33446. * Set specific vertex data
  33447. * @param kind defines the data kind (Position, normal, etc...)
  33448. * @param data defines the vertex data to use
  33449. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  33450. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  33451. */
  33452. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  33453. /**
  33454. * Update a specific associated vertex buffer
  33455. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33456. * - VertexBuffer.PositionKind
  33457. * - VertexBuffer.UVKind
  33458. * - VertexBuffer.UV2Kind
  33459. * - VertexBuffer.UV3Kind
  33460. * - VertexBuffer.UV4Kind
  33461. * - VertexBuffer.UV5Kind
  33462. * - VertexBuffer.UV6Kind
  33463. * - VertexBuffer.ColorKind
  33464. * - VertexBuffer.MatricesIndicesKind
  33465. * - VertexBuffer.MatricesIndicesExtraKind
  33466. * - VertexBuffer.MatricesWeightsKind
  33467. * - VertexBuffer.MatricesWeightsExtraKind
  33468. * @param data defines the data source
  33469. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33470. * @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)
  33471. */
  33472. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  33473. /**
  33474. * Creates a new index buffer
  33475. * @param indices defines the indices to store in the index buffer
  33476. * @param totalVertices defines the total number of vertices (could be null)
  33477. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  33478. */
  33479. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  33480. }
  33481. /**
  33482. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  33483. */
  33484. export class VertexData {
  33485. /**
  33486. * Mesh side orientation : usually the external or front surface
  33487. */
  33488. static readonly FRONTSIDE: number;
  33489. /**
  33490. * Mesh side orientation : usually the internal or back surface
  33491. */
  33492. static readonly BACKSIDE: number;
  33493. /**
  33494. * Mesh side orientation : both internal and external or front and back surfaces
  33495. */
  33496. static readonly DOUBLESIDE: number;
  33497. /**
  33498. * Mesh side orientation : by default, `FRONTSIDE`
  33499. */
  33500. static readonly DEFAULTSIDE: number;
  33501. /**
  33502. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  33503. */
  33504. positions: Nullable<FloatArray>;
  33505. /**
  33506. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  33507. */
  33508. normals: Nullable<FloatArray>;
  33509. /**
  33510. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  33511. */
  33512. tangents: Nullable<FloatArray>;
  33513. /**
  33514. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33515. */
  33516. uvs: Nullable<FloatArray>;
  33517. /**
  33518. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33519. */
  33520. uvs2: Nullable<FloatArray>;
  33521. /**
  33522. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33523. */
  33524. uvs3: Nullable<FloatArray>;
  33525. /**
  33526. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33527. */
  33528. uvs4: Nullable<FloatArray>;
  33529. /**
  33530. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33531. */
  33532. uvs5: Nullable<FloatArray>;
  33533. /**
  33534. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33535. */
  33536. uvs6: Nullable<FloatArray>;
  33537. /**
  33538. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  33539. */
  33540. colors: Nullable<FloatArray>;
  33541. /**
  33542. * 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).
  33543. */
  33544. matricesIndices: Nullable<FloatArray>;
  33545. /**
  33546. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  33547. */
  33548. matricesWeights: Nullable<FloatArray>;
  33549. /**
  33550. * An array extending the number of possible indices
  33551. */
  33552. matricesIndicesExtra: Nullable<FloatArray>;
  33553. /**
  33554. * An array extending the number of possible weights when the number of indices is extended
  33555. */
  33556. matricesWeightsExtra: Nullable<FloatArray>;
  33557. /**
  33558. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  33559. */
  33560. indices: Nullable<IndicesArray>;
  33561. /**
  33562. * Uses the passed data array to set the set the values for the specified kind of data
  33563. * @param data a linear array of floating numbers
  33564. * @param kind the type of data that is being set, eg positions, colors etc
  33565. */
  33566. set(data: FloatArray, kind: string): void;
  33567. /**
  33568. * Associates the vertexData to the passed Mesh.
  33569. * Sets it as updatable or not (default `false`)
  33570. * @param mesh the mesh the vertexData is applied to
  33571. * @param updatable when used and having the value true allows new data to update the vertexData
  33572. * @returns the VertexData
  33573. */
  33574. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  33575. /**
  33576. * Associates the vertexData to the passed Geometry.
  33577. * Sets it as updatable or not (default `false`)
  33578. * @param geometry the geometry the vertexData is applied to
  33579. * @param updatable when used and having the value true allows new data to update the vertexData
  33580. * @returns VertexData
  33581. */
  33582. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  33583. /**
  33584. * Updates the associated mesh
  33585. * @param mesh the mesh to be updated
  33586. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33587. * @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
  33588. * @returns VertexData
  33589. */
  33590. updateMesh(mesh: Mesh): VertexData;
  33591. /**
  33592. * Updates the associated geometry
  33593. * @param geometry the geometry to be updated
  33594. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33595. * @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
  33596. * @returns VertexData.
  33597. */
  33598. updateGeometry(geometry: Geometry): VertexData;
  33599. private _applyTo;
  33600. private _update;
  33601. /**
  33602. * Transforms each position and each normal of the vertexData according to the passed Matrix
  33603. * @param matrix the transforming matrix
  33604. * @returns the VertexData
  33605. */
  33606. transform(matrix: Matrix): VertexData;
  33607. /**
  33608. * Merges the passed VertexData into the current one
  33609. * @param other the VertexData to be merged into the current one
  33610. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  33611. * @returns the modified VertexData
  33612. */
  33613. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  33614. private _mergeElement;
  33615. private _validate;
  33616. /**
  33617. * Serializes the VertexData
  33618. * @returns a serialized object
  33619. */
  33620. serialize(): any;
  33621. /**
  33622. * Extracts the vertexData from a mesh
  33623. * @param mesh the mesh from which to extract the VertexData
  33624. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  33625. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33626. * @returns the object VertexData associated to the passed mesh
  33627. */
  33628. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33629. /**
  33630. * Extracts the vertexData from the geometry
  33631. * @param geometry the geometry from which to extract the VertexData
  33632. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  33633. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33634. * @returns the object VertexData associated to the passed mesh
  33635. */
  33636. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33637. private static _ExtractFrom;
  33638. /**
  33639. * Creates the VertexData for a Ribbon
  33640. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  33641. * * pathArray array of paths, each of which an array of successive Vector3
  33642. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  33643. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  33644. * * 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
  33645. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33646. * * 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)
  33647. * * 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)
  33648. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  33649. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  33650. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  33651. * @returns the VertexData of the ribbon
  33652. */
  33653. static CreateRibbon(options: {
  33654. pathArray: Vector3[][];
  33655. closeArray?: boolean;
  33656. closePath?: boolean;
  33657. offset?: number;
  33658. sideOrientation?: number;
  33659. frontUVs?: Vector4;
  33660. backUVs?: Vector4;
  33661. invertUV?: boolean;
  33662. uvs?: Vector2[];
  33663. colors?: Color4[];
  33664. }): VertexData;
  33665. /**
  33666. * Creates the VertexData for a box
  33667. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33668. * * size sets the width, height and depth of the box to the value of size, optional default 1
  33669. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  33670. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  33671. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  33672. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33673. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33674. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33675. * * 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)
  33676. * * 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)
  33677. * @returns the VertexData of the box
  33678. */
  33679. static CreateBox(options: {
  33680. size?: number;
  33681. width?: number;
  33682. height?: number;
  33683. depth?: number;
  33684. faceUV?: Vector4[];
  33685. faceColors?: Color4[];
  33686. sideOrientation?: number;
  33687. frontUVs?: Vector4;
  33688. backUVs?: Vector4;
  33689. }): VertexData;
  33690. /**
  33691. * Creates the VertexData for a tiled box
  33692. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33693. * * faceTiles sets the pattern, tile size and number of tiles for a face
  33694. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33695. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33696. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33697. * @returns the VertexData of the box
  33698. */
  33699. static CreateTiledBox(options: {
  33700. pattern?: number;
  33701. width?: number;
  33702. height?: number;
  33703. depth?: number;
  33704. tileSize?: number;
  33705. tileWidth?: number;
  33706. tileHeight?: number;
  33707. alignHorizontal?: number;
  33708. alignVertical?: number;
  33709. faceUV?: Vector4[];
  33710. faceColors?: Color4[];
  33711. sideOrientation?: number;
  33712. }): VertexData;
  33713. /**
  33714. * Creates the VertexData for a tiled plane
  33715. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33716. * * pattern a limited pattern arrangement depending on the number
  33717. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  33718. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  33719. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  33720. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33721. * * 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)
  33722. * * 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)
  33723. * @returns the VertexData of the tiled plane
  33724. */
  33725. static CreateTiledPlane(options: {
  33726. pattern?: number;
  33727. tileSize?: number;
  33728. tileWidth?: number;
  33729. tileHeight?: number;
  33730. size?: number;
  33731. width?: number;
  33732. height?: number;
  33733. alignHorizontal?: number;
  33734. alignVertical?: number;
  33735. sideOrientation?: number;
  33736. frontUVs?: Vector4;
  33737. backUVs?: Vector4;
  33738. }): VertexData;
  33739. /**
  33740. * Creates the VertexData for an ellipsoid, defaults to a sphere
  33741. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33742. * * segments sets the number of horizontal strips optional, default 32
  33743. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  33744. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  33745. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  33746. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  33747. * * 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
  33748. * * 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
  33749. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33750. * * 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)
  33751. * * 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)
  33752. * @returns the VertexData of the ellipsoid
  33753. */
  33754. static CreateSphere(options: {
  33755. segments?: number;
  33756. diameter?: number;
  33757. diameterX?: number;
  33758. diameterY?: number;
  33759. diameterZ?: number;
  33760. arc?: number;
  33761. slice?: number;
  33762. sideOrientation?: number;
  33763. frontUVs?: Vector4;
  33764. backUVs?: Vector4;
  33765. }): VertexData;
  33766. /**
  33767. * Creates the VertexData for a cylinder, cone or prism
  33768. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33769. * * height sets the height (y direction) of the cylinder, optional, default 2
  33770. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  33771. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  33772. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  33773. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33774. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  33775. * * 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
  33776. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33777. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33778. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  33779. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  33780. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33781. * * 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)
  33782. * * 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)
  33783. * @returns the VertexData of the cylinder, cone or prism
  33784. */
  33785. static CreateCylinder(options: {
  33786. height?: number;
  33787. diameterTop?: number;
  33788. diameterBottom?: number;
  33789. diameter?: number;
  33790. tessellation?: number;
  33791. subdivisions?: number;
  33792. arc?: number;
  33793. faceColors?: Color4[];
  33794. faceUV?: Vector4[];
  33795. hasRings?: boolean;
  33796. enclose?: boolean;
  33797. sideOrientation?: number;
  33798. frontUVs?: Vector4;
  33799. backUVs?: Vector4;
  33800. }): VertexData;
  33801. /**
  33802. * Creates the VertexData for a torus
  33803. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33804. * * diameter the diameter of the torus, optional default 1
  33805. * * thickness the diameter of the tube forming the torus, optional default 0.5
  33806. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33807. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33808. * * 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)
  33809. * * 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)
  33810. * @returns the VertexData of the torus
  33811. */
  33812. static CreateTorus(options: {
  33813. diameter?: number;
  33814. thickness?: number;
  33815. tessellation?: number;
  33816. sideOrientation?: number;
  33817. frontUVs?: Vector4;
  33818. backUVs?: Vector4;
  33819. }): VertexData;
  33820. /**
  33821. * Creates the VertexData of the LineSystem
  33822. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  33823. * - lines an array of lines, each line being an array of successive Vector3
  33824. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  33825. * @returns the VertexData of the LineSystem
  33826. */
  33827. static CreateLineSystem(options: {
  33828. lines: Vector3[][];
  33829. colors?: Nullable<Color4[][]>;
  33830. }): VertexData;
  33831. /**
  33832. * Create the VertexData for a DashedLines
  33833. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  33834. * - points an array successive Vector3
  33835. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  33836. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  33837. * - dashNb the intended total number of dashes, optional, default 200
  33838. * @returns the VertexData for the DashedLines
  33839. */
  33840. static CreateDashedLines(options: {
  33841. points: Vector3[];
  33842. dashSize?: number;
  33843. gapSize?: number;
  33844. dashNb?: number;
  33845. }): VertexData;
  33846. /**
  33847. * Creates the VertexData for a Ground
  33848. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33849. * - width the width (x direction) of the ground, optional, default 1
  33850. * - height the height (z direction) of the ground, optional, default 1
  33851. * - subdivisions the number of subdivisions per side, optional, default 1
  33852. * @returns the VertexData of the Ground
  33853. */
  33854. static CreateGround(options: {
  33855. width?: number;
  33856. height?: number;
  33857. subdivisions?: number;
  33858. subdivisionsX?: number;
  33859. subdivisionsY?: number;
  33860. }): VertexData;
  33861. /**
  33862. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  33863. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33864. * * xmin the ground minimum X coordinate, optional, default -1
  33865. * * zmin the ground minimum Z coordinate, optional, default -1
  33866. * * xmax the ground maximum X coordinate, optional, default 1
  33867. * * zmax the ground maximum Z coordinate, optional, default 1
  33868. * * 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}
  33869. * * 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}
  33870. * @returns the VertexData of the TiledGround
  33871. */
  33872. static CreateTiledGround(options: {
  33873. xmin: number;
  33874. zmin: number;
  33875. xmax: number;
  33876. zmax: number;
  33877. subdivisions?: {
  33878. w: number;
  33879. h: number;
  33880. };
  33881. precision?: {
  33882. w: number;
  33883. h: number;
  33884. };
  33885. }): VertexData;
  33886. /**
  33887. * Creates the VertexData of the Ground designed from a heightmap
  33888. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  33889. * * width the width (x direction) of the ground
  33890. * * height the height (z direction) of the ground
  33891. * * subdivisions the number of subdivisions per side
  33892. * * minHeight the minimum altitude on the ground, optional, default 0
  33893. * * maxHeight the maximum altitude on the ground, optional default 1
  33894. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  33895. * * buffer the array holding the image color data
  33896. * * bufferWidth the width of image
  33897. * * bufferHeight the height of image
  33898. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  33899. * @returns the VertexData of the Ground designed from a heightmap
  33900. */
  33901. static CreateGroundFromHeightMap(options: {
  33902. width: number;
  33903. height: number;
  33904. subdivisions: number;
  33905. minHeight: number;
  33906. maxHeight: number;
  33907. colorFilter: Color3;
  33908. buffer: Uint8Array;
  33909. bufferWidth: number;
  33910. bufferHeight: number;
  33911. alphaFilter: number;
  33912. }): VertexData;
  33913. /**
  33914. * Creates the VertexData for a Plane
  33915. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  33916. * * size sets the width and height of the plane to the value of size, optional default 1
  33917. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  33918. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  33919. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33920. * * 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)
  33921. * * 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)
  33922. * @returns the VertexData of the box
  33923. */
  33924. static CreatePlane(options: {
  33925. size?: number;
  33926. width?: number;
  33927. height?: number;
  33928. sideOrientation?: number;
  33929. frontUVs?: Vector4;
  33930. backUVs?: Vector4;
  33931. }): VertexData;
  33932. /**
  33933. * Creates the VertexData of the Disc or regular Polygon
  33934. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  33935. * * radius the radius of the disc, optional default 0.5
  33936. * * tessellation the number of polygon sides, optional, default 64
  33937. * * 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
  33938. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33939. * * 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)
  33940. * * 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)
  33941. * @returns the VertexData of the box
  33942. */
  33943. static CreateDisc(options: {
  33944. radius?: number;
  33945. tessellation?: number;
  33946. arc?: number;
  33947. sideOrientation?: number;
  33948. frontUVs?: Vector4;
  33949. backUVs?: Vector4;
  33950. }): VertexData;
  33951. /**
  33952. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  33953. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  33954. * @param polygon a mesh built from polygonTriangulation.build()
  33955. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33956. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33957. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33958. * @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)
  33959. * @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)
  33960. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  33961. * @returns the VertexData of the Polygon
  33962. */
  33963. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  33964. /**
  33965. * Creates the VertexData of the IcoSphere
  33966. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  33967. * * radius the radius of the IcoSphere, optional default 1
  33968. * * radiusX allows stretching in the x direction, optional, default radius
  33969. * * radiusY allows stretching in the y direction, optional, default radius
  33970. * * radiusZ allows stretching in the z direction, optional, default radius
  33971. * * flat when true creates a flat shaded mesh, optional, default true
  33972. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  33973. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33974. * * 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)
  33975. * * 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)
  33976. * @returns the VertexData of the IcoSphere
  33977. */
  33978. static CreateIcoSphere(options: {
  33979. radius?: number;
  33980. radiusX?: number;
  33981. radiusY?: number;
  33982. radiusZ?: number;
  33983. flat?: boolean;
  33984. subdivisions?: number;
  33985. sideOrientation?: number;
  33986. frontUVs?: Vector4;
  33987. backUVs?: Vector4;
  33988. }): VertexData;
  33989. /**
  33990. * Creates the VertexData for a Polyhedron
  33991. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  33992. * * type provided types are:
  33993. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  33994. * * 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)
  33995. * * size the size of the IcoSphere, optional default 1
  33996. * * sizeX allows stretching in the x direction, optional, default size
  33997. * * sizeY allows stretching in the y direction, optional, default size
  33998. * * sizeZ allows stretching in the z direction, optional, default size
  33999. * * 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
  34000. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34001. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34002. * * flat when true creates a flat shaded mesh, optional, default true
  34003. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34004. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34005. * * 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)
  34006. * * 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)
  34007. * @returns the VertexData of the Polyhedron
  34008. */
  34009. static CreatePolyhedron(options: {
  34010. type?: number;
  34011. size?: number;
  34012. sizeX?: number;
  34013. sizeY?: number;
  34014. sizeZ?: number;
  34015. custom?: any;
  34016. faceUV?: Vector4[];
  34017. faceColors?: Color4[];
  34018. flat?: boolean;
  34019. sideOrientation?: number;
  34020. frontUVs?: Vector4;
  34021. backUVs?: Vector4;
  34022. }): VertexData;
  34023. /**
  34024. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34025. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34026. * @returns the VertexData of the Capsule
  34027. */
  34028. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34029. /**
  34030. * Creates the VertexData for a TorusKnot
  34031. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34032. * * radius the radius of the torus knot, optional, default 2
  34033. * * tube the thickness of the tube, optional, default 0.5
  34034. * * radialSegments the number of sides on each tube segments, optional, default 32
  34035. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34036. * * p the number of windings around the z axis, optional, default 2
  34037. * * q the number of windings around the x axis, optional, default 3
  34038. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34039. * * 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)
  34040. * * 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)
  34041. * @returns the VertexData of the Torus Knot
  34042. */
  34043. static CreateTorusKnot(options: {
  34044. radius?: number;
  34045. tube?: number;
  34046. radialSegments?: number;
  34047. tubularSegments?: number;
  34048. p?: number;
  34049. q?: number;
  34050. sideOrientation?: number;
  34051. frontUVs?: Vector4;
  34052. backUVs?: Vector4;
  34053. }): VertexData;
  34054. /**
  34055. * Compute normals for given positions and indices
  34056. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34057. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34058. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34059. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34060. * * facetNormals : optional array of facet normals (vector3)
  34061. * * facetPositions : optional array of facet positions (vector3)
  34062. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34063. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34064. * * bInfo : optional bounding info, required for facetPartitioning computation
  34065. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34066. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34067. * * useRightHandedSystem: optional boolean to for right handed system computation
  34068. * * depthSort : optional boolean to enable the facet depth sort computation
  34069. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34070. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34071. */
  34072. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34073. facetNormals?: any;
  34074. facetPositions?: any;
  34075. facetPartitioning?: any;
  34076. ratio?: number;
  34077. bInfo?: any;
  34078. bbSize?: Vector3;
  34079. subDiv?: any;
  34080. useRightHandedSystem?: boolean;
  34081. depthSort?: boolean;
  34082. distanceTo?: Vector3;
  34083. depthSortedFacets?: any;
  34084. }): void;
  34085. /** @hidden */
  34086. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34087. /**
  34088. * Applies VertexData created from the imported parameters to the geometry
  34089. * @param parsedVertexData the parsed data from an imported file
  34090. * @param geometry the geometry to apply the VertexData to
  34091. */
  34092. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34093. }
  34094. }
  34095. declare module BABYLON {
  34096. /**
  34097. * Class containing static functions to help procedurally build meshes
  34098. */
  34099. export class DiscBuilder {
  34100. /**
  34101. * Creates a plane polygonal mesh. By default, this is a disc
  34102. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34103. * * 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
  34104. * * 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
  34105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34106. * * 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
  34107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34108. * @param name defines the name of the mesh
  34109. * @param options defines the options used to create the mesh
  34110. * @param scene defines the hosting scene
  34111. * @returns the plane polygonal mesh
  34112. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34113. */
  34114. static CreateDisc(name: string, options: {
  34115. radius?: number;
  34116. tessellation?: number;
  34117. arc?: number;
  34118. updatable?: boolean;
  34119. sideOrientation?: number;
  34120. frontUVs?: Vector4;
  34121. backUVs?: Vector4;
  34122. }, scene?: Nullable<Scene>): Mesh;
  34123. }
  34124. }
  34125. declare module BABYLON {
  34126. /**
  34127. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34128. *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.
  34129. * The SPS is also a particle system. It provides some methods to manage the particles.
  34130. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34131. *
  34132. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34133. */
  34134. export class SolidParticleSystem implements IDisposable {
  34135. /**
  34136. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34137. * Example : var p = SPS.particles[i];
  34138. */
  34139. particles: SolidParticle[];
  34140. /**
  34141. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34142. */
  34143. nbParticles: number;
  34144. /**
  34145. * If the particles must ever face the camera (default false). Useful for planar particles.
  34146. */
  34147. billboard: boolean;
  34148. /**
  34149. * Recompute normals when adding a shape
  34150. */
  34151. recomputeNormals: boolean;
  34152. /**
  34153. * This a counter ofr your own usage. It's not set by any SPS functions.
  34154. */
  34155. counter: number;
  34156. /**
  34157. * The SPS name. This name is also given to the underlying mesh.
  34158. */
  34159. name: string;
  34160. /**
  34161. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34162. */
  34163. mesh: Mesh;
  34164. /**
  34165. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34166. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34167. */
  34168. vars: any;
  34169. /**
  34170. * This array is populated when the SPS is set as 'pickable'.
  34171. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34172. * Each element of this array is an object `{idx: int, faceId: int}`.
  34173. * `idx` is the picked particle index in the `SPS.particles` array
  34174. * `faceId` is the picked face index counted within this particle.
  34175. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34176. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34177. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34178. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34179. */
  34180. pickedParticles: {
  34181. idx: number;
  34182. faceId: number;
  34183. }[];
  34184. /**
  34185. * This array is populated when the SPS is set as 'pickable'
  34186. * Each key of this array is a submesh index.
  34187. * Each element of this array is a second array defined like this :
  34188. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34189. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34190. * `idx` is the picked particle index in the `SPS.particles` array
  34191. * `faceId` is the picked face index counted within this particle.
  34192. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34193. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34194. */
  34195. pickedBySubMesh: {
  34196. idx: number;
  34197. faceId: number;
  34198. }[][];
  34199. /**
  34200. * This array is populated when `enableDepthSort` is set to true.
  34201. * Each element of this array is an instance of the class DepthSortedParticle.
  34202. */
  34203. depthSortedParticles: DepthSortedParticle[];
  34204. /**
  34205. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34206. * @hidden
  34207. */
  34208. _bSphereOnly: boolean;
  34209. /**
  34210. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34211. * @hidden
  34212. */
  34213. _bSphereRadiusFactor: number;
  34214. private _scene;
  34215. private _positions;
  34216. private _indices;
  34217. private _normals;
  34218. private _colors;
  34219. private _uvs;
  34220. private _indices32;
  34221. private _positions32;
  34222. private _normals32;
  34223. private _fixedNormal32;
  34224. private _colors32;
  34225. private _uvs32;
  34226. private _index;
  34227. private _updatable;
  34228. private _pickable;
  34229. private _isVisibilityBoxLocked;
  34230. private _alwaysVisible;
  34231. private _depthSort;
  34232. private _expandable;
  34233. private _shapeCounter;
  34234. private _copy;
  34235. private _color;
  34236. private _computeParticleColor;
  34237. private _computeParticleTexture;
  34238. private _computeParticleRotation;
  34239. private _computeParticleVertex;
  34240. private _computeBoundingBox;
  34241. private _depthSortParticles;
  34242. private _camera;
  34243. private _mustUnrotateFixedNormals;
  34244. private _particlesIntersect;
  34245. private _needs32Bits;
  34246. private _isNotBuilt;
  34247. private _lastParticleId;
  34248. private _idxOfId;
  34249. private _multimaterialEnabled;
  34250. private _useModelMaterial;
  34251. private _indicesByMaterial;
  34252. private _materialIndexes;
  34253. private _depthSortFunction;
  34254. private _materialSortFunction;
  34255. private _materials;
  34256. private _multimaterial;
  34257. private _materialIndexesById;
  34258. private _defaultMaterial;
  34259. private _autoUpdateSubMeshes;
  34260. private _tmpVertex;
  34261. /**
  34262. * Creates a SPS (Solid Particle System) object.
  34263. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34264. * @param scene (Scene) is the scene in which the SPS is added.
  34265. * @param options defines the options of the sps e.g.
  34266. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34267. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34268. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34269. * * 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.
  34270. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34271. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34272. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34273. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34274. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34275. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34276. */
  34277. constructor(name: string, scene: Scene, options?: {
  34278. updatable?: boolean;
  34279. isPickable?: boolean;
  34280. enableDepthSort?: boolean;
  34281. particleIntersection?: boolean;
  34282. boundingSphereOnly?: boolean;
  34283. bSphereRadiusFactor?: number;
  34284. expandable?: boolean;
  34285. useModelMaterial?: boolean;
  34286. enableMultiMaterial?: boolean;
  34287. });
  34288. /**
  34289. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34290. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34291. * @returns the created mesh
  34292. */
  34293. buildMesh(): Mesh;
  34294. /**
  34295. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34296. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34297. * Thus the particles generated from `digest()` have their property `position` set yet.
  34298. * @param mesh ( Mesh ) is the mesh to be digested
  34299. * @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
  34300. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34301. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34302. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34303. * @returns the current SPS
  34304. */
  34305. digest(mesh: Mesh, options?: {
  34306. facetNb?: number;
  34307. number?: number;
  34308. delta?: number;
  34309. storage?: [];
  34310. }): SolidParticleSystem;
  34311. /**
  34312. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34313. * @hidden
  34314. */
  34315. private _unrotateFixedNormals;
  34316. /**
  34317. * Resets the temporary working copy particle
  34318. * @hidden
  34319. */
  34320. private _resetCopy;
  34321. /**
  34322. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34323. * @param p the current index in the positions array to be updated
  34324. * @param ind the current index in the indices array
  34325. * @param shape a Vector3 array, the shape geometry
  34326. * @param positions the positions array to be updated
  34327. * @param meshInd the shape indices array
  34328. * @param indices the indices array to be updated
  34329. * @param meshUV the shape uv array
  34330. * @param uvs the uv array to be updated
  34331. * @param meshCol the shape color array
  34332. * @param colors the color array to be updated
  34333. * @param meshNor the shape normals array
  34334. * @param normals the normals array to be updated
  34335. * @param idx the particle index
  34336. * @param idxInShape the particle index in its shape
  34337. * @param options the addShape() method passed options
  34338. * @model the particle model
  34339. * @hidden
  34340. */
  34341. private _meshBuilder;
  34342. /**
  34343. * Returns a shape Vector3 array from positions float array
  34344. * @param positions float array
  34345. * @returns a vector3 array
  34346. * @hidden
  34347. */
  34348. private _posToShape;
  34349. /**
  34350. * Returns a shapeUV array from a float uvs (array deep copy)
  34351. * @param uvs as a float array
  34352. * @returns a shapeUV array
  34353. * @hidden
  34354. */
  34355. private _uvsToShapeUV;
  34356. /**
  34357. * Adds a new particle object in the particles array
  34358. * @param idx particle index in particles array
  34359. * @param id particle id
  34360. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34361. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34362. * @param model particle ModelShape object
  34363. * @param shapeId model shape identifier
  34364. * @param idxInShape index of the particle in the current model
  34365. * @param bInfo model bounding info object
  34366. * @param storage target storage array, if any
  34367. * @hidden
  34368. */
  34369. private _addParticle;
  34370. /**
  34371. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34372. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34373. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34374. * @param nb (positive integer) the number of particles to be created from this model
  34375. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34376. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34377. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34378. * @returns the number of shapes in the system
  34379. */
  34380. addShape(mesh: Mesh, nb: number, options?: {
  34381. positionFunction?: any;
  34382. vertexFunction?: any;
  34383. storage?: [];
  34384. }): number;
  34385. /**
  34386. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34387. * @hidden
  34388. */
  34389. private _rebuildParticle;
  34390. /**
  34391. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34392. * @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.
  34393. * @returns the SPS.
  34394. */
  34395. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34396. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34397. * Returns an array with the removed particles.
  34398. * 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.
  34399. * The SPS can't be empty so at least one particle needs to remain in place.
  34400. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34401. * @param start index of the first particle to remove
  34402. * @param end index of the last particle to remove (included)
  34403. * @returns an array populated with the removed particles
  34404. */
  34405. removeParticles(start: number, end: number): SolidParticle[];
  34406. /**
  34407. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34408. * @param solidParticleArray an array populated with Solid Particles objects
  34409. * @returns the SPS
  34410. */
  34411. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34412. /**
  34413. * Creates a new particle and modifies the SPS mesh geometry :
  34414. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34415. * - calls _addParticle() to populate the particle array
  34416. * factorized code from addShape() and insertParticlesFromArray()
  34417. * @param idx particle index in the particles array
  34418. * @param i particle index in its shape
  34419. * @param modelShape particle ModelShape object
  34420. * @param shape shape vertex array
  34421. * @param meshInd shape indices array
  34422. * @param meshUV shape uv array
  34423. * @param meshCol shape color array
  34424. * @param meshNor shape normals array
  34425. * @param bbInfo shape bounding info
  34426. * @param storage target particle storage
  34427. * @options addShape() passed options
  34428. * @hidden
  34429. */
  34430. private _insertNewParticle;
  34431. /**
  34432. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34433. * This method calls `updateParticle()` for each particle of the SPS.
  34434. * For an animated SPS, it is usually called within the render loop.
  34435. * 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.
  34436. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34437. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34438. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34439. * @returns the SPS.
  34440. */
  34441. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34442. /**
  34443. * Disposes the SPS.
  34444. */
  34445. dispose(): void;
  34446. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34447. * idx is the particle index in the SPS
  34448. * faceId is the picked face index counted within this particle.
  34449. * Returns null if the pickInfo can't identify a picked particle.
  34450. * @param pickingInfo (PickingInfo object)
  34451. * @returns {idx: number, faceId: number} or null
  34452. */
  34453. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34454. idx: number;
  34455. faceId: number;
  34456. }>;
  34457. /**
  34458. * Returns a SolidParticle object from its identifier : particle.id
  34459. * @param id (integer) the particle Id
  34460. * @returns the searched particle or null if not found in the SPS.
  34461. */
  34462. getParticleById(id: number): Nullable<SolidParticle>;
  34463. /**
  34464. * Returns a new array populated with the particles having the passed shapeId.
  34465. * @param shapeId (integer) the shape identifier
  34466. * @returns a new solid particle array
  34467. */
  34468. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34469. /**
  34470. * Populates the passed array "ref" with the particles having the passed shapeId.
  34471. * @param shapeId the shape identifier
  34472. * @returns the SPS
  34473. * @param ref
  34474. */
  34475. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34476. /**
  34477. * Computes the required SubMeshes according the materials assigned to the particles.
  34478. * @returns the solid particle system.
  34479. * Does nothing if called before the SPS mesh is built.
  34480. */
  34481. computeSubMeshes(): SolidParticleSystem;
  34482. /**
  34483. * Sorts the solid particles by material when MultiMaterial is enabled.
  34484. * Updates the indices32 array.
  34485. * Updates the indicesByMaterial array.
  34486. * Updates the mesh indices array.
  34487. * @returns the SPS
  34488. * @hidden
  34489. */
  34490. private _sortParticlesByMaterial;
  34491. /**
  34492. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34493. * @hidden
  34494. */
  34495. private _setMaterialIndexesById;
  34496. /**
  34497. * Returns an array with unique values of Materials from the passed array
  34498. * @param array the material array to be checked and filtered
  34499. * @hidden
  34500. */
  34501. private _filterUniqueMaterialId;
  34502. /**
  34503. * Sets a new Standard Material as _defaultMaterial if not already set.
  34504. * @hidden
  34505. */
  34506. private _setDefaultMaterial;
  34507. /**
  34508. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34509. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34510. * @returns the SPS.
  34511. */
  34512. refreshVisibleSize(): SolidParticleSystem;
  34513. /**
  34514. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34515. * @param size the size (float) of the visibility box
  34516. * note : this doesn't lock the SPS mesh bounding box.
  34517. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34518. */
  34519. setVisibilityBox(size: number): void;
  34520. /**
  34521. * Gets whether the SPS as always visible or not
  34522. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34523. */
  34524. get isAlwaysVisible(): boolean;
  34525. /**
  34526. * Sets the SPS as always visible or not
  34527. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34528. */
  34529. set isAlwaysVisible(val: boolean);
  34530. /**
  34531. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34532. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34533. */
  34534. set isVisibilityBoxLocked(val: boolean);
  34535. /**
  34536. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34537. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34538. */
  34539. get isVisibilityBoxLocked(): boolean;
  34540. /**
  34541. * Tells to `setParticles()` to compute the particle rotations or not.
  34542. * Default value : true. The SPS is faster when it's set to false.
  34543. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34544. */
  34545. set computeParticleRotation(val: boolean);
  34546. /**
  34547. * Tells to `setParticles()` to compute the particle colors or not.
  34548. * Default value : true. The SPS is faster when it's set to false.
  34549. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34550. */
  34551. set computeParticleColor(val: boolean);
  34552. set computeParticleTexture(val: boolean);
  34553. /**
  34554. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34555. * Default value : false. The SPS is faster when it's set to false.
  34556. * Note : the particle custom vertex positions aren't stored values.
  34557. */
  34558. set computeParticleVertex(val: boolean);
  34559. /**
  34560. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34561. */
  34562. set computeBoundingBox(val: boolean);
  34563. /**
  34564. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34565. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34566. * Default : `true`
  34567. */
  34568. set depthSortParticles(val: boolean);
  34569. /**
  34570. * Gets if `setParticles()` computes the particle rotations or not.
  34571. * Default value : true. The SPS is faster when it's set to false.
  34572. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34573. */
  34574. get computeParticleRotation(): boolean;
  34575. /**
  34576. * Gets if `setParticles()` computes the particle colors or not.
  34577. * Default value : true. The SPS is faster when it's set to false.
  34578. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34579. */
  34580. get computeParticleColor(): boolean;
  34581. /**
  34582. * Gets if `setParticles()` computes the particle textures or not.
  34583. * Default value : true. The SPS is faster when it's set to false.
  34584. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34585. */
  34586. get computeParticleTexture(): boolean;
  34587. /**
  34588. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34589. * Default value : false. The SPS is faster when it's set to false.
  34590. * Note : the particle custom vertex positions aren't stored values.
  34591. */
  34592. get computeParticleVertex(): boolean;
  34593. /**
  34594. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34595. */
  34596. get computeBoundingBox(): boolean;
  34597. /**
  34598. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34599. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34600. * Default : `true`
  34601. */
  34602. get depthSortParticles(): boolean;
  34603. /**
  34604. * Gets if the SPS is created as expandable at construction time.
  34605. * Default : `false`
  34606. */
  34607. get expandable(): boolean;
  34608. /**
  34609. * Gets if the SPS supports the Multi Materials
  34610. */
  34611. get multimaterialEnabled(): boolean;
  34612. /**
  34613. * Gets if the SPS uses the model materials for its own multimaterial.
  34614. */
  34615. get useModelMaterial(): boolean;
  34616. /**
  34617. * The SPS used material array.
  34618. */
  34619. get materials(): Material[];
  34620. /**
  34621. * Sets the SPS MultiMaterial from the passed materials.
  34622. * Note : the passed array is internally copied and not used then by reference.
  34623. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34624. */
  34625. setMultiMaterial(materials: Material[]): void;
  34626. /**
  34627. * The SPS computed multimaterial object
  34628. */
  34629. get multimaterial(): MultiMaterial;
  34630. set multimaterial(mm: MultiMaterial);
  34631. /**
  34632. * If the subMeshes must be updated on the next call to setParticles()
  34633. */
  34634. get autoUpdateSubMeshes(): boolean;
  34635. set autoUpdateSubMeshes(val: boolean);
  34636. /**
  34637. * This function does nothing. It may be overwritten to set all the particle first values.
  34638. * The SPS doesn't call this function, you may have to call it by your own.
  34639. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34640. */
  34641. initParticles(): void;
  34642. /**
  34643. * This function does nothing. It may be overwritten to recycle a particle.
  34644. * The SPS doesn't call this function, you may have to call it by your own.
  34645. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34646. * @param particle The particle to recycle
  34647. * @returns the recycled particle
  34648. */
  34649. recycleParticle(particle: SolidParticle): SolidParticle;
  34650. /**
  34651. * Updates a particle : this function should be overwritten by the user.
  34652. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34653. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34654. * @example : just set a particle position or velocity and recycle conditions
  34655. * @param particle The particle to update
  34656. * @returns the updated particle
  34657. */
  34658. updateParticle(particle: SolidParticle): SolidParticle;
  34659. /**
  34660. * Updates a vertex of a particle : it can be overwritten by the user.
  34661. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34662. * @param particle the current particle
  34663. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34664. * @param pt the index of the current vertex in the particle shape
  34665. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34666. * @example : just set a vertex particle position or color
  34667. * @returns the sps
  34668. */
  34669. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34670. /**
  34671. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34672. * This does nothing and may be overwritten by the user.
  34673. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34674. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34675. * @param update the boolean update value actually passed to setParticles()
  34676. */
  34677. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34678. /**
  34679. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34680. * This will be passed three parameters.
  34681. * This does nothing and may be overwritten by the user.
  34682. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34683. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34684. * @param update the boolean update value actually passed to setParticles()
  34685. */
  34686. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34687. }
  34688. }
  34689. declare module BABYLON {
  34690. /**
  34691. * Represents one particle of a solid particle system.
  34692. */
  34693. export class SolidParticle {
  34694. /**
  34695. * particle global index
  34696. */
  34697. idx: number;
  34698. /**
  34699. * particle identifier
  34700. */
  34701. id: number;
  34702. /**
  34703. * The color of the particle
  34704. */
  34705. color: Nullable<Color4>;
  34706. /**
  34707. * The world space position of the particle.
  34708. */
  34709. position: Vector3;
  34710. /**
  34711. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34712. */
  34713. rotation: Vector3;
  34714. /**
  34715. * The world space rotation quaternion of the particle.
  34716. */
  34717. rotationQuaternion: Nullable<Quaternion>;
  34718. /**
  34719. * The scaling of the particle.
  34720. */
  34721. scaling: Vector3;
  34722. /**
  34723. * The uvs of the particle.
  34724. */
  34725. uvs: Vector4;
  34726. /**
  34727. * The current speed of the particle.
  34728. */
  34729. velocity: Vector3;
  34730. /**
  34731. * The pivot point in the particle local space.
  34732. */
  34733. pivot: Vector3;
  34734. /**
  34735. * Must the particle be translated from its pivot point in its local space ?
  34736. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34737. * Default : false
  34738. */
  34739. translateFromPivot: boolean;
  34740. /**
  34741. * Is the particle active or not ?
  34742. */
  34743. alive: boolean;
  34744. /**
  34745. * Is the particle visible or not ?
  34746. */
  34747. isVisible: boolean;
  34748. /**
  34749. * Index of this particle in the global "positions" array (Internal use)
  34750. * @hidden
  34751. */
  34752. _pos: number;
  34753. /**
  34754. * @hidden Index of this particle in the global "indices" array (Internal use)
  34755. */
  34756. _ind: number;
  34757. /**
  34758. * @hidden ModelShape of this particle (Internal use)
  34759. */
  34760. _model: ModelShape;
  34761. /**
  34762. * ModelShape id of this particle
  34763. */
  34764. shapeId: number;
  34765. /**
  34766. * Index of the particle in its shape id
  34767. */
  34768. idxInShape: number;
  34769. /**
  34770. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34771. */
  34772. _modelBoundingInfo: BoundingInfo;
  34773. /**
  34774. * @hidden Particle BoundingInfo object (Internal use)
  34775. */
  34776. _boundingInfo: BoundingInfo;
  34777. /**
  34778. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34779. */
  34780. _sps: SolidParticleSystem;
  34781. /**
  34782. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34783. */
  34784. _stillInvisible: boolean;
  34785. /**
  34786. * @hidden Last computed particle rotation matrix
  34787. */
  34788. _rotationMatrix: number[];
  34789. /**
  34790. * Parent particle Id, if any.
  34791. * Default null.
  34792. */
  34793. parentId: Nullable<number>;
  34794. /**
  34795. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34796. */
  34797. materialIndex: Nullable<number>;
  34798. /**
  34799. * Custom object or properties.
  34800. */
  34801. props: Nullable<any>;
  34802. /**
  34803. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34804. * The possible values are :
  34805. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34806. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34807. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34808. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34809. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34810. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34811. * */
  34812. cullingStrategy: number;
  34813. /**
  34814. * @hidden Internal global position in the SPS.
  34815. */
  34816. _globalPosition: Vector3;
  34817. /**
  34818. * Creates a Solid Particle object.
  34819. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34820. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34821. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34822. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34823. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34824. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34825. * @param shapeId (integer) is the model shape identifier in the SPS.
  34826. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34827. * @param sps defines the sps it is associated to
  34828. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34829. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34830. */
  34831. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34832. /**
  34833. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34834. * @param target the particle target
  34835. * @returns the current particle
  34836. */
  34837. copyToRef(target: SolidParticle): SolidParticle;
  34838. /**
  34839. * Legacy support, changed scale to scaling
  34840. */
  34841. get scale(): Vector3;
  34842. /**
  34843. * Legacy support, changed scale to scaling
  34844. */
  34845. set scale(scale: Vector3);
  34846. /**
  34847. * Legacy support, changed quaternion to rotationQuaternion
  34848. */
  34849. get quaternion(): Nullable<Quaternion>;
  34850. /**
  34851. * Legacy support, changed quaternion to rotationQuaternion
  34852. */
  34853. set quaternion(q: Nullable<Quaternion>);
  34854. /**
  34855. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34856. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34857. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34858. * @returns true if it intersects
  34859. */
  34860. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34861. /**
  34862. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34863. * A particle is in the frustum if its bounding box intersects the frustum
  34864. * @param frustumPlanes defines the frustum to test
  34865. * @returns true if the particle is in the frustum planes
  34866. */
  34867. isInFrustum(frustumPlanes: Plane[]): boolean;
  34868. /**
  34869. * get the rotation matrix of the particle
  34870. * @hidden
  34871. */
  34872. getRotationMatrix(m: Matrix): void;
  34873. }
  34874. /**
  34875. * Represents the shape of the model used by one particle of a solid particle system.
  34876. * SPS internal tool, don't use it manually.
  34877. */
  34878. export class ModelShape {
  34879. /**
  34880. * The shape id
  34881. * @hidden
  34882. */
  34883. shapeID: number;
  34884. /**
  34885. * flat array of model positions (internal use)
  34886. * @hidden
  34887. */
  34888. _shape: Vector3[];
  34889. /**
  34890. * flat array of model UVs (internal use)
  34891. * @hidden
  34892. */
  34893. _shapeUV: number[];
  34894. /**
  34895. * color array of the model
  34896. * @hidden
  34897. */
  34898. _shapeColors: number[];
  34899. /**
  34900. * indices array of the model
  34901. * @hidden
  34902. */
  34903. _indices: number[];
  34904. /**
  34905. * normals array of the model
  34906. * @hidden
  34907. */
  34908. _normals: number[];
  34909. /**
  34910. * length of the shape in the model indices array (internal use)
  34911. * @hidden
  34912. */
  34913. _indicesLength: number;
  34914. /**
  34915. * Custom position function (internal use)
  34916. * @hidden
  34917. */
  34918. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34919. /**
  34920. * Custom vertex function (internal use)
  34921. * @hidden
  34922. */
  34923. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  34924. /**
  34925. * Model material (internal use)
  34926. * @hidden
  34927. */
  34928. _material: Nullable<Material>;
  34929. /**
  34930. * 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.
  34931. * SPS internal tool, don't use it manually.
  34932. * @hidden
  34933. */
  34934. 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>);
  34935. }
  34936. /**
  34937. * Represents a Depth Sorted Particle in the solid particle system.
  34938. * @hidden
  34939. */
  34940. export class DepthSortedParticle {
  34941. /**
  34942. * Particle index
  34943. */
  34944. idx: number;
  34945. /**
  34946. * Index of the particle in the "indices" array
  34947. */
  34948. ind: number;
  34949. /**
  34950. * Length of the particle shape in the "indices" array
  34951. */
  34952. indicesLength: number;
  34953. /**
  34954. * Squared distance from the particle to the camera
  34955. */
  34956. sqDistance: number;
  34957. /**
  34958. * Material index when used with MultiMaterials
  34959. */
  34960. materialIndex: number;
  34961. /**
  34962. * Creates a new sorted particle
  34963. * @param materialIndex
  34964. */
  34965. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  34966. }
  34967. /**
  34968. * Represents a solid particle vertex
  34969. */
  34970. export class SolidParticleVertex {
  34971. /**
  34972. * Vertex position
  34973. */
  34974. position: Vector3;
  34975. /**
  34976. * Vertex color
  34977. */
  34978. color: Color4;
  34979. /**
  34980. * Vertex UV
  34981. */
  34982. uv: Vector2;
  34983. /**
  34984. * Creates a new solid particle vertex
  34985. */
  34986. constructor();
  34987. /** Vertex x coordinate */
  34988. get x(): number;
  34989. set x(val: number);
  34990. /** Vertex y coordinate */
  34991. get y(): number;
  34992. set y(val: number);
  34993. /** Vertex z coordinate */
  34994. get z(): number;
  34995. set z(val: number);
  34996. }
  34997. }
  34998. declare module BABYLON {
  34999. /**
  35000. * @hidden
  35001. */
  35002. export class _MeshCollisionData {
  35003. _checkCollisions: boolean;
  35004. _collisionMask: number;
  35005. _collisionGroup: number;
  35006. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35007. _collider: Nullable<Collider>;
  35008. _oldPositionForCollisions: Vector3;
  35009. _diffPositionForCollisions: Vector3;
  35010. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35011. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35012. _collisionResponse: boolean;
  35013. }
  35014. }
  35015. declare module BABYLON {
  35016. /** @hidden */
  35017. class _FacetDataStorage {
  35018. facetPositions: Vector3[];
  35019. facetNormals: Vector3[];
  35020. facetPartitioning: number[][];
  35021. facetNb: number;
  35022. partitioningSubdivisions: number;
  35023. partitioningBBoxRatio: number;
  35024. facetDataEnabled: boolean;
  35025. facetParameters: any;
  35026. bbSize: Vector3;
  35027. subDiv: {
  35028. max: number;
  35029. X: number;
  35030. Y: number;
  35031. Z: number;
  35032. };
  35033. facetDepthSort: boolean;
  35034. facetDepthSortEnabled: boolean;
  35035. depthSortedIndices: IndicesArray;
  35036. depthSortedFacets: {
  35037. ind: number;
  35038. sqDistance: number;
  35039. }[];
  35040. facetDepthSortFunction: (f1: {
  35041. ind: number;
  35042. sqDistance: number;
  35043. }, f2: {
  35044. ind: number;
  35045. sqDistance: number;
  35046. }) => number;
  35047. facetDepthSortFrom: Vector3;
  35048. facetDepthSortOrigin: Vector3;
  35049. invertedMatrix: Matrix;
  35050. }
  35051. /**
  35052. * @hidden
  35053. **/
  35054. class _InternalAbstractMeshDataInfo {
  35055. _hasVertexAlpha: boolean;
  35056. _useVertexColors: boolean;
  35057. _numBoneInfluencers: number;
  35058. _applyFog: boolean;
  35059. _receiveShadows: boolean;
  35060. _facetData: _FacetDataStorage;
  35061. _visibility: number;
  35062. _skeleton: Nullable<Skeleton>;
  35063. _layerMask: number;
  35064. _computeBonesUsingShaders: boolean;
  35065. _isActive: boolean;
  35066. _onlyForInstances: boolean;
  35067. _isActiveIntermediate: boolean;
  35068. _onlyForInstancesIntermediate: boolean;
  35069. _actAsRegularMesh: boolean;
  35070. _currentLOD: Nullable<AbstractMesh>;
  35071. }
  35072. /**
  35073. * Class used to store all common mesh properties
  35074. */
  35075. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35076. /** No occlusion */
  35077. static OCCLUSION_TYPE_NONE: number;
  35078. /** Occlusion set to optimisitic */
  35079. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35080. /** Occlusion set to strict */
  35081. static OCCLUSION_TYPE_STRICT: number;
  35082. /** Use an accurante occlusion algorithm */
  35083. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35084. /** Use a conservative occlusion algorithm */
  35085. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35086. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35087. * Test order :
  35088. * Is the bounding sphere outside the frustum ?
  35089. * If not, are the bounding box vertices outside the frustum ?
  35090. * It not, then the cullable object is in the frustum.
  35091. */
  35092. static readonly CULLINGSTRATEGY_STANDARD: number;
  35093. /** Culling strategy : Bounding Sphere Only.
  35094. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35095. * It's also less accurate than the standard because some not visible objects can still be selected.
  35096. * Test : is the bounding sphere outside the frustum ?
  35097. * If not, then the cullable object is in the frustum.
  35098. */
  35099. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35100. /** Culling strategy : Optimistic Inclusion.
  35101. * This in an inclusion test first, then the standard exclusion test.
  35102. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35103. * 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.
  35104. * Anyway, it's as accurate as the standard strategy.
  35105. * Test :
  35106. * Is the cullable object bounding sphere center in the frustum ?
  35107. * If not, apply the default culling strategy.
  35108. */
  35109. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35110. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35111. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35112. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35113. * 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.
  35114. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35115. * Test :
  35116. * Is the cullable object bounding sphere center in the frustum ?
  35117. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35118. */
  35119. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35120. /**
  35121. * No billboard
  35122. */
  35123. static get BILLBOARDMODE_NONE(): number;
  35124. /** Billboard on X axis */
  35125. static get BILLBOARDMODE_X(): number;
  35126. /** Billboard on Y axis */
  35127. static get BILLBOARDMODE_Y(): number;
  35128. /** Billboard on Z axis */
  35129. static get BILLBOARDMODE_Z(): number;
  35130. /** Billboard on all axes */
  35131. static get BILLBOARDMODE_ALL(): number;
  35132. /** Billboard on using position instead of orientation */
  35133. static get BILLBOARDMODE_USE_POSITION(): number;
  35134. /** @hidden */
  35135. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35136. /**
  35137. * The culling strategy to use to check whether the mesh must be rendered or not.
  35138. * This value can be changed at any time and will be used on the next render mesh selection.
  35139. * The possible values are :
  35140. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35141. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35142. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35143. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35144. * Please read each static variable documentation to get details about the culling process.
  35145. * */
  35146. cullingStrategy: number;
  35147. /**
  35148. * Gets the number of facets in the mesh
  35149. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35150. */
  35151. get facetNb(): number;
  35152. /**
  35153. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35154. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35155. */
  35156. get partitioningSubdivisions(): number;
  35157. set partitioningSubdivisions(nb: number);
  35158. /**
  35159. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35160. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35161. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35162. */
  35163. get partitioningBBoxRatio(): number;
  35164. set partitioningBBoxRatio(ratio: number);
  35165. /**
  35166. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35167. * Works only for updatable meshes.
  35168. * Doesn't work with multi-materials
  35169. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35170. */
  35171. get mustDepthSortFacets(): boolean;
  35172. set mustDepthSortFacets(sort: boolean);
  35173. /**
  35174. * The location (Vector3) where the facet depth sort must be computed from.
  35175. * By default, the active camera position.
  35176. * Used only when facet depth sort is enabled
  35177. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35178. */
  35179. get facetDepthSortFrom(): Vector3;
  35180. set facetDepthSortFrom(location: Vector3);
  35181. /**
  35182. * gets a boolean indicating if facetData is enabled
  35183. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35184. */
  35185. get isFacetDataEnabled(): boolean;
  35186. /** @hidden */
  35187. _updateNonUniformScalingState(value: boolean): boolean;
  35188. /**
  35189. * An event triggered when this mesh collides with another one
  35190. */
  35191. onCollideObservable: Observable<AbstractMesh>;
  35192. /** Set a function to call when this mesh collides with another one */
  35193. set onCollide(callback: () => void);
  35194. /**
  35195. * An event triggered when the collision's position changes
  35196. */
  35197. onCollisionPositionChangeObservable: Observable<Vector3>;
  35198. /** Set a function to call when the collision's position changes */
  35199. set onCollisionPositionChange(callback: () => void);
  35200. /**
  35201. * An event triggered when material is changed
  35202. */
  35203. onMaterialChangedObservable: Observable<AbstractMesh>;
  35204. /**
  35205. * Gets or sets the orientation for POV movement & rotation
  35206. */
  35207. definedFacingForward: boolean;
  35208. /** @hidden */
  35209. _occlusionQuery: Nullable<WebGLQuery>;
  35210. /** @hidden */
  35211. _renderingGroup: Nullable<RenderingGroup>;
  35212. /**
  35213. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35214. */
  35215. get visibility(): number;
  35216. /**
  35217. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35218. */
  35219. set visibility(value: number);
  35220. /** Gets or sets the alpha index used to sort transparent meshes
  35221. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35222. */
  35223. alphaIndex: number;
  35224. /**
  35225. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35226. */
  35227. isVisible: boolean;
  35228. /**
  35229. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35230. */
  35231. isPickable: boolean;
  35232. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35233. showSubMeshesBoundingBox: boolean;
  35234. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35235. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35236. */
  35237. isBlocker: boolean;
  35238. /**
  35239. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35240. */
  35241. enablePointerMoveEvents: boolean;
  35242. private _renderingGroupId;
  35243. /**
  35244. * Specifies the rendering group id for this mesh (0 by default)
  35245. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35246. */
  35247. get renderingGroupId(): number;
  35248. set renderingGroupId(value: number);
  35249. private _material;
  35250. /** Gets or sets current material */
  35251. get material(): Nullable<Material>;
  35252. set material(value: Nullable<Material>);
  35253. /**
  35254. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35255. * @see https://doc.babylonjs.com/babylon101/shadows
  35256. */
  35257. get receiveShadows(): boolean;
  35258. set receiveShadows(value: boolean);
  35259. /** Defines color to use when rendering outline */
  35260. outlineColor: Color3;
  35261. /** Define width to use when rendering outline */
  35262. outlineWidth: number;
  35263. /** Defines color to use when rendering overlay */
  35264. overlayColor: Color3;
  35265. /** Defines alpha to use when rendering overlay */
  35266. overlayAlpha: number;
  35267. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35268. get hasVertexAlpha(): boolean;
  35269. set hasVertexAlpha(value: boolean);
  35270. /** 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) */
  35271. get useVertexColors(): boolean;
  35272. set useVertexColors(value: boolean);
  35273. /**
  35274. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35275. */
  35276. get computeBonesUsingShaders(): boolean;
  35277. set computeBonesUsingShaders(value: boolean);
  35278. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35279. get numBoneInfluencers(): number;
  35280. set numBoneInfluencers(value: number);
  35281. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35282. get applyFog(): boolean;
  35283. set applyFog(value: boolean);
  35284. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35285. useOctreeForRenderingSelection: boolean;
  35286. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35287. useOctreeForPicking: boolean;
  35288. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35289. useOctreeForCollisions: boolean;
  35290. /**
  35291. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35292. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35293. */
  35294. get layerMask(): number;
  35295. set layerMask(value: number);
  35296. /**
  35297. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35298. */
  35299. alwaysSelectAsActiveMesh: boolean;
  35300. /**
  35301. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35302. */
  35303. doNotSyncBoundingInfo: boolean;
  35304. /**
  35305. * Gets or sets the current action manager
  35306. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35307. */
  35308. actionManager: Nullable<AbstractActionManager>;
  35309. private _meshCollisionData;
  35310. /**
  35311. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35312. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35313. */
  35314. ellipsoid: Vector3;
  35315. /**
  35316. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35317. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35318. */
  35319. ellipsoidOffset: Vector3;
  35320. /**
  35321. * Gets or sets a collision mask used to mask collisions (default is -1).
  35322. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35323. */
  35324. get collisionMask(): number;
  35325. set collisionMask(mask: number);
  35326. /**
  35327. * Gets or sets a collision response flag (default is true).
  35328. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35329. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35330. * to respond to the collision.
  35331. */
  35332. get collisionResponse(): boolean;
  35333. set collisionResponse(response: boolean);
  35334. /**
  35335. * Gets or sets the current collision group mask (-1 by default).
  35336. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35337. */
  35338. get collisionGroup(): number;
  35339. set collisionGroup(mask: number);
  35340. /**
  35341. * Gets or sets current surrounding meshes (null by default).
  35342. *
  35343. * By default collision detection is tested against every mesh in the scene.
  35344. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35345. * meshes will be tested for the collision.
  35346. *
  35347. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35348. */
  35349. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35350. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35351. /**
  35352. * Defines edge width used when edgesRenderer is enabled
  35353. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35354. */
  35355. edgesWidth: number;
  35356. /**
  35357. * Defines edge color used when edgesRenderer is enabled
  35358. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35359. */
  35360. edgesColor: Color4;
  35361. /** @hidden */
  35362. _edgesRenderer: Nullable<IEdgesRenderer>;
  35363. /** @hidden */
  35364. _masterMesh: Nullable<AbstractMesh>;
  35365. /** @hidden */
  35366. _boundingInfo: Nullable<BoundingInfo>;
  35367. /** @hidden */
  35368. _renderId: number;
  35369. /**
  35370. * Gets or sets the list of subMeshes
  35371. * @see https://doc.babylonjs.com/how_to/multi_materials
  35372. */
  35373. subMeshes: SubMesh[];
  35374. /** @hidden */
  35375. _intersectionsInProgress: AbstractMesh[];
  35376. /** @hidden */
  35377. _unIndexed: boolean;
  35378. /** @hidden */
  35379. _lightSources: Light[];
  35380. /** Gets the list of lights affecting that mesh */
  35381. get lightSources(): Light[];
  35382. /** @hidden */
  35383. get _positions(): Nullable<Vector3[]>;
  35384. /** @hidden */
  35385. _waitingData: {
  35386. lods: Nullable<any>;
  35387. actions: Nullable<any>;
  35388. freezeWorldMatrix: Nullable<boolean>;
  35389. };
  35390. /** @hidden */
  35391. _bonesTransformMatrices: Nullable<Float32Array>;
  35392. /** @hidden */
  35393. _transformMatrixTexture: Nullable<RawTexture>;
  35394. /**
  35395. * Gets or sets a skeleton to apply skining transformations
  35396. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35397. */
  35398. set skeleton(value: Nullable<Skeleton>);
  35399. get skeleton(): Nullable<Skeleton>;
  35400. /**
  35401. * An event triggered when the mesh is rebuilt.
  35402. */
  35403. onRebuildObservable: Observable<AbstractMesh>;
  35404. /**
  35405. * Creates a new AbstractMesh
  35406. * @param name defines the name of the mesh
  35407. * @param scene defines the hosting scene
  35408. */
  35409. constructor(name: string, scene?: Nullable<Scene>);
  35410. /**
  35411. * Returns the string "AbstractMesh"
  35412. * @returns "AbstractMesh"
  35413. */
  35414. getClassName(): string;
  35415. /**
  35416. * Gets a string representation of the current mesh
  35417. * @param fullDetails defines a boolean indicating if full details must be included
  35418. * @returns a string representation of the current mesh
  35419. */
  35420. toString(fullDetails?: boolean): string;
  35421. /**
  35422. * @hidden
  35423. */
  35424. protected _getEffectiveParent(): Nullable<Node>;
  35425. /** @hidden */
  35426. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35427. /** @hidden */
  35428. _rebuild(): void;
  35429. /** @hidden */
  35430. _resyncLightSources(): void;
  35431. /** @hidden */
  35432. _resyncLightSource(light: Light): void;
  35433. /** @hidden */
  35434. _unBindEffect(): void;
  35435. /** @hidden */
  35436. _removeLightSource(light: Light, dispose: boolean): void;
  35437. private _markSubMeshesAsDirty;
  35438. /** @hidden */
  35439. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35440. /** @hidden */
  35441. _markSubMeshesAsAttributesDirty(): void;
  35442. /** @hidden */
  35443. _markSubMeshesAsMiscDirty(): void;
  35444. /**
  35445. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35446. */
  35447. get scaling(): Vector3;
  35448. set scaling(newScaling: Vector3);
  35449. /**
  35450. * Returns true if the mesh is blocked. Implemented by child classes
  35451. */
  35452. get isBlocked(): boolean;
  35453. /**
  35454. * Returns the mesh itself by default. Implemented by child classes
  35455. * @param camera defines the camera to use to pick the right LOD level
  35456. * @returns the currentAbstractMesh
  35457. */
  35458. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35459. /**
  35460. * Returns 0 by default. Implemented by child classes
  35461. * @returns an integer
  35462. */
  35463. getTotalVertices(): number;
  35464. /**
  35465. * Returns a positive integer : the total number of indices in this mesh geometry.
  35466. * @returns the numner of indices or zero if the mesh has no geometry.
  35467. */
  35468. getTotalIndices(): number;
  35469. /**
  35470. * Returns null by default. Implemented by child classes
  35471. * @returns null
  35472. */
  35473. getIndices(): Nullable<IndicesArray>;
  35474. /**
  35475. * Returns the array of the requested vertex data kind. Implemented by child classes
  35476. * @param kind defines the vertex data kind to use
  35477. * @returns null
  35478. */
  35479. getVerticesData(kind: string): Nullable<FloatArray>;
  35480. /**
  35481. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35482. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35483. * Note that a new underlying VertexBuffer object is created each call.
  35484. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35485. * @param kind defines vertex data kind:
  35486. * * VertexBuffer.PositionKind
  35487. * * VertexBuffer.UVKind
  35488. * * VertexBuffer.UV2Kind
  35489. * * VertexBuffer.UV3Kind
  35490. * * VertexBuffer.UV4Kind
  35491. * * VertexBuffer.UV5Kind
  35492. * * VertexBuffer.UV6Kind
  35493. * * VertexBuffer.ColorKind
  35494. * * VertexBuffer.MatricesIndicesKind
  35495. * * VertexBuffer.MatricesIndicesExtraKind
  35496. * * VertexBuffer.MatricesWeightsKind
  35497. * * VertexBuffer.MatricesWeightsExtraKind
  35498. * @param data defines the data source
  35499. * @param updatable defines if the data must be flagged as updatable (or static)
  35500. * @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
  35501. * @returns the current mesh
  35502. */
  35503. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35504. /**
  35505. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35506. * If the mesh has no geometry, it is simply returned as it is.
  35507. * @param kind defines vertex data kind:
  35508. * * VertexBuffer.PositionKind
  35509. * * VertexBuffer.UVKind
  35510. * * VertexBuffer.UV2Kind
  35511. * * VertexBuffer.UV3Kind
  35512. * * VertexBuffer.UV4Kind
  35513. * * VertexBuffer.UV5Kind
  35514. * * VertexBuffer.UV6Kind
  35515. * * VertexBuffer.ColorKind
  35516. * * VertexBuffer.MatricesIndicesKind
  35517. * * VertexBuffer.MatricesIndicesExtraKind
  35518. * * VertexBuffer.MatricesWeightsKind
  35519. * * VertexBuffer.MatricesWeightsExtraKind
  35520. * @param data defines the data source
  35521. * @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
  35522. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35523. * @returns the current mesh
  35524. */
  35525. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35526. /**
  35527. * Sets the mesh indices,
  35528. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35529. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35530. * @param totalVertices Defines the total number of vertices
  35531. * @returns the current mesh
  35532. */
  35533. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35534. /**
  35535. * Gets a boolean indicating if specific vertex data is present
  35536. * @param kind defines the vertex data kind to use
  35537. * @returns true is data kind is present
  35538. */
  35539. isVerticesDataPresent(kind: string): boolean;
  35540. /**
  35541. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35542. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35543. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35544. * @returns a BoundingInfo
  35545. */
  35546. getBoundingInfo(): BoundingInfo;
  35547. /**
  35548. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35549. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35550. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35551. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35552. * @returns the current mesh
  35553. */
  35554. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35555. /**
  35556. * Overwrite the current bounding info
  35557. * @param boundingInfo defines the new bounding info
  35558. * @returns the current mesh
  35559. */
  35560. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35561. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35562. get useBones(): boolean;
  35563. /** @hidden */
  35564. _preActivate(): void;
  35565. /** @hidden */
  35566. _preActivateForIntermediateRendering(renderId: number): void;
  35567. /** @hidden */
  35568. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35569. /** @hidden */
  35570. _postActivate(): void;
  35571. /** @hidden */
  35572. _freeze(): void;
  35573. /** @hidden */
  35574. _unFreeze(): void;
  35575. /**
  35576. * Gets the current world matrix
  35577. * @returns a Matrix
  35578. */
  35579. getWorldMatrix(): Matrix;
  35580. /** @hidden */
  35581. _getWorldMatrixDeterminant(): number;
  35582. /**
  35583. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35584. */
  35585. get isAnInstance(): boolean;
  35586. /**
  35587. * Gets a boolean indicating if this mesh has instances
  35588. */
  35589. get hasInstances(): boolean;
  35590. /**
  35591. * Gets a boolean indicating if this mesh has thin instances
  35592. */
  35593. get hasThinInstances(): boolean;
  35594. /**
  35595. * Perform relative position change from the point of view of behind the front of the mesh.
  35596. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35597. * Supports definition of mesh facing forward or backward
  35598. * @param amountRight defines the distance on the right axis
  35599. * @param amountUp defines the distance on the up axis
  35600. * @param amountForward defines the distance on the forward axis
  35601. * @returns the current mesh
  35602. */
  35603. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35604. /**
  35605. * Calculate relative position change from the point of view of behind the front of the mesh.
  35606. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35607. * Supports definition of mesh facing forward or backward
  35608. * @param amountRight defines the distance on the right axis
  35609. * @param amountUp defines the distance on the up axis
  35610. * @param amountForward defines the distance on the forward axis
  35611. * @returns the new displacement vector
  35612. */
  35613. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35614. /**
  35615. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35616. * Supports definition of mesh facing forward or backward
  35617. * @param flipBack defines the flip
  35618. * @param twirlClockwise defines the twirl
  35619. * @param tiltRight defines the tilt
  35620. * @returns the current mesh
  35621. */
  35622. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35623. /**
  35624. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35625. * Supports definition of mesh facing forward or backward.
  35626. * @param flipBack defines the flip
  35627. * @param twirlClockwise defines the twirl
  35628. * @param tiltRight defines the tilt
  35629. * @returns the new rotation vector
  35630. */
  35631. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35632. /**
  35633. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35634. * This means the mesh underlying bounding box and sphere are recomputed.
  35635. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35636. * @returns the current mesh
  35637. */
  35638. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35639. /** @hidden */
  35640. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35641. /** @hidden */
  35642. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35643. /** @hidden */
  35644. _updateBoundingInfo(): AbstractMesh;
  35645. /** @hidden */
  35646. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35647. /** @hidden */
  35648. protected _afterComputeWorldMatrix(): void;
  35649. /** @hidden */
  35650. get _effectiveMesh(): AbstractMesh;
  35651. /**
  35652. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35653. * A mesh is in the frustum if its bounding box intersects the frustum
  35654. * @param frustumPlanes defines the frustum to test
  35655. * @returns true if the mesh is in the frustum planes
  35656. */
  35657. isInFrustum(frustumPlanes: Plane[]): boolean;
  35658. /**
  35659. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35660. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35661. * @param frustumPlanes defines the frustum to test
  35662. * @returns true if the mesh is completely in the frustum planes
  35663. */
  35664. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35665. /**
  35666. * True if the mesh intersects another mesh or a SolidParticle object
  35667. * @param mesh defines a target mesh or SolidParticle to test
  35668. * @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)
  35669. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35670. * @returns true if there is an intersection
  35671. */
  35672. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35673. /**
  35674. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35675. * @param point defines the point to test
  35676. * @returns true if there is an intersection
  35677. */
  35678. intersectsPoint(point: Vector3): boolean;
  35679. /**
  35680. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35681. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35682. */
  35683. get checkCollisions(): boolean;
  35684. set checkCollisions(collisionEnabled: boolean);
  35685. /**
  35686. * Gets Collider object used to compute collisions (not physics)
  35687. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35688. */
  35689. get collider(): Nullable<Collider>;
  35690. /**
  35691. * Move the mesh using collision engine
  35692. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35693. * @param displacement defines the requested displacement vector
  35694. * @returns the current mesh
  35695. */
  35696. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35697. private _onCollisionPositionChange;
  35698. /** @hidden */
  35699. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35700. /** @hidden */
  35701. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35702. /** @hidden */
  35703. _checkCollision(collider: Collider): AbstractMesh;
  35704. /** @hidden */
  35705. _generatePointsArray(): boolean;
  35706. /**
  35707. * Checks if the passed Ray intersects with the mesh
  35708. * @param ray defines the ray to use
  35709. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35710. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35711. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35712. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35713. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  35714. * @returns the picking info
  35715. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35716. */
  35717. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  35718. /**
  35719. * Clones the current mesh
  35720. * @param name defines the mesh name
  35721. * @param newParent defines the new mesh parent
  35722. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35723. * @returns the new mesh
  35724. */
  35725. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35726. /**
  35727. * Disposes all the submeshes of the current meshnp
  35728. * @returns the current mesh
  35729. */
  35730. releaseSubMeshes(): AbstractMesh;
  35731. /**
  35732. * Releases resources associated with this abstract mesh.
  35733. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35734. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35735. */
  35736. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35737. /**
  35738. * Adds the passed mesh as a child to the current mesh
  35739. * @param mesh defines the child mesh
  35740. * @returns the current mesh
  35741. */
  35742. addChild(mesh: AbstractMesh): AbstractMesh;
  35743. /**
  35744. * Removes the passed mesh from the current mesh children list
  35745. * @param mesh defines the child mesh
  35746. * @returns the current mesh
  35747. */
  35748. removeChild(mesh: AbstractMesh): AbstractMesh;
  35749. /** @hidden */
  35750. private _initFacetData;
  35751. /**
  35752. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35753. * This method can be called within the render loop.
  35754. * 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
  35755. * @returns the current mesh
  35756. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35757. */
  35758. updateFacetData(): AbstractMesh;
  35759. /**
  35760. * Returns the facetLocalNormals array.
  35761. * The normals are expressed in the mesh local spac
  35762. * @returns an array of Vector3
  35763. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35764. */
  35765. getFacetLocalNormals(): Vector3[];
  35766. /**
  35767. * Returns the facetLocalPositions array.
  35768. * The facet positions are expressed in the mesh local space
  35769. * @returns an array of Vector3
  35770. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35771. */
  35772. getFacetLocalPositions(): Vector3[];
  35773. /**
  35774. * Returns the facetLocalPartioning array
  35775. * @returns an array of array of numbers
  35776. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35777. */
  35778. getFacetLocalPartitioning(): number[][];
  35779. /**
  35780. * Returns the i-th facet position in the world system.
  35781. * This method allocates a new Vector3 per call
  35782. * @param i defines the facet index
  35783. * @returns a new Vector3
  35784. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35785. */
  35786. getFacetPosition(i: number): Vector3;
  35787. /**
  35788. * Sets the reference Vector3 with the i-th facet position in the world system
  35789. * @param i defines the facet index
  35790. * @param ref defines the target vector
  35791. * @returns the current mesh
  35792. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35793. */
  35794. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35795. /**
  35796. * Returns the i-th facet normal in the world system.
  35797. * This method allocates a new Vector3 per call
  35798. * @param i defines the facet index
  35799. * @returns a new Vector3
  35800. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35801. */
  35802. getFacetNormal(i: number): Vector3;
  35803. /**
  35804. * Sets the reference Vector3 with the i-th facet normal in the world system
  35805. * @param i defines the facet index
  35806. * @param ref defines the target vector
  35807. * @returns the current mesh
  35808. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35809. */
  35810. getFacetNormalToRef(i: number, ref: Vector3): this;
  35811. /**
  35812. * 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)
  35813. * @param x defines x coordinate
  35814. * @param y defines y coordinate
  35815. * @param z defines z coordinate
  35816. * @returns the array of facet indexes
  35817. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35818. */
  35819. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35820. /**
  35821. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35822. * @param projected sets as the (x,y,z) world projection on the facet
  35823. * @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
  35824. * @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
  35825. * @param x defines x coordinate
  35826. * @param y defines y coordinate
  35827. * @param z defines z coordinate
  35828. * @returns the face index if found (or null instead)
  35829. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35830. */
  35831. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35832. /**
  35833. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35834. * @param projected sets as the (x,y,z) local projection on the facet
  35835. * @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
  35836. * @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
  35837. * @param x defines x coordinate
  35838. * @param y defines y coordinate
  35839. * @param z defines z coordinate
  35840. * @returns the face index if found (or null instead)
  35841. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35842. */
  35843. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35844. /**
  35845. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35846. * @returns the parameters
  35847. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35848. */
  35849. getFacetDataParameters(): any;
  35850. /**
  35851. * Disables the feature FacetData and frees the related memory
  35852. * @returns the current mesh
  35853. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35854. */
  35855. disableFacetData(): AbstractMesh;
  35856. /**
  35857. * Updates the AbstractMesh indices array
  35858. * @param indices defines the data source
  35859. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35860. * @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)
  35861. * @returns the current mesh
  35862. */
  35863. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35864. /**
  35865. * Creates new normals data for the mesh
  35866. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35867. * @returns the current mesh
  35868. */
  35869. createNormals(updatable: boolean): AbstractMesh;
  35870. /**
  35871. * Align the mesh with a normal
  35872. * @param normal defines the normal to use
  35873. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35874. * @returns the current mesh
  35875. */
  35876. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35877. /** @hidden */
  35878. _checkOcclusionQuery(): boolean;
  35879. /**
  35880. * Disables the mesh edge rendering mode
  35881. * @returns the currentAbstractMesh
  35882. */
  35883. disableEdgesRendering(): AbstractMesh;
  35884. /**
  35885. * Enables the edge rendering mode on the mesh.
  35886. * This mode makes the mesh edges visible
  35887. * @param epsilon defines the maximal distance between two angles to detect a face
  35888. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35889. * @param options options to the edge renderer
  35890. * @returns the currentAbstractMesh
  35891. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35892. */
  35893. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  35894. /**
  35895. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35896. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35897. */
  35898. getConnectedParticleSystems(): IParticleSystem[];
  35899. }
  35900. }
  35901. declare module BABYLON {
  35902. /**
  35903. * Interface used to define ActionEvent
  35904. */
  35905. export interface IActionEvent {
  35906. /** The mesh or sprite that triggered the action */
  35907. source: any;
  35908. /** The X mouse cursor position at the time of the event */
  35909. pointerX: number;
  35910. /** The Y mouse cursor position at the time of the event */
  35911. pointerY: number;
  35912. /** The mesh that is currently pointed at (can be null) */
  35913. meshUnderPointer: Nullable<AbstractMesh>;
  35914. /** the original (browser) event that triggered the ActionEvent */
  35915. sourceEvent?: any;
  35916. /** additional data for the event */
  35917. additionalData?: any;
  35918. }
  35919. /**
  35920. * ActionEvent is the event being sent when an action is triggered.
  35921. */
  35922. export class ActionEvent implements IActionEvent {
  35923. /** The mesh or sprite that triggered the action */
  35924. source: any;
  35925. /** The X mouse cursor position at the time of the event */
  35926. pointerX: number;
  35927. /** The Y mouse cursor position at the time of the event */
  35928. pointerY: number;
  35929. /** The mesh that is currently pointed at (can be null) */
  35930. meshUnderPointer: Nullable<AbstractMesh>;
  35931. /** the original (browser) event that triggered the ActionEvent */
  35932. sourceEvent?: any;
  35933. /** additional data for the event */
  35934. additionalData?: any;
  35935. /**
  35936. * Creates a new ActionEvent
  35937. * @param source The mesh or sprite that triggered the action
  35938. * @param pointerX The X mouse cursor position at the time of the event
  35939. * @param pointerY The Y mouse cursor position at the time of the event
  35940. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  35941. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  35942. * @param additionalData additional data for the event
  35943. */
  35944. constructor(
  35945. /** The mesh or sprite that triggered the action */
  35946. source: any,
  35947. /** The X mouse cursor position at the time of the event */
  35948. pointerX: number,
  35949. /** The Y mouse cursor position at the time of the event */
  35950. pointerY: number,
  35951. /** The mesh that is currently pointed at (can be null) */
  35952. meshUnderPointer: Nullable<AbstractMesh>,
  35953. /** the original (browser) event that triggered the ActionEvent */
  35954. sourceEvent?: any,
  35955. /** additional data for the event */
  35956. additionalData?: any);
  35957. /**
  35958. * Helper function to auto-create an ActionEvent from a source mesh.
  35959. * @param source The source mesh that triggered the event
  35960. * @param evt The original (browser) event
  35961. * @param additionalData additional data for the event
  35962. * @returns the new ActionEvent
  35963. */
  35964. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  35965. /**
  35966. * Helper function to auto-create an ActionEvent from a source sprite
  35967. * @param source The source sprite that triggered the event
  35968. * @param scene Scene associated with the sprite
  35969. * @param evt The original (browser) event
  35970. * @param additionalData additional data for the event
  35971. * @returns the new ActionEvent
  35972. */
  35973. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  35974. /**
  35975. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  35976. * @param scene the scene where the event occurred
  35977. * @param evt The original (browser) event
  35978. * @returns the new ActionEvent
  35979. */
  35980. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  35981. /**
  35982. * Helper function to auto-create an ActionEvent from a primitive
  35983. * @param prim defines the target primitive
  35984. * @param pointerPos defines the pointer position
  35985. * @param evt The original (browser) event
  35986. * @param additionalData additional data for the event
  35987. * @returns the new ActionEvent
  35988. */
  35989. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  35990. }
  35991. }
  35992. declare module BABYLON {
  35993. /**
  35994. * Abstract class used to decouple action Manager from scene and meshes.
  35995. * Do not instantiate.
  35996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35997. */
  35998. export abstract class AbstractActionManager implements IDisposable {
  35999. /** Gets the list of active triggers */
  36000. static Triggers: {
  36001. [key: string]: number;
  36002. };
  36003. /** Gets the cursor to use when hovering items */
  36004. hoverCursor: string;
  36005. /** Gets the list of actions */
  36006. actions: IAction[];
  36007. /**
  36008. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36009. */
  36010. isRecursive: boolean;
  36011. /**
  36012. * Releases all associated resources
  36013. */
  36014. abstract dispose(): void;
  36015. /**
  36016. * Does this action manager has pointer triggers
  36017. */
  36018. abstract get hasPointerTriggers(): boolean;
  36019. /**
  36020. * Does this action manager has pick triggers
  36021. */
  36022. abstract get hasPickTriggers(): boolean;
  36023. /**
  36024. * Process a specific trigger
  36025. * @param trigger defines the trigger to process
  36026. * @param evt defines the event details to be processed
  36027. */
  36028. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36029. /**
  36030. * Does this action manager handles actions of any of the given triggers
  36031. * @param triggers defines the triggers to be tested
  36032. * @return a boolean indicating whether one (or more) of the triggers is handled
  36033. */
  36034. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36035. /**
  36036. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36037. * speed.
  36038. * @param triggerA defines the trigger to be tested
  36039. * @param triggerB defines the trigger to be tested
  36040. * @return a boolean indicating whether one (or more) of the triggers is handled
  36041. */
  36042. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36043. /**
  36044. * Does this action manager handles actions of a given trigger
  36045. * @param trigger defines the trigger to be tested
  36046. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36047. * @return whether the trigger is handled
  36048. */
  36049. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36050. /**
  36051. * Serialize this manager to a JSON object
  36052. * @param name defines the property name to store this manager
  36053. * @returns a JSON representation of this manager
  36054. */
  36055. abstract serialize(name: string): any;
  36056. /**
  36057. * Registers an action to this action manager
  36058. * @param action defines the action to be registered
  36059. * @return the action amended (prepared) after registration
  36060. */
  36061. abstract registerAction(action: IAction): Nullable<IAction>;
  36062. /**
  36063. * Unregisters an action to this action manager
  36064. * @param action defines the action to be unregistered
  36065. * @return a boolean indicating whether the action has been unregistered
  36066. */
  36067. abstract unregisterAction(action: IAction): Boolean;
  36068. /**
  36069. * Does exist one action manager with at least one trigger
  36070. **/
  36071. static get HasTriggers(): boolean;
  36072. /**
  36073. * Does exist one action manager with at least one pick trigger
  36074. **/
  36075. static get HasPickTriggers(): boolean;
  36076. /**
  36077. * Does exist one action manager that handles actions of a given trigger
  36078. * @param trigger defines the trigger to be tested
  36079. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36080. **/
  36081. static HasSpecificTrigger(trigger: number): boolean;
  36082. }
  36083. }
  36084. declare module BABYLON {
  36085. /**
  36086. * Defines how a node can be built from a string name.
  36087. */
  36088. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36089. /**
  36090. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36091. */
  36092. export class Node implements IBehaviorAware<Node> {
  36093. /** @hidden */
  36094. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36095. private static _NodeConstructors;
  36096. /**
  36097. * Add a new node constructor
  36098. * @param type defines the type name of the node to construct
  36099. * @param constructorFunc defines the constructor function
  36100. */
  36101. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36102. /**
  36103. * Returns a node constructor based on type name
  36104. * @param type defines the type name
  36105. * @param name defines the new node name
  36106. * @param scene defines the hosting scene
  36107. * @param options defines optional options to transmit to constructors
  36108. * @returns the new constructor or null
  36109. */
  36110. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36111. /**
  36112. * Gets or sets the name of the node
  36113. */
  36114. name: string;
  36115. /**
  36116. * Gets or sets the id of the node
  36117. */
  36118. id: string;
  36119. /**
  36120. * Gets or sets the unique id of the node
  36121. */
  36122. uniqueId: number;
  36123. /**
  36124. * Gets or sets a string used to store user defined state for the node
  36125. */
  36126. state: string;
  36127. /**
  36128. * Gets or sets an object used to store user defined information for the node
  36129. */
  36130. metadata: any;
  36131. /**
  36132. * For internal use only. Please do not use.
  36133. */
  36134. reservedDataStore: any;
  36135. /**
  36136. * List of inspectable custom properties (used by the Inspector)
  36137. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36138. */
  36139. inspectableCustomProperties: IInspectable[];
  36140. private _doNotSerialize;
  36141. /**
  36142. * Gets or sets a boolean used to define if the node must be serialized
  36143. */
  36144. get doNotSerialize(): boolean;
  36145. set doNotSerialize(value: boolean);
  36146. /** @hidden */
  36147. _isDisposed: boolean;
  36148. /**
  36149. * Gets a list of Animations associated with the node
  36150. */
  36151. animations: Animation[];
  36152. protected _ranges: {
  36153. [name: string]: Nullable<AnimationRange>;
  36154. };
  36155. /**
  36156. * Callback raised when the node is ready to be used
  36157. */
  36158. onReady: Nullable<(node: Node) => void>;
  36159. private _isEnabled;
  36160. private _isParentEnabled;
  36161. private _isReady;
  36162. /** @hidden */
  36163. _currentRenderId: number;
  36164. private _parentUpdateId;
  36165. /** @hidden */
  36166. _childUpdateId: number;
  36167. /** @hidden */
  36168. _waitingParentId: Nullable<string>;
  36169. /** @hidden */
  36170. _scene: Scene;
  36171. /** @hidden */
  36172. _cache: any;
  36173. private _parentNode;
  36174. private _children;
  36175. /** @hidden */
  36176. _worldMatrix: Matrix;
  36177. /** @hidden */
  36178. _worldMatrixDeterminant: number;
  36179. /** @hidden */
  36180. _worldMatrixDeterminantIsDirty: boolean;
  36181. /** @hidden */
  36182. private _sceneRootNodesIndex;
  36183. /**
  36184. * Gets a boolean indicating if the node has been disposed
  36185. * @returns true if the node was disposed
  36186. */
  36187. isDisposed(): boolean;
  36188. /**
  36189. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36190. * @see https://doc.babylonjs.com/how_to/parenting
  36191. */
  36192. set parent(parent: Nullable<Node>);
  36193. get parent(): Nullable<Node>;
  36194. /** @hidden */
  36195. _addToSceneRootNodes(): void;
  36196. /** @hidden */
  36197. _removeFromSceneRootNodes(): void;
  36198. private _animationPropertiesOverride;
  36199. /**
  36200. * Gets or sets the animation properties override
  36201. */
  36202. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36203. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36204. /**
  36205. * Gets a string identifying the name of the class
  36206. * @returns "Node" string
  36207. */
  36208. getClassName(): string;
  36209. /** @hidden */
  36210. readonly _isNode: boolean;
  36211. /**
  36212. * An event triggered when the mesh is disposed
  36213. */
  36214. onDisposeObservable: Observable<Node>;
  36215. private _onDisposeObserver;
  36216. /**
  36217. * Sets a callback that will be raised when the node will be disposed
  36218. */
  36219. set onDispose(callback: () => void);
  36220. /**
  36221. * Creates a new Node
  36222. * @param name the name and id to be given to this node
  36223. * @param scene the scene this node will be added to
  36224. */
  36225. constructor(name: string, scene?: Nullable<Scene>);
  36226. /**
  36227. * Gets the scene of the node
  36228. * @returns a scene
  36229. */
  36230. getScene(): Scene;
  36231. /**
  36232. * Gets the engine of the node
  36233. * @returns a Engine
  36234. */
  36235. getEngine(): Engine;
  36236. private _behaviors;
  36237. /**
  36238. * Attach a behavior to the node
  36239. * @see https://doc.babylonjs.com/features/behaviour
  36240. * @param behavior defines the behavior to attach
  36241. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36242. * @returns the current Node
  36243. */
  36244. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36245. /**
  36246. * Remove an attached behavior
  36247. * @see https://doc.babylonjs.com/features/behaviour
  36248. * @param behavior defines the behavior to attach
  36249. * @returns the current Node
  36250. */
  36251. removeBehavior(behavior: Behavior<Node>): Node;
  36252. /**
  36253. * Gets the list of attached behaviors
  36254. * @see https://doc.babylonjs.com/features/behaviour
  36255. */
  36256. get behaviors(): Behavior<Node>[];
  36257. /**
  36258. * Gets an attached behavior by name
  36259. * @param name defines the name of the behavior to look for
  36260. * @see https://doc.babylonjs.com/features/behaviour
  36261. * @returns null if behavior was not found else the requested behavior
  36262. */
  36263. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36264. /**
  36265. * Returns the latest update of the World matrix
  36266. * @returns a Matrix
  36267. */
  36268. getWorldMatrix(): Matrix;
  36269. /** @hidden */
  36270. _getWorldMatrixDeterminant(): number;
  36271. /**
  36272. * Returns directly the latest state of the mesh World matrix.
  36273. * A Matrix is returned.
  36274. */
  36275. get worldMatrixFromCache(): Matrix;
  36276. /** @hidden */
  36277. _initCache(): void;
  36278. /** @hidden */
  36279. updateCache(force?: boolean): void;
  36280. /** @hidden */
  36281. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36282. /** @hidden */
  36283. _updateCache(ignoreParentClass?: boolean): void;
  36284. /** @hidden */
  36285. _isSynchronized(): boolean;
  36286. /** @hidden */
  36287. _markSyncedWithParent(): void;
  36288. /** @hidden */
  36289. isSynchronizedWithParent(): boolean;
  36290. /** @hidden */
  36291. isSynchronized(): boolean;
  36292. /**
  36293. * Is this node ready to be used/rendered
  36294. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36295. * @return true if the node is ready
  36296. */
  36297. isReady(completeCheck?: boolean): boolean;
  36298. /**
  36299. * Is this node enabled?
  36300. * 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
  36301. * @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
  36302. * @return whether this node (and its parent) is enabled
  36303. */
  36304. isEnabled(checkAncestors?: boolean): boolean;
  36305. /** @hidden */
  36306. protected _syncParentEnabledState(): void;
  36307. /**
  36308. * Set the enabled state of this node
  36309. * @param value defines the new enabled state
  36310. */
  36311. setEnabled(value: boolean): void;
  36312. /**
  36313. * Is this node a descendant of the given node?
  36314. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36315. * @param ancestor defines the parent node to inspect
  36316. * @returns a boolean indicating if this node is a descendant of the given node
  36317. */
  36318. isDescendantOf(ancestor: Node): boolean;
  36319. /** @hidden */
  36320. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36321. /**
  36322. * Will return all nodes that have this node as ascendant
  36323. * @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
  36324. * @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
  36325. * @return all children nodes of all types
  36326. */
  36327. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36328. /**
  36329. * Get all child-meshes of this node
  36330. * @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)
  36331. * @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
  36332. * @returns an array of AbstractMesh
  36333. */
  36334. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36335. /**
  36336. * Get all direct children of this node
  36337. * @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
  36338. * @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)
  36339. * @returns an array of Node
  36340. */
  36341. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36342. /** @hidden */
  36343. _setReady(state: boolean): void;
  36344. /**
  36345. * Get an animation by name
  36346. * @param name defines the name of the animation to look for
  36347. * @returns null if not found else the requested animation
  36348. */
  36349. getAnimationByName(name: string): Nullable<Animation>;
  36350. /**
  36351. * Creates an animation range for this node
  36352. * @param name defines the name of the range
  36353. * @param from defines the starting key
  36354. * @param to defines the end key
  36355. */
  36356. createAnimationRange(name: string, from: number, to: number): void;
  36357. /**
  36358. * Delete a specific animation range
  36359. * @param name defines the name of the range to delete
  36360. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36361. */
  36362. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36363. /**
  36364. * Get an animation range by name
  36365. * @param name defines the name of the animation range to look for
  36366. * @returns null if not found else the requested animation range
  36367. */
  36368. getAnimationRange(name: string): Nullable<AnimationRange>;
  36369. /**
  36370. * Gets the list of all animation ranges defined on this node
  36371. * @returns an array
  36372. */
  36373. getAnimationRanges(): Nullable<AnimationRange>[];
  36374. /**
  36375. * Will start the animation sequence
  36376. * @param name defines the range frames for animation sequence
  36377. * @param loop defines if the animation should loop (false by default)
  36378. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36379. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36380. * @returns the object created for this animation. If range does not exist, it will return null
  36381. */
  36382. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36383. /**
  36384. * Serialize animation ranges into a JSON compatible object
  36385. * @returns serialization object
  36386. */
  36387. serializeAnimationRanges(): any;
  36388. /**
  36389. * Computes the world matrix of the node
  36390. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36391. * @returns the world matrix
  36392. */
  36393. computeWorldMatrix(force?: boolean): Matrix;
  36394. /**
  36395. * Releases resources associated with this node.
  36396. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36397. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36398. */
  36399. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36400. /**
  36401. * Parse animation range data from a serialization object and store them into a given node
  36402. * @param node defines where to store the animation ranges
  36403. * @param parsedNode defines the serialization object to read data from
  36404. * @param scene defines the hosting scene
  36405. */
  36406. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36407. /**
  36408. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36409. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36410. * @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
  36411. * @returns the new bounding vectors
  36412. */
  36413. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36414. min: Vector3;
  36415. max: Vector3;
  36416. };
  36417. }
  36418. }
  36419. declare module BABYLON {
  36420. /**
  36421. * @hidden
  36422. */
  36423. export class _IAnimationState {
  36424. key: number;
  36425. repeatCount: number;
  36426. workValue?: any;
  36427. loopMode?: number;
  36428. offsetValue?: any;
  36429. highLimitValue?: any;
  36430. }
  36431. /**
  36432. * Class used to store any kind of animation
  36433. */
  36434. export class Animation {
  36435. /**Name of the animation */
  36436. name: string;
  36437. /**Property to animate */
  36438. targetProperty: string;
  36439. /**The frames per second of the animation */
  36440. framePerSecond: number;
  36441. /**The data type of the animation */
  36442. dataType: number;
  36443. /**The loop mode of the animation */
  36444. loopMode?: number | undefined;
  36445. /**Specifies if blending should be enabled */
  36446. enableBlending?: boolean | undefined;
  36447. /**
  36448. * Use matrix interpolation instead of using direct key value when animating matrices
  36449. */
  36450. static AllowMatricesInterpolation: boolean;
  36451. /**
  36452. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36453. */
  36454. static AllowMatrixDecomposeForInterpolation: boolean;
  36455. /** Define the Url to load snippets */
  36456. static SnippetUrl: string;
  36457. /** Snippet ID if the animation was created from the snippet server */
  36458. snippetId: string;
  36459. /**
  36460. * Stores the key frames of the animation
  36461. */
  36462. private _keys;
  36463. /**
  36464. * Stores the easing function of the animation
  36465. */
  36466. private _easingFunction;
  36467. /**
  36468. * @hidden Internal use only
  36469. */
  36470. _runtimeAnimations: RuntimeAnimation[];
  36471. /**
  36472. * The set of event that will be linked to this animation
  36473. */
  36474. private _events;
  36475. /**
  36476. * Stores an array of target property paths
  36477. */
  36478. targetPropertyPath: string[];
  36479. /**
  36480. * Stores the blending speed of the animation
  36481. */
  36482. blendingSpeed: number;
  36483. /**
  36484. * Stores the animation ranges for the animation
  36485. */
  36486. private _ranges;
  36487. /**
  36488. * @hidden Internal use
  36489. */
  36490. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36491. /**
  36492. * Sets up an animation
  36493. * @param property The property to animate
  36494. * @param animationType The animation type to apply
  36495. * @param framePerSecond The frames per second of the animation
  36496. * @param easingFunction The easing function used in the animation
  36497. * @returns The created animation
  36498. */
  36499. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36500. /**
  36501. * Create and start an animation on a node
  36502. * @param name defines the name of the global animation that will be run on all nodes
  36503. * @param node defines the root node where the animation will take place
  36504. * @param targetProperty defines property to animate
  36505. * @param framePerSecond defines the number of frame per second yo use
  36506. * @param totalFrame defines the number of frames in total
  36507. * @param from defines the initial value
  36508. * @param to defines the final value
  36509. * @param loopMode defines which loop mode you want to use (off by default)
  36510. * @param easingFunction defines the easing function to use (linear by default)
  36511. * @param onAnimationEnd defines the callback to call when animation end
  36512. * @returns the animatable created for this animation
  36513. */
  36514. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36515. /**
  36516. * Create and start an animation on a node and its descendants
  36517. * @param name defines the name of the global animation that will be run on all nodes
  36518. * @param node defines the root node where the animation will take place
  36519. * @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
  36520. * @param targetProperty defines property to animate
  36521. * @param framePerSecond defines the number of frame per second to use
  36522. * @param totalFrame defines the number of frames in total
  36523. * @param from defines the initial value
  36524. * @param to defines the final value
  36525. * @param loopMode defines which loop mode you want to use (off by default)
  36526. * @param easingFunction defines the easing function to use (linear by default)
  36527. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36528. * @returns the list of animatables created for all nodes
  36529. * @example https://www.babylonjs-playground.com/#MH0VLI
  36530. */
  36531. 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[]>;
  36532. /**
  36533. * Creates a new animation, merges it with the existing animations and starts it
  36534. * @param name Name of the animation
  36535. * @param node Node which contains the scene that begins the animations
  36536. * @param targetProperty Specifies which property to animate
  36537. * @param framePerSecond The frames per second of the animation
  36538. * @param totalFrame The total number of frames
  36539. * @param from The frame at the beginning of the animation
  36540. * @param to The frame at the end of the animation
  36541. * @param loopMode Specifies the loop mode of the animation
  36542. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36543. * @param onAnimationEnd Callback to run once the animation is complete
  36544. * @returns Nullable animation
  36545. */
  36546. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36547. /**
  36548. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36549. * @param sourceAnimation defines the Animation containing keyframes to convert
  36550. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36551. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36552. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36553. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36554. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36555. */
  36556. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36557. /**
  36558. * Transition property of an host to the target Value
  36559. * @param property The property to transition
  36560. * @param targetValue The target Value of the property
  36561. * @param host The object where the property to animate belongs
  36562. * @param scene Scene used to run the animation
  36563. * @param frameRate Framerate (in frame/s) to use
  36564. * @param transition The transition type we want to use
  36565. * @param duration The duration of the animation, in milliseconds
  36566. * @param onAnimationEnd Callback trigger at the end of the animation
  36567. * @returns Nullable animation
  36568. */
  36569. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36570. /**
  36571. * Return the array of runtime animations currently using this animation
  36572. */
  36573. get runtimeAnimations(): RuntimeAnimation[];
  36574. /**
  36575. * Specifies if any of the runtime animations are currently running
  36576. */
  36577. get hasRunningRuntimeAnimations(): boolean;
  36578. /**
  36579. * Initializes the animation
  36580. * @param name Name of the animation
  36581. * @param targetProperty Property to animate
  36582. * @param framePerSecond The frames per second of the animation
  36583. * @param dataType The data type of the animation
  36584. * @param loopMode The loop mode of the animation
  36585. * @param enableBlending Specifies if blending should be enabled
  36586. */
  36587. constructor(
  36588. /**Name of the animation */
  36589. name: string,
  36590. /**Property to animate */
  36591. targetProperty: string,
  36592. /**The frames per second of the animation */
  36593. framePerSecond: number,
  36594. /**The data type of the animation */
  36595. dataType: number,
  36596. /**The loop mode of the animation */
  36597. loopMode?: number | undefined,
  36598. /**Specifies if blending should be enabled */
  36599. enableBlending?: boolean | undefined);
  36600. /**
  36601. * Converts the animation to a string
  36602. * @param fullDetails support for multiple levels of logging within scene loading
  36603. * @returns String form of the animation
  36604. */
  36605. toString(fullDetails?: boolean): string;
  36606. /**
  36607. * Add an event to this animation
  36608. * @param event Event to add
  36609. */
  36610. addEvent(event: AnimationEvent): void;
  36611. /**
  36612. * Remove all events found at the given frame
  36613. * @param frame The frame to remove events from
  36614. */
  36615. removeEvents(frame: number): void;
  36616. /**
  36617. * Retrieves all the events from the animation
  36618. * @returns Events from the animation
  36619. */
  36620. getEvents(): AnimationEvent[];
  36621. /**
  36622. * Creates an animation range
  36623. * @param name Name of the animation range
  36624. * @param from Starting frame of the animation range
  36625. * @param to Ending frame of the animation
  36626. */
  36627. createRange(name: string, from: number, to: number): void;
  36628. /**
  36629. * Deletes an animation range by name
  36630. * @param name Name of the animation range to delete
  36631. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36632. */
  36633. deleteRange(name: string, deleteFrames?: boolean): void;
  36634. /**
  36635. * Gets the animation range by name, or null if not defined
  36636. * @param name Name of the animation range
  36637. * @returns Nullable animation range
  36638. */
  36639. getRange(name: string): Nullable<AnimationRange>;
  36640. /**
  36641. * Gets the key frames from the animation
  36642. * @returns The key frames of the animation
  36643. */
  36644. getKeys(): Array<IAnimationKey>;
  36645. /**
  36646. * Gets the highest frame rate of the animation
  36647. * @returns Highest frame rate of the animation
  36648. */
  36649. getHighestFrame(): number;
  36650. /**
  36651. * Gets the easing function of the animation
  36652. * @returns Easing function of the animation
  36653. */
  36654. getEasingFunction(): IEasingFunction;
  36655. /**
  36656. * Sets the easing function of the animation
  36657. * @param easingFunction A custom mathematical formula for animation
  36658. */
  36659. setEasingFunction(easingFunction: EasingFunction): void;
  36660. /**
  36661. * Interpolates a scalar linearly
  36662. * @param startValue Start value of the animation curve
  36663. * @param endValue End value of the animation curve
  36664. * @param gradient Scalar amount to interpolate
  36665. * @returns Interpolated scalar value
  36666. */
  36667. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36668. /**
  36669. * Interpolates a scalar cubically
  36670. * @param startValue Start value of the animation curve
  36671. * @param outTangent End tangent of the animation
  36672. * @param endValue End value of the animation curve
  36673. * @param inTangent Start tangent of the animation curve
  36674. * @param gradient Scalar amount to interpolate
  36675. * @returns Interpolated scalar value
  36676. */
  36677. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36678. /**
  36679. * Interpolates a quaternion using a spherical linear interpolation
  36680. * @param startValue Start value of the animation curve
  36681. * @param endValue End value of the animation curve
  36682. * @param gradient Scalar amount to interpolate
  36683. * @returns Interpolated quaternion value
  36684. */
  36685. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36686. /**
  36687. * Interpolates a quaternion cubically
  36688. * @param startValue Start value of the animation curve
  36689. * @param outTangent End tangent of the animation curve
  36690. * @param endValue End value of the animation curve
  36691. * @param inTangent Start tangent of the animation curve
  36692. * @param gradient Scalar amount to interpolate
  36693. * @returns Interpolated quaternion value
  36694. */
  36695. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36696. /**
  36697. * Interpolates a Vector3 linearl
  36698. * @param startValue Start value of the animation curve
  36699. * @param endValue End value of the animation curve
  36700. * @param gradient Scalar amount to interpolate
  36701. * @returns Interpolated scalar value
  36702. */
  36703. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36704. /**
  36705. * Interpolates a Vector3 cubically
  36706. * @param startValue Start value of the animation curve
  36707. * @param outTangent End tangent of the animation
  36708. * @param endValue End value of the animation curve
  36709. * @param inTangent Start tangent of the animation curve
  36710. * @param gradient Scalar amount to interpolate
  36711. * @returns InterpolatedVector3 value
  36712. */
  36713. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36714. /**
  36715. * Interpolates a Vector2 linearly
  36716. * @param startValue Start value of the animation curve
  36717. * @param endValue End value of the animation curve
  36718. * @param gradient Scalar amount to interpolate
  36719. * @returns Interpolated Vector2 value
  36720. */
  36721. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36722. /**
  36723. * Interpolates a Vector2 cubically
  36724. * @param startValue Start value of the animation curve
  36725. * @param outTangent End tangent of the animation
  36726. * @param endValue End value of the animation curve
  36727. * @param inTangent Start tangent of the animation curve
  36728. * @param gradient Scalar amount to interpolate
  36729. * @returns Interpolated Vector2 value
  36730. */
  36731. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36732. /**
  36733. * Interpolates a size linearly
  36734. * @param startValue Start value of the animation curve
  36735. * @param endValue End value of the animation curve
  36736. * @param gradient Scalar amount to interpolate
  36737. * @returns Interpolated Size value
  36738. */
  36739. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36740. /**
  36741. * Interpolates a Color3 linearly
  36742. * @param startValue Start value of the animation curve
  36743. * @param endValue End value of the animation curve
  36744. * @param gradient Scalar amount to interpolate
  36745. * @returns Interpolated Color3 value
  36746. */
  36747. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36748. /**
  36749. * Interpolates a Color4 linearly
  36750. * @param startValue Start value of the animation curve
  36751. * @param endValue End value of the animation curve
  36752. * @param gradient Scalar amount to interpolate
  36753. * @returns Interpolated Color3 value
  36754. */
  36755. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36756. /**
  36757. * @hidden Internal use only
  36758. */
  36759. _getKeyValue(value: any): any;
  36760. /**
  36761. * @hidden Internal use only
  36762. */
  36763. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36764. /**
  36765. * Defines the function to use to interpolate matrices
  36766. * @param startValue defines the start matrix
  36767. * @param endValue defines the end matrix
  36768. * @param gradient defines the gradient between both matrices
  36769. * @param result defines an optional target matrix where to store the interpolation
  36770. * @returns the interpolated matrix
  36771. */
  36772. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36773. /**
  36774. * Makes a copy of the animation
  36775. * @returns Cloned animation
  36776. */
  36777. clone(): Animation;
  36778. /**
  36779. * Sets the key frames of the animation
  36780. * @param values The animation key frames to set
  36781. */
  36782. setKeys(values: Array<IAnimationKey>): void;
  36783. /**
  36784. * Serializes the animation to an object
  36785. * @returns Serialized object
  36786. */
  36787. serialize(): any;
  36788. /**
  36789. * Float animation type
  36790. */
  36791. static readonly ANIMATIONTYPE_FLOAT: number;
  36792. /**
  36793. * Vector3 animation type
  36794. */
  36795. static readonly ANIMATIONTYPE_VECTOR3: number;
  36796. /**
  36797. * Quaternion animation type
  36798. */
  36799. static readonly ANIMATIONTYPE_QUATERNION: number;
  36800. /**
  36801. * Matrix animation type
  36802. */
  36803. static readonly ANIMATIONTYPE_MATRIX: number;
  36804. /**
  36805. * Color3 animation type
  36806. */
  36807. static readonly ANIMATIONTYPE_COLOR3: number;
  36808. /**
  36809. * Color3 animation type
  36810. */
  36811. static readonly ANIMATIONTYPE_COLOR4: number;
  36812. /**
  36813. * Vector2 animation type
  36814. */
  36815. static readonly ANIMATIONTYPE_VECTOR2: number;
  36816. /**
  36817. * Size animation type
  36818. */
  36819. static readonly ANIMATIONTYPE_SIZE: number;
  36820. /**
  36821. * Relative Loop Mode
  36822. */
  36823. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36824. /**
  36825. * Cycle Loop Mode
  36826. */
  36827. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36828. /**
  36829. * Constant Loop Mode
  36830. */
  36831. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36832. /** @hidden */
  36833. static _UniversalLerp(left: any, right: any, amount: number): any;
  36834. /**
  36835. * Parses an animation object and creates an animation
  36836. * @param parsedAnimation Parsed animation object
  36837. * @returns Animation object
  36838. */
  36839. static Parse(parsedAnimation: any): Animation;
  36840. /**
  36841. * Appends the serialized animations from the source animations
  36842. * @param source Source containing the animations
  36843. * @param destination Target to store the animations
  36844. */
  36845. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36846. /**
  36847. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36848. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36849. * @param url defines the url to load from
  36850. * @returns a promise that will resolve to the new animation or an array of animations
  36851. */
  36852. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36853. /**
  36854. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36855. * @param snippetId defines the snippet to load
  36856. * @returns a promise that will resolve to the new animation or a new array of animations
  36857. */
  36858. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36859. }
  36860. }
  36861. declare module BABYLON {
  36862. /**
  36863. * Interface containing an array of animations
  36864. */
  36865. export interface IAnimatable {
  36866. /**
  36867. * Array of animations
  36868. */
  36869. animations: Nullable<Array<Animation>>;
  36870. }
  36871. }
  36872. declare module BABYLON {
  36873. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36874. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36875. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36876. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36877. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36878. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36879. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36880. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36881. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36882. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36883. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36884. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36885. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36886. /**
  36887. * Decorator used to define property that can be serialized as reference to a camera
  36888. * @param sourceName defines the name of the property to decorate
  36889. */
  36890. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36891. /**
  36892. * Class used to help serialization objects
  36893. */
  36894. export class SerializationHelper {
  36895. /** @hidden */
  36896. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36897. /** @hidden */
  36898. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36899. /** @hidden */
  36900. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36901. /** @hidden */
  36902. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36903. /**
  36904. * Appends the serialized animations from the source animations
  36905. * @param source Source containing the animations
  36906. * @param destination Target to store the animations
  36907. */
  36908. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36909. /**
  36910. * Static function used to serialized a specific entity
  36911. * @param entity defines the entity to serialize
  36912. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36913. * @returns a JSON compatible object representing the serialization of the entity
  36914. */
  36915. static Serialize<T>(entity: T, serializationObject?: any): any;
  36916. /**
  36917. * Creates a new entity from a serialization data object
  36918. * @param creationFunction defines a function used to instanciated the new entity
  36919. * @param source defines the source serialization data
  36920. * @param scene defines the hosting scene
  36921. * @param rootUrl defines the root url for resources
  36922. * @returns a new entity
  36923. */
  36924. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  36925. /**
  36926. * Clones an object
  36927. * @param creationFunction defines the function used to instanciate the new object
  36928. * @param source defines the source object
  36929. * @returns the cloned object
  36930. */
  36931. static Clone<T>(creationFunction: () => T, source: T): T;
  36932. /**
  36933. * Instanciates a new object based on a source one (some data will be shared between both object)
  36934. * @param creationFunction defines the function used to instanciate the new object
  36935. * @param source defines the source object
  36936. * @returns the new object
  36937. */
  36938. static Instanciate<T>(creationFunction: () => T, source: T): T;
  36939. }
  36940. }
  36941. declare module BABYLON {
  36942. /**
  36943. * This is the base class of all the camera used in the application.
  36944. * @see https://doc.babylonjs.com/features/cameras
  36945. */
  36946. export class Camera extends Node {
  36947. /** @hidden */
  36948. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  36949. /**
  36950. * This is the default projection mode used by the cameras.
  36951. * It helps recreating a feeling of perspective and better appreciate depth.
  36952. * This is the best way to simulate real life cameras.
  36953. */
  36954. static readonly PERSPECTIVE_CAMERA: number;
  36955. /**
  36956. * This helps creating camera with an orthographic mode.
  36957. * 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.
  36958. */
  36959. static readonly ORTHOGRAPHIC_CAMERA: number;
  36960. /**
  36961. * This is the default FOV mode for perspective cameras.
  36962. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  36963. */
  36964. static readonly FOVMODE_VERTICAL_FIXED: number;
  36965. /**
  36966. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  36967. */
  36968. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  36969. /**
  36970. * This specifies ther is no need for a camera rig.
  36971. * Basically only one eye is rendered corresponding to the camera.
  36972. */
  36973. static readonly RIG_MODE_NONE: number;
  36974. /**
  36975. * Simulates a camera Rig with one blue eye and one red eye.
  36976. * This can be use with 3d blue and red glasses.
  36977. */
  36978. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  36979. /**
  36980. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  36981. */
  36982. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  36983. /**
  36984. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  36985. */
  36986. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  36987. /**
  36988. * Defines that both eyes of the camera will be rendered over under each other.
  36989. */
  36990. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  36991. /**
  36992. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  36993. */
  36994. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  36995. /**
  36996. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  36997. */
  36998. static readonly RIG_MODE_VR: number;
  36999. /**
  37000. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37001. */
  37002. static readonly RIG_MODE_WEBVR: number;
  37003. /**
  37004. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37005. */
  37006. static readonly RIG_MODE_CUSTOM: number;
  37007. /**
  37008. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37009. */
  37010. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37011. /**
  37012. * Define the input manager associated with the camera.
  37013. */
  37014. inputs: CameraInputsManager<Camera>;
  37015. /** @hidden */
  37016. _position: Vector3;
  37017. /**
  37018. * Define the current local position of the camera in the scene
  37019. */
  37020. get position(): Vector3;
  37021. set position(newPosition: Vector3);
  37022. protected _upVector: Vector3;
  37023. /**
  37024. * The vector the camera should consider as up.
  37025. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37026. */
  37027. set upVector(vec: Vector3);
  37028. get upVector(): Vector3;
  37029. /**
  37030. * Define the current limit on the left side for an orthographic camera
  37031. * In scene unit
  37032. */
  37033. orthoLeft: Nullable<number>;
  37034. /**
  37035. * Define the current limit on the right side for an orthographic camera
  37036. * In scene unit
  37037. */
  37038. orthoRight: Nullable<number>;
  37039. /**
  37040. * Define the current limit on the bottom side for an orthographic camera
  37041. * In scene unit
  37042. */
  37043. orthoBottom: Nullable<number>;
  37044. /**
  37045. * Define the current limit on the top side for an orthographic camera
  37046. * In scene unit
  37047. */
  37048. orthoTop: Nullable<number>;
  37049. /**
  37050. * Field Of View is set in Radians. (default is 0.8)
  37051. */
  37052. fov: number;
  37053. /**
  37054. * Define the minimum distance the camera can see from.
  37055. * This is important to note that the depth buffer are not infinite and the closer it starts
  37056. * the more your scene might encounter depth fighting issue.
  37057. */
  37058. minZ: number;
  37059. /**
  37060. * Define the maximum distance the camera can see to.
  37061. * This is important to note that the depth buffer are not infinite and the further it end
  37062. * the more your scene might encounter depth fighting issue.
  37063. */
  37064. maxZ: number;
  37065. /**
  37066. * Define the default inertia of the camera.
  37067. * This helps giving a smooth feeling to the camera movement.
  37068. */
  37069. inertia: number;
  37070. /**
  37071. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37072. */
  37073. mode: number;
  37074. /**
  37075. * Define whether the camera is intermediate.
  37076. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37077. */
  37078. isIntermediate: boolean;
  37079. /**
  37080. * Define the viewport of the camera.
  37081. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37082. */
  37083. viewport: Viewport;
  37084. /**
  37085. * Restricts the camera to viewing objects with the same layerMask.
  37086. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37087. */
  37088. layerMask: number;
  37089. /**
  37090. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37091. */
  37092. fovMode: number;
  37093. /**
  37094. * Rig mode of the camera.
  37095. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37096. * This is normally controlled byt the camera themselves as internal use.
  37097. */
  37098. cameraRigMode: number;
  37099. /**
  37100. * Defines the distance between both "eyes" in case of a RIG
  37101. */
  37102. interaxialDistance: number;
  37103. /**
  37104. * Defines if stereoscopic rendering is done side by side or over under.
  37105. */
  37106. isStereoscopicSideBySide: boolean;
  37107. /**
  37108. * 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
  37109. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37110. * else in the scene. (Eg. security camera)
  37111. *
  37112. * 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)
  37113. */
  37114. customRenderTargets: RenderTargetTexture[];
  37115. /**
  37116. * When set, the camera will render to this render target instead of the default canvas
  37117. *
  37118. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37119. */
  37120. outputRenderTarget: Nullable<RenderTargetTexture>;
  37121. /**
  37122. * Observable triggered when the camera view matrix has changed.
  37123. */
  37124. onViewMatrixChangedObservable: Observable<Camera>;
  37125. /**
  37126. * Observable triggered when the camera Projection matrix has changed.
  37127. */
  37128. onProjectionMatrixChangedObservable: Observable<Camera>;
  37129. /**
  37130. * Observable triggered when the inputs have been processed.
  37131. */
  37132. onAfterCheckInputsObservable: Observable<Camera>;
  37133. /**
  37134. * Observable triggered when reset has been called and applied to the camera.
  37135. */
  37136. onRestoreStateObservable: Observable<Camera>;
  37137. /**
  37138. * Is this camera a part of a rig system?
  37139. */
  37140. isRigCamera: boolean;
  37141. /**
  37142. * If isRigCamera set to true this will be set with the parent camera.
  37143. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37144. */
  37145. rigParent?: Camera;
  37146. /** @hidden */
  37147. _cameraRigParams: any;
  37148. /** @hidden */
  37149. _rigCameras: Camera[];
  37150. /** @hidden */
  37151. _rigPostProcess: Nullable<PostProcess>;
  37152. protected _webvrViewMatrix: Matrix;
  37153. /** @hidden */
  37154. _skipRendering: boolean;
  37155. /** @hidden */
  37156. _projectionMatrix: Matrix;
  37157. /** @hidden */
  37158. _postProcesses: Nullable<PostProcess>[];
  37159. /** @hidden */
  37160. _activeMeshes: SmartArray<AbstractMesh>;
  37161. protected _globalPosition: Vector3;
  37162. /** @hidden */
  37163. _computedViewMatrix: Matrix;
  37164. private _doNotComputeProjectionMatrix;
  37165. private _transformMatrix;
  37166. private _frustumPlanes;
  37167. private _refreshFrustumPlanes;
  37168. private _storedFov;
  37169. private _stateStored;
  37170. /**
  37171. * Instantiates a new camera object.
  37172. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  37173. * @see https://doc.babylonjs.com/features/cameras
  37174. * @param name Defines the name of the camera in the scene
  37175. * @param position Defines the position of the camera
  37176. * @param scene Defines the scene the camera belongs too
  37177. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  37178. */
  37179. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37180. /**
  37181. * Store current camera state (fov, position, etc..)
  37182. * @returns the camera
  37183. */
  37184. storeState(): Camera;
  37185. /**
  37186. * Restores the camera state values if it has been stored. You must call storeState() first
  37187. */
  37188. protected _restoreStateValues(): boolean;
  37189. /**
  37190. * Restored camera state. You must call storeState() first.
  37191. * @returns true if restored and false otherwise
  37192. */
  37193. restoreState(): boolean;
  37194. /**
  37195. * Gets the class name of the camera.
  37196. * @returns the class name
  37197. */
  37198. getClassName(): string;
  37199. /** @hidden */
  37200. readonly _isCamera: boolean;
  37201. /**
  37202. * Gets a string representation of the camera useful for debug purpose.
  37203. * @param fullDetails Defines that a more verboe level of logging is required
  37204. * @returns the string representation
  37205. */
  37206. toString(fullDetails?: boolean): string;
  37207. /**
  37208. * Gets the current world space position of the camera.
  37209. */
  37210. get globalPosition(): Vector3;
  37211. /**
  37212. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  37213. * @returns the active meshe list
  37214. */
  37215. getActiveMeshes(): SmartArray<AbstractMesh>;
  37216. /**
  37217. * Check whether a mesh is part of the current active mesh list of the camera
  37218. * @param mesh Defines the mesh to check
  37219. * @returns true if active, false otherwise
  37220. */
  37221. isActiveMesh(mesh: Mesh): boolean;
  37222. /**
  37223. * Is this camera ready to be used/rendered
  37224. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  37225. * @return true if the camera is ready
  37226. */
  37227. isReady(completeCheck?: boolean): boolean;
  37228. /** @hidden */
  37229. _initCache(): void;
  37230. /** @hidden */
  37231. _updateCache(ignoreParentClass?: boolean): void;
  37232. /** @hidden */
  37233. _isSynchronized(): boolean;
  37234. /** @hidden */
  37235. _isSynchronizedViewMatrix(): boolean;
  37236. /** @hidden */
  37237. _isSynchronizedProjectionMatrix(): boolean;
  37238. /**
  37239. * Attach the input controls to a specific dom element to get the input from.
  37240. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37241. */
  37242. attachControl(noPreventDefault?: boolean): void;
  37243. /**
  37244. * Attach the input controls to a specific dom element to get the input from.
  37245. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  37246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37247. * BACK COMPAT SIGNATURE ONLY.
  37248. */
  37249. attachControl(ignored: any, noPreventDefault?: boolean): void;
  37250. /**
  37251. * Detach the current controls from the specified dom element.
  37252. */
  37253. detachControl(): void;
  37254. /**
  37255. * Detach the current controls from the specified dom element.
  37256. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  37257. */
  37258. detachControl(ignored: any): void;
  37259. /**
  37260. * Update the camera state according to the different inputs gathered during the frame.
  37261. */
  37262. update(): void;
  37263. /** @hidden */
  37264. _checkInputs(): void;
  37265. /** @hidden */
  37266. get rigCameras(): Camera[];
  37267. /**
  37268. * Gets the post process used by the rig cameras
  37269. */
  37270. get rigPostProcess(): Nullable<PostProcess>;
  37271. /**
  37272. * Internal, gets the first post proces.
  37273. * @returns the first post process to be run on this camera.
  37274. */
  37275. _getFirstPostProcess(): Nullable<PostProcess>;
  37276. private _cascadePostProcessesToRigCams;
  37277. /**
  37278. * Attach a post process to the camera.
  37279. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37280. * @param postProcess The post process to attach to the camera
  37281. * @param insertAt The position of the post process in case several of them are in use in the scene
  37282. * @returns the position the post process has been inserted at
  37283. */
  37284. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  37285. /**
  37286. * Detach a post process to the camera.
  37287. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37288. * @param postProcess The post process to detach from the camera
  37289. */
  37290. detachPostProcess(postProcess: PostProcess): void;
  37291. /**
  37292. * Gets the current world matrix of the camera
  37293. */
  37294. getWorldMatrix(): Matrix;
  37295. /** @hidden */
  37296. _getViewMatrix(): Matrix;
  37297. /**
  37298. * Gets the current view matrix of the camera.
  37299. * @param force forces the camera to recompute the matrix without looking at the cached state
  37300. * @returns the view matrix
  37301. */
  37302. getViewMatrix(force?: boolean): Matrix;
  37303. /**
  37304. * Freeze the projection matrix.
  37305. * It will prevent the cache check of the camera projection compute and can speed up perf
  37306. * if no parameter of the camera are meant to change
  37307. * @param projection Defines manually a projection if necessary
  37308. */
  37309. freezeProjectionMatrix(projection?: Matrix): void;
  37310. /**
  37311. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  37312. */
  37313. unfreezeProjectionMatrix(): void;
  37314. /**
  37315. * Gets the current projection matrix of the camera.
  37316. * @param force forces the camera to recompute the matrix without looking at the cached state
  37317. * @returns the projection matrix
  37318. */
  37319. getProjectionMatrix(force?: boolean): Matrix;
  37320. /**
  37321. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  37322. * @returns a Matrix
  37323. */
  37324. getTransformationMatrix(): Matrix;
  37325. private _updateFrustumPlanes;
  37326. /**
  37327. * Checks if a cullable object (mesh...) is in the camera frustum
  37328. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  37329. * @param target The object to check
  37330. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  37331. * @returns true if the object is in frustum otherwise false
  37332. */
  37333. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  37334. /**
  37335. * Checks if a cullable object (mesh...) is in the camera frustum
  37336. * Unlike isInFrustum this cheks the full bounding box
  37337. * @param target The object to check
  37338. * @returns true if the object is in frustum otherwise false
  37339. */
  37340. isCompletelyInFrustum(target: ICullable): boolean;
  37341. /**
  37342. * Gets a ray in the forward direction from the camera.
  37343. * @param length Defines the length of the ray to create
  37344. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37345. * @param origin Defines the start point of the ray which defaults to the camera position
  37346. * @returns the forward ray
  37347. */
  37348. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37349. /**
  37350. * Gets a ray in the forward direction from the camera.
  37351. * @param refRay the ray to (re)use when setting the values
  37352. * @param length Defines the length of the ray to create
  37353. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37354. * @param origin Defines the start point of the ray which defaults to the camera position
  37355. * @returns the forward ray
  37356. */
  37357. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37358. /**
  37359. * Releases resources associated with this node.
  37360. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37361. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37362. */
  37363. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37364. /** @hidden */
  37365. _isLeftCamera: boolean;
  37366. /**
  37367. * Gets the left camera of a rig setup in case of Rigged Camera
  37368. */
  37369. get isLeftCamera(): boolean;
  37370. /** @hidden */
  37371. _isRightCamera: boolean;
  37372. /**
  37373. * Gets the right camera of a rig setup in case of Rigged Camera
  37374. */
  37375. get isRightCamera(): boolean;
  37376. /**
  37377. * Gets the left camera of a rig setup in case of Rigged Camera
  37378. */
  37379. get leftCamera(): Nullable<FreeCamera>;
  37380. /**
  37381. * Gets the right camera of a rig setup in case of Rigged Camera
  37382. */
  37383. get rightCamera(): Nullable<FreeCamera>;
  37384. /**
  37385. * Gets the left camera target of a rig setup in case of Rigged Camera
  37386. * @returns the target position
  37387. */
  37388. getLeftTarget(): Nullable<Vector3>;
  37389. /**
  37390. * Gets the right camera target of a rig setup in case of Rigged Camera
  37391. * @returns the target position
  37392. */
  37393. getRightTarget(): Nullable<Vector3>;
  37394. /**
  37395. * @hidden
  37396. */
  37397. setCameraRigMode(mode: number, rigParams: any): void;
  37398. /** @hidden */
  37399. static _setStereoscopicRigMode(camera: Camera): void;
  37400. /** @hidden */
  37401. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  37402. /** @hidden */
  37403. static _setVRRigMode(camera: Camera, rigParams: any): void;
  37404. /** @hidden */
  37405. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  37406. /** @hidden */
  37407. _getVRProjectionMatrix(): Matrix;
  37408. protected _updateCameraRotationMatrix(): void;
  37409. protected _updateWebVRCameraRotationMatrix(): void;
  37410. /**
  37411. * This function MUST be overwritten by the different WebVR cameras available.
  37412. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37413. * @hidden
  37414. */
  37415. _getWebVRProjectionMatrix(): Matrix;
  37416. /**
  37417. * This function MUST be overwritten by the different WebVR cameras available.
  37418. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37419. * @hidden
  37420. */
  37421. _getWebVRViewMatrix(): Matrix;
  37422. /** @hidden */
  37423. setCameraRigParameter(name: string, value: any): void;
  37424. /**
  37425. * needs to be overridden by children so sub has required properties to be copied
  37426. * @hidden
  37427. */
  37428. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  37429. /**
  37430. * May need to be overridden by children
  37431. * @hidden
  37432. */
  37433. _updateRigCameras(): void;
  37434. /** @hidden */
  37435. _setupInputs(): void;
  37436. /**
  37437. * Serialiaze the camera setup to a json represention
  37438. * @returns the JSON representation
  37439. */
  37440. serialize(): any;
  37441. /**
  37442. * Clones the current camera.
  37443. * @param name The cloned camera name
  37444. * @returns the cloned camera
  37445. */
  37446. clone(name: string): Camera;
  37447. /**
  37448. * Gets the direction of the camera relative to a given local axis.
  37449. * @param localAxis Defines the reference axis to provide a relative direction.
  37450. * @return the direction
  37451. */
  37452. getDirection(localAxis: Vector3): Vector3;
  37453. /**
  37454. * Returns the current camera absolute rotation
  37455. */
  37456. get absoluteRotation(): Quaternion;
  37457. /**
  37458. * Gets the direction of the camera relative to a given local axis into a passed vector.
  37459. * @param localAxis Defines the reference axis to provide a relative direction.
  37460. * @param result Defines the vector to store the result in
  37461. */
  37462. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  37463. /**
  37464. * Gets a camera constructor for a given camera type
  37465. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  37466. * @param name The name of the camera the result will be able to instantiate
  37467. * @param scene The scene the result will construct the camera in
  37468. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  37469. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  37470. * @returns a factory method to construc the camera
  37471. */
  37472. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  37473. /**
  37474. * Compute the world matrix of the camera.
  37475. * @returns the camera world matrix
  37476. */
  37477. computeWorldMatrix(): Matrix;
  37478. /**
  37479. * Parse a JSON and creates the camera from the parsed information
  37480. * @param parsedCamera The JSON to parse
  37481. * @param scene The scene to instantiate the camera in
  37482. * @returns the newly constructed camera
  37483. */
  37484. static Parse(parsedCamera: any, scene: Scene): Camera;
  37485. }
  37486. }
  37487. declare module BABYLON {
  37488. /**
  37489. * PostProcessManager is used to manage one or more post processes or post process pipelines
  37490. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  37491. */
  37492. export class PostProcessManager {
  37493. private _scene;
  37494. private _indexBuffer;
  37495. private _vertexBuffers;
  37496. /**
  37497. * Creates a new instance PostProcess
  37498. * @param scene The scene that the post process is associated with.
  37499. */
  37500. constructor(scene: Scene);
  37501. private _prepareBuffers;
  37502. private _buildIndexBuffer;
  37503. /**
  37504. * Rebuilds the vertex buffers of the manager.
  37505. * @hidden
  37506. */
  37507. _rebuild(): void;
  37508. /**
  37509. * Prepares a frame to be run through a post process.
  37510. * @param sourceTexture The input texture to the post procesess. (default: null)
  37511. * @param postProcesses An array of post processes to be run. (default: null)
  37512. * @returns True if the post processes were able to be run.
  37513. * @hidden
  37514. */
  37515. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  37516. /**
  37517. * Manually render a set of post processes to a texture.
  37518. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  37519. * @param postProcesses An array of post processes to be run.
  37520. * @param targetTexture The target texture to render to.
  37521. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  37522. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  37523. * @param lodLevel defines which lod of the texture to render to
  37524. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  37525. */
  37526. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  37527. /**
  37528. * Finalize the result of the output of the postprocesses.
  37529. * @param doNotPresent If true the result will not be displayed to the screen.
  37530. * @param targetTexture The target texture to render to.
  37531. * @param faceIndex The index of the face to bind the target texture to.
  37532. * @param postProcesses The array of post processes to render.
  37533. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  37534. * @hidden
  37535. */
  37536. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  37537. /**
  37538. * Disposes of the post process manager.
  37539. */
  37540. dispose(): void;
  37541. }
  37542. }
  37543. declare module BABYLON {
  37544. /**
  37545. * This Helps creating a texture that will be created from a camera in your scene.
  37546. * It is basically a dynamic texture that could be used to create special effects for instance.
  37547. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  37548. */
  37549. export class RenderTargetTexture extends Texture {
  37550. /**
  37551. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  37552. */
  37553. static readonly REFRESHRATE_RENDER_ONCE: number;
  37554. /**
  37555. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  37556. */
  37557. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37558. /**
  37559. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  37560. * the central point of your effect and can save a lot of performances.
  37561. */
  37562. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37563. /**
  37564. * Use this predicate to dynamically define the list of mesh you want to render.
  37565. * If set, the renderList property will be overwritten.
  37566. */
  37567. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37568. private _renderList;
  37569. /**
  37570. * Use this list to define the list of mesh you want to render.
  37571. */
  37572. get renderList(): Nullable<Array<AbstractMesh>>;
  37573. set renderList(value: Nullable<Array<AbstractMesh>>);
  37574. /**
  37575. * Use this function to overload the renderList array at rendering time.
  37576. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  37577. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  37578. * the cube (if the RTT is a cube, else layerOrFace=0).
  37579. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  37580. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  37581. * hold dummy elements!
  37582. */
  37583. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  37584. private _hookArray;
  37585. /**
  37586. * Define if particles should be rendered in your texture.
  37587. */
  37588. renderParticles: boolean;
  37589. /**
  37590. * Define if sprites should be rendered in your texture.
  37591. */
  37592. renderSprites: boolean;
  37593. /**
  37594. * Define the camera used to render the texture.
  37595. */
  37596. activeCamera: Nullable<Camera>;
  37597. /**
  37598. * Override the mesh isReady function with your own one.
  37599. */
  37600. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  37601. /**
  37602. * Override the render function of the texture with your own one.
  37603. */
  37604. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37605. /**
  37606. * Define if camera post processes should be use while rendering the texture.
  37607. */
  37608. useCameraPostProcesses: boolean;
  37609. /**
  37610. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  37611. */
  37612. ignoreCameraViewport: boolean;
  37613. private _postProcessManager;
  37614. private _postProcesses;
  37615. private _resizeObserver;
  37616. /**
  37617. * An event triggered when the texture is unbind.
  37618. */
  37619. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37620. /**
  37621. * An event triggered when the texture is unbind.
  37622. */
  37623. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37624. private _onAfterUnbindObserver;
  37625. /**
  37626. * Set a after unbind callback in the texture.
  37627. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  37628. */
  37629. set onAfterUnbind(callback: () => void);
  37630. /**
  37631. * An event triggered before rendering the texture
  37632. */
  37633. onBeforeRenderObservable: Observable<number>;
  37634. private _onBeforeRenderObserver;
  37635. /**
  37636. * Set a before render callback in the texture.
  37637. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  37638. */
  37639. set onBeforeRender(callback: (faceIndex: number) => void);
  37640. /**
  37641. * An event triggered after rendering the texture
  37642. */
  37643. onAfterRenderObservable: Observable<number>;
  37644. private _onAfterRenderObserver;
  37645. /**
  37646. * Set a after render callback in the texture.
  37647. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  37648. */
  37649. set onAfterRender(callback: (faceIndex: number) => void);
  37650. /**
  37651. * An event triggered after the texture clear
  37652. */
  37653. onClearObservable: Observable<Engine>;
  37654. private _onClearObserver;
  37655. /**
  37656. * Set a clear callback in the texture.
  37657. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  37658. */
  37659. set onClear(callback: (Engine: Engine) => void);
  37660. /**
  37661. * An event triggered when the texture is resized.
  37662. */
  37663. onResizeObservable: Observable<RenderTargetTexture>;
  37664. /**
  37665. * Define the clear color of the Render Target if it should be different from the scene.
  37666. */
  37667. clearColor: Color4;
  37668. protected _size: number | {
  37669. width: number;
  37670. height: number;
  37671. layers?: number;
  37672. };
  37673. protected _initialSizeParameter: number | {
  37674. width: number;
  37675. height: number;
  37676. } | {
  37677. ratio: number;
  37678. };
  37679. protected _sizeRatio: Nullable<number>;
  37680. /** @hidden */
  37681. _generateMipMaps: boolean;
  37682. protected _renderingManager: RenderingManager;
  37683. /** @hidden */
  37684. _waitingRenderList?: string[];
  37685. protected _doNotChangeAspectRatio: boolean;
  37686. protected _currentRefreshId: number;
  37687. protected _refreshRate: number;
  37688. protected _textureMatrix: Matrix;
  37689. protected _samples: number;
  37690. protected _renderTargetOptions: RenderTargetCreationOptions;
  37691. /**
  37692. * Gets render target creation options that were used.
  37693. */
  37694. get renderTargetOptions(): RenderTargetCreationOptions;
  37695. protected _onRatioRescale(): void;
  37696. /**
  37697. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37698. * It must define where the camera used to render the texture is set
  37699. */
  37700. boundingBoxPosition: Vector3;
  37701. private _boundingBoxSize;
  37702. /**
  37703. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37704. * When defined, the cubemap will switch to local mode
  37705. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37706. * @example https://www.babylonjs-playground.com/#RNASML
  37707. */
  37708. set boundingBoxSize(value: Vector3);
  37709. get boundingBoxSize(): Vector3;
  37710. /**
  37711. * In case the RTT has been created with a depth texture, get the associated
  37712. * depth texture.
  37713. * Otherwise, return null.
  37714. */
  37715. get depthStencilTexture(): Nullable<InternalTexture>;
  37716. /**
  37717. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  37718. * or used a shadow, depth texture...
  37719. * @param name The friendly name of the texture
  37720. * @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)
  37721. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37722. * @param generateMipMaps True if mip maps need to be generated after render.
  37723. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37724. * @param type The type of the buffer in the RTT (int, half float, float...)
  37725. * @param isCube True if a cube texture needs to be created
  37726. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37727. * @param generateDepthBuffer True to generate a depth buffer
  37728. * @param generateStencilBuffer True to generate a stencil buffer
  37729. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37730. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37731. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37732. */
  37733. constructor(name: string, size: number | {
  37734. width: number;
  37735. height: number;
  37736. layers?: number;
  37737. } | {
  37738. ratio: number;
  37739. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  37740. /**
  37741. * Creates a depth stencil texture.
  37742. * This is only available in WebGL 2 or with the depth texture extension available.
  37743. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37744. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37745. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37746. */
  37747. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37748. private _processSizeParameter;
  37749. /**
  37750. * Define the number of samples to use in case of MSAA.
  37751. * It defaults to one meaning no MSAA has been enabled.
  37752. */
  37753. get samples(): number;
  37754. set samples(value: number);
  37755. /**
  37756. * Resets the refresh counter of the texture and start bak from scratch.
  37757. * Could be useful to regenerate the texture if it is setup to render only once.
  37758. */
  37759. resetRefreshCounter(): void;
  37760. /**
  37761. * Define the refresh rate of the texture or the rendering frequency.
  37762. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  37763. */
  37764. get refreshRate(): number;
  37765. set refreshRate(value: number);
  37766. /**
  37767. * Adds a post process to the render target rendering passes.
  37768. * @param postProcess define the post process to add
  37769. */
  37770. addPostProcess(postProcess: PostProcess): void;
  37771. /**
  37772. * Clear all the post processes attached to the render target
  37773. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  37774. */
  37775. clearPostProcesses(dispose?: boolean): void;
  37776. /**
  37777. * Remove one of the post process from the list of attached post processes to the texture
  37778. * @param postProcess define the post process to remove from the list
  37779. */
  37780. removePostProcess(postProcess: PostProcess): void;
  37781. /** @hidden */
  37782. _shouldRender(): boolean;
  37783. /**
  37784. * Gets the actual render size of the texture.
  37785. * @returns the width of the render size
  37786. */
  37787. getRenderSize(): number;
  37788. /**
  37789. * Gets the actual render width of the texture.
  37790. * @returns the width of the render size
  37791. */
  37792. getRenderWidth(): number;
  37793. /**
  37794. * Gets the actual render height of the texture.
  37795. * @returns the height of the render size
  37796. */
  37797. getRenderHeight(): number;
  37798. /**
  37799. * Gets the actual number of layers of the texture.
  37800. * @returns the number of layers
  37801. */
  37802. getRenderLayers(): number;
  37803. /**
  37804. * Get if the texture can be rescaled or not.
  37805. */
  37806. get canRescale(): boolean;
  37807. /**
  37808. * Resize the texture using a ratio.
  37809. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  37810. */
  37811. scale(ratio: number): void;
  37812. /**
  37813. * Get the texture reflection matrix used to rotate/transform the reflection.
  37814. * @returns the reflection matrix
  37815. */
  37816. getReflectionTextureMatrix(): Matrix;
  37817. /**
  37818. * Resize the texture to a new desired size.
  37819. * Be carrefull as it will recreate all the data in the new texture.
  37820. * @param size Define the new size. It can be:
  37821. * - a number for squared texture,
  37822. * - an object containing { width: number, height: number }
  37823. * - or an object containing a ratio { ratio: number }
  37824. */
  37825. resize(size: number | {
  37826. width: number;
  37827. height: number;
  37828. } | {
  37829. ratio: number;
  37830. }): void;
  37831. private _defaultRenderListPrepared;
  37832. /**
  37833. * Renders all the objects from the render list into the texture.
  37834. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  37835. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  37836. */
  37837. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37838. private _bestReflectionRenderTargetDimension;
  37839. private _prepareRenderingManager;
  37840. /**
  37841. * @hidden
  37842. * @param faceIndex face index to bind to if this is a cubetexture
  37843. * @param layer defines the index of the texture to bind in the array
  37844. */
  37845. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  37846. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37847. private renderToTarget;
  37848. /**
  37849. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37850. * This allowed control for front to back rendering or reversly depending of the special needs.
  37851. *
  37852. * @param renderingGroupId The rendering group id corresponding to its index
  37853. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37854. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37855. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37856. */
  37857. 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;
  37858. /**
  37859. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37860. *
  37861. * @param renderingGroupId The rendering group id corresponding to its index
  37862. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37863. */
  37864. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37865. /**
  37866. * Clones the texture.
  37867. * @returns the cloned texture
  37868. */
  37869. clone(): RenderTargetTexture;
  37870. /**
  37871. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  37872. * @returns The JSON representation of the texture
  37873. */
  37874. serialize(): any;
  37875. /**
  37876. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  37877. */
  37878. disposeFramebufferObjects(): void;
  37879. /**
  37880. * Dispose the texture and release its associated resources.
  37881. */
  37882. dispose(): void;
  37883. /** @hidden */
  37884. _rebuild(): void;
  37885. /**
  37886. * Clear the info related to rendering groups preventing retention point in material dispose.
  37887. */
  37888. freeRenderingGroups(): void;
  37889. /**
  37890. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  37891. * @returns the view count
  37892. */
  37893. getViewCount(): number;
  37894. }
  37895. }
  37896. declare module BABYLON {
  37897. /**
  37898. * Options to be used when creating an effect.
  37899. */
  37900. export interface IEffectCreationOptions {
  37901. /**
  37902. * Atrributes that will be used in the shader.
  37903. */
  37904. attributes: string[];
  37905. /**
  37906. * Uniform varible names that will be set in the shader.
  37907. */
  37908. uniformsNames: string[];
  37909. /**
  37910. * Uniform buffer variable names that will be set in the shader.
  37911. */
  37912. uniformBuffersNames: string[];
  37913. /**
  37914. * Sampler texture variable names that will be set in the shader.
  37915. */
  37916. samplers: string[];
  37917. /**
  37918. * Define statements that will be set in the shader.
  37919. */
  37920. defines: any;
  37921. /**
  37922. * Possible fallbacks for this effect to improve performance when needed.
  37923. */
  37924. fallbacks: Nullable<IEffectFallbacks>;
  37925. /**
  37926. * Callback that will be called when the shader is compiled.
  37927. */
  37928. onCompiled: Nullable<(effect: Effect) => void>;
  37929. /**
  37930. * Callback that will be called if an error occurs during shader compilation.
  37931. */
  37932. onError: Nullable<(effect: Effect, errors: string) => void>;
  37933. /**
  37934. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37935. */
  37936. indexParameters?: any;
  37937. /**
  37938. * Max number of lights that can be used in the shader.
  37939. */
  37940. maxSimultaneousLights?: number;
  37941. /**
  37942. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37943. */
  37944. transformFeedbackVaryings?: Nullable<string[]>;
  37945. /**
  37946. * 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
  37947. */
  37948. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37949. /**
  37950. * Is this effect rendering to several color attachments ?
  37951. */
  37952. multiTarget?: boolean;
  37953. }
  37954. /**
  37955. * Effect containing vertex and fragment shader that can be executed on an object.
  37956. */
  37957. export class Effect implements IDisposable {
  37958. /**
  37959. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37960. */
  37961. static ShadersRepository: string;
  37962. /**
  37963. * Enable logging of the shader code when a compilation error occurs
  37964. */
  37965. static LogShaderCodeOnCompilationError: boolean;
  37966. /**
  37967. * Name of the effect.
  37968. */
  37969. name: any;
  37970. /**
  37971. * String container all the define statements that should be set on the shader.
  37972. */
  37973. defines: string;
  37974. /**
  37975. * Callback that will be called when the shader is compiled.
  37976. */
  37977. onCompiled: Nullable<(effect: Effect) => void>;
  37978. /**
  37979. * Callback that will be called if an error occurs during shader compilation.
  37980. */
  37981. onError: Nullable<(effect: Effect, errors: string) => void>;
  37982. /**
  37983. * Callback that will be called when effect is bound.
  37984. */
  37985. onBind: Nullable<(effect: Effect) => void>;
  37986. /**
  37987. * Unique ID of the effect.
  37988. */
  37989. uniqueId: number;
  37990. /**
  37991. * Observable that will be called when the shader is compiled.
  37992. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37993. */
  37994. onCompileObservable: Observable<Effect>;
  37995. /**
  37996. * Observable that will be called if an error occurs during shader compilation.
  37997. */
  37998. onErrorObservable: Observable<Effect>;
  37999. /** @hidden */
  38000. _onBindObservable: Nullable<Observable<Effect>>;
  38001. /**
  38002. * @hidden
  38003. * Specifies if the effect was previously ready
  38004. */
  38005. _wasPreviouslyReady: boolean;
  38006. /**
  38007. * Observable that will be called when effect is bound.
  38008. */
  38009. get onBindObservable(): Observable<Effect>;
  38010. /** @hidden */
  38011. _bonesComputationForcedToCPU: boolean;
  38012. /** @hidden */
  38013. _multiTarget: boolean;
  38014. private static _uniqueIdSeed;
  38015. private _engine;
  38016. private _uniformBuffersNames;
  38017. private _uniformBuffersNamesList;
  38018. private _uniformsNames;
  38019. private _samplerList;
  38020. private _samplers;
  38021. private _isReady;
  38022. private _compilationError;
  38023. private _allFallbacksProcessed;
  38024. private _attributesNames;
  38025. private _attributes;
  38026. private _attributeLocationByName;
  38027. private _uniforms;
  38028. /**
  38029. * Key for the effect.
  38030. * @hidden
  38031. */
  38032. _key: string;
  38033. private _indexParameters;
  38034. private _fallbacks;
  38035. private _vertexSourceCode;
  38036. private _fragmentSourceCode;
  38037. private _vertexSourceCodeOverride;
  38038. private _fragmentSourceCodeOverride;
  38039. private _transformFeedbackVaryings;
  38040. private _rawVertexSourceCode;
  38041. private _rawFragmentSourceCode;
  38042. /**
  38043. * Compiled shader to webGL program.
  38044. * @hidden
  38045. */
  38046. _pipelineContext: Nullable<IPipelineContext>;
  38047. private _valueCache;
  38048. private static _baseCache;
  38049. /**
  38050. * Instantiates an effect.
  38051. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38052. * @param baseName Name of the effect.
  38053. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38054. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38055. * @param samplers List of sampler variables that will be passed to the shader.
  38056. * @param engine Engine to be used to render the effect
  38057. * @param defines Define statements to be added to the shader.
  38058. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38059. * @param onCompiled Callback that will be called when the shader is compiled.
  38060. * @param onError Callback that will be called if an error occurs during shader compilation.
  38061. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38062. */
  38063. 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);
  38064. private _useFinalCode;
  38065. /**
  38066. * Unique key for this effect
  38067. */
  38068. get key(): string;
  38069. /**
  38070. * If the effect has been compiled and prepared.
  38071. * @returns if the effect is compiled and prepared.
  38072. */
  38073. isReady(): boolean;
  38074. private _isReadyInternal;
  38075. /**
  38076. * The engine the effect was initialized with.
  38077. * @returns the engine.
  38078. */
  38079. getEngine(): Engine;
  38080. /**
  38081. * The pipeline context for this effect
  38082. * @returns the associated pipeline context
  38083. */
  38084. getPipelineContext(): Nullable<IPipelineContext>;
  38085. /**
  38086. * The set of names of attribute variables for the shader.
  38087. * @returns An array of attribute names.
  38088. */
  38089. getAttributesNames(): string[];
  38090. /**
  38091. * Returns the attribute at the given index.
  38092. * @param index The index of the attribute.
  38093. * @returns The location of the attribute.
  38094. */
  38095. getAttributeLocation(index: number): number;
  38096. /**
  38097. * Returns the attribute based on the name of the variable.
  38098. * @param name of the attribute to look up.
  38099. * @returns the attribute location.
  38100. */
  38101. getAttributeLocationByName(name: string): number;
  38102. /**
  38103. * The number of attributes.
  38104. * @returns the numnber of attributes.
  38105. */
  38106. getAttributesCount(): number;
  38107. /**
  38108. * Gets the index of a uniform variable.
  38109. * @param uniformName of the uniform to look up.
  38110. * @returns the index.
  38111. */
  38112. getUniformIndex(uniformName: string): number;
  38113. /**
  38114. * Returns the attribute based on the name of the variable.
  38115. * @param uniformName of the uniform to look up.
  38116. * @returns the location of the uniform.
  38117. */
  38118. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38119. /**
  38120. * Returns an array of sampler variable names
  38121. * @returns The array of sampler variable names.
  38122. */
  38123. getSamplers(): string[];
  38124. /**
  38125. * Returns an array of uniform variable names
  38126. * @returns The array of uniform variable names.
  38127. */
  38128. getUniformNames(): string[];
  38129. /**
  38130. * Returns an array of uniform buffer variable names
  38131. * @returns The array of uniform buffer variable names.
  38132. */
  38133. getUniformBuffersNames(): string[];
  38134. /**
  38135. * Returns the index parameters used to create the effect
  38136. * @returns The index parameters object
  38137. */
  38138. getIndexParameters(): any;
  38139. /**
  38140. * The error from the last compilation.
  38141. * @returns the error string.
  38142. */
  38143. getCompilationError(): string;
  38144. /**
  38145. * Gets a boolean indicating that all fallbacks were used during compilation
  38146. * @returns true if all fallbacks were used
  38147. */
  38148. allFallbacksProcessed(): boolean;
  38149. /**
  38150. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38151. * @param func The callback to be used.
  38152. */
  38153. executeWhenCompiled(func: (effect: Effect) => void): void;
  38154. private _checkIsReady;
  38155. private _loadShader;
  38156. /**
  38157. * Gets the vertex shader source code of this effect
  38158. */
  38159. get vertexSourceCode(): string;
  38160. /**
  38161. * Gets the fragment shader source code of this effect
  38162. */
  38163. get fragmentSourceCode(): string;
  38164. /**
  38165. * Gets the vertex shader source code before it has been processed by the preprocessor
  38166. */
  38167. get rawVertexSourceCode(): string;
  38168. /**
  38169. * Gets the fragment shader source code before it has been processed by the preprocessor
  38170. */
  38171. get rawFragmentSourceCode(): string;
  38172. /**
  38173. * Recompiles the webGL program
  38174. * @param vertexSourceCode The source code for the vertex shader.
  38175. * @param fragmentSourceCode The source code for the fragment shader.
  38176. * @param onCompiled Callback called when completed.
  38177. * @param onError Callback called on error.
  38178. * @hidden
  38179. */
  38180. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  38181. /**
  38182. * Prepares the effect
  38183. * @hidden
  38184. */
  38185. _prepareEffect(): void;
  38186. private _getShaderCodeAndErrorLine;
  38187. private _processCompilationErrors;
  38188. /**
  38189. * Checks if the effect is supported. (Must be called after compilation)
  38190. */
  38191. get isSupported(): boolean;
  38192. /**
  38193. * Binds a texture to the engine to be used as output of the shader.
  38194. * @param channel Name of the output variable.
  38195. * @param texture Texture to bind.
  38196. * @hidden
  38197. */
  38198. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  38199. /**
  38200. * Sets a texture on the engine to be used in the shader.
  38201. * @param channel Name of the sampler variable.
  38202. * @param texture Texture to set.
  38203. */
  38204. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  38205. /**
  38206. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  38207. * @param channel Name of the sampler variable.
  38208. * @param texture Texture to set.
  38209. */
  38210. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  38211. /**
  38212. * Sets an array of textures on the engine to be used in the shader.
  38213. * @param channel Name of the variable.
  38214. * @param textures Textures to set.
  38215. */
  38216. setTextureArray(channel: string, textures: ThinTexture[]): void;
  38217. /**
  38218. * 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)
  38219. * @param channel Name of the sampler variable.
  38220. * @param postProcess Post process to get the input texture from.
  38221. */
  38222. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  38223. /**
  38224. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  38225. * 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)
  38226. * @param channel Name of the sampler variable.
  38227. * @param postProcess Post process to get the output texture from.
  38228. */
  38229. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  38230. /** @hidden */
  38231. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  38232. /** @hidden */
  38233. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  38234. /** @hidden */
  38235. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  38236. /** @hidden */
  38237. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  38238. /**
  38239. * Binds a buffer to a uniform.
  38240. * @param buffer Buffer to bind.
  38241. * @param name Name of the uniform variable to bind to.
  38242. */
  38243. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38244. /**
  38245. * Binds block to a uniform.
  38246. * @param blockName Name of the block to bind.
  38247. * @param index Index to bind.
  38248. */
  38249. bindUniformBlock(blockName: string, index: number): void;
  38250. /**
  38251. * Sets an interger value on a uniform variable.
  38252. * @param uniformName Name of the variable.
  38253. * @param value Value to be set.
  38254. * @returns this effect.
  38255. */
  38256. setInt(uniformName: string, value: number): Effect;
  38257. /**
  38258. * Sets an int array on a uniform variable.
  38259. * @param uniformName Name of the variable.
  38260. * @param array array to be set.
  38261. * @returns this effect.
  38262. */
  38263. setIntArray(uniformName: string, array: Int32Array): Effect;
  38264. /**
  38265. * 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)
  38266. * @param uniformName Name of the variable.
  38267. * @param array array to be set.
  38268. * @returns this effect.
  38269. */
  38270. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38271. /**
  38272. * 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)
  38273. * @param uniformName Name of the variable.
  38274. * @param array array to be set.
  38275. * @returns this effect.
  38276. */
  38277. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38278. /**
  38279. * 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)
  38280. * @param uniformName Name of the variable.
  38281. * @param array array to be set.
  38282. * @returns this effect.
  38283. */
  38284. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38285. /**
  38286. * Sets an float array on a uniform variable.
  38287. * @param uniformName Name of the variable.
  38288. * @param array array to be set.
  38289. * @returns this effect.
  38290. */
  38291. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38292. /**
  38293. * 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)
  38294. * @param uniformName Name of the variable.
  38295. * @param array array to be set.
  38296. * @returns this effect.
  38297. */
  38298. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38299. /**
  38300. * 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)
  38301. * @param uniformName Name of the variable.
  38302. * @param array array to be set.
  38303. * @returns this effect.
  38304. */
  38305. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38306. /**
  38307. * 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)
  38308. * @param uniformName Name of the variable.
  38309. * @param array array to be set.
  38310. * @returns this effect.
  38311. */
  38312. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38313. /**
  38314. * Sets an array on a uniform variable.
  38315. * @param uniformName Name of the variable.
  38316. * @param array array to be set.
  38317. * @returns this effect.
  38318. */
  38319. setArray(uniformName: string, array: number[]): Effect;
  38320. /**
  38321. * 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)
  38322. * @param uniformName Name of the variable.
  38323. * @param array array to be set.
  38324. * @returns this effect.
  38325. */
  38326. setArray2(uniformName: string, array: number[]): Effect;
  38327. /**
  38328. * 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)
  38329. * @param uniformName Name of the variable.
  38330. * @param array array to be set.
  38331. * @returns this effect.
  38332. */
  38333. setArray3(uniformName: string, array: number[]): Effect;
  38334. /**
  38335. * 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)
  38336. * @param uniformName Name of the variable.
  38337. * @param array array to be set.
  38338. * @returns this effect.
  38339. */
  38340. setArray4(uniformName: string, array: number[]): Effect;
  38341. /**
  38342. * Sets matrices on a uniform variable.
  38343. * @param uniformName Name of the variable.
  38344. * @param matrices matrices to be set.
  38345. * @returns this effect.
  38346. */
  38347. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38348. /**
  38349. * Sets matrix on a uniform variable.
  38350. * @param uniformName Name of the variable.
  38351. * @param matrix matrix to be set.
  38352. * @returns this effect.
  38353. */
  38354. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38355. /**
  38356. * 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)
  38357. * @param uniformName Name of the variable.
  38358. * @param matrix matrix to be set.
  38359. * @returns this effect.
  38360. */
  38361. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38362. /**
  38363. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38364. * @param uniformName Name of the variable.
  38365. * @param matrix matrix to be set.
  38366. * @returns this effect.
  38367. */
  38368. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38369. /**
  38370. * Sets a float on a uniform variable.
  38371. * @param uniformName Name of the variable.
  38372. * @param value value to be set.
  38373. * @returns this effect.
  38374. */
  38375. setFloat(uniformName: string, value: number): Effect;
  38376. /**
  38377. * Sets a boolean on a uniform variable.
  38378. * @param uniformName Name of the variable.
  38379. * @param bool value to be set.
  38380. * @returns this effect.
  38381. */
  38382. setBool(uniformName: string, bool: boolean): Effect;
  38383. /**
  38384. * Sets a Vector2 on a uniform variable.
  38385. * @param uniformName Name of the variable.
  38386. * @param vector2 vector2 to be set.
  38387. * @returns this effect.
  38388. */
  38389. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38390. /**
  38391. * Sets a float2 on a uniform variable.
  38392. * @param uniformName Name of the variable.
  38393. * @param x First float in float2.
  38394. * @param y Second float in float2.
  38395. * @returns this effect.
  38396. */
  38397. setFloat2(uniformName: string, x: number, y: number): Effect;
  38398. /**
  38399. * Sets a Vector3 on a uniform variable.
  38400. * @param uniformName Name of the variable.
  38401. * @param vector3 Value to be set.
  38402. * @returns this effect.
  38403. */
  38404. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38405. /**
  38406. * Sets a float3 on a uniform variable.
  38407. * @param uniformName Name of the variable.
  38408. * @param x First float in float3.
  38409. * @param y Second float in float3.
  38410. * @param z Third float in float3.
  38411. * @returns this effect.
  38412. */
  38413. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38414. /**
  38415. * Sets a Vector4 on a uniform variable.
  38416. * @param uniformName Name of the variable.
  38417. * @param vector4 Value to be set.
  38418. * @returns this effect.
  38419. */
  38420. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38421. /**
  38422. * Sets a float4 on a uniform variable.
  38423. * @param uniformName Name of the variable.
  38424. * @param x First float in float4.
  38425. * @param y Second float in float4.
  38426. * @param z Third float in float4.
  38427. * @param w Fourth float in float4.
  38428. * @returns this effect.
  38429. */
  38430. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38431. /**
  38432. * Sets a Color3 on a uniform variable.
  38433. * @param uniformName Name of the variable.
  38434. * @param color3 Value to be set.
  38435. * @returns this effect.
  38436. */
  38437. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38438. /**
  38439. * Sets a Color4 on a uniform variable.
  38440. * @param uniformName Name of the variable.
  38441. * @param color3 Value to be set.
  38442. * @param alpha Alpha value to be set.
  38443. * @returns this effect.
  38444. */
  38445. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38446. /**
  38447. * Sets a Color4 on a uniform variable
  38448. * @param uniformName defines the name of the variable
  38449. * @param color4 defines the value to be set
  38450. * @returns this effect.
  38451. */
  38452. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38453. /** Release all associated resources */
  38454. dispose(): void;
  38455. /**
  38456. * This function will add a new shader to the shader store
  38457. * @param name the name of the shader
  38458. * @param pixelShader optional pixel shader content
  38459. * @param vertexShader optional vertex shader content
  38460. */
  38461. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38462. /**
  38463. * Store of each shader (The can be looked up using effect.key)
  38464. */
  38465. static ShadersStore: {
  38466. [key: string]: string;
  38467. };
  38468. /**
  38469. * Store of each included file for a shader (The can be looked up using effect.key)
  38470. */
  38471. static IncludesShadersStore: {
  38472. [key: string]: string;
  38473. };
  38474. /**
  38475. * Resets the cache of effects.
  38476. */
  38477. static ResetCache(): void;
  38478. }
  38479. }
  38480. declare module BABYLON {
  38481. /**
  38482. * Interface used to describe the capabilities of the engine relatively to the current browser
  38483. */
  38484. export interface EngineCapabilities {
  38485. /** Maximum textures units per fragment shader */
  38486. maxTexturesImageUnits: number;
  38487. /** Maximum texture units per vertex shader */
  38488. maxVertexTextureImageUnits: number;
  38489. /** Maximum textures units in the entire pipeline */
  38490. maxCombinedTexturesImageUnits: number;
  38491. /** Maximum texture size */
  38492. maxTextureSize: number;
  38493. /** Maximum texture samples */
  38494. maxSamples?: number;
  38495. /** Maximum cube texture size */
  38496. maxCubemapTextureSize: number;
  38497. /** Maximum render texture size */
  38498. maxRenderTextureSize: number;
  38499. /** Maximum number of vertex attributes */
  38500. maxVertexAttribs: number;
  38501. /** Maximum number of varyings */
  38502. maxVaryingVectors: number;
  38503. /** Maximum number of uniforms per vertex shader */
  38504. maxVertexUniformVectors: number;
  38505. /** Maximum number of uniforms per fragment shader */
  38506. maxFragmentUniformVectors: number;
  38507. /** Defines if standard derivates (dx/dy) are supported */
  38508. standardDerivatives: boolean;
  38509. /** Defines if s3tc texture compression is supported */
  38510. s3tc?: WEBGL_compressed_texture_s3tc;
  38511. /** Defines if pvrtc texture compression is supported */
  38512. pvrtc: any;
  38513. /** Defines if etc1 texture compression is supported */
  38514. etc1: any;
  38515. /** Defines if etc2 texture compression is supported */
  38516. etc2: any;
  38517. /** Defines if astc texture compression is supported */
  38518. astc: any;
  38519. /** Defines if bptc texture compression is supported */
  38520. bptc: any;
  38521. /** Defines if float textures are supported */
  38522. textureFloat: boolean;
  38523. /** Defines if vertex array objects are supported */
  38524. vertexArrayObject: boolean;
  38525. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38526. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38527. /** Gets the maximum level of anisotropy supported */
  38528. maxAnisotropy: number;
  38529. /** Defines if instancing is supported */
  38530. instancedArrays: boolean;
  38531. /** Defines if 32 bits indices are supported */
  38532. uintIndices: boolean;
  38533. /** Defines if high precision shaders are supported */
  38534. highPrecisionShaderSupported: boolean;
  38535. /** Defines if depth reading in the fragment shader is supported */
  38536. fragmentDepthSupported: boolean;
  38537. /** Defines if float texture linear filtering is supported*/
  38538. textureFloatLinearFiltering: boolean;
  38539. /** Defines if rendering to float textures is supported */
  38540. textureFloatRender: boolean;
  38541. /** Defines if half float textures are supported*/
  38542. textureHalfFloat: boolean;
  38543. /** Defines if half float texture linear filtering is supported*/
  38544. textureHalfFloatLinearFiltering: boolean;
  38545. /** Defines if rendering to half float textures is supported */
  38546. textureHalfFloatRender: boolean;
  38547. /** Defines if textureLOD shader command is supported */
  38548. textureLOD: boolean;
  38549. /** Defines if draw buffers extension is supported */
  38550. drawBuffersExtension: boolean;
  38551. /** Defines if depth textures are supported */
  38552. depthTextureExtension: boolean;
  38553. /** Defines if float color buffer are supported */
  38554. colorBufferFloat: boolean;
  38555. /** Gets disjoint timer query extension (null if not supported) */
  38556. timerQuery?: EXT_disjoint_timer_query;
  38557. /** Defines if timestamp can be used with timer query */
  38558. canUseTimestampForTimerQuery: boolean;
  38559. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38560. multiview?: any;
  38561. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38562. oculusMultiview?: any;
  38563. /** Function used to let the system compiles shaders in background */
  38564. parallelShaderCompile?: {
  38565. COMPLETION_STATUS_KHR: number;
  38566. };
  38567. /** Max number of texture samples for MSAA */
  38568. maxMSAASamples: number;
  38569. /** Defines if the blend min max extension is supported */
  38570. blendMinMax: boolean;
  38571. }
  38572. }
  38573. declare module BABYLON {
  38574. /**
  38575. * @hidden
  38576. **/
  38577. export class DepthCullingState {
  38578. private _isDepthTestDirty;
  38579. private _isDepthMaskDirty;
  38580. private _isDepthFuncDirty;
  38581. private _isCullFaceDirty;
  38582. private _isCullDirty;
  38583. private _isZOffsetDirty;
  38584. private _isFrontFaceDirty;
  38585. private _depthTest;
  38586. private _depthMask;
  38587. private _depthFunc;
  38588. private _cull;
  38589. private _cullFace;
  38590. private _zOffset;
  38591. private _frontFace;
  38592. /**
  38593. * Initializes the state.
  38594. */
  38595. constructor();
  38596. get isDirty(): boolean;
  38597. get zOffset(): number;
  38598. set zOffset(value: number);
  38599. get cullFace(): Nullable<number>;
  38600. set cullFace(value: Nullable<number>);
  38601. get cull(): Nullable<boolean>;
  38602. set cull(value: Nullable<boolean>);
  38603. get depthFunc(): Nullable<number>;
  38604. set depthFunc(value: Nullable<number>);
  38605. get depthMask(): boolean;
  38606. set depthMask(value: boolean);
  38607. get depthTest(): boolean;
  38608. set depthTest(value: boolean);
  38609. get frontFace(): Nullable<number>;
  38610. set frontFace(value: Nullable<number>);
  38611. reset(): void;
  38612. apply(gl: WebGLRenderingContext): void;
  38613. }
  38614. }
  38615. declare module BABYLON {
  38616. /**
  38617. * @hidden
  38618. **/
  38619. export class StencilState {
  38620. /** 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 */
  38621. static readonly ALWAYS: number;
  38622. /** Passed to stencilOperation to specify that stencil value must be kept */
  38623. static readonly KEEP: number;
  38624. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38625. static readonly REPLACE: number;
  38626. private _isStencilTestDirty;
  38627. private _isStencilMaskDirty;
  38628. private _isStencilFuncDirty;
  38629. private _isStencilOpDirty;
  38630. private _stencilTest;
  38631. private _stencilMask;
  38632. private _stencilFunc;
  38633. private _stencilFuncRef;
  38634. private _stencilFuncMask;
  38635. private _stencilOpStencilFail;
  38636. private _stencilOpDepthFail;
  38637. private _stencilOpStencilDepthPass;
  38638. get isDirty(): boolean;
  38639. get stencilFunc(): number;
  38640. set stencilFunc(value: number);
  38641. get stencilFuncRef(): number;
  38642. set stencilFuncRef(value: number);
  38643. get stencilFuncMask(): number;
  38644. set stencilFuncMask(value: number);
  38645. get stencilOpStencilFail(): number;
  38646. set stencilOpStencilFail(value: number);
  38647. get stencilOpDepthFail(): number;
  38648. set stencilOpDepthFail(value: number);
  38649. get stencilOpStencilDepthPass(): number;
  38650. set stencilOpStencilDepthPass(value: number);
  38651. get stencilMask(): number;
  38652. set stencilMask(value: number);
  38653. get stencilTest(): boolean;
  38654. set stencilTest(value: boolean);
  38655. constructor();
  38656. reset(): void;
  38657. apply(gl: WebGLRenderingContext): void;
  38658. }
  38659. }
  38660. declare module BABYLON {
  38661. /**
  38662. * @hidden
  38663. **/
  38664. export class AlphaState {
  38665. private _isAlphaBlendDirty;
  38666. private _isBlendFunctionParametersDirty;
  38667. private _isBlendEquationParametersDirty;
  38668. private _isBlendConstantsDirty;
  38669. private _alphaBlend;
  38670. private _blendFunctionParameters;
  38671. private _blendEquationParameters;
  38672. private _blendConstants;
  38673. /**
  38674. * Initializes the state.
  38675. */
  38676. constructor();
  38677. get isDirty(): boolean;
  38678. get alphaBlend(): boolean;
  38679. set alphaBlend(value: boolean);
  38680. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38681. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38682. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38683. reset(): void;
  38684. apply(gl: WebGLRenderingContext): void;
  38685. }
  38686. }
  38687. declare module BABYLON {
  38688. /** @hidden */
  38689. export class WebGLShaderProcessor implements IShaderProcessor {
  38690. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38691. }
  38692. }
  38693. declare module BABYLON {
  38694. /** @hidden */
  38695. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38696. attributeProcessor(attribute: string): string;
  38697. varyingProcessor(varying: string, isFragment: boolean): string;
  38698. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38699. }
  38700. }
  38701. declare module BABYLON {
  38702. /**
  38703. * Interface for attribute information associated with buffer instanciation
  38704. */
  38705. export interface InstancingAttributeInfo {
  38706. /**
  38707. * Name of the GLSL attribute
  38708. * if attribute index is not specified, this is used to retrieve the index from the effect
  38709. */
  38710. attributeName: string;
  38711. /**
  38712. * Index/offset of the attribute in the vertex shader
  38713. * if not specified, this will be computes from the name.
  38714. */
  38715. index?: number;
  38716. /**
  38717. * size of the attribute, 1, 2, 3 or 4
  38718. */
  38719. attributeSize: number;
  38720. /**
  38721. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38722. */
  38723. offset: number;
  38724. /**
  38725. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38726. * default to 1
  38727. */
  38728. divisor?: number;
  38729. /**
  38730. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38731. * default is FLOAT
  38732. */
  38733. attributeType?: number;
  38734. /**
  38735. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38736. */
  38737. normalized?: boolean;
  38738. }
  38739. }
  38740. declare module BABYLON {
  38741. interface ThinEngine {
  38742. /**
  38743. * Update a video texture
  38744. * @param texture defines the texture to update
  38745. * @param video defines the video element to use
  38746. * @param invertY defines if data must be stored with Y axis inverted
  38747. */
  38748. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38749. }
  38750. }
  38751. declare module BABYLON {
  38752. interface ThinEngine {
  38753. /**
  38754. * Creates a dynamic texture
  38755. * @param width defines the width of the texture
  38756. * @param height defines the height of the texture
  38757. * @param generateMipMaps defines if the engine should generate the mip levels
  38758. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38759. * @returns the dynamic texture inside an InternalTexture
  38760. */
  38761. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38762. /**
  38763. * Update the content of a dynamic texture
  38764. * @param texture defines the texture to update
  38765. * @param canvas defines the canvas containing the source
  38766. * @param invertY defines if data must be stored with Y axis inverted
  38767. * @param premulAlpha defines if alpha is stored as premultiplied
  38768. * @param format defines the format of the data
  38769. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38770. */
  38771. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38772. }
  38773. }
  38774. declare module BABYLON {
  38775. /**
  38776. * Settings for finer control over video usage
  38777. */
  38778. export interface VideoTextureSettings {
  38779. /**
  38780. * Applies `autoplay` to video, if specified
  38781. */
  38782. autoPlay?: boolean;
  38783. /**
  38784. * Applies `muted` to video, if specified
  38785. */
  38786. muted?: boolean;
  38787. /**
  38788. * Applies `loop` to video, if specified
  38789. */
  38790. loop?: boolean;
  38791. /**
  38792. * Automatically updates internal texture from video at every frame in the render loop
  38793. */
  38794. autoUpdateTexture: boolean;
  38795. /**
  38796. * Image src displayed during the video loading or until the user interacts with the video.
  38797. */
  38798. poster?: string;
  38799. }
  38800. /**
  38801. * If you want to display a video in your scene, this is the special texture for that.
  38802. * This special texture works similar to other textures, with the exception of a few parameters.
  38803. * @see https://doc.babylonjs.com/how_to/video_texture
  38804. */
  38805. export class VideoTexture extends Texture {
  38806. /**
  38807. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38808. */
  38809. readonly autoUpdateTexture: boolean;
  38810. /**
  38811. * The video instance used by the texture internally
  38812. */
  38813. readonly video: HTMLVideoElement;
  38814. private _onUserActionRequestedObservable;
  38815. /**
  38816. * Event triggerd when a dom action is required by the user to play the video.
  38817. * This happens due to recent changes in browser policies preventing video to auto start.
  38818. */
  38819. get onUserActionRequestedObservable(): Observable<Texture>;
  38820. private _generateMipMaps;
  38821. private _stillImageCaptured;
  38822. private _displayingPosterTexture;
  38823. private _settings;
  38824. private _createInternalTextureOnEvent;
  38825. private _frameId;
  38826. private _currentSrc;
  38827. /**
  38828. * Creates a video texture.
  38829. * If you want to display a video in your scene, this is the special texture for that.
  38830. * This special texture works similar to other textures, with the exception of a few parameters.
  38831. * @see https://doc.babylonjs.com/how_to/video_texture
  38832. * @param name optional name, will detect from video source, if not defined
  38833. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38834. * @param scene is obviously the current scene.
  38835. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38836. * @param invertY is false by default but can be used to invert video on Y axis
  38837. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38838. * @param settings allows finer control over video usage
  38839. */
  38840. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38841. private _getName;
  38842. private _getVideo;
  38843. private _createInternalTexture;
  38844. private reset;
  38845. /**
  38846. * @hidden Internal method to initiate `update`.
  38847. */
  38848. _rebuild(): void;
  38849. /**
  38850. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38851. */
  38852. update(): void;
  38853. /**
  38854. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38855. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38856. */
  38857. updateTexture(isVisible: boolean): void;
  38858. protected _updateInternalTexture: () => void;
  38859. /**
  38860. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38861. * @param url New url.
  38862. */
  38863. updateURL(url: string): void;
  38864. /**
  38865. * Clones the texture.
  38866. * @returns the cloned texture
  38867. */
  38868. clone(): VideoTexture;
  38869. /**
  38870. * Dispose the texture and release its associated resources.
  38871. */
  38872. dispose(): void;
  38873. /**
  38874. * Creates a video texture straight from a stream.
  38875. * @param scene Define the scene the texture should be created in
  38876. * @param stream Define the stream the texture should be created from
  38877. * @returns The created video texture as a promise
  38878. */
  38879. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38880. /**
  38881. * Creates a video texture straight from your WebCam video feed.
  38882. * @param scene Define the scene the texture should be created in
  38883. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38884. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38885. * @returns The created video texture as a promise
  38886. */
  38887. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38888. minWidth: number;
  38889. maxWidth: number;
  38890. minHeight: number;
  38891. maxHeight: number;
  38892. deviceId: string;
  38893. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38894. /**
  38895. * Creates a video texture straight from your WebCam video feed.
  38896. * @param scene Define the scene the texture should be created in
  38897. * @param onReady Define a callback to triggered once the texture will be ready
  38898. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38899. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38900. */
  38901. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38902. minWidth: number;
  38903. maxWidth: number;
  38904. minHeight: number;
  38905. maxHeight: number;
  38906. deviceId: string;
  38907. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38908. }
  38909. }
  38910. declare module BABYLON {
  38911. /**
  38912. * Defines the interface used by objects working like Scene
  38913. * @hidden
  38914. */
  38915. export interface ISceneLike {
  38916. _addPendingData(data: any): void;
  38917. _removePendingData(data: any): void;
  38918. offlineProvider: IOfflineProvider;
  38919. }
  38920. /**
  38921. * Information about the current host
  38922. */
  38923. export interface HostInformation {
  38924. /**
  38925. * Defines if the current host is a mobile
  38926. */
  38927. isMobile: boolean;
  38928. }
  38929. /** Interface defining initialization parameters for Engine class */
  38930. export interface EngineOptions extends WebGLContextAttributes {
  38931. /**
  38932. * Defines if the engine should no exceed a specified device ratio
  38933. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38934. */
  38935. limitDeviceRatio?: number;
  38936. /**
  38937. * Defines if webvr should be enabled automatically
  38938. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38939. */
  38940. autoEnableWebVR?: boolean;
  38941. /**
  38942. * Defines if webgl2 should be turned off even if supported
  38943. * @see https://doc.babylonjs.com/features/webgl2
  38944. */
  38945. disableWebGL2Support?: boolean;
  38946. /**
  38947. * Defines if webaudio should be initialized as well
  38948. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38949. */
  38950. audioEngine?: boolean;
  38951. /**
  38952. * Defines if animations should run using a deterministic lock step
  38953. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38954. */
  38955. deterministicLockstep?: boolean;
  38956. /** Defines the maximum steps to use with deterministic lock step mode */
  38957. lockstepMaxSteps?: number;
  38958. /** Defines the seconds between each deterministic lock step */
  38959. timeStep?: number;
  38960. /**
  38961. * Defines that engine should ignore context lost events
  38962. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38963. */
  38964. doNotHandleContextLost?: boolean;
  38965. /**
  38966. * Defines that engine should ignore modifying touch action attribute and style
  38967. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38968. */
  38969. doNotHandleTouchAction?: boolean;
  38970. /**
  38971. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38972. */
  38973. useHighPrecisionFloats?: boolean;
  38974. /**
  38975. * Make the canvas XR Compatible for XR sessions
  38976. */
  38977. xrCompatible?: boolean;
  38978. /**
  38979. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38980. */
  38981. useHighPrecisionMatrix?: boolean;
  38982. /**
  38983. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38984. */
  38985. failIfMajorPerformanceCaveat?: boolean;
  38986. }
  38987. /**
  38988. * The base engine class (root of all engines)
  38989. */
  38990. export class ThinEngine {
  38991. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38992. static ExceptionList: ({
  38993. key: string;
  38994. capture: string;
  38995. captureConstraint: number;
  38996. targets: string[];
  38997. } | {
  38998. key: string;
  38999. capture: null;
  39000. captureConstraint: null;
  39001. targets: string[];
  39002. })[];
  39003. /** @hidden */
  39004. static _TextureLoaders: IInternalTextureLoader[];
  39005. /**
  39006. * Returns the current npm package of the sdk
  39007. */
  39008. static get NpmPackage(): string;
  39009. /**
  39010. * Returns the current version of the framework
  39011. */
  39012. static get Version(): string;
  39013. /**
  39014. * Returns a string describing the current engine
  39015. */
  39016. get description(): string;
  39017. /**
  39018. * Gets or sets the epsilon value used by collision engine
  39019. */
  39020. static CollisionsEpsilon: number;
  39021. /**
  39022. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39023. */
  39024. static get ShadersRepository(): string;
  39025. static set ShadersRepository(value: string);
  39026. /** @hidden */
  39027. _shaderProcessor: IShaderProcessor;
  39028. /**
  39029. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39030. */
  39031. forcePOTTextures: boolean;
  39032. /**
  39033. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39034. */
  39035. isFullscreen: boolean;
  39036. /**
  39037. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39038. */
  39039. cullBackFaces: boolean;
  39040. /**
  39041. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39042. */
  39043. renderEvenInBackground: boolean;
  39044. /**
  39045. * Gets or sets a boolean indicating that cache can be kept between frames
  39046. */
  39047. preventCacheWipeBetweenFrames: boolean;
  39048. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39049. validateShaderPrograms: boolean;
  39050. /**
  39051. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39052. * This can provide greater z depth for distant objects.
  39053. */
  39054. useReverseDepthBuffer: boolean;
  39055. /**
  39056. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39057. */
  39058. disableUniformBuffers: boolean;
  39059. /** @hidden */
  39060. _uniformBuffers: UniformBuffer[];
  39061. /**
  39062. * Gets a boolean indicating that the engine supports uniform buffers
  39063. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39064. */
  39065. get supportsUniformBuffers(): boolean;
  39066. /** @hidden */
  39067. _gl: WebGLRenderingContext;
  39068. /** @hidden */
  39069. _webGLVersion: number;
  39070. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39071. protected _windowIsBackground: boolean;
  39072. protected _creationOptions: EngineOptions;
  39073. protected _highPrecisionShadersAllowed: boolean;
  39074. /** @hidden */
  39075. get _shouldUseHighPrecisionShader(): boolean;
  39076. /**
  39077. * Gets a boolean indicating that only power of 2 textures are supported
  39078. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39079. */
  39080. get needPOTTextures(): boolean;
  39081. /** @hidden */
  39082. _badOS: boolean;
  39083. /** @hidden */
  39084. _badDesktopOS: boolean;
  39085. private _hardwareScalingLevel;
  39086. /** @hidden */
  39087. _caps: EngineCapabilities;
  39088. private _isStencilEnable;
  39089. private _glVersion;
  39090. private _glRenderer;
  39091. private _glVendor;
  39092. /** @hidden */
  39093. _videoTextureSupported: boolean;
  39094. protected _renderingQueueLaunched: boolean;
  39095. protected _activeRenderLoops: (() => void)[];
  39096. /**
  39097. * Observable signaled when a context lost event is raised
  39098. */
  39099. onContextLostObservable: Observable<ThinEngine>;
  39100. /**
  39101. * Observable signaled when a context restored event is raised
  39102. */
  39103. onContextRestoredObservable: Observable<ThinEngine>;
  39104. private _onContextLost;
  39105. private _onContextRestored;
  39106. protected _contextWasLost: boolean;
  39107. /** @hidden */
  39108. _doNotHandleContextLost: boolean;
  39109. /**
  39110. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  39111. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  39112. */
  39113. get doNotHandleContextLost(): boolean;
  39114. set doNotHandleContextLost(value: boolean);
  39115. /**
  39116. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  39117. */
  39118. disableVertexArrayObjects: boolean;
  39119. /** @hidden */
  39120. protected _colorWrite: boolean;
  39121. /** @hidden */
  39122. protected _colorWriteChanged: boolean;
  39123. /** @hidden */
  39124. protected _depthCullingState: DepthCullingState;
  39125. /** @hidden */
  39126. protected _stencilState: StencilState;
  39127. /** @hidden */
  39128. _alphaState: AlphaState;
  39129. /** @hidden */
  39130. _alphaMode: number;
  39131. /** @hidden */
  39132. _alphaEquation: number;
  39133. /** @hidden */
  39134. _internalTexturesCache: InternalTexture[];
  39135. /** @hidden */
  39136. protected _activeChannel: number;
  39137. private _currentTextureChannel;
  39138. /** @hidden */
  39139. protected _boundTexturesCache: {
  39140. [key: string]: Nullable<InternalTexture>;
  39141. };
  39142. /** @hidden */
  39143. protected _currentEffect: Nullable<Effect>;
  39144. /** @hidden */
  39145. protected _currentProgram: Nullable<WebGLProgram>;
  39146. private _compiledEffects;
  39147. private _vertexAttribArraysEnabled;
  39148. /** @hidden */
  39149. protected _cachedViewport: Nullable<IViewportLike>;
  39150. private _cachedVertexArrayObject;
  39151. /** @hidden */
  39152. protected _cachedVertexBuffers: any;
  39153. /** @hidden */
  39154. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  39155. /** @hidden */
  39156. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  39157. /** @hidden */
  39158. _currentRenderTarget: Nullable<InternalTexture>;
  39159. private _uintIndicesCurrentlySet;
  39160. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  39161. /** @hidden */
  39162. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  39163. /** @hidden */
  39164. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  39165. private _currentBufferPointers;
  39166. private _currentInstanceLocations;
  39167. private _currentInstanceBuffers;
  39168. private _textureUnits;
  39169. /** @hidden */
  39170. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39171. /** @hidden */
  39172. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39173. /** @hidden */
  39174. _boundRenderFunction: any;
  39175. private _vaoRecordInProgress;
  39176. private _mustWipeVertexAttributes;
  39177. private _emptyTexture;
  39178. private _emptyCubeTexture;
  39179. private _emptyTexture3D;
  39180. private _emptyTexture2DArray;
  39181. /** @hidden */
  39182. _frameHandler: number;
  39183. private _nextFreeTextureSlots;
  39184. private _maxSimultaneousTextures;
  39185. private _activeRequests;
  39186. /** @hidden */
  39187. _transformTextureUrl: Nullable<(url: string) => string>;
  39188. /**
  39189. * Gets information about the current host
  39190. */
  39191. hostInformation: HostInformation;
  39192. protected get _supportsHardwareTextureRescaling(): boolean;
  39193. private _framebufferDimensionsObject;
  39194. /**
  39195. * sets the object from which width and height will be taken from when getting render width and height
  39196. * Will fallback to the gl object
  39197. * @param dimensions the framebuffer width and height that will be used.
  39198. */
  39199. set framebufferDimensionsObject(dimensions: Nullable<{
  39200. framebufferWidth: number;
  39201. framebufferHeight: number;
  39202. }>);
  39203. /**
  39204. * Gets the current viewport
  39205. */
  39206. get currentViewport(): Nullable<IViewportLike>;
  39207. /**
  39208. * Gets the default empty texture
  39209. */
  39210. get emptyTexture(): InternalTexture;
  39211. /**
  39212. * Gets the default empty 3D texture
  39213. */
  39214. get emptyTexture3D(): InternalTexture;
  39215. /**
  39216. * Gets the default empty 2D array texture
  39217. */
  39218. get emptyTexture2DArray(): InternalTexture;
  39219. /**
  39220. * Gets the default empty cube texture
  39221. */
  39222. get emptyCubeTexture(): InternalTexture;
  39223. /**
  39224. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  39225. */
  39226. readonly premultipliedAlpha: boolean;
  39227. /**
  39228. * Observable event triggered before each texture is initialized
  39229. */
  39230. onBeforeTextureInitObservable: Observable<Texture>;
  39231. /**
  39232. * Creates a new engine
  39233. * @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
  39234. * @param antialias defines enable antialiasing (default: false)
  39235. * @param options defines further options to be sent to the getContext() function
  39236. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39237. */
  39238. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39239. private _rebuildInternalTextures;
  39240. private _rebuildEffects;
  39241. /**
  39242. * Gets a boolean indicating if all created effects are ready
  39243. * @returns true if all effects are ready
  39244. */
  39245. areAllEffectsReady(): boolean;
  39246. protected _rebuildBuffers(): void;
  39247. protected _initGLContext(): void;
  39248. /**
  39249. * Gets version of the current webGL context
  39250. */
  39251. get webGLVersion(): number;
  39252. /**
  39253. * Gets a string identifying the name of the class
  39254. * @returns "Engine" string
  39255. */
  39256. getClassName(): string;
  39257. /**
  39258. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39259. */
  39260. get isStencilEnable(): boolean;
  39261. /** @hidden */
  39262. _prepareWorkingCanvas(): void;
  39263. /**
  39264. * Reset the texture cache to empty state
  39265. */
  39266. resetTextureCache(): void;
  39267. /**
  39268. * Gets an object containing information about the current webGL context
  39269. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39270. */
  39271. getGlInfo(): {
  39272. vendor: string;
  39273. renderer: string;
  39274. version: string;
  39275. };
  39276. /**
  39277. * Defines the hardware scaling level.
  39278. * By default the hardware scaling level is computed from the window device ratio.
  39279. * 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.
  39280. * @param level defines the level to use
  39281. */
  39282. setHardwareScalingLevel(level: number): void;
  39283. /**
  39284. * Gets the current hardware scaling level.
  39285. * By default the hardware scaling level is computed from the window device ratio.
  39286. * 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.
  39287. * @returns a number indicating the current hardware scaling level
  39288. */
  39289. getHardwareScalingLevel(): number;
  39290. /**
  39291. * Gets the list of loaded textures
  39292. * @returns an array containing all loaded textures
  39293. */
  39294. getLoadedTexturesCache(): InternalTexture[];
  39295. /**
  39296. * Gets the object containing all engine capabilities
  39297. * @returns the EngineCapabilities object
  39298. */
  39299. getCaps(): EngineCapabilities;
  39300. /**
  39301. * stop executing a render loop function and remove it from the execution array
  39302. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39303. */
  39304. stopRenderLoop(renderFunction?: () => void): void;
  39305. /** @hidden */
  39306. _renderLoop(): void;
  39307. /**
  39308. * Gets the HTML canvas attached with the current webGL context
  39309. * @returns a HTML canvas
  39310. */
  39311. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39312. /**
  39313. * Gets host window
  39314. * @returns the host window object
  39315. */
  39316. getHostWindow(): Nullable<Window>;
  39317. /**
  39318. * Gets the current render width
  39319. * @param useScreen defines if screen size must be used (or the current render target if any)
  39320. * @returns a number defining the current render width
  39321. */
  39322. getRenderWidth(useScreen?: boolean): number;
  39323. /**
  39324. * Gets the current render height
  39325. * @param useScreen defines if screen size must be used (or the current render target if any)
  39326. * @returns a number defining the current render height
  39327. */
  39328. getRenderHeight(useScreen?: boolean): number;
  39329. /**
  39330. * Can be used to override the current requestAnimationFrame requester.
  39331. * @hidden
  39332. */
  39333. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39334. /**
  39335. * Register and execute a render loop. The engine can have more than one render function
  39336. * @param renderFunction defines the function to continuously execute
  39337. */
  39338. runRenderLoop(renderFunction: () => void): void;
  39339. /**
  39340. * Clear the current render buffer or the current render target (if any is set up)
  39341. * @param color defines the color to use
  39342. * @param backBuffer defines if the back buffer must be cleared
  39343. * @param depth defines if the depth buffer must be cleared
  39344. * @param stencil defines if the stencil buffer must be cleared
  39345. */
  39346. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39347. private _viewportCached;
  39348. /** @hidden */
  39349. _viewport(x: number, y: number, width: number, height: number): void;
  39350. /**
  39351. * Set the WebGL's viewport
  39352. * @param viewport defines the viewport element to be used
  39353. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39354. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39355. */
  39356. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39357. /**
  39358. * Begin a new frame
  39359. */
  39360. beginFrame(): void;
  39361. /**
  39362. * Enf the current frame
  39363. */
  39364. endFrame(): void;
  39365. /**
  39366. * Resize the view according to the canvas' size
  39367. */
  39368. resize(): void;
  39369. /**
  39370. * Force a specific size of the canvas
  39371. * @param width defines the new canvas' width
  39372. * @param height defines the new canvas' height
  39373. * @returns true if the size was changed
  39374. */
  39375. setSize(width: number, height: number): boolean;
  39376. /**
  39377. * Binds the frame buffer to the specified texture.
  39378. * @param texture The texture to render to or null for the default canvas
  39379. * @param faceIndex The face of the texture to render to in case of cube texture
  39380. * @param requiredWidth The width of the target to render to
  39381. * @param requiredHeight The height of the target to render to
  39382. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39383. * @param lodLevel defines the lod level to bind to the frame buffer
  39384. * @param layer defines the 2d array index to bind to frame buffer to
  39385. */
  39386. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39387. /** @hidden */
  39388. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39389. /**
  39390. * Unbind the current render target texture from the webGL context
  39391. * @param texture defines the render target texture to unbind
  39392. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39393. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39394. */
  39395. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39396. /**
  39397. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39398. */
  39399. flushFramebuffer(): void;
  39400. /**
  39401. * Unbind the current render target and bind the default framebuffer
  39402. */
  39403. restoreDefaultFramebuffer(): void;
  39404. /** @hidden */
  39405. protected _resetVertexBufferBinding(): void;
  39406. /**
  39407. * Creates a vertex buffer
  39408. * @param data the data for the vertex buffer
  39409. * @returns the new WebGL static buffer
  39410. */
  39411. createVertexBuffer(data: DataArray): DataBuffer;
  39412. private _createVertexBuffer;
  39413. /**
  39414. * Creates a dynamic vertex buffer
  39415. * @param data the data for the dynamic vertex buffer
  39416. * @returns the new WebGL dynamic buffer
  39417. */
  39418. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39419. protected _resetIndexBufferBinding(): void;
  39420. /**
  39421. * Creates a new index buffer
  39422. * @param indices defines the content of the index buffer
  39423. * @param updatable defines if the index buffer must be updatable
  39424. * @returns a new webGL buffer
  39425. */
  39426. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39427. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39428. /**
  39429. * Bind a webGL buffer to the webGL context
  39430. * @param buffer defines the buffer to bind
  39431. */
  39432. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39433. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39434. private bindBuffer;
  39435. /**
  39436. * update the bound buffer with the given data
  39437. * @param data defines the data to update
  39438. */
  39439. updateArrayBuffer(data: Float32Array): void;
  39440. private _vertexAttribPointer;
  39441. /** @hidden */
  39442. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39443. private _bindVertexBuffersAttributes;
  39444. /**
  39445. * Records a vertex array object
  39446. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39447. * @param vertexBuffers defines the list of vertex buffers to store
  39448. * @param indexBuffer defines the index buffer to store
  39449. * @param effect defines the effect to store
  39450. * @returns the new vertex array object
  39451. */
  39452. recordVertexArrayObject(vertexBuffers: {
  39453. [key: string]: VertexBuffer;
  39454. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39455. /**
  39456. * Bind a specific vertex array object
  39457. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39458. * @param vertexArrayObject defines the vertex array object to bind
  39459. * @param indexBuffer defines the index buffer to bind
  39460. */
  39461. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39462. /**
  39463. * Bind webGl buffers directly to the webGL context
  39464. * @param vertexBuffer defines the vertex buffer to bind
  39465. * @param indexBuffer defines the index buffer to bind
  39466. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39467. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39468. * @param effect defines the effect associated with the vertex buffer
  39469. */
  39470. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39471. private _unbindVertexArrayObject;
  39472. /**
  39473. * Bind a list of vertex buffers to the webGL context
  39474. * @param vertexBuffers defines the list of vertex buffers to bind
  39475. * @param indexBuffer defines the index buffer to bind
  39476. * @param effect defines the effect associated with the vertex buffers
  39477. */
  39478. bindBuffers(vertexBuffers: {
  39479. [key: string]: Nullable<VertexBuffer>;
  39480. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39481. /**
  39482. * Unbind all instance attributes
  39483. */
  39484. unbindInstanceAttributes(): void;
  39485. /**
  39486. * Release and free the memory of a vertex array object
  39487. * @param vao defines the vertex array object to delete
  39488. */
  39489. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39490. /** @hidden */
  39491. _releaseBuffer(buffer: DataBuffer): boolean;
  39492. protected _deleteBuffer(buffer: DataBuffer): void;
  39493. /**
  39494. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39495. * @param instancesBuffer defines the webGL buffer to update and bind
  39496. * @param data defines the data to store in the buffer
  39497. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39498. */
  39499. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39500. /**
  39501. * Bind the content of a webGL buffer used with instantiation
  39502. * @param instancesBuffer defines the webGL buffer to bind
  39503. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39504. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39505. */
  39506. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39507. /**
  39508. * Disable the instance attribute corresponding to the name in parameter
  39509. * @param name defines the name of the attribute to disable
  39510. */
  39511. disableInstanceAttributeByName(name: string): void;
  39512. /**
  39513. * Disable the instance attribute corresponding to the location in parameter
  39514. * @param attributeLocation defines the attribute location of the attribute to disable
  39515. */
  39516. disableInstanceAttribute(attributeLocation: number): void;
  39517. /**
  39518. * Disable the attribute corresponding to the location in parameter
  39519. * @param attributeLocation defines the attribute location of the attribute to disable
  39520. */
  39521. disableAttributeByIndex(attributeLocation: number): void;
  39522. /**
  39523. * Send a draw order
  39524. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39525. * @param indexStart defines the starting index
  39526. * @param indexCount defines the number of index to draw
  39527. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39528. */
  39529. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39530. /**
  39531. * Draw a list of points
  39532. * @param verticesStart defines the index of first vertex to draw
  39533. * @param verticesCount defines the count of vertices to draw
  39534. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39535. */
  39536. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39537. /**
  39538. * Draw a list of unindexed primitives
  39539. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39540. * @param verticesStart defines the index of first vertex to draw
  39541. * @param verticesCount defines the count of vertices to draw
  39542. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39543. */
  39544. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39545. /**
  39546. * Draw a list of indexed primitives
  39547. * @param fillMode defines the primitive to use
  39548. * @param indexStart defines the starting index
  39549. * @param indexCount defines the number of index to draw
  39550. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39551. */
  39552. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39553. /**
  39554. * Draw a list of unindexed primitives
  39555. * @param fillMode defines the primitive to use
  39556. * @param verticesStart defines the index of first vertex to draw
  39557. * @param verticesCount defines the count of vertices to draw
  39558. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39559. */
  39560. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39561. private _drawMode;
  39562. /** @hidden */
  39563. protected _reportDrawCall(): void;
  39564. /** @hidden */
  39565. _releaseEffect(effect: Effect): void;
  39566. /** @hidden */
  39567. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39568. /**
  39569. * Create a new effect (used to store vertex/fragment shaders)
  39570. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39571. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39572. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39573. * @param samplers defines an array of string used to represent textures
  39574. * @param defines defines the string containing the defines to use to compile the shaders
  39575. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39576. * @param onCompiled defines a function to call when the effect creation is successful
  39577. * @param onError defines a function to call when the effect creation has failed
  39578. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39579. * @returns the new Effect
  39580. */
  39581. 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;
  39582. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39583. private _compileShader;
  39584. private _compileRawShader;
  39585. /** @hidden */
  39586. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39587. /**
  39588. * Directly creates a webGL program
  39589. * @param pipelineContext defines the pipeline context to attach to
  39590. * @param vertexCode defines the vertex shader code to use
  39591. * @param fragmentCode defines the fragment shader code to use
  39592. * @param context defines the webGL context to use (if not set, the current one will be used)
  39593. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39594. * @returns the new webGL program
  39595. */
  39596. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39597. /**
  39598. * Creates a webGL program
  39599. * @param pipelineContext defines the pipeline context to attach to
  39600. * @param vertexCode defines the vertex shader code to use
  39601. * @param fragmentCode defines the fragment shader code to use
  39602. * @param defines defines the string containing the defines to use to compile the shaders
  39603. * @param context defines the webGL context to use (if not set, the current one will be used)
  39604. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39605. * @returns the new webGL program
  39606. */
  39607. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39608. /**
  39609. * Creates a new pipeline context
  39610. * @returns the new pipeline
  39611. */
  39612. createPipelineContext(): IPipelineContext;
  39613. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39614. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39615. /** @hidden */
  39616. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39617. /** @hidden */
  39618. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39619. /** @hidden */
  39620. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39621. /**
  39622. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39623. * @param pipelineContext defines the pipeline context to use
  39624. * @param uniformsNames defines the list of uniform names
  39625. * @returns an array of webGL uniform locations
  39626. */
  39627. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39628. /**
  39629. * Gets the lsit of active attributes for a given webGL program
  39630. * @param pipelineContext defines the pipeline context to use
  39631. * @param attributesNames defines the list of attribute names to get
  39632. * @returns an array of indices indicating the offset of each attribute
  39633. */
  39634. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39635. /**
  39636. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39637. * @param effect defines the effect to activate
  39638. */
  39639. enableEffect(effect: Nullable<Effect>): void;
  39640. /**
  39641. * Set the value of an uniform to a number (int)
  39642. * @param uniform defines the webGL uniform location where to store the value
  39643. * @param value defines the int number to store
  39644. * @returns true if the value was set
  39645. */
  39646. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39647. /**
  39648. * Set the value of an uniform to an array of int32
  39649. * @param uniform defines the webGL uniform location where to store the value
  39650. * @param array defines the array of int32 to store
  39651. * @returns true if the value was set
  39652. */
  39653. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39654. /**
  39655. * Set the value of an uniform to an array of int32 (stored as vec2)
  39656. * @param uniform defines the webGL uniform location where to store the value
  39657. * @param array defines the array of int32 to store
  39658. * @returns true if the value was set
  39659. */
  39660. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39661. /**
  39662. * Set the value of an uniform to an array of int32 (stored as vec3)
  39663. * @param uniform defines the webGL uniform location where to store the value
  39664. * @param array defines the array of int32 to store
  39665. * @returns true if the value was set
  39666. */
  39667. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39668. /**
  39669. * Set the value of an uniform to an array of int32 (stored as vec4)
  39670. * @param uniform defines the webGL uniform location where to store the value
  39671. * @param array defines the array of int32 to store
  39672. * @returns true if the value was set
  39673. */
  39674. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39675. /**
  39676. * Set the value of an uniform to an array of number
  39677. * @param uniform defines the webGL uniform location where to store the value
  39678. * @param array defines the array of number to store
  39679. * @returns true if the value was set
  39680. */
  39681. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39682. /**
  39683. * Set the value of an uniform to an array of number (stored as vec2)
  39684. * @param uniform defines the webGL uniform location where to store the value
  39685. * @param array defines the array of number to store
  39686. * @returns true if the value was set
  39687. */
  39688. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39689. /**
  39690. * Set the value of an uniform to an array of number (stored as vec3)
  39691. * @param uniform defines the webGL uniform location where to store the value
  39692. * @param array defines the array of number to store
  39693. * @returns true if the value was set
  39694. */
  39695. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39696. /**
  39697. * Set the value of an uniform to an array of number (stored as vec4)
  39698. * @param uniform defines the webGL uniform location where to store the value
  39699. * @param array defines the array of number to store
  39700. * @returns true if the value was set
  39701. */
  39702. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39703. /**
  39704. * Set the value of an uniform to an array of float32 (stored as matrices)
  39705. * @param uniform defines the webGL uniform location where to store the value
  39706. * @param matrices defines the array of float32 to store
  39707. * @returns true if the value was set
  39708. */
  39709. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39710. /**
  39711. * Set the value of an uniform to a matrix (3x3)
  39712. * @param uniform defines the webGL uniform location where to store the value
  39713. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39714. * @returns true if the value was set
  39715. */
  39716. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39717. /**
  39718. * Set the value of an uniform to a matrix (2x2)
  39719. * @param uniform defines the webGL uniform location where to store the value
  39720. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39721. * @returns true if the value was set
  39722. */
  39723. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39724. /**
  39725. * Set the value of an uniform to a number (float)
  39726. * @param uniform defines the webGL uniform location where to store the value
  39727. * @param value defines the float number to store
  39728. * @returns true if the value was transfered
  39729. */
  39730. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39731. /**
  39732. * Set the value of an uniform to a vec2
  39733. * @param uniform defines the webGL uniform location where to store the value
  39734. * @param x defines the 1st component of the value
  39735. * @param y defines the 2nd component of the value
  39736. * @returns true if the value was set
  39737. */
  39738. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39739. /**
  39740. * Set the value of an uniform to a vec3
  39741. * @param uniform defines the webGL uniform location where to store the value
  39742. * @param x defines the 1st component of the value
  39743. * @param y defines the 2nd component of the value
  39744. * @param z defines the 3rd component of the value
  39745. * @returns true if the value was set
  39746. */
  39747. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39748. /**
  39749. * Set the value of an uniform to a vec4
  39750. * @param uniform defines the webGL uniform location where to store the value
  39751. * @param x defines the 1st component of the value
  39752. * @param y defines the 2nd component of the value
  39753. * @param z defines the 3rd component of the value
  39754. * @param w defines the 4th component of the value
  39755. * @returns true if the value was set
  39756. */
  39757. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39758. /**
  39759. * Apply all cached states (depth, culling, stencil and alpha)
  39760. */
  39761. applyStates(): void;
  39762. /**
  39763. * Enable or disable color writing
  39764. * @param enable defines the state to set
  39765. */
  39766. setColorWrite(enable: boolean): void;
  39767. /**
  39768. * Gets a boolean indicating if color writing is enabled
  39769. * @returns the current color writing state
  39770. */
  39771. getColorWrite(): boolean;
  39772. /**
  39773. * Gets the depth culling state manager
  39774. */
  39775. get depthCullingState(): DepthCullingState;
  39776. /**
  39777. * Gets the alpha state manager
  39778. */
  39779. get alphaState(): AlphaState;
  39780. /**
  39781. * Gets the stencil state manager
  39782. */
  39783. get stencilState(): StencilState;
  39784. /**
  39785. * Clears the list of texture accessible through engine.
  39786. * This can help preventing texture load conflict due to name collision.
  39787. */
  39788. clearInternalTexturesCache(): void;
  39789. /**
  39790. * Force the entire cache to be cleared
  39791. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39792. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39793. */
  39794. wipeCaches(bruteForce?: boolean): void;
  39795. /** @hidden */
  39796. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39797. min: number;
  39798. mag: number;
  39799. };
  39800. /** @hidden */
  39801. _createTexture(): WebGLTexture;
  39802. /**
  39803. * Usually called from Texture.ts.
  39804. * Passed information to create a WebGLTexture
  39805. * @param url defines a value which contains one of the following:
  39806. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39807. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39808. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39809. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39810. * @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)
  39811. * @param scene needed for loading to the correct scene
  39812. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39813. * @param onLoad optional callback to be called upon successful completion
  39814. * @param onError optional callback to be called upon failure
  39815. * @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
  39816. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39817. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39818. * @param forcedExtension defines the extension to use to pick the right loader
  39819. * @param mimeType defines an optional mime type
  39820. * @param loaderOptions options to be passed to the loader
  39821. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39822. */
  39823. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  39824. /**
  39825. * Loads an image as an HTMLImageElement.
  39826. * @param input url string, ArrayBuffer, or Blob to load
  39827. * @param onLoad callback called when the image successfully loads
  39828. * @param onError callback called when the image fails to load
  39829. * @param offlineProvider offline provider for caching
  39830. * @param mimeType optional mime type
  39831. * @returns the HTMLImageElement of the loaded image
  39832. * @hidden
  39833. */
  39834. 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>;
  39835. /**
  39836. * @hidden
  39837. */
  39838. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39839. private _unpackFlipYCached;
  39840. /**
  39841. * In case you are sharing the context with other applications, it might
  39842. * be interested to not cache the unpack flip y state to ensure a consistent
  39843. * value would be set.
  39844. */
  39845. enableUnpackFlipYCached: boolean;
  39846. /** @hidden */
  39847. _unpackFlipY(value: boolean): void;
  39848. /** @hidden */
  39849. _getUnpackAlignement(): number;
  39850. private _getTextureTarget;
  39851. /**
  39852. * Update the sampling mode of a given texture
  39853. * @param samplingMode defines the required sampling mode
  39854. * @param texture defines the texture to update
  39855. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39856. */
  39857. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39858. /**
  39859. * Update the sampling mode of a given texture
  39860. * @param texture defines the texture to update
  39861. * @param wrapU defines the texture wrap mode of the u coordinates
  39862. * @param wrapV defines the texture wrap mode of the v coordinates
  39863. * @param wrapR defines the texture wrap mode of the r coordinates
  39864. */
  39865. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39866. /** @hidden */
  39867. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39868. width: number;
  39869. height: number;
  39870. layers?: number;
  39871. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39872. /** @hidden */
  39873. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39874. /** @hidden */
  39875. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39876. /**
  39877. * Update a portion of an internal texture
  39878. * @param texture defines the texture to update
  39879. * @param imageData defines the data to store into the texture
  39880. * @param xOffset defines the x coordinates of the update rectangle
  39881. * @param yOffset defines the y coordinates of the update rectangle
  39882. * @param width defines the width of the update rectangle
  39883. * @param height defines the height of the update rectangle
  39884. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39885. * @param lod defines the lod level to update (0 by default)
  39886. */
  39887. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39888. /** @hidden */
  39889. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39890. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39891. private _prepareWebGLTexture;
  39892. /** @hidden */
  39893. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39894. private _getDepthStencilBuffer;
  39895. /** @hidden */
  39896. _releaseFramebufferObjects(texture: InternalTexture): void;
  39897. /** @hidden */
  39898. _releaseTexture(texture: InternalTexture): void;
  39899. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39900. protected _setProgram(program: WebGLProgram): void;
  39901. protected _boundUniforms: {
  39902. [key: number]: WebGLUniformLocation;
  39903. };
  39904. /**
  39905. * Binds an effect to the webGL context
  39906. * @param effect defines the effect to bind
  39907. */
  39908. bindSamplers(effect: Effect): void;
  39909. private _activateCurrentTexture;
  39910. /** @hidden */
  39911. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39912. /** @hidden */
  39913. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39914. /**
  39915. * Unbind all textures from the webGL context
  39916. */
  39917. unbindAllTextures(): void;
  39918. /**
  39919. * Sets a texture to the according uniform.
  39920. * @param channel The texture channel
  39921. * @param uniform The uniform to set
  39922. * @param texture The texture to apply
  39923. */
  39924. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  39925. private _bindSamplerUniformToChannel;
  39926. private _getTextureWrapMode;
  39927. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39928. /**
  39929. * Sets an array of texture to the webGL context
  39930. * @param channel defines the channel where the texture array must be set
  39931. * @param uniform defines the associated uniform location
  39932. * @param textures defines the array of textures to bind
  39933. */
  39934. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  39935. /** @hidden */
  39936. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39937. private _setTextureParameterFloat;
  39938. private _setTextureParameterInteger;
  39939. /**
  39940. * Unbind all vertex attributes from the webGL context
  39941. */
  39942. unbindAllAttributes(): void;
  39943. /**
  39944. * 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
  39945. */
  39946. releaseEffects(): void;
  39947. /**
  39948. * Dispose and release all associated resources
  39949. */
  39950. dispose(): void;
  39951. /**
  39952. * Attach a new callback raised when context lost event is fired
  39953. * @param callback defines the callback to call
  39954. */
  39955. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39956. /**
  39957. * Attach a new callback raised when context restored event is fired
  39958. * @param callback defines the callback to call
  39959. */
  39960. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39961. /**
  39962. * Get the current error code of the webGL context
  39963. * @returns the error code
  39964. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39965. */
  39966. getError(): number;
  39967. private _canRenderToFloatFramebuffer;
  39968. private _canRenderToHalfFloatFramebuffer;
  39969. private _canRenderToFramebuffer;
  39970. /** @hidden */
  39971. _getWebGLTextureType(type: number): number;
  39972. /** @hidden */
  39973. _getInternalFormat(format: number): number;
  39974. /** @hidden */
  39975. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39976. /** @hidden */
  39977. _getRGBAMultiSampleBufferFormat(type: number): number;
  39978. /** @hidden */
  39979. _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;
  39980. /**
  39981. * Loads a file from a url
  39982. * @param url url to load
  39983. * @param onSuccess callback called when the file successfully loads
  39984. * @param onProgress callback called while file is loading (if the server supports this mode)
  39985. * @param offlineProvider defines the offline provider for caching
  39986. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39987. * @param onError callback called when the file fails to load
  39988. * @returns a file request object
  39989. * @hidden
  39990. */
  39991. 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;
  39992. /**
  39993. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39994. * @param x defines the x coordinate of the rectangle where pixels must be read
  39995. * @param y defines the y coordinate of the rectangle where pixels must be read
  39996. * @param width defines the width of the rectangle where pixels must be read
  39997. * @param height defines the height of the rectangle where pixels must be read
  39998. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39999. * @returns a Uint8Array containing RGBA colors
  40000. */
  40001. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40002. private static _IsSupported;
  40003. private static _HasMajorPerformanceCaveat;
  40004. /**
  40005. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40006. */
  40007. static get IsSupported(): boolean;
  40008. /**
  40009. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40010. * @returns true if the engine can be created
  40011. * @ignorenaming
  40012. */
  40013. static isSupported(): boolean;
  40014. /**
  40015. * 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)
  40016. */
  40017. static get HasMajorPerformanceCaveat(): boolean;
  40018. /**
  40019. * Find the next highest power of two.
  40020. * @param x Number to start search from.
  40021. * @return Next highest power of two.
  40022. */
  40023. static CeilingPOT(x: number): number;
  40024. /**
  40025. * Find the next lowest power of two.
  40026. * @param x Number to start search from.
  40027. * @return Next lowest power of two.
  40028. */
  40029. static FloorPOT(x: number): number;
  40030. /**
  40031. * Find the nearest power of two.
  40032. * @param x Number to start search from.
  40033. * @return Next nearest power of two.
  40034. */
  40035. static NearestPOT(x: number): number;
  40036. /**
  40037. * Get the closest exponent of two
  40038. * @param value defines the value to approximate
  40039. * @param max defines the maximum value to return
  40040. * @param mode defines how to define the closest value
  40041. * @returns closest exponent of two of the given value
  40042. */
  40043. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40044. /**
  40045. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40046. * @param func - the function to be called
  40047. * @param requester - the object that will request the next frame. Falls back to window.
  40048. * @returns frame number
  40049. */
  40050. static QueueNewFrame(func: () => void, requester?: any): number;
  40051. /**
  40052. * Gets host document
  40053. * @returns the host document object
  40054. */
  40055. getHostDocument(): Nullable<Document>;
  40056. }
  40057. }
  40058. declare module BABYLON {
  40059. /**
  40060. * Defines the source of the internal texture
  40061. */
  40062. export enum InternalTextureSource {
  40063. /**
  40064. * The source of the texture data is unknown
  40065. */
  40066. Unknown = 0,
  40067. /**
  40068. * Texture data comes from an URL
  40069. */
  40070. Url = 1,
  40071. /**
  40072. * Texture data is only used for temporary storage
  40073. */
  40074. Temp = 2,
  40075. /**
  40076. * Texture data comes from raw data (ArrayBuffer)
  40077. */
  40078. Raw = 3,
  40079. /**
  40080. * Texture content is dynamic (video or dynamic texture)
  40081. */
  40082. Dynamic = 4,
  40083. /**
  40084. * Texture content is generated by rendering to it
  40085. */
  40086. RenderTarget = 5,
  40087. /**
  40088. * Texture content is part of a multi render target process
  40089. */
  40090. MultiRenderTarget = 6,
  40091. /**
  40092. * Texture data comes from a cube data file
  40093. */
  40094. Cube = 7,
  40095. /**
  40096. * Texture data comes from a raw cube data
  40097. */
  40098. CubeRaw = 8,
  40099. /**
  40100. * Texture data come from a prefiltered cube data file
  40101. */
  40102. CubePrefiltered = 9,
  40103. /**
  40104. * Texture content is raw 3D data
  40105. */
  40106. Raw3D = 10,
  40107. /**
  40108. * Texture content is raw 2D array data
  40109. */
  40110. Raw2DArray = 11,
  40111. /**
  40112. * Texture content is a depth texture
  40113. */
  40114. Depth = 12,
  40115. /**
  40116. * Texture data comes from a raw cube data encoded with RGBD
  40117. */
  40118. CubeRawRGBD = 13
  40119. }
  40120. /**
  40121. * Class used to store data associated with WebGL texture data for the engine
  40122. * This class should not be used directly
  40123. */
  40124. export class InternalTexture {
  40125. /** @hidden */
  40126. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  40127. /**
  40128. * Defines if the texture is ready
  40129. */
  40130. isReady: boolean;
  40131. /**
  40132. * Defines if the texture is a cube texture
  40133. */
  40134. isCube: boolean;
  40135. /**
  40136. * Defines if the texture contains 3D data
  40137. */
  40138. is3D: boolean;
  40139. /**
  40140. * Defines if the texture contains 2D array data
  40141. */
  40142. is2DArray: boolean;
  40143. /**
  40144. * Defines if the texture contains multiview data
  40145. */
  40146. isMultiview: boolean;
  40147. /**
  40148. * Gets the URL used to load this texture
  40149. */
  40150. url: string;
  40151. /** @hidden */
  40152. _originalUrl: string;
  40153. /**
  40154. * Gets the sampling mode of the texture
  40155. */
  40156. samplingMode: number;
  40157. /**
  40158. * Gets a boolean indicating if the texture needs mipmaps generation
  40159. */
  40160. generateMipMaps: boolean;
  40161. /**
  40162. * Gets the number of samples used by the texture (WebGL2+ only)
  40163. */
  40164. samples: number;
  40165. /**
  40166. * Gets the type of the texture (int, float...)
  40167. */
  40168. type: number;
  40169. /**
  40170. * Gets the format of the texture (RGB, RGBA...)
  40171. */
  40172. format: number;
  40173. /**
  40174. * Observable called when the texture is loaded
  40175. */
  40176. onLoadedObservable: Observable<InternalTexture>;
  40177. /**
  40178. * Gets the width of the texture
  40179. */
  40180. width: number;
  40181. /**
  40182. * Gets the height of the texture
  40183. */
  40184. height: number;
  40185. /**
  40186. * Gets the depth of the texture
  40187. */
  40188. depth: number;
  40189. /**
  40190. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  40191. */
  40192. baseWidth: number;
  40193. /**
  40194. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  40195. */
  40196. baseHeight: number;
  40197. /**
  40198. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  40199. */
  40200. baseDepth: number;
  40201. /**
  40202. * Gets a boolean indicating if the texture is inverted on Y axis
  40203. */
  40204. invertY: boolean;
  40205. /** @hidden */
  40206. _invertVScale: boolean;
  40207. /** @hidden */
  40208. _associatedChannel: number;
  40209. /** @hidden */
  40210. _source: InternalTextureSource;
  40211. /** @hidden */
  40212. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  40213. /** @hidden */
  40214. _bufferView: Nullable<ArrayBufferView>;
  40215. /** @hidden */
  40216. _bufferViewArray: Nullable<ArrayBufferView[]>;
  40217. /** @hidden */
  40218. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  40219. /** @hidden */
  40220. _size: number;
  40221. /** @hidden */
  40222. _extension: string;
  40223. /** @hidden */
  40224. _files: Nullable<string[]>;
  40225. /** @hidden */
  40226. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40227. /** @hidden */
  40228. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40229. /** @hidden */
  40230. _framebuffer: Nullable<WebGLFramebuffer>;
  40231. /** @hidden */
  40232. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  40233. /** @hidden */
  40234. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  40235. /** @hidden */
  40236. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  40237. /** @hidden */
  40238. _attachments: Nullable<number[]>;
  40239. /** @hidden */
  40240. _textureArray: Nullable<InternalTexture[]>;
  40241. /** @hidden */
  40242. _cachedCoordinatesMode: Nullable<number>;
  40243. /** @hidden */
  40244. _cachedWrapU: Nullable<number>;
  40245. /** @hidden */
  40246. _cachedWrapV: Nullable<number>;
  40247. /** @hidden */
  40248. _cachedWrapR: Nullable<number>;
  40249. /** @hidden */
  40250. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40251. /** @hidden */
  40252. _isDisabled: boolean;
  40253. /** @hidden */
  40254. _compression: Nullable<string>;
  40255. /** @hidden */
  40256. _generateStencilBuffer: boolean;
  40257. /** @hidden */
  40258. _generateDepthBuffer: boolean;
  40259. /** @hidden */
  40260. _comparisonFunction: number;
  40261. /** @hidden */
  40262. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40263. /** @hidden */
  40264. _lodGenerationScale: number;
  40265. /** @hidden */
  40266. _lodGenerationOffset: number;
  40267. /** @hidden */
  40268. _depthStencilTexture: Nullable<InternalTexture>;
  40269. /** @hidden */
  40270. _colorTextureArray: Nullable<WebGLTexture>;
  40271. /** @hidden */
  40272. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40273. /** @hidden */
  40274. _lodTextureHigh: Nullable<BaseTexture>;
  40275. /** @hidden */
  40276. _lodTextureMid: Nullable<BaseTexture>;
  40277. /** @hidden */
  40278. _lodTextureLow: Nullable<BaseTexture>;
  40279. /** @hidden */
  40280. _isRGBD: boolean;
  40281. /** @hidden */
  40282. _linearSpecularLOD: boolean;
  40283. /** @hidden */
  40284. _irradianceTexture: Nullable<BaseTexture>;
  40285. /** @hidden */
  40286. _webGLTexture: Nullable<WebGLTexture>;
  40287. /** @hidden */
  40288. _references: number;
  40289. /** @hidden */
  40290. _gammaSpace: Nullable<boolean>;
  40291. private _engine;
  40292. /**
  40293. * Gets the Engine the texture belongs to.
  40294. * @returns The babylon engine
  40295. */
  40296. getEngine(): ThinEngine;
  40297. /**
  40298. * Gets the data source type of the texture
  40299. */
  40300. get source(): InternalTextureSource;
  40301. /**
  40302. * Creates a new InternalTexture
  40303. * @param engine defines the engine to use
  40304. * @param source defines the type of data that will be used
  40305. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40306. */
  40307. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40308. /**
  40309. * Increments the number of references (ie. the number of Texture that point to it)
  40310. */
  40311. incrementReferences(): void;
  40312. /**
  40313. * Change the size of the texture (not the size of the content)
  40314. * @param width defines the new width
  40315. * @param height defines the new height
  40316. * @param depth defines the new depth (1 by default)
  40317. */
  40318. updateSize(width: int, height: int, depth?: int): void;
  40319. /** @hidden */
  40320. _rebuild(): void;
  40321. /** @hidden */
  40322. _swapAndDie(target: InternalTexture): void;
  40323. /**
  40324. * Dispose the current allocated resources
  40325. */
  40326. dispose(): void;
  40327. }
  40328. }
  40329. declare module BABYLON {
  40330. /**
  40331. * Interface used to present a loading screen while loading a scene
  40332. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40333. */
  40334. export interface ILoadingScreen {
  40335. /**
  40336. * Function called to display the loading screen
  40337. */
  40338. displayLoadingUI: () => void;
  40339. /**
  40340. * Function called to hide the loading screen
  40341. */
  40342. hideLoadingUI: () => void;
  40343. /**
  40344. * Gets or sets the color to use for the background
  40345. */
  40346. loadingUIBackgroundColor: string;
  40347. /**
  40348. * Gets or sets the text to display while loading
  40349. */
  40350. loadingUIText: string;
  40351. }
  40352. /**
  40353. * Class used for the default loading screen
  40354. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40355. */
  40356. export class DefaultLoadingScreen implements ILoadingScreen {
  40357. private _renderingCanvas;
  40358. private _loadingText;
  40359. private _loadingDivBackgroundColor;
  40360. private _loadingDiv;
  40361. private _loadingTextDiv;
  40362. /** Gets or sets the logo url to use for the default loading screen */
  40363. static DefaultLogoUrl: string;
  40364. /** Gets or sets the spinner url to use for the default loading screen */
  40365. static DefaultSpinnerUrl: string;
  40366. /**
  40367. * Creates a new default loading screen
  40368. * @param _renderingCanvas defines the canvas used to render the scene
  40369. * @param _loadingText defines the default text to display
  40370. * @param _loadingDivBackgroundColor defines the default background color
  40371. */
  40372. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40373. /**
  40374. * Function called to display the loading screen
  40375. */
  40376. displayLoadingUI(): void;
  40377. /**
  40378. * Function called to hide the loading screen
  40379. */
  40380. hideLoadingUI(): void;
  40381. /**
  40382. * Gets or sets the text to display while loading
  40383. */
  40384. set loadingUIText(text: string);
  40385. get loadingUIText(): string;
  40386. /**
  40387. * Gets or sets the color to use for the background
  40388. */
  40389. get loadingUIBackgroundColor(): string;
  40390. set loadingUIBackgroundColor(color: string);
  40391. private _resizeLoadingUI;
  40392. }
  40393. }
  40394. declare module BABYLON {
  40395. /**
  40396. * Interface for any object that can request an animation frame
  40397. */
  40398. export interface ICustomAnimationFrameRequester {
  40399. /**
  40400. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40401. */
  40402. renderFunction?: Function;
  40403. /**
  40404. * Called to request the next frame to render to
  40405. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40406. */
  40407. requestAnimationFrame: Function;
  40408. /**
  40409. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40410. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40411. */
  40412. requestID?: number;
  40413. }
  40414. }
  40415. declare module BABYLON {
  40416. /**
  40417. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40418. */
  40419. export class PerformanceMonitor {
  40420. private _enabled;
  40421. private _rollingFrameTime;
  40422. private _lastFrameTimeMs;
  40423. /**
  40424. * constructor
  40425. * @param frameSampleSize The number of samples required to saturate the sliding window
  40426. */
  40427. constructor(frameSampleSize?: number);
  40428. /**
  40429. * Samples current frame
  40430. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40431. */
  40432. sampleFrame(timeMs?: number): void;
  40433. /**
  40434. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40435. */
  40436. get averageFrameTime(): number;
  40437. /**
  40438. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40439. */
  40440. get averageFrameTimeVariance(): number;
  40441. /**
  40442. * Returns the frame time of the most recent frame
  40443. */
  40444. get instantaneousFrameTime(): number;
  40445. /**
  40446. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40447. */
  40448. get averageFPS(): number;
  40449. /**
  40450. * Returns the average framerate in frames per second using the most recent frame time
  40451. */
  40452. get instantaneousFPS(): number;
  40453. /**
  40454. * Returns true if enough samples have been taken to completely fill the sliding window
  40455. */
  40456. get isSaturated(): boolean;
  40457. /**
  40458. * Enables contributions to the sliding window sample set
  40459. */
  40460. enable(): void;
  40461. /**
  40462. * Disables contributions to the sliding window sample set
  40463. * Samples will not be interpolated over the disabled period
  40464. */
  40465. disable(): void;
  40466. /**
  40467. * Returns true if sampling is enabled
  40468. */
  40469. get isEnabled(): boolean;
  40470. /**
  40471. * Resets performance monitor
  40472. */
  40473. reset(): void;
  40474. }
  40475. /**
  40476. * RollingAverage
  40477. *
  40478. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40479. */
  40480. export class RollingAverage {
  40481. /**
  40482. * Current average
  40483. */
  40484. average: number;
  40485. /**
  40486. * Current variance
  40487. */
  40488. variance: number;
  40489. protected _samples: Array<number>;
  40490. protected _sampleCount: number;
  40491. protected _pos: number;
  40492. protected _m2: number;
  40493. /**
  40494. * constructor
  40495. * @param length The number of samples required to saturate the sliding window
  40496. */
  40497. constructor(length: number);
  40498. /**
  40499. * Adds a sample to the sample set
  40500. * @param v The sample value
  40501. */
  40502. add(v: number): void;
  40503. /**
  40504. * Returns previously added values or null if outside of history or outside the sliding window domain
  40505. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40506. * @return Value previously recorded with add() or null if outside of range
  40507. */
  40508. history(i: number): number;
  40509. /**
  40510. * Returns true if enough samples have been taken to completely fill the sliding window
  40511. * @return true if sample-set saturated
  40512. */
  40513. isSaturated(): boolean;
  40514. /**
  40515. * Resets the rolling average (equivalent to 0 samples taken so far)
  40516. */
  40517. reset(): void;
  40518. /**
  40519. * Wraps a value around the sample range boundaries
  40520. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40521. * @return Wrapped position in sample range
  40522. */
  40523. protected _wrapPosition(i: number): number;
  40524. }
  40525. }
  40526. declare module BABYLON {
  40527. /**
  40528. * This class is used to track a performance counter which is number based.
  40529. * The user has access to many properties which give statistics of different nature.
  40530. *
  40531. * The implementer can track two kinds of Performance Counter: time and count.
  40532. * 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.
  40533. * 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.
  40534. */
  40535. export class PerfCounter {
  40536. /**
  40537. * Gets or sets a global boolean to turn on and off all the counters
  40538. */
  40539. static Enabled: boolean;
  40540. /**
  40541. * Returns the smallest value ever
  40542. */
  40543. get min(): number;
  40544. /**
  40545. * Returns the biggest value ever
  40546. */
  40547. get max(): number;
  40548. /**
  40549. * Returns the average value since the performance counter is running
  40550. */
  40551. get average(): number;
  40552. /**
  40553. * Returns the average value of the last second the counter was monitored
  40554. */
  40555. get lastSecAverage(): number;
  40556. /**
  40557. * Returns the current value
  40558. */
  40559. get current(): number;
  40560. /**
  40561. * Gets the accumulated total
  40562. */
  40563. get total(): number;
  40564. /**
  40565. * Gets the total value count
  40566. */
  40567. get count(): number;
  40568. /**
  40569. * Creates a new counter
  40570. */
  40571. constructor();
  40572. /**
  40573. * Call this method to start monitoring a new frame.
  40574. * 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.
  40575. */
  40576. fetchNewFrame(): void;
  40577. /**
  40578. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40579. * @param newCount the count value to add to the monitored count
  40580. * @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.
  40581. */
  40582. addCount(newCount: number, fetchResult: boolean): void;
  40583. /**
  40584. * Start monitoring this performance counter
  40585. */
  40586. beginMonitoring(): void;
  40587. /**
  40588. * Compute the time lapsed since the previous beginMonitoring() call.
  40589. * @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
  40590. */
  40591. endMonitoring(newFrame?: boolean): void;
  40592. private _fetchResult;
  40593. private _startMonitoringTime;
  40594. private _min;
  40595. private _max;
  40596. private _average;
  40597. private _current;
  40598. private _totalValueCount;
  40599. private _totalAccumulated;
  40600. private _lastSecAverage;
  40601. private _lastSecAccumulated;
  40602. private _lastSecTime;
  40603. private _lastSecValueCount;
  40604. }
  40605. }
  40606. declare module BABYLON {
  40607. interface ThinEngine {
  40608. /** @hidden */
  40609. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40610. }
  40611. }
  40612. declare module BABYLON {
  40613. /**
  40614. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40615. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40616. */
  40617. export class Analyser {
  40618. /**
  40619. * Gets or sets the smoothing
  40620. * @ignorenaming
  40621. */
  40622. SMOOTHING: number;
  40623. /**
  40624. * Gets or sets the FFT table size
  40625. * @ignorenaming
  40626. */
  40627. FFT_SIZE: number;
  40628. /**
  40629. * Gets or sets the bar graph amplitude
  40630. * @ignorenaming
  40631. */
  40632. BARGRAPHAMPLITUDE: number;
  40633. /**
  40634. * Gets or sets the position of the debug canvas
  40635. * @ignorenaming
  40636. */
  40637. DEBUGCANVASPOS: {
  40638. x: number;
  40639. y: number;
  40640. };
  40641. /**
  40642. * Gets or sets the debug canvas size
  40643. * @ignorenaming
  40644. */
  40645. DEBUGCANVASSIZE: {
  40646. width: number;
  40647. height: number;
  40648. };
  40649. private _byteFreqs;
  40650. private _byteTime;
  40651. private _floatFreqs;
  40652. private _webAudioAnalyser;
  40653. private _debugCanvas;
  40654. private _debugCanvasContext;
  40655. private _scene;
  40656. private _registerFunc;
  40657. private _audioEngine;
  40658. /**
  40659. * Creates a new analyser
  40660. * @param scene defines hosting scene
  40661. */
  40662. constructor(scene: Scene);
  40663. /**
  40664. * Get the number of data values you will have to play with for the visualization
  40665. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40666. * @returns a number
  40667. */
  40668. getFrequencyBinCount(): number;
  40669. /**
  40670. * Gets the current frequency data as a byte array
  40671. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40672. * @returns a Uint8Array
  40673. */
  40674. getByteFrequencyData(): Uint8Array;
  40675. /**
  40676. * Gets the current waveform as a byte array
  40677. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40678. * @returns a Uint8Array
  40679. */
  40680. getByteTimeDomainData(): Uint8Array;
  40681. /**
  40682. * Gets the current frequency data as a float array
  40683. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40684. * @returns a Float32Array
  40685. */
  40686. getFloatFrequencyData(): Float32Array;
  40687. /**
  40688. * Renders the debug canvas
  40689. */
  40690. drawDebugCanvas(): void;
  40691. /**
  40692. * Stops rendering the debug canvas and removes it
  40693. */
  40694. stopDebugCanvas(): void;
  40695. /**
  40696. * Connects two audio nodes
  40697. * @param inputAudioNode defines first node to connect
  40698. * @param outputAudioNode defines second node to connect
  40699. */
  40700. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40701. /**
  40702. * Releases all associated resources
  40703. */
  40704. dispose(): void;
  40705. }
  40706. }
  40707. declare module BABYLON {
  40708. /**
  40709. * This represents an audio engine and it is responsible
  40710. * to play, synchronize and analyse sounds throughout the application.
  40711. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40712. */
  40713. export interface IAudioEngine extends IDisposable {
  40714. /**
  40715. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40716. */
  40717. readonly canUseWebAudio: boolean;
  40718. /**
  40719. * Gets the current AudioContext if available.
  40720. */
  40721. readonly audioContext: Nullable<AudioContext>;
  40722. /**
  40723. * The master gain node defines the global audio volume of your audio engine.
  40724. */
  40725. readonly masterGain: GainNode;
  40726. /**
  40727. * Gets whether or not mp3 are supported by your browser.
  40728. */
  40729. readonly isMP3supported: boolean;
  40730. /**
  40731. * Gets whether or not ogg are supported by your browser.
  40732. */
  40733. readonly isOGGsupported: boolean;
  40734. /**
  40735. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40736. * @ignoreNaming
  40737. */
  40738. WarnedWebAudioUnsupported: boolean;
  40739. /**
  40740. * Defines if the audio engine relies on a custom unlocked button.
  40741. * In this case, the embedded button will not be displayed.
  40742. */
  40743. useCustomUnlockedButton: boolean;
  40744. /**
  40745. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40746. */
  40747. readonly unlocked: boolean;
  40748. /**
  40749. * Event raised when audio has been unlocked on the browser.
  40750. */
  40751. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40752. /**
  40753. * Event raised when audio has been locked on the browser.
  40754. */
  40755. onAudioLockedObservable: Observable<IAudioEngine>;
  40756. /**
  40757. * Flags the audio engine in Locked state.
  40758. * This happens due to new browser policies preventing audio to autoplay.
  40759. */
  40760. lock(): void;
  40761. /**
  40762. * Unlocks the audio engine once a user action has been done on the dom.
  40763. * This is helpful to resume play once browser policies have been satisfied.
  40764. */
  40765. unlock(): void;
  40766. /**
  40767. * Gets the global volume sets on the master gain.
  40768. * @returns the global volume if set or -1 otherwise
  40769. */
  40770. getGlobalVolume(): number;
  40771. /**
  40772. * Sets the global volume of your experience (sets on the master gain).
  40773. * @param newVolume Defines the new global volume of the application
  40774. */
  40775. setGlobalVolume(newVolume: number): void;
  40776. /**
  40777. * Connect the audio engine to an audio analyser allowing some amazing
  40778. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40779. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40780. * @param analyser The analyser to connect to the engine
  40781. */
  40782. connectToAnalyser(analyser: Analyser): void;
  40783. }
  40784. }
  40785. declare module BABYLON {
  40786. /**
  40787. * Defines the interface used by display changed events
  40788. */
  40789. export interface IDisplayChangedEventArgs {
  40790. /** Gets the vrDisplay object (if any) */
  40791. vrDisplay: Nullable<any>;
  40792. /** Gets a boolean indicating if webVR is supported */
  40793. vrSupported: boolean;
  40794. }
  40795. /**
  40796. * Defines the interface used by objects containing a viewport (like a camera)
  40797. */
  40798. interface IViewportOwnerLike {
  40799. /**
  40800. * Gets or sets the viewport
  40801. */
  40802. viewport: IViewportLike;
  40803. }
  40804. /**
  40805. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40806. */
  40807. export class Engine extends ThinEngine {
  40808. /** Defines that alpha blending is disabled */
  40809. static readonly ALPHA_DISABLE: number;
  40810. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40811. static readonly ALPHA_ADD: number;
  40812. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40813. static readonly ALPHA_COMBINE: number;
  40814. /** Defines that alpha blending to DEST - SRC * DEST */
  40815. static readonly ALPHA_SUBTRACT: number;
  40816. /** Defines that alpha blending to SRC * DEST */
  40817. static readonly ALPHA_MULTIPLY: number;
  40818. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40819. static readonly ALPHA_MAXIMIZED: number;
  40820. /** Defines that alpha blending to SRC + DEST */
  40821. static readonly ALPHA_ONEONE: number;
  40822. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40823. static readonly ALPHA_PREMULTIPLIED: number;
  40824. /**
  40825. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40826. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40827. */
  40828. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40829. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40830. static readonly ALPHA_INTERPOLATE: number;
  40831. /**
  40832. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40833. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40834. */
  40835. static readonly ALPHA_SCREENMODE: number;
  40836. /** Defines that the ressource is not delayed*/
  40837. static readonly DELAYLOADSTATE_NONE: number;
  40838. /** Defines that the ressource was successfully delay loaded */
  40839. static readonly DELAYLOADSTATE_LOADED: number;
  40840. /** Defines that the ressource is currently delay loading */
  40841. static readonly DELAYLOADSTATE_LOADING: number;
  40842. /** Defines that the ressource is delayed and has not started loading */
  40843. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40844. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40845. static readonly NEVER: number;
  40846. /** 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 */
  40847. static readonly ALWAYS: number;
  40848. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40849. static readonly LESS: number;
  40850. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40851. static readonly EQUAL: number;
  40852. /** 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 */
  40853. static readonly LEQUAL: number;
  40854. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40855. static readonly GREATER: number;
  40856. /** 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 */
  40857. static readonly GEQUAL: number;
  40858. /** 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 */
  40859. static readonly NOTEQUAL: number;
  40860. /** Passed to stencilOperation to specify that stencil value must be kept */
  40861. static readonly KEEP: number;
  40862. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40863. static readonly REPLACE: number;
  40864. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40865. static readonly INCR: number;
  40866. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40867. static readonly DECR: number;
  40868. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40869. static readonly INVERT: number;
  40870. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40871. static readonly INCR_WRAP: number;
  40872. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40873. static readonly DECR_WRAP: number;
  40874. /** Texture is not repeating outside of 0..1 UVs */
  40875. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40876. /** Texture is repeating outside of 0..1 UVs */
  40877. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40878. /** Texture is repeating and mirrored */
  40879. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40880. /** ALPHA */
  40881. static readonly TEXTUREFORMAT_ALPHA: number;
  40882. /** LUMINANCE */
  40883. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40884. /** LUMINANCE_ALPHA */
  40885. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40886. /** RGB */
  40887. static readonly TEXTUREFORMAT_RGB: number;
  40888. /** RGBA */
  40889. static readonly TEXTUREFORMAT_RGBA: number;
  40890. /** RED */
  40891. static readonly TEXTUREFORMAT_RED: number;
  40892. /** RED (2nd reference) */
  40893. static readonly TEXTUREFORMAT_R: number;
  40894. /** RG */
  40895. static readonly TEXTUREFORMAT_RG: number;
  40896. /** RED_INTEGER */
  40897. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40898. /** RED_INTEGER (2nd reference) */
  40899. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40900. /** RG_INTEGER */
  40901. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40902. /** RGB_INTEGER */
  40903. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40904. /** RGBA_INTEGER */
  40905. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40906. /** UNSIGNED_BYTE */
  40907. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40908. /** UNSIGNED_BYTE (2nd reference) */
  40909. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40910. /** FLOAT */
  40911. static readonly TEXTURETYPE_FLOAT: number;
  40912. /** HALF_FLOAT */
  40913. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40914. /** BYTE */
  40915. static readonly TEXTURETYPE_BYTE: number;
  40916. /** SHORT */
  40917. static readonly TEXTURETYPE_SHORT: number;
  40918. /** UNSIGNED_SHORT */
  40919. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40920. /** INT */
  40921. static readonly TEXTURETYPE_INT: number;
  40922. /** UNSIGNED_INT */
  40923. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40924. /** UNSIGNED_SHORT_4_4_4_4 */
  40925. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40926. /** UNSIGNED_SHORT_5_5_5_1 */
  40927. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40928. /** UNSIGNED_SHORT_5_6_5 */
  40929. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40930. /** UNSIGNED_INT_2_10_10_10_REV */
  40931. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40932. /** UNSIGNED_INT_24_8 */
  40933. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40934. /** UNSIGNED_INT_10F_11F_11F_REV */
  40935. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40936. /** UNSIGNED_INT_5_9_9_9_REV */
  40937. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40938. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40939. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40940. /** nearest is mag = nearest and min = nearest and mip = linear */
  40941. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40942. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40943. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40944. /** Trilinear is mag = linear and min = linear and mip = linear */
  40945. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40946. /** nearest is mag = nearest and min = nearest and mip = linear */
  40947. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40948. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40949. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40950. /** Trilinear is mag = linear and min = linear and mip = linear */
  40951. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40952. /** mag = nearest and min = nearest and mip = nearest */
  40953. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40954. /** mag = nearest and min = linear and mip = nearest */
  40955. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40956. /** mag = nearest and min = linear and mip = linear */
  40957. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40958. /** mag = nearest and min = linear and mip = none */
  40959. static readonly TEXTURE_NEAREST_LINEAR: number;
  40960. /** mag = nearest and min = nearest and mip = none */
  40961. static readonly TEXTURE_NEAREST_NEAREST: number;
  40962. /** mag = linear and min = nearest and mip = nearest */
  40963. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40964. /** mag = linear and min = nearest and mip = linear */
  40965. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40966. /** mag = linear and min = linear and mip = none */
  40967. static readonly TEXTURE_LINEAR_LINEAR: number;
  40968. /** mag = linear and min = nearest and mip = none */
  40969. static readonly TEXTURE_LINEAR_NEAREST: number;
  40970. /** Explicit coordinates mode */
  40971. static readonly TEXTURE_EXPLICIT_MODE: number;
  40972. /** Spherical coordinates mode */
  40973. static readonly TEXTURE_SPHERICAL_MODE: number;
  40974. /** Planar coordinates mode */
  40975. static readonly TEXTURE_PLANAR_MODE: number;
  40976. /** Cubic coordinates mode */
  40977. static readonly TEXTURE_CUBIC_MODE: number;
  40978. /** Projection coordinates mode */
  40979. static readonly TEXTURE_PROJECTION_MODE: number;
  40980. /** Skybox coordinates mode */
  40981. static readonly TEXTURE_SKYBOX_MODE: number;
  40982. /** Inverse Cubic coordinates mode */
  40983. static readonly TEXTURE_INVCUBIC_MODE: number;
  40984. /** Equirectangular coordinates mode */
  40985. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40986. /** Equirectangular Fixed coordinates mode */
  40987. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40988. /** Equirectangular Fixed Mirrored coordinates mode */
  40989. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40990. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40991. static readonly SCALEMODE_FLOOR: number;
  40992. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40993. static readonly SCALEMODE_NEAREST: number;
  40994. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40995. static readonly SCALEMODE_CEILING: number;
  40996. /**
  40997. * Returns the current npm package of the sdk
  40998. */
  40999. static get NpmPackage(): string;
  41000. /**
  41001. * Returns the current version of the framework
  41002. */
  41003. static get Version(): string;
  41004. /** Gets the list of created engines */
  41005. static get Instances(): Engine[];
  41006. /**
  41007. * Gets the latest created engine
  41008. */
  41009. static get LastCreatedEngine(): Nullable<Engine>;
  41010. /**
  41011. * Gets the latest created scene
  41012. */
  41013. static get LastCreatedScene(): Nullable<Scene>;
  41014. /**
  41015. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  41016. * @param flag defines which part of the materials must be marked as dirty
  41017. * @param predicate defines a predicate used to filter which materials should be affected
  41018. */
  41019. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41020. /**
  41021. * Method called to create the default loading screen.
  41022. * This can be overriden in your own app.
  41023. * @param canvas The rendering canvas element
  41024. * @returns The loading screen
  41025. */
  41026. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  41027. /**
  41028. * Method called to create the default rescale post process on each engine.
  41029. */
  41030. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  41031. /**
  41032. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  41033. **/
  41034. enableOfflineSupport: boolean;
  41035. /**
  41036. * 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)
  41037. **/
  41038. disableManifestCheck: boolean;
  41039. /**
  41040. * Gets the list of created scenes
  41041. */
  41042. scenes: Scene[];
  41043. /**
  41044. * Event raised when a new scene is created
  41045. */
  41046. onNewSceneAddedObservable: Observable<Scene>;
  41047. /**
  41048. * Gets the list of created postprocesses
  41049. */
  41050. postProcesses: PostProcess[];
  41051. /**
  41052. * Gets a boolean indicating if the pointer is currently locked
  41053. */
  41054. isPointerLock: boolean;
  41055. /**
  41056. * Observable event triggered each time the rendering canvas is resized
  41057. */
  41058. onResizeObservable: Observable<Engine>;
  41059. /**
  41060. * Observable event triggered each time the canvas loses focus
  41061. */
  41062. onCanvasBlurObservable: Observable<Engine>;
  41063. /**
  41064. * Observable event triggered each time the canvas gains focus
  41065. */
  41066. onCanvasFocusObservable: Observable<Engine>;
  41067. /**
  41068. * Observable event triggered each time the canvas receives pointerout event
  41069. */
  41070. onCanvasPointerOutObservable: Observable<PointerEvent>;
  41071. /**
  41072. * Observable raised when the engine begins a new frame
  41073. */
  41074. onBeginFrameObservable: Observable<Engine>;
  41075. /**
  41076. * If set, will be used to request the next animation frame for the render loop
  41077. */
  41078. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  41079. /**
  41080. * Observable raised when the engine ends the current frame
  41081. */
  41082. onEndFrameObservable: Observable<Engine>;
  41083. /**
  41084. * Observable raised when the engine is about to compile a shader
  41085. */
  41086. onBeforeShaderCompilationObservable: Observable<Engine>;
  41087. /**
  41088. * Observable raised when the engine has jsut compiled a shader
  41089. */
  41090. onAfterShaderCompilationObservable: Observable<Engine>;
  41091. /**
  41092. * Gets the audio engine
  41093. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41094. * @ignorenaming
  41095. */
  41096. static audioEngine: IAudioEngine;
  41097. /**
  41098. * Default AudioEngine factory responsible of creating the Audio Engine.
  41099. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  41100. */
  41101. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  41102. /**
  41103. * Default offline support factory responsible of creating a tool used to store data locally.
  41104. * By default, this will create a Database object if the workload has been embedded.
  41105. */
  41106. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  41107. private _loadingScreen;
  41108. private _pointerLockRequested;
  41109. private _rescalePostProcess;
  41110. private _deterministicLockstep;
  41111. private _lockstepMaxSteps;
  41112. private _timeStep;
  41113. protected get _supportsHardwareTextureRescaling(): boolean;
  41114. private _fps;
  41115. private _deltaTime;
  41116. /** @hidden */
  41117. _drawCalls: PerfCounter;
  41118. /** 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 */
  41119. canvasTabIndex: number;
  41120. /**
  41121. * Turn this value on if you want to pause FPS computation when in background
  41122. */
  41123. disablePerformanceMonitorInBackground: boolean;
  41124. private _performanceMonitor;
  41125. /**
  41126. * Gets the performance monitor attached to this engine
  41127. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41128. */
  41129. get performanceMonitor(): PerformanceMonitor;
  41130. private _onFocus;
  41131. private _onBlur;
  41132. private _onCanvasPointerOut;
  41133. private _onCanvasBlur;
  41134. private _onCanvasFocus;
  41135. private _onFullscreenChange;
  41136. private _onPointerLockChange;
  41137. /**
  41138. * Gets the HTML element used to attach event listeners
  41139. * @returns a HTML element
  41140. */
  41141. getInputElement(): Nullable<HTMLElement>;
  41142. /**
  41143. * Creates a new engine
  41144. * @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
  41145. * @param antialias defines enable antialiasing (default: false)
  41146. * @param options defines further options to be sent to the getContext() function
  41147. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41148. */
  41149. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41150. /**
  41151. * Gets current aspect ratio
  41152. * @param viewportOwner defines the camera to use to get the aspect ratio
  41153. * @param useScreen defines if screen size must be used (or the current render target if any)
  41154. * @returns a number defining the aspect ratio
  41155. */
  41156. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  41157. /**
  41158. * Gets current screen aspect ratio
  41159. * @returns a number defining the aspect ratio
  41160. */
  41161. getScreenAspectRatio(): number;
  41162. /**
  41163. * Gets the client rect of the HTML canvas attached with the current webGL context
  41164. * @returns a client rectanglee
  41165. */
  41166. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  41167. /**
  41168. * Gets the client rect of the HTML element used for events
  41169. * @returns a client rectanglee
  41170. */
  41171. getInputElementClientRect(): Nullable<ClientRect>;
  41172. /**
  41173. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  41174. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41175. * @returns true if engine is in deterministic lock step mode
  41176. */
  41177. isDeterministicLockStep(): boolean;
  41178. /**
  41179. * Gets the max steps when engine is running in deterministic lock step
  41180. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41181. * @returns the max steps
  41182. */
  41183. getLockstepMaxSteps(): number;
  41184. /**
  41185. * Returns the time in ms between steps when using deterministic lock step.
  41186. * @returns time step in (ms)
  41187. */
  41188. getTimeStep(): number;
  41189. /**
  41190. * Force the mipmap generation for the given render target texture
  41191. * @param texture defines the render target texture to use
  41192. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  41193. */
  41194. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  41195. /** States */
  41196. /**
  41197. * Set various states to the webGL context
  41198. * @param culling defines backface culling state
  41199. * @param zOffset defines the value to apply to zOffset (0 by default)
  41200. * @param force defines if states must be applied even if cache is up to date
  41201. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  41202. */
  41203. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41204. /**
  41205. * Set the z offset to apply to current rendering
  41206. * @param value defines the offset to apply
  41207. */
  41208. setZOffset(value: number): void;
  41209. /**
  41210. * Gets the current value of the zOffset
  41211. * @returns the current zOffset state
  41212. */
  41213. getZOffset(): number;
  41214. /**
  41215. * Enable or disable depth buffering
  41216. * @param enable defines the state to set
  41217. */
  41218. setDepthBuffer(enable: boolean): void;
  41219. /**
  41220. * Gets a boolean indicating if depth writing is enabled
  41221. * @returns the current depth writing state
  41222. */
  41223. getDepthWrite(): boolean;
  41224. /**
  41225. * Enable or disable depth writing
  41226. * @param enable defines the state to set
  41227. */
  41228. setDepthWrite(enable: boolean): void;
  41229. /**
  41230. * Gets a boolean indicating if stencil buffer is enabled
  41231. * @returns the current stencil buffer state
  41232. */
  41233. getStencilBuffer(): boolean;
  41234. /**
  41235. * Enable or disable the stencil buffer
  41236. * @param enable defines if the stencil buffer must be enabled or disabled
  41237. */
  41238. setStencilBuffer(enable: boolean): void;
  41239. /**
  41240. * Gets the current stencil mask
  41241. * @returns a number defining the new stencil mask to use
  41242. */
  41243. getStencilMask(): number;
  41244. /**
  41245. * Sets the current stencil mask
  41246. * @param mask defines the new stencil mask to use
  41247. */
  41248. setStencilMask(mask: number): void;
  41249. /**
  41250. * Gets the current stencil function
  41251. * @returns a number defining the stencil function to use
  41252. */
  41253. getStencilFunction(): number;
  41254. /**
  41255. * Gets the current stencil reference value
  41256. * @returns a number defining the stencil reference value to use
  41257. */
  41258. getStencilFunctionReference(): number;
  41259. /**
  41260. * Gets the current stencil mask
  41261. * @returns a number defining the stencil mask to use
  41262. */
  41263. getStencilFunctionMask(): number;
  41264. /**
  41265. * Sets the current stencil function
  41266. * @param stencilFunc defines the new stencil function to use
  41267. */
  41268. setStencilFunction(stencilFunc: number): void;
  41269. /**
  41270. * Sets the current stencil reference
  41271. * @param reference defines the new stencil reference to use
  41272. */
  41273. setStencilFunctionReference(reference: number): void;
  41274. /**
  41275. * Sets the current stencil mask
  41276. * @param mask defines the new stencil mask to use
  41277. */
  41278. setStencilFunctionMask(mask: number): void;
  41279. /**
  41280. * Gets the current stencil operation when stencil fails
  41281. * @returns a number defining stencil operation to use when stencil fails
  41282. */
  41283. getStencilOperationFail(): number;
  41284. /**
  41285. * Gets the current stencil operation when depth fails
  41286. * @returns a number defining stencil operation to use when depth fails
  41287. */
  41288. getStencilOperationDepthFail(): number;
  41289. /**
  41290. * Gets the current stencil operation when stencil passes
  41291. * @returns a number defining stencil operation to use when stencil passes
  41292. */
  41293. getStencilOperationPass(): number;
  41294. /**
  41295. * Sets the stencil operation to use when stencil fails
  41296. * @param operation defines the stencil operation to use when stencil fails
  41297. */
  41298. setStencilOperationFail(operation: number): void;
  41299. /**
  41300. * Sets the stencil operation to use when depth fails
  41301. * @param operation defines the stencil operation to use when depth fails
  41302. */
  41303. setStencilOperationDepthFail(operation: number): void;
  41304. /**
  41305. * Sets the stencil operation to use when stencil passes
  41306. * @param operation defines the stencil operation to use when stencil passes
  41307. */
  41308. setStencilOperationPass(operation: number): void;
  41309. /**
  41310. * Sets a boolean indicating if the dithering state is enabled or disabled
  41311. * @param value defines the dithering state
  41312. */
  41313. setDitheringState(value: boolean): void;
  41314. /**
  41315. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41316. * @param value defines the rasterizer state
  41317. */
  41318. setRasterizerState(value: boolean): void;
  41319. /**
  41320. * Gets the current depth function
  41321. * @returns a number defining the depth function
  41322. */
  41323. getDepthFunction(): Nullable<number>;
  41324. /**
  41325. * Sets the current depth function
  41326. * @param depthFunc defines the function to use
  41327. */
  41328. setDepthFunction(depthFunc: number): void;
  41329. /**
  41330. * Sets the current depth function to GREATER
  41331. */
  41332. setDepthFunctionToGreater(): void;
  41333. /**
  41334. * Sets the current depth function to GEQUAL
  41335. */
  41336. setDepthFunctionToGreaterOrEqual(): void;
  41337. /**
  41338. * Sets the current depth function to LESS
  41339. */
  41340. setDepthFunctionToLess(): void;
  41341. /**
  41342. * Sets the current depth function to LEQUAL
  41343. */
  41344. setDepthFunctionToLessOrEqual(): void;
  41345. private _cachedStencilBuffer;
  41346. private _cachedStencilFunction;
  41347. private _cachedStencilMask;
  41348. private _cachedStencilOperationPass;
  41349. private _cachedStencilOperationFail;
  41350. private _cachedStencilOperationDepthFail;
  41351. private _cachedStencilReference;
  41352. /**
  41353. * Caches the the state of the stencil buffer
  41354. */
  41355. cacheStencilState(): void;
  41356. /**
  41357. * Restores the state of the stencil buffer
  41358. */
  41359. restoreStencilState(): void;
  41360. /**
  41361. * Directly set the WebGL Viewport
  41362. * @param x defines the x coordinate of the viewport (in screen space)
  41363. * @param y defines the y coordinate of the viewport (in screen space)
  41364. * @param width defines the width of the viewport (in screen space)
  41365. * @param height defines the height of the viewport (in screen space)
  41366. * @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
  41367. */
  41368. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41369. /**
  41370. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41371. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41372. * @param y defines the y-coordinate of the corner of the clear rectangle
  41373. * @param width defines the width of the clear rectangle
  41374. * @param height defines the height of the clear rectangle
  41375. * @param clearColor defines the clear color
  41376. */
  41377. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41378. /**
  41379. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41380. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41381. * @param y defines the y-coordinate of the corner of the clear rectangle
  41382. * @param width defines the width of the clear rectangle
  41383. * @param height defines the height of the clear rectangle
  41384. */
  41385. enableScissor(x: number, y: number, width: number, height: number): void;
  41386. /**
  41387. * Disable previously set scissor test rectangle
  41388. */
  41389. disableScissor(): void;
  41390. protected _reportDrawCall(): void;
  41391. /**
  41392. * Initializes a webVR display and starts listening to display change events
  41393. * The onVRDisplayChangedObservable will be notified upon these changes
  41394. * @returns The onVRDisplayChangedObservable
  41395. */
  41396. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41397. /** @hidden */
  41398. _prepareVRComponent(): void;
  41399. /** @hidden */
  41400. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41401. /** @hidden */
  41402. _submitVRFrame(): void;
  41403. /**
  41404. * Call this function to leave webVR mode
  41405. * Will do nothing if webVR is not supported or if there is no webVR device
  41406. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41407. */
  41408. disableVR(): void;
  41409. /**
  41410. * Gets a boolean indicating that the system is in VR mode and is presenting
  41411. * @returns true if VR mode is engaged
  41412. */
  41413. isVRPresenting(): boolean;
  41414. /** @hidden */
  41415. _requestVRFrame(): void;
  41416. /** @hidden */
  41417. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41418. /**
  41419. * Gets the source code of the vertex shader associated with a specific webGL program
  41420. * @param program defines the program to use
  41421. * @returns a string containing the source code of the vertex shader associated with the program
  41422. */
  41423. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41424. /**
  41425. * Gets the source code of the fragment shader associated with a specific webGL program
  41426. * @param program defines the program to use
  41427. * @returns a string containing the source code of the fragment shader associated with the program
  41428. */
  41429. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41430. /**
  41431. * Sets a depth stencil texture from a render target to the according uniform.
  41432. * @param channel The texture channel
  41433. * @param uniform The uniform to set
  41434. * @param texture The render target texture containing the depth stencil texture to apply
  41435. */
  41436. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41437. /**
  41438. * Sets a texture to the webGL context from a postprocess
  41439. * @param channel defines the channel to use
  41440. * @param postProcess defines the source postprocess
  41441. */
  41442. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41443. /**
  41444. * Binds the output of the passed in post process to the texture channel specified
  41445. * @param channel The channel the texture should be bound to
  41446. * @param postProcess The post process which's output should be bound
  41447. */
  41448. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41449. protected _rebuildBuffers(): void;
  41450. /** @hidden */
  41451. _renderFrame(): void;
  41452. _renderLoop(): void;
  41453. /** @hidden */
  41454. _renderViews(): boolean;
  41455. /**
  41456. * Toggle full screen mode
  41457. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41458. */
  41459. switchFullscreen(requestPointerLock: boolean): void;
  41460. /**
  41461. * Enters full screen mode
  41462. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41463. */
  41464. enterFullscreen(requestPointerLock: boolean): void;
  41465. /**
  41466. * Exits full screen mode
  41467. */
  41468. exitFullscreen(): void;
  41469. /**
  41470. * Enters Pointerlock mode
  41471. */
  41472. enterPointerlock(): void;
  41473. /**
  41474. * Exits Pointerlock mode
  41475. */
  41476. exitPointerlock(): void;
  41477. /**
  41478. * Begin a new frame
  41479. */
  41480. beginFrame(): void;
  41481. /**
  41482. * Enf the current frame
  41483. */
  41484. endFrame(): void;
  41485. resize(): void;
  41486. /**
  41487. * Force a specific size of the canvas
  41488. * @param width defines the new canvas' width
  41489. * @param height defines the new canvas' height
  41490. * @returns true if the size was changed
  41491. */
  41492. setSize(width: number, height: number): boolean;
  41493. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41494. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41495. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41496. _releaseTexture(texture: InternalTexture): void;
  41497. /**
  41498. * @hidden
  41499. * Rescales a texture
  41500. * @param source input texutre
  41501. * @param destination destination texture
  41502. * @param scene scene to use to render the resize
  41503. * @param internalFormat format to use when resizing
  41504. * @param onComplete callback to be called when resize has completed
  41505. */
  41506. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41507. /**
  41508. * Gets the current framerate
  41509. * @returns a number representing the framerate
  41510. */
  41511. getFps(): number;
  41512. /**
  41513. * Gets the time spent between current and previous frame
  41514. * @returns a number representing the delta time in ms
  41515. */
  41516. getDeltaTime(): number;
  41517. private _measureFps;
  41518. /** @hidden */
  41519. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41520. /**
  41521. * Updates the sample count of a render target texture
  41522. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41523. * @param texture defines the texture to update
  41524. * @param samples defines the sample count to set
  41525. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41526. */
  41527. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41528. /**
  41529. * Updates a depth texture Comparison Mode and Function.
  41530. * If the comparison Function is equal to 0, the mode will be set to none.
  41531. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41532. * @param texture The texture to set the comparison function for
  41533. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41534. */
  41535. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41536. /**
  41537. * Creates a webGL buffer to use with instanciation
  41538. * @param capacity defines the size of the buffer
  41539. * @returns the webGL buffer
  41540. */
  41541. createInstancesBuffer(capacity: number): DataBuffer;
  41542. /**
  41543. * Delete a webGL buffer used with instanciation
  41544. * @param buffer defines the webGL buffer to delete
  41545. */
  41546. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41547. private _clientWaitAsync;
  41548. /** @hidden */
  41549. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41550. dispose(): void;
  41551. private _disableTouchAction;
  41552. /**
  41553. * Display the loading screen
  41554. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41555. */
  41556. displayLoadingUI(): void;
  41557. /**
  41558. * Hide the loading screen
  41559. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41560. */
  41561. hideLoadingUI(): void;
  41562. /**
  41563. * Gets the current loading screen object
  41564. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41565. */
  41566. get loadingScreen(): ILoadingScreen;
  41567. /**
  41568. * Sets the current loading screen object
  41569. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41570. */
  41571. set loadingScreen(loadingScreen: ILoadingScreen);
  41572. /**
  41573. * Sets the current loading screen text
  41574. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41575. */
  41576. set loadingUIText(text: string);
  41577. /**
  41578. * Sets the current loading screen background color
  41579. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41580. */
  41581. set loadingUIBackgroundColor(color: string);
  41582. /** Pointerlock and fullscreen */
  41583. /**
  41584. * Ask the browser to promote the current element to pointerlock mode
  41585. * @param element defines the DOM element to promote
  41586. */
  41587. static _RequestPointerlock(element: HTMLElement): void;
  41588. /**
  41589. * Asks the browser to exit pointerlock mode
  41590. */
  41591. static _ExitPointerlock(): void;
  41592. /**
  41593. * Ask the browser to promote the current element to fullscreen rendering mode
  41594. * @param element defines the DOM element to promote
  41595. */
  41596. static _RequestFullscreen(element: HTMLElement): void;
  41597. /**
  41598. * Asks the browser to exit fullscreen mode
  41599. */
  41600. static _ExitFullscreen(): void;
  41601. }
  41602. }
  41603. declare module BABYLON {
  41604. /**
  41605. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41606. * during the life time of the application.
  41607. */
  41608. export class EngineStore {
  41609. /** Gets the list of created engines */
  41610. static Instances: Engine[];
  41611. /** @hidden */
  41612. static _LastCreatedScene: Nullable<Scene>;
  41613. /**
  41614. * Gets the latest created engine
  41615. */
  41616. static get LastCreatedEngine(): Nullable<Engine>;
  41617. /**
  41618. * Gets the latest created scene
  41619. */
  41620. static get LastCreatedScene(): Nullable<Scene>;
  41621. /**
  41622. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41623. * @ignorenaming
  41624. */
  41625. static UseFallbackTexture: boolean;
  41626. /**
  41627. * Texture content used if a texture cannot loaded
  41628. * @ignorenaming
  41629. */
  41630. static FallbackTexture: string;
  41631. }
  41632. }
  41633. declare module BABYLON {
  41634. /**
  41635. * Helper class that provides a small promise polyfill
  41636. */
  41637. export class PromisePolyfill {
  41638. /**
  41639. * Static function used to check if the polyfill is required
  41640. * If this is the case then the function will inject the polyfill to window.Promise
  41641. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41642. */
  41643. static Apply(force?: boolean): void;
  41644. }
  41645. }
  41646. declare module BABYLON {
  41647. /**
  41648. * Interface for screenshot methods with describe argument called `size` as object with options
  41649. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41650. */
  41651. export interface IScreenshotSize {
  41652. /**
  41653. * number in pixels for canvas height
  41654. */
  41655. height?: number;
  41656. /**
  41657. * multiplier allowing render at a higher or lower resolution
  41658. * If value is defined then height and width will be ignored and taken from camera
  41659. */
  41660. precision?: number;
  41661. /**
  41662. * number in pixels for canvas width
  41663. */
  41664. width?: number;
  41665. }
  41666. }
  41667. declare module BABYLON {
  41668. interface IColor4Like {
  41669. r: float;
  41670. g: float;
  41671. b: float;
  41672. a: float;
  41673. }
  41674. /**
  41675. * Class containing a set of static utilities functions
  41676. */
  41677. export class Tools {
  41678. /**
  41679. * Gets or sets the base URL to use to load assets
  41680. */
  41681. static get BaseUrl(): string;
  41682. static set BaseUrl(value: string);
  41683. /**
  41684. * Enable/Disable Custom HTTP Request Headers globally.
  41685. * default = false
  41686. * @see CustomRequestHeaders
  41687. */
  41688. static UseCustomRequestHeaders: boolean;
  41689. /**
  41690. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41691. * i.e. when loading files, where the server/service expects an Authorization header
  41692. */
  41693. static CustomRequestHeaders: {
  41694. [key: string]: string;
  41695. };
  41696. /**
  41697. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41698. */
  41699. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41700. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41701. /**
  41702. * Default behaviour for cors in the application.
  41703. * It can be a string if the expected behavior is identical in the entire app.
  41704. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41705. */
  41706. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41707. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41708. /**
  41709. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41710. * @ignorenaming
  41711. */
  41712. static get UseFallbackTexture(): boolean;
  41713. static set UseFallbackTexture(value: boolean);
  41714. /**
  41715. * Use this object to register external classes like custom textures or material
  41716. * to allow the laoders to instantiate them
  41717. */
  41718. static get RegisteredExternalClasses(): {
  41719. [key: string]: Object;
  41720. };
  41721. static set RegisteredExternalClasses(classes: {
  41722. [key: string]: Object;
  41723. });
  41724. /**
  41725. * Texture content used if a texture cannot loaded
  41726. * @ignorenaming
  41727. */
  41728. static get fallbackTexture(): string;
  41729. static set fallbackTexture(value: string);
  41730. /**
  41731. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41732. * @param u defines the coordinate on X axis
  41733. * @param v defines the coordinate on Y axis
  41734. * @param width defines the width of the source data
  41735. * @param height defines the height of the source data
  41736. * @param pixels defines the source byte array
  41737. * @param color defines the output color
  41738. */
  41739. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41740. /**
  41741. * Interpolates between a and b via alpha
  41742. * @param a The lower value (returned when alpha = 0)
  41743. * @param b The upper value (returned when alpha = 1)
  41744. * @param alpha The interpolation-factor
  41745. * @return The mixed value
  41746. */
  41747. static Mix(a: number, b: number, alpha: number): number;
  41748. /**
  41749. * Tries to instantiate a new object from a given class name
  41750. * @param className defines the class name to instantiate
  41751. * @returns the new object or null if the system was not able to do the instantiation
  41752. */
  41753. static Instantiate(className: string): any;
  41754. /**
  41755. * Provides a slice function that will work even on IE
  41756. * @param data defines the array to slice
  41757. * @param start defines the start of the data (optional)
  41758. * @param end defines the end of the data (optional)
  41759. * @returns the new sliced array
  41760. */
  41761. static Slice<T>(data: T, start?: number, end?: number): T;
  41762. /**
  41763. * Provides a slice function that will work even on IE
  41764. * The difference between this and Slice is that this will force-convert to array
  41765. * @param data defines the array to slice
  41766. * @param start defines the start of the data (optional)
  41767. * @param end defines the end of the data (optional)
  41768. * @returns the new sliced array
  41769. */
  41770. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41771. /**
  41772. * Polyfill for setImmediate
  41773. * @param action defines the action to execute after the current execution block
  41774. */
  41775. static SetImmediate(action: () => void): void;
  41776. /**
  41777. * Function indicating if a number is an exponent of 2
  41778. * @param value defines the value to test
  41779. * @returns true if the value is an exponent of 2
  41780. */
  41781. static IsExponentOfTwo(value: number): boolean;
  41782. private static _tmpFloatArray;
  41783. /**
  41784. * Returns the nearest 32-bit single precision float representation of a Number
  41785. * @param value A Number. If the parameter is of a different type, it will get converted
  41786. * to a number or to NaN if it cannot be converted
  41787. * @returns number
  41788. */
  41789. static FloatRound(value: number): number;
  41790. /**
  41791. * Extracts the filename from a path
  41792. * @param path defines the path to use
  41793. * @returns the filename
  41794. */
  41795. static GetFilename(path: string): string;
  41796. /**
  41797. * Extracts the "folder" part of a path (everything before the filename).
  41798. * @param uri The URI to extract the info from
  41799. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41800. * @returns The "folder" part of the path
  41801. */
  41802. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41803. /**
  41804. * Extracts text content from a DOM element hierarchy
  41805. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41806. */
  41807. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41808. /**
  41809. * Convert an angle in radians to degrees
  41810. * @param angle defines the angle to convert
  41811. * @returns the angle in degrees
  41812. */
  41813. static ToDegrees(angle: number): number;
  41814. /**
  41815. * Convert an angle in degrees to radians
  41816. * @param angle defines the angle to convert
  41817. * @returns the angle in radians
  41818. */
  41819. static ToRadians(angle: number): number;
  41820. /**
  41821. * Returns an array if obj is not an array
  41822. * @param obj defines the object to evaluate as an array
  41823. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41824. * @returns either obj directly if obj is an array or a new array containing obj
  41825. */
  41826. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41827. /**
  41828. * Gets the pointer prefix to use
  41829. * @param engine defines the engine we are finding the prefix for
  41830. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41831. */
  41832. static GetPointerPrefix(engine: Engine): string;
  41833. /**
  41834. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41835. * @param url define the url we are trying
  41836. * @param element define the dom element where to configure the cors policy
  41837. */
  41838. static SetCorsBehavior(url: string | string[], element: {
  41839. crossOrigin: string | null;
  41840. }): void;
  41841. /**
  41842. * Removes unwanted characters from an url
  41843. * @param url defines the url to clean
  41844. * @returns the cleaned url
  41845. */
  41846. static CleanUrl(url: string): string;
  41847. /**
  41848. * Gets or sets a function used to pre-process url before using them to load assets
  41849. */
  41850. static get PreprocessUrl(): (url: string) => string;
  41851. static set PreprocessUrl(processor: (url: string) => string);
  41852. /**
  41853. * Loads an image as an HTMLImageElement.
  41854. * @param input url string, ArrayBuffer, or Blob to load
  41855. * @param onLoad callback called when the image successfully loads
  41856. * @param onError callback called when the image fails to load
  41857. * @param offlineProvider offline provider for caching
  41858. * @param mimeType optional mime type
  41859. * @returns the HTMLImageElement of the loaded image
  41860. */
  41861. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41862. /**
  41863. * Loads a file from a url
  41864. * @param url url string, ArrayBuffer, or Blob to load
  41865. * @param onSuccess callback called when the file successfully loads
  41866. * @param onProgress callback called while file is loading (if the server supports this mode)
  41867. * @param offlineProvider defines the offline provider for caching
  41868. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41869. * @param onError callback called when the file fails to load
  41870. * @returns a file request object
  41871. */
  41872. 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;
  41873. /**
  41874. * Loads a file from a url
  41875. * @param url the file url to load
  41876. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41877. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41878. */
  41879. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41880. /**
  41881. * Load a script (identified by an url). When the url returns, the
  41882. * content of this file is added into a new script element, attached to the DOM (body element)
  41883. * @param scriptUrl defines the url of the script to laod
  41884. * @param onSuccess defines the callback called when the script is loaded
  41885. * @param onError defines the callback to call if an error occurs
  41886. * @param scriptId defines the id of the script element
  41887. */
  41888. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41889. /**
  41890. * Load an asynchronous script (identified by an url). When the url returns, the
  41891. * content of this file is added into a new script element, attached to the DOM (body element)
  41892. * @param scriptUrl defines the url of the script to laod
  41893. * @param scriptId defines the id of the script element
  41894. * @returns a promise request object
  41895. */
  41896. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41897. /**
  41898. * Loads a file from a blob
  41899. * @param fileToLoad defines the blob to use
  41900. * @param callback defines the callback to call when data is loaded
  41901. * @param progressCallback defines the callback to call during loading process
  41902. * @returns a file request object
  41903. */
  41904. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41905. /**
  41906. * Reads a file from a File object
  41907. * @param file defines the file to load
  41908. * @param onSuccess defines the callback to call when data is loaded
  41909. * @param onProgress defines the callback to call during loading process
  41910. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41911. * @param onError defines the callback to call when an error occurs
  41912. * @returns a file request object
  41913. */
  41914. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41915. /**
  41916. * Creates a data url from a given string content
  41917. * @param content defines the content to convert
  41918. * @returns the new data url link
  41919. */
  41920. static FileAsURL(content: string): string;
  41921. /**
  41922. * Format the given number to a specific decimal format
  41923. * @param value defines the number to format
  41924. * @param decimals defines the number of decimals to use
  41925. * @returns the formatted string
  41926. */
  41927. static Format(value: number, decimals?: number): string;
  41928. /**
  41929. * Tries to copy an object by duplicating every property
  41930. * @param source defines the source object
  41931. * @param destination defines the target object
  41932. * @param doNotCopyList defines a list of properties to avoid
  41933. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41934. */
  41935. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41936. /**
  41937. * Gets a boolean indicating if the given object has no own property
  41938. * @param obj defines the object to test
  41939. * @returns true if object has no own property
  41940. */
  41941. static IsEmpty(obj: any): boolean;
  41942. /**
  41943. * Function used to register events at window level
  41944. * @param windowElement defines the Window object to use
  41945. * @param events defines the events to register
  41946. */
  41947. static RegisterTopRootEvents(windowElement: Window, events: {
  41948. name: string;
  41949. handler: Nullable<(e: FocusEvent) => any>;
  41950. }[]): void;
  41951. /**
  41952. * Function used to unregister events from window level
  41953. * @param windowElement defines the Window object to use
  41954. * @param events defines the events to unregister
  41955. */
  41956. static UnregisterTopRootEvents(windowElement: Window, events: {
  41957. name: string;
  41958. handler: Nullable<(e: FocusEvent) => any>;
  41959. }[]): void;
  41960. /**
  41961. * @ignore
  41962. */
  41963. static _ScreenshotCanvas: HTMLCanvasElement;
  41964. /**
  41965. * Dumps the current bound framebuffer
  41966. * @param width defines the rendering width
  41967. * @param height defines the rendering height
  41968. * @param engine defines the hosting engine
  41969. * @param successCallback defines the callback triggered once the data are available
  41970. * @param mimeType defines the mime type of the result
  41971. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41972. */
  41973. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41974. /**
  41975. * Converts the canvas data to blob.
  41976. * This acts as a polyfill for browsers not supporting the to blob function.
  41977. * @param canvas Defines the canvas to extract the data from
  41978. * @param successCallback Defines the callback triggered once the data are available
  41979. * @param mimeType Defines the mime type of the result
  41980. */
  41981. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41982. /**
  41983. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41984. * @param successCallback defines the callback triggered once the data are available
  41985. * @param mimeType defines the mime type of the result
  41986. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41987. */
  41988. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41989. /**
  41990. * Downloads a blob in the browser
  41991. * @param blob defines the blob to download
  41992. * @param fileName defines the name of the downloaded file
  41993. */
  41994. static Download(blob: Blob, fileName: string): void;
  41995. /**
  41996. * Will return the right value of the noPreventDefault variable
  41997. * Needed to keep backwards compatibility to the old API.
  41998. *
  41999. * @param args arguments passed to the attachControl function
  42000. * @returns the correct value for noPreventDefault
  42001. */
  42002. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  42003. /**
  42004. * Captures a screenshot of the current rendering
  42005. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42006. * @param engine defines the rendering engine
  42007. * @param camera defines the source camera
  42008. * @param size This parameter can be set to a single number or to an object with the
  42009. * following (optional) properties: precision, width, height. If a single number is passed,
  42010. * it will be used for both width and height. If an object is passed, the screenshot size
  42011. * will be derived from the parameters. The precision property is a multiplier allowing
  42012. * rendering at a higher or lower resolution
  42013. * @param successCallback defines the callback receives a single parameter which contains the
  42014. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42015. * src parameter of an <img> to display it
  42016. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42017. * Check your browser for supported MIME types
  42018. */
  42019. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  42020. /**
  42021. * Captures a screenshot of the current rendering
  42022. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42023. * @param engine defines the rendering engine
  42024. * @param camera defines the source camera
  42025. * @param size This parameter can be set to a single number or to an object with the
  42026. * following (optional) properties: precision, width, height. If a single number is passed,
  42027. * it will be used for both width and height. If an object is passed, the screenshot size
  42028. * will be derived from the parameters. The precision property is a multiplier allowing
  42029. * rendering at a higher or lower resolution
  42030. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42031. * Check your browser for supported MIME types
  42032. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42033. * to the src parameter of an <img> to display it
  42034. */
  42035. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  42036. /**
  42037. * Generates an image screenshot from the specified camera.
  42038. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42039. * @param engine The engine to use for rendering
  42040. * @param camera The camera to use for rendering
  42041. * @param size This parameter can be set to a single number or to an object with the
  42042. * following (optional) properties: precision, width, height. If a single number is passed,
  42043. * it will be used for both width and height. If an object is passed, the screenshot size
  42044. * will be derived from the parameters. The precision property is a multiplier allowing
  42045. * rendering at a higher or lower resolution
  42046. * @param successCallback The callback receives a single parameter which contains the
  42047. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42048. * src parameter of an <img> to display it
  42049. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42050. * Check your browser for supported MIME types
  42051. * @param samples Texture samples (default: 1)
  42052. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42053. * @param fileName A name for for the downloaded file.
  42054. */
  42055. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  42056. /**
  42057. * Generates an image screenshot from the specified camera.
  42058. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42059. * @param engine The engine to use for rendering
  42060. * @param camera The camera to use for rendering
  42061. * @param size This parameter can be set to a single number or to an object with the
  42062. * following (optional) properties: precision, width, height. If a single number is passed,
  42063. * it will be used for both width and height. If an object is passed, the screenshot size
  42064. * will be derived from the parameters. The precision property is a multiplier allowing
  42065. * rendering at a higher or lower resolution
  42066. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42067. * Check your browser for supported MIME types
  42068. * @param samples Texture samples (default: 1)
  42069. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42070. * @param fileName A name for for the downloaded file.
  42071. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42072. * to the src parameter of an <img> to display it
  42073. */
  42074. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  42075. /**
  42076. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  42077. * Be aware Math.random() could cause collisions, but:
  42078. * "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"
  42079. * @returns a pseudo random id
  42080. */
  42081. static RandomId(): string;
  42082. /**
  42083. * Test if the given uri is a base64 string
  42084. * @param uri The uri to test
  42085. * @return True if the uri is a base64 string or false otherwise
  42086. */
  42087. static IsBase64(uri: string): boolean;
  42088. /**
  42089. * Decode the given base64 uri.
  42090. * @param uri The uri to decode
  42091. * @return The decoded base64 data.
  42092. */
  42093. static DecodeBase64(uri: string): ArrayBuffer;
  42094. /**
  42095. * Gets the absolute url.
  42096. * @param url the input url
  42097. * @return the absolute url
  42098. */
  42099. static GetAbsoluteUrl(url: string): string;
  42100. /**
  42101. * No log
  42102. */
  42103. static readonly NoneLogLevel: number;
  42104. /**
  42105. * Only message logs
  42106. */
  42107. static readonly MessageLogLevel: number;
  42108. /**
  42109. * Only warning logs
  42110. */
  42111. static readonly WarningLogLevel: number;
  42112. /**
  42113. * Only error logs
  42114. */
  42115. static readonly ErrorLogLevel: number;
  42116. /**
  42117. * All logs
  42118. */
  42119. static readonly AllLogLevel: number;
  42120. /**
  42121. * Gets a value indicating the number of loading errors
  42122. * @ignorenaming
  42123. */
  42124. static get errorsCount(): number;
  42125. /**
  42126. * Callback called when a new log is added
  42127. */
  42128. static OnNewCacheEntry: (entry: string) => void;
  42129. /**
  42130. * Log a message to the console
  42131. * @param message defines the message to log
  42132. */
  42133. static Log(message: string): void;
  42134. /**
  42135. * Write a warning message to the console
  42136. * @param message defines the message to log
  42137. */
  42138. static Warn(message: string): void;
  42139. /**
  42140. * Write an error message to the console
  42141. * @param message defines the message to log
  42142. */
  42143. static Error(message: string): void;
  42144. /**
  42145. * Gets current log cache (list of logs)
  42146. */
  42147. static get LogCache(): string;
  42148. /**
  42149. * Clears the log cache
  42150. */
  42151. static ClearLogCache(): void;
  42152. /**
  42153. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  42154. */
  42155. static set LogLevels(level: number);
  42156. /**
  42157. * Checks if the window object exists
  42158. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  42159. */
  42160. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  42161. /**
  42162. * No performance log
  42163. */
  42164. static readonly PerformanceNoneLogLevel: number;
  42165. /**
  42166. * Use user marks to log performance
  42167. */
  42168. static readonly PerformanceUserMarkLogLevel: number;
  42169. /**
  42170. * Log performance to the console
  42171. */
  42172. static readonly PerformanceConsoleLogLevel: number;
  42173. private static _performance;
  42174. /**
  42175. * Sets the current performance log level
  42176. */
  42177. static set PerformanceLogLevel(level: number);
  42178. private static _StartPerformanceCounterDisabled;
  42179. private static _EndPerformanceCounterDisabled;
  42180. private static _StartUserMark;
  42181. private static _EndUserMark;
  42182. private static _StartPerformanceConsole;
  42183. private static _EndPerformanceConsole;
  42184. /**
  42185. * Starts a performance counter
  42186. */
  42187. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42188. /**
  42189. * Ends a specific performance coutner
  42190. */
  42191. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42192. /**
  42193. * Gets either window.performance.now() if supported or Date.now() else
  42194. */
  42195. static get Now(): number;
  42196. /**
  42197. * This method will return the name of the class used to create the instance of the given object.
  42198. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  42199. * @param object the object to get the class name from
  42200. * @param isType defines if the object is actually a type
  42201. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  42202. */
  42203. static GetClassName(object: any, isType?: boolean): string;
  42204. /**
  42205. * Gets the first element of an array satisfying a given predicate
  42206. * @param array defines the array to browse
  42207. * @param predicate defines the predicate to use
  42208. * @returns null if not found or the element
  42209. */
  42210. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  42211. /**
  42212. * This method will return the name of the full name of the class, including its owning module (if any).
  42213. * 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).
  42214. * @param object the object to get the class name from
  42215. * @param isType defines if the object is actually a type
  42216. * @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.
  42217. * @ignorenaming
  42218. */
  42219. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  42220. /**
  42221. * Returns a promise that resolves after the given amount of time.
  42222. * @param delay Number of milliseconds to delay
  42223. * @returns Promise that resolves after the given amount of time
  42224. */
  42225. static DelayAsync(delay: number): Promise<void>;
  42226. /**
  42227. * Utility function to detect if the current user agent is Safari
  42228. * @returns whether or not the current user agent is safari
  42229. */
  42230. static IsSafari(): boolean;
  42231. }
  42232. /**
  42233. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42234. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42235. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42236. * @param name The name of the class, case should be preserved
  42237. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42238. */
  42239. export function className(name: string, module?: string): (target: Object) => void;
  42240. /**
  42241. * An implementation of a loop for asynchronous functions.
  42242. */
  42243. export class AsyncLoop {
  42244. /**
  42245. * Defines the number of iterations for the loop
  42246. */
  42247. iterations: number;
  42248. /**
  42249. * Defines the current index of the loop.
  42250. */
  42251. index: number;
  42252. private _done;
  42253. private _fn;
  42254. private _successCallback;
  42255. /**
  42256. * Constructor.
  42257. * @param iterations the number of iterations.
  42258. * @param func the function to run each iteration
  42259. * @param successCallback the callback that will be called upon succesful execution
  42260. * @param offset starting offset.
  42261. */
  42262. constructor(
  42263. /**
  42264. * Defines the number of iterations for the loop
  42265. */
  42266. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42267. /**
  42268. * Execute the next iteration. Must be called after the last iteration was finished.
  42269. */
  42270. executeNext(): void;
  42271. /**
  42272. * Break the loop and run the success callback.
  42273. */
  42274. breakLoop(): void;
  42275. /**
  42276. * Create and run an async loop.
  42277. * @param iterations the number of iterations.
  42278. * @param fn the function to run each iteration
  42279. * @param successCallback the callback that will be called upon succesful execution
  42280. * @param offset starting offset.
  42281. * @returns the created async loop object
  42282. */
  42283. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42284. /**
  42285. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42286. * @param iterations total number of iterations
  42287. * @param syncedIterations number of synchronous iterations in each async iteration.
  42288. * @param fn the function to call each iteration.
  42289. * @param callback a success call back that will be called when iterating stops.
  42290. * @param breakFunction a break condition (optional)
  42291. * @param timeout timeout settings for the setTimeout function. default - 0.
  42292. * @returns the created async loop object
  42293. */
  42294. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42295. }
  42296. }
  42297. declare module BABYLON {
  42298. /**
  42299. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42300. * The underlying implementation relies on an associative array to ensure the best performances.
  42301. * The value can be anything including 'null' but except 'undefined'
  42302. */
  42303. export class StringDictionary<T> {
  42304. /**
  42305. * This will clear this dictionary and copy the content from the 'source' one.
  42306. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42307. * @param source the dictionary to take the content from and copy to this dictionary
  42308. */
  42309. copyFrom(source: StringDictionary<T>): void;
  42310. /**
  42311. * Get a value based from its key
  42312. * @param key the given key to get the matching value from
  42313. * @return the value if found, otherwise undefined is returned
  42314. */
  42315. get(key: string): T | undefined;
  42316. /**
  42317. * Get a value from its key or add it if it doesn't exist.
  42318. * This method will ensure you that a given key/data will be present in the dictionary.
  42319. * @param key the given key to get the matching value from
  42320. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42321. * The factory will only be invoked if there's no data for the given key.
  42322. * @return the value corresponding to the key.
  42323. */
  42324. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42325. /**
  42326. * Get a value from its key if present in the dictionary otherwise add it
  42327. * @param key the key to get the value from
  42328. * @param val if there's no such key/value pair in the dictionary add it with this value
  42329. * @return the value corresponding to the key
  42330. */
  42331. getOrAdd(key: string, val: T): T;
  42332. /**
  42333. * Check if there's a given key in the dictionary
  42334. * @param key the key to check for
  42335. * @return true if the key is present, false otherwise
  42336. */
  42337. contains(key: string): boolean;
  42338. /**
  42339. * Add a new key and its corresponding value
  42340. * @param key the key to add
  42341. * @param value the value corresponding to the key
  42342. * @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
  42343. */
  42344. add(key: string, value: T): boolean;
  42345. /**
  42346. * Update a specific value associated to a key
  42347. * @param key defines the key to use
  42348. * @param value defines the value to store
  42349. * @returns true if the value was updated (or false if the key was not found)
  42350. */
  42351. set(key: string, value: T): boolean;
  42352. /**
  42353. * Get the element of the given key and remove it from the dictionary
  42354. * @param key defines the key to search
  42355. * @returns the value associated with the key or null if not found
  42356. */
  42357. getAndRemove(key: string): Nullable<T>;
  42358. /**
  42359. * Remove a key/value from the dictionary.
  42360. * @param key the key to remove
  42361. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42362. */
  42363. remove(key: string): boolean;
  42364. /**
  42365. * Clear the whole content of the dictionary
  42366. */
  42367. clear(): void;
  42368. /**
  42369. * Gets the current count
  42370. */
  42371. get count(): number;
  42372. /**
  42373. * Execute a callback on each key/val of the dictionary.
  42374. * Note that you can remove any element in this dictionary in the callback implementation
  42375. * @param callback the callback to execute on a given key/value pair
  42376. */
  42377. forEach(callback: (key: string, val: T) => void): void;
  42378. /**
  42379. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42380. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42381. * Note that you can remove any element in this dictionary in the callback implementation
  42382. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42383. * @returns the first item
  42384. */
  42385. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42386. private _count;
  42387. private _data;
  42388. }
  42389. }
  42390. declare module BABYLON {
  42391. /** @hidden */
  42392. export interface ICollisionCoordinator {
  42393. createCollider(): Collider;
  42394. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42395. init(scene: Scene): void;
  42396. }
  42397. /** @hidden */
  42398. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42399. private _scene;
  42400. private _scaledPosition;
  42401. private _scaledVelocity;
  42402. private _finalPosition;
  42403. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42404. createCollider(): Collider;
  42405. init(scene: Scene): void;
  42406. private _collideWithWorld;
  42407. }
  42408. }
  42409. declare module BABYLON {
  42410. /**
  42411. * Class used to manage all inputs for the scene.
  42412. */
  42413. export class InputManager {
  42414. /** The distance in pixel that you have to move to prevent some events */
  42415. static DragMovementThreshold: number;
  42416. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42417. static LongPressDelay: number;
  42418. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42419. static DoubleClickDelay: number;
  42420. /** If you need to check double click without raising a single click at first click, enable this flag */
  42421. static ExclusiveDoubleClickMode: boolean;
  42422. /** 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. */
  42423. private _alreadyAttached;
  42424. private _alreadyAttachedTo;
  42425. private _wheelEventName;
  42426. private _onPointerMove;
  42427. private _onPointerDown;
  42428. private _onPointerUp;
  42429. private _initClickEvent;
  42430. private _initActionManager;
  42431. private _delayedSimpleClick;
  42432. private _delayedSimpleClickTimeout;
  42433. private _previousDelayedSimpleClickTimeout;
  42434. private _meshPickProceed;
  42435. private _previousButtonPressed;
  42436. private _currentPickResult;
  42437. private _previousPickResult;
  42438. private _totalPointersPressed;
  42439. private _doubleClickOccured;
  42440. private _pointerOverMesh;
  42441. private _pickedDownMesh;
  42442. private _pickedUpMesh;
  42443. private _pointerX;
  42444. private _pointerY;
  42445. private _unTranslatedPointerX;
  42446. private _unTranslatedPointerY;
  42447. private _startingPointerPosition;
  42448. private _previousStartingPointerPosition;
  42449. private _startingPointerTime;
  42450. private _previousStartingPointerTime;
  42451. private _pointerCaptures;
  42452. private _meshUnderPointerId;
  42453. private _onKeyDown;
  42454. private _onKeyUp;
  42455. private _keyboardIsAttached;
  42456. private _onCanvasFocusObserver;
  42457. private _onCanvasBlurObserver;
  42458. private _scene;
  42459. /**
  42460. * Creates a new InputManager
  42461. * @param scene defines the hosting scene
  42462. */
  42463. constructor(scene: Scene);
  42464. /**
  42465. * Gets the mesh that is currently under the pointer
  42466. */
  42467. get meshUnderPointer(): Nullable<AbstractMesh>;
  42468. /**
  42469. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42470. * @param pointerId the pointer id to use
  42471. * @returns The mesh under this pointer id or null if not found
  42472. */
  42473. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42474. /**
  42475. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42476. */
  42477. get unTranslatedPointer(): Vector2;
  42478. /**
  42479. * Gets or sets the current on-screen X position of the pointer
  42480. */
  42481. get pointerX(): number;
  42482. set pointerX(value: number);
  42483. /**
  42484. * Gets or sets the current on-screen Y position of the pointer
  42485. */
  42486. get pointerY(): number;
  42487. set pointerY(value: number);
  42488. private _updatePointerPosition;
  42489. private _processPointerMove;
  42490. private _setRayOnPointerInfo;
  42491. private _checkPrePointerObservable;
  42492. /**
  42493. * Use this method to simulate a pointer move on a mesh
  42494. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42495. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42496. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42497. */
  42498. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42499. /**
  42500. * Use this method to simulate a pointer down on a mesh
  42501. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42502. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42503. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42504. */
  42505. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42506. private _processPointerDown;
  42507. /** @hidden */
  42508. _isPointerSwiping(): boolean;
  42509. /**
  42510. * Use this method to simulate a pointer up on a mesh
  42511. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42512. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42513. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42514. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42515. */
  42516. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42517. private _processPointerUp;
  42518. /**
  42519. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42520. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42521. * @returns true if the pointer was captured
  42522. */
  42523. isPointerCaptured(pointerId?: number): boolean;
  42524. /**
  42525. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42526. * @param attachUp defines if you want to attach events to pointerup
  42527. * @param attachDown defines if you want to attach events to pointerdown
  42528. * @param attachMove defines if you want to attach events to pointermove
  42529. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42530. */
  42531. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42532. /**
  42533. * Detaches all event handlers
  42534. */
  42535. detachControl(): void;
  42536. /**
  42537. * Force the value of meshUnderPointer
  42538. * @param mesh defines the mesh to use
  42539. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42540. */
  42541. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42542. /**
  42543. * Gets the mesh under the pointer
  42544. * @returns a Mesh or null if no mesh is under the pointer
  42545. */
  42546. getPointerOverMesh(): Nullable<AbstractMesh>;
  42547. }
  42548. }
  42549. declare module BABYLON {
  42550. /**
  42551. * This class defines the direct association between an animation and a target
  42552. */
  42553. export class TargetedAnimation {
  42554. /**
  42555. * Animation to perform
  42556. */
  42557. animation: Animation;
  42558. /**
  42559. * Target to animate
  42560. */
  42561. target: any;
  42562. /**
  42563. * Returns the string "TargetedAnimation"
  42564. * @returns "TargetedAnimation"
  42565. */
  42566. getClassName(): string;
  42567. /**
  42568. * Serialize the object
  42569. * @returns the JSON object representing the current entity
  42570. */
  42571. serialize(): any;
  42572. }
  42573. /**
  42574. * Use this class to create coordinated animations on multiple targets
  42575. */
  42576. export class AnimationGroup implements IDisposable {
  42577. /** The name of the animation group */
  42578. name: string;
  42579. private _scene;
  42580. private _targetedAnimations;
  42581. private _animatables;
  42582. private _from;
  42583. private _to;
  42584. private _isStarted;
  42585. private _isPaused;
  42586. private _speedRatio;
  42587. private _loopAnimation;
  42588. private _isAdditive;
  42589. /**
  42590. * Gets or sets the unique id of the node
  42591. */
  42592. uniqueId: number;
  42593. /**
  42594. * This observable will notify when one animation have ended
  42595. */
  42596. onAnimationEndObservable: Observable<TargetedAnimation>;
  42597. /**
  42598. * Observer raised when one animation loops
  42599. */
  42600. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42601. /**
  42602. * Observer raised when all animations have looped
  42603. */
  42604. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42605. /**
  42606. * This observable will notify when all animations have ended.
  42607. */
  42608. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42609. /**
  42610. * This observable will notify when all animations have paused.
  42611. */
  42612. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42613. /**
  42614. * This observable will notify when all animations are playing.
  42615. */
  42616. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42617. /**
  42618. * Gets the first frame
  42619. */
  42620. get from(): number;
  42621. /**
  42622. * Gets the last frame
  42623. */
  42624. get to(): number;
  42625. /**
  42626. * Define if the animations are started
  42627. */
  42628. get isStarted(): boolean;
  42629. /**
  42630. * Gets a value indicating that the current group is playing
  42631. */
  42632. get isPlaying(): boolean;
  42633. /**
  42634. * Gets or sets the speed ratio to use for all animations
  42635. */
  42636. get speedRatio(): number;
  42637. /**
  42638. * Gets or sets the speed ratio to use for all animations
  42639. */
  42640. set speedRatio(value: number);
  42641. /**
  42642. * Gets or sets if all animations should loop or not
  42643. */
  42644. get loopAnimation(): boolean;
  42645. set loopAnimation(value: boolean);
  42646. /**
  42647. * Gets or sets if all animations should be evaluated additively
  42648. */
  42649. get isAdditive(): boolean;
  42650. set isAdditive(value: boolean);
  42651. /**
  42652. * Gets the targeted animations for this animation group
  42653. */
  42654. get targetedAnimations(): Array<TargetedAnimation>;
  42655. /**
  42656. * returning the list of animatables controlled by this animation group.
  42657. */
  42658. get animatables(): Array<Animatable>;
  42659. /**
  42660. * Gets the list of target animations
  42661. */
  42662. get children(): TargetedAnimation[];
  42663. /**
  42664. * Instantiates a new Animation Group.
  42665. * This helps managing several animations at once.
  42666. * @see https://doc.babylonjs.com/how_to/group
  42667. * @param name Defines the name of the group
  42668. * @param scene Defines the scene the group belongs to
  42669. */
  42670. constructor(
  42671. /** The name of the animation group */
  42672. name: string, scene?: Nullable<Scene>);
  42673. /**
  42674. * Add an animation (with its target) in the group
  42675. * @param animation defines the animation we want to add
  42676. * @param target defines the target of the animation
  42677. * @returns the TargetedAnimation object
  42678. */
  42679. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42680. /**
  42681. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42682. * It can add constant keys at begin or end
  42683. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42684. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42685. * @returns the animation group
  42686. */
  42687. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42688. private _animationLoopCount;
  42689. private _animationLoopFlags;
  42690. private _processLoop;
  42691. /**
  42692. * Start all animations on given targets
  42693. * @param loop defines if animations must loop
  42694. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42695. * @param from defines the from key (optional)
  42696. * @param to defines the to key (optional)
  42697. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42698. * @returns the current animation group
  42699. */
  42700. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42701. /**
  42702. * Pause all animations
  42703. * @returns the animation group
  42704. */
  42705. pause(): AnimationGroup;
  42706. /**
  42707. * Play all animations to initial state
  42708. * This function will start() the animations if they were not started or will restart() them if they were paused
  42709. * @param loop defines if animations must loop
  42710. * @returns the animation group
  42711. */
  42712. play(loop?: boolean): AnimationGroup;
  42713. /**
  42714. * Reset all animations to initial state
  42715. * @returns the animation group
  42716. */
  42717. reset(): AnimationGroup;
  42718. /**
  42719. * Restart animations from key 0
  42720. * @returns the animation group
  42721. */
  42722. restart(): AnimationGroup;
  42723. /**
  42724. * Stop all animations
  42725. * @returns the animation group
  42726. */
  42727. stop(): AnimationGroup;
  42728. /**
  42729. * Set animation weight for all animatables
  42730. * @param weight defines the weight to use
  42731. * @return the animationGroup
  42732. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42733. */
  42734. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42735. /**
  42736. * Synchronize and normalize all animatables with a source animatable
  42737. * @param root defines the root animatable to synchronize with
  42738. * @return the animationGroup
  42739. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42740. */
  42741. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42742. /**
  42743. * Goes to a specific frame in this animation group
  42744. * @param frame the frame number to go to
  42745. * @return the animationGroup
  42746. */
  42747. goToFrame(frame: number): AnimationGroup;
  42748. /**
  42749. * Dispose all associated resources
  42750. */
  42751. dispose(): void;
  42752. private _checkAnimationGroupEnded;
  42753. /**
  42754. * Clone the current animation group and returns a copy
  42755. * @param newName defines the name of the new group
  42756. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42757. * @returns the new aniamtion group
  42758. */
  42759. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42760. /**
  42761. * Serializes the animationGroup to an object
  42762. * @returns Serialized object
  42763. */
  42764. serialize(): any;
  42765. /**
  42766. * Returns a new AnimationGroup object parsed from the source provided.
  42767. * @param parsedAnimationGroup defines the source
  42768. * @param scene defines the scene that will receive the animationGroup
  42769. * @returns a new AnimationGroup
  42770. */
  42771. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42772. /**
  42773. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42774. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42775. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42776. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42777. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42778. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42779. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42780. */
  42781. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42782. /**
  42783. * Returns the string "AnimationGroup"
  42784. * @returns "AnimationGroup"
  42785. */
  42786. getClassName(): string;
  42787. /**
  42788. * Creates a detailled string about the object
  42789. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42790. * @returns a string representing the object
  42791. */
  42792. toString(fullDetails?: boolean): string;
  42793. }
  42794. }
  42795. declare module BABYLON {
  42796. /**
  42797. * Define an interface for all classes that will hold resources
  42798. */
  42799. export interface IDisposable {
  42800. /**
  42801. * Releases all held resources
  42802. */
  42803. dispose(): void;
  42804. }
  42805. /** Interface defining initialization parameters for Scene class */
  42806. export interface SceneOptions {
  42807. /**
  42808. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42809. * It will improve performance when the number of geometries becomes important.
  42810. */
  42811. useGeometryUniqueIdsMap?: boolean;
  42812. /**
  42813. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42814. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42815. */
  42816. useMaterialMeshMap?: boolean;
  42817. /**
  42818. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42819. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42820. */
  42821. useClonedMeshMap?: boolean;
  42822. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42823. virtual?: boolean;
  42824. }
  42825. /**
  42826. * Represents a scene to be rendered by the engine.
  42827. * @see https://doc.babylonjs.com/features/scene
  42828. */
  42829. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42830. /** The fog is deactivated */
  42831. static readonly FOGMODE_NONE: number;
  42832. /** The fog density is following an exponential function */
  42833. static readonly FOGMODE_EXP: number;
  42834. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42835. static readonly FOGMODE_EXP2: number;
  42836. /** The fog density is following a linear function. */
  42837. static readonly FOGMODE_LINEAR: number;
  42838. /**
  42839. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42840. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42841. */
  42842. static MinDeltaTime: number;
  42843. /**
  42844. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42845. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42846. */
  42847. static MaxDeltaTime: number;
  42848. /**
  42849. * Factory used to create the default material.
  42850. * @param name The name of the material to create
  42851. * @param scene The scene to create the material for
  42852. * @returns The default material
  42853. */
  42854. static DefaultMaterialFactory(scene: Scene): Material;
  42855. /**
  42856. * Factory used to create the a collision coordinator.
  42857. * @returns The collision coordinator
  42858. */
  42859. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42860. /** @hidden */
  42861. _inputManager: InputManager;
  42862. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42863. cameraToUseForPointers: Nullable<Camera>;
  42864. /** @hidden */
  42865. readonly _isScene: boolean;
  42866. /** @hidden */
  42867. _blockEntityCollection: boolean;
  42868. /**
  42869. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42870. */
  42871. autoClear: boolean;
  42872. /**
  42873. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42874. */
  42875. autoClearDepthAndStencil: boolean;
  42876. /**
  42877. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42878. */
  42879. clearColor: Color4;
  42880. /**
  42881. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42882. */
  42883. ambientColor: Color3;
  42884. /**
  42885. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42886. * It should only be one of the following (if not the default embedded one):
  42887. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42888. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42889. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42890. * The material properties need to be setup according to the type of texture in use.
  42891. */
  42892. environmentBRDFTexture: BaseTexture;
  42893. /**
  42894. * Texture used in all pbr material as the reflection texture.
  42895. * As in the majority of the scene they are the same (exception for multi room and so on),
  42896. * this is easier to reference from here than from all the materials.
  42897. */
  42898. get environmentTexture(): Nullable<BaseTexture>;
  42899. /**
  42900. * Texture used in all pbr material as the reflection texture.
  42901. * As in the majority of the scene they are the same (exception for multi room and so on),
  42902. * this is easier to set here than in all the materials.
  42903. */
  42904. set environmentTexture(value: Nullable<BaseTexture>);
  42905. /** @hidden */
  42906. protected _environmentIntensity: number;
  42907. /**
  42908. * Intensity of the environment in all pbr material.
  42909. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42910. * As in the majority of the scene they are the same (exception for multi room and so on),
  42911. * this is easier to reference from here than from all the materials.
  42912. */
  42913. get environmentIntensity(): number;
  42914. /**
  42915. * Intensity of the environment in all pbr material.
  42916. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42917. * As in the majority of the scene they are the same (exception for multi room and so on),
  42918. * this is easier to set here than in all the materials.
  42919. */
  42920. set environmentIntensity(value: number);
  42921. /** @hidden */
  42922. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42923. /**
  42924. * Default image processing configuration used either in the rendering
  42925. * Forward main pass or through the imageProcessingPostProcess if present.
  42926. * As in the majority of the scene they are the same (exception for multi camera),
  42927. * this is easier to reference from here than from all the materials and post process.
  42928. *
  42929. * No setter as we it is a shared configuration, you can set the values instead.
  42930. */
  42931. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42932. private _forceWireframe;
  42933. /**
  42934. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42935. */
  42936. set forceWireframe(value: boolean);
  42937. get forceWireframe(): boolean;
  42938. private _skipFrustumClipping;
  42939. /**
  42940. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42941. */
  42942. set skipFrustumClipping(value: boolean);
  42943. get skipFrustumClipping(): boolean;
  42944. private _forcePointsCloud;
  42945. /**
  42946. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42947. */
  42948. set forcePointsCloud(value: boolean);
  42949. get forcePointsCloud(): boolean;
  42950. /**
  42951. * Gets or sets the active clipplane 1
  42952. */
  42953. clipPlane: Nullable<Plane>;
  42954. /**
  42955. * Gets or sets the active clipplane 2
  42956. */
  42957. clipPlane2: Nullable<Plane>;
  42958. /**
  42959. * Gets or sets the active clipplane 3
  42960. */
  42961. clipPlane3: Nullable<Plane>;
  42962. /**
  42963. * Gets or sets the active clipplane 4
  42964. */
  42965. clipPlane4: Nullable<Plane>;
  42966. /**
  42967. * Gets or sets the active clipplane 5
  42968. */
  42969. clipPlane5: Nullable<Plane>;
  42970. /**
  42971. * Gets or sets the active clipplane 6
  42972. */
  42973. clipPlane6: Nullable<Plane>;
  42974. /**
  42975. * Gets or sets a boolean indicating if animations are enabled
  42976. */
  42977. animationsEnabled: boolean;
  42978. private _animationPropertiesOverride;
  42979. /**
  42980. * Gets or sets the animation properties override
  42981. */
  42982. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42983. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42984. /**
  42985. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42986. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42987. */
  42988. useConstantAnimationDeltaTime: boolean;
  42989. /**
  42990. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42991. * Please note that it requires to run a ray cast through the scene on every frame
  42992. */
  42993. constantlyUpdateMeshUnderPointer: boolean;
  42994. /**
  42995. * Defines the HTML cursor to use when hovering over interactive elements
  42996. */
  42997. hoverCursor: string;
  42998. /**
  42999. * Defines the HTML default cursor to use (empty by default)
  43000. */
  43001. defaultCursor: string;
  43002. /**
  43003. * Defines whether cursors are handled by the scene.
  43004. */
  43005. doNotHandleCursors: boolean;
  43006. /**
  43007. * This is used to call preventDefault() on pointer down
  43008. * in order to block unwanted artifacts like system double clicks
  43009. */
  43010. preventDefaultOnPointerDown: boolean;
  43011. /**
  43012. * This is used to call preventDefault() on pointer up
  43013. * in order to block unwanted artifacts like system double clicks
  43014. */
  43015. preventDefaultOnPointerUp: boolean;
  43016. /**
  43017. * Gets or sets user defined metadata
  43018. */
  43019. metadata: any;
  43020. /**
  43021. * For internal use only. Please do not use.
  43022. */
  43023. reservedDataStore: any;
  43024. /**
  43025. * Gets the name of the plugin used to load this scene (null by default)
  43026. */
  43027. loadingPluginName: string;
  43028. /**
  43029. * Use this array to add regular expressions used to disable offline support for specific urls
  43030. */
  43031. disableOfflineSupportExceptionRules: RegExp[];
  43032. /**
  43033. * An event triggered when the scene is disposed.
  43034. */
  43035. onDisposeObservable: Observable<Scene>;
  43036. private _onDisposeObserver;
  43037. /** Sets a function to be executed when this scene is disposed. */
  43038. set onDispose(callback: () => void);
  43039. /**
  43040. * An event triggered before rendering the scene (right after animations and physics)
  43041. */
  43042. onBeforeRenderObservable: Observable<Scene>;
  43043. private _onBeforeRenderObserver;
  43044. /** Sets a function to be executed before rendering this scene */
  43045. set beforeRender(callback: Nullable<() => void>);
  43046. /**
  43047. * An event triggered after rendering the scene
  43048. */
  43049. onAfterRenderObservable: Observable<Scene>;
  43050. /**
  43051. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  43052. */
  43053. onAfterRenderCameraObservable: Observable<Camera>;
  43054. private _onAfterRenderObserver;
  43055. /** Sets a function to be executed after rendering this scene */
  43056. set afterRender(callback: Nullable<() => void>);
  43057. /**
  43058. * An event triggered before animating the scene
  43059. */
  43060. onBeforeAnimationsObservable: Observable<Scene>;
  43061. /**
  43062. * An event triggered after animations processing
  43063. */
  43064. onAfterAnimationsObservable: Observable<Scene>;
  43065. /**
  43066. * An event triggered before draw calls are ready to be sent
  43067. */
  43068. onBeforeDrawPhaseObservable: Observable<Scene>;
  43069. /**
  43070. * An event triggered after draw calls have been sent
  43071. */
  43072. onAfterDrawPhaseObservable: Observable<Scene>;
  43073. /**
  43074. * An event triggered when the scene is ready
  43075. */
  43076. onReadyObservable: Observable<Scene>;
  43077. /**
  43078. * An event triggered before rendering a camera
  43079. */
  43080. onBeforeCameraRenderObservable: Observable<Camera>;
  43081. private _onBeforeCameraRenderObserver;
  43082. /** Sets a function to be executed before rendering a camera*/
  43083. set beforeCameraRender(callback: () => void);
  43084. /**
  43085. * An event triggered after rendering a camera
  43086. */
  43087. onAfterCameraRenderObservable: Observable<Camera>;
  43088. private _onAfterCameraRenderObserver;
  43089. /** Sets a function to be executed after rendering a camera*/
  43090. set afterCameraRender(callback: () => void);
  43091. /**
  43092. * An event triggered when active meshes evaluation is about to start
  43093. */
  43094. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  43095. /**
  43096. * An event triggered when active meshes evaluation is done
  43097. */
  43098. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  43099. /**
  43100. * An event triggered when particles rendering is about to start
  43101. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43102. */
  43103. onBeforeParticlesRenderingObservable: Observable<Scene>;
  43104. /**
  43105. * An event triggered when particles rendering is done
  43106. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43107. */
  43108. onAfterParticlesRenderingObservable: Observable<Scene>;
  43109. /**
  43110. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  43111. */
  43112. onDataLoadedObservable: Observable<Scene>;
  43113. /**
  43114. * An event triggered when a camera is created
  43115. */
  43116. onNewCameraAddedObservable: Observable<Camera>;
  43117. /**
  43118. * An event triggered when a camera is removed
  43119. */
  43120. onCameraRemovedObservable: Observable<Camera>;
  43121. /**
  43122. * An event triggered when a light is created
  43123. */
  43124. onNewLightAddedObservable: Observable<Light>;
  43125. /**
  43126. * An event triggered when a light is removed
  43127. */
  43128. onLightRemovedObservable: Observable<Light>;
  43129. /**
  43130. * An event triggered when a geometry is created
  43131. */
  43132. onNewGeometryAddedObservable: Observable<Geometry>;
  43133. /**
  43134. * An event triggered when a geometry is removed
  43135. */
  43136. onGeometryRemovedObservable: Observable<Geometry>;
  43137. /**
  43138. * An event triggered when a transform node is created
  43139. */
  43140. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  43141. /**
  43142. * An event triggered when a transform node is removed
  43143. */
  43144. onTransformNodeRemovedObservable: Observable<TransformNode>;
  43145. /**
  43146. * An event triggered when a mesh is created
  43147. */
  43148. onNewMeshAddedObservable: Observable<AbstractMesh>;
  43149. /**
  43150. * An event triggered when a mesh is removed
  43151. */
  43152. onMeshRemovedObservable: Observable<AbstractMesh>;
  43153. /**
  43154. * An event triggered when a skeleton is created
  43155. */
  43156. onNewSkeletonAddedObservable: Observable<Skeleton>;
  43157. /**
  43158. * An event triggered when a skeleton is removed
  43159. */
  43160. onSkeletonRemovedObservable: Observable<Skeleton>;
  43161. /**
  43162. * An event triggered when a material is created
  43163. */
  43164. onNewMaterialAddedObservable: Observable<Material>;
  43165. /**
  43166. * An event triggered when a multi material is created
  43167. */
  43168. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  43169. /**
  43170. * An event triggered when a material is removed
  43171. */
  43172. onMaterialRemovedObservable: Observable<Material>;
  43173. /**
  43174. * An event triggered when a multi material is removed
  43175. */
  43176. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  43177. /**
  43178. * An event triggered when a texture is created
  43179. */
  43180. onNewTextureAddedObservable: Observable<BaseTexture>;
  43181. /**
  43182. * An event triggered when a texture is removed
  43183. */
  43184. onTextureRemovedObservable: Observable<BaseTexture>;
  43185. /**
  43186. * An event triggered when render targets are about to be rendered
  43187. * Can happen multiple times per frame.
  43188. */
  43189. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  43190. /**
  43191. * An event triggered when render targets were rendered.
  43192. * Can happen multiple times per frame.
  43193. */
  43194. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  43195. /**
  43196. * An event triggered before calculating deterministic simulation step
  43197. */
  43198. onBeforeStepObservable: Observable<Scene>;
  43199. /**
  43200. * An event triggered after calculating deterministic simulation step
  43201. */
  43202. onAfterStepObservable: Observable<Scene>;
  43203. /**
  43204. * An event triggered when the activeCamera property is updated
  43205. */
  43206. onActiveCameraChanged: Observable<Scene>;
  43207. /**
  43208. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  43209. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43210. * 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)
  43211. */
  43212. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43213. /**
  43214. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  43215. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43216. * 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)
  43217. */
  43218. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43219. /**
  43220. * This Observable will when a mesh has been imported into the scene.
  43221. */
  43222. onMeshImportedObservable: Observable<AbstractMesh>;
  43223. /**
  43224. * This Observable will when an animation file has been imported into the scene.
  43225. */
  43226. onAnimationFileImportedObservable: Observable<Scene>;
  43227. /**
  43228. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  43229. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  43230. */
  43231. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  43232. /** @hidden */
  43233. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  43234. /**
  43235. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  43236. */
  43237. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43238. /**
  43239. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43240. */
  43241. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43242. /**
  43243. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43244. */
  43245. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43246. /** Callback called when a pointer move is detected */
  43247. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43248. /** Callback called when a pointer down is detected */
  43249. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43250. /** Callback called when a pointer up is detected */
  43251. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43252. /** Callback called when a pointer pick is detected */
  43253. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43254. /**
  43255. * 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).
  43256. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43257. */
  43258. onPrePointerObservable: Observable<PointerInfoPre>;
  43259. /**
  43260. * Observable event triggered each time an input event is received from the rendering canvas
  43261. */
  43262. onPointerObservable: Observable<PointerInfo>;
  43263. /**
  43264. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43265. */
  43266. get unTranslatedPointer(): Vector2;
  43267. /**
  43268. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43269. */
  43270. static get DragMovementThreshold(): number;
  43271. static set DragMovementThreshold(value: number);
  43272. /**
  43273. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43274. */
  43275. static get LongPressDelay(): number;
  43276. static set LongPressDelay(value: number);
  43277. /**
  43278. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43279. */
  43280. static get DoubleClickDelay(): number;
  43281. static set DoubleClickDelay(value: number);
  43282. /** If you need to check double click without raising a single click at first click, enable this flag */
  43283. static get ExclusiveDoubleClickMode(): boolean;
  43284. static set ExclusiveDoubleClickMode(value: boolean);
  43285. /** @hidden */
  43286. _mirroredCameraPosition: Nullable<Vector3>;
  43287. /**
  43288. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43289. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43290. */
  43291. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43292. /**
  43293. * Observable event triggered each time an keyboard event is received from the hosting window
  43294. */
  43295. onKeyboardObservable: Observable<KeyboardInfo>;
  43296. private _useRightHandedSystem;
  43297. /**
  43298. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43299. */
  43300. set useRightHandedSystem(value: boolean);
  43301. get useRightHandedSystem(): boolean;
  43302. private _timeAccumulator;
  43303. private _currentStepId;
  43304. private _currentInternalStep;
  43305. /**
  43306. * Sets the step Id used by deterministic lock step
  43307. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43308. * @param newStepId defines the step Id
  43309. */
  43310. setStepId(newStepId: number): void;
  43311. /**
  43312. * Gets the step Id used by deterministic lock step
  43313. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43314. * @returns the step Id
  43315. */
  43316. getStepId(): number;
  43317. /**
  43318. * Gets the internal step used by deterministic lock step
  43319. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43320. * @returns the internal step
  43321. */
  43322. getInternalStep(): number;
  43323. private _fogEnabled;
  43324. /**
  43325. * Gets or sets a boolean indicating if fog is enabled on this scene
  43326. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43327. * (Default is true)
  43328. */
  43329. set fogEnabled(value: boolean);
  43330. get fogEnabled(): boolean;
  43331. private _fogMode;
  43332. /**
  43333. * Gets or sets the fog mode to use
  43334. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43335. * | mode | value |
  43336. * | --- | --- |
  43337. * | FOGMODE_NONE | 0 |
  43338. * | FOGMODE_EXP | 1 |
  43339. * | FOGMODE_EXP2 | 2 |
  43340. * | FOGMODE_LINEAR | 3 |
  43341. */
  43342. set fogMode(value: number);
  43343. get fogMode(): number;
  43344. /**
  43345. * Gets or sets the fog color to use
  43346. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43347. * (Default is Color3(0.2, 0.2, 0.3))
  43348. */
  43349. fogColor: Color3;
  43350. /**
  43351. * Gets or sets the fog density to use
  43352. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43353. * (Default is 0.1)
  43354. */
  43355. fogDensity: number;
  43356. /**
  43357. * Gets or sets the fog start distance to use
  43358. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43359. * (Default is 0)
  43360. */
  43361. fogStart: number;
  43362. /**
  43363. * Gets or sets the fog end distance to use
  43364. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43365. * (Default is 1000)
  43366. */
  43367. fogEnd: number;
  43368. /**
  43369. * Flag indicating that the frame buffer binding is handled by another component
  43370. */
  43371. prePass: boolean;
  43372. private _shadowsEnabled;
  43373. /**
  43374. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43375. */
  43376. set shadowsEnabled(value: boolean);
  43377. get shadowsEnabled(): boolean;
  43378. private _lightsEnabled;
  43379. /**
  43380. * Gets or sets a boolean indicating if lights are enabled on this scene
  43381. */
  43382. set lightsEnabled(value: boolean);
  43383. get lightsEnabled(): boolean;
  43384. /** All of the active cameras added to this scene. */
  43385. activeCameras: Camera[];
  43386. /** @hidden */
  43387. _activeCamera: Nullable<Camera>;
  43388. /** Gets or sets the current active camera */
  43389. get activeCamera(): Nullable<Camera>;
  43390. set activeCamera(value: Nullable<Camera>);
  43391. private _defaultMaterial;
  43392. /** The default material used on meshes when no material is affected */
  43393. get defaultMaterial(): Material;
  43394. /** The default material used on meshes when no material is affected */
  43395. set defaultMaterial(value: Material);
  43396. private _texturesEnabled;
  43397. /**
  43398. * Gets or sets a boolean indicating if textures are enabled on this scene
  43399. */
  43400. set texturesEnabled(value: boolean);
  43401. get texturesEnabled(): boolean;
  43402. /**
  43403. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43404. */
  43405. physicsEnabled: boolean;
  43406. /**
  43407. * Gets or sets a boolean indicating if particles are enabled on this scene
  43408. */
  43409. particlesEnabled: boolean;
  43410. /**
  43411. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43412. */
  43413. spritesEnabled: boolean;
  43414. private _skeletonsEnabled;
  43415. /**
  43416. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43417. */
  43418. set skeletonsEnabled(value: boolean);
  43419. get skeletonsEnabled(): boolean;
  43420. /**
  43421. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43422. */
  43423. lensFlaresEnabled: boolean;
  43424. /**
  43425. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43426. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43427. */
  43428. collisionsEnabled: boolean;
  43429. private _collisionCoordinator;
  43430. /** @hidden */
  43431. get collisionCoordinator(): ICollisionCoordinator;
  43432. /**
  43433. * Defines the gravity applied to this scene (used only for collisions)
  43434. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43435. */
  43436. gravity: Vector3;
  43437. /**
  43438. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43439. */
  43440. postProcessesEnabled: boolean;
  43441. /**
  43442. * Gets the current postprocess manager
  43443. */
  43444. postProcessManager: PostProcessManager;
  43445. /**
  43446. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43447. */
  43448. renderTargetsEnabled: boolean;
  43449. /**
  43450. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43451. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43452. */
  43453. dumpNextRenderTargets: boolean;
  43454. /**
  43455. * The list of user defined render targets added to the scene
  43456. */
  43457. customRenderTargets: RenderTargetTexture[];
  43458. /**
  43459. * Defines if texture loading must be delayed
  43460. * If true, textures will only be loaded when they need to be rendered
  43461. */
  43462. useDelayedTextureLoading: boolean;
  43463. /**
  43464. * Gets the list of meshes imported to the scene through SceneLoader
  43465. */
  43466. importedMeshesFiles: String[];
  43467. /**
  43468. * Gets or sets a boolean indicating if probes are enabled on this scene
  43469. */
  43470. probesEnabled: boolean;
  43471. /**
  43472. * Gets or sets the current offline provider to use to store scene data
  43473. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43474. */
  43475. offlineProvider: IOfflineProvider;
  43476. /**
  43477. * Gets or sets the action manager associated with the scene
  43478. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43479. */
  43480. actionManager: AbstractActionManager;
  43481. private _meshesForIntersections;
  43482. /**
  43483. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43484. */
  43485. proceduralTexturesEnabled: boolean;
  43486. private _engine;
  43487. private _totalVertices;
  43488. /** @hidden */
  43489. _activeIndices: PerfCounter;
  43490. /** @hidden */
  43491. _activeParticles: PerfCounter;
  43492. /** @hidden */
  43493. _activeBones: PerfCounter;
  43494. private _animationRatio;
  43495. /** @hidden */
  43496. _animationTimeLast: number;
  43497. /** @hidden */
  43498. _animationTime: number;
  43499. /**
  43500. * Gets or sets a general scale for animation speed
  43501. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43502. */
  43503. animationTimeScale: number;
  43504. /** @hidden */
  43505. _cachedMaterial: Nullable<Material>;
  43506. /** @hidden */
  43507. _cachedEffect: Nullable<Effect>;
  43508. /** @hidden */
  43509. _cachedVisibility: Nullable<number>;
  43510. private _renderId;
  43511. private _frameId;
  43512. private _executeWhenReadyTimeoutId;
  43513. private _intermediateRendering;
  43514. private _viewUpdateFlag;
  43515. private _projectionUpdateFlag;
  43516. /** @hidden */
  43517. _toBeDisposed: Nullable<IDisposable>[];
  43518. private _activeRequests;
  43519. /** @hidden */
  43520. _pendingData: any[];
  43521. private _isDisposed;
  43522. /**
  43523. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43524. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43525. */
  43526. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43527. private _activeMeshes;
  43528. private _processedMaterials;
  43529. private _renderTargets;
  43530. /** @hidden */
  43531. _activeParticleSystems: SmartArray<IParticleSystem>;
  43532. private _activeSkeletons;
  43533. private _softwareSkinnedMeshes;
  43534. private _renderingManager;
  43535. /** @hidden */
  43536. _activeAnimatables: Animatable[];
  43537. private _transformMatrix;
  43538. private _sceneUbo;
  43539. /** @hidden */
  43540. _viewMatrix: Matrix;
  43541. private _projectionMatrix;
  43542. /** @hidden */
  43543. _forcedViewPosition: Nullable<Vector3>;
  43544. /** @hidden */
  43545. _frustumPlanes: Plane[];
  43546. /**
  43547. * Gets the list of frustum planes (built from the active camera)
  43548. */
  43549. get frustumPlanes(): Plane[];
  43550. /**
  43551. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43552. * This is useful if there are more lights that the maximum simulteanous authorized
  43553. */
  43554. requireLightSorting: boolean;
  43555. /** @hidden */
  43556. readonly useMaterialMeshMap: boolean;
  43557. /** @hidden */
  43558. readonly useClonedMeshMap: boolean;
  43559. private _externalData;
  43560. private _uid;
  43561. /**
  43562. * @hidden
  43563. * Backing store of defined scene components.
  43564. */
  43565. _components: ISceneComponent[];
  43566. /**
  43567. * @hidden
  43568. * Backing store of defined scene components.
  43569. */
  43570. _serializableComponents: ISceneSerializableComponent[];
  43571. /**
  43572. * List of components to register on the next registration step.
  43573. */
  43574. private _transientComponents;
  43575. /**
  43576. * Registers the transient components if needed.
  43577. */
  43578. private _registerTransientComponents;
  43579. /**
  43580. * @hidden
  43581. * Add a component to the scene.
  43582. * Note that the ccomponent could be registered on th next frame if this is called after
  43583. * the register component stage.
  43584. * @param component Defines the component to add to the scene
  43585. */
  43586. _addComponent(component: ISceneComponent): void;
  43587. /**
  43588. * @hidden
  43589. * Gets a component from the scene.
  43590. * @param name defines the name of the component to retrieve
  43591. * @returns the component or null if not present
  43592. */
  43593. _getComponent(name: string): Nullable<ISceneComponent>;
  43594. /**
  43595. * @hidden
  43596. * Defines the actions happening before camera updates.
  43597. */
  43598. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43599. /**
  43600. * @hidden
  43601. * Defines the actions happening before clear the canvas.
  43602. */
  43603. _beforeClearStage: Stage<SimpleStageAction>;
  43604. /**
  43605. * @hidden
  43606. * Defines the actions when collecting render targets for the frame.
  43607. */
  43608. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43609. /**
  43610. * @hidden
  43611. * Defines the actions happening for one camera in the frame.
  43612. */
  43613. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43614. /**
  43615. * @hidden
  43616. * Defines the actions happening during the per mesh ready checks.
  43617. */
  43618. _isReadyForMeshStage: Stage<MeshStageAction>;
  43619. /**
  43620. * @hidden
  43621. * Defines the actions happening before evaluate active mesh checks.
  43622. */
  43623. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43624. /**
  43625. * @hidden
  43626. * Defines the actions happening during the evaluate sub mesh checks.
  43627. */
  43628. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43629. /**
  43630. * @hidden
  43631. * Defines the actions happening during the active mesh stage.
  43632. */
  43633. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43634. /**
  43635. * @hidden
  43636. * Defines the actions happening during the per camera render target step.
  43637. */
  43638. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43639. /**
  43640. * @hidden
  43641. * Defines the actions happening just before the active camera is drawing.
  43642. */
  43643. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43644. /**
  43645. * @hidden
  43646. * Defines the actions happening just before a render target is drawing.
  43647. */
  43648. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43649. /**
  43650. * @hidden
  43651. * Defines the actions happening just before a rendering group is drawing.
  43652. */
  43653. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43654. /**
  43655. * @hidden
  43656. * Defines the actions happening just before a mesh is drawing.
  43657. */
  43658. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43659. /**
  43660. * @hidden
  43661. * Defines the actions happening just after a mesh has been drawn.
  43662. */
  43663. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43664. /**
  43665. * @hidden
  43666. * Defines the actions happening just after a rendering group has been drawn.
  43667. */
  43668. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43669. /**
  43670. * @hidden
  43671. * Defines the actions happening just after the active camera has been drawn.
  43672. */
  43673. _afterCameraDrawStage: Stage<CameraStageAction>;
  43674. /**
  43675. * @hidden
  43676. * Defines the actions happening just after a render target has been drawn.
  43677. */
  43678. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43679. /**
  43680. * @hidden
  43681. * Defines the actions happening just after rendering all cameras and computing intersections.
  43682. */
  43683. _afterRenderStage: Stage<SimpleStageAction>;
  43684. /**
  43685. * @hidden
  43686. * Defines the actions happening when a pointer move event happens.
  43687. */
  43688. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43689. /**
  43690. * @hidden
  43691. * Defines the actions happening when a pointer down event happens.
  43692. */
  43693. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43694. /**
  43695. * @hidden
  43696. * Defines the actions happening when a pointer up event happens.
  43697. */
  43698. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43699. /**
  43700. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43701. */
  43702. private geometriesByUniqueId;
  43703. /**
  43704. * Creates a new Scene
  43705. * @param engine defines the engine to use to render this scene
  43706. * @param options defines the scene options
  43707. */
  43708. constructor(engine: Engine, options?: SceneOptions);
  43709. /**
  43710. * Gets a string identifying the name of the class
  43711. * @returns "Scene" string
  43712. */
  43713. getClassName(): string;
  43714. private _defaultMeshCandidates;
  43715. /**
  43716. * @hidden
  43717. */
  43718. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43719. private _defaultSubMeshCandidates;
  43720. /**
  43721. * @hidden
  43722. */
  43723. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43724. /**
  43725. * Sets the default candidate providers for the scene.
  43726. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43727. * and getCollidingSubMeshCandidates to their default function
  43728. */
  43729. setDefaultCandidateProviders(): void;
  43730. /**
  43731. * Gets the mesh that is currently under the pointer
  43732. */
  43733. get meshUnderPointer(): Nullable<AbstractMesh>;
  43734. /**
  43735. * Gets or sets the current on-screen X position of the pointer
  43736. */
  43737. get pointerX(): number;
  43738. set pointerX(value: number);
  43739. /**
  43740. * Gets or sets the current on-screen Y position of the pointer
  43741. */
  43742. get pointerY(): number;
  43743. set pointerY(value: number);
  43744. /**
  43745. * Gets the cached material (ie. the latest rendered one)
  43746. * @returns the cached material
  43747. */
  43748. getCachedMaterial(): Nullable<Material>;
  43749. /**
  43750. * Gets the cached effect (ie. the latest rendered one)
  43751. * @returns the cached effect
  43752. */
  43753. getCachedEffect(): Nullable<Effect>;
  43754. /**
  43755. * Gets the cached visibility state (ie. the latest rendered one)
  43756. * @returns the cached visibility state
  43757. */
  43758. getCachedVisibility(): Nullable<number>;
  43759. /**
  43760. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43761. * @param material defines the current material
  43762. * @param effect defines the current effect
  43763. * @param visibility defines the current visibility state
  43764. * @returns true if one parameter is not cached
  43765. */
  43766. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43767. /**
  43768. * Gets the engine associated with the scene
  43769. * @returns an Engine
  43770. */
  43771. getEngine(): Engine;
  43772. /**
  43773. * Gets the total number of vertices rendered per frame
  43774. * @returns the total number of vertices rendered per frame
  43775. */
  43776. getTotalVertices(): number;
  43777. /**
  43778. * Gets the performance counter for total vertices
  43779. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43780. */
  43781. get totalVerticesPerfCounter(): PerfCounter;
  43782. /**
  43783. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43784. * @returns the total number of active indices rendered per frame
  43785. */
  43786. getActiveIndices(): number;
  43787. /**
  43788. * Gets the performance counter for active indices
  43789. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43790. */
  43791. get totalActiveIndicesPerfCounter(): PerfCounter;
  43792. /**
  43793. * Gets the total number of active particles rendered per frame
  43794. * @returns the total number of active particles rendered per frame
  43795. */
  43796. getActiveParticles(): number;
  43797. /**
  43798. * Gets the performance counter for active particles
  43799. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43800. */
  43801. get activeParticlesPerfCounter(): PerfCounter;
  43802. /**
  43803. * Gets the total number of active bones rendered per frame
  43804. * @returns the total number of active bones rendered per frame
  43805. */
  43806. getActiveBones(): number;
  43807. /**
  43808. * Gets the performance counter for active bones
  43809. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43810. */
  43811. get activeBonesPerfCounter(): PerfCounter;
  43812. /**
  43813. * Gets the array of active meshes
  43814. * @returns an array of AbstractMesh
  43815. */
  43816. getActiveMeshes(): SmartArray<AbstractMesh>;
  43817. /**
  43818. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43819. * @returns a number
  43820. */
  43821. getAnimationRatio(): number;
  43822. /**
  43823. * Gets an unique Id for the current render phase
  43824. * @returns a number
  43825. */
  43826. getRenderId(): number;
  43827. /**
  43828. * Gets an unique Id for the current frame
  43829. * @returns a number
  43830. */
  43831. getFrameId(): number;
  43832. /** Call this function if you want to manually increment the render Id*/
  43833. incrementRenderId(): void;
  43834. private _createUbo;
  43835. /**
  43836. * Use this method to simulate a pointer move on a mesh
  43837. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43838. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43839. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43840. * @returns the current scene
  43841. */
  43842. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43843. /**
  43844. * Use this method to simulate a pointer down on a mesh
  43845. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43846. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43847. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43848. * @returns the current scene
  43849. */
  43850. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43851. /**
  43852. * Use this method to simulate a pointer up on a mesh
  43853. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43854. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43855. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43856. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43857. * @returns the current scene
  43858. */
  43859. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43860. /**
  43861. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43862. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43863. * @returns true if the pointer was captured
  43864. */
  43865. isPointerCaptured(pointerId?: number): boolean;
  43866. /**
  43867. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43868. * @param attachUp defines if you want to attach events to pointerup
  43869. * @param attachDown defines if you want to attach events to pointerdown
  43870. * @param attachMove defines if you want to attach events to pointermove
  43871. */
  43872. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43873. /** Detaches all event handlers*/
  43874. detachControl(): void;
  43875. /**
  43876. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43877. * Delay loaded resources are not taking in account
  43878. * @return true if all required resources are ready
  43879. */
  43880. isReady(): boolean;
  43881. /** Resets all cached information relative to material (including effect and visibility) */
  43882. resetCachedMaterial(): void;
  43883. /**
  43884. * Registers a function to be called before every frame render
  43885. * @param func defines the function to register
  43886. */
  43887. registerBeforeRender(func: () => void): void;
  43888. /**
  43889. * Unregisters a function called before every frame render
  43890. * @param func defines the function to unregister
  43891. */
  43892. unregisterBeforeRender(func: () => void): void;
  43893. /**
  43894. * Registers a function to be called after every frame render
  43895. * @param func defines the function to register
  43896. */
  43897. registerAfterRender(func: () => void): void;
  43898. /**
  43899. * Unregisters a function called after every frame render
  43900. * @param func defines the function to unregister
  43901. */
  43902. unregisterAfterRender(func: () => void): void;
  43903. private _executeOnceBeforeRender;
  43904. /**
  43905. * The provided function will run before render once and will be disposed afterwards.
  43906. * A timeout delay can be provided so that the function will be executed in N ms.
  43907. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43908. * @param func The function to be executed.
  43909. * @param timeout optional delay in ms
  43910. */
  43911. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43912. /** @hidden */
  43913. _addPendingData(data: any): void;
  43914. /** @hidden */
  43915. _removePendingData(data: any): void;
  43916. /**
  43917. * Returns the number of items waiting to be loaded
  43918. * @returns the number of items waiting to be loaded
  43919. */
  43920. getWaitingItemsCount(): number;
  43921. /**
  43922. * Returns a boolean indicating if the scene is still loading data
  43923. */
  43924. get isLoading(): boolean;
  43925. /**
  43926. * Registers a function to be executed when the scene is ready
  43927. * @param {Function} func - the function to be executed
  43928. */
  43929. executeWhenReady(func: () => void): void;
  43930. /**
  43931. * Returns a promise that resolves when the scene is ready
  43932. * @returns A promise that resolves when the scene is ready
  43933. */
  43934. whenReadyAsync(): Promise<void>;
  43935. /** @hidden */
  43936. _checkIsReady(): void;
  43937. /**
  43938. * Gets all animatable attached to the scene
  43939. */
  43940. get animatables(): Animatable[];
  43941. /**
  43942. * Resets the last animation time frame.
  43943. * Useful to override when animations start running when loading a scene for the first time.
  43944. */
  43945. resetLastAnimationTimeFrame(): void;
  43946. /**
  43947. * Gets the current view matrix
  43948. * @returns a Matrix
  43949. */
  43950. getViewMatrix(): Matrix;
  43951. /**
  43952. * Gets the current projection matrix
  43953. * @returns a Matrix
  43954. */
  43955. getProjectionMatrix(): Matrix;
  43956. /**
  43957. * Gets the current transform matrix
  43958. * @returns a Matrix made of View * Projection
  43959. */
  43960. getTransformMatrix(): Matrix;
  43961. /**
  43962. * Sets the current transform matrix
  43963. * @param viewL defines the View matrix to use
  43964. * @param projectionL defines the Projection matrix to use
  43965. * @param viewR defines the right View matrix to use (if provided)
  43966. * @param projectionR defines the right Projection matrix to use (if provided)
  43967. */
  43968. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43969. /**
  43970. * Gets the uniform buffer used to store scene data
  43971. * @returns a UniformBuffer
  43972. */
  43973. getSceneUniformBuffer(): UniformBuffer;
  43974. /**
  43975. * Gets an unique (relatively to the current scene) Id
  43976. * @returns an unique number for the scene
  43977. */
  43978. getUniqueId(): number;
  43979. /**
  43980. * Add a mesh to the list of scene's meshes
  43981. * @param newMesh defines the mesh to add
  43982. * @param recursive if all child meshes should also be added to the scene
  43983. */
  43984. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43985. /**
  43986. * Remove a mesh for the list of scene's meshes
  43987. * @param toRemove defines the mesh to remove
  43988. * @param recursive if all child meshes should also be removed from the scene
  43989. * @returns the index where the mesh was in the mesh list
  43990. */
  43991. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43992. /**
  43993. * Add a transform node to the list of scene's transform nodes
  43994. * @param newTransformNode defines the transform node to add
  43995. */
  43996. addTransformNode(newTransformNode: TransformNode): void;
  43997. /**
  43998. * Remove a transform node for the list of scene's transform nodes
  43999. * @param toRemove defines the transform node to remove
  44000. * @returns the index where the transform node was in the transform node list
  44001. */
  44002. removeTransformNode(toRemove: TransformNode): number;
  44003. /**
  44004. * Remove a skeleton for the list of scene's skeletons
  44005. * @param toRemove defines the skeleton to remove
  44006. * @returns the index where the skeleton was in the skeleton list
  44007. */
  44008. removeSkeleton(toRemove: Skeleton): number;
  44009. /**
  44010. * Remove a morph target for the list of scene's morph targets
  44011. * @param toRemove defines the morph target to remove
  44012. * @returns the index where the morph target was in the morph target list
  44013. */
  44014. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  44015. /**
  44016. * Remove a light for the list of scene's lights
  44017. * @param toRemove defines the light to remove
  44018. * @returns the index where the light was in the light list
  44019. */
  44020. removeLight(toRemove: Light): number;
  44021. /**
  44022. * Remove a camera for the list of scene's cameras
  44023. * @param toRemove defines the camera to remove
  44024. * @returns the index where the camera was in the camera list
  44025. */
  44026. removeCamera(toRemove: Camera): number;
  44027. /**
  44028. * Remove a particle system for the list of scene's particle systems
  44029. * @param toRemove defines the particle system to remove
  44030. * @returns the index where the particle system was in the particle system list
  44031. */
  44032. removeParticleSystem(toRemove: IParticleSystem): number;
  44033. /**
  44034. * Remove a animation for the list of scene's animations
  44035. * @param toRemove defines the animation to remove
  44036. * @returns the index where the animation was in the animation list
  44037. */
  44038. removeAnimation(toRemove: Animation): number;
  44039. /**
  44040. * Will stop the animation of the given target
  44041. * @param target - the target
  44042. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  44043. * @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)
  44044. */
  44045. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  44046. /**
  44047. * Removes the given animation group from this scene.
  44048. * @param toRemove The animation group to remove
  44049. * @returns The index of the removed animation group
  44050. */
  44051. removeAnimationGroup(toRemove: AnimationGroup): number;
  44052. /**
  44053. * Removes the given multi-material from this scene.
  44054. * @param toRemove The multi-material to remove
  44055. * @returns The index of the removed multi-material
  44056. */
  44057. removeMultiMaterial(toRemove: MultiMaterial): number;
  44058. /**
  44059. * Removes the given material from this scene.
  44060. * @param toRemove The material to remove
  44061. * @returns The index of the removed material
  44062. */
  44063. removeMaterial(toRemove: Material): number;
  44064. /**
  44065. * Removes the given action manager from this scene.
  44066. * @param toRemove The action manager to remove
  44067. * @returns The index of the removed action manager
  44068. */
  44069. removeActionManager(toRemove: AbstractActionManager): number;
  44070. /**
  44071. * Removes the given texture from this scene.
  44072. * @param toRemove The texture to remove
  44073. * @returns The index of the removed texture
  44074. */
  44075. removeTexture(toRemove: BaseTexture): number;
  44076. /**
  44077. * Adds the given light to this scene
  44078. * @param newLight The light to add
  44079. */
  44080. addLight(newLight: Light): void;
  44081. /**
  44082. * Sorts the list list based on light priorities
  44083. */
  44084. sortLightsByPriority(): void;
  44085. /**
  44086. * Adds the given camera to this scene
  44087. * @param newCamera The camera to add
  44088. */
  44089. addCamera(newCamera: Camera): void;
  44090. /**
  44091. * Adds the given skeleton to this scene
  44092. * @param newSkeleton The skeleton to add
  44093. */
  44094. addSkeleton(newSkeleton: Skeleton): void;
  44095. /**
  44096. * Adds the given particle system to this scene
  44097. * @param newParticleSystem The particle system to add
  44098. */
  44099. addParticleSystem(newParticleSystem: IParticleSystem): void;
  44100. /**
  44101. * Adds the given animation to this scene
  44102. * @param newAnimation The animation to add
  44103. */
  44104. addAnimation(newAnimation: Animation): void;
  44105. /**
  44106. * Adds the given animation group to this scene.
  44107. * @param newAnimationGroup The animation group to add
  44108. */
  44109. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  44110. /**
  44111. * Adds the given multi-material to this scene
  44112. * @param newMultiMaterial The multi-material to add
  44113. */
  44114. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  44115. /**
  44116. * Adds the given material to this scene
  44117. * @param newMaterial The material to add
  44118. */
  44119. addMaterial(newMaterial: Material): void;
  44120. /**
  44121. * Adds the given morph target to this scene
  44122. * @param newMorphTargetManager The morph target to add
  44123. */
  44124. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  44125. /**
  44126. * Adds the given geometry to this scene
  44127. * @param newGeometry The geometry to add
  44128. */
  44129. addGeometry(newGeometry: Geometry): void;
  44130. /**
  44131. * Adds the given action manager to this scene
  44132. * @param newActionManager The action manager to add
  44133. */
  44134. addActionManager(newActionManager: AbstractActionManager): void;
  44135. /**
  44136. * Adds the given texture to this scene.
  44137. * @param newTexture The texture to add
  44138. */
  44139. addTexture(newTexture: BaseTexture): void;
  44140. /**
  44141. * Switch active camera
  44142. * @param newCamera defines the new active camera
  44143. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  44144. */
  44145. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  44146. /**
  44147. * sets the active camera of the scene using its ID
  44148. * @param id defines the camera's ID
  44149. * @return the new active camera or null if none found.
  44150. */
  44151. setActiveCameraByID(id: string): Nullable<Camera>;
  44152. /**
  44153. * sets the active camera of the scene using its name
  44154. * @param name defines the camera's name
  44155. * @returns the new active camera or null if none found.
  44156. */
  44157. setActiveCameraByName(name: string): Nullable<Camera>;
  44158. /**
  44159. * get an animation group using its name
  44160. * @param name defines the material's name
  44161. * @return the animation group or null if none found.
  44162. */
  44163. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  44164. /**
  44165. * Get a material using its unique id
  44166. * @param uniqueId defines the material's unique id
  44167. * @return the material or null if none found.
  44168. */
  44169. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  44170. /**
  44171. * get a material using its id
  44172. * @param id defines the material's ID
  44173. * @return the material or null if none found.
  44174. */
  44175. getMaterialByID(id: string): Nullable<Material>;
  44176. /**
  44177. * Gets a the last added material using a given id
  44178. * @param id defines the material's ID
  44179. * @return the last material with the given id or null if none found.
  44180. */
  44181. getLastMaterialByID(id: string): Nullable<Material>;
  44182. /**
  44183. * Gets a material using its name
  44184. * @param name defines the material's name
  44185. * @return the material or null if none found.
  44186. */
  44187. getMaterialByName(name: string): Nullable<Material>;
  44188. /**
  44189. * Get a texture using its unique id
  44190. * @param uniqueId defines the texture's unique id
  44191. * @return the texture or null if none found.
  44192. */
  44193. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  44194. /**
  44195. * Gets a camera using its id
  44196. * @param id defines the id to look for
  44197. * @returns the camera or null if not found
  44198. */
  44199. getCameraByID(id: string): Nullable<Camera>;
  44200. /**
  44201. * Gets a camera using its unique id
  44202. * @param uniqueId defines the unique id to look for
  44203. * @returns the camera or null if not found
  44204. */
  44205. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  44206. /**
  44207. * Gets a camera using its name
  44208. * @param name defines the camera's name
  44209. * @return the camera or null if none found.
  44210. */
  44211. getCameraByName(name: string): Nullable<Camera>;
  44212. /**
  44213. * Gets a bone using its id
  44214. * @param id defines the bone's id
  44215. * @return the bone or null if not found
  44216. */
  44217. getBoneByID(id: string): Nullable<Bone>;
  44218. /**
  44219. * Gets a bone using its id
  44220. * @param name defines the bone's name
  44221. * @return the bone or null if not found
  44222. */
  44223. getBoneByName(name: string): Nullable<Bone>;
  44224. /**
  44225. * Gets a light node using its name
  44226. * @param name defines the the light's name
  44227. * @return the light or null if none found.
  44228. */
  44229. getLightByName(name: string): Nullable<Light>;
  44230. /**
  44231. * Gets a light node using its id
  44232. * @param id defines the light's id
  44233. * @return the light or null if none found.
  44234. */
  44235. getLightByID(id: string): Nullable<Light>;
  44236. /**
  44237. * Gets a light node using its scene-generated unique ID
  44238. * @param uniqueId defines the light's unique id
  44239. * @return the light or null if none found.
  44240. */
  44241. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44242. /**
  44243. * Gets a particle system by id
  44244. * @param id defines the particle system id
  44245. * @return the corresponding system or null if none found
  44246. */
  44247. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44248. /**
  44249. * Gets a geometry using its ID
  44250. * @param id defines the geometry's id
  44251. * @return the geometry or null if none found.
  44252. */
  44253. getGeometryByID(id: string): Nullable<Geometry>;
  44254. private _getGeometryByUniqueID;
  44255. /**
  44256. * Add a new geometry to this scene
  44257. * @param geometry defines the geometry to be added to the scene.
  44258. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44259. * @return a boolean defining if the geometry was added or not
  44260. */
  44261. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44262. /**
  44263. * Removes an existing geometry
  44264. * @param geometry defines the geometry to be removed from the scene
  44265. * @return a boolean defining if the geometry was removed or not
  44266. */
  44267. removeGeometry(geometry: Geometry): boolean;
  44268. /**
  44269. * Gets the list of geometries attached to the scene
  44270. * @returns an array of Geometry
  44271. */
  44272. getGeometries(): Geometry[];
  44273. /**
  44274. * Gets the first added mesh found of a given ID
  44275. * @param id defines the id to search for
  44276. * @return the mesh found or null if not found at all
  44277. */
  44278. getMeshByID(id: string): Nullable<AbstractMesh>;
  44279. /**
  44280. * Gets a list of meshes using their id
  44281. * @param id defines the id to search for
  44282. * @returns a list of meshes
  44283. */
  44284. getMeshesByID(id: string): Array<AbstractMesh>;
  44285. /**
  44286. * Gets the first added transform node found of a given ID
  44287. * @param id defines the id to search for
  44288. * @return the found transform node or null if not found at all.
  44289. */
  44290. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44291. /**
  44292. * Gets a transform node with its auto-generated unique id
  44293. * @param uniqueId efines the unique id to search for
  44294. * @return the found transform node or null if not found at all.
  44295. */
  44296. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44297. /**
  44298. * Gets a list of transform nodes using their id
  44299. * @param id defines the id to search for
  44300. * @returns a list of transform nodes
  44301. */
  44302. getTransformNodesByID(id: string): Array<TransformNode>;
  44303. /**
  44304. * Gets a mesh with its auto-generated unique id
  44305. * @param uniqueId defines the unique id to search for
  44306. * @return the found mesh or null if not found at all.
  44307. */
  44308. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44309. /**
  44310. * Gets a the last added mesh using a given id
  44311. * @param id defines the id to search for
  44312. * @return the found mesh or null if not found at all.
  44313. */
  44314. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44315. /**
  44316. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44317. * @param id defines the id to search for
  44318. * @return the found node or null if not found at all
  44319. */
  44320. getLastEntryByID(id: string): Nullable<Node>;
  44321. /**
  44322. * Gets a node (Mesh, Camera, Light) using a given id
  44323. * @param id defines the id to search for
  44324. * @return the found node or null if not found at all
  44325. */
  44326. getNodeByID(id: string): Nullable<Node>;
  44327. /**
  44328. * Gets a node (Mesh, Camera, Light) using a given name
  44329. * @param name defines the name to search for
  44330. * @return the found node or null if not found at all.
  44331. */
  44332. getNodeByName(name: string): Nullable<Node>;
  44333. /**
  44334. * Gets a mesh using a given name
  44335. * @param name defines the name to search for
  44336. * @return the found mesh or null if not found at all.
  44337. */
  44338. getMeshByName(name: string): Nullable<AbstractMesh>;
  44339. /**
  44340. * Gets a transform node using a given name
  44341. * @param name defines the name to search for
  44342. * @return the found transform node or null if not found at all.
  44343. */
  44344. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44345. /**
  44346. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44347. * @param id defines the id to search for
  44348. * @return the found skeleton or null if not found at all.
  44349. */
  44350. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44351. /**
  44352. * Gets a skeleton using a given auto generated unique id
  44353. * @param uniqueId defines the unique id to search for
  44354. * @return the found skeleton or null if not found at all.
  44355. */
  44356. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44357. /**
  44358. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44359. * @param id defines the id to search for
  44360. * @return the found skeleton or null if not found at all.
  44361. */
  44362. getSkeletonById(id: string): Nullable<Skeleton>;
  44363. /**
  44364. * Gets a skeleton using a given name
  44365. * @param name defines the name to search for
  44366. * @return the found skeleton or null if not found at all.
  44367. */
  44368. getSkeletonByName(name: string): Nullable<Skeleton>;
  44369. /**
  44370. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44371. * @param id defines the id to search for
  44372. * @return the found morph target manager or null if not found at all.
  44373. */
  44374. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44375. /**
  44376. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44377. * @param id defines the id to search for
  44378. * @return the found morph target or null if not found at all.
  44379. */
  44380. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44381. /**
  44382. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44383. * @param name defines the name to search for
  44384. * @return the found morph target or null if not found at all.
  44385. */
  44386. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44387. /**
  44388. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44389. * @param name defines the name to search for
  44390. * @return the found post process or null if not found at all.
  44391. */
  44392. getPostProcessByName(name: string): Nullable<PostProcess>;
  44393. /**
  44394. * Gets a boolean indicating if the given mesh is active
  44395. * @param mesh defines the mesh to look for
  44396. * @returns true if the mesh is in the active list
  44397. */
  44398. isActiveMesh(mesh: AbstractMesh): boolean;
  44399. /**
  44400. * Return a unique id as a string which can serve as an identifier for the scene
  44401. */
  44402. get uid(): string;
  44403. /**
  44404. * Add an externaly attached data from its key.
  44405. * This method call will fail and return false, if such key already exists.
  44406. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44407. * @param key the unique key that identifies the data
  44408. * @param data the data object to associate to the key for this Engine instance
  44409. * @return true if no such key were already present and the data was added successfully, false otherwise
  44410. */
  44411. addExternalData<T>(key: string, data: T): boolean;
  44412. /**
  44413. * Get an externaly attached data from its key
  44414. * @param key the unique key that identifies the data
  44415. * @return the associated data, if present (can be null), or undefined if not present
  44416. */
  44417. getExternalData<T>(key: string): Nullable<T>;
  44418. /**
  44419. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44420. * @param key the unique key that identifies the data
  44421. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44422. * @return the associated data, can be null if the factory returned null.
  44423. */
  44424. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44425. /**
  44426. * Remove an externaly attached data from the Engine instance
  44427. * @param key the unique key that identifies the data
  44428. * @return true if the data was successfully removed, false if it doesn't exist
  44429. */
  44430. removeExternalData(key: string): boolean;
  44431. private _evaluateSubMesh;
  44432. /**
  44433. * Clear the processed materials smart array preventing retention point in material dispose.
  44434. */
  44435. freeProcessedMaterials(): void;
  44436. private _preventFreeActiveMeshesAndRenderingGroups;
  44437. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44438. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44439. * when disposing several meshes in a row or a hierarchy of meshes.
  44440. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44441. */
  44442. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44443. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44444. /**
  44445. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44446. */
  44447. freeActiveMeshes(): void;
  44448. /**
  44449. * Clear the info related to rendering groups preventing retention points during dispose.
  44450. */
  44451. freeRenderingGroups(): void;
  44452. /** @hidden */
  44453. _isInIntermediateRendering(): boolean;
  44454. /**
  44455. * Lambda returning the list of potentially active meshes.
  44456. */
  44457. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44458. /**
  44459. * Lambda returning the list of potentially active sub meshes.
  44460. */
  44461. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44462. /**
  44463. * Lambda returning the list of potentially intersecting sub meshes.
  44464. */
  44465. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44466. /**
  44467. * Lambda returning the list of potentially colliding sub meshes.
  44468. */
  44469. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44470. private _activeMeshesFrozen;
  44471. private _skipEvaluateActiveMeshesCompletely;
  44472. /**
  44473. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44474. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44475. * @param onSuccess optional success callback
  44476. * @param onError optional error callback
  44477. * @returns the current scene
  44478. */
  44479. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44480. /**
  44481. * Use this function to restart evaluating active meshes on every frame
  44482. * @returns the current scene
  44483. */
  44484. unfreezeActiveMeshes(): Scene;
  44485. private _evaluateActiveMeshes;
  44486. private _activeMesh;
  44487. /**
  44488. * Update the transform matrix to update from the current active camera
  44489. * @param force defines a boolean used to force the update even if cache is up to date
  44490. */
  44491. updateTransformMatrix(force?: boolean): void;
  44492. private _bindFrameBuffer;
  44493. /** @hidden */
  44494. _allowPostProcessClearColor: boolean;
  44495. /** @hidden */
  44496. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44497. private _processSubCameras;
  44498. private _checkIntersections;
  44499. /** @hidden */
  44500. _advancePhysicsEngineStep(step: number): void;
  44501. /**
  44502. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44503. */
  44504. getDeterministicFrameTime: () => number;
  44505. /** @hidden */
  44506. _animate(): void;
  44507. /** Execute all animations (for a frame) */
  44508. animate(): void;
  44509. /**
  44510. * Render the scene
  44511. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44512. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44513. */
  44514. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44515. /**
  44516. * Freeze all materials
  44517. * A frozen material will not be updatable but should be faster to render
  44518. */
  44519. freezeMaterials(): void;
  44520. /**
  44521. * Unfreeze all materials
  44522. * A frozen material will not be updatable but should be faster to render
  44523. */
  44524. unfreezeMaterials(): void;
  44525. /**
  44526. * Releases all held ressources
  44527. */
  44528. dispose(): void;
  44529. /**
  44530. * Gets if the scene is already disposed
  44531. */
  44532. get isDisposed(): boolean;
  44533. /**
  44534. * Call this function to reduce memory footprint of the scene.
  44535. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44536. */
  44537. clearCachedVertexData(): void;
  44538. /**
  44539. * This function will remove the local cached buffer data from texture.
  44540. * It will save memory but will prevent the texture from being rebuilt
  44541. */
  44542. cleanCachedTextureBuffer(): void;
  44543. /**
  44544. * Get the world extend vectors with an optional filter
  44545. *
  44546. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44547. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44548. */
  44549. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44550. min: Vector3;
  44551. max: Vector3;
  44552. };
  44553. /**
  44554. * Creates a ray that can be used to pick in the scene
  44555. * @param x defines the x coordinate of the origin (on-screen)
  44556. * @param y defines the y coordinate of the origin (on-screen)
  44557. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44558. * @param camera defines the camera to use for the picking
  44559. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44560. * @returns a Ray
  44561. */
  44562. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44563. /**
  44564. * Creates a ray that can be used to pick in the scene
  44565. * @param x defines the x coordinate of the origin (on-screen)
  44566. * @param y defines the y coordinate of the origin (on-screen)
  44567. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44568. * @param result defines the ray where to store the picking ray
  44569. * @param camera defines the camera to use for the picking
  44570. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44571. * @returns the current scene
  44572. */
  44573. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44574. /**
  44575. * Creates a ray that can be used to pick in the scene
  44576. * @param x defines the x coordinate of the origin (on-screen)
  44577. * @param y defines the y coordinate of the origin (on-screen)
  44578. * @param camera defines the camera to use for the picking
  44579. * @returns a Ray
  44580. */
  44581. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44582. /**
  44583. * Creates a ray that can be used to pick in the scene
  44584. * @param x defines the x coordinate of the origin (on-screen)
  44585. * @param y defines the y coordinate of the origin (on-screen)
  44586. * @param result defines the ray where to store the picking ray
  44587. * @param camera defines the camera to use for the picking
  44588. * @returns the current scene
  44589. */
  44590. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44591. /** Launch a ray to try to pick a mesh in the scene
  44592. * @param x position on screen
  44593. * @param y position on screen
  44594. * @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
  44595. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44596. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44597. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44598. * @returns a PickingInfo
  44599. */
  44600. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44601. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44602. * @param x position on screen
  44603. * @param y position on screen
  44604. * @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
  44605. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44606. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44607. * @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)
  44608. */
  44609. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44610. /** Use the given ray to pick a mesh in the scene
  44611. * @param ray The ray to use to pick meshes
  44612. * @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
  44613. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44614. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44615. * @returns a PickingInfo
  44616. */
  44617. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44618. /**
  44619. * Launch a ray to try to pick a mesh in the scene
  44620. * @param x X position on screen
  44621. * @param y Y position on screen
  44622. * @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
  44623. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44624. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44625. * @returns an array of PickingInfo
  44626. */
  44627. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44628. /**
  44629. * Launch a ray to try to pick a mesh in the scene
  44630. * @param ray Ray to use
  44631. * @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
  44632. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44633. * @returns an array of PickingInfo
  44634. */
  44635. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44636. /**
  44637. * Force the value of meshUnderPointer
  44638. * @param mesh defines the mesh to use
  44639. * @param pointerId optional pointer id when using more than one pointer
  44640. */
  44641. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44642. /**
  44643. * Gets the mesh under the pointer
  44644. * @returns a Mesh or null if no mesh is under the pointer
  44645. */
  44646. getPointerOverMesh(): Nullable<AbstractMesh>;
  44647. /** @hidden */
  44648. _rebuildGeometries(): void;
  44649. /** @hidden */
  44650. _rebuildTextures(): void;
  44651. private _getByTags;
  44652. /**
  44653. * Get a list of meshes by tags
  44654. * @param tagsQuery defines the tags query to use
  44655. * @param forEach defines a predicate used to filter results
  44656. * @returns an array of Mesh
  44657. */
  44658. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44659. /**
  44660. * Get a list of cameras by tags
  44661. * @param tagsQuery defines the tags query to use
  44662. * @param forEach defines a predicate used to filter results
  44663. * @returns an array of Camera
  44664. */
  44665. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44666. /**
  44667. * Get a list of lights by tags
  44668. * @param tagsQuery defines the tags query to use
  44669. * @param forEach defines a predicate used to filter results
  44670. * @returns an array of Light
  44671. */
  44672. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44673. /**
  44674. * Get a list of materials by tags
  44675. * @param tagsQuery defines the tags query to use
  44676. * @param forEach defines a predicate used to filter results
  44677. * @returns an array of Material
  44678. */
  44679. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44680. /**
  44681. * Get a list of transform nodes by tags
  44682. * @param tagsQuery defines the tags query to use
  44683. * @param forEach defines a predicate used to filter results
  44684. * @returns an array of TransformNode
  44685. */
  44686. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44687. /**
  44688. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44689. * This allowed control for front to back rendering or reversly depending of the special needs.
  44690. *
  44691. * @param renderingGroupId The rendering group id corresponding to its index
  44692. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44693. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44694. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44695. */
  44696. 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;
  44697. /**
  44698. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44699. *
  44700. * @param renderingGroupId The rendering group id corresponding to its index
  44701. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44702. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44703. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44704. */
  44705. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44706. /**
  44707. * Gets the current auto clear configuration for one rendering group of the rendering
  44708. * manager.
  44709. * @param index the rendering group index to get the information for
  44710. * @returns The auto clear setup for the requested rendering group
  44711. */
  44712. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44713. private _blockMaterialDirtyMechanism;
  44714. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44715. get blockMaterialDirtyMechanism(): boolean;
  44716. set blockMaterialDirtyMechanism(value: boolean);
  44717. /**
  44718. * Will flag all materials as dirty to trigger new shader compilation
  44719. * @param flag defines the flag used to specify which material part must be marked as dirty
  44720. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44721. */
  44722. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44723. /** @hidden */
  44724. _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;
  44725. /** @hidden */
  44726. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44727. /** @hidden */
  44728. _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;
  44729. /** @hidden */
  44730. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44731. /** @hidden */
  44732. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44733. /** @hidden */
  44734. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44735. }
  44736. }
  44737. declare module BABYLON {
  44738. /**
  44739. * Set of assets to keep when moving a scene into an asset container.
  44740. */
  44741. export class KeepAssets extends AbstractScene {
  44742. }
  44743. /**
  44744. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44745. */
  44746. export class InstantiatedEntries {
  44747. /**
  44748. * List of new root nodes (eg. nodes with no parent)
  44749. */
  44750. rootNodes: TransformNode[];
  44751. /**
  44752. * List of new skeletons
  44753. */
  44754. skeletons: Skeleton[];
  44755. /**
  44756. * List of new animation groups
  44757. */
  44758. animationGroups: AnimationGroup[];
  44759. }
  44760. /**
  44761. * Container with a set of assets that can be added or removed from a scene.
  44762. */
  44763. export class AssetContainer extends AbstractScene {
  44764. private _wasAddedToScene;
  44765. /**
  44766. * The scene the AssetContainer belongs to.
  44767. */
  44768. scene: Scene;
  44769. /**
  44770. * Instantiates an AssetContainer.
  44771. * @param scene The scene the AssetContainer belongs to.
  44772. */
  44773. constructor(scene: Scene);
  44774. /**
  44775. * Instantiate or clone all meshes and add the new ones to the scene.
  44776. * Skeletons and animation groups will all be cloned
  44777. * @param nameFunction defines an optional function used to get new names for clones
  44778. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44779. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44780. */
  44781. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44782. /**
  44783. * Adds all the assets from the container to the scene.
  44784. */
  44785. addAllToScene(): void;
  44786. /**
  44787. * Removes all the assets in the container from the scene
  44788. */
  44789. removeAllFromScene(): void;
  44790. /**
  44791. * Disposes all the assets in the container
  44792. */
  44793. dispose(): void;
  44794. private _moveAssets;
  44795. /**
  44796. * Removes all the assets contained in the scene and adds them to the container.
  44797. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44798. */
  44799. moveAllFromScene(keepAssets?: KeepAssets): void;
  44800. /**
  44801. * 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.
  44802. * @returns the root mesh
  44803. */
  44804. createRootMesh(): Mesh;
  44805. /**
  44806. * Merge animations (direct and animation groups) from this asset container into a scene
  44807. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44808. * @param animatables set of animatables to retarget to a node from the scene
  44809. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44810. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44811. */
  44812. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44813. }
  44814. }
  44815. declare module BABYLON {
  44816. /**
  44817. * Defines how the parser contract is defined.
  44818. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44819. */
  44820. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44821. /**
  44822. * Defines how the individual parser contract is defined.
  44823. * These parser can parse an individual asset
  44824. */
  44825. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44826. /**
  44827. * Base class of the scene acting as a container for the different elements composing a scene.
  44828. * This class is dynamically extended by the different components of the scene increasing
  44829. * flexibility and reducing coupling
  44830. */
  44831. export abstract class AbstractScene {
  44832. /**
  44833. * Stores the list of available parsers in the application.
  44834. */
  44835. private static _BabylonFileParsers;
  44836. /**
  44837. * Stores the list of available individual parsers in the application.
  44838. */
  44839. private static _IndividualBabylonFileParsers;
  44840. /**
  44841. * Adds a parser in the list of available ones
  44842. * @param name Defines the name of the parser
  44843. * @param parser Defines the parser to add
  44844. */
  44845. static AddParser(name: string, parser: BabylonFileParser): void;
  44846. /**
  44847. * Gets a general parser from the list of avaialble ones
  44848. * @param name Defines the name of the parser
  44849. * @returns the requested parser or null
  44850. */
  44851. static GetParser(name: string): Nullable<BabylonFileParser>;
  44852. /**
  44853. * Adds n individual parser in the list of available ones
  44854. * @param name Defines the name of the parser
  44855. * @param parser Defines the parser to add
  44856. */
  44857. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44858. /**
  44859. * Gets an individual parser from the list of avaialble ones
  44860. * @param name Defines the name of the parser
  44861. * @returns the requested parser or null
  44862. */
  44863. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44864. /**
  44865. * Parser json data and populate both a scene and its associated container object
  44866. * @param jsonData Defines the data to parse
  44867. * @param scene Defines the scene to parse the data for
  44868. * @param container Defines the container attached to the parsing sequence
  44869. * @param rootUrl Defines the root url of the data
  44870. */
  44871. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44872. /**
  44873. * Gets the list of root nodes (ie. nodes with no parent)
  44874. */
  44875. rootNodes: Node[];
  44876. /** All of the cameras added to this scene
  44877. * @see https://doc.babylonjs.com/babylon101/cameras
  44878. */
  44879. cameras: Camera[];
  44880. /**
  44881. * All of the lights added to this scene
  44882. * @see https://doc.babylonjs.com/babylon101/lights
  44883. */
  44884. lights: Light[];
  44885. /**
  44886. * All of the (abstract) meshes added to this scene
  44887. */
  44888. meshes: AbstractMesh[];
  44889. /**
  44890. * The list of skeletons added to the scene
  44891. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44892. */
  44893. skeletons: Skeleton[];
  44894. /**
  44895. * All of the particle systems added to this scene
  44896. * @see https://doc.babylonjs.com/babylon101/particles
  44897. */
  44898. particleSystems: IParticleSystem[];
  44899. /**
  44900. * Gets a list of Animations associated with the scene
  44901. */
  44902. animations: Animation[];
  44903. /**
  44904. * All of the animation groups added to this scene
  44905. * @see https://doc.babylonjs.com/how_to/group
  44906. */
  44907. animationGroups: AnimationGroup[];
  44908. /**
  44909. * All of the multi-materials added to this scene
  44910. * @see https://doc.babylonjs.com/how_to/multi_materials
  44911. */
  44912. multiMaterials: MultiMaterial[];
  44913. /**
  44914. * All of the materials added to this scene
  44915. * In the context of a Scene, it is not supposed to be modified manually.
  44916. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44917. * Note also that the order of the Material within the array is not significant and might change.
  44918. * @see https://doc.babylonjs.com/babylon101/materials
  44919. */
  44920. materials: Material[];
  44921. /**
  44922. * The list of morph target managers added to the scene
  44923. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44924. */
  44925. morphTargetManagers: MorphTargetManager[];
  44926. /**
  44927. * The list of geometries used in the scene.
  44928. */
  44929. geometries: Geometry[];
  44930. /**
  44931. * All of the tranform nodes added to this scene
  44932. * In the context of a Scene, it is not supposed to be modified manually.
  44933. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44934. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44935. * @see https://doc.babylonjs.com/how_to/transformnode
  44936. */
  44937. transformNodes: TransformNode[];
  44938. /**
  44939. * ActionManagers available on the scene.
  44940. */
  44941. actionManagers: AbstractActionManager[];
  44942. /**
  44943. * Textures to keep.
  44944. */
  44945. textures: BaseTexture[];
  44946. /** @hidden */
  44947. protected _environmentTexture: Nullable<BaseTexture>;
  44948. /**
  44949. * Texture used in all pbr material as the reflection texture.
  44950. * As in the majority of the scene they are the same (exception for multi room and so on),
  44951. * this is easier to reference from here than from all the materials.
  44952. */
  44953. get environmentTexture(): Nullable<BaseTexture>;
  44954. set environmentTexture(value: Nullable<BaseTexture>);
  44955. /**
  44956. * The list of postprocesses added to the scene
  44957. */
  44958. postProcesses: PostProcess[];
  44959. /**
  44960. * @returns all meshes, lights, cameras, transformNodes and bones
  44961. */
  44962. getNodes(): Array<Node>;
  44963. }
  44964. }
  44965. declare module BABYLON {
  44966. /**
  44967. * Interface used to define options for Sound class
  44968. */
  44969. export interface ISoundOptions {
  44970. /**
  44971. * Does the sound autoplay once loaded.
  44972. */
  44973. autoplay?: boolean;
  44974. /**
  44975. * Does the sound loop after it finishes playing once.
  44976. */
  44977. loop?: boolean;
  44978. /**
  44979. * Sound's volume
  44980. */
  44981. volume?: number;
  44982. /**
  44983. * Is it a spatial sound?
  44984. */
  44985. spatialSound?: boolean;
  44986. /**
  44987. * Maximum distance to hear that sound
  44988. */
  44989. maxDistance?: number;
  44990. /**
  44991. * Uses user defined attenuation function
  44992. */
  44993. useCustomAttenuation?: boolean;
  44994. /**
  44995. * Define the roll off factor of spatial sounds.
  44996. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44997. */
  44998. rolloffFactor?: number;
  44999. /**
  45000. * Define the reference distance the sound should be heard perfectly.
  45001. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45002. */
  45003. refDistance?: number;
  45004. /**
  45005. * Define the distance attenuation model the sound will follow.
  45006. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45007. */
  45008. distanceModel?: string;
  45009. /**
  45010. * Defines the playback speed (1 by default)
  45011. */
  45012. playbackRate?: number;
  45013. /**
  45014. * Defines if the sound is from a streaming source
  45015. */
  45016. streaming?: boolean;
  45017. /**
  45018. * Defines an optional length (in seconds) inside the sound file
  45019. */
  45020. length?: number;
  45021. /**
  45022. * Defines an optional offset (in seconds) inside the sound file
  45023. */
  45024. offset?: number;
  45025. /**
  45026. * If true, URLs will not be required to state the audio file codec to use.
  45027. */
  45028. skipCodecCheck?: boolean;
  45029. }
  45030. }
  45031. declare module BABYLON {
  45032. /**
  45033. * Defines a sound that can be played in the application.
  45034. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  45035. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45036. */
  45037. export class Sound {
  45038. /**
  45039. * The name of the sound in the scene.
  45040. */
  45041. name: string;
  45042. /**
  45043. * Does the sound autoplay once loaded.
  45044. */
  45045. autoplay: boolean;
  45046. /**
  45047. * Does the sound loop after it finishes playing once.
  45048. */
  45049. loop: boolean;
  45050. /**
  45051. * Does the sound use a custom attenuation curve to simulate the falloff
  45052. * happening when the source gets further away from the camera.
  45053. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45054. */
  45055. useCustomAttenuation: boolean;
  45056. /**
  45057. * The sound track id this sound belongs to.
  45058. */
  45059. soundTrackId: number;
  45060. /**
  45061. * Is this sound currently played.
  45062. */
  45063. isPlaying: boolean;
  45064. /**
  45065. * Is this sound currently paused.
  45066. */
  45067. isPaused: boolean;
  45068. /**
  45069. * Does this sound enables spatial sound.
  45070. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45071. */
  45072. spatialSound: boolean;
  45073. /**
  45074. * Define the reference distance the sound should be heard perfectly.
  45075. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45076. */
  45077. refDistance: number;
  45078. /**
  45079. * Define the roll off factor of spatial sounds.
  45080. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45081. */
  45082. rolloffFactor: number;
  45083. /**
  45084. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  45085. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45086. */
  45087. maxDistance: number;
  45088. /**
  45089. * Define the distance attenuation model the sound will follow.
  45090. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45091. */
  45092. distanceModel: string;
  45093. /**
  45094. * @hidden
  45095. * Back Compat
  45096. **/
  45097. onended: () => any;
  45098. /**
  45099. * Gets or sets an object used to store user defined information for the sound.
  45100. */
  45101. metadata: any;
  45102. /**
  45103. * Observable event when the current playing sound finishes.
  45104. */
  45105. onEndedObservable: Observable<Sound>;
  45106. /**
  45107. * Gets the current time for the sound.
  45108. */
  45109. get currentTime(): number;
  45110. private _panningModel;
  45111. private _playbackRate;
  45112. private _streaming;
  45113. private _startTime;
  45114. private _startOffset;
  45115. private _position;
  45116. /** @hidden */
  45117. _positionInEmitterSpace: boolean;
  45118. private _localDirection;
  45119. private _volume;
  45120. private _isReadyToPlay;
  45121. private _isDirectional;
  45122. private _readyToPlayCallback;
  45123. private _audioBuffer;
  45124. private _soundSource;
  45125. private _streamingSource;
  45126. private _soundPanner;
  45127. private _soundGain;
  45128. private _inputAudioNode;
  45129. private _outputAudioNode;
  45130. private _coneInnerAngle;
  45131. private _coneOuterAngle;
  45132. private _coneOuterGain;
  45133. private _scene;
  45134. private _connectedTransformNode;
  45135. private _customAttenuationFunction;
  45136. private _registerFunc;
  45137. private _isOutputConnected;
  45138. private _htmlAudioElement;
  45139. private _urlType;
  45140. private _length?;
  45141. private _offset?;
  45142. /** @hidden */
  45143. static _SceneComponentInitialization: (scene: Scene) => void;
  45144. /**
  45145. * Create a sound and attach it to a scene
  45146. * @param name Name of your sound
  45147. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  45148. * @param scene defines the scene the sound belongs to
  45149. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  45150. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  45151. */
  45152. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  45153. /**
  45154. * Release the sound and its associated resources
  45155. */
  45156. dispose(): void;
  45157. /**
  45158. * Gets if the sounds is ready to be played or not.
  45159. * @returns true if ready, otherwise false
  45160. */
  45161. isReady(): boolean;
  45162. private _soundLoaded;
  45163. /**
  45164. * Sets the data of the sound from an audiobuffer
  45165. * @param audioBuffer The audioBuffer containing the data
  45166. */
  45167. setAudioBuffer(audioBuffer: AudioBuffer): void;
  45168. /**
  45169. * Updates the current sounds options such as maxdistance, loop...
  45170. * @param options A JSON object containing values named as the object properties
  45171. */
  45172. updateOptions(options: ISoundOptions): void;
  45173. private _createSpatialParameters;
  45174. private _updateSpatialParameters;
  45175. /**
  45176. * Switch the panning model to HRTF:
  45177. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45178. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45179. */
  45180. switchPanningModelToHRTF(): void;
  45181. /**
  45182. * Switch the panning model to Equal Power:
  45183. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45184. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45185. */
  45186. switchPanningModelToEqualPower(): void;
  45187. private _switchPanningModel;
  45188. /**
  45189. * Connect this sound to a sound track audio node like gain...
  45190. * @param soundTrackAudioNode the sound track audio node to connect to
  45191. */
  45192. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  45193. /**
  45194. * Transform this sound into a directional source
  45195. * @param coneInnerAngle Size of the inner cone in degree
  45196. * @param coneOuterAngle Size of the outer cone in degree
  45197. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  45198. */
  45199. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  45200. /**
  45201. * Gets or sets the inner angle for the directional cone.
  45202. */
  45203. get directionalConeInnerAngle(): number;
  45204. /**
  45205. * Gets or sets the inner angle for the directional cone.
  45206. */
  45207. set directionalConeInnerAngle(value: number);
  45208. /**
  45209. * Gets or sets the outer angle for the directional cone.
  45210. */
  45211. get directionalConeOuterAngle(): number;
  45212. /**
  45213. * Gets or sets the outer angle for the directional cone.
  45214. */
  45215. set directionalConeOuterAngle(value: number);
  45216. /**
  45217. * Sets the position of the emitter if spatial sound is enabled
  45218. * @param newPosition Defines the new posisiton
  45219. */
  45220. setPosition(newPosition: Vector3): void;
  45221. /**
  45222. * Sets the local direction of the emitter if spatial sound is enabled
  45223. * @param newLocalDirection Defines the new local direction
  45224. */
  45225. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  45226. private _updateDirection;
  45227. /** @hidden */
  45228. updateDistanceFromListener(): void;
  45229. /**
  45230. * Sets a new custom attenuation function for the sound.
  45231. * @param callback Defines the function used for the attenuation
  45232. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45233. */
  45234. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  45235. /**
  45236. * Play the sound
  45237. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45238. * @param offset (optional) Start the sound at a specific time in seconds
  45239. * @param length (optional) Sound duration (in seconds)
  45240. */
  45241. play(time?: number, offset?: number, length?: number): void;
  45242. private _onended;
  45243. /**
  45244. * Stop the sound
  45245. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45246. */
  45247. stop(time?: number): void;
  45248. /**
  45249. * Put the sound in pause
  45250. */
  45251. pause(): void;
  45252. /**
  45253. * Sets a dedicated volume for this sounds
  45254. * @param newVolume Define the new volume of the sound
  45255. * @param time Define time for gradual change to new volume
  45256. */
  45257. setVolume(newVolume: number, time?: number): void;
  45258. /**
  45259. * Set the sound play back rate
  45260. * @param newPlaybackRate Define the playback rate the sound should be played at
  45261. */
  45262. setPlaybackRate(newPlaybackRate: number): void;
  45263. /**
  45264. * Gets the volume of the sound.
  45265. * @returns the volume of the sound
  45266. */
  45267. getVolume(): number;
  45268. /**
  45269. * Attach the sound to a dedicated mesh
  45270. * @param transformNode The transform node to connect the sound with
  45271. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45272. */
  45273. attachToMesh(transformNode: TransformNode): void;
  45274. /**
  45275. * Detach the sound from the previously attached mesh
  45276. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45277. */
  45278. detachFromMesh(): void;
  45279. private _onRegisterAfterWorldMatrixUpdate;
  45280. /**
  45281. * Clone the current sound in the scene.
  45282. * @returns the new sound clone
  45283. */
  45284. clone(): Nullable<Sound>;
  45285. /**
  45286. * Gets the current underlying audio buffer containing the data
  45287. * @returns the audio buffer
  45288. */
  45289. getAudioBuffer(): Nullable<AudioBuffer>;
  45290. /**
  45291. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45292. * @returns the source node
  45293. */
  45294. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45295. /**
  45296. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45297. * @returns the gain node
  45298. */
  45299. getSoundGain(): Nullable<GainNode>;
  45300. /**
  45301. * Serializes the Sound in a JSON representation
  45302. * @returns the JSON representation of the sound
  45303. */
  45304. serialize(): any;
  45305. /**
  45306. * Parse a JSON representation of a sound to innstantiate in a given scene
  45307. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45308. * @param scene Define the scene the new parsed sound should be created in
  45309. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45310. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45311. * @returns the newly parsed sound
  45312. */
  45313. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45314. }
  45315. }
  45316. declare module BABYLON {
  45317. /**
  45318. * This defines an action helpful to play a defined sound on a triggered action.
  45319. */
  45320. export class PlaySoundAction extends Action {
  45321. private _sound;
  45322. /**
  45323. * Instantiate the action
  45324. * @param triggerOptions defines the trigger options
  45325. * @param sound defines the sound to play
  45326. * @param condition defines the trigger related conditions
  45327. */
  45328. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45329. /** @hidden */
  45330. _prepare(): void;
  45331. /**
  45332. * Execute the action and play the sound.
  45333. */
  45334. execute(): void;
  45335. /**
  45336. * Serializes the actions and its related information.
  45337. * @param parent defines the object to serialize in
  45338. * @returns the serialized object
  45339. */
  45340. serialize(parent: any): any;
  45341. }
  45342. /**
  45343. * This defines an action helpful to stop a defined sound on a triggered action.
  45344. */
  45345. export class StopSoundAction extends Action {
  45346. private _sound;
  45347. /**
  45348. * Instantiate the action
  45349. * @param triggerOptions defines the trigger options
  45350. * @param sound defines the sound to stop
  45351. * @param condition defines the trigger related conditions
  45352. */
  45353. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45354. /** @hidden */
  45355. _prepare(): void;
  45356. /**
  45357. * Execute the action and stop the sound.
  45358. */
  45359. execute(): void;
  45360. /**
  45361. * Serializes the actions and its related information.
  45362. * @param parent defines the object to serialize in
  45363. * @returns the serialized object
  45364. */
  45365. serialize(parent: any): any;
  45366. }
  45367. }
  45368. declare module BABYLON {
  45369. /**
  45370. * This defines an action responsible to change the value of a property
  45371. * by interpolating between its current value and the newly set one once triggered.
  45372. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45373. */
  45374. export class InterpolateValueAction extends Action {
  45375. /**
  45376. * Defines the path of the property where the value should be interpolated
  45377. */
  45378. propertyPath: string;
  45379. /**
  45380. * Defines the target value at the end of the interpolation.
  45381. */
  45382. value: any;
  45383. /**
  45384. * Defines the time it will take for the property to interpolate to the value.
  45385. */
  45386. duration: number;
  45387. /**
  45388. * Defines if the other scene animations should be stopped when the action has been triggered
  45389. */
  45390. stopOtherAnimations?: boolean;
  45391. /**
  45392. * Defines a callback raised once the interpolation animation has been done.
  45393. */
  45394. onInterpolationDone?: () => void;
  45395. /**
  45396. * Observable triggered once the interpolation animation has been done.
  45397. */
  45398. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45399. private _target;
  45400. private _effectiveTarget;
  45401. private _property;
  45402. /**
  45403. * Instantiate the action
  45404. * @param triggerOptions defines the trigger options
  45405. * @param target defines the object containing the value to interpolate
  45406. * @param propertyPath defines the path to the property in the target object
  45407. * @param value defines the target value at the end of the interpolation
  45408. * @param duration deines the time it will take for the property to interpolate to the value.
  45409. * @param condition defines the trigger related conditions
  45410. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45411. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45412. */
  45413. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45414. /** @hidden */
  45415. _prepare(): void;
  45416. /**
  45417. * Execute the action starts the value interpolation.
  45418. */
  45419. execute(): void;
  45420. /**
  45421. * Serializes the actions and its related information.
  45422. * @param parent defines the object to serialize in
  45423. * @returns the serialized object
  45424. */
  45425. serialize(parent: any): any;
  45426. }
  45427. }
  45428. declare module BABYLON {
  45429. /**
  45430. * This represents the default audio engine used in babylon.
  45431. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45432. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45433. */
  45434. export class AudioEngine implements IAudioEngine {
  45435. private _audioContext;
  45436. private _audioContextInitialized;
  45437. private _muteButton;
  45438. private _hostElement;
  45439. /**
  45440. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45441. */
  45442. canUseWebAudio: boolean;
  45443. /**
  45444. * The master gain node defines the global audio volume of your audio engine.
  45445. */
  45446. masterGain: GainNode;
  45447. /**
  45448. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45449. * @ignoreNaming
  45450. */
  45451. WarnedWebAudioUnsupported: boolean;
  45452. /**
  45453. * Gets whether or not mp3 are supported by your browser.
  45454. */
  45455. isMP3supported: boolean;
  45456. /**
  45457. * Gets whether or not ogg are supported by your browser.
  45458. */
  45459. isOGGsupported: boolean;
  45460. /**
  45461. * Gets whether audio has been unlocked on the device.
  45462. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45463. * a user interaction has happened.
  45464. */
  45465. unlocked: boolean;
  45466. /**
  45467. * Defines if the audio engine relies on a custom unlocked button.
  45468. * In this case, the embedded button will not be displayed.
  45469. */
  45470. useCustomUnlockedButton: boolean;
  45471. /**
  45472. * Event raised when audio has been unlocked on the browser.
  45473. */
  45474. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45475. /**
  45476. * Event raised when audio has been locked on the browser.
  45477. */
  45478. onAudioLockedObservable: Observable<IAudioEngine>;
  45479. /**
  45480. * Gets the current AudioContext if available.
  45481. */
  45482. get audioContext(): Nullable<AudioContext>;
  45483. private _connectedAnalyser;
  45484. /**
  45485. * Instantiates a new audio engine.
  45486. *
  45487. * There should be only one per page as some browsers restrict the number
  45488. * of audio contexts you can create.
  45489. * @param hostElement defines the host element where to display the mute icon if necessary
  45490. */
  45491. constructor(hostElement?: Nullable<HTMLElement>);
  45492. /**
  45493. * Flags the audio engine in Locked state.
  45494. * This happens due to new browser policies preventing audio to autoplay.
  45495. */
  45496. lock(): void;
  45497. /**
  45498. * Unlocks the audio engine once a user action has been done on the dom.
  45499. * This is helpful to resume play once browser policies have been satisfied.
  45500. */
  45501. unlock(): void;
  45502. private _resumeAudioContext;
  45503. private _initializeAudioContext;
  45504. private _tryToRun;
  45505. private _triggerRunningState;
  45506. private _triggerSuspendedState;
  45507. private _displayMuteButton;
  45508. private _moveButtonToTopLeft;
  45509. private _onResize;
  45510. private _hideMuteButton;
  45511. /**
  45512. * Destroy and release the resources associated with the audio ccontext.
  45513. */
  45514. dispose(): void;
  45515. /**
  45516. * Gets the global volume sets on the master gain.
  45517. * @returns the global volume if set or -1 otherwise
  45518. */
  45519. getGlobalVolume(): number;
  45520. /**
  45521. * Sets the global volume of your experience (sets on the master gain).
  45522. * @param newVolume Defines the new global volume of the application
  45523. */
  45524. setGlobalVolume(newVolume: number): void;
  45525. /**
  45526. * Connect the audio engine to an audio analyser allowing some amazing
  45527. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45528. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45529. * @param analyser The analyser to connect to the engine
  45530. */
  45531. connectToAnalyser(analyser: Analyser): void;
  45532. }
  45533. }
  45534. declare module BABYLON {
  45535. /**
  45536. * Options allowed during the creation of a sound track.
  45537. */
  45538. export interface ISoundTrackOptions {
  45539. /**
  45540. * The volume the sound track should take during creation
  45541. */
  45542. volume?: number;
  45543. /**
  45544. * Define if the sound track is the main sound track of the scene
  45545. */
  45546. mainTrack?: boolean;
  45547. }
  45548. /**
  45549. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45550. * It will be also used in a future release to apply effects on a specific track.
  45551. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45552. */
  45553. export class SoundTrack {
  45554. /**
  45555. * The unique identifier of the sound track in the scene.
  45556. */
  45557. id: number;
  45558. /**
  45559. * The list of sounds included in the sound track.
  45560. */
  45561. soundCollection: Array<Sound>;
  45562. private _outputAudioNode;
  45563. private _scene;
  45564. private _connectedAnalyser;
  45565. private _options;
  45566. private _isInitialized;
  45567. /**
  45568. * Creates a new sound track.
  45569. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45570. * @param scene Define the scene the sound track belongs to
  45571. * @param options
  45572. */
  45573. constructor(scene: Scene, options?: ISoundTrackOptions);
  45574. private _initializeSoundTrackAudioGraph;
  45575. /**
  45576. * Release the sound track and its associated resources
  45577. */
  45578. dispose(): void;
  45579. /**
  45580. * Adds a sound to this sound track
  45581. * @param sound define the cound to add
  45582. * @ignoreNaming
  45583. */
  45584. addSound(sound: Sound): void;
  45585. /**
  45586. * Removes a sound to this sound track
  45587. * @param sound define the cound to remove
  45588. * @ignoreNaming
  45589. */
  45590. removeSound(sound: Sound): void;
  45591. /**
  45592. * Set a global volume for the full sound track.
  45593. * @param newVolume Define the new volume of the sound track
  45594. */
  45595. setVolume(newVolume: number): void;
  45596. /**
  45597. * Switch the panning model to HRTF:
  45598. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45599. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45600. */
  45601. switchPanningModelToHRTF(): void;
  45602. /**
  45603. * Switch the panning model to Equal Power:
  45604. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45605. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45606. */
  45607. switchPanningModelToEqualPower(): void;
  45608. /**
  45609. * Connect the sound track to an audio analyser allowing some amazing
  45610. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45611. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45612. * @param analyser The analyser to connect to the engine
  45613. */
  45614. connectToAnalyser(analyser: Analyser): void;
  45615. }
  45616. }
  45617. declare module BABYLON {
  45618. interface AbstractScene {
  45619. /**
  45620. * The list of sounds used in the scene.
  45621. */
  45622. sounds: Nullable<Array<Sound>>;
  45623. }
  45624. interface Scene {
  45625. /**
  45626. * @hidden
  45627. * Backing field
  45628. */
  45629. _mainSoundTrack: SoundTrack;
  45630. /**
  45631. * The main sound track played by the scene.
  45632. * It cotains your primary collection of sounds.
  45633. */
  45634. mainSoundTrack: SoundTrack;
  45635. /**
  45636. * The list of sound tracks added to the scene
  45637. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45638. */
  45639. soundTracks: Nullable<Array<SoundTrack>>;
  45640. /**
  45641. * Gets a sound using a given name
  45642. * @param name defines the name to search for
  45643. * @return the found sound or null if not found at all.
  45644. */
  45645. getSoundByName(name: string): Nullable<Sound>;
  45646. /**
  45647. * Gets or sets if audio support is enabled
  45648. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45649. */
  45650. audioEnabled: boolean;
  45651. /**
  45652. * Gets or sets if audio will be output to headphones
  45653. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45654. */
  45655. headphone: boolean;
  45656. /**
  45657. * Gets or sets custom audio listener position provider
  45658. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45659. */
  45660. audioListenerPositionProvider: Nullable<() => Vector3>;
  45661. /**
  45662. * Gets or sets a refresh rate when using 3D audio positioning
  45663. */
  45664. audioPositioningRefreshRate: number;
  45665. }
  45666. /**
  45667. * Defines the sound scene component responsible to manage any sounds
  45668. * in a given scene.
  45669. */
  45670. export class AudioSceneComponent implements ISceneSerializableComponent {
  45671. private static _CameraDirectionLH;
  45672. private static _CameraDirectionRH;
  45673. /**
  45674. * The component name helpfull to identify the component in the list of scene components.
  45675. */
  45676. readonly name: string;
  45677. /**
  45678. * The scene the component belongs to.
  45679. */
  45680. scene: Scene;
  45681. private _audioEnabled;
  45682. /**
  45683. * Gets whether audio is enabled or not.
  45684. * Please use related enable/disable method to switch state.
  45685. */
  45686. get audioEnabled(): boolean;
  45687. private _headphone;
  45688. /**
  45689. * Gets whether audio is outputing to headphone or not.
  45690. * Please use the according Switch methods to change output.
  45691. */
  45692. get headphone(): boolean;
  45693. /**
  45694. * Gets or sets a refresh rate when using 3D audio positioning
  45695. */
  45696. audioPositioningRefreshRate: number;
  45697. private _audioListenerPositionProvider;
  45698. /**
  45699. * Gets the current audio listener position provider
  45700. */
  45701. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45702. /**
  45703. * Sets a custom listener position for all sounds in the scene
  45704. * By default, this is the position of the first active camera
  45705. */
  45706. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45707. /**
  45708. * Creates a new instance of the component for the given scene
  45709. * @param scene Defines the scene to register the component in
  45710. */
  45711. constructor(scene: Scene);
  45712. /**
  45713. * Registers the component in a given scene
  45714. */
  45715. register(): void;
  45716. /**
  45717. * Rebuilds the elements related to this component in case of
  45718. * context lost for instance.
  45719. */
  45720. rebuild(): void;
  45721. /**
  45722. * Serializes the component data to the specified json object
  45723. * @param serializationObject The object to serialize to
  45724. */
  45725. serialize(serializationObject: any): void;
  45726. /**
  45727. * Adds all the elements from the container to the scene
  45728. * @param container the container holding the elements
  45729. */
  45730. addFromContainer(container: AbstractScene): void;
  45731. /**
  45732. * Removes all the elements in the container from the scene
  45733. * @param container contains the elements to remove
  45734. * @param dispose if the removed element should be disposed (default: false)
  45735. */
  45736. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45737. /**
  45738. * Disposes the component and the associated ressources.
  45739. */
  45740. dispose(): void;
  45741. /**
  45742. * Disables audio in the associated scene.
  45743. */
  45744. disableAudio(): void;
  45745. /**
  45746. * Enables audio in the associated scene.
  45747. */
  45748. enableAudio(): void;
  45749. /**
  45750. * Switch audio to headphone output.
  45751. */
  45752. switchAudioModeForHeadphones(): void;
  45753. /**
  45754. * Switch audio to normal speakers.
  45755. */
  45756. switchAudioModeForNormalSpeakers(): void;
  45757. private _cachedCameraDirection;
  45758. private _cachedCameraPosition;
  45759. private _lastCheck;
  45760. private _afterRender;
  45761. }
  45762. }
  45763. declare module BABYLON {
  45764. /**
  45765. * Wraps one or more Sound objects and selects one with random weight for playback.
  45766. */
  45767. export class WeightedSound {
  45768. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45769. loop: boolean;
  45770. private _coneInnerAngle;
  45771. private _coneOuterAngle;
  45772. private _volume;
  45773. /** A Sound is currently playing. */
  45774. isPlaying: boolean;
  45775. /** A Sound is currently paused. */
  45776. isPaused: boolean;
  45777. private _sounds;
  45778. private _weights;
  45779. private _currentIndex?;
  45780. /**
  45781. * Creates a new WeightedSound from the list of sounds given.
  45782. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45783. * @param sounds Array of Sounds that will be selected from.
  45784. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45785. */
  45786. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45787. /**
  45788. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45789. */
  45790. get directionalConeInnerAngle(): number;
  45791. /**
  45792. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45793. */
  45794. set directionalConeInnerAngle(value: number);
  45795. /**
  45796. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45797. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45798. */
  45799. get directionalConeOuterAngle(): number;
  45800. /**
  45801. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45802. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45803. */
  45804. set directionalConeOuterAngle(value: number);
  45805. /**
  45806. * Playback volume.
  45807. */
  45808. get volume(): number;
  45809. /**
  45810. * Playback volume.
  45811. */
  45812. set volume(value: number);
  45813. private _onended;
  45814. /**
  45815. * Suspend playback
  45816. */
  45817. pause(): void;
  45818. /**
  45819. * Stop playback
  45820. */
  45821. stop(): void;
  45822. /**
  45823. * Start playback.
  45824. * @param startOffset Position the clip head at a specific time in seconds.
  45825. */
  45826. play(startOffset?: number): void;
  45827. }
  45828. }
  45829. declare module BABYLON {
  45830. /**
  45831. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45832. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45833. */
  45834. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45835. /**
  45836. * Gets the name of the behavior.
  45837. */
  45838. get name(): string;
  45839. /**
  45840. * The easing function used by animations
  45841. */
  45842. static EasingFunction: BackEase;
  45843. /**
  45844. * The easing mode used by animations
  45845. */
  45846. static EasingMode: number;
  45847. /**
  45848. * The duration of the animation, in milliseconds
  45849. */
  45850. transitionDuration: number;
  45851. /**
  45852. * Length of the distance animated by the transition when lower radius is reached
  45853. */
  45854. lowerRadiusTransitionRange: number;
  45855. /**
  45856. * Length of the distance animated by the transition when upper radius is reached
  45857. */
  45858. upperRadiusTransitionRange: number;
  45859. private _autoTransitionRange;
  45860. /**
  45861. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45862. */
  45863. get autoTransitionRange(): boolean;
  45864. /**
  45865. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45866. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45867. */
  45868. set autoTransitionRange(value: boolean);
  45869. private _attachedCamera;
  45870. private _onAfterCheckInputsObserver;
  45871. private _onMeshTargetChangedObserver;
  45872. /**
  45873. * Initializes the behavior.
  45874. */
  45875. init(): void;
  45876. /**
  45877. * Attaches the behavior to its arc rotate camera.
  45878. * @param camera Defines the camera to attach the behavior to
  45879. */
  45880. attach(camera: ArcRotateCamera): void;
  45881. /**
  45882. * Detaches the behavior from its current arc rotate camera.
  45883. */
  45884. detach(): void;
  45885. private _radiusIsAnimating;
  45886. private _radiusBounceTransition;
  45887. private _animatables;
  45888. private _cachedWheelPrecision;
  45889. /**
  45890. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45891. * @param radiusLimit The limit to check against.
  45892. * @return Bool to indicate if at limit.
  45893. */
  45894. private _isRadiusAtLimit;
  45895. /**
  45896. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45897. * @param radiusDelta The delta by which to animate to. Can be negative.
  45898. */
  45899. private _applyBoundRadiusAnimation;
  45900. /**
  45901. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45902. */
  45903. protected _clearAnimationLocks(): void;
  45904. /**
  45905. * Stops and removes all animations that have been applied to the camera
  45906. */
  45907. stopAllAnimations(): void;
  45908. }
  45909. }
  45910. declare module BABYLON {
  45911. /**
  45912. * 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.
  45913. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45914. */
  45915. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45916. /**
  45917. * Gets the name of the behavior.
  45918. */
  45919. get name(): string;
  45920. private _mode;
  45921. private _radiusScale;
  45922. private _positionScale;
  45923. private _defaultElevation;
  45924. private _elevationReturnTime;
  45925. private _elevationReturnWaitTime;
  45926. private _zoomStopsAnimation;
  45927. private _framingTime;
  45928. /**
  45929. * The easing function used by animations
  45930. */
  45931. static EasingFunction: ExponentialEase;
  45932. /**
  45933. * The easing mode used by animations
  45934. */
  45935. static EasingMode: number;
  45936. /**
  45937. * Sets the current mode used by the behavior
  45938. */
  45939. set mode(mode: number);
  45940. /**
  45941. * Gets current mode used by the behavior.
  45942. */
  45943. get mode(): number;
  45944. /**
  45945. * Sets the scale applied to the radius (1 by default)
  45946. */
  45947. set radiusScale(radius: number);
  45948. /**
  45949. * Gets the scale applied to the radius
  45950. */
  45951. get radiusScale(): number;
  45952. /**
  45953. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45954. */
  45955. set positionScale(scale: number);
  45956. /**
  45957. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45958. */
  45959. get positionScale(): number;
  45960. /**
  45961. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45962. * behaviour is triggered, in radians.
  45963. */
  45964. set defaultElevation(elevation: number);
  45965. /**
  45966. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45967. * behaviour is triggered, in radians.
  45968. */
  45969. get defaultElevation(): number;
  45970. /**
  45971. * Sets the time (in milliseconds) taken to return to the default beta position.
  45972. * Negative value indicates camera should not return to default.
  45973. */
  45974. set elevationReturnTime(speed: number);
  45975. /**
  45976. * Gets the time (in milliseconds) taken to return to the default beta position.
  45977. * Negative value indicates camera should not return to default.
  45978. */
  45979. get elevationReturnTime(): number;
  45980. /**
  45981. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45982. */
  45983. set elevationReturnWaitTime(time: number);
  45984. /**
  45985. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45986. */
  45987. get elevationReturnWaitTime(): number;
  45988. /**
  45989. * Sets the flag that indicates if user zooming should stop animation.
  45990. */
  45991. set zoomStopsAnimation(flag: boolean);
  45992. /**
  45993. * Gets the flag that indicates if user zooming should stop animation.
  45994. */
  45995. get zoomStopsAnimation(): boolean;
  45996. /**
  45997. * Sets the transition time when framing the mesh, in milliseconds
  45998. */
  45999. set framingTime(time: number);
  46000. /**
  46001. * Gets the transition time when framing the mesh, in milliseconds
  46002. */
  46003. get framingTime(): number;
  46004. /**
  46005. * Define if the behavior should automatically change the configured
  46006. * camera limits and sensibilities.
  46007. */
  46008. autoCorrectCameraLimitsAndSensibility: boolean;
  46009. private _onPrePointerObservableObserver;
  46010. private _onAfterCheckInputsObserver;
  46011. private _onMeshTargetChangedObserver;
  46012. private _attachedCamera;
  46013. private _isPointerDown;
  46014. private _lastInteractionTime;
  46015. /**
  46016. * Initializes the behavior.
  46017. */
  46018. init(): void;
  46019. /**
  46020. * Attaches the behavior to its arc rotate camera.
  46021. * @param camera Defines the camera to attach the behavior to
  46022. */
  46023. attach(camera: ArcRotateCamera): void;
  46024. /**
  46025. * Detaches the behavior from its current arc rotate camera.
  46026. */
  46027. detach(): void;
  46028. private _animatables;
  46029. private _betaIsAnimating;
  46030. private _betaTransition;
  46031. private _radiusTransition;
  46032. private _vectorTransition;
  46033. /**
  46034. * Targets the given mesh and updates zoom level accordingly.
  46035. * @param mesh The mesh to target.
  46036. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46037. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46038. */
  46039. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46040. /**
  46041. * Targets the given mesh with its children and updates zoom level accordingly.
  46042. * @param mesh The mesh to target.
  46043. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46044. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46045. */
  46046. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46047. /**
  46048. * Targets the given meshes with their children and updates zoom level accordingly.
  46049. * @param meshes The mesh to target.
  46050. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46051. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46052. */
  46053. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46054. /**
  46055. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  46056. * @param minimumWorld Determines the smaller position of the bounding box extend
  46057. * @param maximumWorld Determines the bigger position of the bounding box extend
  46058. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46059. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46060. */
  46061. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46062. /**
  46063. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  46064. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  46065. * frustum width.
  46066. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  46067. * to fully enclose the mesh in the viewing frustum.
  46068. */
  46069. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  46070. /**
  46071. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  46072. * is automatically returned to its default position (expected to be above ground plane).
  46073. */
  46074. private _maintainCameraAboveGround;
  46075. /**
  46076. * Returns the frustum slope based on the canvas ratio and camera FOV
  46077. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  46078. */
  46079. private _getFrustumSlope;
  46080. /**
  46081. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  46082. */
  46083. private _clearAnimationLocks;
  46084. /**
  46085. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46086. */
  46087. private _applyUserInteraction;
  46088. /**
  46089. * Stops and removes all animations that have been applied to the camera
  46090. */
  46091. stopAllAnimations(): void;
  46092. /**
  46093. * Gets a value indicating if the user is moving the camera
  46094. */
  46095. get isUserIsMoving(): boolean;
  46096. /**
  46097. * The camera can move all the way towards the mesh.
  46098. */
  46099. static IgnoreBoundsSizeMode: number;
  46100. /**
  46101. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  46102. */
  46103. static FitFrustumSidesMode: number;
  46104. }
  46105. }
  46106. declare module BABYLON {
  46107. /**
  46108. * Base class for Camera Pointer Inputs.
  46109. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  46110. * for example usage.
  46111. */
  46112. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  46113. /**
  46114. * Defines the camera the input is attached to.
  46115. */
  46116. abstract camera: Camera;
  46117. /**
  46118. * Whether keyboard modifier keys are pressed at time of last mouse event.
  46119. */
  46120. protected _altKey: boolean;
  46121. protected _ctrlKey: boolean;
  46122. protected _metaKey: boolean;
  46123. protected _shiftKey: boolean;
  46124. /**
  46125. * Which mouse buttons were pressed at time of last mouse event.
  46126. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  46127. */
  46128. protected _buttonsPressed: number;
  46129. /**
  46130. * Defines the buttons associated with the input to handle camera move.
  46131. */
  46132. buttons: number[];
  46133. /**
  46134. * Attach the input controls to a specific dom element to get the input from.
  46135. * @param element Defines the element the controls should be listened from
  46136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46137. */
  46138. attachControl(noPreventDefault?: boolean): void;
  46139. /**
  46140. * Detach the current controls from the specified dom element.
  46141. */
  46142. detachControl(): void;
  46143. /**
  46144. * Gets the class name of the current input.
  46145. * @returns the class name
  46146. */
  46147. getClassName(): string;
  46148. /**
  46149. * Get the friendly name associated with the input class.
  46150. * @returns the input friendly name
  46151. */
  46152. getSimpleName(): string;
  46153. /**
  46154. * Called on pointer POINTERDOUBLETAP event.
  46155. * Override this method to provide functionality on POINTERDOUBLETAP event.
  46156. */
  46157. protected onDoubleTap(type: string): void;
  46158. /**
  46159. * Called on pointer POINTERMOVE event if only a single touch is active.
  46160. * Override this method to provide functionality.
  46161. */
  46162. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46163. /**
  46164. * Called on pointer POINTERMOVE event if multiple touches are active.
  46165. * Override this method to provide functionality.
  46166. */
  46167. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46168. /**
  46169. * Called on JS contextmenu event.
  46170. * Override this method to provide functionality.
  46171. */
  46172. protected onContextMenu(evt: PointerEvent): void;
  46173. /**
  46174. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46175. * press.
  46176. * Override this method to provide functionality.
  46177. */
  46178. protected onButtonDown(evt: PointerEvent): void;
  46179. /**
  46180. * Called each time a new POINTERUP event occurs. Ie, for each button
  46181. * release.
  46182. * Override this method to provide functionality.
  46183. */
  46184. protected onButtonUp(evt: PointerEvent): void;
  46185. /**
  46186. * Called when window becomes inactive.
  46187. * Override this method to provide functionality.
  46188. */
  46189. protected onLostFocus(): void;
  46190. private _pointerInput;
  46191. private _observer;
  46192. private _onLostFocus;
  46193. private pointA;
  46194. private pointB;
  46195. }
  46196. }
  46197. declare module BABYLON {
  46198. /**
  46199. * Manage the pointers inputs to control an arc rotate camera.
  46200. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46201. */
  46202. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  46203. /**
  46204. * Defines the camera the input is attached to.
  46205. */
  46206. camera: ArcRotateCamera;
  46207. /**
  46208. * Gets the class name of the current input.
  46209. * @returns the class name
  46210. */
  46211. getClassName(): string;
  46212. /**
  46213. * Defines the buttons associated with the input to handle camera move.
  46214. */
  46215. buttons: number[];
  46216. /**
  46217. * Defines the pointer angular sensibility along the X axis or how fast is
  46218. * the camera rotating.
  46219. */
  46220. angularSensibilityX: number;
  46221. /**
  46222. * Defines the pointer angular sensibility along the Y axis or how fast is
  46223. * the camera rotating.
  46224. */
  46225. angularSensibilityY: number;
  46226. /**
  46227. * Defines the pointer pinch precision or how fast is the camera zooming.
  46228. */
  46229. pinchPrecision: number;
  46230. /**
  46231. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46232. * from 0.
  46233. * It defines the percentage of current camera.radius to use as delta when
  46234. * pinch zoom is used.
  46235. */
  46236. pinchDeltaPercentage: number;
  46237. /**
  46238. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46239. * that any object in the plane at the camera's target point will scale
  46240. * perfectly with finger motion.
  46241. * Overrides pinchDeltaPercentage and pinchPrecision.
  46242. */
  46243. useNaturalPinchZoom: boolean;
  46244. /**
  46245. * Defines the pointer panning sensibility or how fast is the camera moving.
  46246. */
  46247. panningSensibility: number;
  46248. /**
  46249. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  46250. */
  46251. multiTouchPanning: boolean;
  46252. /**
  46253. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  46254. * zoom (pinch) through multitouch.
  46255. */
  46256. multiTouchPanAndZoom: boolean;
  46257. /**
  46258. * Revers pinch action direction.
  46259. */
  46260. pinchInwards: boolean;
  46261. private _isPanClick;
  46262. private _twoFingerActivityCount;
  46263. private _isPinching;
  46264. /**
  46265. * Called on pointer POINTERMOVE event if only a single touch is active.
  46266. */
  46267. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46268. /**
  46269. * Called on pointer POINTERDOUBLETAP event.
  46270. */
  46271. protected onDoubleTap(type: string): void;
  46272. /**
  46273. * Called on pointer POINTERMOVE event if multiple touches are active.
  46274. */
  46275. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46276. /**
  46277. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46278. * press.
  46279. */
  46280. protected onButtonDown(evt: PointerEvent): void;
  46281. /**
  46282. * Called each time a new POINTERUP event occurs. Ie, for each button
  46283. * release.
  46284. */
  46285. protected onButtonUp(evt: PointerEvent): void;
  46286. /**
  46287. * Called when window becomes inactive.
  46288. */
  46289. protected onLostFocus(): void;
  46290. }
  46291. }
  46292. declare module BABYLON {
  46293. /**
  46294. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46295. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46296. */
  46297. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46298. /**
  46299. * Defines the camera the input is attached to.
  46300. */
  46301. camera: ArcRotateCamera;
  46302. /**
  46303. * Defines the list of key codes associated with the up action (increase alpha)
  46304. */
  46305. keysUp: number[];
  46306. /**
  46307. * Defines the list of key codes associated with the down action (decrease alpha)
  46308. */
  46309. keysDown: number[];
  46310. /**
  46311. * Defines the list of key codes associated with the left action (increase beta)
  46312. */
  46313. keysLeft: number[];
  46314. /**
  46315. * Defines the list of key codes associated with the right action (decrease beta)
  46316. */
  46317. keysRight: number[];
  46318. /**
  46319. * Defines the list of key codes associated with the reset action.
  46320. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46321. */
  46322. keysReset: number[];
  46323. /**
  46324. * Defines the panning sensibility of the inputs.
  46325. * (How fast is the camera panning)
  46326. */
  46327. panningSensibility: number;
  46328. /**
  46329. * Defines the zooming sensibility of the inputs.
  46330. * (How fast is the camera zooming)
  46331. */
  46332. zoomingSensibility: number;
  46333. /**
  46334. * Defines whether maintaining the alt key down switch the movement mode from
  46335. * orientation to zoom.
  46336. */
  46337. useAltToZoom: boolean;
  46338. /**
  46339. * Rotation speed of the camera
  46340. */
  46341. angularSpeed: number;
  46342. private _keys;
  46343. private _ctrlPressed;
  46344. private _altPressed;
  46345. private _onCanvasBlurObserver;
  46346. private _onKeyboardObserver;
  46347. private _engine;
  46348. private _scene;
  46349. /**
  46350. * Attach the input controls to a specific dom element to get the input from.
  46351. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46352. */
  46353. attachControl(noPreventDefault?: boolean): void;
  46354. /**
  46355. * Detach the current controls from the specified dom element.
  46356. */
  46357. detachControl(): void;
  46358. /**
  46359. * Update the current camera state depending on the inputs that have been used this frame.
  46360. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46361. */
  46362. checkInputs(): void;
  46363. /**
  46364. * Gets the class name of the current intput.
  46365. * @returns the class name
  46366. */
  46367. getClassName(): string;
  46368. /**
  46369. * Get the friendly name associated with the input class.
  46370. * @returns the input friendly name
  46371. */
  46372. getSimpleName(): string;
  46373. }
  46374. }
  46375. declare module BABYLON {
  46376. /**
  46377. * Manage the mouse wheel inputs to control an arc rotate camera.
  46378. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46379. */
  46380. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46381. /**
  46382. * Defines the camera the input is attached to.
  46383. */
  46384. camera: ArcRotateCamera;
  46385. /**
  46386. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46387. */
  46388. wheelPrecision: number;
  46389. /**
  46390. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46391. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46392. */
  46393. wheelDeltaPercentage: number;
  46394. private _wheel;
  46395. private _observer;
  46396. private computeDeltaFromMouseWheelLegacyEvent;
  46397. /**
  46398. * Attach the input controls to a specific dom element to get the input from.
  46399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46400. */
  46401. attachControl(noPreventDefault?: boolean): void;
  46402. /**
  46403. * Detach the current controls from the specified dom element.
  46404. */
  46405. detachControl(): void;
  46406. /**
  46407. * Gets the class name of the current intput.
  46408. * @returns the class name
  46409. */
  46410. getClassName(): string;
  46411. /**
  46412. * Get the friendly name associated with the input class.
  46413. * @returns the input friendly name
  46414. */
  46415. getSimpleName(): string;
  46416. }
  46417. }
  46418. declare module BABYLON {
  46419. /**
  46420. * Default Inputs manager for the ArcRotateCamera.
  46421. * It groups all the default supported inputs for ease of use.
  46422. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46423. */
  46424. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46425. /**
  46426. * Instantiates a new ArcRotateCameraInputsManager.
  46427. * @param camera Defines the camera the inputs belong to
  46428. */
  46429. constructor(camera: ArcRotateCamera);
  46430. /**
  46431. * Add mouse wheel input support to the input manager.
  46432. * @returns the current input manager
  46433. */
  46434. addMouseWheel(): ArcRotateCameraInputsManager;
  46435. /**
  46436. * Add pointers input support to the input manager.
  46437. * @returns the current input manager
  46438. */
  46439. addPointers(): ArcRotateCameraInputsManager;
  46440. /**
  46441. * Add keyboard input support to the input manager.
  46442. * @returns the current input manager
  46443. */
  46444. addKeyboard(): ArcRotateCameraInputsManager;
  46445. }
  46446. }
  46447. declare module BABYLON {
  46448. /**
  46449. * This represents an orbital type of camera.
  46450. *
  46451. * 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.
  46452. * 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.
  46453. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46454. */
  46455. export class ArcRotateCamera extends TargetCamera {
  46456. /**
  46457. * Defines the rotation angle of the camera along the longitudinal axis.
  46458. */
  46459. alpha: number;
  46460. /**
  46461. * Defines the rotation angle of the camera along the latitudinal axis.
  46462. */
  46463. beta: number;
  46464. /**
  46465. * Defines the radius of the camera from it s target point.
  46466. */
  46467. radius: number;
  46468. protected _target: Vector3;
  46469. protected _targetHost: Nullable<AbstractMesh>;
  46470. /**
  46471. * Defines the target point of the camera.
  46472. * The camera looks towards it form the radius distance.
  46473. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46474. */
  46475. get target(): Vector3;
  46476. set target(value: Vector3);
  46477. /**
  46478. * Define the current local position of the camera in the scene
  46479. */
  46480. get position(): Vector3;
  46481. set position(newPosition: Vector3);
  46482. protected _upToYMatrix: Matrix;
  46483. protected _YToUpMatrix: Matrix;
  46484. /**
  46485. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46486. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46487. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46488. */
  46489. set upVector(vec: Vector3);
  46490. get upVector(): Vector3;
  46491. /**
  46492. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46493. */
  46494. setMatUp(): void;
  46495. /**
  46496. * Current inertia value on the longitudinal axis.
  46497. * The bigger this number the longer it will take for the camera to stop.
  46498. */
  46499. inertialAlphaOffset: number;
  46500. /**
  46501. * Current inertia value on the latitudinal axis.
  46502. * The bigger this number the longer it will take for the camera to stop.
  46503. */
  46504. inertialBetaOffset: number;
  46505. /**
  46506. * Current inertia value on the radius axis.
  46507. * The bigger this number the longer it will take for the camera to stop.
  46508. */
  46509. inertialRadiusOffset: number;
  46510. /**
  46511. * Minimum allowed angle on the longitudinal axis.
  46512. * This can help limiting how the Camera is able to move in the scene.
  46513. */
  46514. lowerAlphaLimit: Nullable<number>;
  46515. /**
  46516. * Maximum allowed angle on the longitudinal axis.
  46517. * This can help limiting how the Camera is able to move in the scene.
  46518. */
  46519. upperAlphaLimit: Nullable<number>;
  46520. /**
  46521. * Minimum allowed angle on the latitudinal axis.
  46522. * This can help limiting how the Camera is able to move in the scene.
  46523. */
  46524. lowerBetaLimit: number;
  46525. /**
  46526. * Maximum allowed angle on the latitudinal axis.
  46527. * This can help limiting how the Camera is able to move in the scene.
  46528. */
  46529. upperBetaLimit: number;
  46530. /**
  46531. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46532. * This can help limiting how the Camera is able to move in the scene.
  46533. */
  46534. lowerRadiusLimit: Nullable<number>;
  46535. /**
  46536. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46537. * This can help limiting how the Camera is able to move in the scene.
  46538. */
  46539. upperRadiusLimit: Nullable<number>;
  46540. /**
  46541. * Defines the current inertia value used during panning of the camera along the X axis.
  46542. */
  46543. inertialPanningX: number;
  46544. /**
  46545. * Defines the current inertia value used during panning of the camera along the Y axis.
  46546. */
  46547. inertialPanningY: number;
  46548. /**
  46549. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46550. * Basically if your fingers moves away from more than this distance you will be considered
  46551. * in pinch mode.
  46552. */
  46553. pinchToPanMaxDistance: number;
  46554. /**
  46555. * Defines the maximum distance the camera can pan.
  46556. * This could help keeping the cammera always in your scene.
  46557. */
  46558. panningDistanceLimit: Nullable<number>;
  46559. /**
  46560. * Defines the target of the camera before paning.
  46561. */
  46562. panningOriginTarget: Vector3;
  46563. /**
  46564. * Defines the value of the inertia used during panning.
  46565. * 0 would mean stop inertia and one would mean no decelleration at all.
  46566. */
  46567. panningInertia: number;
  46568. /**
  46569. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46570. */
  46571. get angularSensibilityX(): number;
  46572. set angularSensibilityX(value: number);
  46573. /**
  46574. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46575. */
  46576. get angularSensibilityY(): number;
  46577. set angularSensibilityY(value: number);
  46578. /**
  46579. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46580. */
  46581. get pinchPrecision(): number;
  46582. set pinchPrecision(value: number);
  46583. /**
  46584. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46585. * It will be used instead of pinchDeltaPrecision if different from 0.
  46586. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46587. */
  46588. get pinchDeltaPercentage(): number;
  46589. set pinchDeltaPercentage(value: number);
  46590. /**
  46591. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46592. * and pinch delta percentage.
  46593. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46594. * that any object in the plane at the camera's target point will scale
  46595. * perfectly with finger motion.
  46596. */
  46597. get useNaturalPinchZoom(): boolean;
  46598. set useNaturalPinchZoom(value: boolean);
  46599. /**
  46600. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46601. */
  46602. get panningSensibility(): number;
  46603. set panningSensibility(value: number);
  46604. /**
  46605. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46606. */
  46607. get keysUp(): number[];
  46608. set keysUp(value: number[]);
  46609. /**
  46610. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46611. */
  46612. get keysDown(): number[];
  46613. set keysDown(value: number[]);
  46614. /**
  46615. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46616. */
  46617. get keysLeft(): number[];
  46618. set keysLeft(value: number[]);
  46619. /**
  46620. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46621. */
  46622. get keysRight(): number[];
  46623. set keysRight(value: number[]);
  46624. /**
  46625. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46626. */
  46627. get wheelPrecision(): number;
  46628. set wheelPrecision(value: number);
  46629. /**
  46630. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46631. * It will be used instead of pinchDeltaPrecision if different from 0.
  46632. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46633. */
  46634. get wheelDeltaPercentage(): number;
  46635. set wheelDeltaPercentage(value: number);
  46636. /**
  46637. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46638. */
  46639. zoomOnFactor: number;
  46640. /**
  46641. * Defines a screen offset for the camera position.
  46642. */
  46643. targetScreenOffset: Vector2;
  46644. /**
  46645. * Allows the camera to be completely reversed.
  46646. * If false the camera can not arrive upside down.
  46647. */
  46648. allowUpsideDown: boolean;
  46649. /**
  46650. * Define if double tap/click is used to restore the previously saved state of the camera.
  46651. */
  46652. useInputToRestoreState: boolean;
  46653. /** @hidden */
  46654. _viewMatrix: Matrix;
  46655. /** @hidden */
  46656. _useCtrlForPanning: boolean;
  46657. /** @hidden */
  46658. _panningMouseButton: number;
  46659. /**
  46660. * Defines the input associated to the camera.
  46661. */
  46662. inputs: ArcRotateCameraInputsManager;
  46663. /** @hidden */
  46664. _reset: () => void;
  46665. /**
  46666. * Defines the allowed panning axis.
  46667. */
  46668. panningAxis: Vector3;
  46669. protected _localDirection: Vector3;
  46670. protected _transformedDirection: Vector3;
  46671. private _bouncingBehavior;
  46672. /**
  46673. * Gets the bouncing behavior of the camera if it has been enabled.
  46674. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46675. */
  46676. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46677. /**
  46678. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46679. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46680. */
  46681. get useBouncingBehavior(): boolean;
  46682. set useBouncingBehavior(value: boolean);
  46683. private _framingBehavior;
  46684. /**
  46685. * Gets the framing behavior of the camera if it has been enabled.
  46686. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46687. */
  46688. get framingBehavior(): Nullable<FramingBehavior>;
  46689. /**
  46690. * Defines if the framing behavior of the camera is enabled on the camera.
  46691. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46692. */
  46693. get useFramingBehavior(): boolean;
  46694. set useFramingBehavior(value: boolean);
  46695. private _autoRotationBehavior;
  46696. /**
  46697. * Gets the auto rotation behavior of the camera if it has been enabled.
  46698. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46699. */
  46700. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46701. /**
  46702. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46703. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46704. */
  46705. get useAutoRotationBehavior(): boolean;
  46706. set useAutoRotationBehavior(value: boolean);
  46707. /**
  46708. * Observable triggered when the mesh target has been changed on the camera.
  46709. */
  46710. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46711. /**
  46712. * Event raised when the camera is colliding with a mesh.
  46713. */
  46714. onCollide: (collidedMesh: AbstractMesh) => void;
  46715. /**
  46716. * Defines whether the camera should check collision with the objects oh the scene.
  46717. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46718. */
  46719. checkCollisions: boolean;
  46720. /**
  46721. * Defines the collision radius of the camera.
  46722. * This simulates a sphere around the camera.
  46723. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46724. */
  46725. collisionRadius: Vector3;
  46726. protected _collider: Collider;
  46727. protected _previousPosition: Vector3;
  46728. protected _collisionVelocity: Vector3;
  46729. protected _newPosition: Vector3;
  46730. protected _previousAlpha: number;
  46731. protected _previousBeta: number;
  46732. protected _previousRadius: number;
  46733. protected _collisionTriggered: boolean;
  46734. protected _targetBoundingCenter: Nullable<Vector3>;
  46735. private _computationVector;
  46736. /**
  46737. * Instantiates a new ArcRotateCamera in a given scene
  46738. * @param name Defines the name of the camera
  46739. * @param alpha Defines the camera rotation along the logitudinal axis
  46740. * @param beta Defines the camera rotation along the latitudinal axis
  46741. * @param radius Defines the camera distance from its target
  46742. * @param target Defines the camera target
  46743. * @param scene Defines the scene the camera belongs to
  46744. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46745. */
  46746. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46747. /** @hidden */
  46748. _initCache(): void;
  46749. /** @hidden */
  46750. _updateCache(ignoreParentClass?: boolean): void;
  46751. protected _getTargetPosition(): Vector3;
  46752. private _storedAlpha;
  46753. private _storedBeta;
  46754. private _storedRadius;
  46755. private _storedTarget;
  46756. private _storedTargetScreenOffset;
  46757. /**
  46758. * Stores the current state of the camera (alpha, beta, radius and target)
  46759. * @returns the camera itself
  46760. */
  46761. storeState(): Camera;
  46762. /**
  46763. * @hidden
  46764. * Restored camera state. You must call storeState() first
  46765. */
  46766. _restoreStateValues(): boolean;
  46767. /** @hidden */
  46768. _isSynchronizedViewMatrix(): boolean;
  46769. /**
  46770. * Attach the input controls to a specific dom element to get the input from.
  46771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46772. */
  46773. attachControl(noPreventDefault?: boolean): void;
  46774. /**
  46775. * Attach the input controls to a specific dom element to get the input from.
  46776. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46778. */
  46779. attachControl(ignored: any, noPreventDefault?: boolean): void;
  46780. /**
  46781. * Attached controls to the current camera.
  46782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46783. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46784. */
  46785. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46786. /**
  46787. * Attached controls to the current camera.
  46788. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46790. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46791. */
  46792. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46793. /**
  46794. * Attached controls to the current camera.
  46795. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46796. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46797. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46798. */
  46799. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  46800. /**
  46801. * Detach the current controls from the specified dom element.
  46802. */
  46803. detachControl(): void;
  46804. /**
  46805. * Detach the current controls from the specified dom element.
  46806. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46807. */
  46808. detachControl(ignored: any): void;
  46809. /** @hidden */
  46810. _checkInputs(): void;
  46811. protected _checkLimits(): void;
  46812. /**
  46813. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46814. */
  46815. rebuildAnglesAndRadius(): void;
  46816. /**
  46817. * Use a position to define the current camera related information like alpha, beta and radius
  46818. * @param position Defines the position to set the camera at
  46819. */
  46820. setPosition(position: Vector3): void;
  46821. /**
  46822. * Defines the target the camera should look at.
  46823. * This will automatically adapt alpha beta and radius to fit within the new target.
  46824. * @param target Defines the new target as a Vector or a mesh
  46825. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46826. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46827. */
  46828. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46829. /** @hidden */
  46830. _getViewMatrix(): Matrix;
  46831. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46832. /**
  46833. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46834. * @param meshes Defines the mesh to zoom on
  46835. * @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)
  46836. */
  46837. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46838. /**
  46839. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46840. * The target will be changed but the radius
  46841. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46842. * @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)
  46843. */
  46844. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46845. min: Vector3;
  46846. max: Vector3;
  46847. distance: number;
  46848. }, doNotUpdateMaxZ?: boolean): void;
  46849. /**
  46850. * @override
  46851. * Override Camera.createRigCamera
  46852. */
  46853. createRigCamera(name: string, cameraIndex: number): Camera;
  46854. /**
  46855. * @hidden
  46856. * @override
  46857. * Override Camera._updateRigCameras
  46858. */
  46859. _updateRigCameras(): void;
  46860. /**
  46861. * Destroy the camera and release the current resources hold by it.
  46862. */
  46863. dispose(): void;
  46864. /**
  46865. * Gets the current object class name.
  46866. * @return the class name
  46867. */
  46868. getClassName(): string;
  46869. }
  46870. }
  46871. declare module BABYLON {
  46872. /**
  46873. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46874. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46875. */
  46876. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46877. /**
  46878. * Gets the name of the behavior.
  46879. */
  46880. get name(): string;
  46881. private _zoomStopsAnimation;
  46882. private _idleRotationSpeed;
  46883. private _idleRotationWaitTime;
  46884. private _idleRotationSpinupTime;
  46885. /**
  46886. * Sets the flag that indicates if user zooming should stop animation.
  46887. */
  46888. set zoomStopsAnimation(flag: boolean);
  46889. /**
  46890. * Gets the flag that indicates if user zooming should stop animation.
  46891. */
  46892. get zoomStopsAnimation(): boolean;
  46893. /**
  46894. * Sets the default speed at which the camera rotates around the model.
  46895. */
  46896. set idleRotationSpeed(speed: number);
  46897. /**
  46898. * Gets the default speed at which the camera rotates around the model.
  46899. */
  46900. get idleRotationSpeed(): number;
  46901. /**
  46902. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46903. */
  46904. set idleRotationWaitTime(time: number);
  46905. /**
  46906. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46907. */
  46908. get idleRotationWaitTime(): number;
  46909. /**
  46910. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46911. */
  46912. set idleRotationSpinupTime(time: number);
  46913. /**
  46914. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46915. */
  46916. get idleRotationSpinupTime(): number;
  46917. /**
  46918. * Gets a value indicating if the camera is currently rotating because of this behavior
  46919. */
  46920. get rotationInProgress(): boolean;
  46921. private _onPrePointerObservableObserver;
  46922. private _onAfterCheckInputsObserver;
  46923. private _attachedCamera;
  46924. private _isPointerDown;
  46925. private _lastFrameTime;
  46926. private _lastInteractionTime;
  46927. private _cameraRotationSpeed;
  46928. /**
  46929. * Initializes the behavior.
  46930. */
  46931. init(): void;
  46932. /**
  46933. * Attaches the behavior to its arc rotate camera.
  46934. * @param camera Defines the camera to attach the behavior to
  46935. */
  46936. attach(camera: ArcRotateCamera): void;
  46937. /**
  46938. * Detaches the behavior from its current arc rotate camera.
  46939. */
  46940. detach(): void;
  46941. /**
  46942. * Returns true if user is scrolling.
  46943. * @return true if user is scrolling.
  46944. */
  46945. private _userIsZooming;
  46946. private _lastFrameRadius;
  46947. private _shouldAnimationStopForInteraction;
  46948. /**
  46949. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46950. */
  46951. private _applyUserInteraction;
  46952. private _userIsMoving;
  46953. }
  46954. }
  46955. declare module BABYLON {
  46956. /**
  46957. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46958. */
  46959. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46960. private ui;
  46961. /**
  46962. * The name of the behavior
  46963. */
  46964. name: string;
  46965. /**
  46966. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46967. */
  46968. distanceAwayFromFace: number;
  46969. /**
  46970. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46971. */
  46972. distanceAwayFromBottomOfFace: number;
  46973. private _faceVectors;
  46974. private _target;
  46975. private _scene;
  46976. private _onRenderObserver;
  46977. private _tmpMatrix;
  46978. private _tmpVector;
  46979. /**
  46980. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46981. * @param ui The transform node that should be attched to the mesh
  46982. */
  46983. constructor(ui: TransformNode);
  46984. /**
  46985. * Initializes the behavior
  46986. */
  46987. init(): void;
  46988. private _closestFace;
  46989. private _zeroVector;
  46990. private _lookAtTmpMatrix;
  46991. private _lookAtToRef;
  46992. /**
  46993. * Attaches the AttachToBoxBehavior to the passed in mesh
  46994. * @param target The mesh that the specified node will be attached to
  46995. */
  46996. attach(target: Mesh): void;
  46997. /**
  46998. * Detaches the behavior from the mesh
  46999. */
  47000. detach(): void;
  47001. }
  47002. }
  47003. declare module BABYLON {
  47004. /**
  47005. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  47006. */
  47007. export class FadeInOutBehavior implements Behavior<Mesh> {
  47008. /**
  47009. * Time in milliseconds to delay before fading in (Default: 0)
  47010. */
  47011. delay: number;
  47012. /**
  47013. * Time in milliseconds for the mesh to fade in (Default: 300)
  47014. */
  47015. fadeInTime: number;
  47016. private _millisecondsPerFrame;
  47017. private _hovered;
  47018. private _hoverValue;
  47019. private _ownerNode;
  47020. /**
  47021. * Instatiates the FadeInOutBehavior
  47022. */
  47023. constructor();
  47024. /**
  47025. * The name of the behavior
  47026. */
  47027. get name(): string;
  47028. /**
  47029. * Initializes the behavior
  47030. */
  47031. init(): void;
  47032. /**
  47033. * Attaches the fade behavior on the passed in mesh
  47034. * @param ownerNode The mesh that will be faded in/out once attached
  47035. */
  47036. attach(ownerNode: Mesh): void;
  47037. /**
  47038. * Detaches the behavior from the mesh
  47039. */
  47040. detach(): void;
  47041. /**
  47042. * Triggers the mesh to begin fading in or out
  47043. * @param value if the object should fade in or out (true to fade in)
  47044. */
  47045. fadeIn(value: boolean): void;
  47046. private _update;
  47047. private _setAllVisibility;
  47048. }
  47049. }
  47050. declare module BABYLON {
  47051. /**
  47052. * Class containing a set of static utilities functions for managing Pivots
  47053. * @hidden
  47054. */
  47055. export class PivotTools {
  47056. private static _PivotCached;
  47057. private static _OldPivotPoint;
  47058. private static _PivotTranslation;
  47059. private static _PivotTmpVector;
  47060. private static _PivotPostMultiplyPivotMatrix;
  47061. /** @hidden */
  47062. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  47063. /** @hidden */
  47064. static _RestorePivotPoint(mesh: AbstractMesh): void;
  47065. }
  47066. }
  47067. declare module BABYLON {
  47068. /**
  47069. * Class containing static functions to help procedurally build meshes
  47070. */
  47071. export class PlaneBuilder {
  47072. /**
  47073. * Creates a plane mesh
  47074. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  47075. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  47076. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  47077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47078. * * 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
  47079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47080. * @param name defines the name of the mesh
  47081. * @param options defines the options used to create the mesh
  47082. * @param scene defines the hosting scene
  47083. * @returns the plane mesh
  47084. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  47085. */
  47086. static CreatePlane(name: string, options: {
  47087. size?: number;
  47088. width?: number;
  47089. height?: number;
  47090. sideOrientation?: number;
  47091. frontUVs?: Vector4;
  47092. backUVs?: Vector4;
  47093. updatable?: boolean;
  47094. sourcePlane?: Plane;
  47095. }, scene?: Nullable<Scene>): Mesh;
  47096. }
  47097. }
  47098. declare module BABYLON {
  47099. /**
  47100. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  47101. */
  47102. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  47103. private static _AnyMouseID;
  47104. /**
  47105. * Abstract mesh the behavior is set on
  47106. */
  47107. attachedNode: AbstractMesh;
  47108. private _dragPlane;
  47109. private _scene;
  47110. private _pointerObserver;
  47111. private _beforeRenderObserver;
  47112. private static _planeScene;
  47113. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  47114. /**
  47115. * 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)
  47116. */
  47117. maxDragAngle: number;
  47118. /**
  47119. * @hidden
  47120. */
  47121. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  47122. /**
  47123. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47124. */
  47125. currentDraggingPointerID: number;
  47126. /**
  47127. * The last position where the pointer hit the drag plane in world space
  47128. */
  47129. lastDragPosition: Vector3;
  47130. /**
  47131. * If the behavior is currently in a dragging state
  47132. */
  47133. dragging: boolean;
  47134. /**
  47135. * 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)
  47136. */
  47137. dragDeltaRatio: number;
  47138. /**
  47139. * If the drag plane orientation should be updated during the dragging (Default: true)
  47140. */
  47141. updateDragPlane: boolean;
  47142. private _debugMode;
  47143. private _moving;
  47144. /**
  47145. * Fires each time the attached mesh is dragged with the pointer
  47146. * * delta between last drag position and current drag position in world space
  47147. * * dragDistance along the drag axis
  47148. * * dragPlaneNormal normal of the current drag plane used during the drag
  47149. * * dragPlanePoint in world space where the drag intersects the drag plane
  47150. */
  47151. onDragObservable: Observable<{
  47152. delta: Vector3;
  47153. dragPlanePoint: Vector3;
  47154. dragPlaneNormal: Vector3;
  47155. dragDistance: number;
  47156. pointerId: number;
  47157. }>;
  47158. /**
  47159. * Fires each time a drag begins (eg. mouse down on mesh)
  47160. */
  47161. onDragStartObservable: Observable<{
  47162. dragPlanePoint: Vector3;
  47163. pointerId: number;
  47164. }>;
  47165. /**
  47166. * Fires each time a drag ends (eg. mouse release after drag)
  47167. */
  47168. onDragEndObservable: Observable<{
  47169. dragPlanePoint: Vector3;
  47170. pointerId: number;
  47171. }>;
  47172. /**
  47173. * If the attached mesh should be moved when dragged
  47174. */
  47175. moveAttached: boolean;
  47176. /**
  47177. * If the drag behavior will react to drag events (Default: true)
  47178. */
  47179. enabled: boolean;
  47180. /**
  47181. * If pointer events should start and release the drag (Default: true)
  47182. */
  47183. startAndReleaseDragOnPointerEvents: boolean;
  47184. /**
  47185. * If camera controls should be detached during the drag
  47186. */
  47187. detachCameraControls: boolean;
  47188. /**
  47189. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  47190. */
  47191. useObjectOrientationForDragging: boolean;
  47192. private _options;
  47193. /**
  47194. * Gets the options used by the behavior
  47195. */
  47196. get options(): {
  47197. dragAxis?: Vector3;
  47198. dragPlaneNormal?: Vector3;
  47199. };
  47200. /**
  47201. * Sets the options used by the behavior
  47202. */
  47203. set options(options: {
  47204. dragAxis?: Vector3;
  47205. dragPlaneNormal?: Vector3;
  47206. });
  47207. /**
  47208. * Creates a pointer drag behavior that can be attached to a mesh
  47209. * @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)
  47210. */
  47211. constructor(options?: {
  47212. dragAxis?: Vector3;
  47213. dragPlaneNormal?: Vector3;
  47214. });
  47215. /**
  47216. * Predicate to determine if it is valid to move the object to a new position when it is moved
  47217. */
  47218. validateDrag: (targetPosition: Vector3) => boolean;
  47219. /**
  47220. * The name of the behavior
  47221. */
  47222. get name(): string;
  47223. /**
  47224. * Initializes the behavior
  47225. */
  47226. init(): void;
  47227. private _tmpVector;
  47228. private _alternatePickedPoint;
  47229. private _worldDragAxis;
  47230. private _targetPosition;
  47231. private _attachedToElement;
  47232. /**
  47233. * Attaches the drag behavior the passed in mesh
  47234. * @param ownerNode The mesh that will be dragged around once attached
  47235. * @param predicate Predicate to use for pick filtering
  47236. */
  47237. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  47238. /**
  47239. * Force relase the drag action by code.
  47240. */
  47241. releaseDrag(): void;
  47242. private _startDragRay;
  47243. private _lastPointerRay;
  47244. /**
  47245. * Simulates the start of a pointer drag event on the behavior
  47246. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  47247. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  47248. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  47249. */
  47250. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47251. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47252. private _dragDelta;
  47253. protected _moveDrag(ray: Ray): void;
  47254. private _pickWithRayOnDragPlane;
  47255. private _pointA;
  47256. private _pointC;
  47257. private _localAxis;
  47258. private _lookAt;
  47259. private _updateDragPlanePosition;
  47260. /**
  47261. * Detaches the behavior from the mesh
  47262. */
  47263. detach(): void;
  47264. }
  47265. }
  47266. declare module BABYLON {
  47267. /**
  47268. * A behavior that when attached to a mesh will allow the mesh to be scaled
  47269. */
  47270. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  47271. private _dragBehaviorA;
  47272. private _dragBehaviorB;
  47273. private _startDistance;
  47274. private _initialScale;
  47275. private _targetScale;
  47276. private _ownerNode;
  47277. private _sceneRenderObserver;
  47278. /**
  47279. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  47280. */
  47281. constructor();
  47282. /**
  47283. * The name of the behavior
  47284. */
  47285. get name(): string;
  47286. /**
  47287. * Initializes the behavior
  47288. */
  47289. init(): void;
  47290. private _getCurrentDistance;
  47291. /**
  47292. * Attaches the scale behavior the passed in mesh
  47293. * @param ownerNode The mesh that will be scaled around once attached
  47294. */
  47295. attach(ownerNode: Mesh): void;
  47296. /**
  47297. * Detaches the behavior from the mesh
  47298. */
  47299. detach(): void;
  47300. }
  47301. }
  47302. declare module BABYLON {
  47303. /**
  47304. * 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
  47305. */
  47306. export class SixDofDragBehavior implements Behavior<Mesh> {
  47307. private static _virtualScene;
  47308. private _ownerNode;
  47309. private _sceneRenderObserver;
  47310. private _scene;
  47311. private _targetPosition;
  47312. private _virtualOriginMesh;
  47313. private _virtualDragMesh;
  47314. private _pointerObserver;
  47315. private _moving;
  47316. private _startingOrientation;
  47317. private _attachedToElement;
  47318. /**
  47319. * 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)
  47320. */
  47321. private zDragFactor;
  47322. /**
  47323. * If the object should rotate to face the drag origin
  47324. */
  47325. rotateDraggedObject: boolean;
  47326. /**
  47327. * If the behavior is currently in a dragging state
  47328. */
  47329. dragging: boolean;
  47330. /**
  47331. * 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)
  47332. */
  47333. dragDeltaRatio: number;
  47334. /**
  47335. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47336. */
  47337. currentDraggingPointerID: number;
  47338. /**
  47339. * If camera controls should be detached during the drag
  47340. */
  47341. detachCameraControls: boolean;
  47342. /**
  47343. * Fires each time a drag starts
  47344. */
  47345. onDragStartObservable: Observable<{}>;
  47346. /**
  47347. * Fires each time a drag happens
  47348. */
  47349. onDragObservable: Observable<void>;
  47350. /**
  47351. * Fires each time a drag ends (eg. mouse release after drag)
  47352. */
  47353. onDragEndObservable: Observable<{}>;
  47354. /**
  47355. * 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
  47356. */
  47357. constructor();
  47358. /**
  47359. * The name of the behavior
  47360. */
  47361. get name(): string;
  47362. /**
  47363. * Initializes the behavior
  47364. */
  47365. init(): void;
  47366. /**
  47367. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47368. */
  47369. private get _pointerCamera();
  47370. /**
  47371. * Attaches the scale behavior the passed in mesh
  47372. * @param ownerNode The mesh that will be scaled around once attached
  47373. */
  47374. attach(ownerNode: Mesh): void;
  47375. /**
  47376. * Detaches the behavior from the mesh
  47377. */
  47378. detach(): void;
  47379. }
  47380. }
  47381. declare module BABYLON {
  47382. /**
  47383. * Class used to apply inverse kinematics to bones
  47384. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47385. */
  47386. export class BoneIKController {
  47387. private static _tmpVecs;
  47388. private static _tmpQuat;
  47389. private static _tmpMats;
  47390. /**
  47391. * Gets or sets the target mesh
  47392. */
  47393. targetMesh: AbstractMesh;
  47394. /** Gets or sets the mesh used as pole */
  47395. poleTargetMesh: AbstractMesh;
  47396. /**
  47397. * Gets or sets the bone used as pole
  47398. */
  47399. poleTargetBone: Nullable<Bone>;
  47400. /**
  47401. * Gets or sets the target position
  47402. */
  47403. targetPosition: Vector3;
  47404. /**
  47405. * Gets or sets the pole target position
  47406. */
  47407. poleTargetPosition: Vector3;
  47408. /**
  47409. * Gets or sets the pole target local offset
  47410. */
  47411. poleTargetLocalOffset: Vector3;
  47412. /**
  47413. * Gets or sets the pole angle
  47414. */
  47415. poleAngle: number;
  47416. /**
  47417. * Gets or sets the mesh associated with the controller
  47418. */
  47419. mesh: AbstractMesh;
  47420. /**
  47421. * 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)
  47422. */
  47423. slerpAmount: number;
  47424. private _bone1Quat;
  47425. private _bone1Mat;
  47426. private _bone2Ang;
  47427. private _bone1;
  47428. private _bone2;
  47429. private _bone1Length;
  47430. private _bone2Length;
  47431. private _maxAngle;
  47432. private _maxReach;
  47433. private _rightHandedSystem;
  47434. private _bendAxis;
  47435. private _slerping;
  47436. private _adjustRoll;
  47437. /**
  47438. * Gets or sets maximum allowed angle
  47439. */
  47440. get maxAngle(): number;
  47441. set maxAngle(value: number);
  47442. /**
  47443. * Creates a new BoneIKController
  47444. * @param mesh defines the mesh to control
  47445. * @param bone defines the bone to control
  47446. * @param options defines options to set up the controller
  47447. */
  47448. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47449. targetMesh?: AbstractMesh;
  47450. poleTargetMesh?: AbstractMesh;
  47451. poleTargetBone?: Bone;
  47452. poleTargetLocalOffset?: Vector3;
  47453. poleAngle?: number;
  47454. bendAxis?: Vector3;
  47455. maxAngle?: number;
  47456. slerpAmount?: number;
  47457. });
  47458. private _setMaxAngle;
  47459. /**
  47460. * Force the controller to update the bones
  47461. */
  47462. update(): void;
  47463. }
  47464. }
  47465. declare module BABYLON {
  47466. /**
  47467. * Class used to make a bone look toward a point in space
  47468. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47469. */
  47470. export class BoneLookController {
  47471. private static _tmpVecs;
  47472. private static _tmpQuat;
  47473. private static _tmpMats;
  47474. /**
  47475. * The target Vector3 that the bone will look at
  47476. */
  47477. target: Vector3;
  47478. /**
  47479. * The mesh that the bone is attached to
  47480. */
  47481. mesh: AbstractMesh;
  47482. /**
  47483. * The bone that will be looking to the target
  47484. */
  47485. bone: Bone;
  47486. /**
  47487. * The up axis of the coordinate system that is used when the bone is rotated
  47488. */
  47489. upAxis: Vector3;
  47490. /**
  47491. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47492. */
  47493. upAxisSpace: Space;
  47494. /**
  47495. * Used to make an adjustment to the yaw of the bone
  47496. */
  47497. adjustYaw: number;
  47498. /**
  47499. * Used to make an adjustment to the pitch of the bone
  47500. */
  47501. adjustPitch: number;
  47502. /**
  47503. * Used to make an adjustment to the roll of the bone
  47504. */
  47505. adjustRoll: number;
  47506. /**
  47507. * 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)
  47508. */
  47509. slerpAmount: number;
  47510. private _minYaw;
  47511. private _maxYaw;
  47512. private _minPitch;
  47513. private _maxPitch;
  47514. private _minYawSin;
  47515. private _minYawCos;
  47516. private _maxYawSin;
  47517. private _maxYawCos;
  47518. private _midYawConstraint;
  47519. private _minPitchTan;
  47520. private _maxPitchTan;
  47521. private _boneQuat;
  47522. private _slerping;
  47523. private _transformYawPitch;
  47524. private _transformYawPitchInv;
  47525. private _firstFrameSkipped;
  47526. private _yawRange;
  47527. private _fowardAxis;
  47528. /**
  47529. * Gets or sets the minimum yaw angle that the bone can look to
  47530. */
  47531. get minYaw(): number;
  47532. set minYaw(value: number);
  47533. /**
  47534. * Gets or sets the maximum yaw angle that the bone can look to
  47535. */
  47536. get maxYaw(): number;
  47537. set maxYaw(value: number);
  47538. /**
  47539. * Gets or sets the minimum pitch angle that the bone can look to
  47540. */
  47541. get minPitch(): number;
  47542. set minPitch(value: number);
  47543. /**
  47544. * Gets or sets the maximum pitch angle that the bone can look to
  47545. */
  47546. get maxPitch(): number;
  47547. set maxPitch(value: number);
  47548. /**
  47549. * Create a BoneLookController
  47550. * @param mesh the mesh that the bone belongs to
  47551. * @param bone the bone that will be looking to the target
  47552. * @param target the target Vector3 to look at
  47553. * @param options optional settings:
  47554. * * maxYaw: the maximum angle the bone will yaw to
  47555. * * minYaw: the minimum angle the bone will yaw to
  47556. * * maxPitch: the maximum angle the bone will pitch to
  47557. * * minPitch: the minimum angle the bone will yaw to
  47558. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47559. * * upAxis: the up axis of the coordinate system
  47560. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47561. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47562. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47563. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47564. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47565. * * adjustRoll: used to make an adjustment to the roll of the bone
  47566. **/
  47567. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47568. maxYaw?: number;
  47569. minYaw?: number;
  47570. maxPitch?: number;
  47571. minPitch?: number;
  47572. slerpAmount?: number;
  47573. upAxis?: Vector3;
  47574. upAxisSpace?: Space;
  47575. yawAxis?: Vector3;
  47576. pitchAxis?: Vector3;
  47577. adjustYaw?: number;
  47578. adjustPitch?: number;
  47579. adjustRoll?: number;
  47580. });
  47581. /**
  47582. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47583. */
  47584. update(): void;
  47585. private _getAngleDiff;
  47586. private _getAngleBetween;
  47587. private _isAngleBetween;
  47588. }
  47589. }
  47590. declare module BABYLON {
  47591. /**
  47592. * Manage the gamepad inputs to control an arc rotate camera.
  47593. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47594. */
  47595. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47596. /**
  47597. * Defines the camera the input is attached to.
  47598. */
  47599. camera: ArcRotateCamera;
  47600. /**
  47601. * Defines the gamepad the input is gathering event from.
  47602. */
  47603. gamepad: Nullable<Gamepad>;
  47604. /**
  47605. * Defines the gamepad rotation sensiblity.
  47606. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47607. */
  47608. gamepadRotationSensibility: number;
  47609. /**
  47610. * Defines the gamepad move sensiblity.
  47611. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47612. */
  47613. gamepadMoveSensibility: number;
  47614. private _yAxisScale;
  47615. /**
  47616. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47617. */
  47618. get invertYAxis(): boolean;
  47619. set invertYAxis(value: boolean);
  47620. private _onGamepadConnectedObserver;
  47621. private _onGamepadDisconnectedObserver;
  47622. /**
  47623. * Attach the input controls to a specific dom element to get the input from.
  47624. */
  47625. attachControl(): void;
  47626. /**
  47627. * Detach the current controls from the specified dom element.
  47628. */
  47629. detachControl(): void;
  47630. /**
  47631. * Update the current camera state depending on the inputs that have been used this frame.
  47632. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47633. */
  47634. checkInputs(): void;
  47635. /**
  47636. * Gets the class name of the current intput.
  47637. * @returns the class name
  47638. */
  47639. getClassName(): string;
  47640. /**
  47641. * Get the friendly name associated with the input class.
  47642. * @returns the input friendly name
  47643. */
  47644. getSimpleName(): string;
  47645. }
  47646. }
  47647. declare module BABYLON {
  47648. interface ArcRotateCameraInputsManager {
  47649. /**
  47650. * Add orientation input support to the input manager.
  47651. * @returns the current input manager
  47652. */
  47653. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47654. }
  47655. /**
  47656. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47657. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47658. */
  47659. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47660. /**
  47661. * Defines the camera the input is attached to.
  47662. */
  47663. camera: ArcRotateCamera;
  47664. /**
  47665. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47666. */
  47667. alphaCorrection: number;
  47668. /**
  47669. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47670. */
  47671. gammaCorrection: number;
  47672. private _alpha;
  47673. private _gamma;
  47674. private _dirty;
  47675. private _deviceOrientationHandler;
  47676. /**
  47677. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47678. */
  47679. constructor();
  47680. /**
  47681. * Attach the input controls to a specific dom element to get the input from.
  47682. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47683. */
  47684. attachControl(noPreventDefault?: boolean): void;
  47685. /** @hidden */
  47686. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47687. /**
  47688. * Update the current camera state depending on the inputs that have been used this frame.
  47689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47690. */
  47691. checkInputs(): void;
  47692. /**
  47693. * Detach the current controls from the specified dom element.
  47694. */
  47695. detachControl(): void;
  47696. /**
  47697. * Gets the class name of the current intput.
  47698. * @returns the class name
  47699. */
  47700. getClassName(): string;
  47701. /**
  47702. * Get the friendly name associated with the input class.
  47703. * @returns the input friendly name
  47704. */
  47705. getSimpleName(): string;
  47706. }
  47707. }
  47708. declare module BABYLON {
  47709. /**
  47710. * Listen to mouse events to control the camera.
  47711. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47712. */
  47713. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47714. /**
  47715. * Defines the camera the input is attached to.
  47716. */
  47717. camera: FlyCamera;
  47718. /**
  47719. * Defines if touch is enabled. (Default is true.)
  47720. */
  47721. touchEnabled: boolean;
  47722. /**
  47723. * Defines the buttons associated with the input to handle camera rotation.
  47724. */
  47725. buttons: number[];
  47726. /**
  47727. * Assign buttons for Yaw control.
  47728. */
  47729. buttonsYaw: number[];
  47730. /**
  47731. * Assign buttons for Pitch control.
  47732. */
  47733. buttonsPitch: number[];
  47734. /**
  47735. * Assign buttons for Roll control.
  47736. */
  47737. buttonsRoll: number[];
  47738. /**
  47739. * Detect if any button is being pressed while mouse is moved.
  47740. * -1 = Mouse locked.
  47741. * 0 = Left button.
  47742. * 1 = Middle Button.
  47743. * 2 = Right Button.
  47744. */
  47745. activeButton: number;
  47746. /**
  47747. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47748. * Higher values reduce its sensitivity.
  47749. */
  47750. angularSensibility: number;
  47751. private _observer;
  47752. private _rollObserver;
  47753. private previousPosition;
  47754. private noPreventDefault;
  47755. private element;
  47756. /**
  47757. * Listen to mouse events to control the camera.
  47758. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47759. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47760. */
  47761. constructor(touchEnabled?: boolean);
  47762. /**
  47763. * Attach the mouse control to the HTML DOM element.
  47764. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47765. */
  47766. attachControl(noPreventDefault?: boolean): void;
  47767. /**
  47768. * Detach the current controls from the specified dom element.
  47769. */
  47770. detachControl(): void;
  47771. /**
  47772. * Gets the class name of the current input.
  47773. * @returns the class name.
  47774. */
  47775. getClassName(): string;
  47776. /**
  47777. * Get the friendly name associated with the input class.
  47778. * @returns the input's friendly name.
  47779. */
  47780. getSimpleName(): string;
  47781. private _pointerInput;
  47782. private _onMouseMove;
  47783. /**
  47784. * Rotate camera by mouse offset.
  47785. */
  47786. private rotateCamera;
  47787. }
  47788. }
  47789. declare module BABYLON {
  47790. /**
  47791. * Default Inputs manager for the FlyCamera.
  47792. * It groups all the default supported inputs for ease of use.
  47793. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47794. */
  47795. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47796. /**
  47797. * Instantiates a new FlyCameraInputsManager.
  47798. * @param camera Defines the camera the inputs belong to.
  47799. */
  47800. constructor(camera: FlyCamera);
  47801. /**
  47802. * Add keyboard input support to the input manager.
  47803. * @returns the new FlyCameraKeyboardMoveInput().
  47804. */
  47805. addKeyboard(): FlyCameraInputsManager;
  47806. /**
  47807. * Add mouse input support to the input manager.
  47808. * @param touchEnabled Enable touch screen support.
  47809. * @returns the new FlyCameraMouseInput().
  47810. */
  47811. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47812. }
  47813. }
  47814. declare module BABYLON {
  47815. /**
  47816. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47817. * such as in a 3D Space Shooter or a Flight Simulator.
  47818. */
  47819. export class FlyCamera extends TargetCamera {
  47820. /**
  47821. * Define the collision ellipsoid of the camera.
  47822. * This is helpful for simulating a camera body, like a player's body.
  47823. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47824. */
  47825. ellipsoid: Vector3;
  47826. /**
  47827. * Define an offset for the position of the ellipsoid around the camera.
  47828. * This can be helpful if the camera is attached away from the player's body center,
  47829. * such as at its head.
  47830. */
  47831. ellipsoidOffset: Vector3;
  47832. /**
  47833. * Enable or disable collisions of the camera with the rest of the scene objects.
  47834. */
  47835. checkCollisions: boolean;
  47836. /**
  47837. * Enable or disable gravity on the camera.
  47838. */
  47839. applyGravity: boolean;
  47840. /**
  47841. * Define the current direction the camera is moving to.
  47842. */
  47843. cameraDirection: Vector3;
  47844. /**
  47845. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47846. * This overrides and empties cameraRotation.
  47847. */
  47848. rotationQuaternion: Quaternion;
  47849. /**
  47850. * Track Roll to maintain the wanted Rolling when looking around.
  47851. */
  47852. _trackRoll: number;
  47853. /**
  47854. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47855. */
  47856. rollCorrect: number;
  47857. /**
  47858. * Mimic a banked turn, Rolling the camera when Yawing.
  47859. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47860. */
  47861. bankedTurn: boolean;
  47862. /**
  47863. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47864. */
  47865. bankedTurnLimit: number;
  47866. /**
  47867. * Value of 0 disables the banked Roll.
  47868. * Value of 1 is equal to the Yaw angle in radians.
  47869. */
  47870. bankedTurnMultiplier: number;
  47871. /**
  47872. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47873. */
  47874. inputs: FlyCameraInputsManager;
  47875. /**
  47876. * Gets the input sensibility for mouse input.
  47877. * Higher values reduce sensitivity.
  47878. */
  47879. get angularSensibility(): number;
  47880. /**
  47881. * Sets the input sensibility for a mouse input.
  47882. * Higher values reduce sensitivity.
  47883. */
  47884. set angularSensibility(value: number);
  47885. /**
  47886. * Get the keys for camera movement forward.
  47887. */
  47888. get keysForward(): number[];
  47889. /**
  47890. * Set the keys for camera movement forward.
  47891. */
  47892. set keysForward(value: number[]);
  47893. /**
  47894. * Get the keys for camera movement backward.
  47895. */
  47896. get keysBackward(): number[];
  47897. set keysBackward(value: number[]);
  47898. /**
  47899. * Get the keys for camera movement up.
  47900. */
  47901. get keysUp(): number[];
  47902. /**
  47903. * Set the keys for camera movement up.
  47904. */
  47905. set keysUp(value: number[]);
  47906. /**
  47907. * Get the keys for camera movement down.
  47908. */
  47909. get keysDown(): number[];
  47910. /**
  47911. * Set the keys for camera movement down.
  47912. */
  47913. set keysDown(value: number[]);
  47914. /**
  47915. * Get the keys for camera movement left.
  47916. */
  47917. get keysLeft(): number[];
  47918. /**
  47919. * Set the keys for camera movement left.
  47920. */
  47921. set keysLeft(value: number[]);
  47922. /**
  47923. * Set the keys for camera movement right.
  47924. */
  47925. get keysRight(): number[];
  47926. /**
  47927. * Set the keys for camera movement right.
  47928. */
  47929. set keysRight(value: number[]);
  47930. /**
  47931. * Event raised when the camera collides with a mesh in the scene.
  47932. */
  47933. onCollide: (collidedMesh: AbstractMesh) => void;
  47934. private _collider;
  47935. private _needMoveForGravity;
  47936. private _oldPosition;
  47937. private _diffPosition;
  47938. private _newPosition;
  47939. /** @hidden */
  47940. _localDirection: Vector3;
  47941. /** @hidden */
  47942. _transformedDirection: Vector3;
  47943. /**
  47944. * Instantiates a FlyCamera.
  47945. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47946. * such as in a 3D Space Shooter or a Flight Simulator.
  47947. * @param name Define the name of the camera in the scene.
  47948. * @param position Define the starting position of the camera in the scene.
  47949. * @param scene Define the scene the camera belongs to.
  47950. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47951. */
  47952. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47953. /**
  47954. * Attach the input controls to a specific dom element to get the input from.
  47955. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47956. */
  47957. attachControl(noPreventDefault?: boolean): void;
  47958. /**
  47959. * Detach a control from the HTML DOM element.
  47960. * The camera will stop reacting to that input.
  47961. */
  47962. detachControl(): void;
  47963. private _collisionMask;
  47964. /**
  47965. * Get the mask that the camera ignores in collision events.
  47966. */
  47967. get collisionMask(): number;
  47968. /**
  47969. * Set the mask that the camera ignores in collision events.
  47970. */
  47971. set collisionMask(mask: number);
  47972. /** @hidden */
  47973. _collideWithWorld(displacement: Vector3): void;
  47974. /** @hidden */
  47975. private _onCollisionPositionChange;
  47976. /** @hidden */
  47977. _checkInputs(): void;
  47978. /** @hidden */
  47979. _decideIfNeedsToMove(): boolean;
  47980. /** @hidden */
  47981. _updatePosition(): void;
  47982. /**
  47983. * Restore the Roll to its target value at the rate specified.
  47984. * @param rate - Higher means slower restoring.
  47985. * @hidden
  47986. */
  47987. restoreRoll(rate: number): void;
  47988. /**
  47989. * Destroy the camera and release the current resources held by it.
  47990. */
  47991. dispose(): void;
  47992. /**
  47993. * Get the current object class name.
  47994. * @returns the class name.
  47995. */
  47996. getClassName(): string;
  47997. }
  47998. }
  47999. declare module BABYLON {
  48000. /**
  48001. * Listen to keyboard events to control the camera.
  48002. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48003. */
  48004. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  48005. /**
  48006. * Defines the camera the input is attached to.
  48007. */
  48008. camera: FlyCamera;
  48009. /**
  48010. * The list of keyboard keys used to control the forward move of the camera.
  48011. */
  48012. keysForward: number[];
  48013. /**
  48014. * The list of keyboard keys used to control the backward move of the camera.
  48015. */
  48016. keysBackward: number[];
  48017. /**
  48018. * The list of keyboard keys used to control the forward move of the camera.
  48019. */
  48020. keysUp: number[];
  48021. /**
  48022. * The list of keyboard keys used to control the backward move of the camera.
  48023. */
  48024. keysDown: number[];
  48025. /**
  48026. * The list of keyboard keys used to control the right strafe move of the camera.
  48027. */
  48028. keysRight: number[];
  48029. /**
  48030. * The list of keyboard keys used to control the left strafe move of the camera.
  48031. */
  48032. keysLeft: number[];
  48033. private _keys;
  48034. private _onCanvasBlurObserver;
  48035. private _onKeyboardObserver;
  48036. private _engine;
  48037. private _scene;
  48038. /**
  48039. * Attach the input controls to a specific dom element to get the input from.
  48040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48041. */
  48042. attachControl(noPreventDefault?: boolean): void;
  48043. /**
  48044. * Detach the current controls from the specified dom element.
  48045. */
  48046. detachControl(): void;
  48047. /**
  48048. * Gets the class name of the current intput.
  48049. * @returns the class name
  48050. */
  48051. getClassName(): string;
  48052. /** @hidden */
  48053. _onLostFocus(e: FocusEvent): void;
  48054. /**
  48055. * Get the friendly name associated with the input class.
  48056. * @returns the input friendly name
  48057. */
  48058. getSimpleName(): string;
  48059. /**
  48060. * Update the current camera state depending on the inputs that have been used this frame.
  48061. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48062. */
  48063. checkInputs(): void;
  48064. }
  48065. }
  48066. declare module BABYLON {
  48067. /**
  48068. * Manage the mouse wheel inputs to control a follow camera.
  48069. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48070. */
  48071. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  48072. /**
  48073. * Defines the camera the input is attached to.
  48074. */
  48075. camera: FollowCamera;
  48076. /**
  48077. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  48078. */
  48079. axisControlRadius: boolean;
  48080. /**
  48081. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  48082. */
  48083. axisControlHeight: boolean;
  48084. /**
  48085. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  48086. */
  48087. axisControlRotation: boolean;
  48088. /**
  48089. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  48090. * relation to mouseWheel events.
  48091. */
  48092. wheelPrecision: number;
  48093. /**
  48094. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48095. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48096. */
  48097. wheelDeltaPercentage: number;
  48098. private _wheel;
  48099. private _observer;
  48100. /**
  48101. * Attach the input controls to a specific dom element to get the input from.
  48102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48103. */
  48104. attachControl(noPreventDefault?: boolean): void;
  48105. /**
  48106. * Detach the current controls from the specified dom element.
  48107. */
  48108. detachControl(): void;
  48109. /**
  48110. * Gets the class name of the current intput.
  48111. * @returns the class name
  48112. */
  48113. getClassName(): string;
  48114. /**
  48115. * Get the friendly name associated with the input class.
  48116. * @returns the input friendly name
  48117. */
  48118. getSimpleName(): string;
  48119. }
  48120. }
  48121. declare module BABYLON {
  48122. /**
  48123. * Manage the pointers inputs to control an follow camera.
  48124. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48125. */
  48126. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  48127. /**
  48128. * Defines the camera the input is attached to.
  48129. */
  48130. camera: FollowCamera;
  48131. /**
  48132. * Gets the class name of the current input.
  48133. * @returns the class name
  48134. */
  48135. getClassName(): string;
  48136. /**
  48137. * Defines the pointer angular sensibility along the X axis or how fast is
  48138. * the camera rotating.
  48139. * A negative number will reverse the axis direction.
  48140. */
  48141. angularSensibilityX: number;
  48142. /**
  48143. * Defines the pointer angular sensibility along the Y axis or how fast is
  48144. * the camera rotating.
  48145. * A negative number will reverse the axis direction.
  48146. */
  48147. angularSensibilityY: number;
  48148. /**
  48149. * Defines the pointer pinch precision or how fast is the camera zooming.
  48150. * A negative number will reverse the axis direction.
  48151. */
  48152. pinchPrecision: number;
  48153. /**
  48154. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  48155. * from 0.
  48156. * It defines the percentage of current camera.radius to use as delta when
  48157. * pinch zoom is used.
  48158. */
  48159. pinchDeltaPercentage: number;
  48160. /**
  48161. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  48162. */
  48163. axisXControlRadius: boolean;
  48164. /**
  48165. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  48166. */
  48167. axisXControlHeight: boolean;
  48168. /**
  48169. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  48170. */
  48171. axisXControlRotation: boolean;
  48172. /**
  48173. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  48174. */
  48175. axisYControlRadius: boolean;
  48176. /**
  48177. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  48178. */
  48179. axisYControlHeight: boolean;
  48180. /**
  48181. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  48182. */
  48183. axisYControlRotation: boolean;
  48184. /**
  48185. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  48186. */
  48187. axisPinchControlRadius: boolean;
  48188. /**
  48189. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  48190. */
  48191. axisPinchControlHeight: boolean;
  48192. /**
  48193. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  48194. */
  48195. axisPinchControlRotation: boolean;
  48196. /**
  48197. * Log error messages if basic misconfiguration has occurred.
  48198. */
  48199. warningEnable: boolean;
  48200. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48201. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48202. private _warningCounter;
  48203. private _warning;
  48204. }
  48205. }
  48206. declare module BABYLON {
  48207. /**
  48208. * Default Inputs manager for the FollowCamera.
  48209. * It groups all the default supported inputs for ease of use.
  48210. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48211. */
  48212. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  48213. /**
  48214. * Instantiates a new FollowCameraInputsManager.
  48215. * @param camera Defines the camera the inputs belong to
  48216. */
  48217. constructor(camera: FollowCamera);
  48218. /**
  48219. * Add keyboard input support to the input manager.
  48220. * @returns the current input manager
  48221. */
  48222. addKeyboard(): FollowCameraInputsManager;
  48223. /**
  48224. * Add mouse wheel input support to the input manager.
  48225. * @returns the current input manager
  48226. */
  48227. addMouseWheel(): FollowCameraInputsManager;
  48228. /**
  48229. * Add pointers input support to the input manager.
  48230. * @returns the current input manager
  48231. */
  48232. addPointers(): FollowCameraInputsManager;
  48233. /**
  48234. * Add orientation input support to the input manager.
  48235. * @returns the current input manager
  48236. */
  48237. addVRDeviceOrientation(): FollowCameraInputsManager;
  48238. }
  48239. }
  48240. declare module BABYLON {
  48241. /**
  48242. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  48243. * an arc rotate version arcFollowCamera are available.
  48244. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48245. */
  48246. export class FollowCamera extends TargetCamera {
  48247. /**
  48248. * Distance the follow camera should follow an object at
  48249. */
  48250. radius: number;
  48251. /**
  48252. * Minimum allowed distance of the camera to the axis of rotation
  48253. * (The camera can not get closer).
  48254. * This can help limiting how the Camera is able to move in the scene.
  48255. */
  48256. lowerRadiusLimit: Nullable<number>;
  48257. /**
  48258. * Maximum allowed distance of the camera to the axis of rotation
  48259. * (The camera can not get further).
  48260. * This can help limiting how the Camera is able to move in the scene.
  48261. */
  48262. upperRadiusLimit: Nullable<number>;
  48263. /**
  48264. * Define a rotation offset between the camera and the object it follows
  48265. */
  48266. rotationOffset: number;
  48267. /**
  48268. * Minimum allowed angle to camera position relative to target object.
  48269. * This can help limiting how the Camera is able to move in the scene.
  48270. */
  48271. lowerRotationOffsetLimit: Nullable<number>;
  48272. /**
  48273. * Maximum allowed angle to camera position relative to target object.
  48274. * This can help limiting how the Camera is able to move in the scene.
  48275. */
  48276. upperRotationOffsetLimit: Nullable<number>;
  48277. /**
  48278. * Define a height offset between the camera and the object it follows.
  48279. * It can help following an object from the top (like a car chaing a plane)
  48280. */
  48281. heightOffset: number;
  48282. /**
  48283. * Minimum allowed height of camera position relative to target object.
  48284. * This can help limiting how the Camera is able to move in the scene.
  48285. */
  48286. lowerHeightOffsetLimit: Nullable<number>;
  48287. /**
  48288. * Maximum allowed height of camera position relative to target object.
  48289. * This can help limiting how the Camera is able to move in the scene.
  48290. */
  48291. upperHeightOffsetLimit: Nullable<number>;
  48292. /**
  48293. * Define how fast the camera can accelerate to follow it s target.
  48294. */
  48295. cameraAcceleration: number;
  48296. /**
  48297. * Define the speed limit of the camera following an object.
  48298. */
  48299. maxCameraSpeed: number;
  48300. /**
  48301. * Define the target of the camera.
  48302. */
  48303. lockedTarget: Nullable<AbstractMesh>;
  48304. /**
  48305. * Defines the input associated with the camera.
  48306. */
  48307. inputs: FollowCameraInputsManager;
  48308. /**
  48309. * Instantiates the follow camera.
  48310. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48311. * @param name Define the name of the camera in the scene
  48312. * @param position Define the position of the camera
  48313. * @param scene Define the scene the camera belong to
  48314. * @param lockedTarget Define the target of the camera
  48315. */
  48316. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48317. private _follow;
  48318. /**
  48319. * Attach the input controls to a specific dom element to get the input from.
  48320. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48321. */
  48322. attachControl(noPreventDefault?: boolean): void;
  48323. /**
  48324. * Detach the current controls from the specified dom element.
  48325. */
  48326. detachControl(): void;
  48327. /** @hidden */
  48328. _checkInputs(): void;
  48329. private _checkLimits;
  48330. /**
  48331. * Gets the camera class name.
  48332. * @returns the class name
  48333. */
  48334. getClassName(): string;
  48335. }
  48336. /**
  48337. * Arc Rotate version of the follow camera.
  48338. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48339. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48340. */
  48341. export class ArcFollowCamera extends TargetCamera {
  48342. /** The longitudinal angle of the camera */
  48343. alpha: number;
  48344. /** The latitudinal angle of the camera */
  48345. beta: number;
  48346. /** The radius of the camera from its target */
  48347. radius: number;
  48348. private _cartesianCoordinates;
  48349. /** Define the camera target (the mesh it should follow) */
  48350. private _meshTarget;
  48351. /**
  48352. * Instantiates a new ArcFollowCamera
  48353. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48354. * @param name Define the name of the camera
  48355. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48356. * @param beta Define the rotation angle of the camera around the elevation axis
  48357. * @param radius Define the radius of the camera from its target point
  48358. * @param target Define the target of the camera
  48359. * @param scene Define the scene the camera belongs to
  48360. */
  48361. constructor(name: string,
  48362. /** The longitudinal angle of the camera */
  48363. alpha: number,
  48364. /** The latitudinal angle of the camera */
  48365. beta: number,
  48366. /** The radius of the camera from its target */
  48367. radius: number,
  48368. /** Define the camera target (the mesh it should follow) */
  48369. target: Nullable<AbstractMesh>, scene: Scene);
  48370. private _follow;
  48371. /** @hidden */
  48372. _checkInputs(): void;
  48373. /**
  48374. * Returns the class name of the object.
  48375. * It is mostly used internally for serialization purposes.
  48376. */
  48377. getClassName(): string;
  48378. }
  48379. }
  48380. declare module BABYLON {
  48381. /**
  48382. * Manage the keyboard inputs to control the movement of a follow camera.
  48383. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48384. */
  48385. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48386. /**
  48387. * Defines the camera the input is attached to.
  48388. */
  48389. camera: FollowCamera;
  48390. /**
  48391. * Defines the list of key codes associated with the up action (increase heightOffset)
  48392. */
  48393. keysHeightOffsetIncr: number[];
  48394. /**
  48395. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48396. */
  48397. keysHeightOffsetDecr: number[];
  48398. /**
  48399. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48400. */
  48401. keysHeightOffsetModifierAlt: boolean;
  48402. /**
  48403. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48404. */
  48405. keysHeightOffsetModifierCtrl: boolean;
  48406. /**
  48407. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48408. */
  48409. keysHeightOffsetModifierShift: boolean;
  48410. /**
  48411. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48412. */
  48413. keysRotationOffsetIncr: number[];
  48414. /**
  48415. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48416. */
  48417. keysRotationOffsetDecr: number[];
  48418. /**
  48419. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48420. */
  48421. keysRotationOffsetModifierAlt: boolean;
  48422. /**
  48423. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48424. */
  48425. keysRotationOffsetModifierCtrl: boolean;
  48426. /**
  48427. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48428. */
  48429. keysRotationOffsetModifierShift: boolean;
  48430. /**
  48431. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48432. */
  48433. keysRadiusIncr: number[];
  48434. /**
  48435. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48436. */
  48437. keysRadiusDecr: number[];
  48438. /**
  48439. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48440. */
  48441. keysRadiusModifierAlt: boolean;
  48442. /**
  48443. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48444. */
  48445. keysRadiusModifierCtrl: boolean;
  48446. /**
  48447. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48448. */
  48449. keysRadiusModifierShift: boolean;
  48450. /**
  48451. * Defines the rate of change of heightOffset.
  48452. */
  48453. heightSensibility: number;
  48454. /**
  48455. * Defines the rate of change of rotationOffset.
  48456. */
  48457. rotationSensibility: number;
  48458. /**
  48459. * Defines the rate of change of radius.
  48460. */
  48461. radiusSensibility: number;
  48462. private _keys;
  48463. private _ctrlPressed;
  48464. private _altPressed;
  48465. private _shiftPressed;
  48466. private _onCanvasBlurObserver;
  48467. private _onKeyboardObserver;
  48468. private _engine;
  48469. private _scene;
  48470. /**
  48471. * Attach the input controls to a specific dom element to get the input from.
  48472. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48473. */
  48474. attachControl(noPreventDefault?: boolean): void;
  48475. /**
  48476. * Detach the current controls from the specified dom element.
  48477. */
  48478. detachControl(): void;
  48479. /**
  48480. * Update the current camera state depending on the inputs that have been used this frame.
  48481. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48482. */
  48483. checkInputs(): void;
  48484. /**
  48485. * Gets the class name of the current input.
  48486. * @returns the class name
  48487. */
  48488. getClassName(): string;
  48489. /**
  48490. * Get the friendly name associated with the input class.
  48491. * @returns the input friendly name
  48492. */
  48493. getSimpleName(): string;
  48494. /**
  48495. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48496. * allow modification of the heightOffset value.
  48497. */
  48498. private _modifierHeightOffset;
  48499. /**
  48500. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48501. * allow modification of the rotationOffset value.
  48502. */
  48503. private _modifierRotationOffset;
  48504. /**
  48505. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48506. * allow modification of the radius value.
  48507. */
  48508. private _modifierRadius;
  48509. }
  48510. }
  48511. declare module BABYLON {
  48512. interface FreeCameraInputsManager {
  48513. /**
  48514. * @hidden
  48515. */
  48516. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48517. /**
  48518. * Add orientation input support to the input manager.
  48519. * @returns the current input manager
  48520. */
  48521. addDeviceOrientation(): FreeCameraInputsManager;
  48522. }
  48523. /**
  48524. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48525. * Screen rotation is taken into account.
  48526. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48527. */
  48528. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48529. private _camera;
  48530. private _screenOrientationAngle;
  48531. private _constantTranform;
  48532. private _screenQuaternion;
  48533. private _alpha;
  48534. private _beta;
  48535. private _gamma;
  48536. /**
  48537. * Can be used to detect if a device orientation sensor is available on a device
  48538. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48539. * @returns a promise that will resolve on orientation change
  48540. */
  48541. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48542. /**
  48543. * @hidden
  48544. */
  48545. _onDeviceOrientationChangedObservable: Observable<void>;
  48546. /**
  48547. * Instantiates a new input
  48548. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48549. */
  48550. constructor();
  48551. /**
  48552. * Define the camera controlled by the input.
  48553. */
  48554. get camera(): FreeCamera;
  48555. set camera(camera: FreeCamera);
  48556. /**
  48557. * Attach the input controls to a specific dom element to get the input from.
  48558. */
  48559. attachControl(): void;
  48560. private _orientationChanged;
  48561. private _deviceOrientation;
  48562. /**
  48563. * Detach the current controls from the specified dom element.
  48564. */
  48565. detachControl(): void;
  48566. /**
  48567. * Update the current camera state depending on the inputs that have been used this frame.
  48568. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48569. */
  48570. checkInputs(): void;
  48571. /**
  48572. * Gets the class name of the current intput.
  48573. * @returns the class name
  48574. */
  48575. getClassName(): string;
  48576. /**
  48577. * Get the friendly name associated with the input class.
  48578. * @returns the input friendly name
  48579. */
  48580. getSimpleName(): string;
  48581. }
  48582. }
  48583. declare module BABYLON {
  48584. /**
  48585. * Manage the gamepad inputs to control a free camera.
  48586. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48587. */
  48588. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48589. /**
  48590. * Define the camera the input is attached to.
  48591. */
  48592. camera: FreeCamera;
  48593. /**
  48594. * Define the Gamepad controlling the input
  48595. */
  48596. gamepad: Nullable<Gamepad>;
  48597. /**
  48598. * Defines the gamepad rotation sensiblity.
  48599. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48600. */
  48601. gamepadAngularSensibility: number;
  48602. /**
  48603. * Defines the gamepad move sensiblity.
  48604. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48605. */
  48606. gamepadMoveSensibility: number;
  48607. private _yAxisScale;
  48608. /**
  48609. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48610. */
  48611. get invertYAxis(): boolean;
  48612. set invertYAxis(value: boolean);
  48613. private _onGamepadConnectedObserver;
  48614. private _onGamepadDisconnectedObserver;
  48615. private _cameraTransform;
  48616. private _deltaTransform;
  48617. private _vector3;
  48618. private _vector2;
  48619. /**
  48620. * Attach the input controls to a specific dom element to get the input from.
  48621. */
  48622. attachControl(): void;
  48623. /**
  48624. * Detach the current controls from the specified dom element.
  48625. */
  48626. detachControl(): void;
  48627. /**
  48628. * Update the current camera state depending on the inputs that have been used this frame.
  48629. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48630. */
  48631. checkInputs(): void;
  48632. /**
  48633. * Gets the class name of the current intput.
  48634. * @returns the class name
  48635. */
  48636. getClassName(): string;
  48637. /**
  48638. * Get the friendly name associated with the input class.
  48639. * @returns the input friendly name
  48640. */
  48641. getSimpleName(): string;
  48642. }
  48643. }
  48644. declare module BABYLON {
  48645. /**
  48646. * Defines the potential axis of a Joystick
  48647. */
  48648. export enum JoystickAxis {
  48649. /** X axis */
  48650. X = 0,
  48651. /** Y axis */
  48652. Y = 1,
  48653. /** Z axis */
  48654. Z = 2
  48655. }
  48656. /**
  48657. * Represents the different customization options available
  48658. * for VirtualJoystick
  48659. */
  48660. interface VirtualJoystickCustomizations {
  48661. /**
  48662. * Size of the joystick's puck
  48663. */
  48664. puckSize: number;
  48665. /**
  48666. * Size of the joystick's container
  48667. */
  48668. containerSize: number;
  48669. /**
  48670. * Color of the joystick && puck
  48671. */
  48672. color: string;
  48673. /**
  48674. * Image URL for the joystick's puck
  48675. */
  48676. puckImage?: string;
  48677. /**
  48678. * Image URL for the joystick's container
  48679. */
  48680. containerImage?: string;
  48681. /**
  48682. * Defines the unmoving position of the joystick container
  48683. */
  48684. position?: {
  48685. x: number;
  48686. y: number;
  48687. };
  48688. /**
  48689. * Defines whether or not the joystick container is always visible
  48690. */
  48691. alwaysVisible: boolean;
  48692. /**
  48693. * Defines whether or not to limit the movement of the puck to the joystick's container
  48694. */
  48695. limitToContainer: boolean;
  48696. }
  48697. /**
  48698. * Class used to define virtual joystick (used in touch mode)
  48699. */
  48700. export class VirtualJoystick {
  48701. /**
  48702. * Gets or sets a boolean indicating that left and right values must be inverted
  48703. */
  48704. reverseLeftRight: boolean;
  48705. /**
  48706. * Gets or sets a boolean indicating that up and down values must be inverted
  48707. */
  48708. reverseUpDown: boolean;
  48709. /**
  48710. * Gets the offset value for the position (ie. the change of the position value)
  48711. */
  48712. deltaPosition: Vector3;
  48713. /**
  48714. * Gets a boolean indicating if the virtual joystick was pressed
  48715. */
  48716. pressed: boolean;
  48717. /**
  48718. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48719. */
  48720. static Canvas: Nullable<HTMLCanvasElement>;
  48721. /**
  48722. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48723. */
  48724. limitToContainer: boolean;
  48725. private static _globalJoystickIndex;
  48726. private static _alwaysVisibleSticks;
  48727. private static vjCanvasContext;
  48728. private static vjCanvasWidth;
  48729. private static vjCanvasHeight;
  48730. private static halfWidth;
  48731. private static _GetDefaultOptions;
  48732. private _action;
  48733. private _axisTargetedByLeftAndRight;
  48734. private _axisTargetedByUpAndDown;
  48735. private _joystickSensibility;
  48736. private _inversedSensibility;
  48737. private _joystickPointerID;
  48738. private _joystickColor;
  48739. private _joystickPointerPos;
  48740. private _joystickPreviousPointerPos;
  48741. private _joystickPointerStartPos;
  48742. private _deltaJoystickVector;
  48743. private _leftJoystick;
  48744. private _touches;
  48745. private _joystickPosition;
  48746. private _alwaysVisible;
  48747. private _puckImage;
  48748. private _containerImage;
  48749. private _joystickPuckSize;
  48750. private _joystickContainerSize;
  48751. private _clearPuckSize;
  48752. private _clearContainerSize;
  48753. private _clearPuckSizeOffset;
  48754. private _clearContainerSizeOffset;
  48755. private _onPointerDownHandlerRef;
  48756. private _onPointerMoveHandlerRef;
  48757. private _onPointerUpHandlerRef;
  48758. private _onResize;
  48759. /**
  48760. * Creates a new virtual joystick
  48761. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48762. * @param customizations Defines the options we want to customize the VirtualJoystick
  48763. */
  48764. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48765. /**
  48766. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48767. * @param newJoystickSensibility defines the new sensibility
  48768. */
  48769. setJoystickSensibility(newJoystickSensibility: number): void;
  48770. private _onPointerDown;
  48771. private _onPointerMove;
  48772. private _onPointerUp;
  48773. /**
  48774. * Change the color of the virtual joystick
  48775. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48776. */
  48777. setJoystickColor(newColor: string): void;
  48778. /**
  48779. * Size of the joystick's container
  48780. */
  48781. set containerSize(newSize: number);
  48782. get containerSize(): number;
  48783. /**
  48784. * Size of the joystick's puck
  48785. */
  48786. set puckSize(newSize: number);
  48787. get puckSize(): number;
  48788. /**
  48789. * Clears the set position of the joystick
  48790. */
  48791. clearPosition(): void;
  48792. /**
  48793. * Defines whether or not the joystick container is always visible
  48794. */
  48795. set alwaysVisible(value: boolean);
  48796. get alwaysVisible(): boolean;
  48797. /**
  48798. * Sets the constant position of the Joystick container
  48799. * @param x X axis coordinate
  48800. * @param y Y axis coordinate
  48801. */
  48802. setPosition(x: number, y: number): void;
  48803. /**
  48804. * Defines a callback to call when the joystick is touched
  48805. * @param action defines the callback
  48806. */
  48807. setActionOnTouch(action: () => any): void;
  48808. /**
  48809. * Defines which axis you'd like to control for left & right
  48810. * @param axis defines the axis to use
  48811. */
  48812. setAxisForLeftRight(axis: JoystickAxis): void;
  48813. /**
  48814. * Defines which axis you'd like to control for up & down
  48815. * @param axis defines the axis to use
  48816. */
  48817. setAxisForUpDown(axis: JoystickAxis): void;
  48818. /**
  48819. * Clears the canvas from the previous puck / container draw
  48820. */
  48821. private _clearPreviousDraw;
  48822. /**
  48823. * Loads `urlPath` to be used for the container's image
  48824. * @param urlPath defines the urlPath of an image to use
  48825. */
  48826. setContainerImage(urlPath: string): void;
  48827. /**
  48828. * Loads `urlPath` to be used for the puck's image
  48829. * @param urlPath defines the urlPath of an image to use
  48830. */
  48831. setPuckImage(urlPath: string): void;
  48832. /**
  48833. * Draws the Virtual Joystick's container
  48834. */
  48835. private _drawContainer;
  48836. /**
  48837. * Draws the Virtual Joystick's puck
  48838. */
  48839. private _drawPuck;
  48840. private _drawVirtualJoystick;
  48841. /**
  48842. * Release internal HTML canvas
  48843. */
  48844. releaseCanvas(): void;
  48845. }
  48846. }
  48847. declare module BABYLON {
  48848. interface FreeCameraInputsManager {
  48849. /**
  48850. * Add virtual joystick input support to the input manager.
  48851. * @returns the current input manager
  48852. */
  48853. addVirtualJoystick(): FreeCameraInputsManager;
  48854. }
  48855. /**
  48856. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48857. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48858. */
  48859. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48860. /**
  48861. * Defines the camera the input is attached to.
  48862. */
  48863. camera: FreeCamera;
  48864. private _leftjoystick;
  48865. private _rightjoystick;
  48866. /**
  48867. * Gets the left stick of the virtual joystick.
  48868. * @returns The virtual Joystick
  48869. */
  48870. getLeftJoystick(): VirtualJoystick;
  48871. /**
  48872. * Gets the right stick of the virtual joystick.
  48873. * @returns The virtual Joystick
  48874. */
  48875. getRightJoystick(): VirtualJoystick;
  48876. /**
  48877. * Update the current camera state depending on the inputs that have been used this frame.
  48878. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48879. */
  48880. checkInputs(): void;
  48881. /**
  48882. * Attach the input controls to a specific dom element to get the input from.
  48883. */
  48884. attachControl(): void;
  48885. /**
  48886. * Detach the current controls from the specified dom element.
  48887. */
  48888. detachControl(): void;
  48889. /**
  48890. * Gets the class name of the current intput.
  48891. * @returns the class name
  48892. */
  48893. getClassName(): string;
  48894. /**
  48895. * Get the friendly name associated with the input class.
  48896. * @returns the input friendly name
  48897. */
  48898. getSimpleName(): string;
  48899. }
  48900. }
  48901. declare module BABYLON {
  48902. /**
  48903. * This represents a FPS type of camera controlled by touch.
  48904. * This is like a universal camera minus the Gamepad controls.
  48905. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48906. */
  48907. export class TouchCamera extends FreeCamera {
  48908. /**
  48909. * Defines the touch sensibility for rotation.
  48910. * The higher the faster.
  48911. */
  48912. get touchAngularSensibility(): number;
  48913. set touchAngularSensibility(value: number);
  48914. /**
  48915. * Defines the touch sensibility for move.
  48916. * The higher the faster.
  48917. */
  48918. get touchMoveSensibility(): number;
  48919. set touchMoveSensibility(value: number);
  48920. /**
  48921. * Instantiates a new touch camera.
  48922. * This represents a FPS type of camera controlled by touch.
  48923. * This is like a universal camera minus the Gamepad controls.
  48924. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48925. * @param name Define the name of the camera in the scene
  48926. * @param position Define the start position of the camera in the scene
  48927. * @param scene Define the scene the camera belongs to
  48928. */
  48929. constructor(name: string, position: Vector3, scene: Scene);
  48930. /**
  48931. * Gets the current object class name.
  48932. * @return the class name
  48933. */
  48934. getClassName(): string;
  48935. /** @hidden */
  48936. _setupInputs(): void;
  48937. }
  48938. }
  48939. declare module BABYLON {
  48940. /**
  48941. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48942. * being tilted forward or back and left or right.
  48943. */
  48944. export class DeviceOrientationCamera extends FreeCamera {
  48945. private _initialQuaternion;
  48946. private _quaternionCache;
  48947. private _tmpDragQuaternion;
  48948. private _disablePointerInputWhenUsingDeviceOrientation;
  48949. /**
  48950. * Creates a new device orientation camera
  48951. * @param name The name of the camera
  48952. * @param position The start position camera
  48953. * @param scene The scene the camera belongs to
  48954. */
  48955. constructor(name: string, position: Vector3, scene: Scene);
  48956. /**
  48957. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48958. */
  48959. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48960. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48961. private _dragFactor;
  48962. /**
  48963. * Enabled turning on the y axis when the orientation sensor is active
  48964. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48965. */
  48966. enableHorizontalDragging(dragFactor?: number): void;
  48967. /**
  48968. * Gets the current instance class name ("DeviceOrientationCamera").
  48969. * This helps avoiding instanceof at run time.
  48970. * @returns the class name
  48971. */
  48972. getClassName(): string;
  48973. /**
  48974. * @hidden
  48975. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48976. */
  48977. _checkInputs(): void;
  48978. /**
  48979. * Reset the camera to its default orientation on the specified axis only.
  48980. * @param axis The axis to reset
  48981. */
  48982. resetToCurrentRotation(axis?: Axis): void;
  48983. }
  48984. }
  48985. declare module BABYLON {
  48986. /**
  48987. * Defines supported buttons for XBox360 compatible gamepads
  48988. */
  48989. export enum Xbox360Button {
  48990. /** A */
  48991. A = 0,
  48992. /** B */
  48993. B = 1,
  48994. /** X */
  48995. X = 2,
  48996. /** Y */
  48997. Y = 3,
  48998. /** Left button */
  48999. LB = 4,
  49000. /** Right button */
  49001. RB = 5,
  49002. /** Back */
  49003. Back = 8,
  49004. /** Start */
  49005. Start = 9,
  49006. /** Left stick */
  49007. LeftStick = 10,
  49008. /** Right stick */
  49009. RightStick = 11
  49010. }
  49011. /** Defines values for XBox360 DPad */
  49012. export enum Xbox360Dpad {
  49013. /** Up */
  49014. Up = 12,
  49015. /** Down */
  49016. Down = 13,
  49017. /** Left */
  49018. Left = 14,
  49019. /** Right */
  49020. Right = 15
  49021. }
  49022. /**
  49023. * Defines a XBox360 gamepad
  49024. */
  49025. export class Xbox360Pad extends Gamepad {
  49026. private _leftTrigger;
  49027. private _rightTrigger;
  49028. private _onlefttriggerchanged;
  49029. private _onrighttriggerchanged;
  49030. private _onbuttondown;
  49031. private _onbuttonup;
  49032. private _ondpaddown;
  49033. private _ondpadup;
  49034. /** Observable raised when a button is pressed */
  49035. onButtonDownObservable: Observable<Xbox360Button>;
  49036. /** Observable raised when a button is released */
  49037. onButtonUpObservable: Observable<Xbox360Button>;
  49038. /** Observable raised when a pad is pressed */
  49039. onPadDownObservable: Observable<Xbox360Dpad>;
  49040. /** Observable raised when a pad is released */
  49041. onPadUpObservable: Observable<Xbox360Dpad>;
  49042. private _buttonA;
  49043. private _buttonB;
  49044. private _buttonX;
  49045. private _buttonY;
  49046. private _buttonBack;
  49047. private _buttonStart;
  49048. private _buttonLB;
  49049. private _buttonRB;
  49050. private _buttonLeftStick;
  49051. private _buttonRightStick;
  49052. private _dPadUp;
  49053. private _dPadDown;
  49054. private _dPadLeft;
  49055. private _dPadRight;
  49056. private _isXboxOnePad;
  49057. /**
  49058. * Creates a new XBox360 gamepad object
  49059. * @param id defines the id of this gamepad
  49060. * @param index defines its index
  49061. * @param gamepad defines the internal HTML gamepad object
  49062. * @param xboxOne defines if it is a XBox One gamepad
  49063. */
  49064. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  49065. /**
  49066. * Defines the callback to call when left trigger is pressed
  49067. * @param callback defines the callback to use
  49068. */
  49069. onlefttriggerchanged(callback: (value: number) => void): void;
  49070. /**
  49071. * Defines the callback to call when right trigger is pressed
  49072. * @param callback defines the callback to use
  49073. */
  49074. onrighttriggerchanged(callback: (value: number) => void): void;
  49075. /**
  49076. * Gets the left trigger value
  49077. */
  49078. get leftTrigger(): number;
  49079. /**
  49080. * Sets the left trigger value
  49081. */
  49082. set leftTrigger(newValue: number);
  49083. /**
  49084. * Gets the right trigger value
  49085. */
  49086. get rightTrigger(): number;
  49087. /**
  49088. * Sets the right trigger value
  49089. */
  49090. set rightTrigger(newValue: number);
  49091. /**
  49092. * Defines the callback to call when a button is pressed
  49093. * @param callback defines the callback to use
  49094. */
  49095. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  49096. /**
  49097. * Defines the callback to call when a button is released
  49098. * @param callback defines the callback to use
  49099. */
  49100. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  49101. /**
  49102. * Defines the callback to call when a pad is pressed
  49103. * @param callback defines the callback to use
  49104. */
  49105. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  49106. /**
  49107. * Defines the callback to call when a pad is released
  49108. * @param callback defines the callback to use
  49109. */
  49110. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  49111. private _setButtonValue;
  49112. private _setDPadValue;
  49113. /**
  49114. * Gets the value of the `A` button
  49115. */
  49116. get buttonA(): number;
  49117. /**
  49118. * Sets the value of the `A` button
  49119. */
  49120. set buttonA(value: number);
  49121. /**
  49122. * Gets the value of the `B` button
  49123. */
  49124. get buttonB(): number;
  49125. /**
  49126. * Sets the value of the `B` button
  49127. */
  49128. set buttonB(value: number);
  49129. /**
  49130. * Gets the value of the `X` button
  49131. */
  49132. get buttonX(): number;
  49133. /**
  49134. * Sets the value of the `X` button
  49135. */
  49136. set buttonX(value: number);
  49137. /**
  49138. * Gets the value of the `Y` button
  49139. */
  49140. get buttonY(): number;
  49141. /**
  49142. * Sets the value of the `Y` button
  49143. */
  49144. set buttonY(value: number);
  49145. /**
  49146. * Gets the value of the `Start` button
  49147. */
  49148. get buttonStart(): number;
  49149. /**
  49150. * Sets the value of the `Start` button
  49151. */
  49152. set buttonStart(value: number);
  49153. /**
  49154. * Gets the value of the `Back` button
  49155. */
  49156. get buttonBack(): number;
  49157. /**
  49158. * Sets the value of the `Back` button
  49159. */
  49160. set buttonBack(value: number);
  49161. /**
  49162. * Gets the value of the `Left` button
  49163. */
  49164. get buttonLB(): number;
  49165. /**
  49166. * Sets the value of the `Left` button
  49167. */
  49168. set buttonLB(value: number);
  49169. /**
  49170. * Gets the value of the `Right` button
  49171. */
  49172. get buttonRB(): number;
  49173. /**
  49174. * Sets the value of the `Right` button
  49175. */
  49176. set buttonRB(value: number);
  49177. /**
  49178. * Gets the value of the Left joystick
  49179. */
  49180. get buttonLeftStick(): number;
  49181. /**
  49182. * Sets the value of the Left joystick
  49183. */
  49184. set buttonLeftStick(value: number);
  49185. /**
  49186. * Gets the value of the Right joystick
  49187. */
  49188. get buttonRightStick(): number;
  49189. /**
  49190. * Sets the value of the Right joystick
  49191. */
  49192. set buttonRightStick(value: number);
  49193. /**
  49194. * Gets the value of D-pad up
  49195. */
  49196. get dPadUp(): number;
  49197. /**
  49198. * Sets the value of D-pad up
  49199. */
  49200. set dPadUp(value: number);
  49201. /**
  49202. * Gets the value of D-pad down
  49203. */
  49204. get dPadDown(): number;
  49205. /**
  49206. * Sets the value of D-pad down
  49207. */
  49208. set dPadDown(value: number);
  49209. /**
  49210. * Gets the value of D-pad left
  49211. */
  49212. get dPadLeft(): number;
  49213. /**
  49214. * Sets the value of D-pad left
  49215. */
  49216. set dPadLeft(value: number);
  49217. /**
  49218. * Gets the value of D-pad right
  49219. */
  49220. get dPadRight(): number;
  49221. /**
  49222. * Sets the value of D-pad right
  49223. */
  49224. set dPadRight(value: number);
  49225. /**
  49226. * Force the gamepad to synchronize with device values
  49227. */
  49228. update(): void;
  49229. /**
  49230. * Disposes the gamepad
  49231. */
  49232. dispose(): void;
  49233. }
  49234. }
  49235. declare module BABYLON {
  49236. /**
  49237. * Defines supported buttons for DualShock compatible gamepads
  49238. */
  49239. export enum DualShockButton {
  49240. /** Cross */
  49241. Cross = 0,
  49242. /** Circle */
  49243. Circle = 1,
  49244. /** Square */
  49245. Square = 2,
  49246. /** Triangle */
  49247. Triangle = 3,
  49248. /** L1 */
  49249. L1 = 4,
  49250. /** R1 */
  49251. R1 = 5,
  49252. /** Share */
  49253. Share = 8,
  49254. /** Options */
  49255. Options = 9,
  49256. /** Left stick */
  49257. LeftStick = 10,
  49258. /** Right stick */
  49259. RightStick = 11
  49260. }
  49261. /** Defines values for DualShock DPad */
  49262. export enum DualShockDpad {
  49263. /** Up */
  49264. Up = 12,
  49265. /** Down */
  49266. Down = 13,
  49267. /** Left */
  49268. Left = 14,
  49269. /** Right */
  49270. Right = 15
  49271. }
  49272. /**
  49273. * Defines a DualShock gamepad
  49274. */
  49275. export class DualShockPad extends Gamepad {
  49276. private _leftTrigger;
  49277. private _rightTrigger;
  49278. private _onlefttriggerchanged;
  49279. private _onrighttriggerchanged;
  49280. private _onbuttondown;
  49281. private _onbuttonup;
  49282. private _ondpaddown;
  49283. private _ondpadup;
  49284. /** Observable raised when a button is pressed */
  49285. onButtonDownObservable: Observable<DualShockButton>;
  49286. /** Observable raised when a button is released */
  49287. onButtonUpObservable: Observable<DualShockButton>;
  49288. /** Observable raised when a pad is pressed */
  49289. onPadDownObservable: Observable<DualShockDpad>;
  49290. /** Observable raised when a pad is released */
  49291. onPadUpObservable: Observable<DualShockDpad>;
  49292. private _buttonCross;
  49293. private _buttonCircle;
  49294. private _buttonSquare;
  49295. private _buttonTriangle;
  49296. private _buttonShare;
  49297. private _buttonOptions;
  49298. private _buttonL1;
  49299. private _buttonR1;
  49300. private _buttonLeftStick;
  49301. private _buttonRightStick;
  49302. private _dPadUp;
  49303. private _dPadDown;
  49304. private _dPadLeft;
  49305. private _dPadRight;
  49306. /**
  49307. * Creates a new DualShock gamepad object
  49308. * @param id defines the id of this gamepad
  49309. * @param index defines its index
  49310. * @param gamepad defines the internal HTML gamepad object
  49311. */
  49312. constructor(id: string, index: number, gamepad: any);
  49313. /**
  49314. * Defines the callback to call when left trigger is pressed
  49315. * @param callback defines the callback to use
  49316. */
  49317. onlefttriggerchanged(callback: (value: number) => void): void;
  49318. /**
  49319. * Defines the callback to call when right trigger is pressed
  49320. * @param callback defines the callback to use
  49321. */
  49322. onrighttriggerchanged(callback: (value: number) => void): void;
  49323. /**
  49324. * Gets the left trigger value
  49325. */
  49326. get leftTrigger(): number;
  49327. /**
  49328. * Sets the left trigger value
  49329. */
  49330. set leftTrigger(newValue: number);
  49331. /**
  49332. * Gets the right trigger value
  49333. */
  49334. get rightTrigger(): number;
  49335. /**
  49336. * Sets the right trigger value
  49337. */
  49338. set rightTrigger(newValue: number);
  49339. /**
  49340. * Defines the callback to call when a button is pressed
  49341. * @param callback defines the callback to use
  49342. */
  49343. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49344. /**
  49345. * Defines the callback to call when a button is released
  49346. * @param callback defines the callback to use
  49347. */
  49348. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49349. /**
  49350. * Defines the callback to call when a pad is pressed
  49351. * @param callback defines the callback to use
  49352. */
  49353. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49354. /**
  49355. * Defines the callback to call when a pad is released
  49356. * @param callback defines the callback to use
  49357. */
  49358. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49359. private _setButtonValue;
  49360. private _setDPadValue;
  49361. /**
  49362. * Gets the value of the `Cross` button
  49363. */
  49364. get buttonCross(): number;
  49365. /**
  49366. * Sets the value of the `Cross` button
  49367. */
  49368. set buttonCross(value: number);
  49369. /**
  49370. * Gets the value of the `Circle` button
  49371. */
  49372. get buttonCircle(): number;
  49373. /**
  49374. * Sets the value of the `Circle` button
  49375. */
  49376. set buttonCircle(value: number);
  49377. /**
  49378. * Gets the value of the `Square` button
  49379. */
  49380. get buttonSquare(): number;
  49381. /**
  49382. * Sets the value of the `Square` button
  49383. */
  49384. set buttonSquare(value: number);
  49385. /**
  49386. * Gets the value of the `Triangle` button
  49387. */
  49388. get buttonTriangle(): number;
  49389. /**
  49390. * Sets the value of the `Triangle` button
  49391. */
  49392. set buttonTriangle(value: number);
  49393. /**
  49394. * Gets the value of the `Options` button
  49395. */
  49396. get buttonOptions(): number;
  49397. /**
  49398. * Sets the value of the `Options` button
  49399. */
  49400. set buttonOptions(value: number);
  49401. /**
  49402. * Gets the value of the `Share` button
  49403. */
  49404. get buttonShare(): number;
  49405. /**
  49406. * Sets the value of the `Share` button
  49407. */
  49408. set buttonShare(value: number);
  49409. /**
  49410. * Gets the value of the `L1` button
  49411. */
  49412. get buttonL1(): number;
  49413. /**
  49414. * Sets the value of the `L1` button
  49415. */
  49416. set buttonL1(value: number);
  49417. /**
  49418. * Gets the value of the `R1` button
  49419. */
  49420. get buttonR1(): number;
  49421. /**
  49422. * Sets the value of the `R1` button
  49423. */
  49424. set buttonR1(value: number);
  49425. /**
  49426. * Gets the value of the Left joystick
  49427. */
  49428. get buttonLeftStick(): number;
  49429. /**
  49430. * Sets the value of the Left joystick
  49431. */
  49432. set buttonLeftStick(value: number);
  49433. /**
  49434. * Gets the value of the Right joystick
  49435. */
  49436. get buttonRightStick(): number;
  49437. /**
  49438. * Sets the value of the Right joystick
  49439. */
  49440. set buttonRightStick(value: number);
  49441. /**
  49442. * Gets the value of D-pad up
  49443. */
  49444. get dPadUp(): number;
  49445. /**
  49446. * Sets the value of D-pad up
  49447. */
  49448. set dPadUp(value: number);
  49449. /**
  49450. * Gets the value of D-pad down
  49451. */
  49452. get dPadDown(): number;
  49453. /**
  49454. * Sets the value of D-pad down
  49455. */
  49456. set dPadDown(value: number);
  49457. /**
  49458. * Gets the value of D-pad left
  49459. */
  49460. get dPadLeft(): number;
  49461. /**
  49462. * Sets the value of D-pad left
  49463. */
  49464. set dPadLeft(value: number);
  49465. /**
  49466. * Gets the value of D-pad right
  49467. */
  49468. get dPadRight(): number;
  49469. /**
  49470. * Sets the value of D-pad right
  49471. */
  49472. set dPadRight(value: number);
  49473. /**
  49474. * Force the gamepad to synchronize with device values
  49475. */
  49476. update(): void;
  49477. /**
  49478. * Disposes the gamepad
  49479. */
  49480. dispose(): void;
  49481. }
  49482. }
  49483. declare module BABYLON {
  49484. /**
  49485. * Manager for handling gamepads
  49486. */
  49487. export class GamepadManager {
  49488. private _scene?;
  49489. private _babylonGamepads;
  49490. private _oneGamepadConnected;
  49491. /** @hidden */
  49492. _isMonitoring: boolean;
  49493. private _gamepadEventSupported;
  49494. private _gamepadSupport?;
  49495. /**
  49496. * observable to be triggered when the gamepad controller has been connected
  49497. */
  49498. onGamepadConnectedObservable: Observable<Gamepad>;
  49499. /**
  49500. * observable to be triggered when the gamepad controller has been disconnected
  49501. */
  49502. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49503. private _onGamepadConnectedEvent;
  49504. private _onGamepadDisconnectedEvent;
  49505. /**
  49506. * Initializes the gamepad manager
  49507. * @param _scene BabylonJS scene
  49508. */
  49509. constructor(_scene?: Scene | undefined);
  49510. /**
  49511. * The gamepads in the game pad manager
  49512. */
  49513. get gamepads(): Gamepad[];
  49514. /**
  49515. * Get the gamepad controllers based on type
  49516. * @param type The type of gamepad controller
  49517. * @returns Nullable gamepad
  49518. */
  49519. getGamepadByType(type?: number): Nullable<Gamepad>;
  49520. /**
  49521. * Disposes the gamepad manager
  49522. */
  49523. dispose(): void;
  49524. private _addNewGamepad;
  49525. private _startMonitoringGamepads;
  49526. private _stopMonitoringGamepads;
  49527. /** @hidden */
  49528. _checkGamepadsStatus(): void;
  49529. private _updateGamepadObjects;
  49530. }
  49531. }
  49532. declare module BABYLON {
  49533. interface Scene {
  49534. /** @hidden */
  49535. _gamepadManager: Nullable<GamepadManager>;
  49536. /**
  49537. * Gets the gamepad manager associated with the scene
  49538. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49539. */
  49540. gamepadManager: GamepadManager;
  49541. }
  49542. /**
  49543. * Interface representing a free camera inputs manager
  49544. */
  49545. interface FreeCameraInputsManager {
  49546. /**
  49547. * Adds gamepad input support to the FreeCameraInputsManager.
  49548. * @returns the FreeCameraInputsManager
  49549. */
  49550. addGamepad(): FreeCameraInputsManager;
  49551. }
  49552. /**
  49553. * Interface representing an arc rotate camera inputs manager
  49554. */
  49555. interface ArcRotateCameraInputsManager {
  49556. /**
  49557. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49558. * @returns the camera inputs manager
  49559. */
  49560. addGamepad(): ArcRotateCameraInputsManager;
  49561. }
  49562. /**
  49563. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49564. */
  49565. export class GamepadSystemSceneComponent implements ISceneComponent {
  49566. /**
  49567. * The component name helpfull to identify the component in the list of scene components.
  49568. */
  49569. readonly name: string;
  49570. /**
  49571. * The scene the component belongs to.
  49572. */
  49573. scene: Scene;
  49574. /**
  49575. * Creates a new instance of the component for the given scene
  49576. * @param scene Defines the scene to register the component in
  49577. */
  49578. constructor(scene: Scene);
  49579. /**
  49580. * Registers the component in a given scene
  49581. */
  49582. register(): void;
  49583. /**
  49584. * Rebuilds the elements related to this component in case of
  49585. * context lost for instance.
  49586. */
  49587. rebuild(): void;
  49588. /**
  49589. * Disposes the component and the associated ressources
  49590. */
  49591. dispose(): void;
  49592. private _beforeCameraUpdate;
  49593. }
  49594. }
  49595. declare module BABYLON {
  49596. /**
  49597. * 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,
  49598. * which still works and will still be found in many Playgrounds.
  49599. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49600. */
  49601. export class UniversalCamera extends TouchCamera {
  49602. /**
  49603. * Defines the gamepad rotation sensiblity.
  49604. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49605. */
  49606. get gamepadAngularSensibility(): number;
  49607. set gamepadAngularSensibility(value: number);
  49608. /**
  49609. * Defines the gamepad move sensiblity.
  49610. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49611. */
  49612. get gamepadMoveSensibility(): number;
  49613. set gamepadMoveSensibility(value: number);
  49614. /**
  49615. * 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,
  49616. * which still works and will still be found in many Playgrounds.
  49617. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49618. * @param name Define the name of the camera in the scene
  49619. * @param position Define the start position of the camera in the scene
  49620. * @param scene Define the scene the camera belongs to
  49621. */
  49622. constructor(name: string, position: Vector3, scene: Scene);
  49623. /**
  49624. * Gets the current object class name.
  49625. * @return the class name
  49626. */
  49627. getClassName(): string;
  49628. }
  49629. }
  49630. declare module BABYLON {
  49631. /**
  49632. * This represents a FPS type of camera. This is only here for back compat purpose.
  49633. * Please use the UniversalCamera instead as both are identical.
  49634. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49635. */
  49636. export class GamepadCamera extends UniversalCamera {
  49637. /**
  49638. * Instantiates a new Gamepad Camera
  49639. * This represents a FPS type of camera. This is only here for back compat purpose.
  49640. * Please use the UniversalCamera instead as both are identical.
  49641. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49642. * @param name Define the name of the camera in the scene
  49643. * @param position Define the start position of the camera in the scene
  49644. * @param scene Define the scene the camera belongs to
  49645. */
  49646. constructor(name: string, position: Vector3, scene: Scene);
  49647. /**
  49648. * Gets the current object class name.
  49649. * @return the class name
  49650. */
  49651. getClassName(): string;
  49652. }
  49653. }
  49654. declare module BABYLON {
  49655. /** @hidden */
  49656. export var passPixelShader: {
  49657. name: string;
  49658. shader: string;
  49659. };
  49660. }
  49661. declare module BABYLON {
  49662. /** @hidden */
  49663. export var passCubePixelShader: {
  49664. name: string;
  49665. shader: string;
  49666. };
  49667. }
  49668. declare module BABYLON {
  49669. /**
  49670. * PassPostProcess which produces an output the same as it's input
  49671. */
  49672. export class PassPostProcess extends PostProcess {
  49673. /**
  49674. * Gets a string identifying the name of the class
  49675. * @returns "PassPostProcess" string
  49676. */
  49677. getClassName(): string;
  49678. /**
  49679. * Creates the PassPostProcess
  49680. * @param name The name of the effect.
  49681. * @param options The required width/height ratio to downsize to before computing the render pass.
  49682. * @param camera The camera to apply the render pass to.
  49683. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49684. * @param engine The engine which the post process will be applied. (default: current engine)
  49685. * @param reusable If the post process can be reused on the same frame. (default: false)
  49686. * @param textureType The type of texture to be used when performing the post processing.
  49687. * @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)
  49688. */
  49689. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49690. /** @hidden */
  49691. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49692. }
  49693. /**
  49694. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49695. */
  49696. export class PassCubePostProcess extends PostProcess {
  49697. private _face;
  49698. /**
  49699. * Gets or sets the cube face to display.
  49700. * * 0 is +X
  49701. * * 1 is -X
  49702. * * 2 is +Y
  49703. * * 3 is -Y
  49704. * * 4 is +Z
  49705. * * 5 is -Z
  49706. */
  49707. get face(): number;
  49708. set face(value: number);
  49709. /**
  49710. * Gets a string identifying the name of the class
  49711. * @returns "PassCubePostProcess" string
  49712. */
  49713. getClassName(): string;
  49714. /**
  49715. * Creates the PassCubePostProcess
  49716. * @param name The name of the effect.
  49717. * @param options The required width/height ratio to downsize to before computing the render pass.
  49718. * @param camera The camera to apply the render pass to.
  49719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49720. * @param engine The engine which the post process will be applied. (default: current engine)
  49721. * @param reusable If the post process can be reused on the same frame. (default: false)
  49722. * @param textureType The type of texture to be used when performing the post processing.
  49723. * @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)
  49724. */
  49725. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49726. /** @hidden */
  49727. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49728. }
  49729. }
  49730. declare module BABYLON {
  49731. /** @hidden */
  49732. export var anaglyphPixelShader: {
  49733. name: string;
  49734. shader: string;
  49735. };
  49736. }
  49737. declare module BABYLON {
  49738. /**
  49739. * Postprocess used to generate anaglyphic rendering
  49740. */
  49741. export class AnaglyphPostProcess extends PostProcess {
  49742. private _passedProcess;
  49743. /**
  49744. * Gets a string identifying the name of the class
  49745. * @returns "AnaglyphPostProcess" string
  49746. */
  49747. getClassName(): string;
  49748. /**
  49749. * Creates a new AnaglyphPostProcess
  49750. * @param name defines postprocess name
  49751. * @param options defines creation options or target ratio scale
  49752. * @param rigCameras defines cameras using this postprocess
  49753. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49754. * @param engine defines hosting engine
  49755. * @param reusable defines if the postprocess will be reused multiple times per frame
  49756. */
  49757. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49758. }
  49759. }
  49760. declare module BABYLON {
  49761. /**
  49762. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49763. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49764. */
  49765. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49766. /**
  49767. * Creates a new AnaglyphArcRotateCamera
  49768. * @param name defines camera name
  49769. * @param alpha defines alpha angle (in radians)
  49770. * @param beta defines beta angle (in radians)
  49771. * @param radius defines radius
  49772. * @param target defines camera target
  49773. * @param interaxialDistance defines distance between each color axis
  49774. * @param scene defines the hosting scene
  49775. */
  49776. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49777. /**
  49778. * Gets camera class name
  49779. * @returns AnaglyphArcRotateCamera
  49780. */
  49781. getClassName(): string;
  49782. }
  49783. }
  49784. declare module BABYLON {
  49785. /**
  49786. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49787. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49788. */
  49789. export class AnaglyphFreeCamera extends FreeCamera {
  49790. /**
  49791. * Creates a new AnaglyphFreeCamera
  49792. * @param name defines camera name
  49793. * @param position defines initial position
  49794. * @param interaxialDistance defines distance between each color axis
  49795. * @param scene defines the hosting scene
  49796. */
  49797. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49798. /**
  49799. * Gets camera class name
  49800. * @returns AnaglyphFreeCamera
  49801. */
  49802. getClassName(): string;
  49803. }
  49804. }
  49805. declare module BABYLON {
  49806. /**
  49807. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49808. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49809. */
  49810. export class AnaglyphGamepadCamera extends GamepadCamera {
  49811. /**
  49812. * Creates a new AnaglyphGamepadCamera
  49813. * @param name defines camera name
  49814. * @param position defines initial position
  49815. * @param interaxialDistance defines distance between each color axis
  49816. * @param scene defines the hosting scene
  49817. */
  49818. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49819. /**
  49820. * Gets camera class name
  49821. * @returns AnaglyphGamepadCamera
  49822. */
  49823. getClassName(): string;
  49824. }
  49825. }
  49826. declare module BABYLON {
  49827. /**
  49828. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49829. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49830. */
  49831. export class AnaglyphUniversalCamera extends UniversalCamera {
  49832. /**
  49833. * Creates a new AnaglyphUniversalCamera
  49834. * @param name defines camera name
  49835. * @param position defines initial position
  49836. * @param interaxialDistance defines distance between each color axis
  49837. * @param scene defines the hosting scene
  49838. */
  49839. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49840. /**
  49841. * Gets camera class name
  49842. * @returns AnaglyphUniversalCamera
  49843. */
  49844. getClassName(): string;
  49845. }
  49846. }
  49847. declare module BABYLON {
  49848. /**
  49849. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49850. * @see https://doc.babylonjs.com/features/cameras
  49851. */
  49852. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49853. /**
  49854. * Creates a new StereoscopicArcRotateCamera
  49855. * @param name defines camera name
  49856. * @param alpha defines alpha angle (in radians)
  49857. * @param beta defines beta angle (in radians)
  49858. * @param radius defines radius
  49859. * @param target defines camera target
  49860. * @param interaxialDistance defines distance between each color axis
  49861. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49862. * @param scene defines the hosting scene
  49863. */
  49864. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49865. /**
  49866. * Gets camera class name
  49867. * @returns StereoscopicArcRotateCamera
  49868. */
  49869. getClassName(): string;
  49870. }
  49871. }
  49872. declare module BABYLON {
  49873. /**
  49874. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49875. * @see https://doc.babylonjs.com/features/cameras
  49876. */
  49877. export class StereoscopicFreeCamera extends FreeCamera {
  49878. /**
  49879. * Creates a new StereoscopicFreeCamera
  49880. * @param name defines camera name
  49881. * @param position defines initial position
  49882. * @param interaxialDistance defines distance between each color axis
  49883. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49884. * @param scene defines the hosting scene
  49885. */
  49886. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49887. /**
  49888. * Gets camera class name
  49889. * @returns StereoscopicFreeCamera
  49890. */
  49891. getClassName(): string;
  49892. }
  49893. }
  49894. declare module BABYLON {
  49895. /**
  49896. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49897. * @see https://doc.babylonjs.com/features/cameras
  49898. */
  49899. export class StereoscopicGamepadCamera extends GamepadCamera {
  49900. /**
  49901. * Creates a new StereoscopicGamepadCamera
  49902. * @param name defines camera name
  49903. * @param position defines initial position
  49904. * @param interaxialDistance defines distance between each color axis
  49905. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49906. * @param scene defines the hosting scene
  49907. */
  49908. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49909. /**
  49910. * Gets camera class name
  49911. * @returns StereoscopicGamepadCamera
  49912. */
  49913. getClassName(): string;
  49914. }
  49915. }
  49916. declare module BABYLON {
  49917. /**
  49918. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49919. * @see https://doc.babylonjs.com/features/cameras
  49920. */
  49921. export class StereoscopicUniversalCamera extends UniversalCamera {
  49922. /**
  49923. * Creates a new StereoscopicUniversalCamera
  49924. * @param name defines camera name
  49925. * @param position defines initial position
  49926. * @param interaxialDistance defines distance between each color axis
  49927. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49928. * @param scene defines the hosting scene
  49929. */
  49930. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49931. /**
  49932. * Gets camera class name
  49933. * @returns StereoscopicUniversalCamera
  49934. */
  49935. getClassName(): string;
  49936. }
  49937. }
  49938. declare module BABYLON {
  49939. /**
  49940. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49941. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49942. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49943. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49944. */
  49945. export class VirtualJoysticksCamera extends FreeCamera {
  49946. /**
  49947. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49948. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49949. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49950. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49951. * @param name Define the name of the camera in the scene
  49952. * @param position Define the start position of the camera in the scene
  49953. * @param scene Define the scene the camera belongs to
  49954. */
  49955. constructor(name: string, position: Vector3, scene: Scene);
  49956. /**
  49957. * Gets the current object class name.
  49958. * @return the class name
  49959. */
  49960. getClassName(): string;
  49961. }
  49962. }
  49963. declare module BABYLON {
  49964. /**
  49965. * This represents all the required metrics to create a VR camera.
  49966. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49967. */
  49968. export class VRCameraMetrics {
  49969. /**
  49970. * Define the horizontal resolution off the screen.
  49971. */
  49972. hResolution: number;
  49973. /**
  49974. * Define the vertical resolution off the screen.
  49975. */
  49976. vResolution: number;
  49977. /**
  49978. * Define the horizontal screen size.
  49979. */
  49980. hScreenSize: number;
  49981. /**
  49982. * Define the vertical screen size.
  49983. */
  49984. vScreenSize: number;
  49985. /**
  49986. * Define the vertical screen center position.
  49987. */
  49988. vScreenCenter: number;
  49989. /**
  49990. * Define the distance of the eyes to the screen.
  49991. */
  49992. eyeToScreenDistance: number;
  49993. /**
  49994. * Define the distance between both lenses
  49995. */
  49996. lensSeparationDistance: number;
  49997. /**
  49998. * Define the distance between both viewer's eyes.
  49999. */
  50000. interpupillaryDistance: number;
  50001. /**
  50002. * Define the distortion factor of the VR postprocess.
  50003. * Please, touch with care.
  50004. */
  50005. distortionK: number[];
  50006. /**
  50007. * Define the chromatic aberration correction factors for the VR post process.
  50008. */
  50009. chromaAbCorrection: number[];
  50010. /**
  50011. * Define the scale factor of the post process.
  50012. * The smaller the better but the slower.
  50013. */
  50014. postProcessScaleFactor: number;
  50015. /**
  50016. * Define an offset for the lens center.
  50017. */
  50018. lensCenterOffset: number;
  50019. /**
  50020. * Define if the current vr camera should compensate the distortion of the lense or not.
  50021. */
  50022. compensateDistortion: boolean;
  50023. /**
  50024. * Defines if multiview should be enabled when rendering (Default: false)
  50025. */
  50026. multiviewEnabled: boolean;
  50027. /**
  50028. * Gets the rendering aspect ratio based on the provided resolutions.
  50029. */
  50030. get aspectRatio(): number;
  50031. /**
  50032. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  50033. */
  50034. get aspectRatioFov(): number;
  50035. /**
  50036. * @hidden
  50037. */
  50038. get leftHMatrix(): Matrix;
  50039. /**
  50040. * @hidden
  50041. */
  50042. get rightHMatrix(): Matrix;
  50043. /**
  50044. * @hidden
  50045. */
  50046. get leftPreViewMatrix(): Matrix;
  50047. /**
  50048. * @hidden
  50049. */
  50050. get rightPreViewMatrix(): Matrix;
  50051. /**
  50052. * Get the default VRMetrics based on the most generic setup.
  50053. * @returns the default vr metrics
  50054. */
  50055. static GetDefault(): VRCameraMetrics;
  50056. }
  50057. }
  50058. declare module BABYLON {
  50059. /** @hidden */
  50060. export var vrDistortionCorrectionPixelShader: {
  50061. name: string;
  50062. shader: string;
  50063. };
  50064. }
  50065. declare module BABYLON {
  50066. /**
  50067. * VRDistortionCorrectionPostProcess used for mobile VR
  50068. */
  50069. export class VRDistortionCorrectionPostProcess extends PostProcess {
  50070. private _isRightEye;
  50071. private _distortionFactors;
  50072. private _postProcessScaleFactor;
  50073. private _lensCenterOffset;
  50074. private _scaleIn;
  50075. private _scaleFactor;
  50076. private _lensCenter;
  50077. /**
  50078. * Gets a string identifying the name of the class
  50079. * @returns "VRDistortionCorrectionPostProcess" string
  50080. */
  50081. getClassName(): string;
  50082. /**
  50083. * Initializes the VRDistortionCorrectionPostProcess
  50084. * @param name The name of the effect.
  50085. * @param camera The camera to apply the render pass to.
  50086. * @param isRightEye If this is for the right eye distortion
  50087. * @param vrMetrics All the required metrics for the VR camera
  50088. */
  50089. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  50090. }
  50091. }
  50092. declare module BABYLON {
  50093. /**
  50094. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  50095. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50096. */
  50097. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  50098. /**
  50099. * Creates a new VRDeviceOrientationArcRotateCamera
  50100. * @param name defines camera name
  50101. * @param alpha defines the camera rotation along the logitudinal axis
  50102. * @param beta defines the camera rotation along the latitudinal axis
  50103. * @param radius defines the camera distance from its target
  50104. * @param target defines the camera target
  50105. * @param scene defines the scene the camera belongs to
  50106. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50107. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50108. */
  50109. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50110. /**
  50111. * Gets camera class name
  50112. * @returns VRDeviceOrientationArcRotateCamera
  50113. */
  50114. getClassName(): string;
  50115. }
  50116. }
  50117. declare module BABYLON {
  50118. /**
  50119. * Camera used to simulate VR rendering (based on FreeCamera)
  50120. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50121. */
  50122. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  50123. /**
  50124. * Creates a new VRDeviceOrientationFreeCamera
  50125. * @param name defines camera name
  50126. * @param position defines the start position of the camera
  50127. * @param scene defines the scene the camera belongs to
  50128. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50129. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50130. */
  50131. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50132. /**
  50133. * Gets camera class name
  50134. * @returns VRDeviceOrientationFreeCamera
  50135. */
  50136. getClassName(): string;
  50137. }
  50138. }
  50139. declare module BABYLON {
  50140. /**
  50141. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  50142. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50143. */
  50144. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  50145. /**
  50146. * Creates a new VRDeviceOrientationGamepadCamera
  50147. * @param name defines camera name
  50148. * @param position defines the start position of the camera
  50149. * @param scene defines the scene the camera belongs to
  50150. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50151. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50152. */
  50153. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50154. /**
  50155. * Gets camera class name
  50156. * @returns VRDeviceOrientationGamepadCamera
  50157. */
  50158. getClassName(): string;
  50159. }
  50160. }
  50161. declare module BABYLON {
  50162. /**
  50163. * A class extending Texture allowing drawing on a texture
  50164. * @see https://doc.babylonjs.com/how_to/dynamictexture
  50165. */
  50166. export class DynamicTexture extends Texture {
  50167. private _generateMipMaps;
  50168. private _canvas;
  50169. private _context;
  50170. /**
  50171. * Creates a DynamicTexture
  50172. * @param name defines the name of the texture
  50173. * @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
  50174. * @param scene defines the scene where you want the texture
  50175. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  50176. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  50177. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  50178. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  50179. */
  50180. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  50181. /**
  50182. * Get the current class name of the texture useful for serialization or dynamic coding.
  50183. * @returns "DynamicTexture"
  50184. */
  50185. getClassName(): string;
  50186. /**
  50187. * Gets the current state of canRescale
  50188. */
  50189. get canRescale(): boolean;
  50190. private _recreate;
  50191. /**
  50192. * Scales the texture
  50193. * @param ratio the scale factor to apply to both width and height
  50194. */
  50195. scale(ratio: number): void;
  50196. /**
  50197. * Resizes the texture
  50198. * @param width the new width
  50199. * @param height the new height
  50200. */
  50201. scaleTo(width: number, height: number): void;
  50202. /**
  50203. * Gets the context of the canvas used by the texture
  50204. * @returns the canvas context of the dynamic texture
  50205. */
  50206. getContext(): CanvasRenderingContext2D;
  50207. /**
  50208. * Clears the texture
  50209. */
  50210. clear(): void;
  50211. /**
  50212. * Updates the texture
  50213. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50214. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  50215. */
  50216. update(invertY?: boolean, premulAlpha?: boolean): void;
  50217. /**
  50218. * Draws text onto the texture
  50219. * @param text defines the text to be drawn
  50220. * @param x defines the placement of the text from the left
  50221. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  50222. * @param font defines the font to be used with font-style, font-size, font-name
  50223. * @param color defines the color used for the text
  50224. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  50225. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50226. * @param update defines whether texture is immediately update (default is true)
  50227. */
  50228. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  50229. /**
  50230. * Clones the texture
  50231. * @returns the clone of the texture.
  50232. */
  50233. clone(): DynamicTexture;
  50234. /**
  50235. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  50236. * @returns a serialized dynamic texture object
  50237. */
  50238. serialize(): any;
  50239. private _IsCanvasElement;
  50240. /** @hidden */
  50241. _rebuild(): void;
  50242. }
  50243. }
  50244. declare module BABYLON {
  50245. /**
  50246. * Class containing static functions to help procedurally build meshes
  50247. */
  50248. export class GroundBuilder {
  50249. /**
  50250. * Creates a ground mesh
  50251. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50252. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50254. * @param name defines the name of the mesh
  50255. * @param options defines the options used to create the mesh
  50256. * @param scene defines the hosting scene
  50257. * @returns the ground mesh
  50258. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50259. */
  50260. static CreateGround(name: string, options: {
  50261. width?: number;
  50262. height?: number;
  50263. subdivisions?: number;
  50264. subdivisionsX?: number;
  50265. subdivisionsY?: number;
  50266. updatable?: boolean;
  50267. }, scene: any): Mesh;
  50268. /**
  50269. * Creates a tiled ground mesh
  50270. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50271. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50272. * * 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
  50273. * * 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
  50274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50275. * @param name defines the name of the mesh
  50276. * @param options defines the options used to create the mesh
  50277. * @param scene defines the hosting scene
  50278. * @returns the tiled ground mesh
  50279. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50280. */
  50281. static CreateTiledGround(name: string, options: {
  50282. xmin: number;
  50283. zmin: number;
  50284. xmax: number;
  50285. zmax: number;
  50286. subdivisions?: {
  50287. w: number;
  50288. h: number;
  50289. };
  50290. precision?: {
  50291. w: number;
  50292. h: number;
  50293. };
  50294. updatable?: boolean;
  50295. }, scene?: Nullable<Scene>): Mesh;
  50296. /**
  50297. * Creates a ground mesh from a height map
  50298. * * The parameter `url` sets the URL of the height map image resource.
  50299. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50300. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50301. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50302. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50303. * * 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.
  50304. * * 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).
  50305. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50307. * @param name defines the name of the mesh
  50308. * @param url defines the url to the height map
  50309. * @param options defines the options used to create the mesh
  50310. * @param scene defines the hosting scene
  50311. * @returns the ground mesh
  50312. * @see https://doc.babylonjs.com/babylon101/height_map
  50313. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50314. */
  50315. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50316. width?: number;
  50317. height?: number;
  50318. subdivisions?: number;
  50319. minHeight?: number;
  50320. maxHeight?: number;
  50321. colorFilter?: Color3;
  50322. alphaFilter?: number;
  50323. updatable?: boolean;
  50324. onReady?: (mesh: GroundMesh) => void;
  50325. }, scene?: Nullable<Scene>): GroundMesh;
  50326. }
  50327. }
  50328. declare module BABYLON {
  50329. /**
  50330. * Class containing static functions to help procedurally build meshes
  50331. */
  50332. export class TorusBuilder {
  50333. /**
  50334. * Creates a torus mesh
  50335. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50336. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50337. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50339. * * 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
  50340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50341. * @param name defines the name of the mesh
  50342. * @param options defines the options used to create the mesh
  50343. * @param scene defines the hosting scene
  50344. * @returns the torus mesh
  50345. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50346. */
  50347. static CreateTorus(name: string, options: {
  50348. diameter?: number;
  50349. thickness?: number;
  50350. tessellation?: number;
  50351. updatable?: boolean;
  50352. sideOrientation?: number;
  50353. frontUVs?: Vector4;
  50354. backUVs?: Vector4;
  50355. }, scene: any): Mesh;
  50356. }
  50357. }
  50358. declare module BABYLON {
  50359. /**
  50360. * Class containing static functions to help procedurally build meshes
  50361. */
  50362. export class CylinderBuilder {
  50363. /**
  50364. * Creates a cylinder or a cone mesh
  50365. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50366. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50367. * * 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.
  50368. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50369. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50370. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50371. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50372. * * 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).
  50373. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50374. * * 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).
  50375. * * 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
  50376. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50377. * * 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
  50378. * * 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.
  50379. * * If `enclose` is false, a ring surface is one element.
  50380. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50381. * * 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
  50382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50383. * * 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
  50384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50385. * @param name defines the name of the mesh
  50386. * @param options defines the options used to create the mesh
  50387. * @param scene defines the hosting scene
  50388. * @returns the cylinder mesh
  50389. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50390. */
  50391. static CreateCylinder(name: string, options: {
  50392. height?: number;
  50393. diameterTop?: number;
  50394. diameterBottom?: number;
  50395. diameter?: number;
  50396. tessellation?: number;
  50397. subdivisions?: number;
  50398. arc?: number;
  50399. faceColors?: Color4[];
  50400. faceUV?: Vector4[];
  50401. updatable?: boolean;
  50402. hasRings?: boolean;
  50403. enclose?: boolean;
  50404. cap?: number;
  50405. sideOrientation?: number;
  50406. frontUVs?: Vector4;
  50407. backUVs?: Vector4;
  50408. }, scene: any): Mesh;
  50409. }
  50410. }
  50411. declare module BABYLON {
  50412. /**
  50413. * States of the webXR experience
  50414. */
  50415. export enum WebXRState {
  50416. /**
  50417. * Transitioning to being in XR mode
  50418. */
  50419. ENTERING_XR = 0,
  50420. /**
  50421. * Transitioning to non XR mode
  50422. */
  50423. EXITING_XR = 1,
  50424. /**
  50425. * In XR mode and presenting
  50426. */
  50427. IN_XR = 2,
  50428. /**
  50429. * Not entered XR mode
  50430. */
  50431. NOT_IN_XR = 3
  50432. }
  50433. /**
  50434. * The state of the XR camera's tracking
  50435. */
  50436. export enum WebXRTrackingState {
  50437. /**
  50438. * No transformation received, device is not being tracked
  50439. */
  50440. NOT_TRACKING = 0,
  50441. /**
  50442. * Tracking lost - using emulated position
  50443. */
  50444. TRACKING_LOST = 1,
  50445. /**
  50446. * Transformation tracking works normally
  50447. */
  50448. TRACKING = 2
  50449. }
  50450. /**
  50451. * Abstraction of the XR render target
  50452. */
  50453. export interface WebXRRenderTarget extends IDisposable {
  50454. /**
  50455. * xrpresent context of the canvas which can be used to display/mirror xr content
  50456. */
  50457. canvasContext: WebGLRenderingContext;
  50458. /**
  50459. * xr layer for the canvas
  50460. */
  50461. xrLayer: Nullable<XRWebGLLayer>;
  50462. /**
  50463. * Initializes the xr layer for the session
  50464. * @param xrSession xr session
  50465. * @returns a promise that will resolve once the XR Layer has been created
  50466. */
  50467. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50468. }
  50469. }
  50470. declare module BABYLON {
  50471. /**
  50472. * COnfiguration object for WebXR output canvas
  50473. */
  50474. export class WebXRManagedOutputCanvasOptions {
  50475. /**
  50476. * An optional canvas in case you wish to create it yourself and provide it here.
  50477. * If not provided, a new canvas will be created
  50478. */
  50479. canvasElement?: HTMLCanvasElement;
  50480. /**
  50481. * Options for this XR Layer output
  50482. */
  50483. canvasOptions?: XRWebGLLayerInit;
  50484. /**
  50485. * CSS styling for a newly created canvas (if not provided)
  50486. */
  50487. newCanvasCssStyle?: string;
  50488. /**
  50489. * Get the default values of the configuration object
  50490. * @param engine defines the engine to use (can be null)
  50491. * @returns default values of this configuration object
  50492. */
  50493. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50494. }
  50495. /**
  50496. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50497. */
  50498. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50499. private _options;
  50500. private _canvas;
  50501. private _engine;
  50502. private _originalCanvasSize;
  50503. /**
  50504. * Rendering context of the canvas which can be used to display/mirror xr content
  50505. */
  50506. canvasContext: WebGLRenderingContext;
  50507. /**
  50508. * xr layer for the canvas
  50509. */
  50510. xrLayer: Nullable<XRWebGLLayer>;
  50511. /**
  50512. * Obseervers registered here will be triggered when the xr layer was initialized
  50513. */
  50514. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50515. /**
  50516. * Initializes the canvas to be added/removed upon entering/exiting xr
  50517. * @param _xrSessionManager The XR Session manager
  50518. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50519. */
  50520. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50521. /**
  50522. * Disposes of the object
  50523. */
  50524. dispose(): void;
  50525. /**
  50526. * Initializes the xr layer for the session
  50527. * @param xrSession xr session
  50528. * @returns a promise that will resolve once the XR Layer has been created
  50529. */
  50530. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50531. private _addCanvas;
  50532. private _removeCanvas;
  50533. private _setCanvasSize;
  50534. private _setManagedOutputCanvas;
  50535. }
  50536. }
  50537. declare module BABYLON {
  50538. /**
  50539. * Manages an XRSession to work with Babylon's engine
  50540. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50541. */
  50542. export class WebXRSessionManager implements IDisposable {
  50543. /** The scene which the session should be created for */
  50544. scene: Scene;
  50545. private _referenceSpace;
  50546. private _rttProvider;
  50547. private _sessionEnded;
  50548. private _xrNavigator;
  50549. private baseLayer;
  50550. /**
  50551. * The base reference space from which the session started. good if you want to reset your
  50552. * reference space
  50553. */
  50554. baseReferenceSpace: XRReferenceSpace;
  50555. /**
  50556. * Current XR frame
  50557. */
  50558. currentFrame: Nullable<XRFrame>;
  50559. /** WebXR timestamp updated every frame */
  50560. currentTimestamp: number;
  50561. /**
  50562. * Used just in case of a failure to initialize an immersive session.
  50563. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50564. */
  50565. defaultHeightCompensation: number;
  50566. /**
  50567. * Fires every time a new xrFrame arrives which can be used to update the camera
  50568. */
  50569. onXRFrameObservable: Observable<XRFrame>;
  50570. /**
  50571. * Fires when the reference space changed
  50572. */
  50573. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50574. /**
  50575. * Fires when the xr session is ended either by the device or manually done
  50576. */
  50577. onXRSessionEnded: Observable<any>;
  50578. /**
  50579. * Fires when the xr session is ended either by the device or manually done
  50580. */
  50581. onXRSessionInit: Observable<XRSession>;
  50582. /**
  50583. * Underlying xr session
  50584. */
  50585. session: XRSession;
  50586. /**
  50587. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50588. * or get the offset the player is currently at.
  50589. */
  50590. viewerReferenceSpace: XRReferenceSpace;
  50591. /**
  50592. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50593. * @param scene The scene which the session should be created for
  50594. */
  50595. constructor(
  50596. /** The scene which the session should be created for */
  50597. scene: Scene);
  50598. /**
  50599. * The current reference space used in this session. This reference space can constantly change!
  50600. * It is mainly used to offset the camera's position.
  50601. */
  50602. get referenceSpace(): XRReferenceSpace;
  50603. /**
  50604. * Set a new reference space and triggers the observable
  50605. */
  50606. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50607. /**
  50608. * Disposes of the session manager
  50609. */
  50610. dispose(): void;
  50611. /**
  50612. * Stops the xrSession and restores the render loop
  50613. * @returns Promise which resolves after it exits XR
  50614. */
  50615. exitXRAsync(): Promise<void>;
  50616. /**
  50617. * Gets the correct render target texture to be rendered this frame for this eye
  50618. * @param eye the eye for which to get the render target
  50619. * @returns the render target for the specified eye
  50620. */
  50621. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50622. /**
  50623. * Creates a WebXRRenderTarget object for the XR session
  50624. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50625. * @param options optional options to provide when creating a new render target
  50626. * @returns a WebXR render target to which the session can render
  50627. */
  50628. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50629. /**
  50630. * Initializes the manager
  50631. * After initialization enterXR can be called to start an XR session
  50632. * @returns Promise which resolves after it is initialized
  50633. */
  50634. initializeAsync(): Promise<void>;
  50635. /**
  50636. * Initializes an xr session
  50637. * @param xrSessionMode mode to initialize
  50638. * @param xrSessionInit defines optional and required values to pass to the session builder
  50639. * @returns a promise which will resolve once the session has been initialized
  50640. */
  50641. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50642. /**
  50643. * Checks if a session would be supported for the creation options specified
  50644. * @param sessionMode session mode to check if supported eg. immersive-vr
  50645. * @returns A Promise that resolves to true if supported and false if not
  50646. */
  50647. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50648. /**
  50649. * Resets the reference space to the one started the session
  50650. */
  50651. resetReferenceSpace(): void;
  50652. /**
  50653. * Starts rendering to the xr layer
  50654. */
  50655. runXRRenderLoop(): void;
  50656. /**
  50657. * Sets the reference space on the xr session
  50658. * @param referenceSpaceType space to set
  50659. * @returns a promise that will resolve once the reference space has been set
  50660. */
  50661. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50662. /**
  50663. * Updates the render state of the session
  50664. * @param state state to set
  50665. * @returns a promise that resolves once the render state has been updated
  50666. */
  50667. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50668. /**
  50669. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50670. * @param sessionMode defines the session to test
  50671. * @returns a promise with boolean as final value
  50672. */
  50673. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50674. private _createRenderTargetTexture;
  50675. }
  50676. }
  50677. declare module BABYLON {
  50678. /**
  50679. * WebXR Camera which holds the views for the xrSession
  50680. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50681. */
  50682. export class WebXRCamera extends FreeCamera {
  50683. private _xrSessionManager;
  50684. private _firstFrame;
  50685. private _referenceQuaternion;
  50686. private _referencedPosition;
  50687. private _xrInvPositionCache;
  50688. private _xrInvQuaternionCache;
  50689. private _trackingState;
  50690. /**
  50691. * Observable raised before camera teleportation
  50692. */
  50693. onBeforeCameraTeleport: Observable<Vector3>;
  50694. /**
  50695. * Observable raised after camera teleportation
  50696. */
  50697. onAfterCameraTeleport: Observable<Vector3>;
  50698. /**
  50699. * Notifies when the camera's tracking state has changed.
  50700. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50701. */
  50702. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50703. /**
  50704. * Should position compensation execute on first frame.
  50705. * This is used when copying the position from a native (non XR) camera
  50706. */
  50707. compensateOnFirstFrame: boolean;
  50708. /**
  50709. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50710. * @param name the name of the camera
  50711. * @param scene the scene to add the camera to
  50712. * @param _xrSessionManager a constructed xr session manager
  50713. */
  50714. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50715. /**
  50716. * Get the current XR tracking state of the camera
  50717. */
  50718. get trackingState(): WebXRTrackingState;
  50719. private _setTrackingState;
  50720. /**
  50721. * Return the user's height, unrelated to the current ground.
  50722. * This will be the y position of this camera, when ground level is 0.
  50723. */
  50724. get realWorldHeight(): number;
  50725. /** @hidden */
  50726. _updateForDualEyeDebugging(): void;
  50727. /**
  50728. * Sets this camera's transformation based on a non-vr camera
  50729. * @param otherCamera the non-vr camera to copy the transformation from
  50730. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50731. */
  50732. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50733. /**
  50734. * Gets the current instance class name ("WebXRCamera").
  50735. * @returns the class name
  50736. */
  50737. getClassName(): string;
  50738. private _rotate180;
  50739. private _updateFromXRSession;
  50740. private _updateNumberOfRigCameras;
  50741. private _updateReferenceSpace;
  50742. private _updateReferenceSpaceOffset;
  50743. }
  50744. }
  50745. declare module BABYLON {
  50746. /**
  50747. * Defining the interface required for a (webxr) feature
  50748. */
  50749. export interface IWebXRFeature extends IDisposable {
  50750. /**
  50751. * Is this feature attached
  50752. */
  50753. attached: boolean;
  50754. /**
  50755. * Should auto-attach be disabled?
  50756. */
  50757. disableAutoAttach: boolean;
  50758. /**
  50759. * Attach the feature to the session
  50760. * Will usually be called by the features manager
  50761. *
  50762. * @param force should attachment be forced (even when already attached)
  50763. * @returns true if successful.
  50764. */
  50765. attach(force?: boolean): boolean;
  50766. /**
  50767. * Detach the feature from the session
  50768. * Will usually be called by the features manager
  50769. *
  50770. * @returns true if successful.
  50771. */
  50772. detach(): boolean;
  50773. /**
  50774. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50775. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50776. *
  50777. * @returns whether or not the feature is compatible in this environment
  50778. */
  50779. isCompatible(): boolean;
  50780. /**
  50781. * Was this feature disposed;
  50782. */
  50783. isDisposed: boolean;
  50784. /**
  50785. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50786. */
  50787. xrNativeFeatureName?: string;
  50788. /**
  50789. * A list of (Babylon WebXR) features this feature depends on
  50790. */
  50791. dependsOn?: string[];
  50792. }
  50793. /**
  50794. * A list of the currently available features without referencing them
  50795. */
  50796. export class WebXRFeatureName {
  50797. /**
  50798. * The name of the anchor system feature
  50799. */
  50800. static readonly ANCHOR_SYSTEM: string;
  50801. /**
  50802. * The name of the background remover feature
  50803. */
  50804. static readonly BACKGROUND_REMOVER: string;
  50805. /**
  50806. * The name of the hit test feature
  50807. */
  50808. static readonly HIT_TEST: string;
  50809. /**
  50810. * physics impostors for xr controllers feature
  50811. */
  50812. static readonly PHYSICS_CONTROLLERS: string;
  50813. /**
  50814. * The name of the plane detection feature
  50815. */
  50816. static readonly PLANE_DETECTION: string;
  50817. /**
  50818. * The name of the pointer selection feature
  50819. */
  50820. static readonly POINTER_SELECTION: string;
  50821. /**
  50822. * The name of the teleportation feature
  50823. */
  50824. static readonly TELEPORTATION: string;
  50825. /**
  50826. * The name of the feature points feature.
  50827. */
  50828. static readonly FEATURE_POINTS: string;
  50829. /**
  50830. * The name of the hand tracking feature.
  50831. */
  50832. static readonly HAND_TRACKING: string;
  50833. }
  50834. /**
  50835. * Defining the constructor of a feature. Used to register the modules.
  50836. */
  50837. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50838. /**
  50839. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50840. * It is mainly used in AR sessions.
  50841. *
  50842. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50843. */
  50844. export class WebXRFeaturesManager implements IDisposable {
  50845. private _xrSessionManager;
  50846. private static readonly _AvailableFeatures;
  50847. private _features;
  50848. /**
  50849. * constructs a new features manages.
  50850. *
  50851. * @param _xrSessionManager an instance of WebXRSessionManager
  50852. */
  50853. constructor(_xrSessionManager: WebXRSessionManager);
  50854. /**
  50855. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50856. * Mainly used internally.
  50857. *
  50858. * @param featureName the name of the feature to register
  50859. * @param constructorFunction the function used to construct the module
  50860. * @param version the (babylon) version of the module
  50861. * @param stable is that a stable version of this module
  50862. */
  50863. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50864. /**
  50865. * Returns a constructor of a specific feature.
  50866. *
  50867. * @param featureName the name of the feature to construct
  50868. * @param version the version of the feature to load
  50869. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50870. * @param options optional options provided to the module.
  50871. * @returns a function that, when called, will return a new instance of this feature
  50872. */
  50873. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50874. /**
  50875. * Can be used to return the list of features currently registered
  50876. *
  50877. * @returns an Array of available features
  50878. */
  50879. static GetAvailableFeatures(): string[];
  50880. /**
  50881. * Gets the versions available for a specific feature
  50882. * @param featureName the name of the feature
  50883. * @returns an array with the available versions
  50884. */
  50885. static GetAvailableVersions(featureName: string): string[];
  50886. /**
  50887. * Return the latest unstable version of this feature
  50888. * @param featureName the name of the feature to search
  50889. * @returns the version number. if not found will return -1
  50890. */
  50891. static GetLatestVersionOfFeature(featureName: string): number;
  50892. /**
  50893. * Return the latest stable version of this feature
  50894. * @param featureName the name of the feature to search
  50895. * @returns the version number. if not found will return -1
  50896. */
  50897. static GetStableVersionOfFeature(featureName: string): number;
  50898. /**
  50899. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50900. * Can be used during a session to start a feature
  50901. * @param featureName the name of feature to attach
  50902. */
  50903. attachFeature(featureName: string): void;
  50904. /**
  50905. * Can be used inside a session or when the session ends to detach a specific feature
  50906. * @param featureName the name of the feature to detach
  50907. */
  50908. detachFeature(featureName: string): void;
  50909. /**
  50910. * Used to disable an already-enabled feature
  50911. * The feature will be disposed and will be recreated once enabled.
  50912. * @param featureName the feature to disable
  50913. * @returns true if disable was successful
  50914. */
  50915. disableFeature(featureName: string | {
  50916. Name: string;
  50917. }): boolean;
  50918. /**
  50919. * dispose this features manager
  50920. */
  50921. dispose(): void;
  50922. /**
  50923. * 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.
  50924. * 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.
  50925. *
  50926. * @param featureName the name of the feature to load or the class of the feature
  50927. * @param version optional version to load. if not provided the latest version will be enabled
  50928. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50929. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50930. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50931. * @returns a new constructed feature or throws an error if feature not found.
  50932. */
  50933. enableFeature(featureName: string | {
  50934. Name: string;
  50935. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50936. /**
  50937. * get the implementation of an enabled feature.
  50938. * @param featureName the name of the feature to load
  50939. * @returns the feature class, if found
  50940. */
  50941. getEnabledFeature(featureName: string): IWebXRFeature;
  50942. /**
  50943. * Get the list of enabled features
  50944. * @returns an array of enabled features
  50945. */
  50946. getEnabledFeatures(): string[];
  50947. /**
  50948. * This function will exten the session creation configuration object with enabled features.
  50949. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50950. * according to the defined "required" variable, provided during enableFeature call
  50951. * @param xrSessionInit the xr Session init object to extend
  50952. *
  50953. * @returns an extended XRSessionInit object
  50954. */
  50955. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50956. }
  50957. }
  50958. declare module BABYLON {
  50959. /**
  50960. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50961. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50962. */
  50963. export class WebXRExperienceHelper implements IDisposable {
  50964. private scene;
  50965. private _nonVRCamera;
  50966. private _originalSceneAutoClear;
  50967. private _supported;
  50968. /**
  50969. * Camera used to render xr content
  50970. */
  50971. camera: WebXRCamera;
  50972. /** A features manager for this xr session */
  50973. featuresManager: WebXRFeaturesManager;
  50974. /**
  50975. * Observers registered here will be triggered after the camera's initial transformation is set
  50976. * This can be used to set a different ground level or an extra rotation.
  50977. *
  50978. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50979. * to the position set after this observable is done executing.
  50980. */
  50981. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50982. /**
  50983. * Fires when the state of the experience helper has changed
  50984. */
  50985. onStateChangedObservable: Observable<WebXRState>;
  50986. /** Session manager used to keep track of xr session */
  50987. sessionManager: WebXRSessionManager;
  50988. /**
  50989. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50990. */
  50991. state: WebXRState;
  50992. /**
  50993. * Creates a WebXRExperienceHelper
  50994. * @param scene The scene the helper should be created in
  50995. */
  50996. private constructor();
  50997. /**
  50998. * Creates the experience helper
  50999. * @param scene the scene to attach the experience helper to
  51000. * @returns a promise for the experience helper
  51001. */
  51002. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  51003. /**
  51004. * Disposes of the experience helper
  51005. */
  51006. dispose(): void;
  51007. /**
  51008. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  51009. * @param sessionMode options for the XR session
  51010. * @param referenceSpaceType frame of reference of the XR session
  51011. * @param renderTarget the output canvas that will be used to enter XR mode
  51012. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  51013. * @returns promise that resolves after xr mode has entered
  51014. */
  51015. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  51016. /**
  51017. * Exits XR mode and returns the scene to its original state
  51018. * @returns promise that resolves after xr mode has exited
  51019. */
  51020. exitXRAsync(): Promise<void>;
  51021. private _nonXRToXRCamera;
  51022. private _setState;
  51023. }
  51024. }
  51025. declare module BABYLON {
  51026. /**
  51027. * X-Y values for axes in WebXR
  51028. */
  51029. export interface IWebXRMotionControllerAxesValue {
  51030. /**
  51031. * The value of the x axis
  51032. */
  51033. x: number;
  51034. /**
  51035. * The value of the y-axis
  51036. */
  51037. y: number;
  51038. }
  51039. /**
  51040. * changed / previous values for the values of this component
  51041. */
  51042. export interface IWebXRMotionControllerComponentChangesValues<T> {
  51043. /**
  51044. * current (this frame) value
  51045. */
  51046. current: T;
  51047. /**
  51048. * previous (last change) value
  51049. */
  51050. previous: T;
  51051. }
  51052. /**
  51053. * Represents changes in the component between current frame and last values recorded
  51054. */
  51055. export interface IWebXRMotionControllerComponentChanges {
  51056. /**
  51057. * will be populated with previous and current values if axes changed
  51058. */
  51059. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  51060. /**
  51061. * will be populated with previous and current values if pressed changed
  51062. */
  51063. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51064. /**
  51065. * will be populated with previous and current values if touched changed
  51066. */
  51067. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51068. /**
  51069. * will be populated with previous and current values if value changed
  51070. */
  51071. value?: IWebXRMotionControllerComponentChangesValues<number>;
  51072. }
  51073. /**
  51074. * This class represents a single component (for example button or thumbstick) of a motion controller
  51075. */
  51076. export class WebXRControllerComponent implements IDisposable {
  51077. /**
  51078. * the id of this component
  51079. */
  51080. id: string;
  51081. /**
  51082. * the type of the component
  51083. */
  51084. type: MotionControllerComponentType;
  51085. private _buttonIndex;
  51086. private _axesIndices;
  51087. private _axes;
  51088. private _changes;
  51089. private _currentValue;
  51090. private _hasChanges;
  51091. private _pressed;
  51092. private _touched;
  51093. /**
  51094. * button component type
  51095. */
  51096. static BUTTON_TYPE: MotionControllerComponentType;
  51097. /**
  51098. * squeeze component type
  51099. */
  51100. static SQUEEZE_TYPE: MotionControllerComponentType;
  51101. /**
  51102. * Thumbstick component type
  51103. */
  51104. static THUMBSTICK_TYPE: MotionControllerComponentType;
  51105. /**
  51106. * Touchpad component type
  51107. */
  51108. static TOUCHPAD_TYPE: MotionControllerComponentType;
  51109. /**
  51110. * trigger component type
  51111. */
  51112. static TRIGGER_TYPE: MotionControllerComponentType;
  51113. /**
  51114. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  51115. * the axes data changes
  51116. */
  51117. onAxisValueChangedObservable: Observable<{
  51118. x: number;
  51119. y: number;
  51120. }>;
  51121. /**
  51122. * Observers registered here will be triggered when the state of a button changes
  51123. * State change is either pressed / touched / value
  51124. */
  51125. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  51126. /**
  51127. * Creates a new component for a motion controller.
  51128. * It is created by the motion controller itself
  51129. *
  51130. * @param id the id of this component
  51131. * @param type the type of the component
  51132. * @param _buttonIndex index in the buttons array of the gamepad
  51133. * @param _axesIndices indices of the values in the axes array of the gamepad
  51134. */
  51135. constructor(
  51136. /**
  51137. * the id of this component
  51138. */
  51139. id: string,
  51140. /**
  51141. * the type of the component
  51142. */
  51143. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  51144. /**
  51145. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  51146. */
  51147. get axes(): IWebXRMotionControllerAxesValue;
  51148. /**
  51149. * Get the changes. Elements will be populated only if they changed with their previous and current value
  51150. */
  51151. get changes(): IWebXRMotionControllerComponentChanges;
  51152. /**
  51153. * Return whether or not the component changed the last frame
  51154. */
  51155. get hasChanges(): boolean;
  51156. /**
  51157. * is the button currently pressed
  51158. */
  51159. get pressed(): boolean;
  51160. /**
  51161. * is the button currently touched
  51162. */
  51163. get touched(): boolean;
  51164. /**
  51165. * Get the current value of this component
  51166. */
  51167. get value(): number;
  51168. /**
  51169. * Dispose this component
  51170. */
  51171. dispose(): void;
  51172. /**
  51173. * Are there axes correlating to this component
  51174. * @return true is axes data is available
  51175. */
  51176. isAxes(): boolean;
  51177. /**
  51178. * Is this component a button (hence - pressable)
  51179. * @returns true if can be pressed
  51180. */
  51181. isButton(): boolean;
  51182. /**
  51183. * update this component using the gamepad object it is in. Called on every frame
  51184. * @param nativeController the native gamepad controller object
  51185. */
  51186. update(nativeController: IMinimalMotionControllerObject): void;
  51187. }
  51188. }
  51189. declare module BABYLON {
  51190. /**
  51191. * Interface used to represent data loading progression
  51192. */
  51193. export interface ISceneLoaderProgressEvent {
  51194. /**
  51195. * Defines if data length to load can be evaluated
  51196. */
  51197. readonly lengthComputable: boolean;
  51198. /**
  51199. * Defines the loaded data length
  51200. */
  51201. readonly loaded: number;
  51202. /**
  51203. * Defines the data length to load
  51204. */
  51205. readonly total: number;
  51206. }
  51207. /**
  51208. * Interface used by SceneLoader plugins to define supported file extensions
  51209. */
  51210. export interface ISceneLoaderPluginExtensions {
  51211. /**
  51212. * Defines the list of supported extensions
  51213. */
  51214. [extension: string]: {
  51215. isBinary: boolean;
  51216. };
  51217. }
  51218. /**
  51219. * Interface used by SceneLoader plugin factory
  51220. */
  51221. export interface ISceneLoaderPluginFactory {
  51222. /**
  51223. * Defines the name of the factory
  51224. */
  51225. name: string;
  51226. /**
  51227. * Function called to create a new plugin
  51228. * @return the new plugin
  51229. */
  51230. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  51231. /**
  51232. * The callback that returns true if the data can be directly loaded.
  51233. * @param data string containing the file data
  51234. * @returns if the data can be loaded directly
  51235. */
  51236. canDirectLoad?(data: string): boolean;
  51237. }
  51238. /**
  51239. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  51240. */
  51241. export interface ISceneLoaderPluginBase {
  51242. /**
  51243. * The friendly name of this plugin.
  51244. */
  51245. name: string;
  51246. /**
  51247. * The file extensions supported by this plugin.
  51248. */
  51249. extensions: string | ISceneLoaderPluginExtensions;
  51250. /**
  51251. * The callback called when loading from a url.
  51252. * @param scene scene loading this url
  51253. * @param url url to load
  51254. * @param onSuccess callback called when the file successfully loads
  51255. * @param onProgress callback called while file is loading (if the server supports this mode)
  51256. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  51257. * @param onError callback called when the file fails to load
  51258. * @returns a file request object
  51259. */
  51260. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51261. /**
  51262. * The callback called when loading from a file object.
  51263. * @param scene scene loading this file
  51264. * @param file defines the file to load
  51265. * @param onSuccess defines the callback to call when data is loaded
  51266. * @param onProgress defines the callback to call during loading process
  51267. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51268. * @param onError defines the callback to call when an error occurs
  51269. * @returns a file request object
  51270. */
  51271. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51272. /**
  51273. * The callback that returns true if the data can be directly loaded.
  51274. * @param data string containing the file data
  51275. * @returns if the data can be loaded directly
  51276. */
  51277. canDirectLoad?(data: string): boolean;
  51278. /**
  51279. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51280. * @param scene scene loading this data
  51281. * @param data string containing the data
  51282. * @returns data to pass to the plugin
  51283. */
  51284. directLoad?(scene: Scene, data: string): any;
  51285. /**
  51286. * The callback that allows custom handling of the root url based on the response url.
  51287. * @param rootUrl the original root url
  51288. * @param responseURL the response url if available
  51289. * @returns the new root url
  51290. */
  51291. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51292. }
  51293. /**
  51294. * Interface used to define a SceneLoader plugin
  51295. */
  51296. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51297. /**
  51298. * Import meshes into a scene.
  51299. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51300. * @param scene The scene to import into
  51301. * @param data The data to import
  51302. * @param rootUrl The root url for scene and resources
  51303. * @param meshes The meshes array to import into
  51304. * @param particleSystems The particle systems array to import into
  51305. * @param skeletons The skeletons array to import into
  51306. * @param onError The callback when import fails
  51307. * @returns True if successful or false otherwise
  51308. */
  51309. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51310. /**
  51311. * Load into a scene.
  51312. * @param scene The scene to load into
  51313. * @param data The data to import
  51314. * @param rootUrl The root url for scene and resources
  51315. * @param onError The callback when import fails
  51316. * @returns True if successful or false otherwise
  51317. */
  51318. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51319. /**
  51320. * Load into an asset container.
  51321. * @param scene The scene to load into
  51322. * @param data The data to import
  51323. * @param rootUrl The root url for scene and resources
  51324. * @param onError The callback when import fails
  51325. * @returns The loaded asset container
  51326. */
  51327. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51328. }
  51329. /**
  51330. * Interface used to define an async SceneLoader plugin
  51331. */
  51332. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51333. /**
  51334. * Import meshes into a scene.
  51335. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51336. * @param scene The scene to import into
  51337. * @param data The data to import
  51338. * @param rootUrl The root url for scene and resources
  51339. * @param onProgress The callback when the load progresses
  51340. * @param fileName Defines the name of the file to load
  51341. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  51342. */
  51343. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  51344. meshes: AbstractMesh[];
  51345. particleSystems: IParticleSystem[];
  51346. skeletons: Skeleton[];
  51347. animationGroups: AnimationGroup[];
  51348. }>;
  51349. /**
  51350. * Load into a scene.
  51351. * @param scene The scene to load into
  51352. * @param data The data to import
  51353. * @param rootUrl The root url for scene and resources
  51354. * @param onProgress The callback when the load progresses
  51355. * @param fileName Defines the name of the file to load
  51356. * @returns Nothing
  51357. */
  51358. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51359. /**
  51360. * Load into an asset container.
  51361. * @param scene The scene to load into
  51362. * @param data The data to import
  51363. * @param rootUrl The root url for scene and resources
  51364. * @param onProgress The callback when the load progresses
  51365. * @param fileName Defines the name of the file to load
  51366. * @returns The loaded asset container
  51367. */
  51368. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51369. }
  51370. /**
  51371. * Mode that determines how to handle old animation groups before loading new ones.
  51372. */
  51373. export enum SceneLoaderAnimationGroupLoadingMode {
  51374. /**
  51375. * Reset all old animations to initial state then dispose them.
  51376. */
  51377. Clean = 0,
  51378. /**
  51379. * Stop all old animations.
  51380. */
  51381. Stop = 1,
  51382. /**
  51383. * Restart old animations from first frame.
  51384. */
  51385. Sync = 2,
  51386. /**
  51387. * Old animations remains untouched.
  51388. */
  51389. NoSync = 3
  51390. }
  51391. /**
  51392. * Defines a plugin registered by the SceneLoader
  51393. */
  51394. interface IRegisteredPlugin {
  51395. /**
  51396. * Defines the plugin to use
  51397. */
  51398. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51399. /**
  51400. * Defines if the plugin supports binary data
  51401. */
  51402. isBinary: boolean;
  51403. }
  51404. /**
  51405. * Class used to load scene from various file formats using registered plugins
  51406. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51407. */
  51408. export class SceneLoader {
  51409. /**
  51410. * No logging while loading
  51411. */
  51412. static readonly NO_LOGGING: number;
  51413. /**
  51414. * Minimal logging while loading
  51415. */
  51416. static readonly MINIMAL_LOGGING: number;
  51417. /**
  51418. * Summary logging while loading
  51419. */
  51420. static readonly SUMMARY_LOGGING: number;
  51421. /**
  51422. * Detailled logging while loading
  51423. */
  51424. static readonly DETAILED_LOGGING: number;
  51425. /**
  51426. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51427. */
  51428. static get ForceFullSceneLoadingForIncremental(): boolean;
  51429. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51430. /**
  51431. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51432. */
  51433. static get ShowLoadingScreen(): boolean;
  51434. static set ShowLoadingScreen(value: boolean);
  51435. /**
  51436. * Defines the current logging level (while loading the scene)
  51437. * @ignorenaming
  51438. */
  51439. static get loggingLevel(): number;
  51440. static set loggingLevel(value: number);
  51441. /**
  51442. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51443. */
  51444. static get CleanBoneMatrixWeights(): boolean;
  51445. static set CleanBoneMatrixWeights(value: boolean);
  51446. /**
  51447. * Event raised when a plugin is used to load a scene
  51448. */
  51449. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51450. private static _registeredPlugins;
  51451. private static _showingLoadingScreen;
  51452. /**
  51453. * Gets the default plugin (used to load Babylon files)
  51454. * @returns the .babylon plugin
  51455. */
  51456. static GetDefaultPlugin(): IRegisteredPlugin;
  51457. private static _GetPluginForExtension;
  51458. private static _GetPluginForDirectLoad;
  51459. private static _GetPluginForFilename;
  51460. private static _GetDirectLoad;
  51461. private static _LoadData;
  51462. private static _GetFileInfo;
  51463. /**
  51464. * Gets a plugin that can load the given extension
  51465. * @param extension defines the extension to load
  51466. * @returns a plugin or null if none works
  51467. */
  51468. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51469. /**
  51470. * Gets a boolean indicating that the given extension can be loaded
  51471. * @param extension defines the extension to load
  51472. * @returns true if the extension is supported
  51473. */
  51474. static IsPluginForExtensionAvailable(extension: string): boolean;
  51475. /**
  51476. * Adds a new plugin to the list of registered plugins
  51477. * @param plugin defines the plugin to add
  51478. */
  51479. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51480. /**
  51481. * Import meshes into a scene
  51482. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51483. * @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)
  51484. * @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)
  51485. * @param scene the instance of BABYLON.Scene to append to
  51486. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51487. * @param onProgress a callback with a progress event for each file being loaded
  51488. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51489. * @param pluginExtension the extension used to determine the plugin
  51490. * @returns The loaded plugin
  51491. */
  51492. 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>;
  51493. /**
  51494. * Import meshes into a scene
  51495. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51496. * @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)
  51497. * @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)
  51498. * @param scene the instance of BABYLON.Scene to append to
  51499. * @param onProgress a callback with a progress event for each file being loaded
  51500. * @param pluginExtension the extension used to determine the plugin
  51501. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51502. */
  51503. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  51504. meshes: AbstractMesh[];
  51505. particleSystems: IParticleSystem[];
  51506. skeletons: Skeleton[];
  51507. animationGroups: AnimationGroup[];
  51508. }>;
  51509. /**
  51510. * Load a scene
  51511. * @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)
  51512. * @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)
  51513. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51514. * @param onSuccess a callback with the scene when import succeeds
  51515. * @param onProgress a callback with a progress event for each file being loaded
  51516. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51517. * @param pluginExtension the extension used to determine the plugin
  51518. * @returns The loaded plugin
  51519. */
  51520. 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>;
  51521. /**
  51522. * Load a scene
  51523. * @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)
  51524. * @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)
  51525. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51526. * @param onProgress a callback with a progress event for each file being loaded
  51527. * @param pluginExtension the extension used to determine the plugin
  51528. * @returns The loaded scene
  51529. */
  51530. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51531. /**
  51532. * Append a scene
  51533. * @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)
  51534. * @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)
  51535. * @param scene is the instance of BABYLON.Scene to append to
  51536. * @param onSuccess a callback with the scene when import succeeds
  51537. * @param onProgress a callback with a progress event for each file being loaded
  51538. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51539. * @param pluginExtension the extension used to determine the plugin
  51540. * @returns The loaded plugin
  51541. */
  51542. 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>;
  51543. /**
  51544. * Append a scene
  51545. * @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)
  51546. * @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)
  51547. * @param scene is the instance of BABYLON.Scene to append to
  51548. * @param onProgress a callback with a progress event for each file being loaded
  51549. * @param pluginExtension the extension used to determine the plugin
  51550. * @returns The given scene
  51551. */
  51552. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51553. /**
  51554. * Load a scene into an asset container
  51555. * @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)
  51556. * @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)
  51557. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51558. * @param onSuccess a callback with the scene when import succeeds
  51559. * @param onProgress a callback with a progress event for each file being loaded
  51560. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51561. * @param pluginExtension the extension used to determine the plugin
  51562. * @returns The loaded plugin
  51563. */
  51564. 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>;
  51565. /**
  51566. * Load a scene into an asset container
  51567. * @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)
  51568. * @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)
  51569. * @param scene is the instance of Scene to append to
  51570. * @param onProgress a callback with a progress event for each file being loaded
  51571. * @param pluginExtension the extension used to determine the plugin
  51572. * @returns The loaded asset container
  51573. */
  51574. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51575. /**
  51576. * Import animations from a file into a scene
  51577. * @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)
  51578. * @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)
  51579. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51580. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51581. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51582. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51583. * @param onSuccess a callback with the scene when import succeeds
  51584. * @param onProgress a callback with a progress event for each file being loaded
  51585. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51586. * @param pluginExtension the extension used to determine the plugin
  51587. */
  51588. 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;
  51589. /**
  51590. * Import animations from a file into a scene
  51591. * @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)
  51592. * @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)
  51593. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51594. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51595. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51596. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51597. * @param onSuccess a callback with the scene when import succeeds
  51598. * @param onProgress a callback with a progress event for each file being loaded
  51599. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51600. * @param pluginExtension the extension used to determine the plugin
  51601. * @returns the updated scene with imported animations
  51602. */
  51603. 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>;
  51604. }
  51605. }
  51606. declare module BABYLON {
  51607. /**
  51608. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51609. */
  51610. export type MotionControllerHandedness = "none" | "left" | "right";
  51611. /**
  51612. * The type of components available in motion controllers.
  51613. * This is not the name of the component.
  51614. */
  51615. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51616. /**
  51617. * The state of a controller component
  51618. */
  51619. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51620. /**
  51621. * The schema of motion controller layout.
  51622. * No object will be initialized using this interface
  51623. * This is used just to define the profile.
  51624. */
  51625. export interface IMotionControllerLayout {
  51626. /**
  51627. * Path to load the assets. Usually relative to the base path
  51628. */
  51629. assetPath: string;
  51630. /**
  51631. * Available components (unsorted)
  51632. */
  51633. components: {
  51634. /**
  51635. * A map of component Ids
  51636. */
  51637. [componentId: string]: {
  51638. /**
  51639. * The type of input the component outputs
  51640. */
  51641. type: MotionControllerComponentType;
  51642. /**
  51643. * The indices of this component in the gamepad object
  51644. */
  51645. gamepadIndices: {
  51646. /**
  51647. * Index of button
  51648. */
  51649. button?: number;
  51650. /**
  51651. * If available, index of x-axis
  51652. */
  51653. xAxis?: number;
  51654. /**
  51655. * If available, index of y-axis
  51656. */
  51657. yAxis?: number;
  51658. };
  51659. /**
  51660. * The mesh's root node name
  51661. */
  51662. rootNodeName: string;
  51663. /**
  51664. * Animation definitions for this model
  51665. */
  51666. visualResponses: {
  51667. [stateKey: string]: {
  51668. /**
  51669. * What property will be animated
  51670. */
  51671. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51672. /**
  51673. * What states influence this visual response
  51674. */
  51675. states: MotionControllerComponentStateType[];
  51676. /**
  51677. * Type of animation - movement or visibility
  51678. */
  51679. valueNodeProperty: "transform" | "visibility";
  51680. /**
  51681. * Base node name to move. Its position will be calculated according to the min and max nodes
  51682. */
  51683. valueNodeName?: string;
  51684. /**
  51685. * Minimum movement node
  51686. */
  51687. minNodeName?: string;
  51688. /**
  51689. * Max movement node
  51690. */
  51691. maxNodeName?: string;
  51692. };
  51693. };
  51694. /**
  51695. * If touch enabled, what is the name of node to display user feedback
  51696. */
  51697. touchPointNodeName?: string;
  51698. };
  51699. };
  51700. /**
  51701. * Is it xr standard mapping or not
  51702. */
  51703. gamepadMapping: "" | "xr-standard";
  51704. /**
  51705. * Base root node of this entire model
  51706. */
  51707. rootNodeName: string;
  51708. /**
  51709. * Defines the main button component id
  51710. */
  51711. selectComponentId: string;
  51712. }
  51713. /**
  51714. * A definition for the layout map in the input profile
  51715. */
  51716. export interface IMotionControllerLayoutMap {
  51717. /**
  51718. * Layouts with handedness type as a key
  51719. */
  51720. [handedness: string]: IMotionControllerLayout;
  51721. }
  51722. /**
  51723. * The XR Input profile schema
  51724. * Profiles can be found here:
  51725. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51726. */
  51727. export interface IMotionControllerProfile {
  51728. /**
  51729. * fallback profiles for this profileId
  51730. */
  51731. fallbackProfileIds: string[];
  51732. /**
  51733. * The layout map, with handedness as key
  51734. */
  51735. layouts: IMotionControllerLayoutMap;
  51736. /**
  51737. * The id of this profile
  51738. * correlates to the profile(s) in the xrInput.profiles array
  51739. */
  51740. profileId: string;
  51741. }
  51742. /**
  51743. * A helper-interface for the 3 meshes needed for controller button animation
  51744. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51745. */
  51746. export interface IMotionControllerButtonMeshMap {
  51747. /**
  51748. * the mesh that defines the pressed value mesh position.
  51749. * This is used to find the max-position of this button
  51750. */
  51751. pressedMesh: AbstractMesh;
  51752. /**
  51753. * the mesh that defines the unpressed value mesh position.
  51754. * This is used to find the min (or initial) position of this button
  51755. */
  51756. unpressedMesh: AbstractMesh;
  51757. /**
  51758. * The mesh that will be changed when value changes
  51759. */
  51760. valueMesh: AbstractMesh;
  51761. }
  51762. /**
  51763. * A helper-interface for the 3 meshes needed for controller axis animation.
  51764. * This will be expanded when touchpad animations are fully supported
  51765. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51766. */
  51767. export interface IMotionControllerMeshMap {
  51768. /**
  51769. * the mesh that defines the maximum value mesh position.
  51770. */
  51771. maxMesh?: AbstractMesh;
  51772. /**
  51773. * the mesh that defines the minimum value mesh position.
  51774. */
  51775. minMesh?: AbstractMesh;
  51776. /**
  51777. * The mesh that will be changed when axis value changes
  51778. */
  51779. valueMesh?: AbstractMesh;
  51780. }
  51781. /**
  51782. * The elements needed for change-detection of the gamepad objects in motion controllers
  51783. */
  51784. export interface IMinimalMotionControllerObject {
  51785. /**
  51786. * Available axes of this controller
  51787. */
  51788. axes: number[];
  51789. /**
  51790. * An array of available buttons
  51791. */
  51792. buttons: Array<{
  51793. /**
  51794. * Value of the button/trigger
  51795. */
  51796. value: number;
  51797. /**
  51798. * If the button/trigger is currently touched
  51799. */
  51800. touched: boolean;
  51801. /**
  51802. * If the button/trigger is currently pressed
  51803. */
  51804. pressed: boolean;
  51805. }>;
  51806. /**
  51807. * EXPERIMENTAL haptic support.
  51808. */
  51809. hapticActuators?: Array<{
  51810. pulse: (value: number, duration: number) => Promise<boolean>;
  51811. }>;
  51812. }
  51813. /**
  51814. * An Abstract Motion controller
  51815. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51816. * Each component has an observable to check for changes in value and state
  51817. */
  51818. export abstract class WebXRAbstractMotionController implements IDisposable {
  51819. protected scene: Scene;
  51820. protected layout: IMotionControllerLayout;
  51821. /**
  51822. * The gamepad object correlating to this controller
  51823. */
  51824. gamepadObject: IMinimalMotionControllerObject;
  51825. /**
  51826. * handedness (left/right/none) of this controller
  51827. */
  51828. handedness: MotionControllerHandedness;
  51829. private _initComponent;
  51830. private _modelReady;
  51831. /**
  51832. * A map of components (WebXRControllerComponent) in this motion controller
  51833. * Components have a ComponentType and can also have both button and axis definitions
  51834. */
  51835. readonly components: {
  51836. [id: string]: WebXRControllerComponent;
  51837. };
  51838. /**
  51839. * Disable the model's animation. Can be set at any time.
  51840. */
  51841. disableAnimation: boolean;
  51842. /**
  51843. * Observers registered here will be triggered when the model of this controller is done loading
  51844. */
  51845. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51846. /**
  51847. * The profile id of this motion controller
  51848. */
  51849. abstract profileId: string;
  51850. /**
  51851. * The root mesh of the model. It is null if the model was not yet initialized
  51852. */
  51853. rootMesh: Nullable<AbstractMesh>;
  51854. /**
  51855. * constructs a new abstract motion controller
  51856. * @param scene the scene to which the model of the controller will be added
  51857. * @param layout The profile layout to load
  51858. * @param gamepadObject The gamepad object correlating to this controller
  51859. * @param handedness handedness (left/right/none) of this controller
  51860. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51861. */
  51862. constructor(scene: Scene, layout: IMotionControllerLayout,
  51863. /**
  51864. * The gamepad object correlating to this controller
  51865. */
  51866. gamepadObject: IMinimalMotionControllerObject,
  51867. /**
  51868. * handedness (left/right/none) of this controller
  51869. */
  51870. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51871. /**
  51872. * Dispose this controller, the model mesh and all its components
  51873. */
  51874. dispose(): void;
  51875. /**
  51876. * Returns all components of specific type
  51877. * @param type the type to search for
  51878. * @return an array of components with this type
  51879. */
  51880. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51881. /**
  51882. * get a component based an its component id as defined in layout.components
  51883. * @param id the id of the component
  51884. * @returns the component correlates to the id or undefined if not found
  51885. */
  51886. getComponent(id: string): WebXRControllerComponent;
  51887. /**
  51888. * Get the list of components available in this motion controller
  51889. * @returns an array of strings correlating to available components
  51890. */
  51891. getComponentIds(): string[];
  51892. /**
  51893. * Get the first component of specific type
  51894. * @param type type of component to find
  51895. * @return a controller component or null if not found
  51896. */
  51897. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51898. /**
  51899. * Get the main (Select) component of this controller as defined in the layout
  51900. * @returns the main component of this controller
  51901. */
  51902. getMainComponent(): WebXRControllerComponent;
  51903. /**
  51904. * Loads the model correlating to this controller
  51905. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51906. * @returns A promise fulfilled with the result of the model loading
  51907. */
  51908. loadModel(): Promise<boolean>;
  51909. /**
  51910. * Update this model using the current XRFrame
  51911. * @param xrFrame the current xr frame to use and update the model
  51912. */
  51913. updateFromXRFrame(xrFrame: XRFrame): void;
  51914. /**
  51915. * Backwards compatibility due to a deeply-integrated typo
  51916. */
  51917. get handness(): XREye;
  51918. /**
  51919. * Pulse (vibrate) this controller
  51920. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51921. * Consecutive calls to this function will cancel the last pulse call
  51922. *
  51923. * @param value the strength of the pulse in 0.0...1.0 range
  51924. * @param duration Duration of the pulse in milliseconds
  51925. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51926. * @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
  51927. */
  51928. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51929. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51930. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51931. /**
  51932. * Moves the axis on the controller mesh based on its current state
  51933. * @param axis the index of the axis
  51934. * @param axisValue the value of the axis which determines the meshes new position
  51935. * @hidden
  51936. */
  51937. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51938. /**
  51939. * Update the model itself with the current frame data
  51940. * @param xrFrame the frame to use for updating the model mesh
  51941. */
  51942. protected updateModel(xrFrame: XRFrame): void;
  51943. /**
  51944. * Get the filename and path for this controller's model
  51945. * @returns a map of filename and path
  51946. */
  51947. protected abstract _getFilenameAndPath(): {
  51948. filename: string;
  51949. path: string;
  51950. };
  51951. /**
  51952. * This function is called before the mesh is loaded. It checks for loading constraints.
  51953. * For example, this function can check if the GLB loader is available
  51954. * If this function returns false, the generic controller will be loaded instead
  51955. * @returns Is the client ready to load the mesh
  51956. */
  51957. protected abstract _getModelLoadingConstraints(): boolean;
  51958. /**
  51959. * This function will be called after the model was successfully loaded and can be used
  51960. * for mesh transformations before it is available for the user
  51961. * @param meshes the loaded meshes
  51962. */
  51963. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51964. /**
  51965. * Set the root mesh for this controller. Important for the WebXR controller class
  51966. * @param meshes the loaded meshes
  51967. */
  51968. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51969. /**
  51970. * A function executed each frame that updates the mesh (if needed)
  51971. * @param xrFrame the current xrFrame
  51972. */
  51973. protected abstract _updateModel(xrFrame: XRFrame): void;
  51974. private _getGenericFilenameAndPath;
  51975. private _getGenericParentMesh;
  51976. }
  51977. }
  51978. declare module BABYLON {
  51979. /**
  51980. * A generic trigger-only motion controller for WebXR
  51981. */
  51982. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51983. /**
  51984. * Static version of the profile id of this controller
  51985. */
  51986. static ProfileId: string;
  51987. profileId: string;
  51988. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51989. protected _getFilenameAndPath(): {
  51990. filename: string;
  51991. path: string;
  51992. };
  51993. protected _getModelLoadingConstraints(): boolean;
  51994. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51995. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51996. protected _updateModel(): void;
  51997. }
  51998. }
  51999. declare module BABYLON {
  52000. /**
  52001. * Class containing static functions to help procedurally build meshes
  52002. */
  52003. export class SphereBuilder {
  52004. /**
  52005. * Creates a sphere mesh
  52006. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52007. * * 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`)
  52008. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52009. * * 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
  52010. * * 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)
  52011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52012. * * 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
  52013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52014. * @param name defines the name of the mesh
  52015. * @param options defines the options used to create the mesh
  52016. * @param scene defines the hosting scene
  52017. * @returns the sphere mesh
  52018. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52019. */
  52020. static CreateSphere(name: string, options: {
  52021. segments?: number;
  52022. diameter?: number;
  52023. diameterX?: number;
  52024. diameterY?: number;
  52025. diameterZ?: number;
  52026. arc?: number;
  52027. slice?: number;
  52028. sideOrientation?: number;
  52029. frontUVs?: Vector4;
  52030. backUVs?: Vector4;
  52031. updatable?: boolean;
  52032. }, scene?: Nullable<Scene>): Mesh;
  52033. }
  52034. }
  52035. declare module BABYLON {
  52036. /**
  52037. * A profiled motion controller has its profile loaded from an online repository.
  52038. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  52039. */
  52040. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  52041. private _repositoryUrl;
  52042. private _buttonMeshMapping;
  52043. private _touchDots;
  52044. /**
  52045. * The profile ID of this controller. Will be populated when the controller initializes.
  52046. */
  52047. profileId: string;
  52048. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  52049. dispose(): void;
  52050. protected _getFilenameAndPath(): {
  52051. filename: string;
  52052. path: string;
  52053. };
  52054. protected _getModelLoadingConstraints(): boolean;
  52055. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  52056. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52057. protected _updateModel(_xrFrame: XRFrame): void;
  52058. }
  52059. }
  52060. declare module BABYLON {
  52061. /**
  52062. * A construction function type to create a new controller based on an xrInput object
  52063. */
  52064. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  52065. /**
  52066. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  52067. *
  52068. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  52069. * it should be replaced with auto-loaded controllers.
  52070. *
  52071. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  52072. */
  52073. export class WebXRMotionControllerManager {
  52074. private static _AvailableControllers;
  52075. private static _Fallbacks;
  52076. private static _ProfileLoadingPromises;
  52077. private static _ProfilesList;
  52078. /**
  52079. * The base URL of the online controller repository. Can be changed at any time.
  52080. */
  52081. static BaseRepositoryUrl: string;
  52082. /**
  52083. * Which repository gets priority - local or online
  52084. */
  52085. static PrioritizeOnlineRepository: boolean;
  52086. /**
  52087. * Use the online repository, or use only locally-defined controllers
  52088. */
  52089. static UseOnlineRepository: boolean;
  52090. /**
  52091. * Clear the cache used for profile loading and reload when requested again
  52092. */
  52093. static ClearProfilesCache(): void;
  52094. /**
  52095. * Register the default fallbacks.
  52096. * This function is called automatically when this file is imported.
  52097. */
  52098. static DefaultFallbacks(): void;
  52099. /**
  52100. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  52101. * @param profileId the profile to which a fallback needs to be found
  52102. * @return an array with corresponding fallback profiles
  52103. */
  52104. static FindFallbackWithProfileId(profileId: string): string[];
  52105. /**
  52106. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  52107. * The order of search:
  52108. *
  52109. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  52110. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  52111. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  52112. * 4) return the generic trigger controller if none were found
  52113. *
  52114. * @param xrInput the xrInput to which a new controller is initialized
  52115. * @param scene the scene to which the model will be added
  52116. * @param forceProfile force a certain profile for this controller
  52117. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  52118. */
  52119. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  52120. /**
  52121. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  52122. *
  52123. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  52124. *
  52125. * @param type the profile type to register
  52126. * @param constructFunction the function to be called when loading this profile
  52127. */
  52128. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  52129. /**
  52130. * Register a fallback to a specific profile.
  52131. * @param profileId the profileId that will receive the fallbacks
  52132. * @param fallbacks A list of fallback profiles
  52133. */
  52134. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  52135. /**
  52136. * Will update the list of profiles available in the repository
  52137. * @return a promise that resolves to a map of profiles available online
  52138. */
  52139. static UpdateProfilesList(): Promise<{
  52140. [profile: string]: string;
  52141. }>;
  52142. private static _LoadProfileFromRepository;
  52143. private static _LoadProfilesFromAvailableControllers;
  52144. }
  52145. }
  52146. declare module BABYLON {
  52147. /**
  52148. * Configuration options for the WebXR controller creation
  52149. */
  52150. export interface IWebXRControllerOptions {
  52151. /**
  52152. * Should the controller mesh be animated when a user interacts with it
  52153. * The pressed buttons / thumbstick and touchpad animations will be disabled
  52154. */
  52155. disableMotionControllerAnimation?: boolean;
  52156. /**
  52157. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  52158. */
  52159. doNotLoadControllerMesh?: boolean;
  52160. /**
  52161. * Force a specific controller type for this controller.
  52162. * This can be used when creating your own profile or when testing different controllers
  52163. */
  52164. forceControllerProfile?: string;
  52165. /**
  52166. * Defines a rendering group ID for meshes that will be loaded.
  52167. * This is for the default controllers only.
  52168. */
  52169. renderingGroupId?: number;
  52170. }
  52171. /**
  52172. * Represents an XR controller
  52173. */
  52174. export class WebXRInputSource {
  52175. private _scene;
  52176. /** The underlying input source for the controller */
  52177. inputSource: XRInputSource;
  52178. private _options;
  52179. private _tmpVector;
  52180. private _uniqueId;
  52181. private _disposed;
  52182. /**
  52183. * 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
  52184. */
  52185. grip?: AbstractMesh;
  52186. /**
  52187. * If available, this is the gamepad object related to this controller.
  52188. * Using this object it is possible to get click events and trackpad changes of the
  52189. * webxr controller that is currently being used.
  52190. */
  52191. motionController?: WebXRAbstractMotionController;
  52192. /**
  52193. * Event that fires when the controller is removed/disposed.
  52194. * The object provided as event data is this controller, after associated assets were disposed.
  52195. * uniqueId is still available.
  52196. */
  52197. onDisposeObservable: Observable<WebXRInputSource>;
  52198. /**
  52199. * Will be triggered when the mesh associated with the motion controller is done loading.
  52200. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  52201. * A shortened version of controller -> motion controller -> on mesh loaded.
  52202. */
  52203. onMeshLoadedObservable: Observable<AbstractMesh>;
  52204. /**
  52205. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  52206. */
  52207. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  52208. /**
  52209. * Pointer which can be used to select objects or attach a visible laser to
  52210. */
  52211. pointer: AbstractMesh;
  52212. /**
  52213. * Creates the input source object
  52214. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  52215. * @param _scene the scene which the controller should be associated to
  52216. * @param inputSource the underlying input source for the controller
  52217. * @param _options options for this controller creation
  52218. */
  52219. constructor(_scene: Scene,
  52220. /** The underlying input source for the controller */
  52221. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  52222. /**
  52223. * Get this controllers unique id
  52224. */
  52225. get uniqueId(): string;
  52226. /**
  52227. * Disposes of the object
  52228. */
  52229. dispose(): void;
  52230. /**
  52231. * Gets a world space ray coming from the pointer or grip
  52232. * @param result the resulting ray
  52233. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  52234. */
  52235. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  52236. /**
  52237. * Updates the controller pose based on the given XRFrame
  52238. * @param xrFrame xr frame to update the pose with
  52239. * @param referenceSpace reference space to use
  52240. */
  52241. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  52242. }
  52243. }
  52244. declare module BABYLON {
  52245. /**
  52246. * The schema for initialization options of the XR Input class
  52247. */
  52248. export interface IWebXRInputOptions {
  52249. /**
  52250. * If set to true no model will be automatically loaded
  52251. */
  52252. doNotLoadControllerMeshes?: boolean;
  52253. /**
  52254. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  52255. * If not found, the xr input profile data will be used.
  52256. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  52257. */
  52258. forceInputProfile?: string;
  52259. /**
  52260. * Do not send a request to the controller repository to load the profile.
  52261. *
  52262. * Instead, use the controllers available in babylon itself.
  52263. */
  52264. disableOnlineControllerRepository?: boolean;
  52265. /**
  52266. * A custom URL for the controllers repository
  52267. */
  52268. customControllersRepositoryURL?: string;
  52269. /**
  52270. * Should the controller model's components not move according to the user input
  52271. */
  52272. disableControllerAnimation?: boolean;
  52273. /**
  52274. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52275. */
  52276. controllerOptions?: IWebXRControllerOptions;
  52277. }
  52278. /**
  52279. * XR input used to track XR inputs such as controllers/rays
  52280. */
  52281. export class WebXRInput implements IDisposable {
  52282. /**
  52283. * the xr session manager for this session
  52284. */
  52285. xrSessionManager: WebXRSessionManager;
  52286. /**
  52287. * the WebXR camera for this session. Mainly used for teleportation
  52288. */
  52289. xrCamera: WebXRCamera;
  52290. private readonly options;
  52291. /**
  52292. * XR controllers being tracked
  52293. */
  52294. controllers: Array<WebXRInputSource>;
  52295. private _frameObserver;
  52296. private _sessionEndedObserver;
  52297. private _sessionInitObserver;
  52298. /**
  52299. * Event when a controller has been connected/added
  52300. */
  52301. onControllerAddedObservable: Observable<WebXRInputSource>;
  52302. /**
  52303. * Event when a controller has been removed/disconnected
  52304. */
  52305. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52306. /**
  52307. * Initializes the WebXRInput
  52308. * @param xrSessionManager the xr session manager for this session
  52309. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52310. * @param options = initialization options for this xr input
  52311. */
  52312. constructor(
  52313. /**
  52314. * the xr session manager for this session
  52315. */
  52316. xrSessionManager: WebXRSessionManager,
  52317. /**
  52318. * the WebXR camera for this session. Mainly used for teleportation
  52319. */
  52320. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52321. private _onInputSourcesChange;
  52322. private _addAndRemoveControllers;
  52323. /**
  52324. * Disposes of the object
  52325. */
  52326. dispose(): void;
  52327. }
  52328. }
  52329. declare module BABYLON {
  52330. /**
  52331. * This is the base class for all WebXR features.
  52332. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52333. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52334. */
  52335. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52336. protected _xrSessionManager: WebXRSessionManager;
  52337. private _attached;
  52338. private _removeOnDetach;
  52339. /**
  52340. * Is this feature disposed?
  52341. */
  52342. isDisposed: boolean;
  52343. /**
  52344. * Should auto-attach be disabled?
  52345. */
  52346. disableAutoAttach: boolean;
  52347. /**
  52348. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52349. */
  52350. xrNativeFeatureName: string;
  52351. /**
  52352. * Construct a new (abstract) WebXR feature
  52353. * @param _xrSessionManager the xr session manager for this feature
  52354. */
  52355. constructor(_xrSessionManager: WebXRSessionManager);
  52356. /**
  52357. * Is this feature attached
  52358. */
  52359. get attached(): boolean;
  52360. /**
  52361. * attach this feature
  52362. *
  52363. * @param force should attachment be forced (even when already attached)
  52364. * @returns true if successful, false is failed or already attached
  52365. */
  52366. attach(force?: boolean): boolean;
  52367. /**
  52368. * detach this feature.
  52369. *
  52370. * @returns true if successful, false if failed or already detached
  52371. */
  52372. detach(): boolean;
  52373. /**
  52374. * Dispose this feature and all of the resources attached
  52375. */
  52376. dispose(): void;
  52377. /**
  52378. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52379. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52380. *
  52381. * @returns whether or not the feature is compatible in this environment
  52382. */
  52383. isCompatible(): boolean;
  52384. /**
  52385. * This is used to register callbacks that will automatically be removed when detach is called.
  52386. * @param observable the observable to which the observer will be attached
  52387. * @param callback the callback to register
  52388. */
  52389. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52390. /**
  52391. * Code in this function will be executed on each xrFrame received from the browser.
  52392. * This function will not execute after the feature is detached.
  52393. * @param _xrFrame the current frame
  52394. */
  52395. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52396. }
  52397. }
  52398. declare module BABYLON {
  52399. /**
  52400. * Renders a layer on top of an existing scene
  52401. */
  52402. export class UtilityLayerRenderer implements IDisposable {
  52403. /** the original scene that will be rendered on top of */
  52404. originalScene: Scene;
  52405. private _pointerCaptures;
  52406. private _lastPointerEvents;
  52407. private static _DefaultUtilityLayer;
  52408. private static _DefaultKeepDepthUtilityLayer;
  52409. private _sharedGizmoLight;
  52410. private _renderCamera;
  52411. /**
  52412. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52413. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52414. * @returns the camera that is used when rendering the utility layer
  52415. */
  52416. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52417. /**
  52418. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52419. * @param cam the camera that should be used when rendering the utility layer
  52420. */
  52421. setRenderCamera(cam: Nullable<Camera>): void;
  52422. /**
  52423. * @hidden
  52424. * Light which used by gizmos to get light shading
  52425. */
  52426. _getSharedGizmoLight(): HemisphericLight;
  52427. /**
  52428. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52429. */
  52430. pickUtilitySceneFirst: boolean;
  52431. /**
  52432. * 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)
  52433. */
  52434. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52435. /**
  52436. * 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)
  52437. */
  52438. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52439. /**
  52440. * The scene that is rendered on top of the original scene
  52441. */
  52442. utilityLayerScene: Scene;
  52443. /**
  52444. * If the utility layer should automatically be rendered on top of existing scene
  52445. */
  52446. shouldRender: boolean;
  52447. /**
  52448. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52449. */
  52450. onlyCheckPointerDownEvents: boolean;
  52451. /**
  52452. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52453. */
  52454. processAllEvents: boolean;
  52455. /**
  52456. * Observable raised when the pointer move from the utility layer scene to the main scene
  52457. */
  52458. onPointerOutObservable: Observable<number>;
  52459. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52460. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52461. private _afterRenderObserver;
  52462. private _sceneDisposeObserver;
  52463. private _originalPointerObserver;
  52464. /**
  52465. * Instantiates a UtilityLayerRenderer
  52466. * @param originalScene the original scene that will be rendered on top of
  52467. * @param handleEvents boolean indicating if the utility layer should handle events
  52468. */
  52469. constructor(
  52470. /** the original scene that will be rendered on top of */
  52471. originalScene: Scene, handleEvents?: boolean);
  52472. private _notifyObservers;
  52473. /**
  52474. * Renders the utility layers scene on top of the original scene
  52475. */
  52476. render(): void;
  52477. /**
  52478. * Disposes of the renderer
  52479. */
  52480. dispose(): void;
  52481. private _updateCamera;
  52482. }
  52483. }
  52484. declare module BABYLON {
  52485. /**
  52486. * Options interface for the pointer selection module
  52487. */
  52488. export interface IWebXRControllerPointerSelectionOptions {
  52489. /**
  52490. * if provided, this scene will be used to render meshes.
  52491. */
  52492. customUtilityLayerScene?: Scene;
  52493. /**
  52494. * 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)
  52495. * If not disabled, the last picked point will be used to execute a pointer up event
  52496. * If disabled, pointer up event will be triggered right after the pointer down event.
  52497. * Used in screen and gaze target ray mode only
  52498. */
  52499. disablePointerUpOnTouchOut: boolean;
  52500. /**
  52501. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52502. */
  52503. forceGazeMode: boolean;
  52504. /**
  52505. * 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
  52506. * to start a new countdown to the pointer down event.
  52507. * Defaults to 1.
  52508. */
  52509. gazeModePointerMovedFactor?: number;
  52510. /**
  52511. * Different button type to use instead of the main component
  52512. */
  52513. overrideButtonId?: string;
  52514. /**
  52515. * use this rendering group id for the meshes (optional)
  52516. */
  52517. renderingGroupId?: number;
  52518. /**
  52519. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52520. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52521. * 3000 means 3 seconds between pointing at something and selecting it
  52522. */
  52523. timeToSelect?: number;
  52524. /**
  52525. * Should meshes created here be added to a utility layer or the main scene
  52526. */
  52527. useUtilityLayer?: boolean;
  52528. /**
  52529. * Optional WebXR camera to be used for gaze selection
  52530. */
  52531. gazeCamera?: WebXRCamera;
  52532. /**
  52533. * the xr input to use with this pointer selection
  52534. */
  52535. xrInput: WebXRInput;
  52536. /**
  52537. * Should the scene pointerX and pointerY update be disabled
  52538. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52539. * Disable in VR, if not needed.
  52540. * The first rig camera (left eye) will be used to calculate the projection
  52541. */
  52542. disableScenePointerVectorUpdate: boolean;
  52543. /**
  52544. * Enable pointer selection on all controllers instead of switching between them
  52545. */
  52546. enablePointerSelectionOnAllControllers?: boolean;
  52547. /**
  52548. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52549. * If switch is enabled, it will still allow the user to switch between the different controllers
  52550. */
  52551. preferredHandedness?: XRHandedness;
  52552. /**
  52553. * Disable switching the pointer selection from one controller to the other.
  52554. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  52555. */
  52556. disableSwitchOnClick?: boolean;
  52557. /**
  52558. * The maximum distance of the pointer selection feature. Defaults to 100.
  52559. */
  52560. maxPointerDistance?: number;
  52561. }
  52562. /**
  52563. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52564. */
  52565. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52566. private readonly _options;
  52567. private static _idCounter;
  52568. private _attachController;
  52569. private _controllers;
  52570. private _scene;
  52571. private _tmpVectorForPickCompare;
  52572. private _attachedController;
  52573. /**
  52574. * The module's name
  52575. */
  52576. static readonly Name: string;
  52577. /**
  52578. * The (Babylon) version of this module.
  52579. * This is an integer representing the implementation version.
  52580. * This number does not correspond to the WebXR specs version
  52581. */
  52582. static readonly Version: number;
  52583. /**
  52584. * Disable lighting on the laser pointer (so it will always be visible)
  52585. */
  52586. disablePointerLighting: boolean;
  52587. /**
  52588. * Disable lighting on the selection mesh (so it will always be visible)
  52589. */
  52590. disableSelectionMeshLighting: boolean;
  52591. /**
  52592. * Should the laser pointer be displayed
  52593. */
  52594. displayLaserPointer: boolean;
  52595. /**
  52596. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52597. */
  52598. displaySelectionMesh: boolean;
  52599. /**
  52600. * This color will be set to the laser pointer when selection is triggered
  52601. */
  52602. laserPointerPickedColor: Color3;
  52603. /**
  52604. * Default color of the laser pointer
  52605. */
  52606. laserPointerDefaultColor: Color3;
  52607. /**
  52608. * default color of the selection ring
  52609. */
  52610. selectionMeshDefaultColor: Color3;
  52611. /**
  52612. * This color will be applied to the selection ring when selection is triggered
  52613. */
  52614. selectionMeshPickedColor: Color3;
  52615. /**
  52616. * Optional filter to be used for ray selection. This predicate shares behavior with
  52617. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52618. */
  52619. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52620. /**
  52621. * constructs a new background remover module
  52622. * @param _xrSessionManager the session manager for this module
  52623. * @param _options read-only options to be used in this module
  52624. */
  52625. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52626. /**
  52627. * attach this feature
  52628. * Will usually be called by the features manager
  52629. *
  52630. * @returns true if successful.
  52631. */
  52632. attach(): boolean;
  52633. /**
  52634. * detach this feature.
  52635. * Will usually be called by the features manager
  52636. *
  52637. * @returns true if successful.
  52638. */
  52639. detach(): boolean;
  52640. /**
  52641. * Will get the mesh under a specific pointer.
  52642. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52643. * @param controllerId the controllerId to check
  52644. * @returns The mesh under pointer or null if no mesh is under the pointer
  52645. */
  52646. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52647. /**
  52648. * Get the xr controller that correlates to the pointer id in the pointer event
  52649. *
  52650. * @param id the pointer id to search for
  52651. * @returns the controller that correlates to this id or null if not found
  52652. */
  52653. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52654. private _identityMatrix;
  52655. private _screenCoordinatesRef;
  52656. private _viewportRef;
  52657. protected _onXRFrame(_xrFrame: XRFrame): void;
  52658. private _attachGazeMode;
  52659. private _attachScreenRayMode;
  52660. private _attachTrackedPointerRayMode;
  52661. private _convertNormalToDirectionOfRay;
  52662. private _detachController;
  52663. private _generateNewMeshPair;
  52664. private _pickingMoved;
  52665. private _updatePointerDistance;
  52666. /** @hidden */
  52667. get lasterPointerDefaultColor(): Color3;
  52668. }
  52669. }
  52670. declare module BABYLON {
  52671. /**
  52672. * Button which can be used to enter a different mode of XR
  52673. */
  52674. export class WebXREnterExitUIButton {
  52675. /** button element */
  52676. element: HTMLElement;
  52677. /** XR initialization options for the button */
  52678. sessionMode: XRSessionMode;
  52679. /** Reference space type */
  52680. referenceSpaceType: XRReferenceSpaceType;
  52681. /**
  52682. * Creates a WebXREnterExitUIButton
  52683. * @param element button element
  52684. * @param sessionMode XR initialization session mode
  52685. * @param referenceSpaceType the type of reference space to be used
  52686. */
  52687. constructor(
  52688. /** button element */
  52689. element: HTMLElement,
  52690. /** XR initialization options for the button */
  52691. sessionMode: XRSessionMode,
  52692. /** Reference space type */
  52693. referenceSpaceType: XRReferenceSpaceType);
  52694. /**
  52695. * Extendable function which can be used to update the button's visuals when the state changes
  52696. * @param activeButton the current active button in the UI
  52697. */
  52698. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52699. }
  52700. /**
  52701. * Options to create the webXR UI
  52702. */
  52703. export class WebXREnterExitUIOptions {
  52704. /**
  52705. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52706. */
  52707. customButtons?: Array<WebXREnterExitUIButton>;
  52708. /**
  52709. * A reference space type to use when creating the default button.
  52710. * Default is local-floor
  52711. */
  52712. referenceSpaceType?: XRReferenceSpaceType;
  52713. /**
  52714. * Context to enter xr with
  52715. */
  52716. renderTarget?: Nullable<WebXRRenderTarget>;
  52717. /**
  52718. * A session mode to use when creating the default button.
  52719. * Default is immersive-vr
  52720. */
  52721. sessionMode?: XRSessionMode;
  52722. /**
  52723. * A list of optional features to init the session with
  52724. */
  52725. optionalFeatures?: string[];
  52726. /**
  52727. * A list of optional features to init the session with
  52728. */
  52729. requiredFeatures?: string[];
  52730. /**
  52731. * If defined, this function will be executed if the UI encounters an error when entering XR
  52732. */
  52733. onError?: (error: any) => void;
  52734. }
  52735. /**
  52736. * UI to allow the user to enter/exit XR mode
  52737. */
  52738. export class WebXREnterExitUI implements IDisposable {
  52739. private scene;
  52740. /** version of the options passed to this UI */
  52741. options: WebXREnterExitUIOptions;
  52742. private _activeButton;
  52743. private _buttons;
  52744. /**
  52745. * The HTML Div Element to which buttons are added.
  52746. */
  52747. readonly overlay: HTMLDivElement;
  52748. /**
  52749. * Fired every time the active button is changed.
  52750. *
  52751. * When xr is entered via a button that launches xr that button will be the callback parameter
  52752. *
  52753. * When exiting xr the callback parameter will be null)
  52754. */
  52755. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52756. /**
  52757. *
  52758. * @param scene babylon scene object to use
  52759. * @param options (read-only) version of the options passed to this UI
  52760. */
  52761. private constructor();
  52762. /**
  52763. * Creates UI to allow the user to enter/exit XR mode
  52764. * @param scene the scene to add the ui to
  52765. * @param helper the xr experience helper to enter/exit xr with
  52766. * @param options options to configure the UI
  52767. * @returns the created ui
  52768. */
  52769. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52770. /**
  52771. * Disposes of the XR UI component
  52772. */
  52773. dispose(): void;
  52774. private _updateButtons;
  52775. }
  52776. }
  52777. declare module BABYLON {
  52778. /**
  52779. * Class containing static functions to help procedurally build meshes
  52780. */
  52781. export class LinesBuilder {
  52782. /**
  52783. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52784. * * 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
  52785. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52786. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52787. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52788. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52789. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52790. * * 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
  52791. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52793. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52794. * @param name defines the name of the new line system
  52795. * @param options defines the options used to create the line system
  52796. * @param scene defines the hosting scene
  52797. * @returns a new line system mesh
  52798. */
  52799. static CreateLineSystem(name: string, options: {
  52800. lines: Vector3[][];
  52801. updatable?: boolean;
  52802. instance?: Nullable<LinesMesh>;
  52803. colors?: Nullable<Color4[][]>;
  52804. useVertexAlpha?: boolean;
  52805. }, scene: Nullable<Scene>): LinesMesh;
  52806. /**
  52807. * Creates a line mesh
  52808. * 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
  52809. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52810. * * The parameter `points` is an array successive Vector3
  52811. * * 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
  52812. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52813. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52814. * * When updating an instance, remember that only point positions can change, not the number of points
  52815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52817. * @param name defines the name of the new line system
  52818. * @param options defines the options used to create the line system
  52819. * @param scene defines the hosting scene
  52820. * @returns a new line mesh
  52821. */
  52822. static CreateLines(name: string, options: {
  52823. points: Vector3[];
  52824. updatable?: boolean;
  52825. instance?: Nullable<LinesMesh>;
  52826. colors?: Color4[];
  52827. useVertexAlpha?: boolean;
  52828. }, scene?: Nullable<Scene>): LinesMesh;
  52829. /**
  52830. * Creates a dashed line mesh
  52831. * * 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
  52832. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52833. * * The parameter `points` is an array successive Vector3
  52834. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52835. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52836. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52837. * * 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
  52838. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52839. * * When updating an instance, remember that only point positions can change, not the number of points
  52840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52841. * @param name defines the name of the mesh
  52842. * @param options defines the options used to create the mesh
  52843. * @param scene defines the hosting scene
  52844. * @returns the dashed line mesh
  52845. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52846. */
  52847. static CreateDashedLines(name: string, options: {
  52848. points: Vector3[];
  52849. dashSize?: number;
  52850. gapSize?: number;
  52851. dashNb?: number;
  52852. updatable?: boolean;
  52853. instance?: LinesMesh;
  52854. useVertexAlpha?: boolean;
  52855. }, scene?: Nullable<Scene>): LinesMesh;
  52856. }
  52857. }
  52858. declare module BABYLON {
  52859. /**
  52860. * Construction options for a timer
  52861. */
  52862. export interface ITimerOptions<T> {
  52863. /**
  52864. * Time-to-end
  52865. */
  52866. timeout: number;
  52867. /**
  52868. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52869. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52870. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52871. */
  52872. contextObservable: Observable<T>;
  52873. /**
  52874. * Optional parameters when adding an observer to the observable
  52875. */
  52876. observableParameters?: {
  52877. mask?: number;
  52878. insertFirst?: boolean;
  52879. scope?: any;
  52880. };
  52881. /**
  52882. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52883. */
  52884. breakCondition?: (data?: ITimerData<T>) => boolean;
  52885. /**
  52886. * Will be triggered when the time condition has met
  52887. */
  52888. onEnded?: (data: ITimerData<any>) => void;
  52889. /**
  52890. * Will be triggered when the break condition has met (prematurely ended)
  52891. */
  52892. onAborted?: (data: ITimerData<any>) => void;
  52893. /**
  52894. * Optional function to execute on each tick (or count)
  52895. */
  52896. onTick?: (data: ITimerData<any>) => void;
  52897. }
  52898. /**
  52899. * An interface defining the data sent by the timer
  52900. */
  52901. export interface ITimerData<T> {
  52902. /**
  52903. * When did it start
  52904. */
  52905. startTime: number;
  52906. /**
  52907. * Time now
  52908. */
  52909. currentTime: number;
  52910. /**
  52911. * Time passed since started
  52912. */
  52913. deltaTime: number;
  52914. /**
  52915. * How much is completed, in [0.0...1.0].
  52916. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52917. */
  52918. completeRate: number;
  52919. /**
  52920. * What the registered observable sent in the last count
  52921. */
  52922. payload: T;
  52923. }
  52924. /**
  52925. * The current state of the timer
  52926. */
  52927. export enum TimerState {
  52928. /**
  52929. * Timer initialized, not yet started
  52930. */
  52931. INIT = 0,
  52932. /**
  52933. * Timer started and counting
  52934. */
  52935. STARTED = 1,
  52936. /**
  52937. * Timer ended (whether aborted or time reached)
  52938. */
  52939. ENDED = 2
  52940. }
  52941. /**
  52942. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52943. *
  52944. * @param options options with which to initialize this timer
  52945. */
  52946. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52947. /**
  52948. * An advanced implementation of a timer class
  52949. */
  52950. export class AdvancedTimer<T = any> implements IDisposable {
  52951. /**
  52952. * Will notify each time the timer calculates the remaining time
  52953. */
  52954. onEachCountObservable: Observable<ITimerData<T>>;
  52955. /**
  52956. * Will trigger when the timer was aborted due to the break condition
  52957. */
  52958. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52959. /**
  52960. * Will trigger when the timer ended successfully
  52961. */
  52962. onTimerEndedObservable: Observable<ITimerData<T>>;
  52963. /**
  52964. * Will trigger when the timer state has changed
  52965. */
  52966. onStateChangedObservable: Observable<TimerState>;
  52967. private _observer;
  52968. private _contextObservable;
  52969. private _observableParameters;
  52970. private _startTime;
  52971. private _timer;
  52972. private _state;
  52973. private _breakCondition;
  52974. private _timeToEnd;
  52975. private _breakOnNextTick;
  52976. /**
  52977. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52978. * @param options construction options for this advanced timer
  52979. */
  52980. constructor(options: ITimerOptions<T>);
  52981. /**
  52982. * set a breaking condition for this timer. Default is to never break during count
  52983. * @param predicate the new break condition. Returns true to break, false otherwise
  52984. */
  52985. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52986. /**
  52987. * Reset ALL associated observables in this advanced timer
  52988. */
  52989. clearObservables(): void;
  52990. /**
  52991. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52992. *
  52993. * @param timeToEnd how much time to measure until timer ended
  52994. */
  52995. start(timeToEnd?: number): void;
  52996. /**
  52997. * Will force a stop on the next tick.
  52998. */
  52999. stop(): void;
  53000. /**
  53001. * Dispose this timer, clearing all resources
  53002. */
  53003. dispose(): void;
  53004. private _setState;
  53005. private _tick;
  53006. private _stop;
  53007. }
  53008. }
  53009. declare module BABYLON {
  53010. /**
  53011. * The options container for the teleportation module
  53012. */
  53013. export interface IWebXRTeleportationOptions {
  53014. /**
  53015. * if provided, this scene will be used to render meshes.
  53016. */
  53017. customUtilityLayerScene?: Scene;
  53018. /**
  53019. * Values to configure the default target mesh
  53020. */
  53021. defaultTargetMeshOptions?: {
  53022. /**
  53023. * Fill color of the teleportation area
  53024. */
  53025. teleportationFillColor?: string;
  53026. /**
  53027. * Border color for the teleportation area
  53028. */
  53029. teleportationBorderColor?: string;
  53030. /**
  53031. * Disable the mesh's animation sequence
  53032. */
  53033. disableAnimation?: boolean;
  53034. /**
  53035. * Disable lighting on the material or the ring and arrow
  53036. */
  53037. disableLighting?: boolean;
  53038. /**
  53039. * Override the default material of the torus and arrow
  53040. */
  53041. torusArrowMaterial?: Material;
  53042. };
  53043. /**
  53044. * A list of meshes to use as floor meshes.
  53045. * Meshes can be added and removed after initializing the feature using the
  53046. * addFloorMesh and removeFloorMesh functions
  53047. * If empty, rotation will still work
  53048. */
  53049. floorMeshes?: AbstractMesh[];
  53050. /**
  53051. * use this rendering group id for the meshes (optional)
  53052. */
  53053. renderingGroupId?: number;
  53054. /**
  53055. * Should teleportation move only to snap points
  53056. */
  53057. snapPointsOnly?: boolean;
  53058. /**
  53059. * An array of points to which the teleportation will snap to.
  53060. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  53061. */
  53062. snapPositions?: Vector3[];
  53063. /**
  53064. * How close should the teleportation ray be in order to snap to position.
  53065. * Default to 0.8 units (meters)
  53066. */
  53067. snapToPositionRadius?: number;
  53068. /**
  53069. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  53070. * If you want to support rotation, make sure your mesh has a direction indicator.
  53071. *
  53072. * When left untouched, the default mesh will be initialized.
  53073. */
  53074. teleportationTargetMesh?: AbstractMesh;
  53075. /**
  53076. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  53077. */
  53078. timeToTeleport?: number;
  53079. /**
  53080. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  53081. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  53082. */
  53083. useMainComponentOnly?: boolean;
  53084. /**
  53085. * Should meshes created here be added to a utility layer or the main scene
  53086. */
  53087. useUtilityLayer?: boolean;
  53088. /**
  53089. * Babylon XR Input class for controller
  53090. */
  53091. xrInput: WebXRInput;
  53092. /**
  53093. * Meshes that the teleportation ray cannot go through
  53094. */
  53095. pickBlockerMeshes?: AbstractMesh[];
  53096. }
  53097. /**
  53098. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  53099. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  53100. * the input of the attached controllers.
  53101. */
  53102. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  53103. private _options;
  53104. private _controllers;
  53105. private _currentTeleportationControllerId;
  53106. private _floorMeshes;
  53107. private _quadraticBezierCurve;
  53108. private _selectionFeature;
  53109. private _snapToPositions;
  53110. private _snappedToPoint;
  53111. private _teleportationRingMaterial?;
  53112. private _tmpRay;
  53113. private _tmpVector;
  53114. private _tmpQuaternion;
  53115. /**
  53116. * The module's name
  53117. */
  53118. static readonly Name: string;
  53119. /**
  53120. * The (Babylon) version of this module.
  53121. * This is an integer representing the implementation version.
  53122. * This number does not correspond to the webxr specs version
  53123. */
  53124. static readonly Version: number;
  53125. /**
  53126. * Is movement backwards enabled
  53127. */
  53128. backwardsMovementEnabled: boolean;
  53129. /**
  53130. * Distance to travel when moving backwards
  53131. */
  53132. backwardsTeleportationDistance: number;
  53133. /**
  53134. * The distance from the user to the inspection point in the direction of the controller
  53135. * A higher number will allow the user to move further
  53136. * defaults to 5 (meters, in xr units)
  53137. */
  53138. parabolicCheckRadius: number;
  53139. /**
  53140. * Should the module support parabolic ray on top of direct ray
  53141. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  53142. * Very helpful when moving between floors / different heights
  53143. */
  53144. parabolicRayEnabled: boolean;
  53145. /**
  53146. * How much rotation should be applied when rotating right and left
  53147. */
  53148. rotationAngle: number;
  53149. /**
  53150. * Is rotation enabled when moving forward?
  53151. * Disabling this feature will prevent the user from deciding the direction when teleporting
  53152. */
  53153. rotationEnabled: boolean;
  53154. /**
  53155. * constructs a new anchor system
  53156. * @param _xrSessionManager an instance of WebXRSessionManager
  53157. * @param _options configuration object for this feature
  53158. */
  53159. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  53160. /**
  53161. * Get the snapPointsOnly flag
  53162. */
  53163. get snapPointsOnly(): boolean;
  53164. /**
  53165. * Sets the snapPointsOnly flag
  53166. * @param snapToPoints should teleportation be exclusively to snap points
  53167. */
  53168. set snapPointsOnly(snapToPoints: boolean);
  53169. /**
  53170. * Add a new mesh to the floor meshes array
  53171. * @param mesh the mesh to use as floor mesh
  53172. */
  53173. addFloorMesh(mesh: AbstractMesh): void;
  53174. /**
  53175. * Add a new snap-to point to fix teleportation to this position
  53176. * @param newSnapPoint The new Snap-To point
  53177. */
  53178. addSnapPoint(newSnapPoint: Vector3): void;
  53179. attach(): boolean;
  53180. detach(): boolean;
  53181. dispose(): void;
  53182. /**
  53183. * Remove a mesh from the floor meshes array
  53184. * @param mesh the mesh to remove
  53185. */
  53186. removeFloorMesh(mesh: AbstractMesh): void;
  53187. /**
  53188. * Remove a mesh from the floor meshes array using its name
  53189. * @param name the mesh name to remove
  53190. */
  53191. removeFloorMeshByName(name: string): void;
  53192. /**
  53193. * 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
  53194. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  53195. * @returns was the point found and removed or not
  53196. */
  53197. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  53198. /**
  53199. * This function sets a selection feature that will be disabled when
  53200. * the forward ray is shown and will be reattached when hidden.
  53201. * This is used to remove the selection rays when moving.
  53202. * @param selectionFeature the feature to disable when forward movement is enabled
  53203. */
  53204. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  53205. protected _onXRFrame(_xrFrame: XRFrame): void;
  53206. private _attachController;
  53207. private _createDefaultTargetMesh;
  53208. private _detachController;
  53209. private _findClosestSnapPointWithRadius;
  53210. private _setTargetMeshPosition;
  53211. private _setTargetMeshVisibility;
  53212. private _showParabolicPath;
  53213. private _teleportForward;
  53214. }
  53215. }
  53216. declare module BABYLON {
  53217. /**
  53218. * Options for the default xr helper
  53219. */
  53220. export class WebXRDefaultExperienceOptions {
  53221. /**
  53222. * Enable or disable default UI to enter XR
  53223. */
  53224. disableDefaultUI?: boolean;
  53225. /**
  53226. * Should teleportation not initialize. defaults to false.
  53227. */
  53228. disableTeleportation?: boolean;
  53229. /**
  53230. * Floor meshes that will be used for teleport
  53231. */
  53232. floorMeshes?: Array<AbstractMesh>;
  53233. /**
  53234. * If set to true, the first frame will not be used to reset position
  53235. * The first frame is mainly used when copying transformation from the old camera
  53236. * Mainly used in AR
  53237. */
  53238. ignoreNativeCameraTransformation?: boolean;
  53239. /**
  53240. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  53241. */
  53242. inputOptions?: IWebXRInputOptions;
  53243. /**
  53244. * optional configuration for the output canvas
  53245. */
  53246. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  53247. /**
  53248. * optional UI options. This can be used among other to change session mode and reference space type
  53249. */
  53250. uiOptions?: WebXREnterExitUIOptions;
  53251. /**
  53252. * When loading teleportation and pointer select, use stable versions instead of latest.
  53253. */
  53254. useStablePlugins?: boolean;
  53255. /**
  53256. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  53257. */
  53258. renderingGroupId?: number;
  53259. /**
  53260. * A list of optional features to init the session with
  53261. * If set to true, all features we support will be added
  53262. */
  53263. optionalFeatures?: boolean | string[];
  53264. }
  53265. /**
  53266. * Default experience which provides a similar setup to the previous webVRExperience
  53267. */
  53268. export class WebXRDefaultExperience {
  53269. /**
  53270. * Base experience
  53271. */
  53272. baseExperience: WebXRExperienceHelper;
  53273. /**
  53274. * Enables ui for entering/exiting xr
  53275. */
  53276. enterExitUI: WebXREnterExitUI;
  53277. /**
  53278. * Input experience extension
  53279. */
  53280. input: WebXRInput;
  53281. /**
  53282. * Enables laser pointer and selection
  53283. */
  53284. pointerSelection: WebXRControllerPointerSelection;
  53285. /**
  53286. * Default target xr should render to
  53287. */
  53288. renderTarget: WebXRRenderTarget;
  53289. /**
  53290. * Enables teleportation
  53291. */
  53292. teleportation: WebXRMotionControllerTeleportation;
  53293. private constructor();
  53294. /**
  53295. * Creates the default xr experience
  53296. * @param scene scene
  53297. * @param options options for basic configuration
  53298. * @returns resulting WebXRDefaultExperience
  53299. */
  53300. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53301. /**
  53302. * DIsposes of the experience helper
  53303. */
  53304. dispose(): void;
  53305. }
  53306. }
  53307. declare module BABYLON {
  53308. /**
  53309. * Options to modify the vr teleportation behavior.
  53310. */
  53311. export interface VRTeleportationOptions {
  53312. /**
  53313. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53314. */
  53315. floorMeshName?: string;
  53316. /**
  53317. * A list of meshes to be used as the teleportation floor. (default: empty)
  53318. */
  53319. floorMeshes?: Mesh[];
  53320. /**
  53321. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53322. */
  53323. teleportationMode?: number;
  53324. /**
  53325. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53326. */
  53327. teleportationTime?: number;
  53328. /**
  53329. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53330. */
  53331. teleportationSpeed?: number;
  53332. /**
  53333. * The easing function used in the animation or null for Linear. (default CircleEase)
  53334. */
  53335. easingFunction?: EasingFunction;
  53336. }
  53337. /**
  53338. * Options to modify the vr experience helper's behavior.
  53339. */
  53340. export interface VRExperienceHelperOptions extends WebVROptions {
  53341. /**
  53342. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53343. */
  53344. createDeviceOrientationCamera?: boolean;
  53345. /**
  53346. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53347. */
  53348. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53349. /**
  53350. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53351. */
  53352. laserToggle?: boolean;
  53353. /**
  53354. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53355. */
  53356. floorMeshes?: Mesh[];
  53357. /**
  53358. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53359. */
  53360. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53361. /**
  53362. * Defines if WebXR should be used instead of WebVR (if available)
  53363. */
  53364. useXR?: boolean;
  53365. }
  53366. /**
  53367. * Event containing information after VR has been entered
  53368. */
  53369. export class OnAfterEnteringVRObservableEvent {
  53370. /**
  53371. * If entering vr was successful
  53372. */
  53373. success: boolean;
  53374. }
  53375. /**
  53376. * Helps to quickly add VR support to an existing scene.
  53377. * See https://doc.babylonjs.com/how_to/webvr_helper
  53378. */
  53379. export class VRExperienceHelper {
  53380. /** Options to modify the vr experience helper's behavior. */
  53381. webVROptions: VRExperienceHelperOptions;
  53382. private _scene;
  53383. private _position;
  53384. private _btnVR;
  53385. private _btnVRDisplayed;
  53386. private _webVRsupported;
  53387. private _webVRready;
  53388. private _webVRrequesting;
  53389. private _webVRpresenting;
  53390. private _hasEnteredVR;
  53391. private _fullscreenVRpresenting;
  53392. private _inputElement;
  53393. private _webVRCamera;
  53394. private _vrDeviceOrientationCamera;
  53395. private _deviceOrientationCamera;
  53396. private _existingCamera;
  53397. private _onKeyDown;
  53398. private _onVrDisplayPresentChange;
  53399. private _onVRDisplayChanged;
  53400. private _onVRRequestPresentStart;
  53401. private _onVRRequestPresentComplete;
  53402. /**
  53403. * 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)
  53404. */
  53405. enableGazeEvenWhenNoPointerLock: boolean;
  53406. /**
  53407. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53408. */
  53409. exitVROnDoubleTap: boolean;
  53410. /**
  53411. * Observable raised right before entering VR.
  53412. */
  53413. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53414. /**
  53415. * Observable raised when entering VR has completed.
  53416. */
  53417. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53418. /**
  53419. * Observable raised when exiting VR.
  53420. */
  53421. onExitingVRObservable: Observable<VRExperienceHelper>;
  53422. /**
  53423. * Observable raised when controller mesh is loaded.
  53424. */
  53425. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53426. /** Return this.onEnteringVRObservable
  53427. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53428. */
  53429. get onEnteringVR(): Observable<VRExperienceHelper>;
  53430. /** Return this.onExitingVRObservable
  53431. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53432. */
  53433. get onExitingVR(): Observable<VRExperienceHelper>;
  53434. /** Return this.onControllerMeshLoadedObservable
  53435. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53436. */
  53437. get onControllerMeshLoaded(): Observable<WebVRController>;
  53438. private _rayLength;
  53439. private _useCustomVRButton;
  53440. private _teleportationRequested;
  53441. private _teleportActive;
  53442. private _floorMeshName;
  53443. private _floorMeshesCollection;
  53444. private _teleportationMode;
  53445. private _teleportationTime;
  53446. private _teleportationSpeed;
  53447. private _teleportationEasing;
  53448. private _rotationAllowed;
  53449. private _teleportBackwardsVector;
  53450. private _teleportationTarget;
  53451. private _isDefaultTeleportationTarget;
  53452. private _postProcessMove;
  53453. private _teleportationFillColor;
  53454. private _teleportationBorderColor;
  53455. private _rotationAngle;
  53456. private _haloCenter;
  53457. private _cameraGazer;
  53458. private _padSensibilityUp;
  53459. private _padSensibilityDown;
  53460. private _leftController;
  53461. private _rightController;
  53462. private _gazeColor;
  53463. private _laserColor;
  53464. private _pickedLaserColor;
  53465. private _pickedGazeColor;
  53466. /**
  53467. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53468. */
  53469. onNewMeshSelected: Observable<AbstractMesh>;
  53470. /**
  53471. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53472. * This observable will provide the mesh and the controller used to select the mesh
  53473. */
  53474. onMeshSelectedWithController: Observable<{
  53475. mesh: AbstractMesh;
  53476. controller: WebVRController;
  53477. }>;
  53478. /**
  53479. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53480. */
  53481. onNewMeshPicked: Observable<PickingInfo>;
  53482. private _circleEase;
  53483. /**
  53484. * Observable raised before camera teleportation
  53485. */
  53486. onBeforeCameraTeleport: Observable<Vector3>;
  53487. /**
  53488. * Observable raised after camera teleportation
  53489. */
  53490. onAfterCameraTeleport: Observable<Vector3>;
  53491. /**
  53492. * Observable raised when current selected mesh gets unselected
  53493. */
  53494. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53495. private _raySelectionPredicate;
  53496. /**
  53497. * To be optionaly changed by user to define custom ray selection
  53498. */
  53499. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53500. /**
  53501. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53502. */
  53503. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53504. /**
  53505. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53506. */
  53507. teleportationEnabled: boolean;
  53508. private _defaultHeight;
  53509. private _teleportationInitialized;
  53510. private _interactionsEnabled;
  53511. private _interactionsRequested;
  53512. private _displayGaze;
  53513. private _displayLaserPointer;
  53514. /**
  53515. * The mesh used to display where the user is going to teleport.
  53516. */
  53517. get teleportationTarget(): Mesh;
  53518. /**
  53519. * Sets the mesh to be used to display where the user is going to teleport.
  53520. */
  53521. set teleportationTarget(value: Mesh);
  53522. /**
  53523. * 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
  53524. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53525. * See https://doc.babylonjs.com/resources/baking_transformations
  53526. */
  53527. get gazeTrackerMesh(): Mesh;
  53528. set gazeTrackerMesh(value: Mesh);
  53529. /**
  53530. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53531. */
  53532. updateGazeTrackerScale: boolean;
  53533. /**
  53534. * If the gaze trackers color should be updated when selecting meshes
  53535. */
  53536. updateGazeTrackerColor: boolean;
  53537. /**
  53538. * If the controller laser color should be updated when selecting meshes
  53539. */
  53540. updateControllerLaserColor: boolean;
  53541. /**
  53542. * The gaze tracking mesh corresponding to the left controller
  53543. */
  53544. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53545. /**
  53546. * The gaze tracking mesh corresponding to the right controller
  53547. */
  53548. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53549. /**
  53550. * If the ray of the gaze should be displayed.
  53551. */
  53552. get displayGaze(): boolean;
  53553. /**
  53554. * Sets if the ray of the gaze should be displayed.
  53555. */
  53556. set displayGaze(value: boolean);
  53557. /**
  53558. * If the ray of the LaserPointer should be displayed.
  53559. */
  53560. get displayLaserPointer(): boolean;
  53561. /**
  53562. * Sets if the ray of the LaserPointer should be displayed.
  53563. */
  53564. set displayLaserPointer(value: boolean);
  53565. /**
  53566. * The deviceOrientationCamera used as the camera when not in VR.
  53567. */
  53568. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53569. /**
  53570. * Based on the current WebVR support, returns the current VR camera used.
  53571. */
  53572. get currentVRCamera(): Nullable<Camera>;
  53573. /**
  53574. * The webVRCamera which is used when in VR.
  53575. */
  53576. get webVRCamera(): WebVRFreeCamera;
  53577. /**
  53578. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53579. */
  53580. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53581. /**
  53582. * The html button that is used to trigger entering into VR.
  53583. */
  53584. get vrButton(): Nullable<HTMLButtonElement>;
  53585. private get _teleportationRequestInitiated();
  53586. /**
  53587. * Defines whether or not Pointer lock should be requested when switching to
  53588. * full screen.
  53589. */
  53590. requestPointerLockOnFullScreen: boolean;
  53591. /**
  53592. * If asking to force XR, this will be populated with the default xr experience
  53593. */
  53594. xr: WebXRDefaultExperience;
  53595. /**
  53596. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53597. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53598. */
  53599. xrTestDone: boolean;
  53600. /**
  53601. * Instantiates a VRExperienceHelper.
  53602. * Helps to quickly add VR support to an existing scene.
  53603. * @param scene The scene the VRExperienceHelper belongs to.
  53604. * @param webVROptions Options to modify the vr experience helper's behavior.
  53605. */
  53606. constructor(scene: Scene,
  53607. /** Options to modify the vr experience helper's behavior. */
  53608. webVROptions?: VRExperienceHelperOptions);
  53609. private completeVRInit;
  53610. private _onDefaultMeshLoaded;
  53611. private _onResize;
  53612. private _onFullscreenChange;
  53613. /**
  53614. * Gets a value indicating if we are currently in VR mode.
  53615. */
  53616. get isInVRMode(): boolean;
  53617. private onVrDisplayPresentChange;
  53618. private onVRDisplayChanged;
  53619. private moveButtonToBottomRight;
  53620. private displayVRButton;
  53621. private updateButtonVisibility;
  53622. private _cachedAngularSensibility;
  53623. /**
  53624. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53625. * Otherwise, will use the fullscreen API.
  53626. */
  53627. enterVR(): void;
  53628. /**
  53629. * Attempt to exit VR, or fullscreen.
  53630. */
  53631. exitVR(): void;
  53632. /**
  53633. * The position of the vr experience helper.
  53634. */
  53635. get position(): Vector3;
  53636. /**
  53637. * Sets the position of the vr experience helper.
  53638. */
  53639. set position(value: Vector3);
  53640. /**
  53641. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53642. */
  53643. enableInteractions(): void;
  53644. private get _noControllerIsActive();
  53645. private beforeRender;
  53646. private _isTeleportationFloor;
  53647. /**
  53648. * Adds a floor mesh to be used for teleportation.
  53649. * @param floorMesh the mesh to be used for teleportation.
  53650. */
  53651. addFloorMesh(floorMesh: Mesh): void;
  53652. /**
  53653. * Removes a floor mesh from being used for teleportation.
  53654. * @param floorMesh the mesh to be removed.
  53655. */
  53656. removeFloorMesh(floorMesh: Mesh): void;
  53657. /**
  53658. * Enables interactions and teleportation using the VR controllers and gaze.
  53659. * @param vrTeleportationOptions options to modify teleportation behavior.
  53660. */
  53661. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53662. private _onNewGamepadConnected;
  53663. private _tryEnableInteractionOnController;
  53664. private _onNewGamepadDisconnected;
  53665. private _enableInteractionOnController;
  53666. private _checkTeleportWithRay;
  53667. private _checkRotate;
  53668. private _checkTeleportBackwards;
  53669. private _enableTeleportationOnController;
  53670. private _createTeleportationCircles;
  53671. private _displayTeleportationTarget;
  53672. private _hideTeleportationTarget;
  53673. private _rotateCamera;
  53674. private _moveTeleportationSelectorTo;
  53675. private _workingVector;
  53676. private _workingQuaternion;
  53677. private _workingMatrix;
  53678. /**
  53679. * Time Constant Teleportation Mode
  53680. */
  53681. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53682. /**
  53683. * Speed Constant Teleportation Mode
  53684. */
  53685. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53686. /**
  53687. * Teleports the users feet to the desired location
  53688. * @param location The location where the user's feet should be placed
  53689. */
  53690. teleportCamera(location: Vector3): void;
  53691. private _convertNormalToDirectionOfRay;
  53692. private _castRayAndSelectObject;
  53693. private _notifySelectedMeshUnselected;
  53694. /**
  53695. * Permanently set new colors for the laser pointer
  53696. * @param color the new laser color
  53697. * @param pickedColor the new laser color when picked mesh detected
  53698. */
  53699. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53700. /**
  53701. * Set lighting enabled / disabled on the laser pointer of both controllers
  53702. * @param enabled should the lighting be enabled on the laser pointer
  53703. */
  53704. setLaserLightingState(enabled?: boolean): void;
  53705. /**
  53706. * Permanently set new colors for the gaze pointer
  53707. * @param color the new gaze color
  53708. * @param pickedColor the new gaze color when picked mesh detected
  53709. */
  53710. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53711. /**
  53712. * Sets the color of the laser ray from the vr controllers.
  53713. * @param color new color for the ray.
  53714. */
  53715. changeLaserColor(color: Color3): void;
  53716. /**
  53717. * Sets the color of the ray from the vr headsets gaze.
  53718. * @param color new color for the ray.
  53719. */
  53720. changeGazeColor(color: Color3): void;
  53721. /**
  53722. * Exits VR and disposes of the vr experience helper
  53723. */
  53724. dispose(): void;
  53725. /**
  53726. * Gets the name of the VRExperienceHelper class
  53727. * @returns "VRExperienceHelper"
  53728. */
  53729. getClassName(): string;
  53730. }
  53731. }
  53732. declare module BABYLON {
  53733. /**
  53734. * Contains an array of blocks representing the octree
  53735. */
  53736. export interface IOctreeContainer<T> {
  53737. /**
  53738. * Blocks within the octree
  53739. */
  53740. blocks: Array<OctreeBlock<T>>;
  53741. }
  53742. /**
  53743. * Class used to store a cell in an octree
  53744. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53745. */
  53746. export class OctreeBlock<T> {
  53747. /**
  53748. * Gets the content of the current block
  53749. */
  53750. entries: T[];
  53751. /**
  53752. * Gets the list of block children
  53753. */
  53754. blocks: Array<OctreeBlock<T>>;
  53755. private _depth;
  53756. private _maxDepth;
  53757. private _capacity;
  53758. private _minPoint;
  53759. private _maxPoint;
  53760. private _boundingVectors;
  53761. private _creationFunc;
  53762. /**
  53763. * Creates a new block
  53764. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53765. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53766. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53767. * @param depth defines the current depth of this block in the octree
  53768. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53769. * @param creationFunc defines a callback to call when an element is added to the block
  53770. */
  53771. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53772. /**
  53773. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53774. */
  53775. get capacity(): number;
  53776. /**
  53777. * Gets the minimum vector (in world space) of the block's bounding box
  53778. */
  53779. get minPoint(): Vector3;
  53780. /**
  53781. * Gets the maximum vector (in world space) of the block's bounding box
  53782. */
  53783. get maxPoint(): Vector3;
  53784. /**
  53785. * Add a new element to this block
  53786. * @param entry defines the element to add
  53787. */
  53788. addEntry(entry: T): void;
  53789. /**
  53790. * Remove an element from this block
  53791. * @param entry defines the element to remove
  53792. */
  53793. removeEntry(entry: T): void;
  53794. /**
  53795. * Add an array of elements to this block
  53796. * @param entries defines the array of elements to add
  53797. */
  53798. addEntries(entries: T[]): void;
  53799. /**
  53800. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53801. * @param frustumPlanes defines the frustum planes to test
  53802. * @param selection defines the array to store current content if selection is positive
  53803. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53804. */
  53805. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53806. /**
  53807. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53808. * @param sphereCenter defines the bounding sphere center
  53809. * @param sphereRadius defines the bounding sphere radius
  53810. * @param selection defines the array to store current content if selection is positive
  53811. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53812. */
  53813. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53814. /**
  53815. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53816. * @param ray defines the ray to test with
  53817. * @param selection defines the array to store current content if selection is positive
  53818. */
  53819. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53820. /**
  53821. * Subdivide the content into child blocks (this block will then be empty)
  53822. */
  53823. createInnerBlocks(): void;
  53824. /**
  53825. * @hidden
  53826. */
  53827. 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;
  53828. }
  53829. }
  53830. declare module BABYLON {
  53831. /**
  53832. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53833. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53834. */
  53835. export class Octree<T> {
  53836. /** 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.) */
  53837. maxDepth: number;
  53838. /**
  53839. * Blocks within the octree containing objects
  53840. */
  53841. blocks: Array<OctreeBlock<T>>;
  53842. /**
  53843. * Content stored in the octree
  53844. */
  53845. dynamicContent: T[];
  53846. private _maxBlockCapacity;
  53847. private _selectionContent;
  53848. private _creationFunc;
  53849. /**
  53850. * Creates a octree
  53851. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53852. * @param creationFunc function to be used to instatiate the octree
  53853. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53854. * @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.)
  53855. */
  53856. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53857. /** 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.) */
  53858. maxDepth?: number);
  53859. /**
  53860. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53861. * @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);
  53862. * @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);
  53863. * @param entries meshes to be added to the octree blocks
  53864. */
  53865. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53866. /**
  53867. * Adds a mesh to the octree
  53868. * @param entry Mesh to add to the octree
  53869. */
  53870. addMesh(entry: T): void;
  53871. /**
  53872. * Remove an element from the octree
  53873. * @param entry defines the element to remove
  53874. */
  53875. removeMesh(entry: T): void;
  53876. /**
  53877. * Selects an array of meshes within the frustum
  53878. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53879. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53880. * @returns array of meshes within the frustum
  53881. */
  53882. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53883. /**
  53884. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53885. * @param sphereCenter defines the bounding sphere center
  53886. * @param sphereRadius defines the bounding sphere radius
  53887. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53888. * @returns an array of objects that intersect the sphere
  53889. */
  53890. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53891. /**
  53892. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53893. * @param ray defines the ray to test with
  53894. * @returns array of intersected objects
  53895. */
  53896. intersectsRay(ray: Ray): SmartArray<T>;
  53897. /**
  53898. * Adds a mesh into the octree block if it intersects the block
  53899. */
  53900. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53901. /**
  53902. * Adds a submesh into the octree block if it intersects the block
  53903. */
  53904. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53905. }
  53906. }
  53907. declare module BABYLON {
  53908. interface Scene {
  53909. /**
  53910. * @hidden
  53911. * Backing Filed
  53912. */
  53913. _selectionOctree: Octree<AbstractMesh>;
  53914. /**
  53915. * Gets the octree used to boost mesh selection (picking)
  53916. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53917. */
  53918. selectionOctree: Octree<AbstractMesh>;
  53919. /**
  53920. * Creates or updates the octree used to boost selection (picking)
  53921. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53922. * @param maxCapacity defines the maximum capacity per leaf
  53923. * @param maxDepth defines the maximum depth of the octree
  53924. * @returns an octree of AbstractMesh
  53925. */
  53926. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53927. }
  53928. interface AbstractMesh {
  53929. /**
  53930. * @hidden
  53931. * Backing Field
  53932. */
  53933. _submeshesOctree: Octree<SubMesh>;
  53934. /**
  53935. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53936. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53937. * @param maxCapacity defines the maximum size of each block (64 by default)
  53938. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53939. * @returns the new octree
  53940. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53941. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53942. */
  53943. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53944. }
  53945. /**
  53946. * Defines the octree scene component responsible to manage any octrees
  53947. * in a given scene.
  53948. */
  53949. export class OctreeSceneComponent {
  53950. /**
  53951. * The component name help to identify the component in the list of scene components.
  53952. */
  53953. readonly name: string;
  53954. /**
  53955. * The scene the component belongs to.
  53956. */
  53957. scene: Scene;
  53958. /**
  53959. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53960. */
  53961. readonly checksIsEnabled: boolean;
  53962. /**
  53963. * Creates a new instance of the component for the given scene
  53964. * @param scene Defines the scene to register the component in
  53965. */
  53966. constructor(scene: Scene);
  53967. /**
  53968. * Registers the component in a given scene
  53969. */
  53970. register(): void;
  53971. /**
  53972. * Return the list of active meshes
  53973. * @returns the list of active meshes
  53974. */
  53975. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53976. /**
  53977. * Return the list of active sub meshes
  53978. * @param mesh The mesh to get the candidates sub meshes from
  53979. * @returns the list of active sub meshes
  53980. */
  53981. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53982. private _tempRay;
  53983. /**
  53984. * Return the list of sub meshes intersecting with a given local ray
  53985. * @param mesh defines the mesh to find the submesh for
  53986. * @param localRay defines the ray in local space
  53987. * @returns the list of intersecting sub meshes
  53988. */
  53989. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53990. /**
  53991. * Return the list of sub meshes colliding with a collider
  53992. * @param mesh defines the mesh to find the submesh for
  53993. * @param collider defines the collider to evaluate the collision against
  53994. * @returns the list of colliding sub meshes
  53995. */
  53996. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53997. /**
  53998. * Rebuilds the elements related to this component in case of
  53999. * context lost for instance.
  54000. */
  54001. rebuild(): void;
  54002. /**
  54003. * Disposes the component and the associated ressources.
  54004. */
  54005. dispose(): void;
  54006. }
  54007. }
  54008. declare module BABYLON {
  54009. /**
  54010. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  54011. */
  54012. export interface GizmoAxisCache {
  54013. /** Mesh used to runder the Gizmo */
  54014. gizmoMeshes: Mesh[];
  54015. /** Mesh used to detect user interaction with Gizmo */
  54016. colliderMeshes: Mesh[];
  54017. /** Material used to inicate color of gizmo mesh */
  54018. material: StandardMaterial;
  54019. /** Material used to inicate hover state of the Gizmo */
  54020. hoverMaterial: StandardMaterial;
  54021. /** Material used to inicate disabled state of the Gizmo */
  54022. disableMaterial: StandardMaterial;
  54023. /** Used to indicate Active state of the Gizmo */
  54024. active: boolean;
  54025. }
  54026. /**
  54027. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  54028. */
  54029. export class Gizmo implements IDisposable {
  54030. /** The utility layer the gizmo will be added to */
  54031. gizmoLayer: UtilityLayerRenderer;
  54032. /**
  54033. * The root mesh of the gizmo
  54034. */
  54035. _rootMesh: Mesh;
  54036. private _attachedMesh;
  54037. private _attachedNode;
  54038. /**
  54039. * Ratio for the scale of the gizmo (Default: 1)
  54040. */
  54041. protected _scaleRatio: number;
  54042. /**
  54043. * boolean updated by pointermove when a gizmo mesh is hovered
  54044. */
  54045. protected _isHovered: boolean;
  54046. /**
  54047. * Ratio for the scale of the gizmo (Default: 1)
  54048. */
  54049. set scaleRatio(value: number);
  54050. get scaleRatio(): number;
  54051. /**
  54052. * True when the mouse pointer is hovered a gizmo mesh
  54053. */
  54054. get isHovered(): boolean;
  54055. /**
  54056. * If a custom mesh has been set (Default: false)
  54057. */
  54058. protected _customMeshSet: boolean;
  54059. /**
  54060. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  54061. * * When set, interactions will be enabled
  54062. */
  54063. get attachedMesh(): Nullable<AbstractMesh>;
  54064. set attachedMesh(value: Nullable<AbstractMesh>);
  54065. /**
  54066. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  54067. * * When set, interactions will be enabled
  54068. */
  54069. get attachedNode(): Nullable<Node>;
  54070. set attachedNode(value: Nullable<Node>);
  54071. /**
  54072. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54073. * @param mesh The mesh to replace the default mesh of the gizmo
  54074. */
  54075. setCustomMesh(mesh: Mesh): void;
  54076. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  54077. /**
  54078. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  54079. */
  54080. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54081. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54082. /**
  54083. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  54084. */
  54085. updateGizmoPositionToMatchAttachedMesh: boolean;
  54086. /**
  54087. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  54088. */
  54089. updateScale: boolean;
  54090. protected _interactionsEnabled: boolean;
  54091. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54092. private _beforeRenderObserver;
  54093. private _tempQuaternion;
  54094. private _tempVector;
  54095. private _tempVector2;
  54096. private _tempMatrix1;
  54097. private _tempMatrix2;
  54098. private _rightHandtoLeftHandMatrix;
  54099. /**
  54100. * Creates a gizmo
  54101. * @param gizmoLayer The utility layer the gizmo will be added to
  54102. */
  54103. constructor(
  54104. /** The utility layer the gizmo will be added to */
  54105. gizmoLayer?: UtilityLayerRenderer);
  54106. /**
  54107. * Updates the gizmo to match the attached mesh's position/rotation
  54108. */
  54109. protected _update(): void;
  54110. /**
  54111. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  54112. * @param value Node, TransformNode or mesh
  54113. */
  54114. protected _matrixChanged(): void;
  54115. /**
  54116. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  54117. * @param gizmoLayer The utility layer the gizmo will be added to
  54118. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54119. * @returns {Observer<PointerInfo>} pointerObserver
  54120. */
  54121. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  54122. /**
  54123. * Disposes of the gizmo
  54124. */
  54125. dispose(): void;
  54126. }
  54127. }
  54128. declare module BABYLON {
  54129. /**
  54130. * Single plane drag gizmo
  54131. */
  54132. export class PlaneDragGizmo extends Gizmo {
  54133. /**
  54134. * Drag behavior responsible for the gizmos dragging interactions
  54135. */
  54136. dragBehavior: PointerDragBehavior;
  54137. private _pointerObserver;
  54138. /**
  54139. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54140. */
  54141. snapDistance: number;
  54142. /**
  54143. * Event that fires each time the gizmo snaps to a new location.
  54144. * * snapDistance is the the change in distance
  54145. */
  54146. onSnapObservable: Observable<{
  54147. snapDistance: number;
  54148. }>;
  54149. private _gizmoMesh;
  54150. private _coloredMaterial;
  54151. private _hoverMaterial;
  54152. private _disableMaterial;
  54153. private _isEnabled;
  54154. private _parent;
  54155. private _dragging;
  54156. /** @hidden */
  54157. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  54158. /**
  54159. * Creates a PlaneDragGizmo
  54160. * @param gizmoLayer The utility layer the gizmo will be added to
  54161. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  54162. * @param color The color of the gizmo
  54163. */
  54164. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  54165. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54166. /**
  54167. * If the gizmo is enabled
  54168. */
  54169. set isEnabled(value: boolean);
  54170. get isEnabled(): boolean;
  54171. /**
  54172. * Disposes of the gizmo
  54173. */
  54174. dispose(): void;
  54175. }
  54176. }
  54177. declare module BABYLON {
  54178. /**
  54179. * Single plane rotation gizmo
  54180. */
  54181. export class PlaneRotationGizmo extends Gizmo {
  54182. /**
  54183. * Drag behavior responsible for the gizmos dragging interactions
  54184. */
  54185. dragBehavior: PointerDragBehavior;
  54186. private _pointerObserver;
  54187. /**
  54188. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54189. */
  54190. snapDistance: number;
  54191. /**
  54192. * Event that fires each time the gizmo snaps to a new location.
  54193. * * snapDistance is the the change in distance
  54194. */
  54195. onSnapObservable: Observable<{
  54196. snapDistance: number;
  54197. }>;
  54198. private _isEnabled;
  54199. private _parent;
  54200. private _coloredMaterial;
  54201. private _hoverMaterial;
  54202. private _disableMaterial;
  54203. private _gizmoMesh;
  54204. private _rotationCircle;
  54205. private _dragging;
  54206. private static _CircleConstants;
  54207. /**
  54208. * Creates a PlaneRotationGizmo
  54209. * @param gizmoLayer The utility layer the gizmo will be added to
  54210. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54211. * @param color The color of the gizmo
  54212. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54213. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54214. * @param thickness display gizmo axis thickness
  54215. */
  54216. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  54217. /** Create Geometry for Gizmo */
  54218. private _createGizmoMesh;
  54219. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54220. private setupRotationCircle;
  54221. private updateRotationPath;
  54222. private updateRotationCircle;
  54223. /**
  54224. * If the gizmo is enabled
  54225. */
  54226. set isEnabled(value: boolean);
  54227. get isEnabled(): boolean;
  54228. /**
  54229. * Disposes of the gizmo
  54230. */
  54231. dispose(): void;
  54232. }
  54233. }
  54234. declare module BABYLON {
  54235. /**
  54236. * Gizmo that enables rotating a mesh along 3 axis
  54237. */
  54238. export class RotationGizmo extends Gizmo {
  54239. /**
  54240. * Internal gizmo used for interactions on the x axis
  54241. */
  54242. xGizmo: PlaneRotationGizmo;
  54243. /**
  54244. * Internal gizmo used for interactions on the y axis
  54245. */
  54246. yGizmo: PlaneRotationGizmo;
  54247. /**
  54248. * Internal gizmo used for interactions on the z axis
  54249. */
  54250. zGizmo: PlaneRotationGizmo;
  54251. /** Fires an event when any of it's sub gizmos are dragged */
  54252. onDragStartObservable: Observable<unknown>;
  54253. /** Fires an event when any of it's sub gizmos are released from dragging */
  54254. onDragEndObservable: Observable<unknown>;
  54255. private _meshAttached;
  54256. private _nodeAttached;
  54257. private _observables;
  54258. /** Node Caching for quick lookup */
  54259. private _gizmoAxisCache;
  54260. get attachedMesh(): Nullable<AbstractMesh>;
  54261. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54262. get attachedNode(): Nullable<Node>;
  54263. set attachedNode(node: Nullable<Node>);
  54264. protected _checkBillboardTransform(): void;
  54265. /**
  54266. * True when the mouse pointer is hovering a gizmo mesh
  54267. */
  54268. get isHovered(): boolean;
  54269. /**
  54270. * Creates a RotationGizmo
  54271. * @param gizmoLayer The utility layer the gizmo will be added to
  54272. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54273. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54274. * @param thickness display gizmo axis thickness
  54275. */
  54276. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  54277. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54278. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54279. /**
  54280. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54281. */
  54282. set snapDistance(value: number);
  54283. get snapDistance(): number;
  54284. /**
  54285. * Ratio for the scale of the gizmo (Default: 1)
  54286. */
  54287. set scaleRatio(value: number);
  54288. get scaleRatio(): number;
  54289. /**
  54290. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54291. * @param mesh Axis gizmo mesh
  54292. * @param cache Gizmo axis definition used for reactive gizmo UI
  54293. */
  54294. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54295. /**
  54296. * Disposes of the gizmo
  54297. */
  54298. dispose(): void;
  54299. /**
  54300. * CustomMeshes are not supported by this gizmo
  54301. * @param mesh The mesh to replace the default mesh of the gizmo
  54302. */
  54303. setCustomMesh(mesh: Mesh): void;
  54304. }
  54305. }
  54306. declare module BABYLON {
  54307. /**
  54308. * Class containing static functions to help procedurally build meshes
  54309. */
  54310. export class PolyhedronBuilder {
  54311. /**
  54312. * Creates a polyhedron mesh
  54313. * * 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
  54314. * * The parameter `size` (positive float, default 1) sets the polygon size
  54315. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54316. * * 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`
  54317. * * 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
  54318. * * 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)`)
  54319. * * 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
  54320. * * 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
  54321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54322. * * 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
  54323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54324. * @param name defines the name of the mesh
  54325. * @param options defines the options used to create the mesh
  54326. * @param scene defines the hosting scene
  54327. * @returns the polyhedron mesh
  54328. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54329. */
  54330. static CreatePolyhedron(name: string, options: {
  54331. type?: number;
  54332. size?: number;
  54333. sizeX?: number;
  54334. sizeY?: number;
  54335. sizeZ?: number;
  54336. custom?: any;
  54337. faceUV?: Vector4[];
  54338. faceColors?: Color4[];
  54339. flat?: boolean;
  54340. updatable?: boolean;
  54341. sideOrientation?: number;
  54342. frontUVs?: Vector4;
  54343. backUVs?: Vector4;
  54344. }, scene?: Nullable<Scene>): Mesh;
  54345. }
  54346. }
  54347. declare module BABYLON {
  54348. /**
  54349. * Class containing static functions to help procedurally build meshes
  54350. */
  54351. export class BoxBuilder {
  54352. /**
  54353. * Creates a box mesh
  54354. * * The parameter `size` sets the size (float) of each box side (default 1)
  54355. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54356. * * 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)
  54357. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54359. * * 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
  54360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54361. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54362. * @param name defines the name of the mesh
  54363. * @param options defines the options used to create the mesh
  54364. * @param scene defines the hosting scene
  54365. * @returns the box mesh
  54366. */
  54367. static CreateBox(name: string, options: {
  54368. size?: number;
  54369. width?: number;
  54370. height?: number;
  54371. depth?: number;
  54372. faceUV?: Vector4[];
  54373. faceColors?: Color4[];
  54374. sideOrientation?: number;
  54375. frontUVs?: Vector4;
  54376. backUVs?: Vector4;
  54377. wrap?: boolean;
  54378. topBaseAt?: number;
  54379. bottomBaseAt?: number;
  54380. updatable?: boolean;
  54381. }, scene?: Nullable<Scene>): Mesh;
  54382. }
  54383. }
  54384. declare module BABYLON {
  54385. /**
  54386. * Single axis scale gizmo
  54387. */
  54388. export class AxisScaleGizmo extends Gizmo {
  54389. /**
  54390. * Drag behavior responsible for the gizmos dragging interactions
  54391. */
  54392. dragBehavior: PointerDragBehavior;
  54393. private _pointerObserver;
  54394. /**
  54395. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54396. */
  54397. snapDistance: number;
  54398. /**
  54399. * Event that fires each time the gizmo snaps to a new location.
  54400. * * snapDistance is the the change in distance
  54401. */
  54402. onSnapObservable: Observable<{
  54403. snapDistance: number;
  54404. }>;
  54405. /**
  54406. * If the scaling operation should be done on all axis (default: false)
  54407. */
  54408. uniformScaling: boolean;
  54409. /**
  54410. * Custom sensitivity value for the drag strength
  54411. */
  54412. sensitivity: number;
  54413. private _isEnabled;
  54414. private _parent;
  54415. private _gizmoMesh;
  54416. private _coloredMaterial;
  54417. private _hoverMaterial;
  54418. private _disableMaterial;
  54419. private _dragging;
  54420. /**
  54421. * Creates an AxisScaleGizmo
  54422. * @param gizmoLayer The utility layer the gizmo will be added to
  54423. * @param dragAxis The axis which the gizmo will be able to scale on
  54424. * @param color The color of the gizmo
  54425. * @param thickness display gizmo axis thickness
  54426. */
  54427. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  54428. /** Create Geometry for Gizmo */
  54429. private _createGizmoMesh;
  54430. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54431. /**
  54432. * If the gizmo is enabled
  54433. */
  54434. set isEnabled(value: boolean);
  54435. get isEnabled(): boolean;
  54436. /**
  54437. * Disposes of the gizmo
  54438. */
  54439. dispose(): void;
  54440. /**
  54441. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54442. * @param mesh The mesh to replace the default mesh of the gizmo
  54443. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54444. */
  54445. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54446. }
  54447. }
  54448. declare module BABYLON {
  54449. /**
  54450. * Gizmo that enables scaling a mesh along 3 axis
  54451. */
  54452. export class ScaleGizmo extends Gizmo {
  54453. /**
  54454. * Internal gizmo used for interactions on the x axis
  54455. */
  54456. xGizmo: AxisScaleGizmo;
  54457. /**
  54458. * Internal gizmo used for interactions on the y axis
  54459. */
  54460. yGizmo: AxisScaleGizmo;
  54461. /**
  54462. * Internal gizmo used for interactions on the z axis
  54463. */
  54464. zGizmo: AxisScaleGizmo;
  54465. /**
  54466. * Internal gizmo used to scale all axis equally
  54467. */
  54468. uniformScaleGizmo: AxisScaleGizmo;
  54469. private _meshAttached;
  54470. private _nodeAttached;
  54471. private _snapDistance;
  54472. private _uniformScalingMesh;
  54473. private _octahedron;
  54474. private _sensitivity;
  54475. private _coloredMaterial;
  54476. private _hoverMaterial;
  54477. private _disableMaterial;
  54478. private _observables;
  54479. /** Node Caching for quick lookup */
  54480. private _gizmoAxisCache;
  54481. /** Fires an event when any of it's sub gizmos are dragged */
  54482. onDragStartObservable: Observable<unknown>;
  54483. /** Fires an event when any of it's sub gizmos are released from dragging */
  54484. onDragEndObservable: Observable<unknown>;
  54485. get attachedMesh(): Nullable<AbstractMesh>;
  54486. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54487. get attachedNode(): Nullable<Node>;
  54488. set attachedNode(node: Nullable<Node>);
  54489. /**
  54490. * True when the mouse pointer is hovering a gizmo mesh
  54491. */
  54492. get isHovered(): boolean;
  54493. /**
  54494. * Creates a ScaleGizmo
  54495. * @param gizmoLayer The utility layer the gizmo will be added to
  54496. * @param thickness display gizmo axis thickness
  54497. */
  54498. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54499. /** Create Geometry for Gizmo */
  54500. private _createUniformScaleMesh;
  54501. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54502. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54503. /**
  54504. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54505. */
  54506. set snapDistance(value: number);
  54507. get snapDistance(): number;
  54508. /**
  54509. * Ratio for the scale of the gizmo (Default: 1)
  54510. */
  54511. set scaleRatio(value: number);
  54512. get scaleRatio(): number;
  54513. /**
  54514. * Sensitivity factor for dragging (Default: 1)
  54515. */
  54516. set sensitivity(value: number);
  54517. get sensitivity(): number;
  54518. /**
  54519. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54520. * @param mesh Axis gizmo mesh
  54521. * @param cache Gizmo axis definition used for reactive gizmo UI
  54522. */
  54523. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54524. /**
  54525. * Disposes of the gizmo
  54526. */
  54527. dispose(): void;
  54528. }
  54529. }
  54530. declare module BABYLON {
  54531. /**
  54532. * Bounding box gizmo
  54533. */
  54534. export class BoundingBoxGizmo extends Gizmo {
  54535. private _lineBoundingBox;
  54536. private _rotateSpheresParent;
  54537. private _scaleBoxesParent;
  54538. private _boundingDimensions;
  54539. private _renderObserver;
  54540. private _pointerObserver;
  54541. private _scaleDragSpeed;
  54542. private _tmpQuaternion;
  54543. private _tmpVector;
  54544. private _tmpRotationMatrix;
  54545. /**
  54546. * 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)
  54547. */
  54548. ignoreChildren: boolean;
  54549. /**
  54550. * 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)
  54551. */
  54552. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54553. /**
  54554. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54555. */
  54556. rotationSphereSize: number;
  54557. /**
  54558. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54559. */
  54560. scaleBoxSize: number;
  54561. /**
  54562. * 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)
  54563. */
  54564. fixedDragMeshScreenSize: boolean;
  54565. /**
  54566. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54567. */
  54568. fixedDragMeshScreenSizeDistanceFactor: number;
  54569. /**
  54570. * Fired when a rotation sphere or scale box is dragged
  54571. */
  54572. onDragStartObservable: Observable<{}>;
  54573. /**
  54574. * Fired when a scale box is dragged
  54575. */
  54576. onScaleBoxDragObservable: Observable<{}>;
  54577. /**
  54578. * Fired when a scale box drag is ended
  54579. */
  54580. onScaleBoxDragEndObservable: Observable<{}>;
  54581. /**
  54582. * Fired when a rotation sphere is dragged
  54583. */
  54584. onRotationSphereDragObservable: Observable<{}>;
  54585. /**
  54586. * Fired when a rotation sphere drag is ended
  54587. */
  54588. onRotationSphereDragEndObservable: Observable<{}>;
  54589. /**
  54590. * 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)
  54591. */
  54592. scalePivot: Nullable<Vector3>;
  54593. /**
  54594. * Mesh used as a pivot to rotate the attached node
  54595. */
  54596. private _anchorMesh;
  54597. private _existingMeshScale;
  54598. private _dragMesh;
  54599. private pointerDragBehavior;
  54600. private coloredMaterial;
  54601. private hoverColoredMaterial;
  54602. /**
  54603. * Sets the color of the bounding box gizmo
  54604. * @param color the color to set
  54605. */
  54606. setColor(color: Color3): void;
  54607. /**
  54608. * Creates an BoundingBoxGizmo
  54609. * @param gizmoLayer The utility layer the gizmo will be added to
  54610. * @param color The color of the gizmo
  54611. */
  54612. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54613. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  54614. private _selectNode;
  54615. /**
  54616. * Updates the bounding box information for the Gizmo
  54617. */
  54618. updateBoundingBox(): void;
  54619. private _updateRotationSpheres;
  54620. private _updateScaleBoxes;
  54621. /**
  54622. * Enables rotation on the specified axis and disables rotation on the others
  54623. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54624. */
  54625. setEnabledRotationAxis(axis: string): void;
  54626. /**
  54627. * Enables/disables scaling
  54628. * @param enable if scaling should be enabled
  54629. * @param homogeneousScaling defines if scaling should only be homogeneous
  54630. */
  54631. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54632. private _updateDummy;
  54633. /**
  54634. * Enables a pointer drag behavior on the bounding box of the gizmo
  54635. */
  54636. enableDragBehavior(): void;
  54637. /**
  54638. * Disposes of the gizmo
  54639. */
  54640. dispose(): void;
  54641. /**
  54642. * 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)
  54643. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54644. * @returns the bounding box mesh with the passed in mesh as a child
  54645. */
  54646. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54647. /**
  54648. * CustomMeshes are not supported by this gizmo
  54649. * @param mesh The mesh to replace the default mesh of the gizmo
  54650. */
  54651. setCustomMesh(mesh: Mesh): void;
  54652. }
  54653. }
  54654. declare module BABYLON {
  54655. /**
  54656. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54657. */
  54658. export class GizmoManager implements IDisposable {
  54659. private scene;
  54660. /**
  54661. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54662. */
  54663. gizmos: {
  54664. positionGizmo: Nullable<PositionGizmo>;
  54665. rotationGizmo: Nullable<RotationGizmo>;
  54666. scaleGizmo: Nullable<ScaleGizmo>;
  54667. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54668. };
  54669. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54670. clearGizmoOnEmptyPointerEvent: boolean;
  54671. /** Fires an event when the manager is attached to a mesh */
  54672. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54673. /** Fires an event when the manager is attached to a node */
  54674. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54675. private _gizmosEnabled;
  54676. private _pointerObservers;
  54677. private _attachedMesh;
  54678. private _attachedNode;
  54679. private _boundingBoxColor;
  54680. private _defaultUtilityLayer;
  54681. private _defaultKeepDepthUtilityLayer;
  54682. private _thickness;
  54683. /** Node Caching for quick lookup */
  54684. private _gizmoAxisCache;
  54685. /**
  54686. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54687. */
  54688. boundingBoxDragBehavior: SixDofDragBehavior;
  54689. /**
  54690. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54691. */
  54692. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54693. /**
  54694. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54695. */
  54696. attachableNodes: Nullable<Array<Node>>;
  54697. /**
  54698. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54699. */
  54700. usePointerToAttachGizmos: boolean;
  54701. /**
  54702. * Utility layer that the bounding box gizmo belongs to
  54703. */
  54704. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54705. /**
  54706. * Utility layer that all gizmos besides bounding box belong to
  54707. */
  54708. get utilityLayer(): UtilityLayerRenderer;
  54709. /**
  54710. * True when the mouse pointer is hovering a gizmo mesh
  54711. */
  54712. get isHovered(): boolean;
  54713. /**
  54714. * Instatiates a gizmo manager
  54715. * @param scene the scene to overlay the gizmos on top of
  54716. * @param thickness display gizmo axis thickness
  54717. * @param utilityLayer the layer where gizmos are rendered
  54718. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  54719. */
  54720. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  54721. /**
  54722. * Subscribes to pointer down events, for attaching and detaching mesh
  54723. * @param scene The sceme layer the observer will be added to
  54724. */
  54725. private _attachToMeshPointerObserver;
  54726. /**
  54727. * Attaches a set of gizmos to the specified mesh
  54728. * @param mesh The mesh the gizmo's should be attached to
  54729. */
  54730. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54731. /**
  54732. * Attaches a set of gizmos to the specified node
  54733. * @param node The node the gizmo's should be attached to
  54734. */
  54735. attachToNode(node: Nullable<Node>): void;
  54736. /**
  54737. * If the position gizmo is enabled
  54738. */
  54739. set positionGizmoEnabled(value: boolean);
  54740. get positionGizmoEnabled(): boolean;
  54741. /**
  54742. * If the rotation gizmo is enabled
  54743. */
  54744. set rotationGizmoEnabled(value: boolean);
  54745. get rotationGizmoEnabled(): boolean;
  54746. /**
  54747. * If the scale gizmo is enabled
  54748. */
  54749. set scaleGizmoEnabled(value: boolean);
  54750. get scaleGizmoEnabled(): boolean;
  54751. /**
  54752. * If the boundingBox gizmo is enabled
  54753. */
  54754. set boundingBoxGizmoEnabled(value: boolean);
  54755. get boundingBoxGizmoEnabled(): boolean;
  54756. /**
  54757. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54758. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54759. */
  54760. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  54761. /**
  54762. * Disposes of the gizmo manager
  54763. */
  54764. dispose(): void;
  54765. }
  54766. }
  54767. declare module BABYLON {
  54768. /**
  54769. * Gizmo that enables dragging a mesh along 3 axis
  54770. */
  54771. export class PositionGizmo extends Gizmo {
  54772. /**
  54773. * Internal gizmo used for interactions on the x axis
  54774. */
  54775. xGizmo: AxisDragGizmo;
  54776. /**
  54777. * Internal gizmo used for interactions on the y axis
  54778. */
  54779. yGizmo: AxisDragGizmo;
  54780. /**
  54781. * Internal gizmo used for interactions on the z axis
  54782. */
  54783. zGizmo: AxisDragGizmo;
  54784. /**
  54785. * Internal gizmo used for interactions on the yz plane
  54786. */
  54787. xPlaneGizmo: PlaneDragGizmo;
  54788. /**
  54789. * Internal gizmo used for interactions on the xz plane
  54790. */
  54791. yPlaneGizmo: PlaneDragGizmo;
  54792. /**
  54793. * Internal gizmo used for interactions on the xy plane
  54794. */
  54795. zPlaneGizmo: PlaneDragGizmo;
  54796. /**
  54797. * private variables
  54798. */
  54799. private _meshAttached;
  54800. private _nodeAttached;
  54801. private _snapDistance;
  54802. private _observables;
  54803. /** Node Caching for quick lookup */
  54804. private _gizmoAxisCache;
  54805. /** Fires an event when any of it's sub gizmos are dragged */
  54806. onDragStartObservable: Observable<unknown>;
  54807. /** Fires an event when any of it's sub gizmos are released from dragging */
  54808. onDragEndObservable: Observable<unknown>;
  54809. /**
  54810. * If set to true, planar drag is enabled
  54811. */
  54812. private _planarGizmoEnabled;
  54813. get attachedMesh(): Nullable<AbstractMesh>;
  54814. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54815. get attachedNode(): Nullable<Node>;
  54816. set attachedNode(node: Nullable<Node>);
  54817. /**
  54818. * True when the mouse pointer is hovering a gizmo mesh
  54819. */
  54820. get isHovered(): boolean;
  54821. /**
  54822. * Creates a PositionGizmo
  54823. * @param gizmoLayer The utility layer the gizmo will be added to
  54824. @param thickness display gizmo axis thickness
  54825. */
  54826. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54827. /**
  54828. * If the planar drag gizmo is enabled
  54829. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  54830. */
  54831. set planarGizmoEnabled(value: boolean);
  54832. get planarGizmoEnabled(): boolean;
  54833. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54834. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54835. /**
  54836. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54837. */
  54838. set snapDistance(value: number);
  54839. get snapDistance(): number;
  54840. /**
  54841. * Ratio for the scale of the gizmo (Default: 1)
  54842. */
  54843. set scaleRatio(value: number);
  54844. get scaleRatio(): number;
  54845. /**
  54846. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54847. * @param mesh Axis gizmo mesh
  54848. * @param cache Gizmo axis definition used for reactive gizmo UI
  54849. */
  54850. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54851. /**
  54852. * Disposes of the gizmo
  54853. */
  54854. dispose(): void;
  54855. /**
  54856. * CustomMeshes are not supported by this gizmo
  54857. * @param mesh The mesh to replace the default mesh of the gizmo
  54858. */
  54859. setCustomMesh(mesh: Mesh): void;
  54860. }
  54861. }
  54862. declare module BABYLON {
  54863. /**
  54864. * Single axis drag gizmo
  54865. */
  54866. export class AxisDragGizmo extends Gizmo {
  54867. /**
  54868. * Drag behavior responsible for the gizmos dragging interactions
  54869. */
  54870. dragBehavior: PointerDragBehavior;
  54871. private _pointerObserver;
  54872. /**
  54873. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54874. */
  54875. snapDistance: number;
  54876. /**
  54877. * Event that fires each time the gizmo snaps to a new location.
  54878. * * snapDistance is the the change in distance
  54879. */
  54880. onSnapObservable: Observable<{
  54881. snapDistance: number;
  54882. }>;
  54883. private _isEnabled;
  54884. private _parent;
  54885. private _gizmoMesh;
  54886. private _coloredMaterial;
  54887. private _hoverMaterial;
  54888. private _disableMaterial;
  54889. private _dragging;
  54890. /** @hidden */
  54891. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  54892. /** @hidden */
  54893. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  54894. /**
  54895. * Creates an AxisDragGizmo
  54896. * @param gizmoLayer The utility layer the gizmo will be added to
  54897. * @param dragAxis The axis which the gizmo will be able to drag on
  54898. * @param color The color of the gizmo
  54899. * @param thickness display gizmo axis thickness
  54900. */
  54901. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  54902. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54903. /**
  54904. * If the gizmo is enabled
  54905. */
  54906. set isEnabled(value: boolean);
  54907. get isEnabled(): boolean;
  54908. /**
  54909. * Disposes of the gizmo
  54910. */
  54911. dispose(): void;
  54912. }
  54913. }
  54914. declare module BABYLON.Debug {
  54915. /**
  54916. * The Axes viewer will show 3 axes in a specific point in space
  54917. */
  54918. export class AxesViewer {
  54919. private _xAxis;
  54920. private _yAxis;
  54921. private _zAxis;
  54922. private _scaleLinesFactor;
  54923. private _instanced;
  54924. /**
  54925. * Gets the hosting scene
  54926. */
  54927. scene: Nullable<Scene>;
  54928. /**
  54929. * Gets or sets a number used to scale line length
  54930. */
  54931. scaleLines: number;
  54932. /** Gets the node hierarchy used to render x-axis */
  54933. get xAxis(): TransformNode;
  54934. /** Gets the node hierarchy used to render y-axis */
  54935. get yAxis(): TransformNode;
  54936. /** Gets the node hierarchy used to render z-axis */
  54937. get zAxis(): TransformNode;
  54938. /**
  54939. * Creates a new AxesViewer
  54940. * @param scene defines the hosting scene
  54941. * @param scaleLines defines a number used to scale line length (1 by default)
  54942. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  54943. * @param xAxis defines the node hierarchy used to render the x-axis
  54944. * @param yAxis defines the node hierarchy used to render the y-axis
  54945. * @param zAxis defines the node hierarchy used to render the z-axis
  54946. */
  54947. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  54948. /**
  54949. * Force the viewer to update
  54950. * @param position defines the position of the viewer
  54951. * @param xaxis defines the x axis of the viewer
  54952. * @param yaxis defines the y axis of the viewer
  54953. * @param zaxis defines the z axis of the viewer
  54954. */
  54955. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  54956. /**
  54957. * Creates an instance of this axes viewer.
  54958. * @returns a new axes viewer with instanced meshes
  54959. */
  54960. createInstance(): AxesViewer;
  54961. /** Releases resources */
  54962. dispose(): void;
  54963. private static _SetRenderingGroupId;
  54964. }
  54965. }
  54966. declare module BABYLON.Debug {
  54967. /**
  54968. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  54969. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  54970. */
  54971. export class BoneAxesViewer extends AxesViewer {
  54972. /**
  54973. * Gets or sets the target mesh where to display the axes viewer
  54974. */
  54975. mesh: Nullable<Mesh>;
  54976. /**
  54977. * Gets or sets the target bone where to display the axes viewer
  54978. */
  54979. bone: Nullable<Bone>;
  54980. /** Gets current position */
  54981. pos: Vector3;
  54982. /** Gets direction of X axis */
  54983. xaxis: Vector3;
  54984. /** Gets direction of Y axis */
  54985. yaxis: Vector3;
  54986. /** Gets direction of Z axis */
  54987. zaxis: Vector3;
  54988. /**
  54989. * Creates a new BoneAxesViewer
  54990. * @param scene defines the hosting scene
  54991. * @param bone defines the target bone
  54992. * @param mesh defines the target mesh
  54993. * @param scaleLines defines a scaling factor for line length (1 by default)
  54994. */
  54995. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  54996. /**
  54997. * Force the viewer to update
  54998. */
  54999. update(): void;
  55000. /** Releases resources */
  55001. dispose(): void;
  55002. }
  55003. }
  55004. declare module BABYLON {
  55005. /**
  55006. * Interface used to define scene explorer extensibility option
  55007. */
  55008. export interface IExplorerExtensibilityOption {
  55009. /**
  55010. * Define the option label
  55011. */
  55012. label: string;
  55013. /**
  55014. * Defines the action to execute on click
  55015. */
  55016. action: (entity: any) => void;
  55017. }
  55018. /**
  55019. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  55020. */
  55021. export interface IExplorerExtensibilityGroup {
  55022. /**
  55023. * Defines a predicate to test if a given type mut be extended
  55024. */
  55025. predicate: (entity: any) => boolean;
  55026. /**
  55027. * Gets the list of options added to a type
  55028. */
  55029. entries: IExplorerExtensibilityOption[];
  55030. }
  55031. /**
  55032. * Interface used to define the options to use to create the Inspector
  55033. */
  55034. export interface IInspectorOptions {
  55035. /**
  55036. * Display in overlay mode (default: false)
  55037. */
  55038. overlay?: boolean;
  55039. /**
  55040. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  55041. */
  55042. globalRoot?: HTMLElement;
  55043. /**
  55044. * Display the Scene explorer
  55045. */
  55046. showExplorer?: boolean;
  55047. /**
  55048. * Display the property inspector
  55049. */
  55050. showInspector?: boolean;
  55051. /**
  55052. * Display in embed mode (both panes on the right)
  55053. */
  55054. embedMode?: boolean;
  55055. /**
  55056. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  55057. */
  55058. handleResize?: boolean;
  55059. /**
  55060. * Allow the panes to popup (default: true)
  55061. */
  55062. enablePopup?: boolean;
  55063. /**
  55064. * Allow the panes to be closed by users (default: true)
  55065. */
  55066. enableClose?: boolean;
  55067. /**
  55068. * Optional list of extensibility entries
  55069. */
  55070. explorerExtensibility?: IExplorerExtensibilityGroup[];
  55071. /**
  55072. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  55073. */
  55074. inspectorURL?: string;
  55075. /**
  55076. * Optional initial tab (default to DebugLayerTab.Properties)
  55077. */
  55078. initialTab?: DebugLayerTab;
  55079. }
  55080. interface Scene {
  55081. /**
  55082. * @hidden
  55083. * Backing field
  55084. */
  55085. _debugLayer: DebugLayer;
  55086. /**
  55087. * Gets the debug layer (aka Inspector) associated with the scene
  55088. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55089. */
  55090. debugLayer: DebugLayer;
  55091. }
  55092. /**
  55093. * Enum of inspector action tab
  55094. */
  55095. export enum DebugLayerTab {
  55096. /**
  55097. * Properties tag (default)
  55098. */
  55099. Properties = 0,
  55100. /**
  55101. * Debug tab
  55102. */
  55103. Debug = 1,
  55104. /**
  55105. * Statistics tab
  55106. */
  55107. Statistics = 2,
  55108. /**
  55109. * Tools tab
  55110. */
  55111. Tools = 3,
  55112. /**
  55113. * Settings tab
  55114. */
  55115. Settings = 4
  55116. }
  55117. /**
  55118. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55119. * what is happening in your scene
  55120. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55121. */
  55122. export class DebugLayer {
  55123. /**
  55124. * Define the url to get the inspector script from.
  55125. * By default it uses the babylonjs CDN.
  55126. * @ignoreNaming
  55127. */
  55128. static InspectorURL: string;
  55129. private _scene;
  55130. private BJSINSPECTOR;
  55131. private _onPropertyChangedObservable?;
  55132. /**
  55133. * Observable triggered when a property is changed through the inspector.
  55134. */
  55135. get onPropertyChangedObservable(): any;
  55136. /**
  55137. * Instantiates a new debug layer.
  55138. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55139. * what is happening in your scene
  55140. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55141. * @param scene Defines the scene to inspect
  55142. */
  55143. constructor(scene: Scene);
  55144. /** Creates the inspector window. */
  55145. private _createInspector;
  55146. /**
  55147. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  55148. * @param entity defines the entity to select
  55149. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  55150. */
  55151. select(entity: any, lineContainerTitles?: string | string[]): void;
  55152. /** Get the inspector from bundle or global */
  55153. private _getGlobalInspector;
  55154. /**
  55155. * Get if the inspector is visible or not.
  55156. * @returns true if visible otherwise, false
  55157. */
  55158. isVisible(): boolean;
  55159. /**
  55160. * Hide the inspector and close its window.
  55161. */
  55162. hide(): void;
  55163. /**
  55164. * Update the scene in the inspector
  55165. */
  55166. setAsActiveScene(): void;
  55167. /**
  55168. * Launch the debugLayer.
  55169. * @param config Define the configuration of the inspector
  55170. * @return a promise fulfilled when the debug layer is visible
  55171. */
  55172. show(config?: IInspectorOptions): Promise<DebugLayer>;
  55173. }
  55174. }
  55175. declare module BABYLON.Debug {
  55176. /**
  55177. * Used to show the physics impostor around the specific mesh
  55178. */
  55179. export class PhysicsViewer {
  55180. /** @hidden */
  55181. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  55182. /** @hidden */
  55183. protected _meshes: Array<Nullable<AbstractMesh>>;
  55184. /** @hidden */
  55185. protected _scene: Nullable<Scene>;
  55186. /** @hidden */
  55187. protected _numMeshes: number;
  55188. /** @hidden */
  55189. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  55190. private _renderFunction;
  55191. private _utilityLayer;
  55192. private _debugBoxMesh;
  55193. private _debugSphereMesh;
  55194. private _debugCylinderMesh;
  55195. private _debugMaterial;
  55196. private _debugMeshMeshes;
  55197. /**
  55198. * Creates a new PhysicsViewer
  55199. * @param scene defines the hosting scene
  55200. */
  55201. constructor(scene: Scene);
  55202. /** @hidden */
  55203. protected _updateDebugMeshes(): void;
  55204. /**
  55205. * Renders a specified physic impostor
  55206. * @param impostor defines the impostor to render
  55207. * @param targetMesh defines the mesh represented by the impostor
  55208. * @returns the new debug mesh used to render the impostor
  55209. */
  55210. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  55211. /**
  55212. * Hides a specified physic impostor
  55213. * @param impostor defines the impostor to hide
  55214. */
  55215. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  55216. private _getDebugMaterial;
  55217. private _getDebugBoxMesh;
  55218. private _getDebugSphereMesh;
  55219. private _getDebugCylinderMesh;
  55220. private _getDebugMeshMesh;
  55221. private _getDebugMesh;
  55222. /** Releases all resources */
  55223. dispose(): void;
  55224. }
  55225. }
  55226. declare module BABYLON {
  55227. /**
  55228. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55229. * in order to better appreciate the issue one might have.
  55230. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55231. */
  55232. export class RayHelper {
  55233. /**
  55234. * Defines the ray we are currently tryin to visualize.
  55235. */
  55236. ray: Nullable<Ray>;
  55237. private _renderPoints;
  55238. private _renderLine;
  55239. private _renderFunction;
  55240. private _scene;
  55241. private _onAfterRenderObserver;
  55242. private _onAfterStepObserver;
  55243. private _attachedToMesh;
  55244. private _meshSpaceDirection;
  55245. private _meshSpaceOrigin;
  55246. /**
  55247. * Helper function to create a colored helper in a scene in one line.
  55248. * @param ray Defines the ray we are currently tryin to visualize
  55249. * @param scene Defines the scene the ray is used in
  55250. * @param color Defines the color we want to see the ray in
  55251. * @returns The newly created ray helper.
  55252. */
  55253. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  55254. /**
  55255. * Instantiate a new ray helper.
  55256. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55257. * in order to better appreciate the issue one might have.
  55258. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55259. * @param ray Defines the ray we are currently tryin to visualize
  55260. */
  55261. constructor(ray: Ray);
  55262. /**
  55263. * Shows the ray we are willing to debug.
  55264. * @param scene Defines the scene the ray needs to be rendered in
  55265. * @param color Defines the color the ray needs to be rendered in
  55266. */
  55267. show(scene: Scene, color?: Color3): void;
  55268. /**
  55269. * Hides the ray we are debugging.
  55270. */
  55271. hide(): void;
  55272. private _render;
  55273. /**
  55274. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  55275. * @param mesh Defines the mesh we want the helper attached to
  55276. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  55277. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  55278. * @param length Defines the length of the ray
  55279. */
  55280. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  55281. /**
  55282. * Detach the ray helper from the mesh it has previously been attached to.
  55283. */
  55284. detachFromMesh(): void;
  55285. private _updateToMesh;
  55286. /**
  55287. * Dispose the helper and release its associated resources.
  55288. */
  55289. dispose(): void;
  55290. }
  55291. }
  55292. declare module BABYLON {
  55293. /**
  55294. * Defines the options associated with the creation of a SkeletonViewer.
  55295. */
  55296. export interface ISkeletonViewerOptions {
  55297. /** Should the system pause animations before building the Viewer? */
  55298. pauseAnimations: boolean;
  55299. /** Should the system return the skeleton to rest before building? */
  55300. returnToRest: boolean;
  55301. /** public Display Mode of the Viewer */
  55302. displayMode: number;
  55303. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55304. displayOptions: ISkeletonViewerDisplayOptions;
  55305. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55306. computeBonesUsingShaders: boolean;
  55307. /** Flag ignore non weighted bones */
  55308. useAllBones: boolean;
  55309. }
  55310. /**
  55311. * Defines how to display the various bone meshes for the viewer.
  55312. */
  55313. export interface ISkeletonViewerDisplayOptions {
  55314. /** How far down to start tapering the bone spurs */
  55315. midStep?: number;
  55316. /** How big is the midStep? */
  55317. midStepFactor?: number;
  55318. /** Base for the Sphere Size */
  55319. sphereBaseSize?: number;
  55320. /** The ratio of the sphere to the longest bone in units */
  55321. sphereScaleUnit?: number;
  55322. /** Ratio for the Sphere Size */
  55323. sphereFactor?: number;
  55324. /** Whether a spur should attach its far end to the child bone position */
  55325. spurFollowsChild?: boolean;
  55326. /** Whether to show local axes or not */
  55327. showLocalAxes?: boolean;
  55328. /** Length of each local axis */
  55329. localAxesSize?: number;
  55330. }
  55331. /**
  55332. * Defines the constructor options for the BoneWeight Shader.
  55333. */
  55334. export interface IBoneWeightShaderOptions {
  55335. /** Skeleton to Map */
  55336. skeleton: Skeleton;
  55337. /** Colors for Uninfluenced bones */
  55338. colorBase?: Color3;
  55339. /** Colors for 0.0-0.25 Weight bones */
  55340. colorZero?: Color3;
  55341. /** Color for 0.25-0.5 Weight Influence */
  55342. colorQuarter?: Color3;
  55343. /** Color for 0.5-0.75 Weight Influence */
  55344. colorHalf?: Color3;
  55345. /** Color for 0.75-1 Weight Influence */
  55346. colorFull?: Color3;
  55347. /** Color for Zero Weight Influence */
  55348. targetBoneIndex?: number;
  55349. }
  55350. /**
  55351. * Simple structure of the gradient steps for the Color Map.
  55352. */
  55353. export interface ISkeletonMapShaderColorMapKnot {
  55354. /** Color of the Knot */
  55355. color: Color3;
  55356. /** Location of the Knot */
  55357. location: number;
  55358. }
  55359. /**
  55360. * Defines the constructor options for the SkeletonMap Shader.
  55361. */
  55362. export interface ISkeletonMapShaderOptions {
  55363. /** Skeleton to Map */
  55364. skeleton: Skeleton;
  55365. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  55366. colorMap?: ISkeletonMapShaderColorMapKnot[];
  55367. }
  55368. }
  55369. declare module BABYLON {
  55370. /**
  55371. * Class containing static functions to help procedurally build meshes
  55372. */
  55373. export class RibbonBuilder {
  55374. /**
  55375. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55376. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55377. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55378. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55379. * * 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
  55380. * * 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
  55381. * * 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
  55382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55383. * * 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
  55384. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55385. * * 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
  55386. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55387. * * 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
  55388. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55390. * @param name defines the name of the mesh
  55391. * @param options defines the options used to create the mesh
  55392. * @param scene defines the hosting scene
  55393. * @returns the ribbon mesh
  55394. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55395. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55396. */
  55397. static CreateRibbon(name: string, options: {
  55398. pathArray: Vector3[][];
  55399. closeArray?: boolean;
  55400. closePath?: boolean;
  55401. offset?: number;
  55402. updatable?: boolean;
  55403. sideOrientation?: number;
  55404. frontUVs?: Vector4;
  55405. backUVs?: Vector4;
  55406. instance?: Mesh;
  55407. invertUV?: boolean;
  55408. uvs?: Vector2[];
  55409. colors?: Color4[];
  55410. }, scene?: Nullable<Scene>): Mesh;
  55411. }
  55412. }
  55413. declare module BABYLON {
  55414. /**
  55415. * Class containing static functions to help procedurally build meshes
  55416. */
  55417. export class ShapeBuilder {
  55418. /**
  55419. * 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.
  55420. * * 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.
  55421. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55422. * * 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.
  55423. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55424. * * 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
  55425. * * 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
  55426. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55428. * * 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
  55429. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55431. * @param name defines the name of the mesh
  55432. * @param options defines the options used to create the mesh
  55433. * @param scene defines the hosting scene
  55434. * @returns the extruded shape mesh
  55435. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55436. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55437. */
  55438. static ExtrudeShape(name: string, options: {
  55439. shape: Vector3[];
  55440. path: Vector3[];
  55441. scale?: number;
  55442. rotation?: number;
  55443. cap?: number;
  55444. updatable?: boolean;
  55445. sideOrientation?: number;
  55446. frontUVs?: Vector4;
  55447. backUVs?: Vector4;
  55448. instance?: Mesh;
  55449. invertUV?: boolean;
  55450. }, scene?: Nullable<Scene>): Mesh;
  55451. /**
  55452. * Creates an custom extruded shape mesh.
  55453. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55454. * * 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.
  55455. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55456. * * 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
  55457. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55458. * * 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
  55459. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55460. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55461. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55462. * * 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
  55463. * * 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
  55464. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55466. * * 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
  55467. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55469. * @param name defines the name of the mesh
  55470. * @param options defines the options used to create the mesh
  55471. * @param scene defines the hosting scene
  55472. * @returns the custom extruded shape mesh
  55473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55474. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55475. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55476. */
  55477. static ExtrudeShapeCustom(name: string, options: {
  55478. shape: Vector3[];
  55479. path: Vector3[];
  55480. scaleFunction?: any;
  55481. rotationFunction?: any;
  55482. ribbonCloseArray?: boolean;
  55483. ribbonClosePath?: boolean;
  55484. cap?: number;
  55485. updatable?: boolean;
  55486. sideOrientation?: number;
  55487. frontUVs?: Vector4;
  55488. backUVs?: Vector4;
  55489. instance?: Mesh;
  55490. invertUV?: boolean;
  55491. }, scene?: Nullable<Scene>): Mesh;
  55492. private static _ExtrudeShapeGeneric;
  55493. }
  55494. }
  55495. declare module BABYLON.Debug {
  55496. /**
  55497. * Class used to render a debug view of a given skeleton
  55498. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  55499. */
  55500. export class SkeletonViewer {
  55501. /** defines the skeleton to render */
  55502. skeleton: Skeleton;
  55503. /** defines the mesh attached to the skeleton */
  55504. mesh: AbstractMesh;
  55505. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55506. autoUpdateBonesMatrices: boolean;
  55507. /** defines the rendering group id to use with the viewer */
  55508. renderingGroupId: number;
  55509. /** is the options for the viewer */
  55510. options: Partial<ISkeletonViewerOptions>;
  55511. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  55512. static readonly DISPLAY_LINES: number;
  55513. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  55514. static readonly DISPLAY_SPHERES: number;
  55515. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  55516. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  55517. /** public static method to create a BoneWeight Shader
  55518. * @param options The constructor options
  55519. * @param scene The scene that the shader is scoped to
  55520. * @returns The created ShaderMaterial
  55521. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  55522. */
  55523. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  55524. /** public static method to create a BoneWeight Shader
  55525. * @param options The constructor options
  55526. * @param scene The scene that the shader is scoped to
  55527. * @returns The created ShaderMaterial
  55528. */
  55529. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  55530. /** private static method to create a BoneWeight Shader
  55531. * @param size The size of the buffer to create (usually the bone count)
  55532. * @param colorMap The gradient data to generate
  55533. * @param scene The scene that the shader is scoped to
  55534. * @returns an Array of floats from the color gradient values
  55535. */
  55536. private static _CreateBoneMapColorBuffer;
  55537. /** If SkeletonViewer scene scope. */
  55538. private _scene;
  55539. /** Gets or sets the color used to render the skeleton */
  55540. color: Color3;
  55541. /** Array of the points of the skeleton fo the line view. */
  55542. private _debugLines;
  55543. /** The SkeletonViewers Mesh. */
  55544. private _debugMesh;
  55545. /** The local axes Meshes. */
  55546. private _localAxes;
  55547. /** If SkeletonViewer is enabled. */
  55548. private _isEnabled;
  55549. /** If SkeletonViewer is ready. */
  55550. private _ready;
  55551. /** SkeletonViewer render observable. */
  55552. private _obs;
  55553. /** The Utility Layer to render the gizmos in. */
  55554. private _utilityLayer;
  55555. private _boneIndices;
  55556. /** Gets the Scene. */
  55557. get scene(): Scene;
  55558. /** Gets the utilityLayer. */
  55559. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  55560. /** Checks Ready Status. */
  55561. get isReady(): Boolean;
  55562. /** Sets Ready Status. */
  55563. set ready(value: boolean);
  55564. /** Gets the debugMesh */
  55565. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  55566. /** Sets the debugMesh */
  55567. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  55568. /** Gets the displayMode */
  55569. get displayMode(): number;
  55570. /** Sets the displayMode */
  55571. set displayMode(value: number);
  55572. /**
  55573. * Creates a new SkeletonViewer
  55574. * @param skeleton defines the skeleton to render
  55575. * @param mesh defines the mesh attached to the skeleton
  55576. * @param scene defines the hosting scene
  55577. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  55578. * @param renderingGroupId defines the rendering group id to use with the viewer
  55579. * @param options All of the extra constructor options for the SkeletonViewer
  55580. */
  55581. constructor(
  55582. /** defines the skeleton to render */
  55583. skeleton: Skeleton,
  55584. /** defines the mesh attached to the skeleton */
  55585. mesh: AbstractMesh,
  55586. /** The Scene scope*/
  55587. scene: Scene,
  55588. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55589. autoUpdateBonesMatrices?: boolean,
  55590. /** defines the rendering group id to use with the viewer */
  55591. renderingGroupId?: number,
  55592. /** is the options for the viewer */
  55593. options?: Partial<ISkeletonViewerOptions>);
  55594. /** The Dynamic bindings for the update functions */
  55595. private _bindObs;
  55596. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  55597. update(): void;
  55598. /** Gets or sets a boolean indicating if the viewer is enabled */
  55599. set isEnabled(value: boolean);
  55600. get isEnabled(): boolean;
  55601. private _getBonePosition;
  55602. private _getLinesForBonesWithLength;
  55603. private _getLinesForBonesNoLength;
  55604. /** function to revert the mesh and scene back to the initial state. */
  55605. private _revert;
  55606. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  55607. private _getAbsoluteBindPoseToRef;
  55608. /** function to build and bind sphere joint points and spur bone representations. */
  55609. private _buildSpheresAndSpurs;
  55610. private _buildLocalAxes;
  55611. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  55612. private _displayLinesUpdate;
  55613. /** Changes the displayMode of the skeleton viewer
  55614. * @param mode The displayMode numerical value
  55615. */
  55616. changeDisplayMode(mode: number): void;
  55617. /** Sets a display option of the skeleton viewer
  55618. *
  55619. * | Option | Type | Default | Description |
  55620. * | ---------------- | ------- | ------- | ----------- |
  55621. * | 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`. |
  55622. * | 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`. |
  55623. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55624. * | 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`. |
  55625. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  55626. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  55627. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  55628. *
  55629. * @param option String of the option name
  55630. * @param value The numerical option value
  55631. */
  55632. changeDisplayOptions(option: string, value: number): void;
  55633. /** Release associated resources */
  55634. dispose(): void;
  55635. }
  55636. }
  55637. declare module BABYLON {
  55638. /**
  55639. * Enum for Device Types
  55640. */
  55641. export enum DeviceType {
  55642. /** Generic */
  55643. Generic = 0,
  55644. /** Keyboard */
  55645. Keyboard = 1,
  55646. /** Mouse */
  55647. Mouse = 2,
  55648. /** Touch Pointers */
  55649. Touch = 3,
  55650. /** PS4 Dual Shock */
  55651. DualShock = 4,
  55652. /** Xbox */
  55653. Xbox = 5,
  55654. /** Switch Controller */
  55655. Switch = 6
  55656. }
  55657. /**
  55658. * Enum for All Pointers (Touch/Mouse)
  55659. */
  55660. export enum PointerInput {
  55661. /** Horizontal Axis */
  55662. Horizontal = 0,
  55663. /** Vertical Axis */
  55664. Vertical = 1,
  55665. /** Left Click or Touch */
  55666. LeftClick = 2,
  55667. /** Middle Click */
  55668. MiddleClick = 3,
  55669. /** Right Click */
  55670. RightClick = 4,
  55671. /** Browser Back */
  55672. BrowserBack = 5,
  55673. /** Browser Forward */
  55674. BrowserForward = 6
  55675. }
  55676. /**
  55677. * Enum for Dual Shock Gamepad
  55678. */
  55679. export enum DualShockInput {
  55680. /** Cross */
  55681. Cross = 0,
  55682. /** Circle */
  55683. Circle = 1,
  55684. /** Square */
  55685. Square = 2,
  55686. /** Triangle */
  55687. Triangle = 3,
  55688. /** L1 */
  55689. L1 = 4,
  55690. /** R1 */
  55691. R1 = 5,
  55692. /** L2 */
  55693. L2 = 6,
  55694. /** R2 */
  55695. R2 = 7,
  55696. /** Share */
  55697. Share = 8,
  55698. /** Options */
  55699. Options = 9,
  55700. /** L3 */
  55701. L3 = 10,
  55702. /** R3 */
  55703. R3 = 11,
  55704. /** DPadUp */
  55705. DPadUp = 12,
  55706. /** DPadDown */
  55707. DPadDown = 13,
  55708. /** DPadLeft */
  55709. DPadLeft = 14,
  55710. /** DRight */
  55711. DPadRight = 15,
  55712. /** Home */
  55713. Home = 16,
  55714. /** TouchPad */
  55715. TouchPad = 17,
  55716. /** LStickXAxis */
  55717. LStickXAxis = 18,
  55718. /** LStickYAxis */
  55719. LStickYAxis = 19,
  55720. /** RStickXAxis */
  55721. RStickXAxis = 20,
  55722. /** RStickYAxis */
  55723. RStickYAxis = 21
  55724. }
  55725. /**
  55726. * Enum for Xbox Gamepad
  55727. */
  55728. export enum XboxInput {
  55729. /** A */
  55730. A = 0,
  55731. /** B */
  55732. B = 1,
  55733. /** X */
  55734. X = 2,
  55735. /** Y */
  55736. Y = 3,
  55737. /** LB */
  55738. LB = 4,
  55739. /** RB */
  55740. RB = 5,
  55741. /** LT */
  55742. LT = 6,
  55743. /** RT */
  55744. RT = 7,
  55745. /** Back */
  55746. Back = 8,
  55747. /** Start */
  55748. Start = 9,
  55749. /** LS */
  55750. LS = 10,
  55751. /** RS */
  55752. RS = 11,
  55753. /** DPadUp */
  55754. DPadUp = 12,
  55755. /** DPadDown */
  55756. DPadDown = 13,
  55757. /** DPadLeft */
  55758. DPadLeft = 14,
  55759. /** DRight */
  55760. DPadRight = 15,
  55761. /** Home */
  55762. Home = 16,
  55763. /** LStickXAxis */
  55764. LStickXAxis = 17,
  55765. /** LStickYAxis */
  55766. LStickYAxis = 18,
  55767. /** RStickXAxis */
  55768. RStickXAxis = 19,
  55769. /** RStickYAxis */
  55770. RStickYAxis = 20
  55771. }
  55772. /**
  55773. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  55774. */
  55775. export enum SwitchInput {
  55776. /** B */
  55777. B = 0,
  55778. /** A */
  55779. A = 1,
  55780. /** Y */
  55781. Y = 2,
  55782. /** X */
  55783. X = 3,
  55784. /** L */
  55785. L = 4,
  55786. /** R */
  55787. R = 5,
  55788. /** ZL */
  55789. ZL = 6,
  55790. /** ZR */
  55791. ZR = 7,
  55792. /** Minus */
  55793. Minus = 8,
  55794. /** Plus */
  55795. Plus = 9,
  55796. /** LS */
  55797. LS = 10,
  55798. /** RS */
  55799. RS = 11,
  55800. /** DPadUp */
  55801. DPadUp = 12,
  55802. /** DPadDown */
  55803. DPadDown = 13,
  55804. /** DPadLeft */
  55805. DPadLeft = 14,
  55806. /** DRight */
  55807. DPadRight = 15,
  55808. /** Home */
  55809. Home = 16,
  55810. /** Capture */
  55811. Capture = 17,
  55812. /** LStickXAxis */
  55813. LStickXAxis = 18,
  55814. /** LStickYAxis */
  55815. LStickYAxis = 19,
  55816. /** RStickXAxis */
  55817. RStickXAxis = 20,
  55818. /** RStickYAxis */
  55819. RStickYAxis = 21
  55820. }
  55821. }
  55822. declare module BABYLON {
  55823. /**
  55824. * This class will take all inputs from Keyboard, Pointer, and
  55825. * any Gamepads and provide a polling system that all devices
  55826. * will use. This class assumes that there will only be one
  55827. * pointer device and one keyboard.
  55828. */
  55829. export class DeviceInputSystem implements IDisposable {
  55830. /**
  55831. * Returns onDeviceConnected callback property
  55832. * @returns Callback with function to execute when a device is connected
  55833. */
  55834. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  55835. /**
  55836. * Sets callback function when a device is connected and executes against all connected devices
  55837. * @param callback Function to execute when a device is connected
  55838. */
  55839. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  55840. /**
  55841. * Callback to be triggered when a device is disconnected
  55842. */
  55843. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  55844. /**
  55845. * Callback to be triggered when event driven input is updated
  55846. */
  55847. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  55848. private _inputs;
  55849. private _gamepads;
  55850. private _keyboardActive;
  55851. private _pointerActive;
  55852. private _elementToAttachTo;
  55853. private _keyboardDownEvent;
  55854. private _keyboardUpEvent;
  55855. private _pointerMoveEvent;
  55856. private _pointerDownEvent;
  55857. private _pointerUpEvent;
  55858. private _gamepadConnectedEvent;
  55859. private _gamepadDisconnectedEvent;
  55860. private _onDeviceConnected;
  55861. private static _MAX_KEYCODES;
  55862. private static _MAX_POINTER_INPUTS;
  55863. private constructor();
  55864. /**
  55865. * Creates a new DeviceInputSystem instance
  55866. * @param engine Engine to pull input element from
  55867. * @returns The new instance
  55868. */
  55869. static Create(engine: Engine): DeviceInputSystem;
  55870. /**
  55871. * Checks for current device input value, given an id and input index
  55872. * @param deviceName Id of connected device
  55873. * @param inputIndex Index of device input
  55874. * @returns Current value of input
  55875. */
  55876. /**
  55877. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  55878. * @param deviceType Enum specifiying device type
  55879. * @param deviceSlot "Slot" or index that device is referenced in
  55880. * @param inputIndex Id of input to be checked
  55881. * @returns Current value of input
  55882. */
  55883. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  55884. /**
  55885. * Dispose of all the eventlisteners
  55886. */
  55887. dispose(): void;
  55888. /**
  55889. * Checks for existing connections to devices and register them, if necessary
  55890. * Currently handles gamepads and mouse
  55891. */
  55892. private _checkForConnectedDevices;
  55893. /**
  55894. * Add a gamepad to the DeviceInputSystem
  55895. * @param gamepad A single DOM Gamepad object
  55896. */
  55897. private _addGamePad;
  55898. /**
  55899. * Add pointer device to DeviceInputSystem
  55900. * @param deviceType Type of Pointer to add
  55901. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  55902. * @param currentX Current X at point of adding
  55903. * @param currentY Current Y at point of adding
  55904. */
  55905. private _addPointerDevice;
  55906. /**
  55907. * Add device and inputs to device array
  55908. * @param deviceType Enum specifiying device type
  55909. * @param deviceSlot "Slot" or index that device is referenced in
  55910. * @param numberOfInputs Number of input entries to create for given device
  55911. */
  55912. private _registerDevice;
  55913. /**
  55914. * Given a specific device name, remove that device from the device map
  55915. * @param deviceType Enum specifiying device type
  55916. * @param deviceSlot "Slot" or index that device is referenced in
  55917. */
  55918. private _unregisterDevice;
  55919. /**
  55920. * Handle all actions that come from keyboard interaction
  55921. */
  55922. private _handleKeyActions;
  55923. /**
  55924. * Handle all actions that come from pointer interaction
  55925. */
  55926. private _handlePointerActions;
  55927. /**
  55928. * Handle all actions that come from gamepad interaction
  55929. */
  55930. private _handleGamepadActions;
  55931. /**
  55932. * Update all non-event based devices with each frame
  55933. * @param deviceType Enum specifiying device type
  55934. * @param deviceSlot "Slot" or index that device is referenced in
  55935. * @param inputIndex Id of input to be checked
  55936. */
  55937. private _updateDevice;
  55938. /**
  55939. * Gets DeviceType from the device name
  55940. * @param deviceName Name of Device from DeviceInputSystem
  55941. * @returns DeviceType enum value
  55942. */
  55943. private _getGamepadDeviceType;
  55944. }
  55945. }
  55946. declare module BABYLON {
  55947. /**
  55948. * Type to handle enforcement of inputs
  55949. */
  55950. 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;
  55951. }
  55952. declare module BABYLON {
  55953. /**
  55954. * Class that handles all input for a specific device
  55955. */
  55956. export class DeviceSource<T extends DeviceType> {
  55957. /** Type of device */
  55958. readonly deviceType: DeviceType;
  55959. /** "Slot" or index that device is referenced in */
  55960. readonly deviceSlot: number;
  55961. /**
  55962. * Observable to handle device input changes per device
  55963. */
  55964. readonly onInputChangedObservable: Observable<{
  55965. inputIndex: DeviceInput<T>;
  55966. previousState: Nullable<number>;
  55967. currentState: Nullable<number>;
  55968. }>;
  55969. private readonly _deviceInputSystem;
  55970. /**
  55971. * Default Constructor
  55972. * @param deviceInputSystem Reference to DeviceInputSystem
  55973. * @param deviceType Type of device
  55974. * @param deviceSlot "Slot" or index that device is referenced in
  55975. */
  55976. constructor(deviceInputSystem: DeviceInputSystem,
  55977. /** Type of device */
  55978. deviceType: DeviceType,
  55979. /** "Slot" or index that device is referenced in */
  55980. deviceSlot?: number);
  55981. /**
  55982. * Get input for specific input
  55983. * @param inputIndex index of specific input on device
  55984. * @returns Input value from DeviceInputSystem
  55985. */
  55986. getInput(inputIndex: DeviceInput<T>): number;
  55987. }
  55988. /**
  55989. * Class to keep track of devices
  55990. */
  55991. export class DeviceSourceManager implements IDisposable {
  55992. /**
  55993. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  55994. */
  55995. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  55996. /**
  55997. * Observable to be triggered when after a device is disconnected
  55998. */
  55999. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  56000. private readonly _devices;
  56001. private readonly _firstDevice;
  56002. private readonly _deviceInputSystem;
  56003. /**
  56004. * Default Constructor
  56005. * @param engine engine to pull input element from
  56006. */
  56007. constructor(engine: Engine);
  56008. /**
  56009. * Gets a DeviceSource, given a type and slot
  56010. * @param deviceType Enum specifying device type
  56011. * @param deviceSlot "Slot" or index that device is referenced in
  56012. * @returns DeviceSource object
  56013. */
  56014. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  56015. /**
  56016. * Gets an array of DeviceSource objects for a given device type
  56017. * @param deviceType Enum specifying device type
  56018. * @returns Array of DeviceSource objects
  56019. */
  56020. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  56021. /**
  56022. * Returns a read-only list of all available devices
  56023. * @returns Read-only array with active devices
  56024. */
  56025. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  56026. /**
  56027. * Dispose of DeviceInputSystem and other parts
  56028. */
  56029. dispose(): void;
  56030. /**
  56031. * Function to add device name to device list
  56032. * @param deviceType Enum specifying device type
  56033. * @param deviceSlot "Slot" or index that device is referenced in
  56034. */
  56035. private _addDevice;
  56036. /**
  56037. * Function to remove device name to device list
  56038. * @param deviceType Enum specifying device type
  56039. * @param deviceSlot "Slot" or index that device is referenced in
  56040. */
  56041. private _removeDevice;
  56042. /**
  56043. * Updates array storing first connected device of each type
  56044. * @param type Type of Device
  56045. */
  56046. private _updateFirstDevices;
  56047. }
  56048. }
  56049. declare module BABYLON {
  56050. /**
  56051. * Options to create the null engine
  56052. */
  56053. export class NullEngineOptions {
  56054. /**
  56055. * Render width (Default: 512)
  56056. */
  56057. renderWidth: number;
  56058. /**
  56059. * Render height (Default: 256)
  56060. */
  56061. renderHeight: number;
  56062. /**
  56063. * Texture size (Default: 512)
  56064. */
  56065. textureSize: number;
  56066. /**
  56067. * If delta time between frames should be constant
  56068. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56069. */
  56070. deterministicLockstep: boolean;
  56071. /**
  56072. * Maximum about of steps between frames (Default: 4)
  56073. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56074. */
  56075. lockstepMaxSteps: number;
  56076. /**
  56077. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  56078. */
  56079. useHighPrecisionMatrix?: boolean;
  56080. }
  56081. /**
  56082. * The null engine class provides support for headless version of babylon.js.
  56083. * This can be used in server side scenario or for testing purposes
  56084. */
  56085. export class NullEngine extends Engine {
  56086. private _options;
  56087. /**
  56088. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  56089. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56090. * @returns true if engine is in deterministic lock step mode
  56091. */
  56092. isDeterministicLockStep(): boolean;
  56093. /**
  56094. * Gets the max steps when engine is running in deterministic lock step
  56095. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56096. * @returns the max steps
  56097. */
  56098. getLockstepMaxSteps(): number;
  56099. /**
  56100. * Gets the current hardware scaling level.
  56101. * By default the hardware scaling level is computed from the window device ratio.
  56102. * 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.
  56103. * @returns a number indicating the current hardware scaling level
  56104. */
  56105. getHardwareScalingLevel(): number;
  56106. constructor(options?: NullEngineOptions);
  56107. /**
  56108. * Creates a vertex buffer
  56109. * @param vertices the data for the vertex buffer
  56110. * @returns the new WebGL static buffer
  56111. */
  56112. createVertexBuffer(vertices: FloatArray): DataBuffer;
  56113. /**
  56114. * Creates a new index buffer
  56115. * @param indices defines the content of the index buffer
  56116. * @param updatable defines if the index buffer must be updatable
  56117. * @returns a new webGL buffer
  56118. */
  56119. createIndexBuffer(indices: IndicesArray): DataBuffer;
  56120. /**
  56121. * Clear the current render buffer or the current render target (if any is set up)
  56122. * @param color defines the color to use
  56123. * @param backBuffer defines if the back buffer must be cleared
  56124. * @param depth defines if the depth buffer must be cleared
  56125. * @param stencil defines if the stencil buffer must be cleared
  56126. */
  56127. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56128. /**
  56129. * Gets the current render width
  56130. * @param useScreen defines if screen size must be used (or the current render target if any)
  56131. * @returns a number defining the current render width
  56132. */
  56133. getRenderWidth(useScreen?: boolean): number;
  56134. /**
  56135. * Gets the current render height
  56136. * @param useScreen defines if screen size must be used (or the current render target if any)
  56137. * @returns a number defining the current render height
  56138. */
  56139. getRenderHeight(useScreen?: boolean): number;
  56140. /**
  56141. * Set the WebGL's viewport
  56142. * @param viewport defines the viewport element to be used
  56143. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  56144. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  56145. */
  56146. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  56147. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  56148. /**
  56149. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  56150. * @param pipelineContext defines the pipeline context to use
  56151. * @param uniformsNames defines the list of uniform names
  56152. * @returns an array of webGL uniform locations
  56153. */
  56154. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  56155. /**
  56156. * Gets the lsit of active attributes for a given webGL program
  56157. * @param pipelineContext defines the pipeline context to use
  56158. * @param attributesNames defines the list of attribute names to get
  56159. * @returns an array of indices indicating the offset of each attribute
  56160. */
  56161. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56162. /**
  56163. * Binds an effect to the webGL context
  56164. * @param effect defines the effect to bind
  56165. */
  56166. bindSamplers(effect: Effect): void;
  56167. /**
  56168. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  56169. * @param effect defines the effect to activate
  56170. */
  56171. enableEffect(effect: Effect): void;
  56172. /**
  56173. * Set various states to the webGL context
  56174. * @param culling defines backface culling state
  56175. * @param zOffset defines the value to apply to zOffset (0 by default)
  56176. * @param force defines if states must be applied even if cache is up to date
  56177. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  56178. */
  56179. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56180. /**
  56181. * Set the value of an uniform to an array of int32
  56182. * @param uniform defines the webGL uniform location where to store the value
  56183. * @param array defines the array of int32 to store
  56184. * @returns true if value was set
  56185. */
  56186. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56187. /**
  56188. * Set the value of an uniform to an array of int32 (stored as vec2)
  56189. * @param uniform defines the webGL uniform location where to store the value
  56190. * @param array defines the array of int32 to store
  56191. * @returns true if value was set
  56192. */
  56193. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56194. /**
  56195. * Set the value of an uniform to an array of int32 (stored as vec3)
  56196. * @param uniform defines the webGL uniform location where to store the value
  56197. * @param array defines the array of int32 to store
  56198. * @returns true if value was set
  56199. */
  56200. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56201. /**
  56202. * Set the value of an uniform to an array of int32 (stored as vec4)
  56203. * @param uniform defines the webGL uniform location where to store the value
  56204. * @param array defines the array of int32 to store
  56205. * @returns true if value was set
  56206. */
  56207. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56208. /**
  56209. * Set the value of an uniform to an array of float32
  56210. * @param uniform defines the webGL uniform location where to store the value
  56211. * @param array defines the array of float32 to store
  56212. * @returns true if value was set
  56213. */
  56214. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56215. /**
  56216. * Set the value of an uniform to an array of float32 (stored as vec2)
  56217. * @param uniform defines the webGL uniform location where to store the value
  56218. * @param array defines the array of float32 to store
  56219. * @returns true if value was set
  56220. */
  56221. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56222. /**
  56223. * Set the value of an uniform to an array of float32 (stored as vec3)
  56224. * @param uniform defines the webGL uniform location where to store the value
  56225. * @param array defines the array of float32 to store
  56226. * @returns true if value was set
  56227. */
  56228. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56229. /**
  56230. * Set the value of an uniform to an array of float32 (stored as vec4)
  56231. * @param uniform defines the webGL uniform location where to store the value
  56232. * @param array defines the array of float32 to store
  56233. * @returns true if value was set
  56234. */
  56235. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56236. /**
  56237. * Set the value of an uniform to an array of number
  56238. * @param uniform defines the webGL uniform location where to store the value
  56239. * @param array defines the array of number to store
  56240. * @returns true if value was set
  56241. */
  56242. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56243. /**
  56244. * Set the value of an uniform to an array of number (stored as vec2)
  56245. * @param uniform defines the webGL uniform location where to store the value
  56246. * @param array defines the array of number to store
  56247. * @returns true if value was set
  56248. */
  56249. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56250. /**
  56251. * Set the value of an uniform to an array of number (stored as vec3)
  56252. * @param uniform defines the webGL uniform location where to store the value
  56253. * @param array defines the array of number to store
  56254. * @returns true if value was set
  56255. */
  56256. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56257. /**
  56258. * Set the value of an uniform to an array of number (stored as vec4)
  56259. * @param uniform defines the webGL uniform location where to store the value
  56260. * @param array defines the array of number to store
  56261. * @returns true if value was set
  56262. */
  56263. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56264. /**
  56265. * Set the value of an uniform to an array of float32 (stored as matrices)
  56266. * @param uniform defines the webGL uniform location where to store the value
  56267. * @param matrices defines the array of float32 to store
  56268. * @returns true if value was set
  56269. */
  56270. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56271. /**
  56272. * Set the value of an uniform to a matrix (3x3)
  56273. * @param uniform defines the webGL uniform location where to store the value
  56274. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  56275. * @returns true if value was set
  56276. */
  56277. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56278. /**
  56279. * Set the value of an uniform to a matrix (2x2)
  56280. * @param uniform defines the webGL uniform location where to store the value
  56281. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  56282. * @returns true if value was set
  56283. */
  56284. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56285. /**
  56286. * Set the value of an uniform to a number (float)
  56287. * @param uniform defines the webGL uniform location where to store the value
  56288. * @param value defines the float number to store
  56289. * @returns true if value was set
  56290. */
  56291. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56292. /**
  56293. * Set the value of an uniform to a vec2
  56294. * @param uniform defines the webGL uniform location where to store the value
  56295. * @param x defines the 1st component of the value
  56296. * @param y defines the 2nd component of the value
  56297. * @returns true if value was set
  56298. */
  56299. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56300. /**
  56301. * Set the value of an uniform to a vec3
  56302. * @param uniform defines the webGL uniform location where to store the value
  56303. * @param x defines the 1st component of the value
  56304. * @param y defines the 2nd component of the value
  56305. * @param z defines the 3rd component of the value
  56306. * @returns true if value was set
  56307. */
  56308. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56309. /**
  56310. * Set the value of an uniform to a boolean
  56311. * @param uniform defines the webGL uniform location where to store the value
  56312. * @param bool defines the boolean to store
  56313. * @returns true if value was set
  56314. */
  56315. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  56316. /**
  56317. * Set the value of an uniform to a vec4
  56318. * @param uniform defines the webGL uniform location where to store the value
  56319. * @param x defines the 1st component of the value
  56320. * @param y defines the 2nd component of the value
  56321. * @param z defines the 3rd component of the value
  56322. * @param w defines the 4th component of the value
  56323. * @returns true if value was set
  56324. */
  56325. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56326. /**
  56327. * Sets the current alpha mode
  56328. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  56329. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56330. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56331. */
  56332. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56333. /**
  56334. * Bind webGl buffers directly to the webGL context
  56335. * @param vertexBuffers defines the vertex buffer to bind
  56336. * @param indexBuffer defines the index buffer to bind
  56337. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  56338. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  56339. * @param effect defines the effect associated with the vertex buffer
  56340. */
  56341. bindBuffers(vertexBuffers: {
  56342. [key: string]: VertexBuffer;
  56343. }, indexBuffer: DataBuffer, effect: Effect): void;
  56344. /**
  56345. * Force the entire cache to be cleared
  56346. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  56347. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  56348. */
  56349. wipeCaches(bruteForce?: boolean): void;
  56350. /**
  56351. * Send a draw order
  56352. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  56353. * @param indexStart defines the starting index
  56354. * @param indexCount defines the number of index to draw
  56355. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56356. */
  56357. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  56358. /**
  56359. * Draw a list of indexed primitives
  56360. * @param fillMode defines the primitive to use
  56361. * @param indexStart defines the starting index
  56362. * @param indexCount defines the number of index to draw
  56363. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56364. */
  56365. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56366. /**
  56367. * Draw a list of unindexed primitives
  56368. * @param fillMode defines the primitive to use
  56369. * @param verticesStart defines the index of first vertex to draw
  56370. * @param verticesCount defines the count of vertices to draw
  56371. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56372. */
  56373. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56374. /** @hidden */
  56375. _createTexture(): WebGLTexture;
  56376. /** @hidden */
  56377. _releaseTexture(texture: InternalTexture): void;
  56378. /**
  56379. * Usually called from Texture.ts.
  56380. * Passed information to create a WebGLTexture
  56381. * @param urlArg defines a value which contains one of the following:
  56382. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56383. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56384. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56385. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56386. * @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)
  56387. * @param scene needed for loading to the correct scene
  56388. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56389. * @param onLoad optional callback to be called upon successful completion
  56390. * @param onError optional callback to be called upon failure
  56391. * @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
  56392. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56393. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56394. * @param forcedExtension defines the extension to use to pick the right loader
  56395. * @param mimeType defines an optional mime type
  56396. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56397. */
  56398. 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;
  56399. /**
  56400. * Creates a new render target texture
  56401. * @param size defines the size of the texture
  56402. * @param options defines the options used to create the texture
  56403. * @returns a new render target texture stored in an InternalTexture
  56404. */
  56405. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  56406. /**
  56407. * Update the sampling mode of a given texture
  56408. * @param samplingMode defines the required sampling mode
  56409. * @param texture defines the texture to update
  56410. */
  56411. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56412. /**
  56413. * Binds the frame buffer to the specified texture.
  56414. * @param texture The texture to render to or null for the default canvas
  56415. * @param faceIndex The face of the texture to render to in case of cube texture
  56416. * @param requiredWidth The width of the target to render to
  56417. * @param requiredHeight The height of the target to render to
  56418. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  56419. * @param lodLevel defines le lod level to bind to the frame buffer
  56420. */
  56421. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56422. /**
  56423. * Unbind the current render target texture from the webGL context
  56424. * @param texture defines the render target texture to unbind
  56425. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  56426. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  56427. */
  56428. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56429. /**
  56430. * Creates a dynamic vertex buffer
  56431. * @param vertices the data for the dynamic vertex buffer
  56432. * @returns the new WebGL dynamic buffer
  56433. */
  56434. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  56435. /**
  56436. * Update the content of a dynamic texture
  56437. * @param texture defines the texture to update
  56438. * @param canvas defines the canvas containing the source
  56439. * @param invertY defines if data must be stored with Y axis inverted
  56440. * @param premulAlpha defines if alpha is stored as premultiplied
  56441. * @param format defines the format of the data
  56442. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56443. */
  56444. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56445. /**
  56446. * Gets a boolean indicating if all created effects are ready
  56447. * @returns true if all effects are ready
  56448. */
  56449. areAllEffectsReady(): boolean;
  56450. /**
  56451. * @hidden
  56452. * Get the current error code of the webGL context
  56453. * @returns the error code
  56454. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  56455. */
  56456. getError(): number;
  56457. /** @hidden */
  56458. _getUnpackAlignement(): number;
  56459. /** @hidden */
  56460. _unpackFlipY(value: boolean): void;
  56461. /**
  56462. * Update a dynamic index buffer
  56463. * @param indexBuffer defines the target index buffer
  56464. * @param indices defines the data to update
  56465. * @param offset defines the offset in the target index buffer where update should start
  56466. */
  56467. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  56468. /**
  56469. * Updates a dynamic vertex buffer.
  56470. * @param vertexBuffer the vertex buffer to update
  56471. * @param vertices the data used to update the vertex buffer
  56472. * @param byteOffset the byte offset of the data (optional)
  56473. * @param byteLength the byte length of the data (optional)
  56474. */
  56475. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  56476. /** @hidden */
  56477. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  56478. /** @hidden */
  56479. _bindTexture(channel: number, texture: InternalTexture): void;
  56480. protected _deleteBuffer(buffer: WebGLBuffer): void;
  56481. /**
  56482. * 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
  56483. */
  56484. releaseEffects(): void;
  56485. displayLoadingUI(): void;
  56486. hideLoadingUI(): void;
  56487. /** @hidden */
  56488. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56489. /** @hidden */
  56490. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56491. /** @hidden */
  56492. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56493. /** @hidden */
  56494. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56495. }
  56496. }
  56497. declare module BABYLON {
  56498. /**
  56499. * @hidden
  56500. **/
  56501. export class _TimeToken {
  56502. _startTimeQuery: Nullable<WebGLQuery>;
  56503. _endTimeQuery: Nullable<WebGLQuery>;
  56504. _timeElapsedQuery: Nullable<WebGLQuery>;
  56505. _timeElapsedQueryEnded: boolean;
  56506. }
  56507. }
  56508. declare module BABYLON {
  56509. /** @hidden */
  56510. export class _OcclusionDataStorage {
  56511. /** @hidden */
  56512. occlusionInternalRetryCounter: number;
  56513. /** @hidden */
  56514. isOcclusionQueryInProgress: boolean;
  56515. /** @hidden */
  56516. isOccluded: boolean;
  56517. /** @hidden */
  56518. occlusionRetryCount: number;
  56519. /** @hidden */
  56520. occlusionType: number;
  56521. /** @hidden */
  56522. occlusionQueryAlgorithmType: number;
  56523. }
  56524. interface Engine {
  56525. /**
  56526. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  56527. * @return the new query
  56528. */
  56529. createQuery(): WebGLQuery;
  56530. /**
  56531. * Delete and release a webGL query
  56532. * @param query defines the query to delete
  56533. * @return the current engine
  56534. */
  56535. deleteQuery(query: WebGLQuery): Engine;
  56536. /**
  56537. * Check if a given query has resolved and got its value
  56538. * @param query defines the query to check
  56539. * @returns true if the query got its value
  56540. */
  56541. isQueryResultAvailable(query: WebGLQuery): boolean;
  56542. /**
  56543. * Gets the value of a given query
  56544. * @param query defines the query to check
  56545. * @returns the value of the query
  56546. */
  56547. getQueryResult(query: WebGLQuery): number;
  56548. /**
  56549. * Initiates an occlusion query
  56550. * @param algorithmType defines the algorithm to use
  56551. * @param query defines the query to use
  56552. * @returns the current engine
  56553. * @see https://doc.babylonjs.com/features/occlusionquery
  56554. */
  56555. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  56556. /**
  56557. * Ends an occlusion query
  56558. * @see https://doc.babylonjs.com/features/occlusionquery
  56559. * @param algorithmType defines the algorithm to use
  56560. * @returns the current engine
  56561. */
  56562. endOcclusionQuery(algorithmType: number): Engine;
  56563. /**
  56564. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  56565. * Please note that only one query can be issued at a time
  56566. * @returns a time token used to track the time span
  56567. */
  56568. startTimeQuery(): Nullable<_TimeToken>;
  56569. /**
  56570. * Ends a time query
  56571. * @param token defines the token used to measure the time span
  56572. * @returns the time spent (in ns)
  56573. */
  56574. endTimeQuery(token: _TimeToken): int;
  56575. /** @hidden */
  56576. _currentNonTimestampToken: Nullable<_TimeToken>;
  56577. /** @hidden */
  56578. _createTimeQuery(): WebGLQuery;
  56579. /** @hidden */
  56580. _deleteTimeQuery(query: WebGLQuery): void;
  56581. /** @hidden */
  56582. _getGlAlgorithmType(algorithmType: number): number;
  56583. /** @hidden */
  56584. _getTimeQueryResult(query: WebGLQuery): any;
  56585. /** @hidden */
  56586. _getTimeQueryAvailability(query: WebGLQuery): any;
  56587. }
  56588. interface AbstractMesh {
  56589. /**
  56590. * Backing filed
  56591. * @hidden
  56592. */
  56593. __occlusionDataStorage: _OcclusionDataStorage;
  56594. /**
  56595. * Access property
  56596. * @hidden
  56597. */
  56598. _occlusionDataStorage: _OcclusionDataStorage;
  56599. /**
  56600. * 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.
  56601. * The default value is -1 which means don't break the query and wait till the result
  56602. * @see https://doc.babylonjs.com/features/occlusionquery
  56603. */
  56604. occlusionRetryCount: number;
  56605. /**
  56606. * 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:
  56607. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  56608. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  56609. * * 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.
  56610. * @see https://doc.babylonjs.com/features/occlusionquery
  56611. */
  56612. occlusionType: number;
  56613. /**
  56614. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  56615. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  56616. * * 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.
  56617. * @see https://doc.babylonjs.com/features/occlusionquery
  56618. */
  56619. occlusionQueryAlgorithmType: number;
  56620. /**
  56621. * 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
  56622. * @see https://doc.babylonjs.com/features/occlusionquery
  56623. */
  56624. isOccluded: boolean;
  56625. /**
  56626. * Flag to check the progress status of the query
  56627. * @see https://doc.babylonjs.com/features/occlusionquery
  56628. */
  56629. isOcclusionQueryInProgress: boolean;
  56630. }
  56631. }
  56632. declare module BABYLON {
  56633. /** @hidden */
  56634. export var _forceTransformFeedbackToBundle: boolean;
  56635. interface Engine {
  56636. /**
  56637. * Creates a webGL transform feedback object
  56638. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  56639. * @returns the webGL transform feedback object
  56640. */
  56641. createTransformFeedback(): WebGLTransformFeedback;
  56642. /**
  56643. * Delete a webGL transform feedback object
  56644. * @param value defines the webGL transform feedback object to delete
  56645. */
  56646. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  56647. /**
  56648. * Bind a webGL transform feedback object to the webgl context
  56649. * @param value defines the webGL transform feedback object to bind
  56650. */
  56651. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  56652. /**
  56653. * Begins a transform feedback operation
  56654. * @param usePoints defines if points or triangles must be used
  56655. */
  56656. beginTransformFeedback(usePoints: boolean): void;
  56657. /**
  56658. * Ends a transform feedback operation
  56659. */
  56660. endTransformFeedback(): void;
  56661. /**
  56662. * Specify the varyings to use with transform feedback
  56663. * @param program defines the associated webGL program
  56664. * @param value defines the list of strings representing the varying names
  56665. */
  56666. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  56667. /**
  56668. * Bind a webGL buffer for a transform feedback operation
  56669. * @param value defines the webGL buffer to bind
  56670. */
  56671. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  56672. }
  56673. }
  56674. declare module BABYLON {
  56675. /**
  56676. * Class used to define an additional view for the engine
  56677. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56678. */
  56679. export class EngineView {
  56680. /** Defines the canvas where to render the view */
  56681. target: HTMLCanvasElement;
  56682. /** Defines an optional camera used to render the view (will use active camera else) */
  56683. camera?: Camera;
  56684. }
  56685. interface Engine {
  56686. /**
  56687. * Gets or sets the HTML element to use for attaching events
  56688. */
  56689. inputElement: Nullable<HTMLElement>;
  56690. /**
  56691. * Gets the current engine view
  56692. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56693. */
  56694. activeView: Nullable<EngineView>;
  56695. /** Gets or sets the list of views */
  56696. views: EngineView[];
  56697. /**
  56698. * Register a new child canvas
  56699. * @param canvas defines the canvas to register
  56700. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  56701. * @returns the associated view
  56702. */
  56703. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  56704. /**
  56705. * Remove a registered child canvas
  56706. * @param canvas defines the canvas to remove
  56707. * @returns the current engine
  56708. */
  56709. unRegisterView(canvas: HTMLCanvasElement): Engine;
  56710. }
  56711. }
  56712. declare module BABYLON {
  56713. interface Engine {
  56714. /** @hidden */
  56715. _excludedCompressedTextures: string[];
  56716. /** @hidden */
  56717. _textureFormatInUse: string;
  56718. /**
  56719. * Gets the list of texture formats supported
  56720. */
  56721. readonly texturesSupported: Array<string>;
  56722. /**
  56723. * Gets the texture format in use
  56724. */
  56725. readonly textureFormatInUse: Nullable<string>;
  56726. /**
  56727. * Set the compressed texture extensions or file names to skip.
  56728. *
  56729. * @param skippedFiles defines the list of those texture files you want to skip
  56730. * Example: [".dds", ".env", "myfile.png"]
  56731. */
  56732. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  56733. /**
  56734. * Set the compressed texture format to use, based on the formats you have, and the formats
  56735. * supported by the hardware / browser.
  56736. *
  56737. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  56738. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  56739. * to API arguments needed to compressed textures. This puts the burden on the container
  56740. * generator to house the arcane code for determining these for current & future formats.
  56741. *
  56742. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56743. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56744. *
  56745. * Note: The result of this call is not taken into account when a texture is base64.
  56746. *
  56747. * @param formatsAvailable defines the list of those format families you have created
  56748. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  56749. *
  56750. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  56751. * @returns The extension selected.
  56752. */
  56753. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  56754. }
  56755. }
  56756. declare module BABYLON {
  56757. /** @hidden */
  56758. export var rgbdEncodePixelShader: {
  56759. name: string;
  56760. shader: string;
  56761. };
  56762. }
  56763. declare module BABYLON {
  56764. /**
  56765. * Raw texture data and descriptor sufficient for WebGL texture upload
  56766. */
  56767. export interface EnvironmentTextureInfo {
  56768. /**
  56769. * Version of the environment map
  56770. */
  56771. version: number;
  56772. /**
  56773. * Width of image
  56774. */
  56775. width: number;
  56776. /**
  56777. * Irradiance information stored in the file.
  56778. */
  56779. irradiance: any;
  56780. /**
  56781. * Specular information stored in the file.
  56782. */
  56783. specular: any;
  56784. }
  56785. /**
  56786. * Defines One Image in the file. It requires only the position in the file
  56787. * as well as the length.
  56788. */
  56789. interface BufferImageData {
  56790. /**
  56791. * Length of the image data.
  56792. */
  56793. length: number;
  56794. /**
  56795. * Position of the data from the null terminator delimiting the end of the JSON.
  56796. */
  56797. position: number;
  56798. }
  56799. /**
  56800. * Defines the specular data enclosed in the file.
  56801. * This corresponds to the version 1 of the data.
  56802. */
  56803. export interface EnvironmentTextureSpecularInfoV1 {
  56804. /**
  56805. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  56806. */
  56807. specularDataPosition?: number;
  56808. /**
  56809. * This contains all the images data needed to reconstruct the cubemap.
  56810. */
  56811. mipmaps: Array<BufferImageData>;
  56812. /**
  56813. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  56814. */
  56815. lodGenerationScale: number;
  56816. }
  56817. /**
  56818. * Sets of helpers addressing the serialization and deserialization of environment texture
  56819. * stored in a BabylonJS env file.
  56820. * Those files are usually stored as .env files.
  56821. */
  56822. export class EnvironmentTextureTools {
  56823. /**
  56824. * Magic number identifying the env file.
  56825. */
  56826. private static _MagicBytes;
  56827. /**
  56828. * Gets the environment info from an env file.
  56829. * @param data The array buffer containing the .env bytes.
  56830. * @returns the environment file info (the json header) if successfully parsed.
  56831. */
  56832. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  56833. /**
  56834. * Creates an environment texture from a loaded cube texture.
  56835. * @param texture defines the cube texture to convert in env file
  56836. * @return a promise containing the environment data if succesfull.
  56837. */
  56838. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  56839. /**
  56840. * Creates a JSON representation of the spherical data.
  56841. * @param texture defines the texture containing the polynomials
  56842. * @return the JSON representation of the spherical info
  56843. */
  56844. private static _CreateEnvTextureIrradiance;
  56845. /**
  56846. * Creates the ArrayBufferViews used for initializing environment texture image data.
  56847. * @param data the image data
  56848. * @param info parameters that determine what views will be created for accessing the underlying buffer
  56849. * @return the views described by info providing access to the underlying buffer
  56850. */
  56851. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  56852. /**
  56853. * Uploads the texture info contained in the env file to the GPU.
  56854. * @param texture defines the internal texture to upload to
  56855. * @param data defines the data to load
  56856. * @param info defines the texture info retrieved through the GetEnvInfo method
  56857. * @returns a promise
  56858. */
  56859. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  56860. private static _OnImageReadyAsync;
  56861. /**
  56862. * Uploads the levels of image data to the GPU.
  56863. * @param texture defines the internal texture to upload to
  56864. * @param imageData defines the array buffer views of image data [mipmap][face]
  56865. * @returns a promise
  56866. */
  56867. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  56868. /**
  56869. * Uploads spherical polynomials information to the texture.
  56870. * @param texture defines the texture we are trying to upload the information to
  56871. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  56872. */
  56873. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  56874. /** @hidden */
  56875. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56876. }
  56877. }
  56878. declare module BABYLON {
  56879. /**
  56880. * Class used to inline functions in shader code
  56881. */
  56882. export class ShaderCodeInliner {
  56883. private static readonly _RegexpFindFunctionNameAndType;
  56884. private _sourceCode;
  56885. private _functionDescr;
  56886. private _numMaxIterations;
  56887. /** Gets or sets the token used to mark the functions to inline */
  56888. inlineToken: string;
  56889. /** Gets or sets the debug mode */
  56890. debug: boolean;
  56891. /** Gets the code after the inlining process */
  56892. get code(): string;
  56893. /**
  56894. * Initializes the inliner
  56895. * @param sourceCode shader code source to inline
  56896. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  56897. */
  56898. constructor(sourceCode: string, numMaxIterations?: number);
  56899. /**
  56900. * Start the processing of the shader code
  56901. */
  56902. processCode(): void;
  56903. private _collectFunctions;
  56904. private _processInlining;
  56905. private _extractBetweenMarkers;
  56906. private _skipWhitespaces;
  56907. private _removeComments;
  56908. private _replaceFunctionCallsByCode;
  56909. private _findBackward;
  56910. private _escapeRegExp;
  56911. private _replaceNames;
  56912. }
  56913. }
  56914. declare module BABYLON {
  56915. /**
  56916. * Container for accessors for natively-stored mesh data buffers.
  56917. */
  56918. class NativeDataBuffer extends DataBuffer {
  56919. /**
  56920. * Accessor value used to identify/retrieve a natively-stored index buffer.
  56921. */
  56922. nativeIndexBuffer?: any;
  56923. /**
  56924. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  56925. */
  56926. nativeVertexBuffer?: any;
  56927. }
  56928. /** @hidden */
  56929. class NativeTexture extends InternalTexture {
  56930. getInternalTexture(): InternalTexture;
  56931. getViewCount(): number;
  56932. }
  56933. /** @hidden */
  56934. export class NativeEngine extends Engine {
  56935. private readonly _native;
  56936. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  56937. private readonly INVALID_HANDLE;
  56938. private _boundBuffersVertexArray;
  56939. private _currentDepthTest;
  56940. getHardwareScalingLevel(): number;
  56941. constructor();
  56942. dispose(): void;
  56943. /**
  56944. * Can be used to override the current requestAnimationFrame requester.
  56945. * @hidden
  56946. */
  56947. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  56948. /**
  56949. * Override default engine behavior.
  56950. * @param color
  56951. * @param backBuffer
  56952. * @param depth
  56953. * @param stencil
  56954. */
  56955. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  56956. /**
  56957. * Gets host document
  56958. * @returns the host document object
  56959. */
  56960. getHostDocument(): Nullable<Document>;
  56961. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56962. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  56963. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  56964. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  56965. [key: string]: VertexBuffer;
  56966. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56967. bindBuffers(vertexBuffers: {
  56968. [key: string]: VertexBuffer;
  56969. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56970. recordVertexArrayObject(vertexBuffers: {
  56971. [key: string]: VertexBuffer;
  56972. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  56973. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56974. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56975. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56976. /**
  56977. * Draw a list of indexed primitives
  56978. * @param fillMode defines the primitive to use
  56979. * @param indexStart defines the starting index
  56980. * @param indexCount defines the number of index to draw
  56981. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56982. */
  56983. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56984. /**
  56985. * Draw a list of unindexed primitives
  56986. * @param fillMode defines the primitive to use
  56987. * @param verticesStart defines the index of first vertex to draw
  56988. * @param verticesCount defines the count of vertices to draw
  56989. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56990. */
  56991. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56992. createPipelineContext(): IPipelineContext;
  56993. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  56994. /** @hidden */
  56995. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  56996. /** @hidden */
  56997. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  56998. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56999. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57000. protected _setProgram(program: WebGLProgram): void;
  57001. _releaseEffect(effect: Effect): void;
  57002. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  57003. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  57004. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  57005. bindSamplers(effect: Effect): void;
  57006. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  57007. getRenderWidth(useScreen?: boolean): number;
  57008. getRenderHeight(useScreen?: boolean): number;
  57009. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  57010. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57011. /**
  57012. * Set the z offset to apply to current rendering
  57013. * @param value defines the offset to apply
  57014. */
  57015. setZOffset(value: number): void;
  57016. /**
  57017. * Gets the current value of the zOffset
  57018. * @returns the current zOffset state
  57019. */
  57020. getZOffset(): number;
  57021. /**
  57022. * Enable or disable depth buffering
  57023. * @param enable defines the state to set
  57024. */
  57025. setDepthBuffer(enable: boolean): void;
  57026. /**
  57027. * Gets a boolean indicating if depth writing is enabled
  57028. * @returns the current depth writing state
  57029. */
  57030. getDepthWrite(): boolean;
  57031. setDepthFunctionToGreater(): void;
  57032. setDepthFunctionToGreaterOrEqual(): void;
  57033. setDepthFunctionToLess(): void;
  57034. setDepthFunctionToLessOrEqual(): void;
  57035. /**
  57036. * Enable or disable depth writing
  57037. * @param enable defines the state to set
  57038. */
  57039. setDepthWrite(enable: boolean): void;
  57040. /**
  57041. * Enable or disable color writing
  57042. * @param enable defines the state to set
  57043. */
  57044. setColorWrite(enable: boolean): void;
  57045. /**
  57046. * Gets a boolean indicating if color writing is enabled
  57047. * @returns the current color writing state
  57048. */
  57049. getColorWrite(): boolean;
  57050. /**
  57051. * Sets alpha constants used by some alpha blending modes
  57052. * @param r defines the red component
  57053. * @param g defines the green component
  57054. * @param b defines the blue component
  57055. * @param a defines the alpha component
  57056. */
  57057. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  57058. /**
  57059. * Sets the current alpha mode
  57060. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  57061. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57062. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57063. */
  57064. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57065. /**
  57066. * Gets the current alpha mode
  57067. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57068. * @returns the current alpha mode
  57069. */
  57070. getAlphaMode(): number;
  57071. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  57072. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57073. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57074. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57075. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57076. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57077. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57078. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57079. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57080. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57081. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57082. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57083. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57084. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57085. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57086. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57087. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57088. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57089. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57090. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57091. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  57092. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  57093. wipeCaches(bruteForce?: boolean): void;
  57094. _createTexture(): WebGLTexture;
  57095. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  57096. /**
  57097. * Update the content of a dynamic texture
  57098. * @param texture defines the texture to update
  57099. * @param canvas defines the canvas containing the source
  57100. * @param invertY defines if data must be stored with Y axis inverted
  57101. * @param premulAlpha defines if alpha is stored as premultiplied
  57102. * @param format defines the format of the data
  57103. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57104. */
  57105. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57106. /**
  57107. * Usually called from Texture.ts.
  57108. * Passed information to create a WebGLTexture
  57109. * @param url defines a value which contains one of the following:
  57110. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57111. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57112. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57113. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57114. * @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)
  57115. * @param scene needed for loading to the correct scene
  57116. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57117. * @param onLoad optional callback to be called upon successful completion
  57118. * @param onError optional callback to be called upon failure
  57119. * @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
  57120. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57121. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57122. * @param forcedExtension defines the extension to use to pick the right loader
  57123. * @param mimeType defines an optional mime type
  57124. * @param loaderOptions options to be passed to the loader
  57125. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57126. */
  57127. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any): InternalTexture;
  57128. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  57129. _releaseFramebufferObjects(texture: InternalTexture): void;
  57130. /**
  57131. * Creates a cube texture
  57132. * @param rootUrl defines the url where the files to load is located
  57133. * @param scene defines the current scene
  57134. * @param files defines the list of files to load (1 per face)
  57135. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  57136. * @param onLoad defines an optional callback raised when the texture is loaded
  57137. * @param onError defines an optional callback raised if there is an issue to load the texture
  57138. * @param format defines the format of the data
  57139. * @param forcedExtension defines the extension to use to pick the right loader
  57140. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  57141. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57142. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57143. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  57144. * @returns the cube texture as an InternalTexture
  57145. */
  57146. 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;
  57147. createRenderTargetTexture(size: number | {
  57148. width: number;
  57149. height: number;
  57150. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  57151. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57152. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57153. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57154. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  57155. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  57156. /**
  57157. * Updates a dynamic vertex buffer.
  57158. * @param vertexBuffer the vertex buffer to update
  57159. * @param data the data used to update the vertex buffer
  57160. * @param byteOffset the byte offset of the data (optional)
  57161. * @param byteLength the byte length of the data (optional)
  57162. */
  57163. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  57164. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  57165. private _updateAnisotropicLevel;
  57166. private _getAddressMode;
  57167. /** @hidden */
  57168. _bindTexture(channel: number, texture: InternalTexture): void;
  57169. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  57170. releaseEffects(): void;
  57171. /** @hidden */
  57172. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57173. /** @hidden */
  57174. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57175. /** @hidden */
  57176. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57177. /** @hidden */
  57178. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57179. private _getNativeSamplingMode;
  57180. private _getNativeTextureFormat;
  57181. private _getNativeAlphaMode;
  57182. private _getNativeAttribType;
  57183. }
  57184. }
  57185. declare module BABYLON {
  57186. /**
  57187. * Gather the list of clipboard event types as constants.
  57188. */
  57189. export class ClipboardEventTypes {
  57190. /**
  57191. * The clipboard event is fired when a copy command is active (pressed).
  57192. */
  57193. static readonly COPY: number;
  57194. /**
  57195. * The clipboard event is fired when a cut command is active (pressed).
  57196. */
  57197. static readonly CUT: number;
  57198. /**
  57199. * The clipboard event is fired when a paste command is active (pressed).
  57200. */
  57201. static readonly PASTE: number;
  57202. }
  57203. /**
  57204. * This class is used to store clipboard related info for the onClipboardObservable event.
  57205. */
  57206. export class ClipboardInfo {
  57207. /**
  57208. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57209. */
  57210. type: number;
  57211. /**
  57212. * Defines the related dom event
  57213. */
  57214. event: ClipboardEvent;
  57215. /**
  57216. *Creates an instance of ClipboardInfo.
  57217. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  57218. * @param event Defines the related dom event
  57219. */
  57220. constructor(
  57221. /**
  57222. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57223. */
  57224. type: number,
  57225. /**
  57226. * Defines the related dom event
  57227. */
  57228. event: ClipboardEvent);
  57229. /**
  57230. * Get the clipboard event's type from the keycode.
  57231. * @param keyCode Defines the keyCode for the current keyboard event.
  57232. * @return {number}
  57233. */
  57234. static GetTypeFromCharacter(keyCode: number): number;
  57235. }
  57236. }
  57237. declare module BABYLON {
  57238. /**
  57239. * Google Daydream controller
  57240. */
  57241. export class DaydreamController extends WebVRController {
  57242. /**
  57243. * Base Url for the controller model.
  57244. */
  57245. static MODEL_BASE_URL: string;
  57246. /**
  57247. * File name for the controller model.
  57248. */
  57249. static MODEL_FILENAME: string;
  57250. /**
  57251. * Gamepad Id prefix used to identify Daydream Controller.
  57252. */
  57253. static readonly GAMEPAD_ID_PREFIX: string;
  57254. /**
  57255. * Creates a new DaydreamController from a gamepad
  57256. * @param vrGamepad the gamepad that the controller should be created from
  57257. */
  57258. constructor(vrGamepad: any);
  57259. /**
  57260. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57261. * @param scene scene in which to add meshes
  57262. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57263. */
  57264. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57265. /**
  57266. * Called once for each button that changed state since the last frame
  57267. * @param buttonIdx Which button index changed
  57268. * @param state New state of the button
  57269. * @param changes Which properties on the state changed since last frame
  57270. */
  57271. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57272. }
  57273. }
  57274. declare module BABYLON {
  57275. /**
  57276. * Gear VR Controller
  57277. */
  57278. export class GearVRController extends WebVRController {
  57279. /**
  57280. * Base Url for the controller model.
  57281. */
  57282. static MODEL_BASE_URL: string;
  57283. /**
  57284. * File name for the controller model.
  57285. */
  57286. static MODEL_FILENAME: string;
  57287. /**
  57288. * Gamepad Id prefix used to identify this controller.
  57289. */
  57290. static readonly GAMEPAD_ID_PREFIX: string;
  57291. private readonly _buttonIndexToObservableNameMap;
  57292. /**
  57293. * Creates a new GearVRController from a gamepad
  57294. * @param vrGamepad the gamepad that the controller should be created from
  57295. */
  57296. constructor(vrGamepad: any);
  57297. /**
  57298. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57299. * @param scene scene in which to add meshes
  57300. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57301. */
  57302. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57303. /**
  57304. * Called once for each button that changed state since the last frame
  57305. * @param buttonIdx Which button index changed
  57306. * @param state New state of the button
  57307. * @param changes Which properties on the state changed since last frame
  57308. */
  57309. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57310. }
  57311. }
  57312. declare module BABYLON {
  57313. /**
  57314. * Generic Controller
  57315. */
  57316. export class GenericController extends WebVRController {
  57317. /**
  57318. * Base Url for the controller model.
  57319. */
  57320. static readonly MODEL_BASE_URL: string;
  57321. /**
  57322. * File name for the controller model.
  57323. */
  57324. static readonly MODEL_FILENAME: string;
  57325. /**
  57326. * Creates a new GenericController from a gamepad
  57327. * @param vrGamepad the gamepad that the controller should be created from
  57328. */
  57329. constructor(vrGamepad: any);
  57330. /**
  57331. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57332. * @param scene scene in which to add meshes
  57333. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57334. */
  57335. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57336. /**
  57337. * Called once for each button that changed state since the last frame
  57338. * @param buttonIdx Which button index changed
  57339. * @param state New state of the button
  57340. * @param changes Which properties on the state changed since last frame
  57341. */
  57342. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57343. }
  57344. }
  57345. declare module BABYLON {
  57346. /**
  57347. * Oculus Touch Controller
  57348. */
  57349. export class OculusTouchController extends WebVRController {
  57350. /**
  57351. * Base Url for the controller model.
  57352. */
  57353. static MODEL_BASE_URL: string;
  57354. /**
  57355. * File name for the left controller model.
  57356. */
  57357. static MODEL_LEFT_FILENAME: string;
  57358. /**
  57359. * File name for the right controller model.
  57360. */
  57361. static MODEL_RIGHT_FILENAME: string;
  57362. /**
  57363. * Base Url for the Quest controller model.
  57364. */
  57365. static QUEST_MODEL_BASE_URL: string;
  57366. /**
  57367. * @hidden
  57368. * If the controllers are running on a device that needs the updated Quest controller models
  57369. */
  57370. static _IsQuest: boolean;
  57371. /**
  57372. * Fired when the secondary trigger on this controller is modified
  57373. */
  57374. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  57375. /**
  57376. * Fired when the thumb rest on this controller is modified
  57377. */
  57378. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  57379. /**
  57380. * Creates a new OculusTouchController from a gamepad
  57381. * @param vrGamepad the gamepad that the controller should be created from
  57382. */
  57383. constructor(vrGamepad: any);
  57384. /**
  57385. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57386. * @param scene scene in which to add meshes
  57387. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57388. */
  57389. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57390. /**
  57391. * Fired when the A button on this controller is modified
  57392. */
  57393. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57394. /**
  57395. * Fired when the B button on this controller is modified
  57396. */
  57397. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57398. /**
  57399. * Fired when the X button on this controller is modified
  57400. */
  57401. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57402. /**
  57403. * Fired when the Y button on this controller is modified
  57404. */
  57405. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57406. /**
  57407. * Called once for each button that changed state since the last frame
  57408. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  57409. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  57410. * 2) secondary trigger (same)
  57411. * 3) A (right) X (left), touch, pressed = value
  57412. * 4) B / Y
  57413. * 5) thumb rest
  57414. * @param buttonIdx Which button index changed
  57415. * @param state New state of the button
  57416. * @param changes Which properties on the state changed since last frame
  57417. */
  57418. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57419. }
  57420. }
  57421. declare module BABYLON {
  57422. /**
  57423. * Vive Controller
  57424. */
  57425. export class ViveController extends WebVRController {
  57426. /**
  57427. * Base Url for the controller model.
  57428. */
  57429. static MODEL_BASE_URL: string;
  57430. /**
  57431. * File name for the controller model.
  57432. */
  57433. static MODEL_FILENAME: string;
  57434. /**
  57435. * Creates a new ViveController from a gamepad
  57436. * @param vrGamepad the gamepad that the controller should be created from
  57437. */
  57438. constructor(vrGamepad: any);
  57439. /**
  57440. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57441. * @param scene scene in which to add meshes
  57442. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57443. */
  57444. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57445. /**
  57446. * Fired when the left button on this controller is modified
  57447. */
  57448. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57449. /**
  57450. * Fired when the right button on this controller is modified
  57451. */
  57452. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57453. /**
  57454. * Fired when the menu button on this controller is modified
  57455. */
  57456. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57457. /**
  57458. * Called once for each button that changed state since the last frame
  57459. * Vive mapping:
  57460. * 0: touchpad
  57461. * 1: trigger
  57462. * 2: left AND right buttons
  57463. * 3: menu button
  57464. * @param buttonIdx Which button index changed
  57465. * @param state New state of the button
  57466. * @param changes Which properties on the state changed since last frame
  57467. */
  57468. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57469. }
  57470. }
  57471. declare module BABYLON {
  57472. /**
  57473. * Defines the WindowsMotionController object that the state of the windows motion controller
  57474. */
  57475. export class WindowsMotionController extends WebVRController {
  57476. /**
  57477. * The base url used to load the left and right controller models
  57478. */
  57479. static MODEL_BASE_URL: string;
  57480. /**
  57481. * The name of the left controller model file
  57482. */
  57483. static MODEL_LEFT_FILENAME: string;
  57484. /**
  57485. * The name of the right controller model file
  57486. */
  57487. static MODEL_RIGHT_FILENAME: string;
  57488. /**
  57489. * The controller name prefix for this controller type
  57490. */
  57491. static readonly GAMEPAD_ID_PREFIX: string;
  57492. /**
  57493. * The controller id pattern for this controller type
  57494. */
  57495. private static readonly GAMEPAD_ID_PATTERN;
  57496. private _loadedMeshInfo;
  57497. protected readonly _mapping: {
  57498. buttons: string[];
  57499. buttonMeshNames: {
  57500. trigger: string;
  57501. menu: string;
  57502. grip: string;
  57503. thumbstick: string;
  57504. trackpad: string;
  57505. };
  57506. buttonObservableNames: {
  57507. trigger: string;
  57508. menu: string;
  57509. grip: string;
  57510. thumbstick: string;
  57511. trackpad: string;
  57512. };
  57513. axisMeshNames: string[];
  57514. pointingPoseMeshName: string;
  57515. };
  57516. /**
  57517. * Fired when the trackpad on this controller is clicked
  57518. */
  57519. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57520. /**
  57521. * Fired when the trackpad on this controller is modified
  57522. */
  57523. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57524. /**
  57525. * The current x and y values of this controller's trackpad
  57526. */
  57527. trackpad: StickValues;
  57528. /**
  57529. * Creates a new WindowsMotionController from a gamepad
  57530. * @param vrGamepad the gamepad that the controller should be created from
  57531. */
  57532. constructor(vrGamepad: any);
  57533. /**
  57534. * Fired when the trigger on this controller is modified
  57535. */
  57536. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57537. /**
  57538. * Fired when the menu button on this controller is modified
  57539. */
  57540. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57541. /**
  57542. * Fired when the grip button on this controller is modified
  57543. */
  57544. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57545. /**
  57546. * Fired when the thumbstick button on this controller is modified
  57547. */
  57548. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57549. /**
  57550. * Fired when the touchpad button on this controller is modified
  57551. */
  57552. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57553. /**
  57554. * Fired when the touchpad values on this controller are modified
  57555. */
  57556. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  57557. protected _updateTrackpad(): void;
  57558. /**
  57559. * Called once per frame by the engine.
  57560. */
  57561. update(): void;
  57562. /**
  57563. * Called once for each button that changed state since the last frame
  57564. * @param buttonIdx Which button index changed
  57565. * @param state New state of the button
  57566. * @param changes Which properties on the state changed since last frame
  57567. */
  57568. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57569. /**
  57570. * Moves the buttons on the controller mesh based on their current state
  57571. * @param buttonName the name of the button to move
  57572. * @param buttonValue the value of the button which determines the buttons new position
  57573. */
  57574. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  57575. /**
  57576. * Moves the axis on the controller mesh based on its current state
  57577. * @param axis the index of the axis
  57578. * @param axisValue the value of the axis which determines the meshes new position
  57579. * @hidden
  57580. */
  57581. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  57582. /**
  57583. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57584. * @param scene scene in which to add meshes
  57585. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57586. */
  57587. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  57588. /**
  57589. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  57590. * can be transformed by button presses and axes values, based on this._mapping.
  57591. *
  57592. * @param scene scene in which the meshes exist
  57593. * @param meshes list of meshes that make up the controller model to process
  57594. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  57595. */
  57596. private processModel;
  57597. private createMeshInfo;
  57598. /**
  57599. * Gets the ray of the controller in the direction the controller is pointing
  57600. * @param length the length the resulting ray should be
  57601. * @returns a ray in the direction the controller is pointing
  57602. */
  57603. getForwardRay(length?: number): Ray;
  57604. /**
  57605. * Disposes of the controller
  57606. */
  57607. dispose(): void;
  57608. }
  57609. /**
  57610. * This class represents a new windows motion controller in XR.
  57611. */
  57612. export class XRWindowsMotionController extends WindowsMotionController {
  57613. /**
  57614. * Changing the original WIndowsMotionController mapping to fir the new mapping
  57615. */
  57616. protected readonly _mapping: {
  57617. buttons: string[];
  57618. buttonMeshNames: {
  57619. trigger: string;
  57620. menu: string;
  57621. grip: string;
  57622. thumbstick: string;
  57623. trackpad: string;
  57624. };
  57625. buttonObservableNames: {
  57626. trigger: string;
  57627. menu: string;
  57628. grip: string;
  57629. thumbstick: string;
  57630. trackpad: string;
  57631. };
  57632. axisMeshNames: string[];
  57633. pointingPoseMeshName: string;
  57634. };
  57635. /**
  57636. * Construct a new XR-Based windows motion controller
  57637. *
  57638. * @param gamepadInfo the gamepad object from the browser
  57639. */
  57640. constructor(gamepadInfo: any);
  57641. /**
  57642. * holds the thumbstick values (X,Y)
  57643. */
  57644. thumbstickValues: StickValues;
  57645. /**
  57646. * Fired when the thumbstick on this controller is clicked
  57647. */
  57648. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  57649. /**
  57650. * Fired when the thumbstick on this controller is modified
  57651. */
  57652. onThumbstickValuesChangedObservable: Observable<StickValues>;
  57653. /**
  57654. * Fired when the touchpad button on this controller is modified
  57655. */
  57656. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57657. /**
  57658. * Fired when the touchpad values on this controller are modified
  57659. */
  57660. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57661. /**
  57662. * Fired when the thumbstick button on this controller is modified
  57663. * here to prevent breaking changes
  57664. */
  57665. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57666. /**
  57667. * updating the thumbstick(!) and not the trackpad.
  57668. * This is named this way due to the difference between WebVR and XR and to avoid
  57669. * changing the parent class.
  57670. */
  57671. protected _updateTrackpad(): void;
  57672. /**
  57673. * Disposes the class with joy
  57674. */
  57675. dispose(): void;
  57676. }
  57677. }
  57678. declare module BABYLON {
  57679. /**
  57680. * A directional light is defined by a direction (what a surprise!).
  57681. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57682. * 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.
  57683. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57684. */
  57685. export class DirectionalLight extends ShadowLight {
  57686. private _shadowFrustumSize;
  57687. /**
  57688. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57689. */
  57690. get shadowFrustumSize(): number;
  57691. /**
  57692. * Specifies a fix frustum size for the shadow generation.
  57693. */
  57694. set shadowFrustumSize(value: number);
  57695. private _shadowOrthoScale;
  57696. /**
  57697. * Gets the shadow projection scale against the optimal computed one.
  57698. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57699. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57700. */
  57701. get shadowOrthoScale(): number;
  57702. /**
  57703. * Sets the shadow projection scale against the optimal computed one.
  57704. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57705. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57706. */
  57707. set shadowOrthoScale(value: number);
  57708. /**
  57709. * Automatically compute the projection matrix to best fit (including all the casters)
  57710. * on each frame.
  57711. */
  57712. autoUpdateExtends: boolean;
  57713. /**
  57714. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57715. * on each frame. autoUpdateExtends must be set to true for this to work
  57716. */
  57717. autoCalcShadowZBounds: boolean;
  57718. private _orthoLeft;
  57719. private _orthoRight;
  57720. private _orthoTop;
  57721. private _orthoBottom;
  57722. /**
  57723. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57724. * The directional light is emitted from everywhere in the given direction.
  57725. * It can cast shadows.
  57726. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57727. * @param name The friendly name of the light
  57728. * @param direction The direction of the light
  57729. * @param scene The scene the light belongs to
  57730. */
  57731. constructor(name: string, direction: Vector3, scene: Scene);
  57732. /**
  57733. * Returns the string "DirectionalLight".
  57734. * @return The class name
  57735. */
  57736. getClassName(): string;
  57737. /**
  57738. * Returns the integer 1.
  57739. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57740. */
  57741. getTypeID(): number;
  57742. /**
  57743. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57744. * Returns the DirectionalLight Shadow projection matrix.
  57745. */
  57746. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57747. /**
  57748. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57749. * Returns the DirectionalLight Shadow projection matrix.
  57750. */
  57751. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57752. /**
  57753. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57754. * Returns the DirectionalLight Shadow projection matrix.
  57755. */
  57756. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57757. protected _buildUniformLayout(): void;
  57758. /**
  57759. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57760. * @param effect The effect to update
  57761. * @param lightIndex The index of the light in the effect to update
  57762. * @returns The directional light
  57763. */
  57764. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57765. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57766. /**
  57767. * Gets the minZ used for shadow according to both the scene and the light.
  57768. *
  57769. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57770. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57771. * @param activeCamera The camera we are returning the min for
  57772. * @returns the depth min z
  57773. */
  57774. getDepthMinZ(activeCamera: Camera): number;
  57775. /**
  57776. * Gets the maxZ used for shadow according to both the scene and the light.
  57777. *
  57778. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57779. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57780. * @param activeCamera The camera we are returning the max for
  57781. * @returns the depth max z
  57782. */
  57783. getDepthMaxZ(activeCamera: Camera): number;
  57784. /**
  57785. * Prepares the list of defines specific to the light type.
  57786. * @param defines the list of defines
  57787. * @param lightIndex defines the index of the light for the effect
  57788. */
  57789. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57790. }
  57791. }
  57792. declare module BABYLON {
  57793. /**
  57794. * Class containing static functions to help procedurally build meshes
  57795. */
  57796. export class HemisphereBuilder {
  57797. /**
  57798. * Creates a hemisphere mesh
  57799. * @param name defines the name of the mesh
  57800. * @param options defines the options used to create the mesh
  57801. * @param scene defines the hosting scene
  57802. * @returns the hemisphere mesh
  57803. */
  57804. static CreateHemisphere(name: string, options: {
  57805. segments?: number;
  57806. diameter?: number;
  57807. sideOrientation?: number;
  57808. }, scene: any): Mesh;
  57809. }
  57810. }
  57811. declare module BABYLON {
  57812. /**
  57813. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57814. * These values define a cone of light starting from the position, emitting toward the direction.
  57815. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57816. * and the exponent defines the speed of the decay of the light with distance (reach).
  57817. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57818. */
  57819. export class SpotLight extends ShadowLight {
  57820. private _angle;
  57821. private _innerAngle;
  57822. private _cosHalfAngle;
  57823. private _lightAngleScale;
  57824. private _lightAngleOffset;
  57825. /**
  57826. * Gets the cone angle of the spot light in Radians.
  57827. */
  57828. get angle(): number;
  57829. /**
  57830. * Sets the cone angle of the spot light in Radians.
  57831. */
  57832. set angle(value: number);
  57833. /**
  57834. * Only used in gltf falloff mode, this defines the angle where
  57835. * the directional falloff will start before cutting at angle which could be seen
  57836. * as outer angle.
  57837. */
  57838. get innerAngle(): number;
  57839. /**
  57840. * Only used in gltf falloff mode, this defines the angle where
  57841. * the directional falloff will start before cutting at angle which could be seen
  57842. * as outer angle.
  57843. */
  57844. set innerAngle(value: number);
  57845. private _shadowAngleScale;
  57846. /**
  57847. * Allows scaling the angle of the light for shadow generation only.
  57848. */
  57849. get shadowAngleScale(): number;
  57850. /**
  57851. * Allows scaling the angle of the light for shadow generation only.
  57852. */
  57853. set shadowAngleScale(value: number);
  57854. /**
  57855. * The light decay speed with the distance from the emission spot.
  57856. */
  57857. exponent: number;
  57858. private _projectionTextureMatrix;
  57859. /**
  57860. * Allows reading the projecton texture
  57861. */
  57862. get projectionTextureMatrix(): Matrix;
  57863. protected _projectionTextureLightNear: number;
  57864. /**
  57865. * Gets the near clip of the Spotlight for texture projection.
  57866. */
  57867. get projectionTextureLightNear(): number;
  57868. /**
  57869. * Sets the near clip of the Spotlight for texture projection.
  57870. */
  57871. set projectionTextureLightNear(value: number);
  57872. protected _projectionTextureLightFar: number;
  57873. /**
  57874. * Gets the far clip of the Spotlight for texture projection.
  57875. */
  57876. get projectionTextureLightFar(): number;
  57877. /**
  57878. * Sets the far clip of the Spotlight for texture projection.
  57879. */
  57880. set projectionTextureLightFar(value: number);
  57881. protected _projectionTextureUpDirection: Vector3;
  57882. /**
  57883. * Gets the Up vector of the Spotlight for texture projection.
  57884. */
  57885. get projectionTextureUpDirection(): Vector3;
  57886. /**
  57887. * Sets the Up vector of the Spotlight for texture projection.
  57888. */
  57889. set projectionTextureUpDirection(value: Vector3);
  57890. private _projectionTexture;
  57891. /**
  57892. * Gets the projection texture of the light.
  57893. */
  57894. get projectionTexture(): Nullable<BaseTexture>;
  57895. /**
  57896. * Sets the projection texture of the light.
  57897. */
  57898. set projectionTexture(value: Nullable<BaseTexture>);
  57899. private static _IsProceduralTexture;
  57900. private static _IsTexture;
  57901. private _projectionTextureViewLightDirty;
  57902. private _projectionTextureProjectionLightDirty;
  57903. private _projectionTextureDirty;
  57904. private _projectionTextureViewTargetVector;
  57905. private _projectionTextureViewLightMatrix;
  57906. private _projectionTextureProjectionLightMatrix;
  57907. private _projectionTextureScalingMatrix;
  57908. /**
  57909. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57910. * It can cast shadows.
  57911. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57912. * @param name The light friendly name
  57913. * @param position The position of the spot light in the scene
  57914. * @param direction The direction of the light in the scene
  57915. * @param angle The cone angle of the light in Radians
  57916. * @param exponent The light decay speed with the distance from the emission spot
  57917. * @param scene The scene the lights belongs to
  57918. */
  57919. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57920. /**
  57921. * Returns the string "SpotLight".
  57922. * @returns the class name
  57923. */
  57924. getClassName(): string;
  57925. /**
  57926. * Returns the integer 2.
  57927. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57928. */
  57929. getTypeID(): number;
  57930. /**
  57931. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57932. */
  57933. protected _setDirection(value: Vector3): void;
  57934. /**
  57935. * Overrides the position setter to recompute the projection texture view light Matrix.
  57936. */
  57937. protected _setPosition(value: Vector3): void;
  57938. /**
  57939. * 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.
  57940. * Returns the SpotLight.
  57941. */
  57942. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57943. protected _computeProjectionTextureViewLightMatrix(): void;
  57944. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57945. /**
  57946. * Main function for light texture projection matrix computing.
  57947. */
  57948. protected _computeProjectionTextureMatrix(): void;
  57949. protected _buildUniformLayout(): void;
  57950. private _computeAngleValues;
  57951. /**
  57952. * Sets the passed Effect "effect" with the Light textures.
  57953. * @param effect The effect to update
  57954. * @param lightIndex The index of the light in the effect to update
  57955. * @returns The light
  57956. */
  57957. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57958. /**
  57959. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57960. * @param effect The effect to update
  57961. * @param lightIndex The index of the light in the effect to update
  57962. * @returns The spot light
  57963. */
  57964. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57965. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57966. /**
  57967. * Disposes the light and the associated resources.
  57968. */
  57969. dispose(): void;
  57970. /**
  57971. * Prepares the list of defines specific to the light type.
  57972. * @param defines the list of defines
  57973. * @param lightIndex defines the index of the light for the effect
  57974. */
  57975. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57976. }
  57977. }
  57978. declare module BABYLON {
  57979. /**
  57980. * Gizmo that enables viewing a light
  57981. */
  57982. export class LightGizmo extends Gizmo {
  57983. private _lightMesh;
  57984. private _material;
  57985. private _cachedPosition;
  57986. private _cachedForward;
  57987. private _attachedMeshParent;
  57988. private _pointerObserver;
  57989. /**
  57990. * Event that fires each time the gizmo is clicked
  57991. */
  57992. onClickedObservable: Observable<Light>;
  57993. /**
  57994. * Creates a LightGizmo
  57995. * @param gizmoLayer The utility layer the gizmo will be added to
  57996. */
  57997. constructor(gizmoLayer?: UtilityLayerRenderer);
  57998. private _light;
  57999. /**
  58000. * The light that the gizmo is attached to
  58001. */
  58002. set light(light: Nullable<Light>);
  58003. get light(): Nullable<Light>;
  58004. /**
  58005. * Gets the material used to render the light gizmo
  58006. */
  58007. get material(): StandardMaterial;
  58008. /**
  58009. * @hidden
  58010. * Updates the gizmo to match the attached mesh's position/rotation
  58011. */
  58012. protected _update(): void;
  58013. private static _Scale;
  58014. /**
  58015. * Creates the lines for a light mesh
  58016. */
  58017. private static _CreateLightLines;
  58018. /**
  58019. * Disposes of the light gizmo
  58020. */
  58021. dispose(): void;
  58022. private static _CreateHemisphericLightMesh;
  58023. private static _CreatePointLightMesh;
  58024. private static _CreateSpotLightMesh;
  58025. private static _CreateDirectionalLightMesh;
  58026. }
  58027. }
  58028. declare module BABYLON {
  58029. /**
  58030. * Gizmo that enables viewing a camera
  58031. */
  58032. export class CameraGizmo extends Gizmo {
  58033. private _cameraMesh;
  58034. private _cameraLinesMesh;
  58035. private _material;
  58036. private _pointerObserver;
  58037. /**
  58038. * Event that fires each time the gizmo is clicked
  58039. */
  58040. onClickedObservable: Observable<Camera>;
  58041. /**
  58042. * Creates a CameraGizmo
  58043. * @param gizmoLayer The utility layer the gizmo will be added to
  58044. */
  58045. constructor(gizmoLayer?: UtilityLayerRenderer);
  58046. private _camera;
  58047. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  58048. get displayFrustum(): boolean;
  58049. set displayFrustum(value: boolean);
  58050. /**
  58051. * The camera that the gizmo is attached to
  58052. */
  58053. set camera(camera: Nullable<Camera>);
  58054. get camera(): Nullable<Camera>;
  58055. /**
  58056. * Gets the material used to render the camera gizmo
  58057. */
  58058. get material(): StandardMaterial;
  58059. /**
  58060. * @hidden
  58061. * Updates the gizmo to match the attached mesh's position/rotation
  58062. */
  58063. protected _update(): void;
  58064. private static _Scale;
  58065. private _invProjection;
  58066. /**
  58067. * Disposes of the camera gizmo
  58068. */
  58069. dispose(): void;
  58070. private static _CreateCameraMesh;
  58071. private static _CreateCameraFrustum;
  58072. }
  58073. }
  58074. declare module BABYLON {
  58075. /** @hidden */
  58076. export var backgroundFragmentDeclaration: {
  58077. name: string;
  58078. shader: string;
  58079. };
  58080. }
  58081. declare module BABYLON {
  58082. /** @hidden */
  58083. export var backgroundUboDeclaration: {
  58084. name: string;
  58085. shader: string;
  58086. };
  58087. }
  58088. declare module BABYLON {
  58089. /** @hidden */
  58090. export var backgroundPixelShader: {
  58091. name: string;
  58092. shader: string;
  58093. };
  58094. }
  58095. declare module BABYLON {
  58096. /** @hidden */
  58097. export var backgroundVertexDeclaration: {
  58098. name: string;
  58099. shader: string;
  58100. };
  58101. }
  58102. declare module BABYLON {
  58103. /** @hidden */
  58104. export var backgroundVertexShader: {
  58105. name: string;
  58106. shader: string;
  58107. };
  58108. }
  58109. declare module BABYLON {
  58110. /**
  58111. * Background material used to create an efficient environement around your scene.
  58112. */
  58113. export class BackgroundMaterial extends PushMaterial {
  58114. /**
  58115. * Standard reflectance value at parallel view angle.
  58116. */
  58117. static StandardReflectance0: number;
  58118. /**
  58119. * Standard reflectance value at grazing angle.
  58120. */
  58121. static StandardReflectance90: number;
  58122. protected _primaryColor: Color3;
  58123. /**
  58124. * Key light Color (multiply against the environement texture)
  58125. */
  58126. primaryColor: Color3;
  58127. protected __perceptualColor: Nullable<Color3>;
  58128. /**
  58129. * Experimental Internal Use Only.
  58130. *
  58131. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  58132. * This acts as a helper to set the primary color to a more "human friendly" value.
  58133. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  58134. * output color as close as possible from the chosen value.
  58135. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  58136. * part of lighting setup.)
  58137. */
  58138. get _perceptualColor(): Nullable<Color3>;
  58139. set _perceptualColor(value: Nullable<Color3>);
  58140. protected _primaryColorShadowLevel: float;
  58141. /**
  58142. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  58143. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  58144. */
  58145. get primaryColorShadowLevel(): float;
  58146. set primaryColorShadowLevel(value: float);
  58147. protected _primaryColorHighlightLevel: float;
  58148. /**
  58149. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  58150. * The primary color is used at the level chosen to define what the white area would look.
  58151. */
  58152. get primaryColorHighlightLevel(): float;
  58153. set primaryColorHighlightLevel(value: float);
  58154. protected _reflectionTexture: Nullable<BaseTexture>;
  58155. /**
  58156. * Reflection Texture used in the material.
  58157. * Should be author in a specific way for the best result (refer to the documentation).
  58158. */
  58159. reflectionTexture: Nullable<BaseTexture>;
  58160. protected _reflectionBlur: float;
  58161. /**
  58162. * Reflection Texture level of blur.
  58163. *
  58164. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  58165. * texture twice.
  58166. */
  58167. reflectionBlur: float;
  58168. protected _diffuseTexture: Nullable<BaseTexture>;
  58169. /**
  58170. * Diffuse Texture used in the material.
  58171. * Should be author in a specific way for the best result (refer to the documentation).
  58172. */
  58173. diffuseTexture: Nullable<BaseTexture>;
  58174. protected _shadowLights: Nullable<IShadowLight[]>;
  58175. /**
  58176. * Specify the list of lights casting shadow on the material.
  58177. * All scene shadow lights will be included if null.
  58178. */
  58179. shadowLights: Nullable<IShadowLight[]>;
  58180. protected _shadowLevel: float;
  58181. /**
  58182. * Helps adjusting the shadow to a softer level if required.
  58183. * 0 means black shadows and 1 means no shadows.
  58184. */
  58185. shadowLevel: float;
  58186. protected _sceneCenter: Vector3;
  58187. /**
  58188. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  58189. * It is usually zero but might be interesting to modify according to your setup.
  58190. */
  58191. sceneCenter: Vector3;
  58192. protected _opacityFresnel: boolean;
  58193. /**
  58194. * This helps specifying that the material is falling off to the sky box at grazing angle.
  58195. * This helps ensuring a nice transition when the camera goes under the ground.
  58196. */
  58197. opacityFresnel: boolean;
  58198. protected _reflectionFresnel: boolean;
  58199. /**
  58200. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  58201. * This helps adding a mirror texture on the ground.
  58202. */
  58203. reflectionFresnel: boolean;
  58204. protected _reflectionFalloffDistance: number;
  58205. /**
  58206. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  58207. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  58208. */
  58209. reflectionFalloffDistance: number;
  58210. protected _reflectionAmount: number;
  58211. /**
  58212. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  58213. */
  58214. reflectionAmount: number;
  58215. protected _reflectionReflectance0: number;
  58216. /**
  58217. * This specifies the weight of the reflection at grazing angle.
  58218. */
  58219. reflectionReflectance0: number;
  58220. protected _reflectionReflectance90: number;
  58221. /**
  58222. * This specifies the weight of the reflection at a perpendicular point of view.
  58223. */
  58224. reflectionReflectance90: number;
  58225. /**
  58226. * Sets the reflection reflectance fresnel values according to the default standard
  58227. * empirically know to work well :-)
  58228. */
  58229. set reflectionStandardFresnelWeight(value: number);
  58230. protected _useRGBColor: boolean;
  58231. /**
  58232. * Helps to directly use the maps channels instead of their level.
  58233. */
  58234. useRGBColor: boolean;
  58235. protected _enableNoise: boolean;
  58236. /**
  58237. * This helps reducing the banding effect that could occur on the background.
  58238. */
  58239. enableNoise: boolean;
  58240. /**
  58241. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58242. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  58243. * Recommended to be keep at 1.0 except for special cases.
  58244. */
  58245. get fovMultiplier(): number;
  58246. set fovMultiplier(value: number);
  58247. private _fovMultiplier;
  58248. /**
  58249. * Enable the FOV adjustment feature controlled by fovMultiplier.
  58250. */
  58251. useEquirectangularFOV: boolean;
  58252. private _maxSimultaneousLights;
  58253. /**
  58254. * Number of Simultaneous lights allowed on the material.
  58255. */
  58256. maxSimultaneousLights: int;
  58257. private _shadowOnly;
  58258. /**
  58259. * Make the material only render shadows
  58260. */
  58261. shadowOnly: boolean;
  58262. /**
  58263. * Default configuration related to image processing available in the Background Material.
  58264. */
  58265. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58266. /**
  58267. * Keep track of the image processing observer to allow dispose and replace.
  58268. */
  58269. private _imageProcessingObserver;
  58270. /**
  58271. * Attaches a new image processing configuration to the PBR Material.
  58272. * @param configuration (if null the scene configuration will be use)
  58273. */
  58274. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58275. /**
  58276. * Gets the image processing configuration used either in this material.
  58277. */
  58278. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  58279. /**
  58280. * Sets the Default image processing configuration used either in the this material.
  58281. *
  58282. * If sets to null, the scene one is in use.
  58283. */
  58284. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  58285. /**
  58286. * Gets wether the color curves effect is enabled.
  58287. */
  58288. get cameraColorCurvesEnabled(): boolean;
  58289. /**
  58290. * Sets wether the color curves effect is enabled.
  58291. */
  58292. set cameraColorCurvesEnabled(value: boolean);
  58293. /**
  58294. * Gets wether the color grading effect is enabled.
  58295. */
  58296. get cameraColorGradingEnabled(): boolean;
  58297. /**
  58298. * Gets wether the color grading effect is enabled.
  58299. */
  58300. set cameraColorGradingEnabled(value: boolean);
  58301. /**
  58302. * Gets wether tonemapping is enabled or not.
  58303. */
  58304. get cameraToneMappingEnabled(): boolean;
  58305. /**
  58306. * Sets wether tonemapping is enabled or not
  58307. */
  58308. set cameraToneMappingEnabled(value: boolean);
  58309. /**
  58310. * The camera exposure used on this material.
  58311. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58312. * This corresponds to a photographic exposure.
  58313. */
  58314. get cameraExposure(): float;
  58315. /**
  58316. * The camera exposure used on this material.
  58317. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58318. * This corresponds to a photographic exposure.
  58319. */
  58320. set cameraExposure(value: float);
  58321. /**
  58322. * Gets The camera contrast used on this material.
  58323. */
  58324. get cameraContrast(): float;
  58325. /**
  58326. * Sets The camera contrast used on this material.
  58327. */
  58328. set cameraContrast(value: float);
  58329. /**
  58330. * Gets the Color Grading 2D Lookup Texture.
  58331. */
  58332. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58333. /**
  58334. * Sets the Color Grading 2D Lookup Texture.
  58335. */
  58336. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58337. /**
  58338. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58339. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58340. * 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;
  58341. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58342. */
  58343. get cameraColorCurves(): Nullable<ColorCurves>;
  58344. /**
  58345. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58346. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58347. * 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;
  58348. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58349. */
  58350. set cameraColorCurves(value: Nullable<ColorCurves>);
  58351. /**
  58352. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  58353. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  58354. */
  58355. switchToBGR: boolean;
  58356. private _renderTargets;
  58357. private _reflectionControls;
  58358. private _white;
  58359. private _primaryShadowColor;
  58360. private _primaryHighlightColor;
  58361. /**
  58362. * Instantiates a Background Material in the given scene
  58363. * @param name The friendly name of the material
  58364. * @param scene The scene to add the material to
  58365. */
  58366. constructor(name: string, scene: Scene);
  58367. /**
  58368. * Gets a boolean indicating that current material needs to register RTT
  58369. */
  58370. get hasRenderTargetTextures(): boolean;
  58371. /**
  58372. * The entire material has been created in order to prevent overdraw.
  58373. * @returns false
  58374. */
  58375. needAlphaTesting(): boolean;
  58376. /**
  58377. * The entire material has been created in order to prevent overdraw.
  58378. * @returns true if blending is enable
  58379. */
  58380. needAlphaBlending(): boolean;
  58381. /**
  58382. * Checks wether the material is ready to be rendered for a given mesh.
  58383. * @param mesh The mesh to render
  58384. * @param subMesh The submesh to check against
  58385. * @param useInstances Specify wether or not the material is used with instances
  58386. * @returns true if all the dependencies are ready (Textures, Effects...)
  58387. */
  58388. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58389. /**
  58390. * Compute the primary color according to the chosen perceptual color.
  58391. */
  58392. private _computePrimaryColorFromPerceptualColor;
  58393. /**
  58394. * Compute the highlights and shadow colors according to their chosen levels.
  58395. */
  58396. private _computePrimaryColors;
  58397. /**
  58398. * Build the uniform buffer used in the material.
  58399. */
  58400. buildUniformLayout(): void;
  58401. /**
  58402. * Unbind the material.
  58403. */
  58404. unbind(): void;
  58405. /**
  58406. * Bind only the world matrix to the material.
  58407. * @param world The world matrix to bind.
  58408. */
  58409. bindOnlyWorldMatrix(world: Matrix): void;
  58410. /**
  58411. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58412. * @param world The world matrix to bind.
  58413. * @param subMesh The submesh to bind for.
  58414. */
  58415. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58416. /**
  58417. * Checks to see if a texture is used in the material.
  58418. * @param texture - Base texture to use.
  58419. * @returns - Boolean specifying if a texture is used in the material.
  58420. */
  58421. hasTexture(texture: BaseTexture): boolean;
  58422. /**
  58423. * Dispose the material.
  58424. * @param forceDisposeEffect Force disposal of the associated effect.
  58425. * @param forceDisposeTextures Force disposal of the associated textures.
  58426. */
  58427. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58428. /**
  58429. * Clones the material.
  58430. * @param name The cloned name.
  58431. * @returns The cloned material.
  58432. */
  58433. clone(name: string): BackgroundMaterial;
  58434. /**
  58435. * Serializes the current material to its JSON representation.
  58436. * @returns The JSON representation.
  58437. */
  58438. serialize(): any;
  58439. /**
  58440. * Gets the class name of the material
  58441. * @returns "BackgroundMaterial"
  58442. */
  58443. getClassName(): string;
  58444. /**
  58445. * Parse a JSON input to create back a background material.
  58446. * @param source The JSON data to parse
  58447. * @param scene The scene to create the parsed material in
  58448. * @param rootUrl The root url of the assets the material depends upon
  58449. * @returns the instantiated BackgroundMaterial.
  58450. */
  58451. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58452. }
  58453. }
  58454. declare module BABYLON {
  58455. /**
  58456. * Represents the different options available during the creation of
  58457. * a Environment helper.
  58458. *
  58459. * This can control the default ground, skybox and image processing setup of your scene.
  58460. */
  58461. export interface IEnvironmentHelperOptions {
  58462. /**
  58463. * Specifies whether or not to create a ground.
  58464. * True by default.
  58465. */
  58466. createGround: boolean;
  58467. /**
  58468. * Specifies the ground size.
  58469. * 15 by default.
  58470. */
  58471. groundSize: number;
  58472. /**
  58473. * The texture used on the ground for the main color.
  58474. * Comes from the BabylonJS CDN by default.
  58475. *
  58476. * Remarks: Can be either a texture or a url.
  58477. */
  58478. groundTexture: string | BaseTexture;
  58479. /**
  58480. * The color mixed in the ground texture by default.
  58481. * BabylonJS clearColor by default.
  58482. */
  58483. groundColor: Color3;
  58484. /**
  58485. * Specifies the ground opacity.
  58486. * 1 by default.
  58487. */
  58488. groundOpacity: number;
  58489. /**
  58490. * Enables the ground to receive shadows.
  58491. * True by default.
  58492. */
  58493. enableGroundShadow: boolean;
  58494. /**
  58495. * Helps preventing the shadow to be fully black on the ground.
  58496. * 0.5 by default.
  58497. */
  58498. groundShadowLevel: number;
  58499. /**
  58500. * Creates a mirror texture attach to the ground.
  58501. * false by default.
  58502. */
  58503. enableGroundMirror: boolean;
  58504. /**
  58505. * Specifies the ground mirror size ratio.
  58506. * 0.3 by default as the default kernel is 64.
  58507. */
  58508. groundMirrorSizeRatio: number;
  58509. /**
  58510. * Specifies the ground mirror blur kernel size.
  58511. * 64 by default.
  58512. */
  58513. groundMirrorBlurKernel: number;
  58514. /**
  58515. * Specifies the ground mirror visibility amount.
  58516. * 1 by default
  58517. */
  58518. groundMirrorAmount: number;
  58519. /**
  58520. * Specifies the ground mirror reflectance weight.
  58521. * This uses the standard weight of the background material to setup the fresnel effect
  58522. * of the mirror.
  58523. * 1 by default.
  58524. */
  58525. groundMirrorFresnelWeight: number;
  58526. /**
  58527. * Specifies the ground mirror Falloff distance.
  58528. * This can helps reducing the size of the reflection.
  58529. * 0 by Default.
  58530. */
  58531. groundMirrorFallOffDistance: number;
  58532. /**
  58533. * Specifies the ground mirror texture type.
  58534. * Unsigned Int by Default.
  58535. */
  58536. groundMirrorTextureType: number;
  58537. /**
  58538. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58539. * the shown objects.
  58540. */
  58541. groundYBias: number;
  58542. /**
  58543. * Specifies whether or not to create a skybox.
  58544. * True by default.
  58545. */
  58546. createSkybox: boolean;
  58547. /**
  58548. * Specifies the skybox size.
  58549. * 20 by default.
  58550. */
  58551. skyboxSize: number;
  58552. /**
  58553. * The texture used on the skybox for the main color.
  58554. * Comes from the BabylonJS CDN by default.
  58555. *
  58556. * Remarks: Can be either a texture or a url.
  58557. */
  58558. skyboxTexture: string | BaseTexture;
  58559. /**
  58560. * The color mixed in the skybox texture by default.
  58561. * BabylonJS clearColor by default.
  58562. */
  58563. skyboxColor: Color3;
  58564. /**
  58565. * The background rotation around the Y axis of the scene.
  58566. * This helps aligning the key lights of your scene with the background.
  58567. * 0 by default.
  58568. */
  58569. backgroundYRotation: number;
  58570. /**
  58571. * Compute automatically the size of the elements to best fit with the scene.
  58572. */
  58573. sizeAuto: boolean;
  58574. /**
  58575. * Default position of the rootMesh if autoSize is not true.
  58576. */
  58577. rootPosition: Vector3;
  58578. /**
  58579. * Sets up the image processing in the scene.
  58580. * true by default.
  58581. */
  58582. setupImageProcessing: boolean;
  58583. /**
  58584. * The texture used as your environment texture in the scene.
  58585. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58586. *
  58587. * Remarks: Can be either a texture or a url.
  58588. */
  58589. environmentTexture: string | BaseTexture;
  58590. /**
  58591. * The value of the exposure to apply to the scene.
  58592. * 0.6 by default if setupImageProcessing is true.
  58593. */
  58594. cameraExposure: number;
  58595. /**
  58596. * The value of the contrast to apply to the scene.
  58597. * 1.6 by default if setupImageProcessing is true.
  58598. */
  58599. cameraContrast: number;
  58600. /**
  58601. * Specifies whether or not tonemapping should be enabled in the scene.
  58602. * true by default if setupImageProcessing is true.
  58603. */
  58604. toneMappingEnabled: boolean;
  58605. }
  58606. /**
  58607. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58608. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58609. * It also helps with the default setup of your imageProcessing configuration.
  58610. */
  58611. export class EnvironmentHelper {
  58612. /**
  58613. * Default ground texture URL.
  58614. */
  58615. private static _groundTextureCDNUrl;
  58616. /**
  58617. * Default skybox texture URL.
  58618. */
  58619. private static _skyboxTextureCDNUrl;
  58620. /**
  58621. * Default environment texture URL.
  58622. */
  58623. private static _environmentTextureCDNUrl;
  58624. /**
  58625. * Creates the default options for the helper.
  58626. */
  58627. private static _getDefaultOptions;
  58628. private _rootMesh;
  58629. /**
  58630. * Gets the root mesh created by the helper.
  58631. */
  58632. get rootMesh(): Mesh;
  58633. private _skybox;
  58634. /**
  58635. * Gets the skybox created by the helper.
  58636. */
  58637. get skybox(): Nullable<Mesh>;
  58638. private _skyboxTexture;
  58639. /**
  58640. * Gets the skybox texture created by the helper.
  58641. */
  58642. get skyboxTexture(): Nullable<BaseTexture>;
  58643. private _skyboxMaterial;
  58644. /**
  58645. * Gets the skybox material created by the helper.
  58646. */
  58647. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58648. private _ground;
  58649. /**
  58650. * Gets the ground mesh created by the helper.
  58651. */
  58652. get ground(): Nullable<Mesh>;
  58653. private _groundTexture;
  58654. /**
  58655. * Gets the ground texture created by the helper.
  58656. */
  58657. get groundTexture(): Nullable<BaseTexture>;
  58658. private _groundMirror;
  58659. /**
  58660. * Gets the ground mirror created by the helper.
  58661. */
  58662. get groundMirror(): Nullable<MirrorTexture>;
  58663. /**
  58664. * Gets the ground mirror render list to helps pushing the meshes
  58665. * you wish in the ground reflection.
  58666. */
  58667. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58668. private _groundMaterial;
  58669. /**
  58670. * Gets the ground material created by the helper.
  58671. */
  58672. get groundMaterial(): Nullable<BackgroundMaterial>;
  58673. /**
  58674. * Stores the creation options.
  58675. */
  58676. private readonly _scene;
  58677. private _options;
  58678. /**
  58679. * This observable will be notified with any error during the creation of the environment,
  58680. * mainly texture creation errors.
  58681. */
  58682. onErrorObservable: Observable<{
  58683. message?: string;
  58684. exception?: any;
  58685. }>;
  58686. /**
  58687. * constructor
  58688. * @param options Defines the options we want to customize the helper
  58689. * @param scene The scene to add the material to
  58690. */
  58691. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58692. /**
  58693. * Updates the background according to the new options
  58694. * @param options
  58695. */
  58696. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58697. /**
  58698. * Sets the primary color of all the available elements.
  58699. * @param color the main color to affect to the ground and the background
  58700. */
  58701. setMainColor(color: Color3): void;
  58702. /**
  58703. * Setup the image processing according to the specified options.
  58704. */
  58705. private _setupImageProcessing;
  58706. /**
  58707. * Setup the environment texture according to the specified options.
  58708. */
  58709. private _setupEnvironmentTexture;
  58710. /**
  58711. * Setup the background according to the specified options.
  58712. */
  58713. private _setupBackground;
  58714. /**
  58715. * Get the scene sizes according to the setup.
  58716. */
  58717. private _getSceneSize;
  58718. /**
  58719. * Setup the ground according to the specified options.
  58720. */
  58721. private _setupGround;
  58722. /**
  58723. * Setup the ground material according to the specified options.
  58724. */
  58725. private _setupGroundMaterial;
  58726. /**
  58727. * Setup the ground diffuse texture according to the specified options.
  58728. */
  58729. private _setupGroundDiffuseTexture;
  58730. /**
  58731. * Setup the ground mirror texture according to the specified options.
  58732. */
  58733. private _setupGroundMirrorTexture;
  58734. /**
  58735. * Setup the ground to receive the mirror texture.
  58736. */
  58737. private _setupMirrorInGroundMaterial;
  58738. /**
  58739. * Setup the skybox according to the specified options.
  58740. */
  58741. private _setupSkybox;
  58742. /**
  58743. * Setup the skybox material according to the specified options.
  58744. */
  58745. private _setupSkyboxMaterial;
  58746. /**
  58747. * Setup the skybox reflection texture according to the specified options.
  58748. */
  58749. private _setupSkyboxReflectionTexture;
  58750. private _errorHandler;
  58751. /**
  58752. * Dispose all the elements created by the Helper.
  58753. */
  58754. dispose(): void;
  58755. }
  58756. }
  58757. declare module BABYLON {
  58758. /**
  58759. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58760. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58761. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58762. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58763. */
  58764. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58765. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58766. /**
  58767. * Define the source as a Monoscopic panoramic 360/180.
  58768. */
  58769. static readonly MODE_MONOSCOPIC: number;
  58770. /**
  58771. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58772. */
  58773. static readonly MODE_TOPBOTTOM: number;
  58774. /**
  58775. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58776. */
  58777. static readonly MODE_SIDEBYSIDE: number;
  58778. private _halfDome;
  58779. private _crossEye;
  58780. protected _useDirectMapping: boolean;
  58781. /**
  58782. * The texture being displayed on the sphere
  58783. */
  58784. protected _texture: T;
  58785. /**
  58786. * Gets the texture being displayed on the sphere
  58787. */
  58788. get texture(): T;
  58789. /**
  58790. * Sets the texture being displayed on the sphere
  58791. */
  58792. set texture(newTexture: T);
  58793. /**
  58794. * The skybox material
  58795. */
  58796. protected _material: BackgroundMaterial;
  58797. /**
  58798. * The surface used for the dome
  58799. */
  58800. protected _mesh: Mesh;
  58801. /**
  58802. * Gets the mesh used for the dome.
  58803. */
  58804. get mesh(): Mesh;
  58805. /**
  58806. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58807. */
  58808. private _halfDomeMask;
  58809. /**
  58810. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58811. * Also see the options.resolution property.
  58812. */
  58813. get fovMultiplier(): number;
  58814. set fovMultiplier(value: number);
  58815. protected _textureMode: number;
  58816. /**
  58817. * Gets or set the current texture mode for the texture. It can be:
  58818. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58819. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58820. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58821. */
  58822. get textureMode(): number;
  58823. /**
  58824. * Sets the current texture mode for the texture. It can be:
  58825. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58826. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58827. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58828. */
  58829. set textureMode(value: number);
  58830. /**
  58831. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58832. */
  58833. get halfDome(): boolean;
  58834. /**
  58835. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58836. */
  58837. set halfDome(enabled: boolean);
  58838. /**
  58839. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58840. */
  58841. set crossEye(enabled: boolean);
  58842. /**
  58843. * Is it a cross-eye texture?
  58844. */
  58845. get crossEye(): boolean;
  58846. /**
  58847. * The background material of this dome.
  58848. */
  58849. get material(): BackgroundMaterial;
  58850. /**
  58851. * Oberserver used in Stereoscopic VR Mode.
  58852. */
  58853. private _onBeforeCameraRenderObserver;
  58854. /**
  58855. * Observable raised when an error occured while loading the 360 image
  58856. */
  58857. onLoadErrorObservable: Observable<string>;
  58858. /**
  58859. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58860. * @param name Element's name, child elements will append suffixes for their own names.
  58861. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58862. * @param options An object containing optional or exposed sub element properties
  58863. */
  58864. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58865. resolution?: number;
  58866. clickToPlay?: boolean;
  58867. autoPlay?: boolean;
  58868. loop?: boolean;
  58869. size?: number;
  58870. poster?: string;
  58871. faceForward?: boolean;
  58872. useDirectMapping?: boolean;
  58873. halfDomeMode?: boolean;
  58874. crossEyeMode?: boolean;
  58875. generateMipMaps?: boolean;
  58876. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58877. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58878. protected _changeTextureMode(value: number): void;
  58879. /**
  58880. * Releases resources associated with this node.
  58881. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58882. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58883. */
  58884. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58885. }
  58886. }
  58887. declare module BABYLON {
  58888. /**
  58889. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58890. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58891. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58892. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58893. */
  58894. export class PhotoDome extends TextureDome<Texture> {
  58895. /**
  58896. * Define the image as a Monoscopic panoramic 360 image.
  58897. */
  58898. static readonly MODE_MONOSCOPIC: number;
  58899. /**
  58900. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58901. */
  58902. static readonly MODE_TOPBOTTOM: number;
  58903. /**
  58904. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58905. */
  58906. static readonly MODE_SIDEBYSIDE: number;
  58907. /**
  58908. * Gets or sets the texture being displayed on the sphere
  58909. */
  58910. get photoTexture(): Texture;
  58911. /**
  58912. * sets the texture being displayed on the sphere
  58913. */
  58914. set photoTexture(value: Texture);
  58915. /**
  58916. * Gets the current video mode for the video. It can be:
  58917. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58918. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58919. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58920. */
  58921. get imageMode(): number;
  58922. /**
  58923. * Sets the current video mode for the video. It can be:
  58924. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58925. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58926. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58927. */
  58928. set imageMode(value: number);
  58929. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58930. }
  58931. }
  58932. declare module BABYLON {
  58933. /**
  58934. * Direct draw surface info
  58935. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58936. */
  58937. export interface DDSInfo {
  58938. /**
  58939. * Width of the texture
  58940. */
  58941. width: number;
  58942. /**
  58943. * Width of the texture
  58944. */
  58945. height: number;
  58946. /**
  58947. * Number of Mipmaps for the texture
  58948. * @see https://en.wikipedia.org/wiki/Mipmap
  58949. */
  58950. mipmapCount: number;
  58951. /**
  58952. * If the textures format is a known fourCC format
  58953. * @see https://www.fourcc.org/
  58954. */
  58955. isFourCC: boolean;
  58956. /**
  58957. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58958. */
  58959. isRGB: boolean;
  58960. /**
  58961. * If the texture is a lumincance format
  58962. */
  58963. isLuminance: boolean;
  58964. /**
  58965. * If this is a cube texture
  58966. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58967. */
  58968. isCube: boolean;
  58969. /**
  58970. * If the texture is a compressed format eg. FOURCC_DXT1
  58971. */
  58972. isCompressed: boolean;
  58973. /**
  58974. * The dxgiFormat of the texture
  58975. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58976. */
  58977. dxgiFormat: number;
  58978. /**
  58979. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58980. */
  58981. textureType: number;
  58982. /**
  58983. * Sphericle polynomial created for the dds texture
  58984. */
  58985. sphericalPolynomial?: SphericalPolynomial;
  58986. }
  58987. /**
  58988. * Class used to provide DDS decompression tools
  58989. */
  58990. export class DDSTools {
  58991. /**
  58992. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58993. */
  58994. static StoreLODInAlphaChannel: boolean;
  58995. /**
  58996. * Gets DDS information from an array buffer
  58997. * @param data defines the array buffer view to read data from
  58998. * @returns the DDS information
  58999. */
  59000. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59001. private static _FloatView;
  59002. private static _Int32View;
  59003. private static _ToHalfFloat;
  59004. private static _FromHalfFloat;
  59005. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59006. private static _GetHalfFloatRGBAArrayBuffer;
  59007. private static _GetFloatRGBAArrayBuffer;
  59008. private static _GetFloatAsUIntRGBAArrayBuffer;
  59009. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59010. private static _GetRGBAArrayBuffer;
  59011. private static _ExtractLongWordOrder;
  59012. private static _GetRGBArrayBuffer;
  59013. private static _GetLuminanceArrayBuffer;
  59014. /**
  59015. * Uploads DDS Levels to a Babylon Texture
  59016. * @hidden
  59017. */
  59018. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59019. }
  59020. interface ThinEngine {
  59021. /**
  59022. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59023. * @param rootUrl defines the url where the file to load is located
  59024. * @param scene defines the current scene
  59025. * @param lodScale defines scale to apply to the mip map selection
  59026. * @param lodOffset defines offset to apply to the mip map selection
  59027. * @param onLoad defines an optional callback raised when the texture is loaded
  59028. * @param onError defines an optional callback raised if there is an issue to load the texture
  59029. * @param format defines the format of the data
  59030. * @param forcedExtension defines the extension to use to pick the right loader
  59031. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59032. * @returns the cube texture as an InternalTexture
  59033. */
  59034. 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;
  59035. }
  59036. }
  59037. declare module BABYLON {
  59038. /**
  59039. * Implementation of the DDS Texture Loader.
  59040. * @hidden
  59041. */
  59042. export class _DDSTextureLoader implements IInternalTextureLoader {
  59043. /**
  59044. * Defines wether the loader supports cascade loading the different faces.
  59045. */
  59046. readonly supportCascades: boolean;
  59047. /**
  59048. * This returns if the loader support the current file information.
  59049. * @param extension defines the file extension of the file being loaded
  59050. * @returns true if the loader can load the specified file
  59051. */
  59052. canLoad(extension: string): boolean;
  59053. /**
  59054. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59055. * @param data contains the texture data
  59056. * @param texture defines the BabylonJS internal texture
  59057. * @param createPolynomials will be true if polynomials have been requested
  59058. * @param onLoad defines the callback to trigger once the texture is ready
  59059. * @param onError defines the callback to trigger in case of error
  59060. */
  59061. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59062. /**
  59063. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59064. * @param data contains the texture data
  59065. * @param texture defines the BabylonJS internal texture
  59066. * @param callback defines the method to call once ready to upload
  59067. */
  59068. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59069. }
  59070. }
  59071. declare module BABYLON {
  59072. /**
  59073. * Implementation of the ENV Texture Loader.
  59074. * @hidden
  59075. */
  59076. export class _ENVTextureLoader implements IInternalTextureLoader {
  59077. /**
  59078. * Defines wether the loader supports cascade loading the different faces.
  59079. */
  59080. readonly supportCascades: boolean;
  59081. /**
  59082. * This returns if the loader support the current file information.
  59083. * @param extension defines the file extension of the file being loaded
  59084. * @returns true if the loader can load the specified file
  59085. */
  59086. canLoad(extension: string): boolean;
  59087. /**
  59088. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59089. * @param data contains the texture data
  59090. * @param texture defines the BabylonJS internal texture
  59091. * @param createPolynomials will be true if polynomials have been requested
  59092. * @param onLoad defines the callback to trigger once the texture is ready
  59093. * @param onError defines the callback to trigger in case of error
  59094. */
  59095. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59096. /**
  59097. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59098. * @param data contains the texture data
  59099. * @param texture defines the BabylonJS internal texture
  59100. * @param callback defines the method to call once ready to upload
  59101. */
  59102. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59103. }
  59104. }
  59105. declare module BABYLON {
  59106. /**
  59107. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59108. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59109. */
  59110. export class KhronosTextureContainer {
  59111. /** contents of the KTX container file */
  59112. data: ArrayBufferView;
  59113. private static HEADER_LEN;
  59114. private static COMPRESSED_2D;
  59115. private static COMPRESSED_3D;
  59116. private static TEX_2D;
  59117. private static TEX_3D;
  59118. /**
  59119. * Gets the openGL type
  59120. */
  59121. glType: number;
  59122. /**
  59123. * Gets the openGL type size
  59124. */
  59125. glTypeSize: number;
  59126. /**
  59127. * Gets the openGL format
  59128. */
  59129. glFormat: number;
  59130. /**
  59131. * Gets the openGL internal format
  59132. */
  59133. glInternalFormat: number;
  59134. /**
  59135. * Gets the base internal format
  59136. */
  59137. glBaseInternalFormat: number;
  59138. /**
  59139. * Gets image width in pixel
  59140. */
  59141. pixelWidth: number;
  59142. /**
  59143. * Gets image height in pixel
  59144. */
  59145. pixelHeight: number;
  59146. /**
  59147. * Gets image depth in pixels
  59148. */
  59149. pixelDepth: number;
  59150. /**
  59151. * Gets the number of array elements
  59152. */
  59153. numberOfArrayElements: number;
  59154. /**
  59155. * Gets the number of faces
  59156. */
  59157. numberOfFaces: number;
  59158. /**
  59159. * Gets the number of mipmap levels
  59160. */
  59161. numberOfMipmapLevels: number;
  59162. /**
  59163. * Gets the bytes of key value data
  59164. */
  59165. bytesOfKeyValueData: number;
  59166. /**
  59167. * Gets the load type
  59168. */
  59169. loadType: number;
  59170. /**
  59171. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59172. */
  59173. isInvalid: boolean;
  59174. /**
  59175. * Creates a new KhronosTextureContainer
  59176. * @param data contents of the KTX container file
  59177. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59178. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59179. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59180. */
  59181. constructor(
  59182. /** contents of the KTX container file */
  59183. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59184. /**
  59185. * Uploads KTX content to a Babylon Texture.
  59186. * It is assumed that the texture has already been created & is currently bound
  59187. * @hidden
  59188. */
  59189. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59190. private _upload2DCompressedLevels;
  59191. /**
  59192. * Checks if the given data starts with a KTX file identifier.
  59193. * @param data the data to check
  59194. * @returns true if the data is a KTX file or false otherwise
  59195. */
  59196. static IsValid(data: ArrayBufferView): boolean;
  59197. }
  59198. }
  59199. declare module BABYLON {
  59200. /**
  59201. * Helper class to push actions to a pool of workers.
  59202. */
  59203. export class WorkerPool implements IDisposable {
  59204. private _workerInfos;
  59205. private _pendingActions;
  59206. /**
  59207. * Constructor
  59208. * @param workers Array of workers to use for actions
  59209. */
  59210. constructor(workers: Array<Worker>);
  59211. /**
  59212. * Terminates all workers and clears any pending actions.
  59213. */
  59214. dispose(): void;
  59215. /**
  59216. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59217. * pended until a worker has completed its action.
  59218. * @param action The action to perform. Call onComplete when the action is complete.
  59219. */
  59220. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59221. private _execute;
  59222. }
  59223. }
  59224. declare module BABYLON {
  59225. /**
  59226. * Class for loading KTX2 files
  59227. */
  59228. export class KhronosTextureContainer2 {
  59229. private static _WorkerPoolPromise?;
  59230. private static _Initialized;
  59231. private static _Ktx2Decoder;
  59232. /**
  59233. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  59234. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  59235. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  59236. * Urls you can change:
  59237. * URLConfig.jsDecoderModule
  59238. * URLConfig.wasmUASTCToASTC
  59239. * URLConfig.wasmUASTCToBC7
  59240. * URLConfig.wasmUASTCToRGBA_UNORM
  59241. * URLConfig.wasmUASTCToRGBA_SRGB
  59242. * URLConfig.jsMSCTranscoder
  59243. * URLConfig.wasmMSCTranscoder
  59244. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  59245. */
  59246. static URLConfig: {
  59247. jsDecoderModule: string;
  59248. wasmUASTCToASTC: null;
  59249. wasmUASTCToBC7: null;
  59250. wasmUASTCToRGBA_UNORM: null;
  59251. wasmUASTCToRGBA_SRGB: null;
  59252. jsMSCTranscoder: null;
  59253. wasmMSCTranscoder: null;
  59254. };
  59255. /**
  59256. * Default number of workers used to handle data decoding
  59257. */
  59258. static DefaultNumWorkers: number;
  59259. private static GetDefaultNumWorkers;
  59260. private _engine;
  59261. private static _CreateWorkerPool;
  59262. /**
  59263. * Constructor
  59264. * @param engine The engine to use
  59265. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59266. */
  59267. constructor(engine: ThinEngine, numWorkers?: number);
  59268. /** @hidden */
  59269. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  59270. /**
  59271. * Stop all async operations and release resources.
  59272. */
  59273. dispose(): void;
  59274. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  59275. /**
  59276. * Checks if the given data starts with a KTX2 file identifier.
  59277. * @param data the data to check
  59278. * @returns true if the data is a KTX2 file or false otherwise
  59279. */
  59280. static IsValid(data: ArrayBufferView): boolean;
  59281. }
  59282. }
  59283. declare module BABYLON {
  59284. /**
  59285. * Implementation of the KTX Texture Loader.
  59286. * @hidden
  59287. */
  59288. export class _KTXTextureLoader implements IInternalTextureLoader {
  59289. /**
  59290. * Defines wether the loader supports cascade loading the different faces.
  59291. */
  59292. readonly supportCascades: boolean;
  59293. /**
  59294. * This returns if the loader support the current file information.
  59295. * @param extension defines the file extension of the file being loaded
  59296. * @param mimeType defines the optional mime type of the file being loaded
  59297. * @returns true if the loader can load the specified file
  59298. */
  59299. canLoad(extension: string, mimeType?: string): boolean;
  59300. /**
  59301. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59302. * @param data contains the texture data
  59303. * @param texture defines the BabylonJS internal texture
  59304. * @param createPolynomials will be true if polynomials have been requested
  59305. * @param onLoad defines the callback to trigger once the texture is ready
  59306. * @param onError defines the callback to trigger in case of error
  59307. */
  59308. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59309. /**
  59310. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59311. * @param data contains the texture data
  59312. * @param texture defines the BabylonJS internal texture
  59313. * @param callback defines the method to call once ready to upload
  59314. */
  59315. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  59316. }
  59317. }
  59318. declare module BABYLON {
  59319. /** @hidden */
  59320. export var _forceSceneHelpersToBundle: boolean;
  59321. interface Scene {
  59322. /**
  59323. * Creates a default light for the scene.
  59324. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59325. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59326. */
  59327. createDefaultLight(replace?: boolean): void;
  59328. /**
  59329. * Creates a default camera for the scene.
  59330. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59331. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59332. * @param replace has default false, when true replaces the active camera in the scene
  59333. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59334. */
  59335. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59336. /**
  59337. * Creates a default camera and a default light.
  59338. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59339. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59340. * @param replace has the default false, when true replaces the active camera/light in the scene
  59341. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59342. */
  59343. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59344. /**
  59345. * Creates a new sky box
  59346. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59347. * @param environmentTexture defines the texture to use as environment texture
  59348. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59349. * @param scale defines the overall scale of the skybox
  59350. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59351. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59352. * @returns a new mesh holding the sky box
  59353. */
  59354. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59355. /**
  59356. * Creates a new environment
  59357. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59358. * @param options defines the options you can use to configure the environment
  59359. * @returns the new EnvironmentHelper
  59360. */
  59361. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59362. /**
  59363. * Creates a new VREXperienceHelper
  59364. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59365. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59366. * @returns a new VREXperienceHelper
  59367. */
  59368. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59369. /**
  59370. * Creates a new WebXRDefaultExperience
  59371. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59372. * @param options experience options
  59373. * @returns a promise for a new WebXRDefaultExperience
  59374. */
  59375. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59376. }
  59377. }
  59378. declare module BABYLON {
  59379. /**
  59380. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59381. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59382. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59383. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59384. */
  59385. export class VideoDome extends TextureDome<VideoTexture> {
  59386. /**
  59387. * Define the video source as a Monoscopic panoramic 360 video.
  59388. */
  59389. static readonly MODE_MONOSCOPIC: number;
  59390. /**
  59391. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59392. */
  59393. static readonly MODE_TOPBOTTOM: number;
  59394. /**
  59395. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59396. */
  59397. static readonly MODE_SIDEBYSIDE: number;
  59398. /**
  59399. * Get the video texture associated with this video dome
  59400. */
  59401. get videoTexture(): VideoTexture;
  59402. /**
  59403. * Get the video mode of this dome
  59404. */
  59405. get videoMode(): number;
  59406. /**
  59407. * Set the video mode of this dome.
  59408. * @see textureMode
  59409. */
  59410. set videoMode(value: number);
  59411. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59412. }
  59413. }
  59414. declare module BABYLON {
  59415. /**
  59416. * This class can be used to get instrumentation data from a Babylon engine
  59417. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59418. */
  59419. export class EngineInstrumentation implements IDisposable {
  59420. /**
  59421. * Define the instrumented engine.
  59422. */
  59423. engine: Engine;
  59424. private _captureGPUFrameTime;
  59425. private _gpuFrameTimeToken;
  59426. private _gpuFrameTime;
  59427. private _captureShaderCompilationTime;
  59428. private _shaderCompilationTime;
  59429. private _onBeginFrameObserver;
  59430. private _onEndFrameObserver;
  59431. private _onBeforeShaderCompilationObserver;
  59432. private _onAfterShaderCompilationObserver;
  59433. /**
  59434. * Gets the perf counter used for GPU frame time
  59435. */
  59436. get gpuFrameTimeCounter(): PerfCounter;
  59437. /**
  59438. * Gets the GPU frame time capture status
  59439. */
  59440. get captureGPUFrameTime(): boolean;
  59441. /**
  59442. * Enable or disable the GPU frame time capture
  59443. */
  59444. set captureGPUFrameTime(value: boolean);
  59445. /**
  59446. * Gets the perf counter used for shader compilation time
  59447. */
  59448. get shaderCompilationTimeCounter(): PerfCounter;
  59449. /**
  59450. * Gets the shader compilation time capture status
  59451. */
  59452. get captureShaderCompilationTime(): boolean;
  59453. /**
  59454. * Enable or disable the shader compilation time capture
  59455. */
  59456. set captureShaderCompilationTime(value: boolean);
  59457. /**
  59458. * Instantiates a new engine instrumentation.
  59459. * This class can be used to get instrumentation data from a Babylon engine
  59460. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59461. * @param engine Defines the engine to instrument
  59462. */
  59463. constructor(
  59464. /**
  59465. * Define the instrumented engine.
  59466. */
  59467. engine: Engine);
  59468. /**
  59469. * Dispose and release associated resources.
  59470. */
  59471. dispose(): void;
  59472. }
  59473. }
  59474. declare module BABYLON {
  59475. /**
  59476. * This class can be used to get instrumentation data from a Babylon engine
  59477. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59478. */
  59479. export class SceneInstrumentation implements IDisposable {
  59480. /**
  59481. * Defines the scene to instrument
  59482. */
  59483. scene: Scene;
  59484. private _captureActiveMeshesEvaluationTime;
  59485. private _activeMeshesEvaluationTime;
  59486. private _captureRenderTargetsRenderTime;
  59487. private _renderTargetsRenderTime;
  59488. private _captureFrameTime;
  59489. private _frameTime;
  59490. private _captureRenderTime;
  59491. private _renderTime;
  59492. private _captureInterFrameTime;
  59493. private _interFrameTime;
  59494. private _captureParticlesRenderTime;
  59495. private _particlesRenderTime;
  59496. private _captureSpritesRenderTime;
  59497. private _spritesRenderTime;
  59498. private _capturePhysicsTime;
  59499. private _physicsTime;
  59500. private _captureAnimationsTime;
  59501. private _animationsTime;
  59502. private _captureCameraRenderTime;
  59503. private _cameraRenderTime;
  59504. private _onBeforeActiveMeshesEvaluationObserver;
  59505. private _onAfterActiveMeshesEvaluationObserver;
  59506. private _onBeforeRenderTargetsRenderObserver;
  59507. private _onAfterRenderTargetsRenderObserver;
  59508. private _onAfterRenderObserver;
  59509. private _onBeforeDrawPhaseObserver;
  59510. private _onAfterDrawPhaseObserver;
  59511. private _onBeforeAnimationsObserver;
  59512. private _onBeforeParticlesRenderingObserver;
  59513. private _onAfterParticlesRenderingObserver;
  59514. private _onBeforeSpritesRenderingObserver;
  59515. private _onAfterSpritesRenderingObserver;
  59516. private _onBeforePhysicsObserver;
  59517. private _onAfterPhysicsObserver;
  59518. private _onAfterAnimationsObserver;
  59519. private _onBeforeCameraRenderObserver;
  59520. private _onAfterCameraRenderObserver;
  59521. /**
  59522. * Gets the perf counter used for active meshes evaluation time
  59523. */
  59524. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59525. /**
  59526. * Gets the active meshes evaluation time capture status
  59527. */
  59528. get captureActiveMeshesEvaluationTime(): boolean;
  59529. /**
  59530. * Enable or disable the active meshes evaluation time capture
  59531. */
  59532. set captureActiveMeshesEvaluationTime(value: boolean);
  59533. /**
  59534. * Gets the perf counter used for render targets render time
  59535. */
  59536. get renderTargetsRenderTimeCounter(): PerfCounter;
  59537. /**
  59538. * Gets the render targets render time capture status
  59539. */
  59540. get captureRenderTargetsRenderTime(): boolean;
  59541. /**
  59542. * Enable or disable the render targets render time capture
  59543. */
  59544. set captureRenderTargetsRenderTime(value: boolean);
  59545. /**
  59546. * Gets the perf counter used for particles render time
  59547. */
  59548. get particlesRenderTimeCounter(): PerfCounter;
  59549. /**
  59550. * Gets the particles render time capture status
  59551. */
  59552. get captureParticlesRenderTime(): boolean;
  59553. /**
  59554. * Enable or disable the particles render time capture
  59555. */
  59556. set captureParticlesRenderTime(value: boolean);
  59557. /**
  59558. * Gets the perf counter used for sprites render time
  59559. */
  59560. get spritesRenderTimeCounter(): PerfCounter;
  59561. /**
  59562. * Gets the sprites render time capture status
  59563. */
  59564. get captureSpritesRenderTime(): boolean;
  59565. /**
  59566. * Enable or disable the sprites render time capture
  59567. */
  59568. set captureSpritesRenderTime(value: boolean);
  59569. /**
  59570. * Gets the perf counter used for physics time
  59571. */
  59572. get physicsTimeCounter(): PerfCounter;
  59573. /**
  59574. * Gets the physics time capture status
  59575. */
  59576. get capturePhysicsTime(): boolean;
  59577. /**
  59578. * Enable or disable the physics time capture
  59579. */
  59580. set capturePhysicsTime(value: boolean);
  59581. /**
  59582. * Gets the perf counter used for animations time
  59583. */
  59584. get animationsTimeCounter(): PerfCounter;
  59585. /**
  59586. * Gets the animations time capture status
  59587. */
  59588. get captureAnimationsTime(): boolean;
  59589. /**
  59590. * Enable or disable the animations time capture
  59591. */
  59592. set captureAnimationsTime(value: boolean);
  59593. /**
  59594. * Gets the perf counter used for frame time capture
  59595. */
  59596. get frameTimeCounter(): PerfCounter;
  59597. /**
  59598. * Gets the frame time capture status
  59599. */
  59600. get captureFrameTime(): boolean;
  59601. /**
  59602. * Enable or disable the frame time capture
  59603. */
  59604. set captureFrameTime(value: boolean);
  59605. /**
  59606. * Gets the perf counter used for inter-frames time capture
  59607. */
  59608. get interFrameTimeCounter(): PerfCounter;
  59609. /**
  59610. * Gets the inter-frames time capture status
  59611. */
  59612. get captureInterFrameTime(): boolean;
  59613. /**
  59614. * Enable or disable the inter-frames time capture
  59615. */
  59616. set captureInterFrameTime(value: boolean);
  59617. /**
  59618. * Gets the perf counter used for render time capture
  59619. */
  59620. get renderTimeCounter(): PerfCounter;
  59621. /**
  59622. * Gets the render time capture status
  59623. */
  59624. get captureRenderTime(): boolean;
  59625. /**
  59626. * Enable or disable the render time capture
  59627. */
  59628. set captureRenderTime(value: boolean);
  59629. /**
  59630. * Gets the perf counter used for camera render time capture
  59631. */
  59632. get cameraRenderTimeCounter(): PerfCounter;
  59633. /**
  59634. * Gets the camera render time capture status
  59635. */
  59636. get captureCameraRenderTime(): boolean;
  59637. /**
  59638. * Enable or disable the camera render time capture
  59639. */
  59640. set captureCameraRenderTime(value: boolean);
  59641. /**
  59642. * Gets the perf counter used for draw calls
  59643. */
  59644. get drawCallsCounter(): PerfCounter;
  59645. /**
  59646. * Instantiates a new scene instrumentation.
  59647. * This class can be used to get instrumentation data from a Babylon engine
  59648. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59649. * @param scene Defines the scene to instrument
  59650. */
  59651. constructor(
  59652. /**
  59653. * Defines the scene to instrument
  59654. */
  59655. scene: Scene);
  59656. /**
  59657. * Dispose and release associated resources.
  59658. */
  59659. dispose(): void;
  59660. }
  59661. }
  59662. declare module BABYLON {
  59663. /** @hidden */
  59664. export var glowMapGenerationPixelShader: {
  59665. name: string;
  59666. shader: string;
  59667. };
  59668. }
  59669. declare module BABYLON {
  59670. /** @hidden */
  59671. export var glowMapGenerationVertexShader: {
  59672. name: string;
  59673. shader: string;
  59674. };
  59675. }
  59676. declare module BABYLON {
  59677. /**
  59678. * Effect layer options. This helps customizing the behaviour
  59679. * of the effect layer.
  59680. */
  59681. export interface IEffectLayerOptions {
  59682. /**
  59683. * Multiplication factor apply to the canvas size to compute the render target size
  59684. * used to generated the objects (the smaller the faster).
  59685. */
  59686. mainTextureRatio: number;
  59687. /**
  59688. * Enforces a fixed size texture to ensure effect stability across devices.
  59689. */
  59690. mainTextureFixedSize?: number;
  59691. /**
  59692. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59693. */
  59694. alphaBlendingMode: number;
  59695. /**
  59696. * The camera attached to the layer.
  59697. */
  59698. camera: Nullable<Camera>;
  59699. /**
  59700. * The rendering group to draw the layer in.
  59701. */
  59702. renderingGroupId: number;
  59703. }
  59704. /**
  59705. * The effect layer Helps adding post process effect blended with the main pass.
  59706. *
  59707. * This can be for instance use to generate glow or higlight effects on the scene.
  59708. *
  59709. * The effect layer class can not be used directly and is intented to inherited from to be
  59710. * customized per effects.
  59711. */
  59712. export abstract class EffectLayer {
  59713. private _vertexBuffers;
  59714. private _indexBuffer;
  59715. private _cachedDefines;
  59716. private _effectLayerMapGenerationEffect;
  59717. private _effectLayerOptions;
  59718. private _mergeEffect;
  59719. protected _scene: Scene;
  59720. protected _engine: Engine;
  59721. protected _maxSize: number;
  59722. protected _mainTextureDesiredSize: ISize;
  59723. protected _mainTexture: RenderTargetTexture;
  59724. protected _shouldRender: boolean;
  59725. protected _postProcesses: PostProcess[];
  59726. protected _textures: BaseTexture[];
  59727. protected _emissiveTextureAndColor: {
  59728. texture: Nullable<BaseTexture>;
  59729. color: Color4;
  59730. };
  59731. /**
  59732. * The name of the layer
  59733. */
  59734. name: string;
  59735. /**
  59736. * The clear color of the texture used to generate the glow map.
  59737. */
  59738. neutralColor: Color4;
  59739. /**
  59740. * Specifies whether the highlight layer is enabled or not.
  59741. */
  59742. isEnabled: boolean;
  59743. /**
  59744. * Gets the camera attached to the layer.
  59745. */
  59746. get camera(): Nullable<Camera>;
  59747. /**
  59748. * Gets the rendering group id the layer should render in.
  59749. */
  59750. get renderingGroupId(): number;
  59751. set renderingGroupId(renderingGroupId: number);
  59752. /**
  59753. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59754. */
  59755. disableBoundingBoxesFromEffectLayer: boolean;
  59756. /**
  59757. * An event triggered when the effect layer has been disposed.
  59758. */
  59759. onDisposeObservable: Observable<EffectLayer>;
  59760. /**
  59761. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59762. */
  59763. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59764. /**
  59765. * An event triggered when the generated texture is being merged in the scene.
  59766. */
  59767. onBeforeComposeObservable: Observable<EffectLayer>;
  59768. /**
  59769. * An event triggered when the mesh is rendered into the effect render target.
  59770. */
  59771. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59772. /**
  59773. * An event triggered after the mesh has been rendered into the effect render target.
  59774. */
  59775. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59776. /**
  59777. * An event triggered when the generated texture has been merged in the scene.
  59778. */
  59779. onAfterComposeObservable: Observable<EffectLayer>;
  59780. /**
  59781. * An event triggered when the efffect layer changes its size.
  59782. */
  59783. onSizeChangedObservable: Observable<EffectLayer>;
  59784. /** @hidden */
  59785. static _SceneComponentInitialization: (scene: Scene) => void;
  59786. /**
  59787. * Instantiates a new effect Layer and references it in the scene.
  59788. * @param name The name of the layer
  59789. * @param scene The scene to use the layer in
  59790. */
  59791. constructor(
  59792. /** The Friendly of the effect in the scene */
  59793. name: string, scene: Scene);
  59794. /**
  59795. * Get the effect name of the layer.
  59796. * @return The effect name
  59797. */
  59798. abstract getEffectName(): string;
  59799. /**
  59800. * Checks for the readiness of the element composing the layer.
  59801. * @param subMesh the mesh to check for
  59802. * @param useInstances specify whether or not to use instances to render the mesh
  59803. * @return true if ready otherwise, false
  59804. */
  59805. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59806. /**
  59807. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59808. * @returns true if the effect requires stencil during the main canvas render pass.
  59809. */
  59810. abstract needStencil(): boolean;
  59811. /**
  59812. * Create the merge effect. This is the shader use to blit the information back
  59813. * to the main canvas at the end of the scene rendering.
  59814. * @returns The effect containing the shader used to merge the effect on the main canvas
  59815. */
  59816. protected abstract _createMergeEffect(): Effect;
  59817. /**
  59818. * Creates the render target textures and post processes used in the effect layer.
  59819. */
  59820. protected abstract _createTextureAndPostProcesses(): void;
  59821. /**
  59822. * Implementation specific of rendering the generating effect on the main canvas.
  59823. * @param effect The effect used to render through
  59824. */
  59825. protected abstract _internalRender(effect: Effect): void;
  59826. /**
  59827. * Sets the required values for both the emissive texture and and the main color.
  59828. */
  59829. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59830. /**
  59831. * Free any resources and references associated to a mesh.
  59832. * Internal use
  59833. * @param mesh The mesh to free.
  59834. */
  59835. abstract _disposeMesh(mesh: Mesh): void;
  59836. /**
  59837. * Serializes this layer (Glow or Highlight for example)
  59838. * @returns a serialized layer object
  59839. */
  59840. abstract serialize?(): any;
  59841. /**
  59842. * Initializes the effect layer with the required options.
  59843. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59844. */
  59845. protected _init(options: Partial<IEffectLayerOptions>): void;
  59846. /**
  59847. * Generates the index buffer of the full screen quad blending to the main canvas.
  59848. */
  59849. private _generateIndexBuffer;
  59850. /**
  59851. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59852. */
  59853. private _generateVertexBuffer;
  59854. /**
  59855. * Sets the main texture desired size which is the closest power of two
  59856. * of the engine canvas size.
  59857. */
  59858. private _setMainTextureSize;
  59859. /**
  59860. * Creates the main texture for the effect layer.
  59861. */
  59862. protected _createMainTexture(): void;
  59863. /**
  59864. * Adds specific effects defines.
  59865. * @param defines The defines to add specifics to.
  59866. */
  59867. protected _addCustomEffectDefines(defines: string[]): void;
  59868. /**
  59869. * Checks for the readiness of the element composing the layer.
  59870. * @param subMesh the mesh to check for
  59871. * @param useInstances specify whether or not to use instances to render the mesh
  59872. * @param emissiveTexture the associated emissive texture used to generate the glow
  59873. * @return true if ready otherwise, false
  59874. */
  59875. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59876. /**
  59877. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59878. */
  59879. render(): void;
  59880. /**
  59881. * Determine if a given mesh will be used in the current effect.
  59882. * @param mesh mesh to test
  59883. * @returns true if the mesh will be used
  59884. */
  59885. hasMesh(mesh: AbstractMesh): boolean;
  59886. /**
  59887. * Returns true if the layer contains information to display, otherwise false.
  59888. * @returns true if the glow layer should be rendered
  59889. */
  59890. shouldRender(): boolean;
  59891. /**
  59892. * Returns true if the mesh should render, otherwise false.
  59893. * @param mesh The mesh to render
  59894. * @returns true if it should render otherwise false
  59895. */
  59896. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59897. /**
  59898. * Returns true if the mesh can be rendered, otherwise false.
  59899. * @param mesh The mesh to render
  59900. * @param material The material used on the mesh
  59901. * @returns true if it can be rendered otherwise false
  59902. */
  59903. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59904. /**
  59905. * Returns true if the mesh should render, otherwise false.
  59906. * @param mesh The mesh to render
  59907. * @returns true if it should render otherwise false
  59908. */
  59909. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59910. /**
  59911. * Renders the submesh passed in parameter to the generation map.
  59912. */
  59913. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59914. /**
  59915. * Defines whether the current material of the mesh should be use to render the effect.
  59916. * @param mesh defines the current mesh to render
  59917. */
  59918. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59919. /**
  59920. * Rebuild the required buffers.
  59921. * @hidden Internal use only.
  59922. */
  59923. _rebuild(): void;
  59924. /**
  59925. * Dispose only the render target textures and post process.
  59926. */
  59927. private _disposeTextureAndPostProcesses;
  59928. /**
  59929. * Dispose the highlight layer and free resources.
  59930. */
  59931. dispose(): void;
  59932. /**
  59933. * Gets the class name of the effect layer
  59934. * @returns the string with the class name of the effect layer
  59935. */
  59936. getClassName(): string;
  59937. /**
  59938. * Creates an effect layer from parsed effect layer data
  59939. * @param parsedEffectLayer defines effect layer data
  59940. * @param scene defines the current scene
  59941. * @param rootUrl defines the root URL containing the effect layer information
  59942. * @returns a parsed effect Layer
  59943. */
  59944. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59945. }
  59946. }
  59947. declare module BABYLON {
  59948. interface AbstractScene {
  59949. /**
  59950. * The list of effect layers (highlights/glow) added to the scene
  59951. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59952. * @see https://doc.babylonjs.com/how_to/glow_layer
  59953. */
  59954. effectLayers: Array<EffectLayer>;
  59955. /**
  59956. * Removes the given effect layer from this scene.
  59957. * @param toRemove defines the effect layer to remove
  59958. * @returns the index of the removed effect layer
  59959. */
  59960. removeEffectLayer(toRemove: EffectLayer): number;
  59961. /**
  59962. * Adds the given effect layer to this scene
  59963. * @param newEffectLayer defines the effect layer to add
  59964. */
  59965. addEffectLayer(newEffectLayer: EffectLayer): void;
  59966. }
  59967. /**
  59968. * Defines the layer scene component responsible to manage any effect layers
  59969. * in a given scene.
  59970. */
  59971. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59972. /**
  59973. * The component name helpfull to identify the component in the list of scene components.
  59974. */
  59975. readonly name: string;
  59976. /**
  59977. * The scene the component belongs to.
  59978. */
  59979. scene: Scene;
  59980. private _engine;
  59981. private _renderEffects;
  59982. private _needStencil;
  59983. private _previousStencilState;
  59984. /**
  59985. * Creates a new instance of the component for the given scene
  59986. * @param scene Defines the scene to register the component in
  59987. */
  59988. constructor(scene: Scene);
  59989. /**
  59990. * Registers the component in a given scene
  59991. */
  59992. register(): void;
  59993. /**
  59994. * Rebuilds the elements related to this component in case of
  59995. * context lost for instance.
  59996. */
  59997. rebuild(): void;
  59998. /**
  59999. * Serializes the component data to the specified json object
  60000. * @param serializationObject The object to serialize to
  60001. */
  60002. serialize(serializationObject: any): void;
  60003. /**
  60004. * Adds all the elements from the container to the scene
  60005. * @param container the container holding the elements
  60006. */
  60007. addFromContainer(container: AbstractScene): void;
  60008. /**
  60009. * Removes all the elements in the container from the scene
  60010. * @param container contains the elements to remove
  60011. * @param dispose if the removed element should be disposed (default: false)
  60012. */
  60013. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60014. /**
  60015. * Disposes the component and the associated ressources.
  60016. */
  60017. dispose(): void;
  60018. private _isReadyForMesh;
  60019. private _renderMainTexture;
  60020. private _setStencil;
  60021. private _setStencilBack;
  60022. private _draw;
  60023. private _drawCamera;
  60024. private _drawRenderingGroup;
  60025. }
  60026. }
  60027. declare module BABYLON {
  60028. /** @hidden */
  60029. export var glowMapMergePixelShader: {
  60030. name: string;
  60031. shader: string;
  60032. };
  60033. }
  60034. declare module BABYLON {
  60035. /** @hidden */
  60036. export var glowMapMergeVertexShader: {
  60037. name: string;
  60038. shader: string;
  60039. };
  60040. }
  60041. declare module BABYLON {
  60042. interface AbstractScene {
  60043. /**
  60044. * Return a the first highlight layer of the scene with a given name.
  60045. * @param name The name of the highlight layer to look for.
  60046. * @return The highlight layer if found otherwise null.
  60047. */
  60048. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60049. }
  60050. /**
  60051. * Glow layer options. This helps customizing the behaviour
  60052. * of the glow layer.
  60053. */
  60054. export interface IGlowLayerOptions {
  60055. /**
  60056. * Multiplication factor apply to the canvas size to compute the render target size
  60057. * used to generated the glowing objects (the smaller the faster).
  60058. */
  60059. mainTextureRatio: number;
  60060. /**
  60061. * Enforces a fixed size texture to ensure resize independant blur.
  60062. */
  60063. mainTextureFixedSize?: number;
  60064. /**
  60065. * How big is the kernel of the blur texture.
  60066. */
  60067. blurKernelSize: number;
  60068. /**
  60069. * The camera attached to the layer.
  60070. */
  60071. camera: Nullable<Camera>;
  60072. /**
  60073. * Enable MSAA by chosing the number of samples.
  60074. */
  60075. mainTextureSamples?: number;
  60076. /**
  60077. * The rendering group to draw the layer in.
  60078. */
  60079. renderingGroupId: number;
  60080. }
  60081. /**
  60082. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60083. *
  60084. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60085. *
  60086. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60087. */
  60088. export class GlowLayer extends EffectLayer {
  60089. /**
  60090. * Effect Name of the layer.
  60091. */
  60092. static readonly EffectName: string;
  60093. /**
  60094. * The default blur kernel size used for the glow.
  60095. */
  60096. static DefaultBlurKernelSize: number;
  60097. /**
  60098. * The default texture size ratio used for the glow.
  60099. */
  60100. static DefaultTextureRatio: number;
  60101. /**
  60102. * Sets the kernel size of the blur.
  60103. */
  60104. set blurKernelSize(value: number);
  60105. /**
  60106. * Gets the kernel size of the blur.
  60107. */
  60108. get blurKernelSize(): number;
  60109. /**
  60110. * Sets the glow intensity.
  60111. */
  60112. set intensity(value: number);
  60113. /**
  60114. * Gets the glow intensity.
  60115. */
  60116. get intensity(): number;
  60117. private _options;
  60118. private _intensity;
  60119. private _horizontalBlurPostprocess1;
  60120. private _verticalBlurPostprocess1;
  60121. private _horizontalBlurPostprocess2;
  60122. private _verticalBlurPostprocess2;
  60123. private _blurTexture1;
  60124. private _blurTexture2;
  60125. private _postProcesses1;
  60126. private _postProcesses2;
  60127. private _includedOnlyMeshes;
  60128. private _excludedMeshes;
  60129. private _meshesUsingTheirOwnMaterials;
  60130. /**
  60131. * Callback used to let the user override the color selection on a per mesh basis
  60132. */
  60133. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60134. /**
  60135. * Callback used to let the user override the texture selection on a per mesh basis
  60136. */
  60137. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60138. /**
  60139. * Instantiates a new glow Layer and references it to the scene.
  60140. * @param name The name of the layer
  60141. * @param scene The scene to use the layer in
  60142. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60143. */
  60144. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60145. /**
  60146. * Get the effect name of the layer.
  60147. * @return The effect name
  60148. */
  60149. getEffectName(): string;
  60150. /**
  60151. * Create the merge effect. This is the shader use to blit the information back
  60152. * to the main canvas at the end of the scene rendering.
  60153. */
  60154. protected _createMergeEffect(): Effect;
  60155. /**
  60156. * Creates the render target textures and post processes used in the glow layer.
  60157. */
  60158. protected _createTextureAndPostProcesses(): void;
  60159. /**
  60160. * Checks for the readiness of the element composing the layer.
  60161. * @param subMesh the mesh to check for
  60162. * @param useInstances specify wether or not to use instances to render the mesh
  60163. * @param emissiveTexture the associated emissive texture used to generate the glow
  60164. * @return true if ready otherwise, false
  60165. */
  60166. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60167. /**
  60168. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60169. */
  60170. needStencil(): boolean;
  60171. /**
  60172. * Returns true if the mesh can be rendered, otherwise false.
  60173. * @param mesh The mesh to render
  60174. * @param material The material used on the mesh
  60175. * @returns true if it can be rendered otherwise false
  60176. */
  60177. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60178. /**
  60179. * Implementation specific of rendering the generating effect on the main canvas.
  60180. * @param effect The effect used to render through
  60181. */
  60182. protected _internalRender(effect: Effect): void;
  60183. /**
  60184. * Sets the required values for both the emissive texture and and the main color.
  60185. */
  60186. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60187. /**
  60188. * Returns true if the mesh should render, otherwise false.
  60189. * @param mesh The mesh to render
  60190. * @returns true if it should render otherwise false
  60191. */
  60192. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60193. /**
  60194. * Adds specific effects defines.
  60195. * @param defines The defines to add specifics to.
  60196. */
  60197. protected _addCustomEffectDefines(defines: string[]): void;
  60198. /**
  60199. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60200. * @param mesh The mesh to exclude from the glow layer
  60201. */
  60202. addExcludedMesh(mesh: Mesh): void;
  60203. /**
  60204. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60205. * @param mesh The mesh to remove
  60206. */
  60207. removeExcludedMesh(mesh: Mesh): void;
  60208. /**
  60209. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60210. * @param mesh The mesh to include in the glow layer
  60211. */
  60212. addIncludedOnlyMesh(mesh: Mesh): void;
  60213. /**
  60214. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60215. * @param mesh The mesh to remove
  60216. */
  60217. removeIncludedOnlyMesh(mesh: Mesh): void;
  60218. /**
  60219. * Determine if a given mesh will be used in the glow layer
  60220. * @param mesh The mesh to test
  60221. * @returns true if the mesh will be highlighted by the current glow layer
  60222. */
  60223. hasMesh(mesh: AbstractMesh): boolean;
  60224. /**
  60225. * Defines whether the current material of the mesh should be use to render the effect.
  60226. * @param mesh defines the current mesh to render
  60227. */
  60228. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60229. /**
  60230. * Add a mesh to be rendered through its own material and not with emissive only.
  60231. * @param mesh The mesh for which we need to use its material
  60232. */
  60233. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60234. /**
  60235. * Remove a mesh from being rendered through its own material and not with emissive only.
  60236. * @param mesh The mesh for which we need to not use its material
  60237. */
  60238. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60239. /**
  60240. * Free any resources and references associated to a mesh.
  60241. * Internal use
  60242. * @param mesh The mesh to free.
  60243. * @hidden
  60244. */
  60245. _disposeMesh(mesh: Mesh): void;
  60246. /**
  60247. * Gets the class name of the effect layer
  60248. * @returns the string with the class name of the effect layer
  60249. */
  60250. getClassName(): string;
  60251. /**
  60252. * Serializes this glow layer
  60253. * @returns a serialized glow layer object
  60254. */
  60255. serialize(): any;
  60256. /**
  60257. * Creates a Glow Layer from parsed glow layer data
  60258. * @param parsedGlowLayer defines glow layer data
  60259. * @param scene defines the current scene
  60260. * @param rootUrl defines the root URL containing the glow layer information
  60261. * @returns a parsed Glow Layer
  60262. */
  60263. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60264. }
  60265. }
  60266. declare module BABYLON {
  60267. /** @hidden */
  60268. export var glowBlurPostProcessPixelShader: {
  60269. name: string;
  60270. shader: string;
  60271. };
  60272. }
  60273. declare module BABYLON {
  60274. interface AbstractScene {
  60275. /**
  60276. * Return a the first highlight layer of the scene with a given name.
  60277. * @param name The name of the highlight layer to look for.
  60278. * @return The highlight layer if found otherwise null.
  60279. */
  60280. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60281. }
  60282. /**
  60283. * Highlight layer options. This helps customizing the behaviour
  60284. * of the highlight layer.
  60285. */
  60286. export interface IHighlightLayerOptions {
  60287. /**
  60288. * Multiplication factor apply to the canvas size to compute the render target size
  60289. * used to generated the glowing objects (the smaller the faster).
  60290. */
  60291. mainTextureRatio: number;
  60292. /**
  60293. * Enforces a fixed size texture to ensure resize independant blur.
  60294. */
  60295. mainTextureFixedSize?: number;
  60296. /**
  60297. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60298. * of the picture to blur (the smaller the faster).
  60299. */
  60300. blurTextureSizeRatio: number;
  60301. /**
  60302. * How big in texel of the blur texture is the vertical blur.
  60303. */
  60304. blurVerticalSize: number;
  60305. /**
  60306. * How big in texel of the blur texture is the horizontal blur.
  60307. */
  60308. blurHorizontalSize: number;
  60309. /**
  60310. * Alpha blending mode used to apply the blur. Default is combine.
  60311. */
  60312. alphaBlendingMode: number;
  60313. /**
  60314. * The camera attached to the layer.
  60315. */
  60316. camera: Nullable<Camera>;
  60317. /**
  60318. * Should we display highlight as a solid stroke?
  60319. */
  60320. isStroke?: boolean;
  60321. /**
  60322. * The rendering group to draw the layer in.
  60323. */
  60324. renderingGroupId: number;
  60325. }
  60326. /**
  60327. * The highlight layer Helps adding a glow effect around a mesh.
  60328. *
  60329. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60330. * glowy meshes to your scene.
  60331. *
  60332. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60333. */
  60334. export class HighlightLayer extends EffectLayer {
  60335. name: string;
  60336. /**
  60337. * Effect Name of the highlight layer.
  60338. */
  60339. static readonly EffectName: string;
  60340. /**
  60341. * The neutral color used during the preparation of the glow effect.
  60342. * This is black by default as the blend operation is a blend operation.
  60343. */
  60344. static NeutralColor: Color4;
  60345. /**
  60346. * Stencil value used for glowing meshes.
  60347. */
  60348. static GlowingMeshStencilReference: number;
  60349. /**
  60350. * Stencil value used for the other meshes in the scene.
  60351. */
  60352. static NormalMeshStencilReference: number;
  60353. /**
  60354. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60355. */
  60356. innerGlow: boolean;
  60357. /**
  60358. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60359. */
  60360. outerGlow: boolean;
  60361. /**
  60362. * Specifies the horizontal size of the blur.
  60363. */
  60364. set blurHorizontalSize(value: number);
  60365. /**
  60366. * Specifies the vertical size of the blur.
  60367. */
  60368. set blurVerticalSize(value: number);
  60369. /**
  60370. * Gets the horizontal size of the blur.
  60371. */
  60372. get blurHorizontalSize(): number;
  60373. /**
  60374. * Gets the vertical size of the blur.
  60375. */
  60376. get blurVerticalSize(): number;
  60377. /**
  60378. * An event triggered when the highlight layer is being blurred.
  60379. */
  60380. onBeforeBlurObservable: Observable<HighlightLayer>;
  60381. /**
  60382. * An event triggered when the highlight layer has been blurred.
  60383. */
  60384. onAfterBlurObservable: Observable<HighlightLayer>;
  60385. private _instanceGlowingMeshStencilReference;
  60386. private _options;
  60387. private _downSamplePostprocess;
  60388. private _horizontalBlurPostprocess;
  60389. private _verticalBlurPostprocess;
  60390. private _blurTexture;
  60391. private _meshes;
  60392. private _excludedMeshes;
  60393. /**
  60394. * Instantiates a new highlight Layer and references it to the scene..
  60395. * @param name The name of the layer
  60396. * @param scene The scene to use the layer in
  60397. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60398. */
  60399. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60400. /**
  60401. * Get the effect name of the layer.
  60402. * @return The effect name
  60403. */
  60404. getEffectName(): string;
  60405. /**
  60406. * Create the merge effect. This is the shader use to blit the information back
  60407. * to the main canvas at the end of the scene rendering.
  60408. */
  60409. protected _createMergeEffect(): Effect;
  60410. /**
  60411. * Creates the render target textures and post processes used in the highlight layer.
  60412. */
  60413. protected _createTextureAndPostProcesses(): void;
  60414. /**
  60415. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60416. */
  60417. needStencil(): boolean;
  60418. /**
  60419. * Checks for the readiness of the element composing the layer.
  60420. * @param subMesh the mesh to check for
  60421. * @param useInstances specify wether or not to use instances to render the mesh
  60422. * @param emissiveTexture the associated emissive texture used to generate the glow
  60423. * @return true if ready otherwise, false
  60424. */
  60425. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60426. /**
  60427. * Implementation specific of rendering the generating effect on the main canvas.
  60428. * @param effect The effect used to render through
  60429. */
  60430. protected _internalRender(effect: Effect): void;
  60431. /**
  60432. * Returns true if the layer contains information to display, otherwise false.
  60433. */
  60434. shouldRender(): boolean;
  60435. /**
  60436. * Returns true if the mesh should render, otherwise false.
  60437. * @param mesh The mesh to render
  60438. * @returns true if it should render otherwise false
  60439. */
  60440. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60441. /**
  60442. * Returns true if the mesh can be rendered, otherwise false.
  60443. * @param mesh The mesh to render
  60444. * @param material The material used on the mesh
  60445. * @returns true if it can be rendered otherwise false
  60446. */
  60447. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60448. /**
  60449. * Adds specific effects defines.
  60450. * @param defines The defines to add specifics to.
  60451. */
  60452. protected _addCustomEffectDefines(defines: string[]): void;
  60453. /**
  60454. * Sets the required values for both the emissive texture and and the main color.
  60455. */
  60456. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60457. /**
  60458. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60459. * @param mesh The mesh to exclude from the highlight layer
  60460. */
  60461. addExcludedMesh(mesh: Mesh): void;
  60462. /**
  60463. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60464. * @param mesh The mesh to highlight
  60465. */
  60466. removeExcludedMesh(mesh: Mesh): void;
  60467. /**
  60468. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60469. * @param mesh mesh to test
  60470. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60471. */
  60472. hasMesh(mesh: AbstractMesh): boolean;
  60473. /**
  60474. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60475. * @param mesh The mesh to highlight
  60476. * @param color The color of the highlight
  60477. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60478. */
  60479. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60480. /**
  60481. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60482. * @param mesh The mesh to highlight
  60483. */
  60484. removeMesh(mesh: Mesh): void;
  60485. /**
  60486. * Remove all the meshes currently referenced in the highlight layer
  60487. */
  60488. removeAllMeshes(): void;
  60489. /**
  60490. * Force the stencil to the normal expected value for none glowing parts
  60491. */
  60492. private _defaultStencilReference;
  60493. /**
  60494. * Free any resources and references associated to a mesh.
  60495. * Internal use
  60496. * @param mesh The mesh to free.
  60497. * @hidden
  60498. */
  60499. _disposeMesh(mesh: Mesh): void;
  60500. /**
  60501. * Dispose the highlight layer and free resources.
  60502. */
  60503. dispose(): void;
  60504. /**
  60505. * Gets the class name of the effect layer
  60506. * @returns the string with the class name of the effect layer
  60507. */
  60508. getClassName(): string;
  60509. /**
  60510. * Serializes this Highlight layer
  60511. * @returns a serialized Highlight layer object
  60512. */
  60513. serialize(): any;
  60514. /**
  60515. * Creates a Highlight layer from parsed Highlight layer data
  60516. * @param parsedHightlightLayer defines the Highlight layer data
  60517. * @param scene defines the current scene
  60518. * @param rootUrl defines the root URL containing the Highlight layer information
  60519. * @returns a parsed Highlight layer
  60520. */
  60521. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60522. }
  60523. }
  60524. declare module BABYLON {
  60525. interface AbstractScene {
  60526. /**
  60527. * The list of layers (background and foreground) of the scene
  60528. */
  60529. layers: Array<Layer>;
  60530. }
  60531. /**
  60532. * Defines the layer scene component responsible to manage any layers
  60533. * in a given scene.
  60534. */
  60535. export class LayerSceneComponent implements ISceneComponent {
  60536. /**
  60537. * The component name helpfull to identify the component in the list of scene components.
  60538. */
  60539. readonly name: string;
  60540. /**
  60541. * The scene the component belongs to.
  60542. */
  60543. scene: Scene;
  60544. private _engine;
  60545. /**
  60546. * Creates a new instance of the component for the given scene
  60547. * @param scene Defines the scene to register the component in
  60548. */
  60549. constructor(scene: Scene);
  60550. /**
  60551. * Registers the component in a given scene
  60552. */
  60553. register(): void;
  60554. /**
  60555. * Rebuilds the elements related to this component in case of
  60556. * context lost for instance.
  60557. */
  60558. rebuild(): void;
  60559. /**
  60560. * Disposes the component and the associated ressources.
  60561. */
  60562. dispose(): void;
  60563. private _draw;
  60564. private _drawCameraPredicate;
  60565. private _drawCameraBackground;
  60566. private _drawCameraForeground;
  60567. private _drawRenderTargetPredicate;
  60568. private _drawRenderTargetBackground;
  60569. private _drawRenderTargetForeground;
  60570. /**
  60571. * Adds all the elements from the container to the scene
  60572. * @param container the container holding the elements
  60573. */
  60574. addFromContainer(container: AbstractScene): void;
  60575. /**
  60576. * Removes all the elements in the container from the scene
  60577. * @param container contains the elements to remove
  60578. * @param dispose if the removed element should be disposed (default: false)
  60579. */
  60580. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60581. }
  60582. }
  60583. declare module BABYLON {
  60584. /** @hidden */
  60585. export var layerPixelShader: {
  60586. name: string;
  60587. shader: string;
  60588. };
  60589. }
  60590. declare module BABYLON {
  60591. /** @hidden */
  60592. export var layerVertexShader: {
  60593. name: string;
  60594. shader: string;
  60595. };
  60596. }
  60597. declare module BABYLON {
  60598. /**
  60599. * This represents a full screen 2d layer.
  60600. * This can be useful to display a picture in the background of your scene for instance.
  60601. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60602. */
  60603. export class Layer {
  60604. /**
  60605. * Define the name of the layer.
  60606. */
  60607. name: string;
  60608. /**
  60609. * Define the texture the layer should display.
  60610. */
  60611. texture: Nullable<Texture>;
  60612. /**
  60613. * Is the layer in background or foreground.
  60614. */
  60615. isBackground: boolean;
  60616. /**
  60617. * Define the color of the layer (instead of texture).
  60618. */
  60619. color: Color4;
  60620. /**
  60621. * Define the scale of the layer in order to zoom in out of the texture.
  60622. */
  60623. scale: Vector2;
  60624. /**
  60625. * Define an offset for the layer in order to shift the texture.
  60626. */
  60627. offset: Vector2;
  60628. /**
  60629. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60630. */
  60631. alphaBlendingMode: number;
  60632. /**
  60633. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60634. * Alpha test will not mix with the background color in case of transparency.
  60635. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60636. */
  60637. alphaTest: boolean;
  60638. /**
  60639. * Define a mask to restrict the layer to only some of the scene cameras.
  60640. */
  60641. layerMask: number;
  60642. /**
  60643. * Define the list of render target the layer is visible into.
  60644. */
  60645. renderTargetTextures: RenderTargetTexture[];
  60646. /**
  60647. * Define if the layer is only used in renderTarget or if it also
  60648. * renders in the main frame buffer of the canvas.
  60649. */
  60650. renderOnlyInRenderTargetTextures: boolean;
  60651. private _scene;
  60652. private _vertexBuffers;
  60653. private _indexBuffer;
  60654. private _effect;
  60655. private _previousDefines;
  60656. /**
  60657. * An event triggered when the layer is disposed.
  60658. */
  60659. onDisposeObservable: Observable<Layer>;
  60660. private _onDisposeObserver;
  60661. /**
  60662. * Back compatibility with callback before the onDisposeObservable existed.
  60663. * The set callback will be triggered when the layer has been disposed.
  60664. */
  60665. set onDispose(callback: () => void);
  60666. /**
  60667. * An event triggered before rendering the scene
  60668. */
  60669. onBeforeRenderObservable: Observable<Layer>;
  60670. private _onBeforeRenderObserver;
  60671. /**
  60672. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60673. * The set callback will be triggered just before rendering the layer.
  60674. */
  60675. set onBeforeRender(callback: () => void);
  60676. /**
  60677. * An event triggered after rendering the scene
  60678. */
  60679. onAfterRenderObservable: Observable<Layer>;
  60680. private _onAfterRenderObserver;
  60681. /**
  60682. * Back compatibility with callback before the onAfterRenderObservable existed.
  60683. * The set callback will be triggered just after rendering the layer.
  60684. */
  60685. set onAfterRender(callback: () => void);
  60686. /**
  60687. * Instantiates a new layer.
  60688. * This represents a full screen 2d layer.
  60689. * This can be useful to display a picture in the background of your scene for instance.
  60690. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60691. * @param name Define the name of the layer in the scene
  60692. * @param imgUrl Define the url of the texture to display in the layer
  60693. * @param scene Define the scene the layer belongs to
  60694. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60695. * @param color Defines a color for the layer
  60696. */
  60697. constructor(
  60698. /**
  60699. * Define the name of the layer.
  60700. */
  60701. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60702. private _createIndexBuffer;
  60703. /** @hidden */
  60704. _rebuild(): void;
  60705. /**
  60706. * Renders the layer in the scene.
  60707. */
  60708. render(): void;
  60709. /**
  60710. * Disposes and releases the associated ressources.
  60711. */
  60712. dispose(): void;
  60713. }
  60714. }
  60715. declare module BABYLON {
  60716. /** @hidden */
  60717. export var lensFlarePixelShader: {
  60718. name: string;
  60719. shader: string;
  60720. };
  60721. }
  60722. declare module BABYLON {
  60723. /** @hidden */
  60724. export var lensFlareVertexShader: {
  60725. name: string;
  60726. shader: string;
  60727. };
  60728. }
  60729. declare module BABYLON {
  60730. /**
  60731. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60732. * It is usually composed of several `lensFlare`.
  60733. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60734. */
  60735. export class LensFlareSystem {
  60736. /**
  60737. * Define the name of the lens flare system
  60738. */
  60739. name: string;
  60740. /**
  60741. * List of lens flares used in this system.
  60742. */
  60743. lensFlares: LensFlare[];
  60744. /**
  60745. * Define a limit from the border the lens flare can be visible.
  60746. */
  60747. borderLimit: number;
  60748. /**
  60749. * Define a viewport border we do not want to see the lens flare in.
  60750. */
  60751. viewportBorder: number;
  60752. /**
  60753. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60754. */
  60755. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60756. /**
  60757. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60758. */
  60759. layerMask: number;
  60760. /**
  60761. * Define the id of the lens flare system in the scene.
  60762. * (equal to name by default)
  60763. */
  60764. id: string;
  60765. private _scene;
  60766. private _emitter;
  60767. private _vertexBuffers;
  60768. private _indexBuffer;
  60769. private _effect;
  60770. private _positionX;
  60771. private _positionY;
  60772. private _isEnabled;
  60773. /** @hidden */
  60774. static _SceneComponentInitialization: (scene: Scene) => void;
  60775. /**
  60776. * Instantiates a lens flare system.
  60777. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60778. * It is usually composed of several `lensFlare`.
  60779. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60780. * @param name Define the name of the lens flare system in the scene
  60781. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60782. * @param scene Define the scene the lens flare system belongs to
  60783. */
  60784. constructor(
  60785. /**
  60786. * Define the name of the lens flare system
  60787. */
  60788. name: string, emitter: any, scene: Scene);
  60789. /**
  60790. * Define if the lens flare system is enabled.
  60791. */
  60792. get isEnabled(): boolean;
  60793. set isEnabled(value: boolean);
  60794. /**
  60795. * Get the scene the effects belongs to.
  60796. * @returns the scene holding the lens flare system
  60797. */
  60798. getScene(): Scene;
  60799. /**
  60800. * Get the emitter of the lens flare system.
  60801. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60802. * @returns the emitter of the lens flare system
  60803. */
  60804. getEmitter(): any;
  60805. /**
  60806. * Set the emitter of the lens flare system.
  60807. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60808. * @param newEmitter Define the new emitter of the system
  60809. */
  60810. setEmitter(newEmitter: any): void;
  60811. /**
  60812. * Get the lens flare system emitter position.
  60813. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60814. * @returns the position
  60815. */
  60816. getEmitterPosition(): Vector3;
  60817. /**
  60818. * @hidden
  60819. */
  60820. computeEffectivePosition(globalViewport: Viewport): boolean;
  60821. /** @hidden */
  60822. _isVisible(): boolean;
  60823. /**
  60824. * @hidden
  60825. */
  60826. render(): boolean;
  60827. /**
  60828. * Dispose and release the lens flare with its associated resources.
  60829. */
  60830. dispose(): void;
  60831. /**
  60832. * Parse a lens flare system from a JSON repressentation
  60833. * @param parsedLensFlareSystem Define the JSON to parse
  60834. * @param scene Define the scene the parsed system should be instantiated in
  60835. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60836. * @returns the parsed system
  60837. */
  60838. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60839. /**
  60840. * Serialize the current Lens Flare System into a JSON representation.
  60841. * @returns the serialized JSON
  60842. */
  60843. serialize(): any;
  60844. }
  60845. }
  60846. declare module BABYLON {
  60847. /**
  60848. * This represents one of the lens effect in a `lensFlareSystem`.
  60849. * It controls one of the indiviual texture used in the effect.
  60850. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60851. */
  60852. export class LensFlare {
  60853. /**
  60854. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60855. */
  60856. size: number;
  60857. /**
  60858. * 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.
  60859. */
  60860. position: number;
  60861. /**
  60862. * Define the lens color.
  60863. */
  60864. color: Color3;
  60865. /**
  60866. * Define the lens texture.
  60867. */
  60868. texture: Nullable<Texture>;
  60869. /**
  60870. * Define the alpha mode to render this particular lens.
  60871. */
  60872. alphaMode: number;
  60873. private _system;
  60874. /**
  60875. * Creates a new Lens Flare.
  60876. * This represents one of the lens effect in a `lensFlareSystem`.
  60877. * It controls one of the indiviual texture used in the effect.
  60878. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60879. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60880. * @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.
  60881. * @param color Define the lens color
  60882. * @param imgUrl Define the lens texture url
  60883. * @param system Define the `lensFlareSystem` this flare is part of
  60884. * @returns The newly created Lens Flare
  60885. */
  60886. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60887. /**
  60888. * Instantiates a new Lens Flare.
  60889. * This represents one of the lens effect in a `lensFlareSystem`.
  60890. * It controls one of the indiviual texture used in the effect.
  60891. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60892. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60893. * @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.
  60894. * @param color Define the lens color
  60895. * @param imgUrl Define the lens texture url
  60896. * @param system Define the `lensFlareSystem` this flare is part of
  60897. */
  60898. constructor(
  60899. /**
  60900. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60901. */
  60902. size: number,
  60903. /**
  60904. * 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.
  60905. */
  60906. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60907. /**
  60908. * Dispose and release the lens flare with its associated resources.
  60909. */
  60910. dispose(): void;
  60911. }
  60912. }
  60913. declare module BABYLON {
  60914. interface AbstractScene {
  60915. /**
  60916. * The list of lens flare system added to the scene
  60917. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60918. */
  60919. lensFlareSystems: Array<LensFlareSystem>;
  60920. /**
  60921. * Removes the given lens flare system from this scene.
  60922. * @param toRemove The lens flare system to remove
  60923. * @returns The index of the removed lens flare system
  60924. */
  60925. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60926. /**
  60927. * Adds the given lens flare system to this scene
  60928. * @param newLensFlareSystem The lens flare system to add
  60929. */
  60930. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60931. /**
  60932. * Gets a lens flare system using its name
  60933. * @param name defines the name to look for
  60934. * @returns the lens flare system or null if not found
  60935. */
  60936. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60937. /**
  60938. * Gets a lens flare system using its id
  60939. * @param id defines the id to look for
  60940. * @returns the lens flare system or null if not found
  60941. */
  60942. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60943. }
  60944. /**
  60945. * Defines the lens flare scene component responsible to manage any lens flares
  60946. * in a given scene.
  60947. */
  60948. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60949. /**
  60950. * The component name helpfull to identify the component in the list of scene components.
  60951. */
  60952. readonly name: string;
  60953. /**
  60954. * The scene the component belongs to.
  60955. */
  60956. scene: Scene;
  60957. /**
  60958. * Creates a new instance of the component for the given scene
  60959. * @param scene Defines the scene to register the component in
  60960. */
  60961. constructor(scene: Scene);
  60962. /**
  60963. * Registers the component in a given scene
  60964. */
  60965. register(): void;
  60966. /**
  60967. * Rebuilds the elements related to this component in case of
  60968. * context lost for instance.
  60969. */
  60970. rebuild(): void;
  60971. /**
  60972. * Adds all the elements from the container to the scene
  60973. * @param container the container holding the elements
  60974. */
  60975. addFromContainer(container: AbstractScene): void;
  60976. /**
  60977. * Removes all the elements in the container from the scene
  60978. * @param container contains the elements to remove
  60979. * @param dispose if the removed element should be disposed (default: false)
  60980. */
  60981. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60982. /**
  60983. * Serializes the component data to the specified json object
  60984. * @param serializationObject The object to serialize to
  60985. */
  60986. serialize(serializationObject: any): void;
  60987. /**
  60988. * Disposes the component and the associated ressources.
  60989. */
  60990. dispose(): void;
  60991. private _draw;
  60992. }
  60993. }
  60994. declare module BABYLON {
  60995. /** @hidden */
  60996. export var depthPixelShader: {
  60997. name: string;
  60998. shader: string;
  60999. };
  61000. }
  61001. declare module BABYLON {
  61002. /** @hidden */
  61003. export var depthVertexShader: {
  61004. name: string;
  61005. shader: string;
  61006. };
  61007. }
  61008. declare module BABYLON {
  61009. /**
  61010. * This represents a depth renderer in Babylon.
  61011. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61012. */
  61013. export class DepthRenderer {
  61014. private _scene;
  61015. private _depthMap;
  61016. private _effect;
  61017. private readonly _storeNonLinearDepth;
  61018. private readonly _clearColor;
  61019. /** Get if the depth renderer is using packed depth or not */
  61020. readonly isPacked: boolean;
  61021. private _cachedDefines;
  61022. private _camera;
  61023. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61024. enabled: boolean;
  61025. /**
  61026. * Specifiess that the depth renderer will only be used within
  61027. * the camera it is created for.
  61028. * This can help forcing its rendering during the camera processing.
  61029. */
  61030. useOnlyInActiveCamera: boolean;
  61031. /** @hidden */
  61032. static _SceneComponentInitialization: (scene: Scene) => void;
  61033. /**
  61034. * Instantiates a depth renderer
  61035. * @param scene The scene the renderer belongs to
  61036. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61037. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61038. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61039. */
  61040. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61041. /**
  61042. * Creates the depth rendering effect and checks if the effect is ready.
  61043. * @param subMesh The submesh to be used to render the depth map of
  61044. * @param useInstances If multiple world instances should be used
  61045. * @returns if the depth renderer is ready to render the depth map
  61046. */
  61047. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61048. /**
  61049. * Gets the texture which the depth map will be written to.
  61050. * @returns The depth map texture
  61051. */
  61052. getDepthMap(): RenderTargetTexture;
  61053. /**
  61054. * Disposes of the depth renderer.
  61055. */
  61056. dispose(): void;
  61057. }
  61058. }
  61059. declare module BABYLON {
  61060. /** @hidden */
  61061. export var minmaxReduxPixelShader: {
  61062. name: string;
  61063. shader: string;
  61064. };
  61065. }
  61066. declare module BABYLON {
  61067. /**
  61068. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61069. * and maximum values from all values of the texture.
  61070. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61071. * The source values are read from the red channel of the texture.
  61072. */
  61073. export class MinMaxReducer {
  61074. /**
  61075. * Observable triggered when the computation has been performed
  61076. */
  61077. onAfterReductionPerformed: Observable<{
  61078. min: number;
  61079. max: number;
  61080. }>;
  61081. protected _camera: Camera;
  61082. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61083. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61084. protected _postProcessManager: PostProcessManager;
  61085. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61086. protected _forceFullscreenViewport: boolean;
  61087. /**
  61088. * Creates a min/max reducer
  61089. * @param camera The camera to use for the post processes
  61090. */
  61091. constructor(camera: Camera);
  61092. /**
  61093. * Gets the texture used to read the values from.
  61094. */
  61095. get sourceTexture(): Nullable<RenderTargetTexture>;
  61096. /**
  61097. * Sets the source texture to read the values from.
  61098. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61099. * because in such textures '1' value must not be taken into account to compute the maximum
  61100. * as this value is used to clear the texture.
  61101. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61102. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61103. * @param depthRedux Indicates if the texture is a depth texture or not
  61104. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61105. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61106. */
  61107. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61108. /**
  61109. * Defines the refresh rate of the computation.
  61110. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61111. */
  61112. get refreshRate(): number;
  61113. set refreshRate(value: number);
  61114. protected _activated: boolean;
  61115. /**
  61116. * Gets the activation status of the reducer
  61117. */
  61118. get activated(): boolean;
  61119. /**
  61120. * Activates the reduction computation.
  61121. * When activated, the observers registered in onAfterReductionPerformed are
  61122. * called after the compuation is performed
  61123. */
  61124. activate(): void;
  61125. /**
  61126. * Deactivates the reduction computation.
  61127. */
  61128. deactivate(): void;
  61129. /**
  61130. * Disposes the min/max reducer
  61131. * @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.
  61132. */
  61133. dispose(disposeAll?: boolean): void;
  61134. }
  61135. }
  61136. declare module BABYLON {
  61137. /**
  61138. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61139. */
  61140. export class DepthReducer extends MinMaxReducer {
  61141. private _depthRenderer;
  61142. private _depthRendererId;
  61143. /**
  61144. * Gets the depth renderer used for the computation.
  61145. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61146. */
  61147. get depthRenderer(): Nullable<DepthRenderer>;
  61148. /**
  61149. * Creates a depth reducer
  61150. * @param camera The camera used to render the depth texture
  61151. */
  61152. constructor(camera: Camera);
  61153. /**
  61154. * Sets the depth renderer to use to generate the depth map
  61155. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61156. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61157. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61158. */
  61159. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61160. /** @hidden */
  61161. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61162. /**
  61163. * Activates the reduction computation.
  61164. * When activated, the observers registered in onAfterReductionPerformed are
  61165. * called after the compuation is performed
  61166. */
  61167. activate(): void;
  61168. /**
  61169. * Deactivates the reduction computation.
  61170. */
  61171. deactivate(): void;
  61172. /**
  61173. * Disposes the depth reducer
  61174. * @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.
  61175. */
  61176. dispose(disposeAll?: boolean): void;
  61177. }
  61178. }
  61179. declare module BABYLON {
  61180. /**
  61181. * A CSM implementation allowing casting shadows on large scenes.
  61182. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61183. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61184. */
  61185. export class CascadedShadowGenerator extends ShadowGenerator {
  61186. private static readonly frustumCornersNDCSpace;
  61187. /**
  61188. * Name of the CSM class
  61189. */
  61190. static CLASSNAME: string;
  61191. /**
  61192. * Defines the default number of cascades used by the CSM.
  61193. */
  61194. static readonly DEFAULT_CASCADES_COUNT: number;
  61195. /**
  61196. * Defines the minimum number of cascades used by the CSM.
  61197. */
  61198. static readonly MIN_CASCADES_COUNT: number;
  61199. /**
  61200. * Defines the maximum number of cascades used by the CSM.
  61201. */
  61202. static readonly MAX_CASCADES_COUNT: number;
  61203. protected _validateFilter(filter: number): number;
  61204. /**
  61205. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61206. */
  61207. penumbraDarkness: number;
  61208. private _numCascades;
  61209. /**
  61210. * Gets or set the number of cascades used by the CSM.
  61211. */
  61212. get numCascades(): number;
  61213. set numCascades(value: number);
  61214. /**
  61215. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61216. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61217. */
  61218. stabilizeCascades: boolean;
  61219. private _freezeShadowCastersBoundingInfo;
  61220. private _freezeShadowCastersBoundingInfoObservable;
  61221. /**
  61222. * Enables or disables the shadow casters bounding info computation.
  61223. * If your shadow casters don't move, you can disable this feature.
  61224. * If it is enabled, the bounding box computation is done every frame.
  61225. */
  61226. get freezeShadowCastersBoundingInfo(): boolean;
  61227. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61228. private _scbiMin;
  61229. private _scbiMax;
  61230. protected _computeShadowCastersBoundingInfo(): void;
  61231. protected _shadowCastersBoundingInfo: BoundingInfo;
  61232. /**
  61233. * Gets or sets the shadow casters bounding info.
  61234. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61235. * so that the system won't overwrite the bounds you provide
  61236. */
  61237. get shadowCastersBoundingInfo(): BoundingInfo;
  61238. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61239. protected _breaksAreDirty: boolean;
  61240. protected _minDistance: number;
  61241. protected _maxDistance: number;
  61242. /**
  61243. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61244. *
  61245. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61246. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61247. * @param min minimal distance for the breaks (default to 0.)
  61248. * @param max maximal distance for the breaks (default to 1.)
  61249. */
  61250. setMinMaxDistance(min: number, max: number): void;
  61251. /** Gets the minimal distance used in the cascade break computation */
  61252. get minDistance(): number;
  61253. /** Gets the maximal distance used in the cascade break computation */
  61254. get maxDistance(): number;
  61255. /**
  61256. * Gets the class name of that object
  61257. * @returns "CascadedShadowGenerator"
  61258. */
  61259. getClassName(): string;
  61260. private _cascadeMinExtents;
  61261. private _cascadeMaxExtents;
  61262. /**
  61263. * Gets a cascade minimum extents
  61264. * @param cascadeIndex index of the cascade
  61265. * @returns the minimum cascade extents
  61266. */
  61267. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61268. /**
  61269. * Gets a cascade maximum extents
  61270. * @param cascadeIndex index of the cascade
  61271. * @returns the maximum cascade extents
  61272. */
  61273. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61274. private _cascades;
  61275. private _currentLayer;
  61276. private _viewSpaceFrustumsZ;
  61277. private _viewMatrices;
  61278. private _projectionMatrices;
  61279. private _transformMatrices;
  61280. private _transformMatricesAsArray;
  61281. private _frustumLengths;
  61282. private _lightSizeUVCorrection;
  61283. private _depthCorrection;
  61284. private _frustumCornersWorldSpace;
  61285. private _frustumCenter;
  61286. private _shadowCameraPos;
  61287. private _shadowMaxZ;
  61288. /**
  61289. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61290. * It defaults to camera.maxZ
  61291. */
  61292. get shadowMaxZ(): number;
  61293. /**
  61294. * Sets the shadow max z distance.
  61295. */
  61296. set shadowMaxZ(value: number);
  61297. protected _debug: boolean;
  61298. /**
  61299. * Gets or sets the debug flag.
  61300. * When enabled, the cascades are materialized by different colors on the screen.
  61301. */
  61302. get debug(): boolean;
  61303. set debug(dbg: boolean);
  61304. private _depthClamp;
  61305. /**
  61306. * Gets or sets the depth clamping value.
  61307. *
  61308. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61309. * to account for the shadow casters far away.
  61310. *
  61311. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61312. */
  61313. get depthClamp(): boolean;
  61314. set depthClamp(value: boolean);
  61315. private _cascadeBlendPercentage;
  61316. /**
  61317. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61318. * It defaults to 0.1 (10% blending).
  61319. */
  61320. get cascadeBlendPercentage(): number;
  61321. set cascadeBlendPercentage(value: number);
  61322. private _lambda;
  61323. /**
  61324. * Gets or set the lambda parameter.
  61325. * This parameter is used to split the camera frustum and create the cascades.
  61326. * 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.
  61327. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61328. */
  61329. get lambda(): number;
  61330. set lambda(value: number);
  61331. /**
  61332. * Gets the view matrix corresponding to a given cascade
  61333. * @param cascadeNum cascade to retrieve the view matrix from
  61334. * @returns the cascade view matrix
  61335. */
  61336. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61337. /**
  61338. * Gets the projection matrix corresponding to a given cascade
  61339. * @param cascadeNum cascade to retrieve the projection matrix from
  61340. * @returns the cascade projection matrix
  61341. */
  61342. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61343. /**
  61344. * Gets the transformation matrix corresponding to a given cascade
  61345. * @param cascadeNum cascade to retrieve the transformation matrix from
  61346. * @returns the cascade transformation matrix
  61347. */
  61348. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61349. private _depthRenderer;
  61350. /**
  61351. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61352. *
  61353. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61354. *
  61355. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61356. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61357. * @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
  61358. */
  61359. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61360. private _depthReducer;
  61361. private _autoCalcDepthBounds;
  61362. /**
  61363. * Gets or sets the autoCalcDepthBounds property.
  61364. *
  61365. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61366. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61367. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61368. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61369. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61370. */
  61371. get autoCalcDepthBounds(): boolean;
  61372. set autoCalcDepthBounds(value: boolean);
  61373. /**
  61374. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61375. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61376. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61377. * for setting the refresh rate on the renderer yourself!
  61378. */
  61379. get autoCalcDepthBoundsRefreshRate(): number;
  61380. set autoCalcDepthBoundsRefreshRate(value: number);
  61381. /**
  61382. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61383. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61384. * you change the camera near/far planes!
  61385. */
  61386. splitFrustum(): void;
  61387. private _splitFrustum;
  61388. private _computeMatrices;
  61389. private _computeFrustumInWorldSpace;
  61390. private _computeCascadeFrustum;
  61391. /**
  61392. * Support test.
  61393. */
  61394. static get IsSupported(): boolean;
  61395. /** @hidden */
  61396. static _SceneComponentInitialization: (scene: Scene) => void;
  61397. /**
  61398. * Creates a Cascaded Shadow Generator object.
  61399. * A ShadowGenerator is the required tool to use the shadows.
  61400. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61401. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61402. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61403. * @param light The directional light object generating the shadows.
  61404. * @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.
  61405. */
  61406. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61407. protected _initializeGenerator(): void;
  61408. protected _createTargetRenderTexture(): void;
  61409. protected _initializeShadowMap(): void;
  61410. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61411. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61412. /**
  61413. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61414. * @param defines Defines of the material we want to update
  61415. * @param lightIndex Index of the light in the enabled light list of the material
  61416. */
  61417. prepareDefines(defines: any, lightIndex: number): void;
  61418. /**
  61419. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61420. * defined in the generator but impacting the effect).
  61421. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61422. * @param effect The effect we are binfing the information for
  61423. */
  61424. bindShadowLight(lightIndex: string, effect: Effect): void;
  61425. /**
  61426. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61427. * (eq to view projection * shadow projection matrices)
  61428. * @returns The transform matrix used to create the shadow map
  61429. */
  61430. getTransformMatrix(): Matrix;
  61431. /**
  61432. * Disposes the ShadowGenerator.
  61433. * Returns nothing.
  61434. */
  61435. dispose(): void;
  61436. /**
  61437. * Serializes the shadow generator setup to a json object.
  61438. * @returns The serialized JSON object
  61439. */
  61440. serialize(): any;
  61441. /**
  61442. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61443. * @param parsedShadowGenerator The JSON object to parse
  61444. * @param scene The scene to create the shadow map for
  61445. * @returns The parsed shadow generator
  61446. */
  61447. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61448. }
  61449. }
  61450. declare module BABYLON {
  61451. /**
  61452. * Defines the shadow generator component responsible to manage any shadow generators
  61453. * in a given scene.
  61454. */
  61455. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61456. /**
  61457. * The component name helpfull to identify the component in the list of scene components.
  61458. */
  61459. readonly name: string;
  61460. /**
  61461. * The scene the component belongs to.
  61462. */
  61463. scene: Scene;
  61464. /**
  61465. * Creates a new instance of the component for the given scene
  61466. * @param scene Defines the scene to register the component in
  61467. */
  61468. constructor(scene: Scene);
  61469. /**
  61470. * Registers the component in a given scene
  61471. */
  61472. register(): void;
  61473. /**
  61474. * Rebuilds the elements related to this component in case of
  61475. * context lost for instance.
  61476. */
  61477. rebuild(): void;
  61478. /**
  61479. * Serializes the component data to the specified json object
  61480. * @param serializationObject The object to serialize to
  61481. */
  61482. serialize(serializationObject: any): void;
  61483. /**
  61484. * Adds all the elements from the container to the scene
  61485. * @param container the container holding the elements
  61486. */
  61487. addFromContainer(container: AbstractScene): void;
  61488. /**
  61489. * Removes all the elements in the container from the scene
  61490. * @param container contains the elements to remove
  61491. * @param dispose if the removed element should be disposed (default: false)
  61492. */
  61493. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61494. /**
  61495. * Rebuilds the elements related to this component in case of
  61496. * context lost for instance.
  61497. */
  61498. dispose(): void;
  61499. private _gatherRenderTargets;
  61500. }
  61501. }
  61502. declare module BABYLON {
  61503. /**
  61504. * A point light is a light defined by an unique point in world space.
  61505. * The light is emitted in every direction from this point.
  61506. * A good example of a point light is a standard light bulb.
  61507. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61508. */
  61509. export class PointLight extends ShadowLight {
  61510. private _shadowAngle;
  61511. /**
  61512. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61513. * This specifies what angle the shadow will use to be created.
  61514. *
  61515. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61516. */
  61517. get shadowAngle(): number;
  61518. /**
  61519. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61520. * This specifies what angle the shadow will use to be created.
  61521. *
  61522. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61523. */
  61524. set shadowAngle(value: number);
  61525. /**
  61526. * Gets the direction if it has been set.
  61527. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61528. */
  61529. get direction(): Vector3;
  61530. /**
  61531. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61532. */
  61533. set direction(value: Vector3);
  61534. /**
  61535. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61536. * A PointLight emits the light in every direction.
  61537. * It can cast shadows.
  61538. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61539. * ```javascript
  61540. * var pointLight = new PointLight("pl", camera.position, scene);
  61541. * ```
  61542. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61543. * @param name The light friendly name
  61544. * @param position The position of the point light in the scene
  61545. * @param scene The scene the lights belongs to
  61546. */
  61547. constructor(name: string, position: Vector3, scene: Scene);
  61548. /**
  61549. * Returns the string "PointLight"
  61550. * @returns the class name
  61551. */
  61552. getClassName(): string;
  61553. /**
  61554. * Returns the integer 0.
  61555. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61556. */
  61557. getTypeID(): number;
  61558. /**
  61559. * Specifies wether or not the shadowmap should be a cube texture.
  61560. * @returns true if the shadowmap needs to be a cube texture.
  61561. */
  61562. needCube(): boolean;
  61563. /**
  61564. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61565. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61566. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61567. */
  61568. getShadowDirection(faceIndex?: number): Vector3;
  61569. /**
  61570. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61571. * - fov = PI / 2
  61572. * - aspect ratio : 1.0
  61573. * - z-near and far equal to the active camera minZ and maxZ.
  61574. * Returns the PointLight.
  61575. */
  61576. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61577. protected _buildUniformLayout(): void;
  61578. /**
  61579. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61580. * @param effect The effect to update
  61581. * @param lightIndex The index of the light in the effect to update
  61582. * @returns The point light
  61583. */
  61584. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61585. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61586. /**
  61587. * Prepares the list of defines specific to the light type.
  61588. * @param defines the list of defines
  61589. * @param lightIndex defines the index of the light for the effect
  61590. */
  61591. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61592. }
  61593. }
  61594. declare module BABYLON {
  61595. /**
  61596. * Header information of HDR texture files.
  61597. */
  61598. export interface HDRInfo {
  61599. /**
  61600. * The height of the texture in pixels.
  61601. */
  61602. height: number;
  61603. /**
  61604. * The width of the texture in pixels.
  61605. */
  61606. width: number;
  61607. /**
  61608. * The index of the beginning of the data in the binary file.
  61609. */
  61610. dataPosition: number;
  61611. }
  61612. /**
  61613. * This groups tools to convert HDR texture to native colors array.
  61614. */
  61615. export class HDRTools {
  61616. private static Ldexp;
  61617. private static Rgbe2float;
  61618. private static readStringLine;
  61619. /**
  61620. * Reads header information from an RGBE texture stored in a native array.
  61621. * More information on this format are available here:
  61622. * https://en.wikipedia.org/wiki/RGBE_image_format
  61623. *
  61624. * @param uint8array The binary file stored in native array.
  61625. * @return The header information.
  61626. */
  61627. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61628. /**
  61629. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61630. * This RGBE texture needs to store the information as a panorama.
  61631. *
  61632. * More information on this format are available here:
  61633. * https://en.wikipedia.org/wiki/RGBE_image_format
  61634. *
  61635. * @param buffer The binary file stored in an array buffer.
  61636. * @param size The expected size of the extracted cubemap.
  61637. * @return The Cube Map information.
  61638. */
  61639. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61640. /**
  61641. * Returns the pixels data extracted from an RGBE texture.
  61642. * This pixels will be stored left to right up to down in the R G B order in one array.
  61643. *
  61644. * More information on this format are available here:
  61645. * https://en.wikipedia.org/wiki/RGBE_image_format
  61646. *
  61647. * @param uint8array The binary file stored in an array buffer.
  61648. * @param hdrInfo The header information of the file.
  61649. * @return The pixels data in RGB right to left up to down order.
  61650. */
  61651. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61652. private static RGBE_ReadPixels_RLE;
  61653. private static RGBE_ReadPixels_NOT_RLE;
  61654. }
  61655. }
  61656. declare module BABYLON {
  61657. /**
  61658. * Effect Render Options
  61659. */
  61660. export interface IEffectRendererOptions {
  61661. /**
  61662. * Defines the vertices positions.
  61663. */
  61664. positions?: number[];
  61665. /**
  61666. * Defines the indices.
  61667. */
  61668. indices?: number[];
  61669. }
  61670. /**
  61671. * Helper class to render one or more effects.
  61672. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61673. */
  61674. export class EffectRenderer {
  61675. private engine;
  61676. private static _DefaultOptions;
  61677. private _vertexBuffers;
  61678. private _indexBuffer;
  61679. private _fullscreenViewport;
  61680. /**
  61681. * Creates an effect renderer
  61682. * @param engine the engine to use for rendering
  61683. * @param options defines the options of the effect renderer
  61684. */
  61685. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61686. /**
  61687. * Sets the current viewport in normalized coordinates 0-1
  61688. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61689. */
  61690. setViewport(viewport?: Viewport): void;
  61691. /**
  61692. * Binds the embedded attributes buffer to the effect.
  61693. * @param effect Defines the effect to bind the attributes for
  61694. */
  61695. bindBuffers(effect: Effect): void;
  61696. /**
  61697. * Sets the current effect wrapper to use during draw.
  61698. * The effect needs to be ready before calling this api.
  61699. * This also sets the default full screen position attribute.
  61700. * @param effectWrapper Defines the effect to draw with
  61701. */
  61702. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61703. /**
  61704. * Restores engine states
  61705. */
  61706. restoreStates(): void;
  61707. /**
  61708. * Draws a full screen quad.
  61709. */
  61710. draw(): void;
  61711. private isRenderTargetTexture;
  61712. /**
  61713. * renders one or more effects to a specified texture
  61714. * @param effectWrapper the effect to renderer
  61715. * @param outputTexture texture to draw to, if null it will render to the screen.
  61716. */
  61717. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61718. /**
  61719. * Disposes of the effect renderer
  61720. */
  61721. dispose(): void;
  61722. }
  61723. /**
  61724. * Options to create an EffectWrapper
  61725. */
  61726. interface EffectWrapperCreationOptions {
  61727. /**
  61728. * Engine to use to create the effect
  61729. */
  61730. engine: ThinEngine;
  61731. /**
  61732. * Fragment shader for the effect
  61733. */
  61734. fragmentShader: string;
  61735. /**
  61736. * Use the shader store instead of direct source code
  61737. */
  61738. useShaderStore?: boolean;
  61739. /**
  61740. * Vertex shader for the effect
  61741. */
  61742. vertexShader?: string;
  61743. /**
  61744. * Attributes to use in the shader
  61745. */
  61746. attributeNames?: Array<string>;
  61747. /**
  61748. * Uniforms to use in the shader
  61749. */
  61750. uniformNames?: Array<string>;
  61751. /**
  61752. * Texture sampler names to use in the shader
  61753. */
  61754. samplerNames?: Array<string>;
  61755. /**
  61756. * Defines to use in the shader
  61757. */
  61758. defines?: Array<string>;
  61759. /**
  61760. * Callback when effect is compiled
  61761. */
  61762. onCompiled?: Nullable<(effect: Effect) => void>;
  61763. /**
  61764. * The friendly name of the effect displayed in Spector.
  61765. */
  61766. name?: string;
  61767. }
  61768. /**
  61769. * Wraps an effect to be used for rendering
  61770. */
  61771. export class EffectWrapper {
  61772. /**
  61773. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61774. */
  61775. onApplyObservable: Observable<{}>;
  61776. /**
  61777. * The underlying effect
  61778. */
  61779. effect: Effect;
  61780. /**
  61781. * Creates an effect to be renderer
  61782. * @param creationOptions options to create the effect
  61783. */
  61784. constructor(creationOptions: EffectWrapperCreationOptions);
  61785. /**
  61786. * Disposes of the effect wrapper
  61787. */
  61788. dispose(): void;
  61789. }
  61790. }
  61791. declare module BABYLON {
  61792. /** @hidden */
  61793. export var hdrFilteringVertexShader: {
  61794. name: string;
  61795. shader: string;
  61796. };
  61797. }
  61798. declare module BABYLON {
  61799. /** @hidden */
  61800. export var hdrFilteringPixelShader: {
  61801. name: string;
  61802. shader: string;
  61803. };
  61804. }
  61805. declare module BABYLON {
  61806. /**
  61807. * Options for texture filtering
  61808. */
  61809. interface IHDRFilteringOptions {
  61810. /**
  61811. * Scales pixel intensity for the input HDR map.
  61812. */
  61813. hdrScale?: number;
  61814. /**
  61815. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61816. */
  61817. quality?: number;
  61818. }
  61819. /**
  61820. * Filters HDR maps to get correct renderings of PBR reflections
  61821. */
  61822. export class HDRFiltering {
  61823. private _engine;
  61824. private _effectRenderer;
  61825. private _effectWrapper;
  61826. private _lodGenerationOffset;
  61827. private _lodGenerationScale;
  61828. /**
  61829. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61830. * you care about baking speed.
  61831. */
  61832. quality: number;
  61833. /**
  61834. * Scales pixel intensity for the input HDR map.
  61835. */
  61836. hdrScale: number;
  61837. /**
  61838. * Instantiates HDR filter for reflection maps
  61839. *
  61840. * @param engine Thin engine
  61841. * @param options Options
  61842. */
  61843. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61844. private _createRenderTarget;
  61845. private _prefilterInternal;
  61846. private _createEffect;
  61847. /**
  61848. * Get a value indicating if the filter is ready to be used
  61849. * @param texture Texture to filter
  61850. * @returns true if the filter is ready
  61851. */
  61852. isReady(texture: BaseTexture): boolean;
  61853. /**
  61854. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61855. * Prefiltering will be invoked at the end of next rendering pass.
  61856. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61857. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61858. * @param texture Texture to filter
  61859. * @param onFinished Callback when filtering is done
  61860. * @return Promise called when prefiltering is done
  61861. */
  61862. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61863. }
  61864. }
  61865. declare module BABYLON {
  61866. /**
  61867. * This represents a texture coming from an HDR input.
  61868. *
  61869. * The only supported format is currently panorama picture stored in RGBE format.
  61870. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61871. */
  61872. export class HDRCubeTexture extends BaseTexture {
  61873. private static _facesMapping;
  61874. private _generateHarmonics;
  61875. private _noMipmap;
  61876. private _prefilterOnLoad;
  61877. private _textureMatrix;
  61878. private _size;
  61879. private _onLoad;
  61880. private _onError;
  61881. /**
  61882. * The texture URL.
  61883. */
  61884. url: string;
  61885. protected _isBlocking: boolean;
  61886. /**
  61887. * Sets wether or not the texture is blocking during loading.
  61888. */
  61889. set isBlocking(value: boolean);
  61890. /**
  61891. * Gets wether or not the texture is blocking during loading.
  61892. */
  61893. get isBlocking(): boolean;
  61894. protected _rotationY: number;
  61895. /**
  61896. * Sets texture matrix rotation angle around Y axis in radians.
  61897. */
  61898. set rotationY(value: number);
  61899. /**
  61900. * Gets texture matrix rotation angle around Y axis radians.
  61901. */
  61902. get rotationY(): number;
  61903. /**
  61904. * Gets or sets the center of the bounding box associated with the cube texture
  61905. * It must define where the camera used to render the texture was set
  61906. */
  61907. boundingBoxPosition: Vector3;
  61908. private _boundingBoxSize;
  61909. /**
  61910. * Gets or sets the size of the bounding box associated with the cube texture
  61911. * When defined, the cubemap will switch to local mode
  61912. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61913. * @example https://www.babylonjs-playground.com/#RNASML
  61914. */
  61915. set boundingBoxSize(value: Vector3);
  61916. get boundingBoxSize(): Vector3;
  61917. /**
  61918. * Instantiates an HDRTexture from the following parameters.
  61919. *
  61920. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61921. * @param sceneOrEngine The scene or engine the texture will be used in
  61922. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61923. * @param noMipmap Forces to not generate the mipmap if true
  61924. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61925. * @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)
  61926. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61927. */
  61928. 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>);
  61929. /**
  61930. * Get the current class name of the texture useful for serialization or dynamic coding.
  61931. * @returns "HDRCubeTexture"
  61932. */
  61933. getClassName(): string;
  61934. /**
  61935. * Occurs when the file is raw .hdr file.
  61936. */
  61937. private loadTexture;
  61938. clone(): HDRCubeTexture;
  61939. delayLoad(): void;
  61940. /**
  61941. * Get the texture reflection matrix used to rotate/transform the reflection.
  61942. * @returns the reflection matrix
  61943. */
  61944. getReflectionTextureMatrix(): Matrix;
  61945. /**
  61946. * Set the texture reflection matrix used to rotate/transform the reflection.
  61947. * @param value Define the reflection matrix to set
  61948. */
  61949. setReflectionTextureMatrix(value: Matrix): void;
  61950. /**
  61951. * Parses a JSON representation of an HDR Texture in order to create the texture
  61952. * @param parsedTexture Define the JSON representation
  61953. * @param scene Define the scene the texture should be created in
  61954. * @param rootUrl Define the root url in case we need to load relative dependencies
  61955. * @returns the newly created texture after parsing
  61956. */
  61957. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61958. serialize(): any;
  61959. }
  61960. }
  61961. declare module BABYLON {
  61962. /**
  61963. * Class used to control physics engine
  61964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61965. */
  61966. export class PhysicsEngine implements IPhysicsEngine {
  61967. private _physicsPlugin;
  61968. /**
  61969. * Global value used to control the smallest number supported by the simulation
  61970. */
  61971. static Epsilon: number;
  61972. private _impostors;
  61973. private _joints;
  61974. private _subTimeStep;
  61975. /**
  61976. * Gets the gravity vector used by the simulation
  61977. */
  61978. gravity: Vector3;
  61979. /**
  61980. * Factory used to create the default physics plugin.
  61981. * @returns The default physics plugin
  61982. */
  61983. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61984. /**
  61985. * Creates a new Physics Engine
  61986. * @param gravity defines the gravity vector used by the simulation
  61987. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61988. */
  61989. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61990. /**
  61991. * Sets the gravity vector used by the simulation
  61992. * @param gravity defines the gravity vector to use
  61993. */
  61994. setGravity(gravity: Vector3): void;
  61995. /**
  61996. * Set the time step of the physics engine.
  61997. * Default is 1/60.
  61998. * To slow it down, enter 1/600 for example.
  61999. * To speed it up, 1/30
  62000. * @param newTimeStep defines the new timestep to apply to this world.
  62001. */
  62002. setTimeStep(newTimeStep?: number): void;
  62003. /**
  62004. * Get the time step of the physics engine.
  62005. * @returns the current time step
  62006. */
  62007. getTimeStep(): number;
  62008. /**
  62009. * Set the sub time step of the physics engine.
  62010. * Default is 0 meaning there is no sub steps
  62011. * To increase physics resolution precision, set a small value (like 1 ms)
  62012. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62013. */
  62014. setSubTimeStep(subTimeStep?: number): void;
  62015. /**
  62016. * Get the sub time step of the physics engine.
  62017. * @returns the current sub time step
  62018. */
  62019. getSubTimeStep(): number;
  62020. /**
  62021. * Release all resources
  62022. */
  62023. dispose(): void;
  62024. /**
  62025. * Gets the name of the current physics plugin
  62026. * @returns the name of the plugin
  62027. */
  62028. getPhysicsPluginName(): string;
  62029. /**
  62030. * Adding a new impostor for the impostor tracking.
  62031. * This will be done by the impostor itself.
  62032. * @param impostor the impostor to add
  62033. */
  62034. addImpostor(impostor: PhysicsImpostor): void;
  62035. /**
  62036. * Remove an impostor from the engine.
  62037. * This impostor and its mesh will not longer be updated by the physics engine.
  62038. * @param impostor the impostor to remove
  62039. */
  62040. removeImpostor(impostor: PhysicsImpostor): void;
  62041. /**
  62042. * Add a joint to the physics engine
  62043. * @param mainImpostor defines the main impostor to which the joint is added.
  62044. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62045. * @param joint defines the joint that will connect both impostors.
  62046. */
  62047. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62048. /**
  62049. * Removes a joint from the simulation
  62050. * @param mainImpostor defines the impostor used with the joint
  62051. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62052. * @param joint defines the joint to remove
  62053. */
  62054. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62055. /**
  62056. * Called by the scene. No need to call it.
  62057. * @param delta defines the timespam between frames
  62058. */
  62059. _step(delta: number): void;
  62060. /**
  62061. * Gets the current plugin used to run the simulation
  62062. * @returns current plugin
  62063. */
  62064. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62065. /**
  62066. * Gets the list of physic impostors
  62067. * @returns an array of PhysicsImpostor
  62068. */
  62069. getImpostors(): Array<PhysicsImpostor>;
  62070. /**
  62071. * Gets the impostor for a physics enabled object
  62072. * @param object defines the object impersonated by the impostor
  62073. * @returns the PhysicsImpostor or null if not found
  62074. */
  62075. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62076. /**
  62077. * Gets the impostor for a physics body object
  62078. * @param body defines physics body used by the impostor
  62079. * @returns the PhysicsImpostor or null if not found
  62080. */
  62081. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62082. /**
  62083. * Does a raycast in the physics world
  62084. * @param from when should the ray start?
  62085. * @param to when should the ray end?
  62086. * @returns PhysicsRaycastResult
  62087. */
  62088. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62089. }
  62090. }
  62091. declare module BABYLON {
  62092. /** @hidden */
  62093. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62094. private _useDeltaForWorldStep;
  62095. world: any;
  62096. name: string;
  62097. private _physicsMaterials;
  62098. private _fixedTimeStep;
  62099. private _cannonRaycastResult;
  62100. private _raycastResult;
  62101. private _physicsBodysToRemoveAfterStep;
  62102. private _firstFrame;
  62103. BJSCANNON: any;
  62104. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62105. setGravity(gravity: Vector3): void;
  62106. setTimeStep(timeStep: number): void;
  62107. getTimeStep(): number;
  62108. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62109. private _removeMarkedPhysicsBodiesFromWorld;
  62110. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62111. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62112. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62113. private _processChildMeshes;
  62114. removePhysicsBody(impostor: PhysicsImpostor): void;
  62115. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62116. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62117. private _addMaterial;
  62118. private _checkWithEpsilon;
  62119. private _createShape;
  62120. private _createHeightmap;
  62121. private _minus90X;
  62122. private _plus90X;
  62123. private _tmpPosition;
  62124. private _tmpDeltaPosition;
  62125. private _tmpUnityRotation;
  62126. private _updatePhysicsBodyTransformation;
  62127. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62128. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62129. isSupported(): boolean;
  62130. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62131. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62132. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62133. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62134. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62135. getBodyMass(impostor: PhysicsImpostor): number;
  62136. getBodyFriction(impostor: PhysicsImpostor): number;
  62137. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62138. getBodyRestitution(impostor: PhysicsImpostor): number;
  62139. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62140. sleepBody(impostor: PhysicsImpostor): void;
  62141. wakeUpBody(impostor: PhysicsImpostor): void;
  62142. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62143. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62144. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62145. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62146. getRadius(impostor: PhysicsImpostor): number;
  62147. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62148. dispose(): void;
  62149. private _extendNamespace;
  62150. /**
  62151. * Does a raycast in the physics world
  62152. * @param from when should the ray start?
  62153. * @param to when should the ray end?
  62154. * @returns PhysicsRaycastResult
  62155. */
  62156. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62157. }
  62158. }
  62159. declare module BABYLON {
  62160. /** @hidden */
  62161. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62162. private _useDeltaForWorldStep;
  62163. world: any;
  62164. name: string;
  62165. BJSOIMO: any;
  62166. private _raycastResult;
  62167. private _fixedTimeStep;
  62168. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62169. setGravity(gravity: Vector3): void;
  62170. setTimeStep(timeStep: number): void;
  62171. getTimeStep(): number;
  62172. private _tmpImpostorsArray;
  62173. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62174. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62175. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62176. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62177. private _tmpPositionVector;
  62178. removePhysicsBody(impostor: PhysicsImpostor): void;
  62179. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62180. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62181. isSupported(): boolean;
  62182. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62183. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62184. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62185. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62186. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62187. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62188. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62189. getBodyMass(impostor: PhysicsImpostor): number;
  62190. getBodyFriction(impostor: PhysicsImpostor): number;
  62191. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62192. getBodyRestitution(impostor: PhysicsImpostor): number;
  62193. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62194. sleepBody(impostor: PhysicsImpostor): void;
  62195. wakeUpBody(impostor: PhysicsImpostor): void;
  62196. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62197. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62198. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62199. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62200. getRadius(impostor: PhysicsImpostor): number;
  62201. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62202. dispose(): void;
  62203. /**
  62204. * Does a raycast in the physics world
  62205. * @param from when should the ray start?
  62206. * @param to when should the ray end?
  62207. * @returns PhysicsRaycastResult
  62208. */
  62209. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62210. }
  62211. }
  62212. declare module BABYLON {
  62213. /**
  62214. * AmmoJS Physics plugin
  62215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62216. * @see https://github.com/kripken/ammo.js/
  62217. */
  62218. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62219. private _useDeltaForWorldStep;
  62220. /**
  62221. * Reference to the Ammo library
  62222. */
  62223. bjsAMMO: any;
  62224. /**
  62225. * Created ammoJS world which physics bodies are added to
  62226. */
  62227. world: any;
  62228. /**
  62229. * Name of the plugin
  62230. */
  62231. name: string;
  62232. private _timeStep;
  62233. private _fixedTimeStep;
  62234. private _maxSteps;
  62235. private _tmpQuaternion;
  62236. private _tmpAmmoTransform;
  62237. private _tmpAmmoQuaternion;
  62238. private _tmpAmmoConcreteContactResultCallback;
  62239. private _collisionConfiguration;
  62240. private _dispatcher;
  62241. private _overlappingPairCache;
  62242. private _solver;
  62243. private _softBodySolver;
  62244. private _tmpAmmoVectorA;
  62245. private _tmpAmmoVectorB;
  62246. private _tmpAmmoVectorC;
  62247. private _tmpAmmoVectorD;
  62248. private _tmpContactCallbackResult;
  62249. private _tmpAmmoVectorRCA;
  62250. private _tmpAmmoVectorRCB;
  62251. private _raycastResult;
  62252. private _tmpContactPoint;
  62253. private static readonly DISABLE_COLLISION_FLAG;
  62254. private static readonly KINEMATIC_FLAG;
  62255. private static readonly DISABLE_DEACTIVATION_FLAG;
  62256. /**
  62257. * Initializes the ammoJS plugin
  62258. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62259. * @param ammoInjection can be used to inject your own ammo reference
  62260. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62261. */
  62262. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62263. /**
  62264. * Sets the gravity of the physics world (m/(s^2))
  62265. * @param gravity Gravity to set
  62266. */
  62267. setGravity(gravity: Vector3): void;
  62268. /**
  62269. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62270. * @param timeStep timestep to use in seconds
  62271. */
  62272. setTimeStep(timeStep: number): void;
  62273. /**
  62274. * 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)
  62275. * @param fixedTimeStep fixedTimeStep to use in seconds
  62276. */
  62277. setFixedTimeStep(fixedTimeStep: number): void;
  62278. /**
  62279. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62280. * @param maxSteps the maximum number of steps by the physics engine per frame
  62281. */
  62282. setMaxSteps(maxSteps: number): void;
  62283. /**
  62284. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62285. * @returns the current timestep in seconds
  62286. */
  62287. getTimeStep(): number;
  62288. /**
  62289. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62290. */
  62291. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62292. private _isImpostorInContact;
  62293. private _isImpostorPairInContact;
  62294. private _stepSimulation;
  62295. /**
  62296. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62297. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62298. * After the step the babylon meshes are set to the position of the physics imposters
  62299. * @param delta amount of time to step forward
  62300. * @param impostors array of imposters to update before/after the step
  62301. */
  62302. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62303. /**
  62304. * Update babylon mesh to match physics world object
  62305. * @param impostor imposter to match
  62306. */
  62307. private _afterSoftStep;
  62308. /**
  62309. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62310. * @param impostor imposter to match
  62311. */
  62312. private _ropeStep;
  62313. /**
  62314. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62315. * @param impostor imposter to match
  62316. */
  62317. private _softbodyOrClothStep;
  62318. private _tmpMatrix;
  62319. /**
  62320. * Applies an impulse on the imposter
  62321. * @param impostor imposter to apply impulse to
  62322. * @param force amount of force to be applied to the imposter
  62323. * @param contactPoint the location to apply the impulse on the imposter
  62324. */
  62325. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62326. /**
  62327. * Applies a force on the imposter
  62328. * @param impostor imposter to apply force
  62329. * @param force amount of force to be applied to the imposter
  62330. * @param contactPoint the location to apply the force on the imposter
  62331. */
  62332. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62333. /**
  62334. * Creates a physics body using the plugin
  62335. * @param impostor the imposter to create the physics body on
  62336. */
  62337. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62338. /**
  62339. * Removes the physics body from the imposter and disposes of the body's memory
  62340. * @param impostor imposter to remove the physics body from
  62341. */
  62342. removePhysicsBody(impostor: PhysicsImpostor): void;
  62343. /**
  62344. * Generates a joint
  62345. * @param impostorJoint the imposter joint to create the joint with
  62346. */
  62347. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62348. /**
  62349. * Removes a joint
  62350. * @param impostorJoint the imposter joint to remove the joint from
  62351. */
  62352. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62353. private _addMeshVerts;
  62354. /**
  62355. * Initialise the soft body vertices to match its object's (mesh) vertices
  62356. * Softbody vertices (nodes) are in world space and to match this
  62357. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62358. * @param impostor to create the softbody for
  62359. */
  62360. private _softVertexData;
  62361. /**
  62362. * Create an impostor's soft body
  62363. * @param impostor to create the softbody for
  62364. */
  62365. private _createSoftbody;
  62366. /**
  62367. * Create cloth for an impostor
  62368. * @param impostor to create the softbody for
  62369. */
  62370. private _createCloth;
  62371. /**
  62372. * Create rope for an impostor
  62373. * @param impostor to create the softbody for
  62374. */
  62375. private _createRope;
  62376. /**
  62377. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62378. * @param impostor to create the custom physics shape for
  62379. */
  62380. private _createCustom;
  62381. private _addHullVerts;
  62382. private _createShape;
  62383. /**
  62384. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62385. * @param impostor imposter containing the physics body and babylon object
  62386. */
  62387. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62388. /**
  62389. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62390. * @param impostor imposter containing the physics body and babylon object
  62391. * @param newPosition new position
  62392. * @param newRotation new rotation
  62393. */
  62394. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62395. /**
  62396. * If this plugin is supported
  62397. * @returns true if its supported
  62398. */
  62399. isSupported(): boolean;
  62400. /**
  62401. * Sets the linear velocity of the physics body
  62402. * @param impostor imposter to set the velocity on
  62403. * @param velocity velocity to set
  62404. */
  62405. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62406. /**
  62407. * Sets the angular velocity of the physics body
  62408. * @param impostor imposter to set the velocity on
  62409. * @param velocity velocity to set
  62410. */
  62411. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62412. /**
  62413. * gets the linear velocity
  62414. * @param impostor imposter to get linear velocity from
  62415. * @returns linear velocity
  62416. */
  62417. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62418. /**
  62419. * gets the angular velocity
  62420. * @param impostor imposter to get angular velocity from
  62421. * @returns angular velocity
  62422. */
  62423. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62424. /**
  62425. * Sets the mass of physics body
  62426. * @param impostor imposter to set the mass on
  62427. * @param mass mass to set
  62428. */
  62429. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62430. /**
  62431. * Gets the mass of the physics body
  62432. * @param impostor imposter to get the mass from
  62433. * @returns mass
  62434. */
  62435. getBodyMass(impostor: PhysicsImpostor): number;
  62436. /**
  62437. * Gets friction of the impostor
  62438. * @param impostor impostor to get friction from
  62439. * @returns friction value
  62440. */
  62441. getBodyFriction(impostor: PhysicsImpostor): number;
  62442. /**
  62443. * Sets friction of the impostor
  62444. * @param impostor impostor to set friction on
  62445. * @param friction friction value
  62446. */
  62447. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62448. /**
  62449. * Gets restitution of the impostor
  62450. * @param impostor impostor to get restitution from
  62451. * @returns restitution value
  62452. */
  62453. getBodyRestitution(impostor: PhysicsImpostor): number;
  62454. /**
  62455. * Sets resitution of the impostor
  62456. * @param impostor impostor to set resitution on
  62457. * @param restitution resitution value
  62458. */
  62459. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62460. /**
  62461. * Gets pressure inside the impostor
  62462. * @param impostor impostor to get pressure from
  62463. * @returns pressure value
  62464. */
  62465. getBodyPressure(impostor: PhysicsImpostor): number;
  62466. /**
  62467. * Sets pressure inside a soft body impostor
  62468. * Cloth and rope must remain 0 pressure
  62469. * @param impostor impostor to set pressure on
  62470. * @param pressure pressure value
  62471. */
  62472. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62473. /**
  62474. * Gets stiffness of the impostor
  62475. * @param impostor impostor to get stiffness from
  62476. * @returns pressure value
  62477. */
  62478. getBodyStiffness(impostor: PhysicsImpostor): number;
  62479. /**
  62480. * Sets stiffness of the impostor
  62481. * @param impostor impostor to set stiffness on
  62482. * @param stiffness stiffness value from 0 to 1
  62483. */
  62484. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62485. /**
  62486. * Gets velocityIterations of the impostor
  62487. * @param impostor impostor to get velocity iterations from
  62488. * @returns velocityIterations value
  62489. */
  62490. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62491. /**
  62492. * Sets velocityIterations of the impostor
  62493. * @param impostor impostor to set velocity iterations on
  62494. * @param velocityIterations velocityIterations value
  62495. */
  62496. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62497. /**
  62498. * Gets positionIterations of the impostor
  62499. * @param impostor impostor to get position iterations from
  62500. * @returns positionIterations value
  62501. */
  62502. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62503. /**
  62504. * Sets positionIterations of the impostor
  62505. * @param impostor impostor to set position on
  62506. * @param positionIterations positionIterations value
  62507. */
  62508. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62509. /**
  62510. * Append an anchor to a cloth object
  62511. * @param impostor is the cloth impostor to add anchor to
  62512. * @param otherImpostor is the rigid impostor to anchor to
  62513. * @param width ratio across width from 0 to 1
  62514. * @param height ratio up height from 0 to 1
  62515. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62516. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62517. */
  62518. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62519. /**
  62520. * Append an hook to a rope object
  62521. * @param impostor is the rope impostor to add hook to
  62522. * @param otherImpostor is the rigid impostor to hook to
  62523. * @param length ratio along the rope from 0 to 1
  62524. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62525. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62526. */
  62527. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62528. /**
  62529. * Sleeps the physics body and stops it from being active
  62530. * @param impostor impostor to sleep
  62531. */
  62532. sleepBody(impostor: PhysicsImpostor): void;
  62533. /**
  62534. * Activates the physics body
  62535. * @param impostor impostor to activate
  62536. */
  62537. wakeUpBody(impostor: PhysicsImpostor): void;
  62538. /**
  62539. * Updates the distance parameters of the joint
  62540. * @param joint joint to update
  62541. * @param maxDistance maximum distance of the joint
  62542. * @param minDistance minimum distance of the joint
  62543. */
  62544. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62545. /**
  62546. * Sets a motor on the joint
  62547. * @param joint joint to set motor on
  62548. * @param speed speed of the motor
  62549. * @param maxForce maximum force of the motor
  62550. * @param motorIndex index of the motor
  62551. */
  62552. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62553. /**
  62554. * Sets the motors limit
  62555. * @param joint joint to set limit on
  62556. * @param upperLimit upper limit
  62557. * @param lowerLimit lower limit
  62558. */
  62559. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62560. /**
  62561. * Syncs the position and rotation of a mesh with the impostor
  62562. * @param mesh mesh to sync
  62563. * @param impostor impostor to update the mesh with
  62564. */
  62565. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62566. /**
  62567. * Gets the radius of the impostor
  62568. * @param impostor impostor to get radius from
  62569. * @returns the radius
  62570. */
  62571. getRadius(impostor: PhysicsImpostor): number;
  62572. /**
  62573. * Gets the box size of the impostor
  62574. * @param impostor impostor to get box size from
  62575. * @param result the resulting box size
  62576. */
  62577. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62578. /**
  62579. * Disposes of the impostor
  62580. */
  62581. dispose(): void;
  62582. /**
  62583. * Does a raycast in the physics world
  62584. * @param from when should the ray start?
  62585. * @param to when should the ray end?
  62586. * @returns PhysicsRaycastResult
  62587. */
  62588. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62589. }
  62590. }
  62591. declare module BABYLON {
  62592. interface AbstractScene {
  62593. /**
  62594. * The list of reflection probes added to the scene
  62595. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62596. */
  62597. reflectionProbes: Array<ReflectionProbe>;
  62598. /**
  62599. * Removes the given reflection probe from this scene.
  62600. * @param toRemove The reflection probe to remove
  62601. * @returns The index of the removed reflection probe
  62602. */
  62603. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62604. /**
  62605. * Adds the given reflection probe to this scene.
  62606. * @param newReflectionProbe The reflection probe to add
  62607. */
  62608. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62609. }
  62610. /**
  62611. * Class used to generate realtime reflection / refraction cube textures
  62612. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62613. */
  62614. export class ReflectionProbe {
  62615. /** defines the name of the probe */
  62616. name: string;
  62617. private _scene;
  62618. private _renderTargetTexture;
  62619. private _projectionMatrix;
  62620. private _viewMatrix;
  62621. private _target;
  62622. private _add;
  62623. private _attachedMesh;
  62624. private _invertYAxis;
  62625. /** Gets or sets probe position (center of the cube map) */
  62626. position: Vector3;
  62627. /**
  62628. * Creates a new reflection probe
  62629. * @param name defines the name of the probe
  62630. * @param size defines the texture resolution (for each face)
  62631. * @param scene defines the hosting scene
  62632. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62633. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62634. */
  62635. constructor(
  62636. /** defines the name of the probe */
  62637. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62638. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62639. get samples(): number;
  62640. set samples(value: number);
  62641. /** Gets or sets the refresh rate to use (on every frame by default) */
  62642. get refreshRate(): number;
  62643. set refreshRate(value: number);
  62644. /**
  62645. * Gets the hosting scene
  62646. * @returns a Scene
  62647. */
  62648. getScene(): Scene;
  62649. /** Gets the internal CubeTexture used to render to */
  62650. get cubeTexture(): RenderTargetTexture;
  62651. /** Gets the list of meshes to render */
  62652. get renderList(): Nullable<AbstractMesh[]>;
  62653. /**
  62654. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62655. * @param mesh defines the mesh to attach to
  62656. */
  62657. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62658. /**
  62659. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62660. * @param renderingGroupId The rendering group id corresponding to its index
  62661. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62662. */
  62663. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62664. /**
  62665. * Clean all associated resources
  62666. */
  62667. dispose(): void;
  62668. /**
  62669. * Converts the reflection probe information to a readable string for debug purpose.
  62670. * @param fullDetails Supports for multiple levels of logging within scene loading
  62671. * @returns the human readable reflection probe info
  62672. */
  62673. toString(fullDetails?: boolean): string;
  62674. /**
  62675. * Get the class name of the relfection probe.
  62676. * @returns "ReflectionProbe"
  62677. */
  62678. getClassName(): string;
  62679. /**
  62680. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62681. * @returns The JSON representation of the texture
  62682. */
  62683. serialize(): any;
  62684. /**
  62685. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62686. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62687. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62688. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62689. * @returns The parsed reflection probe if successful
  62690. */
  62691. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62692. }
  62693. }
  62694. declare module BABYLON {
  62695. /** @hidden */
  62696. export var _BabylonLoaderRegistered: boolean;
  62697. /**
  62698. * Helps setting up some configuration for the babylon file loader.
  62699. */
  62700. export class BabylonFileLoaderConfiguration {
  62701. /**
  62702. * The loader does not allow injecting custom physix engine into the plugins.
  62703. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62704. * So you could set this variable to your engine import to make it work.
  62705. */
  62706. static LoaderInjectedPhysicsEngine: any;
  62707. }
  62708. }
  62709. declare module BABYLON {
  62710. /**
  62711. * The Physically based simple base material of BJS.
  62712. *
  62713. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62714. * It is used as the base class for both the specGloss and metalRough conventions.
  62715. */
  62716. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62717. /**
  62718. * Number of Simultaneous lights allowed on the material.
  62719. */
  62720. maxSimultaneousLights: number;
  62721. /**
  62722. * If sets to true, disables all the lights affecting the material.
  62723. */
  62724. disableLighting: boolean;
  62725. /**
  62726. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62727. */
  62728. environmentTexture: BaseTexture;
  62729. /**
  62730. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62731. */
  62732. invertNormalMapX: boolean;
  62733. /**
  62734. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62735. */
  62736. invertNormalMapY: boolean;
  62737. /**
  62738. * Normal map used in the model.
  62739. */
  62740. normalTexture: BaseTexture;
  62741. /**
  62742. * Emissivie color used to self-illuminate the model.
  62743. */
  62744. emissiveColor: Color3;
  62745. /**
  62746. * Emissivie texture used to self-illuminate the model.
  62747. */
  62748. emissiveTexture: BaseTexture;
  62749. /**
  62750. * Occlusion Channel Strenght.
  62751. */
  62752. occlusionStrength: number;
  62753. /**
  62754. * Occlusion Texture of the material (adding extra occlusion effects).
  62755. */
  62756. occlusionTexture: BaseTexture;
  62757. /**
  62758. * Defines the alpha limits in alpha test mode.
  62759. */
  62760. alphaCutOff: number;
  62761. /**
  62762. * Gets the current double sided mode.
  62763. */
  62764. get doubleSided(): boolean;
  62765. /**
  62766. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62767. */
  62768. set doubleSided(value: boolean);
  62769. /**
  62770. * Stores the pre-calculated light information of a mesh in a texture.
  62771. */
  62772. lightmapTexture: BaseTexture;
  62773. /**
  62774. * If true, the light map contains occlusion information instead of lighting info.
  62775. */
  62776. useLightmapAsShadowmap: boolean;
  62777. /**
  62778. * Instantiates a new PBRMaterial instance.
  62779. *
  62780. * @param name The material name
  62781. * @param scene The scene the material will be use in.
  62782. */
  62783. constructor(name: string, scene: Scene);
  62784. getClassName(): string;
  62785. }
  62786. }
  62787. declare module BABYLON {
  62788. /**
  62789. * The PBR material of BJS following the metal roughness convention.
  62790. *
  62791. * This fits to the PBR convention in the GLTF definition:
  62792. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62793. */
  62794. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62795. /**
  62796. * The base color has two different interpretations depending on the value of metalness.
  62797. * When the material is a metal, the base color is the specific measured reflectance value
  62798. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62799. * of the material.
  62800. */
  62801. baseColor: Color3;
  62802. /**
  62803. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62804. * well as opacity information in the alpha channel.
  62805. */
  62806. baseTexture: BaseTexture;
  62807. /**
  62808. * Specifies the metallic scalar value of the material.
  62809. * Can also be used to scale the metalness values of the metallic texture.
  62810. */
  62811. metallic: number;
  62812. /**
  62813. * Specifies the roughness scalar value of the material.
  62814. * Can also be used to scale the roughness values of the metallic texture.
  62815. */
  62816. roughness: number;
  62817. /**
  62818. * Texture containing both the metallic value in the B channel and the
  62819. * roughness value in the G channel to keep better precision.
  62820. */
  62821. metallicRoughnessTexture: BaseTexture;
  62822. /**
  62823. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62824. *
  62825. * @param name The material name
  62826. * @param scene The scene the material will be use in.
  62827. */
  62828. constructor(name: string, scene: Scene);
  62829. /**
  62830. * Return the currrent class name of the material.
  62831. */
  62832. getClassName(): string;
  62833. /**
  62834. * Makes a duplicate of the current material.
  62835. * @param name - name to use for the new material.
  62836. */
  62837. clone(name: string): PBRMetallicRoughnessMaterial;
  62838. /**
  62839. * Serialize the material to a parsable JSON object.
  62840. */
  62841. serialize(): any;
  62842. /**
  62843. * Parses a JSON object correponding to the serialize function.
  62844. */
  62845. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62846. }
  62847. }
  62848. declare module BABYLON {
  62849. /**
  62850. * The PBR material of BJS following the specular glossiness convention.
  62851. *
  62852. * This fits to the PBR convention in the GLTF definition:
  62853. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62854. */
  62855. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62856. /**
  62857. * Specifies the diffuse color of the material.
  62858. */
  62859. diffuseColor: Color3;
  62860. /**
  62861. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62862. * channel.
  62863. */
  62864. diffuseTexture: BaseTexture;
  62865. /**
  62866. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62867. */
  62868. specularColor: Color3;
  62869. /**
  62870. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62871. */
  62872. glossiness: number;
  62873. /**
  62874. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62875. */
  62876. specularGlossinessTexture: BaseTexture;
  62877. /**
  62878. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62879. *
  62880. * @param name The material name
  62881. * @param scene The scene the material will be use in.
  62882. */
  62883. constructor(name: string, scene: Scene);
  62884. /**
  62885. * Return the currrent class name of the material.
  62886. */
  62887. getClassName(): string;
  62888. /**
  62889. * Makes a duplicate of the current material.
  62890. * @param name - name to use for the new material.
  62891. */
  62892. clone(name: string): PBRSpecularGlossinessMaterial;
  62893. /**
  62894. * Serialize the material to a parsable JSON object.
  62895. */
  62896. serialize(): any;
  62897. /**
  62898. * Parses a JSON object correponding to the serialize function.
  62899. */
  62900. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62901. }
  62902. }
  62903. declare module BABYLON {
  62904. /**
  62905. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62906. * It can help converting any input color in a desired output one. This can then be used to create effects
  62907. * from sepia, black and white to sixties or futuristic rendering...
  62908. *
  62909. * The only supported format is currently 3dl.
  62910. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62911. */
  62912. export class ColorGradingTexture extends BaseTexture {
  62913. /**
  62914. * The texture URL.
  62915. */
  62916. url: string;
  62917. /**
  62918. * Empty line regex stored for GC.
  62919. */
  62920. private static _noneEmptyLineRegex;
  62921. private _textureMatrix;
  62922. private _onLoad;
  62923. /**
  62924. * Instantiates a ColorGradingTexture from the following parameters.
  62925. *
  62926. * @param url The location of the color gradind data (currently only supporting 3dl)
  62927. * @param sceneOrEngine The scene or engine the texture will be used in
  62928. * @param onLoad defines a callback triggered when the texture has been loaded
  62929. */
  62930. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62931. /**
  62932. * Fires the onload event from the constructor if requested.
  62933. */
  62934. private _triggerOnLoad;
  62935. /**
  62936. * Returns the texture matrix used in most of the material.
  62937. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62938. */
  62939. getTextureMatrix(): Matrix;
  62940. /**
  62941. * Occurs when the file being loaded is a .3dl LUT file.
  62942. */
  62943. private load3dlTexture;
  62944. /**
  62945. * Starts the loading process of the texture.
  62946. */
  62947. private loadTexture;
  62948. /**
  62949. * Clones the color gradind texture.
  62950. */
  62951. clone(): ColorGradingTexture;
  62952. /**
  62953. * Called during delayed load for textures.
  62954. */
  62955. delayLoad(): void;
  62956. /**
  62957. * Parses a color grading texture serialized by Babylon.
  62958. * @param parsedTexture The texture information being parsedTexture
  62959. * @param scene The scene to load the texture in
  62960. * @param rootUrl The root url of the data assets to load
  62961. * @return A color gradind texture
  62962. */
  62963. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62964. /**
  62965. * Serializes the LUT texture to json format.
  62966. */
  62967. serialize(): any;
  62968. }
  62969. }
  62970. declare module BABYLON {
  62971. /**
  62972. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62973. */
  62974. export class EquiRectangularCubeTexture extends BaseTexture {
  62975. /** The six faces of the cube. */
  62976. private static _FacesMapping;
  62977. private _noMipmap;
  62978. private _onLoad;
  62979. private _onError;
  62980. /** The size of the cubemap. */
  62981. private _size;
  62982. /** The buffer of the image. */
  62983. private _buffer;
  62984. /** The width of the input image. */
  62985. private _width;
  62986. /** The height of the input image. */
  62987. private _height;
  62988. /** The URL to the image. */
  62989. url: string;
  62990. /**
  62991. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62992. * @param url The location of the image
  62993. * @param scene The scene the texture will be used in
  62994. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62995. * @param noMipmap Forces to not generate the mipmap if true
  62996. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62997. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62998. * @param onLoad — defines a callback called when texture is loaded
  62999. * @param onError — defines a callback called if there is an error
  63000. */
  63001. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63002. /**
  63003. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63004. */
  63005. private loadImage;
  63006. /**
  63007. * Convert the image buffer into a cubemap and create a CubeTexture.
  63008. */
  63009. private loadTexture;
  63010. /**
  63011. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63012. * @param buffer The ArrayBuffer that should be converted.
  63013. * @returns The buffer as Float32Array.
  63014. */
  63015. private getFloat32ArrayFromArrayBuffer;
  63016. /**
  63017. * Get the current class name of the texture useful for serialization or dynamic coding.
  63018. * @returns "EquiRectangularCubeTexture"
  63019. */
  63020. getClassName(): string;
  63021. /**
  63022. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63023. * @returns A clone of the current EquiRectangularCubeTexture.
  63024. */
  63025. clone(): EquiRectangularCubeTexture;
  63026. }
  63027. }
  63028. declare module BABYLON {
  63029. /**
  63030. * Defines the options related to the creation of an HtmlElementTexture
  63031. */
  63032. export interface IHtmlElementTextureOptions {
  63033. /**
  63034. * Defines wether mip maps should be created or not.
  63035. */
  63036. generateMipMaps?: boolean;
  63037. /**
  63038. * Defines the sampling mode of the texture.
  63039. */
  63040. samplingMode?: number;
  63041. /**
  63042. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63043. */
  63044. engine: Nullable<ThinEngine>;
  63045. /**
  63046. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63047. */
  63048. scene: Nullable<Scene>;
  63049. }
  63050. /**
  63051. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63052. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63053. * is automatically managed.
  63054. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63055. * in your application.
  63056. *
  63057. * As the update is not automatic, you need to call them manually.
  63058. */
  63059. export class HtmlElementTexture extends BaseTexture {
  63060. /**
  63061. * The texture URL.
  63062. */
  63063. element: HTMLVideoElement | HTMLCanvasElement;
  63064. private static readonly DefaultOptions;
  63065. private _textureMatrix;
  63066. private _isVideo;
  63067. private _generateMipMaps;
  63068. private _samplingMode;
  63069. /**
  63070. * Instantiates a HtmlElementTexture from the following parameters.
  63071. *
  63072. * @param name Defines the name of the texture
  63073. * @param element Defines the video or canvas the texture is filled with
  63074. * @param options Defines the other none mandatory texture creation options
  63075. */
  63076. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63077. private _createInternalTexture;
  63078. /**
  63079. * Returns the texture matrix used in most of the material.
  63080. */
  63081. getTextureMatrix(): Matrix;
  63082. /**
  63083. * Updates the content of the texture.
  63084. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63085. */
  63086. update(invertY?: Nullable<boolean>): void;
  63087. }
  63088. }
  63089. declare module BABYLON {
  63090. /**
  63091. * Based on jsTGALoader - Javascript loader for TGA file
  63092. * By Vincent Thibault
  63093. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63094. */
  63095. export class TGATools {
  63096. private static _TYPE_INDEXED;
  63097. private static _TYPE_RGB;
  63098. private static _TYPE_GREY;
  63099. private static _TYPE_RLE_INDEXED;
  63100. private static _TYPE_RLE_RGB;
  63101. private static _TYPE_RLE_GREY;
  63102. private static _ORIGIN_MASK;
  63103. private static _ORIGIN_SHIFT;
  63104. private static _ORIGIN_BL;
  63105. private static _ORIGIN_BR;
  63106. private static _ORIGIN_UL;
  63107. private static _ORIGIN_UR;
  63108. /**
  63109. * Gets the header of a TGA file
  63110. * @param data defines the TGA data
  63111. * @returns the header
  63112. */
  63113. static GetTGAHeader(data: Uint8Array): any;
  63114. /**
  63115. * Uploads TGA content to a Babylon Texture
  63116. * @hidden
  63117. */
  63118. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63119. /** @hidden */
  63120. 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;
  63121. /** @hidden */
  63122. 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;
  63123. /** @hidden */
  63124. 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;
  63125. /** @hidden */
  63126. 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;
  63127. /** @hidden */
  63128. 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;
  63129. /** @hidden */
  63130. 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;
  63131. }
  63132. }
  63133. declare module BABYLON {
  63134. /**
  63135. * Implementation of the TGA Texture Loader.
  63136. * @hidden
  63137. */
  63138. export class _TGATextureLoader implements IInternalTextureLoader {
  63139. /**
  63140. * Defines wether the loader supports cascade loading the different faces.
  63141. */
  63142. readonly supportCascades: boolean;
  63143. /**
  63144. * This returns if the loader support the current file information.
  63145. * @param extension defines the file extension of the file being loaded
  63146. * @returns true if the loader can load the specified file
  63147. */
  63148. canLoad(extension: string): boolean;
  63149. /**
  63150. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63151. * @param data contains the texture data
  63152. * @param texture defines the BabylonJS internal texture
  63153. * @param createPolynomials will be true if polynomials have been requested
  63154. * @param onLoad defines the callback to trigger once the texture is ready
  63155. * @param onError defines the callback to trigger in case of error
  63156. */
  63157. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63158. /**
  63159. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63160. * @param data contains the texture data
  63161. * @param texture defines the BabylonJS internal texture
  63162. * @param callback defines the method to call once ready to upload
  63163. */
  63164. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63165. }
  63166. }
  63167. declare module BABYLON {
  63168. /**
  63169. * Info about the .basis files
  63170. */
  63171. class BasisFileInfo {
  63172. /**
  63173. * If the file has alpha
  63174. */
  63175. hasAlpha: boolean;
  63176. /**
  63177. * Info about each image of the basis file
  63178. */
  63179. images: Array<{
  63180. levels: Array<{
  63181. width: number;
  63182. height: number;
  63183. transcodedPixels: ArrayBufferView;
  63184. }>;
  63185. }>;
  63186. }
  63187. /**
  63188. * Result of transcoding a basis file
  63189. */
  63190. class TranscodeResult {
  63191. /**
  63192. * Info about the .basis file
  63193. */
  63194. fileInfo: BasisFileInfo;
  63195. /**
  63196. * Format to use when loading the file
  63197. */
  63198. format: number;
  63199. }
  63200. /**
  63201. * Configuration options for the Basis transcoder
  63202. */
  63203. export class BasisTranscodeConfiguration {
  63204. /**
  63205. * Supported compression formats used to determine the supported output format of the transcoder
  63206. */
  63207. supportedCompressionFormats?: {
  63208. /**
  63209. * etc1 compression format
  63210. */
  63211. etc1?: boolean;
  63212. /**
  63213. * s3tc compression format
  63214. */
  63215. s3tc?: boolean;
  63216. /**
  63217. * pvrtc compression format
  63218. */
  63219. pvrtc?: boolean;
  63220. /**
  63221. * etc2 compression format
  63222. */
  63223. etc2?: boolean;
  63224. };
  63225. /**
  63226. * If mipmap levels should be loaded for transcoded images (Default: true)
  63227. */
  63228. loadMipmapLevels?: boolean;
  63229. /**
  63230. * Index of a single image to load (Default: all images)
  63231. */
  63232. loadSingleImage?: number;
  63233. }
  63234. /**
  63235. * Used to load .Basis files
  63236. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63237. */
  63238. export class BasisTools {
  63239. private static _IgnoreSupportedFormats;
  63240. /**
  63241. * URL to use when loading the basis transcoder
  63242. */
  63243. static JSModuleURL: string;
  63244. /**
  63245. * URL to use when loading the wasm module for the transcoder
  63246. */
  63247. static WasmModuleURL: string;
  63248. /**
  63249. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63250. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63251. * @returns internal format corresponding to the Basis format
  63252. */
  63253. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63254. private static _WorkerPromise;
  63255. private static _Worker;
  63256. private static _actionId;
  63257. private static _CreateWorkerAsync;
  63258. /**
  63259. * Transcodes a loaded image file to compressed pixel data
  63260. * @param data image data to transcode
  63261. * @param config configuration options for the transcoding
  63262. * @returns a promise resulting in the transcoded image
  63263. */
  63264. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63265. /**
  63266. * Loads a texture from the transcode result
  63267. * @param texture texture load to
  63268. * @param transcodeResult the result of transcoding the basis file to load from
  63269. */
  63270. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63271. }
  63272. }
  63273. declare module BABYLON {
  63274. /**
  63275. * Loader for .basis file format
  63276. */
  63277. export class _BasisTextureLoader implements IInternalTextureLoader {
  63278. /**
  63279. * Defines whether the loader supports cascade loading the different faces.
  63280. */
  63281. readonly supportCascades: boolean;
  63282. /**
  63283. * This returns if the loader support the current file information.
  63284. * @param extension defines the file extension of the file being loaded
  63285. * @returns true if the loader can load the specified file
  63286. */
  63287. canLoad(extension: string): boolean;
  63288. /**
  63289. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63290. * @param data contains the texture data
  63291. * @param texture defines the BabylonJS internal texture
  63292. * @param createPolynomials will be true if polynomials have been requested
  63293. * @param onLoad defines the callback to trigger once the texture is ready
  63294. * @param onError defines the callback to trigger in case of error
  63295. */
  63296. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63297. /**
  63298. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63299. * @param data contains the texture data
  63300. * @param texture defines the BabylonJS internal texture
  63301. * @param callback defines the method to call once ready to upload
  63302. */
  63303. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63304. }
  63305. }
  63306. declare module BABYLON {
  63307. /**
  63308. * Defines the basic options interface of a TexturePacker Frame
  63309. */
  63310. export interface ITexturePackerFrame {
  63311. /**
  63312. * The frame ID
  63313. */
  63314. id: number;
  63315. /**
  63316. * The frames Scale
  63317. */
  63318. scale: Vector2;
  63319. /**
  63320. * The Frames offset
  63321. */
  63322. offset: Vector2;
  63323. }
  63324. /**
  63325. * This is a support class for frame Data on texture packer sets.
  63326. */
  63327. export class TexturePackerFrame implements ITexturePackerFrame {
  63328. /**
  63329. * The frame ID
  63330. */
  63331. id: number;
  63332. /**
  63333. * The frames Scale
  63334. */
  63335. scale: Vector2;
  63336. /**
  63337. * The Frames offset
  63338. */
  63339. offset: Vector2;
  63340. /**
  63341. * Initializes a texture package frame.
  63342. * @param id The numerical frame identifier
  63343. * @param scale Scalar Vector2 for UV frame
  63344. * @param offset Vector2 for the frame position in UV units.
  63345. * @returns TexturePackerFrame
  63346. */
  63347. constructor(id: number, scale: Vector2, offset: Vector2);
  63348. }
  63349. }
  63350. declare module BABYLON {
  63351. /**
  63352. * Defines the basic options interface of a TexturePacker
  63353. */
  63354. export interface ITexturePackerOptions {
  63355. /**
  63356. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63357. */
  63358. map?: string[];
  63359. /**
  63360. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63361. */
  63362. uvsIn?: string;
  63363. /**
  63364. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63365. */
  63366. uvsOut?: string;
  63367. /**
  63368. * number representing the layout style. Defaults to LAYOUT_STRIP
  63369. */
  63370. layout?: number;
  63371. /**
  63372. * number of columns if using custom column count layout(2). This defaults to 4.
  63373. */
  63374. colnum?: number;
  63375. /**
  63376. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63377. */
  63378. updateInputMeshes?: boolean;
  63379. /**
  63380. * boolean flag to dispose all the source textures. Defaults to true.
  63381. */
  63382. disposeSources?: boolean;
  63383. /**
  63384. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63385. */
  63386. fillBlanks?: boolean;
  63387. /**
  63388. * string value representing the context fill style color. Defaults to 'black'.
  63389. */
  63390. customFillColor?: string;
  63391. /**
  63392. * Width and Height Value of each Frame in the TexturePacker Sets
  63393. */
  63394. frameSize?: number;
  63395. /**
  63396. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63397. */
  63398. paddingRatio?: number;
  63399. /**
  63400. * Number that declares the fill method for the padding gutter.
  63401. */
  63402. paddingMode?: number;
  63403. /**
  63404. * If in SUBUV_COLOR padding mode what color to use.
  63405. */
  63406. paddingColor?: Color3 | Color4;
  63407. }
  63408. /**
  63409. * Defines the basic interface of a TexturePacker JSON File
  63410. */
  63411. export interface ITexturePackerJSON {
  63412. /**
  63413. * The frame ID
  63414. */
  63415. name: string;
  63416. /**
  63417. * The base64 channel data
  63418. */
  63419. sets: any;
  63420. /**
  63421. * The options of the Packer
  63422. */
  63423. options: ITexturePackerOptions;
  63424. /**
  63425. * The frame data of the Packer
  63426. */
  63427. frames: Array<number>;
  63428. }
  63429. /**
  63430. * This is a support class that generates a series of packed texture sets.
  63431. * @see https://doc.babylonjs.com/babylon101/materials
  63432. */
  63433. export class TexturePacker {
  63434. /** Packer Layout Constant 0 */
  63435. static readonly LAYOUT_STRIP: number;
  63436. /** Packer Layout Constant 1 */
  63437. static readonly LAYOUT_POWER2: number;
  63438. /** Packer Layout Constant 2 */
  63439. static readonly LAYOUT_COLNUM: number;
  63440. /** Packer Layout Constant 0 */
  63441. static readonly SUBUV_WRAP: number;
  63442. /** Packer Layout Constant 1 */
  63443. static readonly SUBUV_EXTEND: number;
  63444. /** Packer Layout Constant 2 */
  63445. static readonly SUBUV_COLOR: number;
  63446. /** The Name of the Texture Package */
  63447. name: string;
  63448. /** The scene scope of the TexturePacker */
  63449. scene: Scene;
  63450. /** The Meshes to target */
  63451. meshes: AbstractMesh[];
  63452. /** Arguments passed with the Constructor */
  63453. options: ITexturePackerOptions;
  63454. /** The promise that is started upon initialization */
  63455. promise: Nullable<Promise<TexturePacker | string>>;
  63456. /** The Container object for the channel sets that are generated */
  63457. sets: object;
  63458. /** The Container array for the frames that are generated */
  63459. frames: TexturePackerFrame[];
  63460. /** The expected number of textures the system is parsing. */
  63461. private _expecting;
  63462. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63463. private _paddingValue;
  63464. /**
  63465. * Initializes a texture package series from an array of meshes or a single mesh.
  63466. * @param name The name of the package
  63467. * @param meshes The target meshes to compose the package from
  63468. * @param options The arguments that texture packer should follow while building.
  63469. * @param scene The scene which the textures are scoped to.
  63470. * @returns TexturePacker
  63471. */
  63472. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63473. /**
  63474. * Starts the package process
  63475. * @param resolve The promises resolution function
  63476. * @returns TexturePacker
  63477. */
  63478. private _createFrames;
  63479. /**
  63480. * Calculates the Size of the Channel Sets
  63481. * @returns Vector2
  63482. */
  63483. private _calculateSize;
  63484. /**
  63485. * Calculates the UV data for the frames.
  63486. * @param baseSize the base frameSize
  63487. * @param padding the base frame padding
  63488. * @param dtSize size of the Dynamic Texture for that channel
  63489. * @param dtUnits is 1/dtSize
  63490. * @param update flag to update the input meshes
  63491. */
  63492. private _calculateMeshUVFrames;
  63493. /**
  63494. * Calculates the frames Offset.
  63495. * @param index of the frame
  63496. * @returns Vector2
  63497. */
  63498. private _getFrameOffset;
  63499. /**
  63500. * Updates a Mesh to the frame data
  63501. * @param mesh that is the target
  63502. * @param frameID or the frame index
  63503. */
  63504. private _updateMeshUV;
  63505. /**
  63506. * Updates a Meshes materials to use the texture packer channels
  63507. * @param m is the mesh to target
  63508. * @param force all channels on the packer to be set.
  63509. */
  63510. private _updateTextureReferences;
  63511. /**
  63512. * Public method to set a Mesh to a frame
  63513. * @param m that is the target
  63514. * @param frameID or the frame index
  63515. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63516. */
  63517. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63518. /**
  63519. * Starts the async promise to compile the texture packer.
  63520. * @returns Promise<void>
  63521. */
  63522. processAsync(): Promise<void>;
  63523. /**
  63524. * Disposes all textures associated with this packer
  63525. */
  63526. dispose(): void;
  63527. /**
  63528. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63529. * @param imageType is the image type to use.
  63530. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63531. */
  63532. download(imageType?: string, quality?: number): void;
  63533. /**
  63534. * Public method to load a texturePacker JSON file.
  63535. * @param data of the JSON file in string format.
  63536. */
  63537. updateFromJSON(data: string): void;
  63538. }
  63539. }
  63540. declare module BABYLON {
  63541. /**
  63542. * 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.
  63543. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63544. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63545. */
  63546. export class CustomProceduralTexture extends ProceduralTexture {
  63547. private _animate;
  63548. private _time;
  63549. private _config;
  63550. private _texturePath;
  63551. /**
  63552. * Instantiates a new Custom Procedural Texture.
  63553. * 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.
  63554. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63555. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63556. * @param name Define the name of the texture
  63557. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63558. * @param size Define the size of the texture to create
  63559. * @param scene Define the scene the texture belongs to
  63560. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63561. * @param generateMipMaps Define if the texture should creates mip maps or not
  63562. */
  63563. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63564. private _loadJson;
  63565. /**
  63566. * Is the texture ready to be used ? (rendered at least once)
  63567. * @returns true if ready, otherwise, false.
  63568. */
  63569. isReady(): boolean;
  63570. /**
  63571. * Render the texture to its associated render target.
  63572. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63573. */
  63574. render(useCameraPostProcess?: boolean): void;
  63575. /**
  63576. * Update the list of dependant textures samplers in the shader.
  63577. */
  63578. updateTextures(): void;
  63579. /**
  63580. * Update the uniform values of the procedural texture in the shader.
  63581. */
  63582. updateShaderUniforms(): void;
  63583. /**
  63584. * Define if the texture animates or not.
  63585. */
  63586. get animate(): boolean;
  63587. set animate(value: boolean);
  63588. }
  63589. }
  63590. declare module BABYLON {
  63591. /** @hidden */
  63592. export var noisePixelShader: {
  63593. name: string;
  63594. shader: string;
  63595. };
  63596. }
  63597. declare module BABYLON {
  63598. /**
  63599. * Class used to generate noise procedural textures
  63600. */
  63601. export class NoiseProceduralTexture extends ProceduralTexture {
  63602. /** Gets or sets the start time (default is 0) */
  63603. time: number;
  63604. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63605. brightness: number;
  63606. /** Defines the number of octaves to process */
  63607. octaves: number;
  63608. /** Defines the level of persistence (0.8 by default) */
  63609. persistence: number;
  63610. /** Gets or sets animation speed factor (default is 1) */
  63611. animationSpeedFactor: number;
  63612. /**
  63613. * Creates a new NoiseProceduralTexture
  63614. * @param name defines the name fo the texture
  63615. * @param size defines the size of the texture (default is 256)
  63616. * @param scene defines the hosting scene
  63617. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63618. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63619. */
  63620. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63621. private _updateShaderUniforms;
  63622. protected _getDefines(): string;
  63623. /** Generate the current state of the procedural texture */
  63624. render(useCameraPostProcess?: boolean): void;
  63625. /**
  63626. * Serializes this noise procedural texture
  63627. * @returns a serialized noise procedural texture object
  63628. */
  63629. serialize(): any;
  63630. /**
  63631. * Clone the texture.
  63632. * @returns the cloned texture
  63633. */
  63634. clone(): NoiseProceduralTexture;
  63635. /**
  63636. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63637. * @param parsedTexture defines parsed texture data
  63638. * @param scene defines the current scene
  63639. * @param rootUrl defines the root URL containing noise procedural texture information
  63640. * @returns a parsed NoiseProceduralTexture
  63641. */
  63642. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63643. }
  63644. }
  63645. declare module BABYLON {
  63646. /**
  63647. * Raw cube texture where the raw buffers are passed in
  63648. */
  63649. export class RawCubeTexture extends CubeTexture {
  63650. /**
  63651. * Creates a cube texture where the raw buffers are passed in.
  63652. * @param scene defines the scene the texture is attached to
  63653. * @param data defines the array of data to use to create each face
  63654. * @param size defines the size of the textures
  63655. * @param format defines the format of the data
  63656. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63657. * @param generateMipMaps defines if the engine should generate the mip levels
  63658. * @param invertY defines if data must be stored with Y axis inverted
  63659. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63660. * @param compression defines the compression used (null by default)
  63661. */
  63662. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63663. /**
  63664. * Updates the raw cube texture.
  63665. * @param data defines the data to store
  63666. * @param format defines the data format
  63667. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63668. * @param invertY defines if data must be stored with Y axis inverted
  63669. * @param compression defines the compression used (null by default)
  63670. * @param level defines which level of the texture to update
  63671. */
  63672. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63673. /**
  63674. * Updates a raw cube texture with RGBD encoded data.
  63675. * @param data defines the array of data [mipmap][face] to use to create each face
  63676. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63677. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63678. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63679. * @returns a promsie that resolves when the operation is complete
  63680. */
  63681. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63682. /**
  63683. * Clones the raw cube texture.
  63684. * @return a new cube texture
  63685. */
  63686. clone(): CubeTexture;
  63687. /** @hidden */
  63688. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63689. }
  63690. }
  63691. declare module BABYLON {
  63692. /**
  63693. * Class used to store 2D array textures containing user data
  63694. */
  63695. export class RawTexture2DArray extends Texture {
  63696. /** Gets or sets the texture format to use */
  63697. format: number;
  63698. /**
  63699. * Create a new RawTexture2DArray
  63700. * @param data defines the data of the texture
  63701. * @param width defines the width of the texture
  63702. * @param height defines the height of the texture
  63703. * @param depth defines the number of layers of the texture
  63704. * @param format defines the texture format to use
  63705. * @param scene defines the hosting scene
  63706. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63707. * @param invertY defines if texture must be stored with Y axis inverted
  63708. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63709. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63710. */
  63711. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63712. /** Gets or sets the texture format to use */
  63713. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63714. /**
  63715. * Update the texture with new data
  63716. * @param data defines the data to store in the texture
  63717. */
  63718. update(data: ArrayBufferView): void;
  63719. }
  63720. }
  63721. declare module BABYLON {
  63722. /**
  63723. * Class used to store 3D textures containing user data
  63724. */
  63725. export class RawTexture3D extends Texture {
  63726. /** Gets or sets the texture format to use */
  63727. format: number;
  63728. /**
  63729. * Create a new RawTexture3D
  63730. * @param data defines the data of the texture
  63731. * @param width defines the width of the texture
  63732. * @param height defines the height of the texture
  63733. * @param depth defines the depth of the texture
  63734. * @param format defines the texture format to use
  63735. * @param scene defines the hosting scene
  63736. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63737. * @param invertY defines if texture must be stored with Y axis inverted
  63738. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63739. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63740. */
  63741. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63742. /** Gets or sets the texture format to use */
  63743. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63744. /**
  63745. * Update the texture with new data
  63746. * @param data defines the data to store in the texture
  63747. */
  63748. update(data: ArrayBufferView): void;
  63749. }
  63750. }
  63751. declare module BABYLON {
  63752. /**
  63753. * Creates a refraction texture used by refraction channel of the standard material.
  63754. * It is like a mirror but to see through a material.
  63755. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63756. */
  63757. export class RefractionTexture extends RenderTargetTexture {
  63758. /**
  63759. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63760. * 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.
  63761. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63762. */
  63763. refractionPlane: Plane;
  63764. /**
  63765. * Define how deep under the surface we should see.
  63766. */
  63767. depth: number;
  63768. /**
  63769. * Creates a refraction texture used by refraction channel of the standard material.
  63770. * It is like a mirror but to see through a material.
  63771. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63772. * @param name Define the texture name
  63773. * @param size Define the size of the underlying texture
  63774. * @param scene Define the scene the refraction belongs to
  63775. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63776. */
  63777. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63778. /**
  63779. * Clone the refraction texture.
  63780. * @returns the cloned texture
  63781. */
  63782. clone(): RefractionTexture;
  63783. /**
  63784. * Serialize the texture to a JSON representation you could use in Parse later on
  63785. * @returns the serialized JSON representation
  63786. */
  63787. serialize(): any;
  63788. }
  63789. }
  63790. declare module BABYLON {
  63791. /**
  63792. * Block used to add support for vertex skinning (bones)
  63793. */
  63794. export class BonesBlock extends NodeMaterialBlock {
  63795. /**
  63796. * Creates a new BonesBlock
  63797. * @param name defines the block name
  63798. */
  63799. constructor(name: string);
  63800. /**
  63801. * Initialize the block and prepare the context for build
  63802. * @param state defines the state that will be used for the build
  63803. */
  63804. initialize(state: NodeMaterialBuildState): void;
  63805. /**
  63806. * Gets the current class name
  63807. * @returns the class name
  63808. */
  63809. getClassName(): string;
  63810. /**
  63811. * Gets the matrix indices input component
  63812. */
  63813. get matricesIndices(): NodeMaterialConnectionPoint;
  63814. /**
  63815. * Gets the matrix weights input component
  63816. */
  63817. get matricesWeights(): NodeMaterialConnectionPoint;
  63818. /**
  63819. * Gets the extra matrix indices input component
  63820. */
  63821. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63822. /**
  63823. * Gets the extra matrix weights input component
  63824. */
  63825. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63826. /**
  63827. * Gets the world input component
  63828. */
  63829. get world(): NodeMaterialConnectionPoint;
  63830. /**
  63831. * Gets the output component
  63832. */
  63833. get output(): NodeMaterialConnectionPoint;
  63834. autoConfigure(material: NodeMaterial): void;
  63835. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63836. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63837. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63838. protected _buildBlock(state: NodeMaterialBuildState): this;
  63839. }
  63840. }
  63841. declare module BABYLON {
  63842. /**
  63843. * Block used to add support for instances
  63844. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63845. */
  63846. export class InstancesBlock extends NodeMaterialBlock {
  63847. /**
  63848. * Creates a new InstancesBlock
  63849. * @param name defines the block name
  63850. */
  63851. constructor(name: string);
  63852. /**
  63853. * Gets the current class name
  63854. * @returns the class name
  63855. */
  63856. getClassName(): string;
  63857. /**
  63858. * Gets the first world row input component
  63859. */
  63860. get world0(): NodeMaterialConnectionPoint;
  63861. /**
  63862. * Gets the second world row input component
  63863. */
  63864. get world1(): NodeMaterialConnectionPoint;
  63865. /**
  63866. * Gets the third world row input component
  63867. */
  63868. get world2(): NodeMaterialConnectionPoint;
  63869. /**
  63870. * Gets the forth world row input component
  63871. */
  63872. get world3(): NodeMaterialConnectionPoint;
  63873. /**
  63874. * Gets the world input component
  63875. */
  63876. get world(): NodeMaterialConnectionPoint;
  63877. /**
  63878. * Gets the output component
  63879. */
  63880. get output(): NodeMaterialConnectionPoint;
  63881. /**
  63882. * Gets the isntanceID component
  63883. */
  63884. get instanceID(): NodeMaterialConnectionPoint;
  63885. autoConfigure(material: NodeMaterial): void;
  63886. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63887. protected _buildBlock(state: NodeMaterialBuildState): this;
  63888. }
  63889. }
  63890. declare module BABYLON {
  63891. /**
  63892. * Block used to add morph targets support to vertex shader
  63893. */
  63894. export class MorphTargetsBlock extends NodeMaterialBlock {
  63895. private _repeatableContentAnchor;
  63896. /**
  63897. * Create a new MorphTargetsBlock
  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 position input component
  63908. */
  63909. get position(): NodeMaterialConnectionPoint;
  63910. /**
  63911. * Gets the normal input component
  63912. */
  63913. get normal(): NodeMaterialConnectionPoint;
  63914. /**
  63915. * Gets the tangent input component
  63916. */
  63917. get tangent(): NodeMaterialConnectionPoint;
  63918. /**
  63919. * Gets the tangent input component
  63920. */
  63921. get uv(): NodeMaterialConnectionPoint;
  63922. /**
  63923. * Gets the position output component
  63924. */
  63925. get positionOutput(): NodeMaterialConnectionPoint;
  63926. /**
  63927. * Gets the normal output component
  63928. */
  63929. get normalOutput(): NodeMaterialConnectionPoint;
  63930. /**
  63931. * Gets the tangent output component
  63932. */
  63933. get tangentOutput(): NodeMaterialConnectionPoint;
  63934. /**
  63935. * Gets the tangent output component
  63936. */
  63937. get uvOutput(): NodeMaterialConnectionPoint;
  63938. initialize(state: NodeMaterialBuildState): void;
  63939. autoConfigure(material: NodeMaterial): void;
  63940. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63941. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63942. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63943. protected _buildBlock(state: NodeMaterialBuildState): this;
  63944. }
  63945. }
  63946. declare module BABYLON {
  63947. /**
  63948. * Block used to get data information from a light
  63949. */
  63950. export class LightInformationBlock extends NodeMaterialBlock {
  63951. private _lightDataUniformName;
  63952. private _lightColorUniformName;
  63953. private _lightTypeDefineName;
  63954. /**
  63955. * Gets or sets the light associated with this block
  63956. */
  63957. light: Nullable<Light>;
  63958. /**
  63959. * Creates a new LightInformationBlock
  63960. * @param name defines the block name
  63961. */
  63962. constructor(name: string);
  63963. /**
  63964. * Gets the current class name
  63965. * @returns the class name
  63966. */
  63967. getClassName(): string;
  63968. /**
  63969. * Gets the world position input component
  63970. */
  63971. get worldPosition(): NodeMaterialConnectionPoint;
  63972. /**
  63973. * Gets the direction output component
  63974. */
  63975. get direction(): NodeMaterialConnectionPoint;
  63976. /**
  63977. * Gets the direction output component
  63978. */
  63979. get color(): NodeMaterialConnectionPoint;
  63980. /**
  63981. * Gets the direction output component
  63982. */
  63983. get intensity(): NodeMaterialConnectionPoint;
  63984. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63985. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63986. protected _buildBlock(state: NodeMaterialBuildState): this;
  63987. serialize(): any;
  63988. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63989. }
  63990. }
  63991. declare module BABYLON {
  63992. /**
  63993. * Block used to add image processing support to fragment shader
  63994. */
  63995. export class ImageProcessingBlock extends NodeMaterialBlock {
  63996. /**
  63997. * Create a new ImageProcessingBlock
  63998. * @param name defines the block name
  63999. */
  64000. constructor(name: string);
  64001. /**
  64002. * Gets the current class name
  64003. * @returns the class name
  64004. */
  64005. getClassName(): string;
  64006. /**
  64007. * Gets the color input component
  64008. */
  64009. get color(): NodeMaterialConnectionPoint;
  64010. /**
  64011. * Gets the output component
  64012. */
  64013. get output(): NodeMaterialConnectionPoint;
  64014. /**
  64015. * Initialize the block and prepare the context for build
  64016. * @param state defines the state that will be used for the build
  64017. */
  64018. initialize(state: NodeMaterialBuildState): void;
  64019. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64020. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64021. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64022. protected _buildBlock(state: NodeMaterialBuildState): this;
  64023. }
  64024. }
  64025. declare module BABYLON {
  64026. /**
  64027. * Block used to pertub normals based on a normal map
  64028. */
  64029. export class PerturbNormalBlock extends NodeMaterialBlock {
  64030. private _tangentSpaceParameterName;
  64031. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64032. invertX: boolean;
  64033. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64034. invertY: boolean;
  64035. /**
  64036. * Create a new PerturbNormalBlock
  64037. * @param name defines the block name
  64038. */
  64039. constructor(name: string);
  64040. /**
  64041. * Gets the current class name
  64042. * @returns the class name
  64043. */
  64044. getClassName(): string;
  64045. /**
  64046. * Gets the world position input component
  64047. */
  64048. get worldPosition(): NodeMaterialConnectionPoint;
  64049. /**
  64050. * Gets the world normal input component
  64051. */
  64052. get worldNormal(): NodeMaterialConnectionPoint;
  64053. /**
  64054. * Gets the world tangent input component
  64055. */
  64056. get worldTangent(): NodeMaterialConnectionPoint;
  64057. /**
  64058. * Gets the uv input component
  64059. */
  64060. get uv(): NodeMaterialConnectionPoint;
  64061. /**
  64062. * Gets the normal map color input component
  64063. */
  64064. get normalMapColor(): NodeMaterialConnectionPoint;
  64065. /**
  64066. * Gets the strength input component
  64067. */
  64068. get strength(): NodeMaterialConnectionPoint;
  64069. /**
  64070. * Gets the output component
  64071. */
  64072. get output(): NodeMaterialConnectionPoint;
  64073. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64074. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64075. autoConfigure(material: NodeMaterial): void;
  64076. protected _buildBlock(state: NodeMaterialBuildState): this;
  64077. protected _dumpPropertiesCode(): string;
  64078. serialize(): any;
  64079. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64080. }
  64081. }
  64082. declare module BABYLON {
  64083. /**
  64084. * Block used to discard a pixel if a value is smaller than a cutoff
  64085. */
  64086. export class DiscardBlock extends NodeMaterialBlock {
  64087. /**
  64088. * Create a new DiscardBlock
  64089. * @param name defines the block name
  64090. */
  64091. constructor(name: string);
  64092. /**
  64093. * Gets the current class name
  64094. * @returns the class name
  64095. */
  64096. getClassName(): string;
  64097. /**
  64098. * Gets the color input component
  64099. */
  64100. get value(): NodeMaterialConnectionPoint;
  64101. /**
  64102. * Gets the cutoff input component
  64103. */
  64104. get cutoff(): NodeMaterialConnectionPoint;
  64105. protected _buildBlock(state: NodeMaterialBuildState): this;
  64106. }
  64107. }
  64108. declare module BABYLON {
  64109. /**
  64110. * Block used to test if the fragment shader is front facing
  64111. */
  64112. export class FrontFacingBlock extends NodeMaterialBlock {
  64113. /**
  64114. * Creates a new FrontFacingBlock
  64115. * @param name defines the block name
  64116. */
  64117. constructor(name: string);
  64118. /**
  64119. * Gets the current class name
  64120. * @returns the class name
  64121. */
  64122. getClassName(): string;
  64123. /**
  64124. * Gets the output component
  64125. */
  64126. get output(): NodeMaterialConnectionPoint;
  64127. protected _buildBlock(state: NodeMaterialBuildState): this;
  64128. }
  64129. }
  64130. declare module BABYLON {
  64131. /**
  64132. * Block used to get the derivative value on x and y of a given input
  64133. */
  64134. export class DerivativeBlock extends NodeMaterialBlock {
  64135. /**
  64136. * Create a new DerivativeBlock
  64137. * @param name defines the block name
  64138. */
  64139. constructor(name: string);
  64140. /**
  64141. * Gets the current class name
  64142. * @returns the class name
  64143. */
  64144. getClassName(): string;
  64145. /**
  64146. * Gets the input component
  64147. */
  64148. get input(): NodeMaterialConnectionPoint;
  64149. /**
  64150. * Gets the derivative output on x
  64151. */
  64152. get dx(): NodeMaterialConnectionPoint;
  64153. /**
  64154. * Gets the derivative output on y
  64155. */
  64156. get dy(): NodeMaterialConnectionPoint;
  64157. protected _buildBlock(state: NodeMaterialBuildState): this;
  64158. }
  64159. }
  64160. declare module BABYLON {
  64161. /**
  64162. * Block used to make gl_FragCoord available
  64163. */
  64164. export class FragCoordBlock extends NodeMaterialBlock {
  64165. /**
  64166. * Creates a new FragCoordBlock
  64167. * @param name defines the block name
  64168. */
  64169. constructor(name: string);
  64170. /**
  64171. * Gets the current class name
  64172. * @returns the class name
  64173. */
  64174. getClassName(): string;
  64175. /**
  64176. * Gets the xy component
  64177. */
  64178. get xy(): NodeMaterialConnectionPoint;
  64179. /**
  64180. * Gets the xyz component
  64181. */
  64182. get xyz(): NodeMaterialConnectionPoint;
  64183. /**
  64184. * Gets the xyzw component
  64185. */
  64186. get xyzw(): NodeMaterialConnectionPoint;
  64187. /**
  64188. * Gets the x component
  64189. */
  64190. get x(): NodeMaterialConnectionPoint;
  64191. /**
  64192. * Gets the y component
  64193. */
  64194. get y(): NodeMaterialConnectionPoint;
  64195. /**
  64196. * Gets the z component
  64197. */
  64198. get z(): NodeMaterialConnectionPoint;
  64199. /**
  64200. * Gets the w component
  64201. */
  64202. get output(): NodeMaterialConnectionPoint;
  64203. protected writeOutputs(state: NodeMaterialBuildState): string;
  64204. protected _buildBlock(state: NodeMaterialBuildState): this;
  64205. }
  64206. }
  64207. declare module BABYLON {
  64208. /**
  64209. * Block used to get the screen sizes
  64210. */
  64211. export class ScreenSizeBlock extends NodeMaterialBlock {
  64212. private _varName;
  64213. private _scene;
  64214. /**
  64215. * Creates a new ScreenSizeBlock
  64216. * @param name defines the block name
  64217. */
  64218. constructor(name: string);
  64219. /**
  64220. * Gets the current class name
  64221. * @returns the class name
  64222. */
  64223. getClassName(): string;
  64224. /**
  64225. * Gets the xy component
  64226. */
  64227. get xy(): NodeMaterialConnectionPoint;
  64228. /**
  64229. * Gets the x component
  64230. */
  64231. get x(): NodeMaterialConnectionPoint;
  64232. /**
  64233. * Gets the y component
  64234. */
  64235. get y(): NodeMaterialConnectionPoint;
  64236. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64237. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64238. protected _buildBlock(state: NodeMaterialBuildState): this;
  64239. }
  64240. }
  64241. declare module BABYLON {
  64242. /**
  64243. * Block used to add support for scene fog
  64244. */
  64245. export class FogBlock extends NodeMaterialBlock {
  64246. private _fogDistanceName;
  64247. private _fogParameters;
  64248. /**
  64249. * Create a new FogBlock
  64250. * @param name defines the block name
  64251. */
  64252. constructor(name: string);
  64253. /**
  64254. * Gets the current class name
  64255. * @returns the class name
  64256. */
  64257. getClassName(): string;
  64258. /**
  64259. * Gets the world position input component
  64260. */
  64261. get worldPosition(): NodeMaterialConnectionPoint;
  64262. /**
  64263. * Gets the view input component
  64264. */
  64265. get view(): NodeMaterialConnectionPoint;
  64266. /**
  64267. * Gets the color input component
  64268. */
  64269. get input(): NodeMaterialConnectionPoint;
  64270. /**
  64271. * Gets the fog color input component
  64272. */
  64273. get fogColor(): NodeMaterialConnectionPoint;
  64274. /**
  64275. * Gets the output component
  64276. */
  64277. get output(): NodeMaterialConnectionPoint;
  64278. autoConfigure(material: NodeMaterial): void;
  64279. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64280. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64281. protected _buildBlock(state: NodeMaterialBuildState): this;
  64282. }
  64283. }
  64284. declare module BABYLON {
  64285. /**
  64286. * Block used to add light in the fragment shader
  64287. */
  64288. export class LightBlock extends NodeMaterialBlock {
  64289. private _lightId;
  64290. /**
  64291. * Gets or sets the light associated with this block
  64292. */
  64293. light: Nullable<Light>;
  64294. /**
  64295. * Create a new LightBlock
  64296. * @param name defines the block name
  64297. */
  64298. constructor(name: string);
  64299. /**
  64300. * Gets the current class name
  64301. * @returns the class name
  64302. */
  64303. getClassName(): string;
  64304. /**
  64305. * Gets the world position input component
  64306. */
  64307. get worldPosition(): NodeMaterialConnectionPoint;
  64308. /**
  64309. * Gets the world normal input component
  64310. */
  64311. get worldNormal(): NodeMaterialConnectionPoint;
  64312. /**
  64313. * Gets the camera (or eye) position component
  64314. */
  64315. get cameraPosition(): NodeMaterialConnectionPoint;
  64316. /**
  64317. * Gets the glossiness component
  64318. */
  64319. get glossiness(): NodeMaterialConnectionPoint;
  64320. /**
  64321. * Gets the glossinness power component
  64322. */
  64323. get glossPower(): NodeMaterialConnectionPoint;
  64324. /**
  64325. * Gets the diffuse color component
  64326. */
  64327. get diffuseColor(): NodeMaterialConnectionPoint;
  64328. /**
  64329. * Gets the specular color component
  64330. */
  64331. get specularColor(): NodeMaterialConnectionPoint;
  64332. /**
  64333. * Gets the view matrix component
  64334. */
  64335. get view(): NodeMaterialConnectionPoint;
  64336. /**
  64337. * Gets the diffuse output component
  64338. */
  64339. get diffuseOutput(): NodeMaterialConnectionPoint;
  64340. /**
  64341. * Gets the specular output component
  64342. */
  64343. get specularOutput(): NodeMaterialConnectionPoint;
  64344. /**
  64345. * Gets the shadow output component
  64346. */
  64347. get shadow(): NodeMaterialConnectionPoint;
  64348. autoConfigure(material: NodeMaterial): void;
  64349. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64350. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64351. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64352. private _injectVertexCode;
  64353. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64354. serialize(): any;
  64355. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64356. }
  64357. }
  64358. declare module BABYLON {
  64359. /**
  64360. * Block used to read a reflection texture from a sampler
  64361. */
  64362. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64363. /**
  64364. * Create a new ReflectionTextureBlock
  64365. * @param name defines the block name
  64366. */
  64367. constructor(name: string);
  64368. /**
  64369. * Gets the current class name
  64370. * @returns the class name
  64371. */
  64372. getClassName(): string;
  64373. /**
  64374. * Gets the world position input component
  64375. */
  64376. get position(): NodeMaterialConnectionPoint;
  64377. /**
  64378. * Gets the world position input component
  64379. */
  64380. get worldPosition(): NodeMaterialConnectionPoint;
  64381. /**
  64382. * Gets the world normal input component
  64383. */
  64384. get worldNormal(): NodeMaterialConnectionPoint;
  64385. /**
  64386. * Gets the world input component
  64387. */
  64388. get world(): NodeMaterialConnectionPoint;
  64389. /**
  64390. * Gets the camera (or eye) position component
  64391. */
  64392. get cameraPosition(): NodeMaterialConnectionPoint;
  64393. /**
  64394. * Gets the view input component
  64395. */
  64396. get view(): NodeMaterialConnectionPoint;
  64397. /**
  64398. * Gets the rgb output component
  64399. */
  64400. get rgb(): NodeMaterialConnectionPoint;
  64401. /**
  64402. * Gets the rgba output component
  64403. */
  64404. get rgba(): NodeMaterialConnectionPoint;
  64405. /**
  64406. * Gets the r output component
  64407. */
  64408. get r(): NodeMaterialConnectionPoint;
  64409. /**
  64410. * Gets the g output component
  64411. */
  64412. get g(): NodeMaterialConnectionPoint;
  64413. /**
  64414. * Gets the b output component
  64415. */
  64416. get b(): NodeMaterialConnectionPoint;
  64417. /**
  64418. * Gets the a output component
  64419. */
  64420. get a(): NodeMaterialConnectionPoint;
  64421. autoConfigure(material: NodeMaterial): void;
  64422. protected _buildBlock(state: NodeMaterialBuildState): this;
  64423. }
  64424. }
  64425. declare module BABYLON {
  64426. /**
  64427. * Block used to add 2 vectors
  64428. */
  64429. export class AddBlock extends NodeMaterialBlock {
  64430. /**
  64431. * Creates a new AddBlock
  64432. * @param name defines the block name
  64433. */
  64434. constructor(name: string);
  64435. /**
  64436. * Gets the current class name
  64437. * @returns the class name
  64438. */
  64439. getClassName(): string;
  64440. /**
  64441. * Gets the left operand input component
  64442. */
  64443. get left(): NodeMaterialConnectionPoint;
  64444. /**
  64445. * Gets the right operand input component
  64446. */
  64447. get right(): 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 scale a vector by a float
  64458. */
  64459. export class ScaleBlock extends NodeMaterialBlock {
  64460. /**
  64461. * Creates a new ScaleBlock
  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 input component
  64472. */
  64473. get input(): NodeMaterialConnectionPoint;
  64474. /**
  64475. * Gets the factor input component
  64476. */
  64477. get factor(): NodeMaterialConnectionPoint;
  64478. /**
  64479. * Gets the output component
  64480. */
  64481. get output(): NodeMaterialConnectionPoint;
  64482. protected _buildBlock(state: NodeMaterialBuildState): this;
  64483. }
  64484. }
  64485. declare module BABYLON {
  64486. /**
  64487. * Block used to clamp a float
  64488. */
  64489. export class ClampBlock extends NodeMaterialBlock {
  64490. /** Gets or sets the minimum range */
  64491. minimum: number;
  64492. /** Gets or sets the maximum range */
  64493. maximum: number;
  64494. /**
  64495. * Creates a new ClampBlock
  64496. * @param name defines the block name
  64497. */
  64498. constructor(name: string);
  64499. /**
  64500. * Gets the current class name
  64501. * @returns the class name
  64502. */
  64503. getClassName(): string;
  64504. /**
  64505. * Gets the value input component
  64506. */
  64507. get value(): NodeMaterialConnectionPoint;
  64508. /**
  64509. * Gets the output component
  64510. */
  64511. get output(): NodeMaterialConnectionPoint;
  64512. protected _buildBlock(state: NodeMaterialBuildState): this;
  64513. protected _dumpPropertiesCode(): string;
  64514. serialize(): any;
  64515. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64516. }
  64517. }
  64518. declare module BABYLON {
  64519. /**
  64520. * Block used to apply a cross product between 2 vectors
  64521. */
  64522. export class CrossBlock extends NodeMaterialBlock {
  64523. /**
  64524. * Creates a new CrossBlock
  64525. * @param name defines the block name
  64526. */
  64527. constructor(name: string);
  64528. /**
  64529. * Gets the current class name
  64530. * @returns the class name
  64531. */
  64532. getClassName(): string;
  64533. /**
  64534. * Gets the left operand input component
  64535. */
  64536. get left(): NodeMaterialConnectionPoint;
  64537. /**
  64538. * Gets the right operand input component
  64539. */
  64540. get right(): NodeMaterialConnectionPoint;
  64541. /**
  64542. * Gets the output component
  64543. */
  64544. get output(): NodeMaterialConnectionPoint;
  64545. protected _buildBlock(state: NodeMaterialBuildState): this;
  64546. }
  64547. }
  64548. declare module BABYLON {
  64549. /**
  64550. * Block used to apply a dot product between 2 vectors
  64551. */
  64552. export class DotBlock extends NodeMaterialBlock {
  64553. /**
  64554. * Creates a new DotBlock
  64555. * @param name defines the block name
  64556. */
  64557. constructor(name: string);
  64558. /**
  64559. * Gets the current class name
  64560. * @returns the class name
  64561. */
  64562. getClassName(): string;
  64563. /**
  64564. * Gets the left operand input component
  64565. */
  64566. get left(): NodeMaterialConnectionPoint;
  64567. /**
  64568. * Gets the right operand input component
  64569. */
  64570. get right(): NodeMaterialConnectionPoint;
  64571. /**
  64572. * Gets the output component
  64573. */
  64574. get output(): NodeMaterialConnectionPoint;
  64575. protected _buildBlock(state: NodeMaterialBuildState): this;
  64576. }
  64577. }
  64578. declare module BABYLON {
  64579. /**
  64580. * Block used to normalize a vector
  64581. */
  64582. export class NormalizeBlock extends NodeMaterialBlock {
  64583. /**
  64584. * Creates a new NormalizeBlock
  64585. * @param name defines the block name
  64586. */
  64587. constructor(name: string);
  64588. /**
  64589. * Gets the current class name
  64590. * @returns the class name
  64591. */
  64592. getClassName(): string;
  64593. /**
  64594. * Gets the input component
  64595. */
  64596. get input(): NodeMaterialConnectionPoint;
  64597. /**
  64598. * Gets the output component
  64599. */
  64600. get output(): NodeMaterialConnectionPoint;
  64601. protected _buildBlock(state: NodeMaterialBuildState): this;
  64602. }
  64603. }
  64604. declare module BABYLON {
  64605. /**
  64606. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64607. */
  64608. export class ColorMergerBlock extends NodeMaterialBlock {
  64609. /**
  64610. * Create a new ColorMergerBlock
  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 rgb component (input)
  64621. */
  64622. get rgbIn(): NodeMaterialConnectionPoint;
  64623. /**
  64624. * Gets the r component (input)
  64625. */
  64626. get r(): NodeMaterialConnectionPoint;
  64627. /**
  64628. * Gets the g component (input)
  64629. */
  64630. get g(): NodeMaterialConnectionPoint;
  64631. /**
  64632. * Gets the b component (input)
  64633. */
  64634. get b(): NodeMaterialConnectionPoint;
  64635. /**
  64636. * Gets the a component (input)
  64637. */
  64638. get a(): NodeMaterialConnectionPoint;
  64639. /**
  64640. * Gets the rgba component (output)
  64641. */
  64642. get rgba(): NodeMaterialConnectionPoint;
  64643. /**
  64644. * Gets the rgb component (output)
  64645. */
  64646. get rgbOut(): NodeMaterialConnectionPoint;
  64647. /**
  64648. * Gets the rgb component (output)
  64649. * @deprecated Please use rgbOut instead.
  64650. */
  64651. get rgb(): NodeMaterialConnectionPoint;
  64652. protected _buildBlock(state: NodeMaterialBuildState): this;
  64653. }
  64654. }
  64655. declare module BABYLON {
  64656. /**
  64657. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64658. */
  64659. export class VectorSplitterBlock extends NodeMaterialBlock {
  64660. /**
  64661. * Create a new VectorSplitterBlock
  64662. * @param name defines the block name
  64663. */
  64664. constructor(name: string);
  64665. /**
  64666. * Gets the current class name
  64667. * @returns the class name
  64668. */
  64669. getClassName(): string;
  64670. /**
  64671. * Gets the xyzw component (input)
  64672. */
  64673. get xyzw(): NodeMaterialConnectionPoint;
  64674. /**
  64675. * Gets the xyz component (input)
  64676. */
  64677. get xyzIn(): NodeMaterialConnectionPoint;
  64678. /**
  64679. * Gets the xy component (input)
  64680. */
  64681. get xyIn(): NodeMaterialConnectionPoint;
  64682. /**
  64683. * Gets the xyz component (output)
  64684. */
  64685. get xyzOut(): NodeMaterialConnectionPoint;
  64686. /**
  64687. * Gets the xy component (output)
  64688. */
  64689. get xyOut(): NodeMaterialConnectionPoint;
  64690. /**
  64691. * Gets the x component (output)
  64692. */
  64693. get x(): NodeMaterialConnectionPoint;
  64694. /**
  64695. * Gets the y component (output)
  64696. */
  64697. get y(): NodeMaterialConnectionPoint;
  64698. /**
  64699. * Gets the z component (output)
  64700. */
  64701. get z(): NodeMaterialConnectionPoint;
  64702. /**
  64703. * Gets the w component (output)
  64704. */
  64705. get w(): NodeMaterialConnectionPoint;
  64706. protected _inputRename(name: string): string;
  64707. protected _outputRename(name: string): string;
  64708. protected _buildBlock(state: NodeMaterialBuildState): this;
  64709. }
  64710. }
  64711. declare module BABYLON {
  64712. /**
  64713. * Block used to lerp between 2 values
  64714. */
  64715. export class LerpBlock extends NodeMaterialBlock {
  64716. /**
  64717. * Creates a new LerpBlock
  64718. * @param name defines the block name
  64719. */
  64720. constructor(name: string);
  64721. /**
  64722. * Gets the current class name
  64723. * @returns the class name
  64724. */
  64725. getClassName(): string;
  64726. /**
  64727. * Gets the left operand input component
  64728. */
  64729. get left(): NodeMaterialConnectionPoint;
  64730. /**
  64731. * Gets the right operand input component
  64732. */
  64733. get right(): NodeMaterialConnectionPoint;
  64734. /**
  64735. * Gets the gradient operand input component
  64736. */
  64737. get gradient(): NodeMaterialConnectionPoint;
  64738. /**
  64739. * Gets the output component
  64740. */
  64741. get output(): NodeMaterialConnectionPoint;
  64742. protected _buildBlock(state: NodeMaterialBuildState): this;
  64743. }
  64744. }
  64745. declare module BABYLON {
  64746. /**
  64747. * Block used to divide 2 vectors
  64748. */
  64749. export class DivideBlock extends NodeMaterialBlock {
  64750. /**
  64751. * Creates a new DivideBlock
  64752. * @param name defines the block name
  64753. */
  64754. constructor(name: string);
  64755. /**
  64756. * Gets the current class name
  64757. * @returns the class name
  64758. */
  64759. getClassName(): string;
  64760. /**
  64761. * Gets the left operand input component
  64762. */
  64763. get left(): NodeMaterialConnectionPoint;
  64764. /**
  64765. * Gets the right operand input component
  64766. */
  64767. get right(): NodeMaterialConnectionPoint;
  64768. /**
  64769. * Gets the output component
  64770. */
  64771. get output(): NodeMaterialConnectionPoint;
  64772. protected _buildBlock(state: NodeMaterialBuildState): this;
  64773. }
  64774. }
  64775. declare module BABYLON {
  64776. /**
  64777. * Block used to subtract 2 vectors
  64778. */
  64779. export class SubtractBlock extends NodeMaterialBlock {
  64780. /**
  64781. * Creates a new SubtractBlock
  64782. * @param name defines the block name
  64783. */
  64784. constructor(name: string);
  64785. /**
  64786. * Gets the current class name
  64787. * @returns the class name
  64788. */
  64789. getClassName(): string;
  64790. /**
  64791. * Gets the left operand input component
  64792. */
  64793. get left(): NodeMaterialConnectionPoint;
  64794. /**
  64795. * Gets the right operand input component
  64796. */
  64797. get right(): NodeMaterialConnectionPoint;
  64798. /**
  64799. * Gets the output component
  64800. */
  64801. get output(): NodeMaterialConnectionPoint;
  64802. protected _buildBlock(state: NodeMaterialBuildState): this;
  64803. }
  64804. }
  64805. declare module BABYLON {
  64806. /**
  64807. * Block used to step a value
  64808. */
  64809. export class StepBlock extends NodeMaterialBlock {
  64810. /**
  64811. * Creates a new StepBlock
  64812. * @param name defines the block name
  64813. */
  64814. constructor(name: string);
  64815. /**
  64816. * Gets the current class name
  64817. * @returns the class name
  64818. */
  64819. getClassName(): string;
  64820. /**
  64821. * Gets the value operand input component
  64822. */
  64823. get value(): NodeMaterialConnectionPoint;
  64824. /**
  64825. * Gets the edge operand input component
  64826. */
  64827. get edge(): NodeMaterialConnectionPoint;
  64828. /**
  64829. * Gets the output component
  64830. */
  64831. get output(): NodeMaterialConnectionPoint;
  64832. protected _buildBlock(state: NodeMaterialBuildState): this;
  64833. }
  64834. }
  64835. declare module BABYLON {
  64836. /**
  64837. * Block used to get the opposite (1 - x) of a value
  64838. */
  64839. export class OneMinusBlock extends NodeMaterialBlock {
  64840. /**
  64841. * Creates a new OneMinusBlock
  64842. * @param name defines the block name
  64843. */
  64844. constructor(name: string);
  64845. /**
  64846. * Gets the current class name
  64847. * @returns the class name
  64848. */
  64849. getClassName(): string;
  64850. /**
  64851. * Gets the input component
  64852. */
  64853. get input(): NodeMaterialConnectionPoint;
  64854. /**
  64855. * Gets the output component
  64856. */
  64857. get output(): NodeMaterialConnectionPoint;
  64858. protected _buildBlock(state: NodeMaterialBuildState): this;
  64859. }
  64860. }
  64861. declare module BABYLON {
  64862. /**
  64863. * Block used to get the view direction
  64864. */
  64865. export class ViewDirectionBlock extends NodeMaterialBlock {
  64866. /**
  64867. * Creates a new ViewDirectionBlock
  64868. * @param name defines the block name
  64869. */
  64870. constructor(name: string);
  64871. /**
  64872. * Gets the current class name
  64873. * @returns the class name
  64874. */
  64875. getClassName(): string;
  64876. /**
  64877. * Gets the world position component
  64878. */
  64879. get worldPosition(): NodeMaterialConnectionPoint;
  64880. /**
  64881. * Gets the camera position component
  64882. */
  64883. get cameraPosition(): NodeMaterialConnectionPoint;
  64884. /**
  64885. * Gets the output component
  64886. */
  64887. get output(): NodeMaterialConnectionPoint;
  64888. autoConfigure(material: NodeMaterial): void;
  64889. protected _buildBlock(state: NodeMaterialBuildState): this;
  64890. }
  64891. }
  64892. declare module BABYLON {
  64893. /**
  64894. * Block used to compute fresnel value
  64895. */
  64896. export class FresnelBlock extends NodeMaterialBlock {
  64897. /**
  64898. * Create a new FresnelBlock
  64899. * @param name defines the block name
  64900. */
  64901. constructor(name: string);
  64902. /**
  64903. * Gets the current class name
  64904. * @returns the class name
  64905. */
  64906. getClassName(): string;
  64907. /**
  64908. * Gets the world normal input component
  64909. */
  64910. get worldNormal(): NodeMaterialConnectionPoint;
  64911. /**
  64912. * Gets the view direction input component
  64913. */
  64914. get viewDirection(): NodeMaterialConnectionPoint;
  64915. /**
  64916. * Gets the bias input component
  64917. */
  64918. get bias(): NodeMaterialConnectionPoint;
  64919. /**
  64920. * Gets the camera (or eye) position component
  64921. */
  64922. get power(): NodeMaterialConnectionPoint;
  64923. /**
  64924. * Gets the fresnel output component
  64925. */
  64926. get fresnel(): NodeMaterialConnectionPoint;
  64927. autoConfigure(material: NodeMaterial): void;
  64928. protected _buildBlock(state: NodeMaterialBuildState): this;
  64929. }
  64930. }
  64931. declare module BABYLON {
  64932. /**
  64933. * Block used to get the max of 2 values
  64934. */
  64935. export class MaxBlock extends NodeMaterialBlock {
  64936. /**
  64937. * Creates a new MaxBlock
  64938. * @param name defines the block name
  64939. */
  64940. constructor(name: string);
  64941. /**
  64942. * Gets the current class name
  64943. * @returns the class name
  64944. */
  64945. getClassName(): string;
  64946. /**
  64947. * Gets the left operand input component
  64948. */
  64949. get left(): NodeMaterialConnectionPoint;
  64950. /**
  64951. * Gets the right operand input component
  64952. */
  64953. get right(): NodeMaterialConnectionPoint;
  64954. /**
  64955. * Gets the output component
  64956. */
  64957. get output(): NodeMaterialConnectionPoint;
  64958. protected _buildBlock(state: NodeMaterialBuildState): this;
  64959. }
  64960. }
  64961. declare module BABYLON {
  64962. /**
  64963. * Block used to get the min of 2 values
  64964. */
  64965. export class MinBlock extends NodeMaterialBlock {
  64966. /**
  64967. * Creates a new MinBlock
  64968. * @param name defines the block name
  64969. */
  64970. constructor(name: string);
  64971. /**
  64972. * Gets the current class name
  64973. * @returns the class name
  64974. */
  64975. getClassName(): string;
  64976. /**
  64977. * Gets the left operand input component
  64978. */
  64979. get left(): NodeMaterialConnectionPoint;
  64980. /**
  64981. * Gets the right operand input component
  64982. */
  64983. get right(): NodeMaterialConnectionPoint;
  64984. /**
  64985. * Gets the output component
  64986. */
  64987. get output(): NodeMaterialConnectionPoint;
  64988. protected _buildBlock(state: NodeMaterialBuildState): this;
  64989. }
  64990. }
  64991. declare module BABYLON {
  64992. /**
  64993. * Block used to get the distance between 2 values
  64994. */
  64995. export class DistanceBlock extends NodeMaterialBlock {
  64996. /**
  64997. * Creates a new DistanceBlock
  64998. * @param name defines the block name
  64999. */
  65000. constructor(name: string);
  65001. /**
  65002. * Gets the current class name
  65003. * @returns the class name
  65004. */
  65005. getClassName(): string;
  65006. /**
  65007. * Gets the left operand input component
  65008. */
  65009. get left(): NodeMaterialConnectionPoint;
  65010. /**
  65011. * Gets the right operand input component
  65012. */
  65013. get right(): NodeMaterialConnectionPoint;
  65014. /**
  65015. * Gets the output component
  65016. */
  65017. get output(): NodeMaterialConnectionPoint;
  65018. protected _buildBlock(state: NodeMaterialBuildState): this;
  65019. }
  65020. }
  65021. declare module BABYLON {
  65022. /**
  65023. * Block used to get the length of a vector
  65024. */
  65025. export class LengthBlock extends NodeMaterialBlock {
  65026. /**
  65027. * Creates a new LengthBlock
  65028. * @param name defines the block name
  65029. */
  65030. constructor(name: string);
  65031. /**
  65032. * Gets the current class name
  65033. * @returns the class name
  65034. */
  65035. getClassName(): string;
  65036. /**
  65037. * Gets the value input component
  65038. */
  65039. get value(): NodeMaterialConnectionPoint;
  65040. /**
  65041. * Gets the output component
  65042. */
  65043. get output(): NodeMaterialConnectionPoint;
  65044. protected _buildBlock(state: NodeMaterialBuildState): this;
  65045. }
  65046. }
  65047. declare module BABYLON {
  65048. /**
  65049. * Block used to get negative version of a value (i.e. x * -1)
  65050. */
  65051. export class NegateBlock extends NodeMaterialBlock {
  65052. /**
  65053. * Creates a new NegateBlock
  65054. * @param name defines the block name
  65055. */
  65056. constructor(name: string);
  65057. /**
  65058. * Gets the current class name
  65059. * @returns the class name
  65060. */
  65061. getClassName(): string;
  65062. /**
  65063. * Gets the value input component
  65064. */
  65065. get value(): NodeMaterialConnectionPoint;
  65066. /**
  65067. * Gets the output component
  65068. */
  65069. get output(): NodeMaterialConnectionPoint;
  65070. protected _buildBlock(state: NodeMaterialBuildState): this;
  65071. }
  65072. }
  65073. declare module BABYLON {
  65074. /**
  65075. * Block used to get the value of the first parameter raised to the power of the second
  65076. */
  65077. export class PowBlock extends NodeMaterialBlock {
  65078. /**
  65079. * Creates a new PowBlock
  65080. * @param name defines the block name
  65081. */
  65082. constructor(name: string);
  65083. /**
  65084. * Gets the current class name
  65085. * @returns the class name
  65086. */
  65087. getClassName(): string;
  65088. /**
  65089. * Gets the value operand input component
  65090. */
  65091. get value(): NodeMaterialConnectionPoint;
  65092. /**
  65093. * Gets the power operand input component
  65094. */
  65095. get power(): NodeMaterialConnectionPoint;
  65096. /**
  65097. * Gets the output component
  65098. */
  65099. get output(): NodeMaterialConnectionPoint;
  65100. protected _buildBlock(state: NodeMaterialBuildState): this;
  65101. }
  65102. }
  65103. declare module BABYLON {
  65104. /**
  65105. * Block used to get a random number
  65106. */
  65107. export class RandomNumberBlock extends NodeMaterialBlock {
  65108. /**
  65109. * Creates a new RandomNumberBlock
  65110. * @param name defines the block name
  65111. */
  65112. constructor(name: string);
  65113. /**
  65114. * Gets the current class name
  65115. * @returns the class name
  65116. */
  65117. getClassName(): string;
  65118. /**
  65119. * Gets the seed input component
  65120. */
  65121. get seed(): NodeMaterialConnectionPoint;
  65122. /**
  65123. * Gets the output component
  65124. */
  65125. get output(): NodeMaterialConnectionPoint;
  65126. protected _buildBlock(state: NodeMaterialBuildState): this;
  65127. }
  65128. }
  65129. declare module BABYLON {
  65130. /**
  65131. * Block used to compute arc tangent of 2 values
  65132. */
  65133. export class ArcTan2Block extends NodeMaterialBlock {
  65134. /**
  65135. * Creates a new ArcTan2Block
  65136. * @param name defines the block name
  65137. */
  65138. constructor(name: string);
  65139. /**
  65140. * Gets the current class name
  65141. * @returns the class name
  65142. */
  65143. getClassName(): string;
  65144. /**
  65145. * Gets the x operand input component
  65146. */
  65147. get x(): NodeMaterialConnectionPoint;
  65148. /**
  65149. * Gets the y operand input component
  65150. */
  65151. get y(): NodeMaterialConnectionPoint;
  65152. /**
  65153. * Gets the output component
  65154. */
  65155. get output(): NodeMaterialConnectionPoint;
  65156. protected _buildBlock(state: NodeMaterialBuildState): this;
  65157. }
  65158. }
  65159. declare module BABYLON {
  65160. /**
  65161. * Block used to smooth step a value
  65162. */
  65163. export class SmoothStepBlock extends NodeMaterialBlock {
  65164. /**
  65165. * Creates a new SmoothStepBlock
  65166. * @param name defines the block name
  65167. */
  65168. constructor(name: string);
  65169. /**
  65170. * Gets the current class name
  65171. * @returns the class name
  65172. */
  65173. getClassName(): string;
  65174. /**
  65175. * Gets the value operand input component
  65176. */
  65177. get value(): NodeMaterialConnectionPoint;
  65178. /**
  65179. * Gets the first edge operand input component
  65180. */
  65181. get edge0(): NodeMaterialConnectionPoint;
  65182. /**
  65183. * Gets the second edge operand input component
  65184. */
  65185. get edge1(): NodeMaterialConnectionPoint;
  65186. /**
  65187. * Gets the output component
  65188. */
  65189. get output(): NodeMaterialConnectionPoint;
  65190. protected _buildBlock(state: NodeMaterialBuildState): this;
  65191. }
  65192. }
  65193. declare module BABYLON {
  65194. /**
  65195. * Block used to get the reciprocal (1 / x) of a value
  65196. */
  65197. export class ReciprocalBlock extends NodeMaterialBlock {
  65198. /**
  65199. * Creates a new ReciprocalBlock
  65200. * @param name defines the block name
  65201. */
  65202. constructor(name: string);
  65203. /**
  65204. * Gets the current class name
  65205. * @returns the class name
  65206. */
  65207. getClassName(): string;
  65208. /**
  65209. * Gets the input component
  65210. */
  65211. get input(): NodeMaterialConnectionPoint;
  65212. /**
  65213. * Gets the output component
  65214. */
  65215. get output(): NodeMaterialConnectionPoint;
  65216. protected _buildBlock(state: NodeMaterialBuildState): this;
  65217. }
  65218. }
  65219. declare module BABYLON {
  65220. /**
  65221. * Block used to replace a color by another one
  65222. */
  65223. export class ReplaceColorBlock extends NodeMaterialBlock {
  65224. /**
  65225. * Creates a new ReplaceColorBlock
  65226. * @param name defines the block name
  65227. */
  65228. constructor(name: string);
  65229. /**
  65230. * Gets the current class name
  65231. * @returns the class name
  65232. */
  65233. getClassName(): string;
  65234. /**
  65235. * Gets the value input component
  65236. */
  65237. get value(): NodeMaterialConnectionPoint;
  65238. /**
  65239. * Gets the reference input component
  65240. */
  65241. get reference(): NodeMaterialConnectionPoint;
  65242. /**
  65243. * Gets the distance input component
  65244. */
  65245. get distance(): NodeMaterialConnectionPoint;
  65246. /**
  65247. * Gets the replacement input component
  65248. */
  65249. get replacement(): NodeMaterialConnectionPoint;
  65250. /**
  65251. * Gets the output component
  65252. */
  65253. get output(): NodeMaterialConnectionPoint;
  65254. protected _buildBlock(state: NodeMaterialBuildState): this;
  65255. }
  65256. }
  65257. declare module BABYLON {
  65258. /**
  65259. * Block used to posterize a value
  65260. * @see https://en.wikipedia.org/wiki/Posterization
  65261. */
  65262. export class PosterizeBlock extends NodeMaterialBlock {
  65263. /**
  65264. * Creates a new PosterizeBlock
  65265. * @param name defines the block name
  65266. */
  65267. constructor(name: string);
  65268. /**
  65269. * Gets the current class name
  65270. * @returns the class name
  65271. */
  65272. getClassName(): string;
  65273. /**
  65274. * Gets the value input component
  65275. */
  65276. get value(): NodeMaterialConnectionPoint;
  65277. /**
  65278. * Gets the steps input component
  65279. */
  65280. get steps(): NodeMaterialConnectionPoint;
  65281. /**
  65282. * Gets the output component
  65283. */
  65284. get output(): NodeMaterialConnectionPoint;
  65285. protected _buildBlock(state: NodeMaterialBuildState): this;
  65286. }
  65287. }
  65288. declare module BABYLON {
  65289. /**
  65290. * Operations supported by the Wave block
  65291. */
  65292. export enum WaveBlockKind {
  65293. /** SawTooth */
  65294. SawTooth = 0,
  65295. /** Square */
  65296. Square = 1,
  65297. /** Triangle */
  65298. Triangle = 2
  65299. }
  65300. /**
  65301. * Block used to apply wave operation to floats
  65302. */
  65303. export class WaveBlock extends NodeMaterialBlock {
  65304. /**
  65305. * Gets or sets the kibnd of wave to be applied by the block
  65306. */
  65307. kind: WaveBlockKind;
  65308. /**
  65309. * Creates a new WaveBlock
  65310. * @param name defines the block name
  65311. */
  65312. constructor(name: string);
  65313. /**
  65314. * Gets the current class name
  65315. * @returns the class name
  65316. */
  65317. getClassName(): string;
  65318. /**
  65319. * Gets the input component
  65320. */
  65321. get input(): NodeMaterialConnectionPoint;
  65322. /**
  65323. * Gets the output component
  65324. */
  65325. get output(): NodeMaterialConnectionPoint;
  65326. protected _buildBlock(state: NodeMaterialBuildState): this;
  65327. serialize(): any;
  65328. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65329. }
  65330. }
  65331. declare module BABYLON {
  65332. /**
  65333. * Class used to store a color step for the GradientBlock
  65334. */
  65335. export class GradientBlockColorStep {
  65336. private _step;
  65337. /**
  65338. * Gets value indicating which step this color is associated with (between 0 and 1)
  65339. */
  65340. get step(): number;
  65341. /**
  65342. * Sets a value indicating which step this color is associated with (between 0 and 1)
  65343. */
  65344. set step(val: number);
  65345. private _color;
  65346. /**
  65347. * Gets the color associated with this step
  65348. */
  65349. get color(): Color3;
  65350. /**
  65351. * Sets the color associated with this step
  65352. */
  65353. set color(val: Color3);
  65354. /**
  65355. * Creates a new GradientBlockColorStep
  65356. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65357. * @param color defines the color associated with this step
  65358. */
  65359. constructor(step: number, color: Color3);
  65360. }
  65361. /**
  65362. * Block used to return a color from a gradient based on an input value between 0 and 1
  65363. */
  65364. export class GradientBlock extends NodeMaterialBlock {
  65365. /**
  65366. * Gets or sets the list of color steps
  65367. */
  65368. colorSteps: GradientBlockColorStep[];
  65369. /** Gets an observable raised when the value is changed */
  65370. onValueChangedObservable: Observable<GradientBlock>;
  65371. /** calls observable when the value is changed*/
  65372. colorStepsUpdated(): void;
  65373. /**
  65374. * Creates a new GradientBlock
  65375. * @param name defines the block name
  65376. */
  65377. constructor(name: string);
  65378. /**
  65379. * Gets the current class name
  65380. * @returns the class name
  65381. */
  65382. getClassName(): string;
  65383. /**
  65384. * Gets the gradient input component
  65385. */
  65386. get gradient(): NodeMaterialConnectionPoint;
  65387. /**
  65388. * Gets the output component
  65389. */
  65390. get output(): NodeMaterialConnectionPoint;
  65391. private _writeColorConstant;
  65392. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65393. serialize(): any;
  65394. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65395. protected _dumpPropertiesCode(): string;
  65396. }
  65397. }
  65398. declare module BABYLON {
  65399. /**
  65400. * Block used to normalize lerp between 2 values
  65401. */
  65402. export class NLerpBlock extends NodeMaterialBlock {
  65403. /**
  65404. * Creates a new NLerpBlock
  65405. * @param name defines the block name
  65406. */
  65407. constructor(name: string);
  65408. /**
  65409. * Gets the current class name
  65410. * @returns the class name
  65411. */
  65412. getClassName(): string;
  65413. /**
  65414. * Gets the left operand input component
  65415. */
  65416. get left(): NodeMaterialConnectionPoint;
  65417. /**
  65418. * Gets the right operand input component
  65419. */
  65420. get right(): NodeMaterialConnectionPoint;
  65421. /**
  65422. * Gets the gradient operand input component
  65423. */
  65424. get gradient(): NodeMaterialConnectionPoint;
  65425. /**
  65426. * Gets the output component
  65427. */
  65428. get output(): NodeMaterialConnectionPoint;
  65429. protected _buildBlock(state: NodeMaterialBuildState): this;
  65430. }
  65431. }
  65432. declare module BABYLON {
  65433. /**
  65434. * block used to Generate a Worley Noise 3D Noise Pattern
  65435. */
  65436. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65437. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65438. manhattanDistance: boolean;
  65439. /**
  65440. * Creates a new WorleyNoise3DBlock
  65441. * @param name defines the block name
  65442. */
  65443. constructor(name: string);
  65444. /**
  65445. * Gets the current class name
  65446. * @returns the class name
  65447. */
  65448. getClassName(): string;
  65449. /**
  65450. * Gets the seed input component
  65451. */
  65452. get seed(): NodeMaterialConnectionPoint;
  65453. /**
  65454. * Gets the jitter input component
  65455. */
  65456. get jitter(): NodeMaterialConnectionPoint;
  65457. /**
  65458. * Gets the output component
  65459. */
  65460. get output(): NodeMaterialConnectionPoint;
  65461. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65462. /**
  65463. * Exposes the properties to the UI?
  65464. */
  65465. protected _dumpPropertiesCode(): string;
  65466. /**
  65467. * Exposes the properties to the Seralize?
  65468. */
  65469. serialize(): any;
  65470. /**
  65471. * Exposes the properties to the deseralize?
  65472. */
  65473. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65474. }
  65475. }
  65476. declare module BABYLON {
  65477. /**
  65478. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65479. */
  65480. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65481. /**
  65482. * Creates a new SimplexPerlin3DBlock
  65483. * @param name defines the block name
  65484. */
  65485. constructor(name: string);
  65486. /**
  65487. * Gets the current class name
  65488. * @returns the class name
  65489. */
  65490. getClassName(): string;
  65491. /**
  65492. * Gets the seed operand input component
  65493. */
  65494. get seed(): NodeMaterialConnectionPoint;
  65495. /**
  65496. * Gets the output component
  65497. */
  65498. get output(): NodeMaterialConnectionPoint;
  65499. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65500. }
  65501. }
  65502. declare module BABYLON {
  65503. /**
  65504. * Block used to blend normals
  65505. */
  65506. export class NormalBlendBlock extends NodeMaterialBlock {
  65507. /**
  65508. * Creates a new NormalBlendBlock
  65509. * @param name defines the block name
  65510. */
  65511. constructor(name: string);
  65512. /**
  65513. * Gets the current class name
  65514. * @returns the class name
  65515. */
  65516. getClassName(): string;
  65517. /**
  65518. * Gets the first input component
  65519. */
  65520. get normalMap0(): NodeMaterialConnectionPoint;
  65521. /**
  65522. * Gets the second input component
  65523. */
  65524. get normalMap1(): NodeMaterialConnectionPoint;
  65525. /**
  65526. * Gets the output component
  65527. */
  65528. get output(): NodeMaterialConnectionPoint;
  65529. protected _buildBlock(state: NodeMaterialBuildState): this;
  65530. }
  65531. }
  65532. declare module BABYLON {
  65533. /**
  65534. * Block used to rotate a 2d vector by a given angle
  65535. */
  65536. export class Rotate2dBlock extends NodeMaterialBlock {
  65537. /**
  65538. * Creates a new Rotate2dBlock
  65539. * @param name defines the block name
  65540. */
  65541. constructor(name: string);
  65542. /**
  65543. * Gets the current class name
  65544. * @returns the class name
  65545. */
  65546. getClassName(): string;
  65547. /**
  65548. * Gets the input vector
  65549. */
  65550. get input(): NodeMaterialConnectionPoint;
  65551. /**
  65552. * Gets the input angle
  65553. */
  65554. get angle(): NodeMaterialConnectionPoint;
  65555. /**
  65556. * Gets the output component
  65557. */
  65558. get output(): NodeMaterialConnectionPoint;
  65559. autoConfigure(material: NodeMaterial): void;
  65560. protected _buildBlock(state: NodeMaterialBuildState): this;
  65561. }
  65562. }
  65563. declare module BABYLON {
  65564. /**
  65565. * Block used to get the reflected vector from a direction and a normal
  65566. */
  65567. export class ReflectBlock extends NodeMaterialBlock {
  65568. /**
  65569. * Creates a new ReflectBlock
  65570. * @param name defines the block name
  65571. */
  65572. constructor(name: string);
  65573. /**
  65574. * Gets the current class name
  65575. * @returns the class name
  65576. */
  65577. getClassName(): string;
  65578. /**
  65579. * Gets the incident component
  65580. */
  65581. get incident(): NodeMaterialConnectionPoint;
  65582. /**
  65583. * Gets the normal component
  65584. */
  65585. get normal(): NodeMaterialConnectionPoint;
  65586. /**
  65587. * Gets the output component
  65588. */
  65589. get output(): NodeMaterialConnectionPoint;
  65590. protected _buildBlock(state: NodeMaterialBuildState): this;
  65591. }
  65592. }
  65593. declare module BABYLON {
  65594. /**
  65595. * Block used to get the refracted vector from a direction and a normal
  65596. */
  65597. export class RefractBlock extends NodeMaterialBlock {
  65598. /**
  65599. * Creates a new RefractBlock
  65600. * @param name defines the block name
  65601. */
  65602. constructor(name: string);
  65603. /**
  65604. * Gets the current class name
  65605. * @returns the class name
  65606. */
  65607. getClassName(): string;
  65608. /**
  65609. * Gets the incident component
  65610. */
  65611. get incident(): NodeMaterialConnectionPoint;
  65612. /**
  65613. * Gets the normal component
  65614. */
  65615. get normal(): NodeMaterialConnectionPoint;
  65616. /**
  65617. * Gets the index of refraction component
  65618. */
  65619. get ior(): NodeMaterialConnectionPoint;
  65620. /**
  65621. * Gets the output component
  65622. */
  65623. get output(): NodeMaterialConnectionPoint;
  65624. protected _buildBlock(state: NodeMaterialBuildState): this;
  65625. }
  65626. }
  65627. declare module BABYLON {
  65628. /**
  65629. * Block used to desaturate a color
  65630. */
  65631. export class DesaturateBlock extends NodeMaterialBlock {
  65632. /**
  65633. * Creates a new DesaturateBlock
  65634. * @param name defines the block name
  65635. */
  65636. constructor(name: string);
  65637. /**
  65638. * Gets the current class name
  65639. * @returns the class name
  65640. */
  65641. getClassName(): string;
  65642. /**
  65643. * Gets the color operand input component
  65644. */
  65645. get color(): NodeMaterialConnectionPoint;
  65646. /**
  65647. * Gets the level operand input component
  65648. */
  65649. get level(): NodeMaterialConnectionPoint;
  65650. /**
  65651. * Gets the output component
  65652. */
  65653. get output(): NodeMaterialConnectionPoint;
  65654. protected _buildBlock(state: NodeMaterialBuildState): this;
  65655. }
  65656. }
  65657. declare module BABYLON {
  65658. /**
  65659. * Block used to implement the reflection module of the PBR material
  65660. */
  65661. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65662. /** @hidden */
  65663. _defineLODReflectionAlpha: string;
  65664. /** @hidden */
  65665. _defineLinearSpecularReflection: string;
  65666. private _vEnvironmentIrradianceName;
  65667. /** @hidden */
  65668. _vReflectionMicrosurfaceInfosName: string;
  65669. /** @hidden */
  65670. _vReflectionInfosName: string;
  65671. /** @hidden */
  65672. _vReflectionFilteringInfoName: string;
  65673. private _scene;
  65674. /**
  65675. * The properties below are set by the main PBR block prior to calling methods of this class.
  65676. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65677. * It's less burden on the user side in the editor part.
  65678. */
  65679. /** @hidden */
  65680. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65681. /** @hidden */
  65682. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65683. /** @hidden */
  65684. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65685. /** @hidden */
  65686. viewConnectionPoint: NodeMaterialConnectionPoint;
  65687. /**
  65688. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65689. * diffuse part of the IBL.
  65690. */
  65691. useSphericalHarmonics: boolean;
  65692. /**
  65693. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65694. */
  65695. forceIrradianceInFragment: boolean;
  65696. /**
  65697. * Create a new ReflectionBlock
  65698. * @param name defines the block name
  65699. */
  65700. constructor(name: string);
  65701. /**
  65702. * Gets the current class name
  65703. * @returns the class name
  65704. */
  65705. getClassName(): string;
  65706. /**
  65707. * Gets the position input component
  65708. */
  65709. get position(): NodeMaterialConnectionPoint;
  65710. /**
  65711. * Gets the world position input component
  65712. */
  65713. get worldPosition(): NodeMaterialConnectionPoint;
  65714. /**
  65715. * Gets the world normal input component
  65716. */
  65717. get worldNormal(): NodeMaterialConnectionPoint;
  65718. /**
  65719. * Gets the world input component
  65720. */
  65721. get world(): NodeMaterialConnectionPoint;
  65722. /**
  65723. * Gets the camera (or eye) position component
  65724. */
  65725. get cameraPosition(): NodeMaterialConnectionPoint;
  65726. /**
  65727. * Gets the view input component
  65728. */
  65729. get view(): NodeMaterialConnectionPoint;
  65730. /**
  65731. * Gets the color input component
  65732. */
  65733. get color(): NodeMaterialConnectionPoint;
  65734. /**
  65735. * Gets the reflection object output component
  65736. */
  65737. get reflection(): NodeMaterialConnectionPoint;
  65738. /**
  65739. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65740. */
  65741. get hasTexture(): boolean;
  65742. /**
  65743. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65744. */
  65745. get reflectionColor(): string;
  65746. protected _getTexture(): Nullable<BaseTexture>;
  65747. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65748. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65749. /**
  65750. * Gets the code to inject in the vertex shader
  65751. * @param state current state of the node material building
  65752. * @returns the shader code
  65753. */
  65754. handleVertexSide(state: NodeMaterialBuildState): string;
  65755. /**
  65756. * Gets the main code of the block (fragment side)
  65757. * @param state current state of the node material building
  65758. * @param normalVarName name of the existing variable corresponding to the normal
  65759. * @returns the shader code
  65760. */
  65761. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65762. protected _buildBlock(state: NodeMaterialBuildState): this;
  65763. protected _dumpPropertiesCode(): string;
  65764. serialize(): any;
  65765. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65766. }
  65767. }
  65768. declare module BABYLON {
  65769. /**
  65770. * Block used to implement the sheen module of the PBR material
  65771. */
  65772. export class SheenBlock extends NodeMaterialBlock {
  65773. /**
  65774. * Create a new SheenBlock
  65775. * @param name defines the block name
  65776. */
  65777. constructor(name: string);
  65778. /**
  65779. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65780. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65781. * making it easier to setup and tweak the effect
  65782. */
  65783. albedoScaling: boolean;
  65784. /**
  65785. * Defines if the sheen is linked to the sheen color.
  65786. */
  65787. linkSheenWithAlbedo: boolean;
  65788. /**
  65789. * Initialize the block and prepare the context for build
  65790. * @param state defines the state that will be used for the build
  65791. */
  65792. initialize(state: NodeMaterialBuildState): void;
  65793. /**
  65794. * Gets the current class name
  65795. * @returns the class name
  65796. */
  65797. getClassName(): string;
  65798. /**
  65799. * Gets the intensity input component
  65800. */
  65801. get intensity(): NodeMaterialConnectionPoint;
  65802. /**
  65803. * Gets the color input component
  65804. */
  65805. get color(): NodeMaterialConnectionPoint;
  65806. /**
  65807. * Gets the roughness input component
  65808. */
  65809. get roughness(): NodeMaterialConnectionPoint;
  65810. /**
  65811. * Gets the sheen object output component
  65812. */
  65813. get sheen(): NodeMaterialConnectionPoint;
  65814. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65815. /**
  65816. * Gets the main code of the block (fragment side)
  65817. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65818. * @returns the shader code
  65819. */
  65820. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65821. protected _buildBlock(state: NodeMaterialBuildState): this;
  65822. protected _dumpPropertiesCode(): string;
  65823. serialize(): any;
  65824. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65825. }
  65826. }
  65827. declare module BABYLON {
  65828. /**
  65829. * Block used to implement the anisotropy module of the PBR material
  65830. */
  65831. export class AnisotropyBlock extends NodeMaterialBlock {
  65832. /**
  65833. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65834. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65835. * It's less burden on the user side in the editor part.
  65836. */
  65837. /** @hidden */
  65838. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65839. /** @hidden */
  65840. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65841. /**
  65842. * Create a new AnisotropyBlock
  65843. * @param name defines the block name
  65844. */
  65845. constructor(name: string);
  65846. /**
  65847. * Initialize the block and prepare the context for build
  65848. * @param state defines the state that will be used for the build
  65849. */
  65850. initialize(state: NodeMaterialBuildState): void;
  65851. /**
  65852. * Gets the current class name
  65853. * @returns the class name
  65854. */
  65855. getClassName(): string;
  65856. /**
  65857. * Gets the intensity input component
  65858. */
  65859. get intensity(): NodeMaterialConnectionPoint;
  65860. /**
  65861. * Gets the direction input component
  65862. */
  65863. get direction(): NodeMaterialConnectionPoint;
  65864. /**
  65865. * Gets the uv input component
  65866. */
  65867. get uv(): NodeMaterialConnectionPoint;
  65868. /**
  65869. * Gets the worldTangent input component
  65870. */
  65871. get worldTangent(): NodeMaterialConnectionPoint;
  65872. /**
  65873. * Gets the anisotropy object output component
  65874. */
  65875. get anisotropy(): NodeMaterialConnectionPoint;
  65876. private _generateTBNSpace;
  65877. /**
  65878. * Gets the main code of the block (fragment side)
  65879. * @param state current state of the node material building
  65880. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65881. * @returns the shader code
  65882. */
  65883. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65884. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65885. protected _buildBlock(state: NodeMaterialBuildState): this;
  65886. }
  65887. }
  65888. declare module BABYLON {
  65889. /**
  65890. * Block used to implement the clear coat module of the PBR material
  65891. */
  65892. export class ClearCoatBlock extends NodeMaterialBlock {
  65893. private _scene;
  65894. /**
  65895. * Create a new ClearCoatBlock
  65896. * @param name defines the block name
  65897. */
  65898. constructor(name: string);
  65899. /**
  65900. * Defines if the F0 value should be remapped to account for the interface change in the material.
  65901. */
  65902. remapF0OnInterfaceChange: boolean;
  65903. /**
  65904. * Initialize the block and prepare the context for build
  65905. * @param state defines the state that will be used for the build
  65906. */
  65907. initialize(state: NodeMaterialBuildState): void;
  65908. /**
  65909. * Gets the current class name
  65910. * @returns the class name
  65911. */
  65912. getClassName(): string;
  65913. /**
  65914. * Gets the intensity input component
  65915. */
  65916. get intensity(): NodeMaterialConnectionPoint;
  65917. /**
  65918. * Gets the roughness input component
  65919. */
  65920. get roughness(): NodeMaterialConnectionPoint;
  65921. /**
  65922. * Gets the ior input component
  65923. */
  65924. get indexOfRefraction(): NodeMaterialConnectionPoint;
  65925. /**
  65926. * Gets the bump texture input component
  65927. */
  65928. get normalMapColor(): NodeMaterialConnectionPoint;
  65929. /**
  65930. * Gets the uv input component
  65931. */
  65932. get uv(): NodeMaterialConnectionPoint;
  65933. /**
  65934. * Gets the tint color input component
  65935. */
  65936. get tintColor(): NodeMaterialConnectionPoint;
  65937. /**
  65938. * Gets the tint "at distance" input component
  65939. */
  65940. get tintAtDistance(): NodeMaterialConnectionPoint;
  65941. /**
  65942. * Gets the tint thickness input component
  65943. */
  65944. get tintThickness(): NodeMaterialConnectionPoint;
  65945. /**
  65946. * Gets the world tangent input component
  65947. */
  65948. get worldTangent(): NodeMaterialConnectionPoint;
  65949. /**
  65950. * Gets the clear coat object output component
  65951. */
  65952. get clearcoat(): NodeMaterialConnectionPoint;
  65953. autoConfigure(material: NodeMaterial): void;
  65954. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65955. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65956. private _generateTBNSpace;
  65957. /**
  65958. * Gets the main code of the block (fragment side)
  65959. * @param state current state of the node material building
  65960. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65961. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65962. * @param worldPosVarName name of the variable holding the world position
  65963. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65964. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65965. * @param worldNormalVarName name of the variable holding the world normal
  65966. * @returns the shader code
  65967. */
  65968. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65969. protected _buildBlock(state: NodeMaterialBuildState): this;
  65970. protected _dumpPropertiesCode(): string;
  65971. serialize(): any;
  65972. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65973. }
  65974. }
  65975. declare module BABYLON {
  65976. /**
  65977. * Block used to implement the sub surface module of the PBR material
  65978. */
  65979. export class SubSurfaceBlock extends NodeMaterialBlock {
  65980. /**
  65981. * Create a new SubSurfaceBlock
  65982. * @param name defines the block name
  65983. */
  65984. constructor(name: string);
  65985. /**
  65986. * Initialize the block and prepare the context for build
  65987. * @param state defines the state that will be used for the build
  65988. */
  65989. initialize(state: NodeMaterialBuildState): void;
  65990. /**
  65991. * Gets the current class name
  65992. * @returns the class name
  65993. */
  65994. getClassName(): string;
  65995. /**
  65996. * Gets the thickness component
  65997. */
  65998. get thickness(): NodeMaterialConnectionPoint;
  65999. /**
  66000. * Gets the tint color input component
  66001. */
  66002. get tintColor(): NodeMaterialConnectionPoint;
  66003. /**
  66004. * Gets the translucency intensity input component
  66005. */
  66006. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66007. /**
  66008. * Gets the translucency diffusion distance input component
  66009. */
  66010. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  66011. /**
  66012. * Gets the refraction object parameters
  66013. */
  66014. get refraction(): NodeMaterialConnectionPoint;
  66015. /**
  66016. * Gets the sub surface object output component
  66017. */
  66018. get subsurface(): NodeMaterialConnectionPoint;
  66019. autoConfigure(material: NodeMaterial): void;
  66020. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66021. /**
  66022. * Gets the main code of the block (fragment side)
  66023. * @param state current state of the node material building
  66024. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66025. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66026. * @param worldPosVarName name of the variable holding the world position
  66027. * @returns the shader code
  66028. */
  66029. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66030. protected _buildBlock(state: NodeMaterialBuildState): this;
  66031. }
  66032. }
  66033. declare module BABYLON {
  66034. /**
  66035. * Block used to implement the PBR metallic/roughness model
  66036. */
  66037. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66038. /**
  66039. * Gets or sets the light associated with this block
  66040. */
  66041. light: Nullable<Light>;
  66042. private _lightId;
  66043. private _scene;
  66044. private _environmentBRDFTexture;
  66045. private _environmentBrdfSamplerName;
  66046. private _vNormalWName;
  66047. private _invertNormalName;
  66048. private _metallicReflectanceColor;
  66049. private _metallicF0Factor;
  66050. private _vMetallicReflectanceFactorsName;
  66051. /**
  66052. * Create a new ReflectionBlock
  66053. * @param name defines the block name
  66054. */
  66055. constructor(name: string);
  66056. /**
  66057. * Intensity of the direct lights e.g. the four lights available in your scene.
  66058. * This impacts both the direct diffuse and specular highlights.
  66059. */
  66060. directIntensity: number;
  66061. /**
  66062. * Intensity of the environment e.g. how much the environment will light the object
  66063. * either through harmonics for rough material or through the refelction for shiny ones.
  66064. */
  66065. environmentIntensity: number;
  66066. /**
  66067. * This is a special control allowing the reduction of the specular highlights coming from the
  66068. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66069. */
  66070. specularIntensity: number;
  66071. /**
  66072. * Defines the falloff type used in this material.
  66073. * It by default is Physical.
  66074. */
  66075. lightFalloff: number;
  66076. /**
  66077. * Specifies that alpha test should be used
  66078. */
  66079. useAlphaTest: boolean;
  66080. /**
  66081. * Defines the alpha limits in alpha test mode.
  66082. */
  66083. alphaTestCutoff: number;
  66084. /**
  66085. * Specifies that alpha blending should be used
  66086. */
  66087. useAlphaBlending: boolean;
  66088. /**
  66089. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66090. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66091. */
  66092. useRadianceOverAlpha: boolean;
  66093. /**
  66094. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66095. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66096. */
  66097. useSpecularOverAlpha: boolean;
  66098. /**
  66099. * Enables specular anti aliasing in the PBR shader.
  66100. * It will both interacts on the Geometry for analytical and IBL lighting.
  66101. * It also prefilter the roughness map based on the bump values.
  66102. */
  66103. enableSpecularAntiAliasing: boolean;
  66104. /**
  66105. * Enables realtime filtering on the texture.
  66106. */
  66107. realTimeFiltering: boolean;
  66108. /**
  66109. * Quality switch for realtime filtering
  66110. */
  66111. realTimeFilteringQuality: number;
  66112. /**
  66113. * Defines if the material uses energy conservation.
  66114. */
  66115. useEnergyConservation: boolean;
  66116. /**
  66117. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66118. * too much the area relying on ambient texture to define their ambient occlusion.
  66119. */
  66120. useRadianceOcclusion: boolean;
  66121. /**
  66122. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66123. * makes the reflect vector face the model (under horizon).
  66124. */
  66125. useHorizonOcclusion: boolean;
  66126. /**
  66127. * If set to true, no lighting calculations will be applied.
  66128. */
  66129. unlit: boolean;
  66130. /**
  66131. * Force normal to face away from face.
  66132. */
  66133. forceNormalForward: boolean;
  66134. /**
  66135. * Defines the material debug mode.
  66136. * It helps seeing only some components of the material while troubleshooting.
  66137. */
  66138. debugMode: number;
  66139. /**
  66140. * Specify from where on screen the debug mode should start.
  66141. * The value goes from -1 (full screen) to 1 (not visible)
  66142. * It helps with side by side comparison against the final render
  66143. * This defaults to 0
  66144. */
  66145. debugLimit: number;
  66146. /**
  66147. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66148. * You can use the factor to better multiply the final value.
  66149. */
  66150. debugFactor: number;
  66151. /**
  66152. * Initialize the block and prepare the context for build
  66153. * @param state defines the state that will be used for the build
  66154. */
  66155. initialize(state: NodeMaterialBuildState): void;
  66156. /**
  66157. * Gets the current class name
  66158. * @returns the class name
  66159. */
  66160. getClassName(): string;
  66161. /**
  66162. * Gets the world position input component
  66163. */
  66164. get worldPosition(): NodeMaterialConnectionPoint;
  66165. /**
  66166. * Gets the world normal input component
  66167. */
  66168. get worldNormal(): NodeMaterialConnectionPoint;
  66169. /**
  66170. * Gets the view matrix parameter
  66171. */
  66172. get view(): NodeMaterialConnectionPoint;
  66173. /**
  66174. * Gets the camera position input component
  66175. */
  66176. get cameraPosition(): NodeMaterialConnectionPoint;
  66177. /**
  66178. * Gets the perturbed normal input component
  66179. */
  66180. get perturbedNormal(): NodeMaterialConnectionPoint;
  66181. /**
  66182. * Gets the base color input component
  66183. */
  66184. get baseColor(): NodeMaterialConnectionPoint;
  66185. /**
  66186. * Gets the metallic input component
  66187. */
  66188. get metallic(): NodeMaterialConnectionPoint;
  66189. /**
  66190. * Gets the roughness input component
  66191. */
  66192. get roughness(): NodeMaterialConnectionPoint;
  66193. /**
  66194. * Gets the ambient occlusion input component
  66195. */
  66196. get ambientOcc(): NodeMaterialConnectionPoint;
  66197. /**
  66198. * Gets the opacity input component
  66199. */
  66200. get opacity(): NodeMaterialConnectionPoint;
  66201. /**
  66202. * Gets the index of refraction input component
  66203. */
  66204. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66205. /**
  66206. * Gets the ambient color input component
  66207. */
  66208. get ambientColor(): NodeMaterialConnectionPoint;
  66209. /**
  66210. * Gets the reflection object parameters
  66211. */
  66212. get reflection(): NodeMaterialConnectionPoint;
  66213. /**
  66214. * Gets the clear coat object parameters
  66215. */
  66216. get clearcoat(): NodeMaterialConnectionPoint;
  66217. /**
  66218. * Gets the sheen object parameters
  66219. */
  66220. get sheen(): NodeMaterialConnectionPoint;
  66221. /**
  66222. * Gets the sub surface object parameters
  66223. */
  66224. get subsurface(): NodeMaterialConnectionPoint;
  66225. /**
  66226. * Gets the anisotropy object parameters
  66227. */
  66228. get anisotropy(): NodeMaterialConnectionPoint;
  66229. /**
  66230. * Gets the ambient output component
  66231. */
  66232. get ambientClr(): NodeMaterialConnectionPoint;
  66233. /**
  66234. * Gets the diffuse output component
  66235. */
  66236. get diffuseDir(): NodeMaterialConnectionPoint;
  66237. /**
  66238. * Gets the specular output component
  66239. */
  66240. get specularDir(): NodeMaterialConnectionPoint;
  66241. /**
  66242. * Gets the clear coat output component
  66243. */
  66244. get clearcoatDir(): NodeMaterialConnectionPoint;
  66245. /**
  66246. * Gets the sheen output component
  66247. */
  66248. get sheenDir(): NodeMaterialConnectionPoint;
  66249. /**
  66250. * Gets the indirect diffuse output component
  66251. */
  66252. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66253. /**
  66254. * Gets the indirect specular output component
  66255. */
  66256. get specularIndirect(): NodeMaterialConnectionPoint;
  66257. /**
  66258. * Gets the indirect clear coat output component
  66259. */
  66260. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66261. /**
  66262. * Gets the indirect sheen output component
  66263. */
  66264. get sheenIndirect(): NodeMaterialConnectionPoint;
  66265. /**
  66266. * Gets the refraction output component
  66267. */
  66268. get refraction(): NodeMaterialConnectionPoint;
  66269. /**
  66270. * Gets the global lighting output component
  66271. */
  66272. get lighting(): NodeMaterialConnectionPoint;
  66273. /**
  66274. * Gets the shadow output component
  66275. */
  66276. get shadow(): NodeMaterialConnectionPoint;
  66277. /**
  66278. * Gets the alpha output component
  66279. */
  66280. get alpha(): NodeMaterialConnectionPoint;
  66281. autoConfigure(material: NodeMaterial): void;
  66282. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66283. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66284. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66285. private _injectVertexCode;
  66286. private _getAlbedoOpacityCode;
  66287. private _getAmbientOcclusionCode;
  66288. private _getReflectivityCode;
  66289. protected _buildBlock(state: NodeMaterialBuildState): this;
  66290. protected _dumpPropertiesCode(): string;
  66291. serialize(): any;
  66292. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66293. }
  66294. }
  66295. declare module BABYLON {
  66296. /**
  66297. * Block used to compute value of one parameter modulo another
  66298. */
  66299. export class ModBlock extends NodeMaterialBlock {
  66300. /**
  66301. * Creates a new ModBlock
  66302. * @param name defines the block name
  66303. */
  66304. constructor(name: string);
  66305. /**
  66306. * Gets the current class name
  66307. * @returns the class name
  66308. */
  66309. getClassName(): string;
  66310. /**
  66311. * Gets the left operand input component
  66312. */
  66313. get left(): NodeMaterialConnectionPoint;
  66314. /**
  66315. * Gets the right operand input component
  66316. */
  66317. get right(): NodeMaterialConnectionPoint;
  66318. /**
  66319. * Gets the output component
  66320. */
  66321. get output(): NodeMaterialConnectionPoint;
  66322. protected _buildBlock(state: NodeMaterialBuildState): this;
  66323. }
  66324. }
  66325. declare module BABYLON {
  66326. /**
  66327. * Configuration for Draco compression
  66328. */
  66329. export interface IDracoCompressionConfiguration {
  66330. /**
  66331. * Configuration for the decoder.
  66332. */
  66333. decoder: {
  66334. /**
  66335. * The url to the WebAssembly module.
  66336. */
  66337. wasmUrl?: string;
  66338. /**
  66339. * The url to the WebAssembly binary.
  66340. */
  66341. wasmBinaryUrl?: string;
  66342. /**
  66343. * The url to the fallback JavaScript module.
  66344. */
  66345. fallbackUrl?: string;
  66346. };
  66347. }
  66348. /**
  66349. * Draco compression (https://google.github.io/draco/)
  66350. *
  66351. * This class wraps the Draco module.
  66352. *
  66353. * **Encoder**
  66354. *
  66355. * The encoder is not currently implemented.
  66356. *
  66357. * **Decoder**
  66358. *
  66359. * 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.
  66360. *
  66361. * To update the configuration, use the following code:
  66362. * ```javascript
  66363. * DracoCompression.Configuration = {
  66364. * decoder: {
  66365. * wasmUrl: "<url to the WebAssembly library>",
  66366. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66367. * fallbackUrl: "<url to the fallback JavaScript library>",
  66368. * }
  66369. * };
  66370. * ```
  66371. *
  66372. * 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.
  66373. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66374. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66375. *
  66376. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66377. * ```javascript
  66378. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66379. * ```
  66380. *
  66381. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66382. */
  66383. export class DracoCompression implements IDisposable {
  66384. private _workerPoolPromise?;
  66385. private _decoderModulePromise?;
  66386. /**
  66387. * The configuration. Defaults to the following urls:
  66388. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66389. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66390. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66391. */
  66392. static Configuration: IDracoCompressionConfiguration;
  66393. /**
  66394. * Returns true if the decoder configuration is available.
  66395. */
  66396. static get DecoderAvailable(): boolean;
  66397. /**
  66398. * Default number of workers to create when creating the draco compression object.
  66399. */
  66400. static DefaultNumWorkers: number;
  66401. private static GetDefaultNumWorkers;
  66402. private static _Default;
  66403. /**
  66404. * Default instance for the draco compression object.
  66405. */
  66406. static get Default(): DracoCompression;
  66407. /**
  66408. * Constructor
  66409. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66410. */
  66411. constructor(numWorkers?: number);
  66412. /**
  66413. * Stop all async operations and release resources.
  66414. */
  66415. dispose(): void;
  66416. /**
  66417. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66418. * @returns a promise that resolves when ready
  66419. */
  66420. whenReadyAsync(): Promise<void>;
  66421. /**
  66422. * Decode Draco compressed mesh data to vertex data.
  66423. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66424. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66425. * @returns A promise that resolves with the decoded vertex data
  66426. */
  66427. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66428. [kind: string]: number;
  66429. }): Promise<VertexData>;
  66430. }
  66431. }
  66432. declare module BABYLON {
  66433. /**
  66434. * Class for building Constructive Solid Geometry
  66435. */
  66436. export class CSG {
  66437. private polygons;
  66438. /**
  66439. * The world matrix
  66440. */
  66441. matrix: Matrix;
  66442. /**
  66443. * Stores the position
  66444. */
  66445. position: Vector3;
  66446. /**
  66447. * Stores the rotation
  66448. */
  66449. rotation: Vector3;
  66450. /**
  66451. * Stores the rotation quaternion
  66452. */
  66453. rotationQuaternion: Nullable<Quaternion>;
  66454. /**
  66455. * Stores the scaling vector
  66456. */
  66457. scaling: Vector3;
  66458. /**
  66459. * Convert the Mesh to CSG
  66460. * @param mesh The Mesh to convert to CSG
  66461. * @returns A new CSG from the Mesh
  66462. */
  66463. static FromMesh(mesh: Mesh): CSG;
  66464. /**
  66465. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66466. * @param polygons Polygons used to construct a CSG solid
  66467. */
  66468. private static FromPolygons;
  66469. /**
  66470. * Clones, or makes a deep copy, of the CSG
  66471. * @returns A new CSG
  66472. */
  66473. clone(): CSG;
  66474. /**
  66475. * Unions this CSG with another CSG
  66476. * @param csg The CSG to union against this CSG
  66477. * @returns The unioned CSG
  66478. */
  66479. union(csg: CSG): CSG;
  66480. /**
  66481. * Unions this CSG with another CSG in place
  66482. * @param csg The CSG to union against this CSG
  66483. */
  66484. unionInPlace(csg: CSG): void;
  66485. /**
  66486. * Subtracts this CSG with another CSG
  66487. * @param csg The CSG to subtract against this CSG
  66488. * @returns A new CSG
  66489. */
  66490. subtract(csg: CSG): CSG;
  66491. /**
  66492. * Subtracts this CSG with another CSG in place
  66493. * @param csg The CSG to subtact against this CSG
  66494. */
  66495. subtractInPlace(csg: CSG): void;
  66496. /**
  66497. * Intersect this CSG with another CSG
  66498. * @param csg The CSG to intersect against this CSG
  66499. * @returns A new CSG
  66500. */
  66501. intersect(csg: CSG): CSG;
  66502. /**
  66503. * Intersects this CSG with another CSG in place
  66504. * @param csg The CSG to intersect against this CSG
  66505. */
  66506. intersectInPlace(csg: CSG): void;
  66507. /**
  66508. * Return a new CSG solid with solid and empty space switched. This solid is
  66509. * not modified.
  66510. * @returns A new CSG solid with solid and empty space switched
  66511. */
  66512. inverse(): CSG;
  66513. /**
  66514. * Inverses the CSG in place
  66515. */
  66516. inverseInPlace(): void;
  66517. /**
  66518. * This is used to keep meshes transformations so they can be restored
  66519. * when we build back a Babylon Mesh
  66520. * NB : All CSG operations are performed in world coordinates
  66521. * @param csg The CSG to copy the transform attributes from
  66522. * @returns This CSG
  66523. */
  66524. copyTransformAttributes(csg: CSG): CSG;
  66525. /**
  66526. * Build Raw mesh from CSG
  66527. * Coordinates here are in world space
  66528. * @param name The name of the mesh geometry
  66529. * @param scene The Scene
  66530. * @param keepSubMeshes Specifies if the submeshes should be kept
  66531. * @returns A new Mesh
  66532. */
  66533. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66534. /**
  66535. * Build Mesh from CSG taking material and transforms into account
  66536. * @param name The name of the Mesh
  66537. * @param material The material of the Mesh
  66538. * @param scene The Scene
  66539. * @param keepSubMeshes Specifies if submeshes should be kept
  66540. * @returns The new Mesh
  66541. */
  66542. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66543. }
  66544. }
  66545. declare module BABYLON {
  66546. /**
  66547. * Class used to create a trail following a mesh
  66548. */
  66549. export class TrailMesh extends Mesh {
  66550. private _generator;
  66551. private _autoStart;
  66552. private _running;
  66553. private _diameter;
  66554. private _length;
  66555. private _sectionPolygonPointsCount;
  66556. private _sectionVectors;
  66557. private _sectionNormalVectors;
  66558. private _beforeRenderObserver;
  66559. /**
  66560. * @constructor
  66561. * @param name The value used by scene.getMeshByName() to do a lookup.
  66562. * @param generator The mesh or transform node to generate a trail.
  66563. * @param scene The scene to add this mesh to.
  66564. * @param diameter Diameter of trailing mesh. Default is 1.
  66565. * @param length Length of trailing mesh. Default is 60.
  66566. * @param autoStart Automatically start trailing mesh. Default true.
  66567. */
  66568. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66569. /**
  66570. * "TrailMesh"
  66571. * @returns "TrailMesh"
  66572. */
  66573. getClassName(): string;
  66574. private _createMesh;
  66575. /**
  66576. * Start trailing mesh.
  66577. */
  66578. start(): void;
  66579. /**
  66580. * Stop trailing mesh.
  66581. */
  66582. stop(): void;
  66583. /**
  66584. * Update trailing mesh geometry.
  66585. */
  66586. update(): void;
  66587. /**
  66588. * Returns a new TrailMesh object.
  66589. * @param name is a string, the name given to the new mesh
  66590. * @param newGenerator use new generator object for cloned trail mesh
  66591. * @returns a new mesh
  66592. */
  66593. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66594. /**
  66595. * Serializes this trail mesh
  66596. * @param serializationObject object to write serialization to
  66597. */
  66598. serialize(serializationObject: any): void;
  66599. /**
  66600. * Parses a serialized trail mesh
  66601. * @param parsedMesh the serialized mesh
  66602. * @param scene the scene to create the trail mesh in
  66603. * @returns the created trail mesh
  66604. */
  66605. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66606. }
  66607. }
  66608. declare module BABYLON {
  66609. /**
  66610. * Class containing static functions to help procedurally build meshes
  66611. */
  66612. export class TiledBoxBuilder {
  66613. /**
  66614. * Creates a box mesh
  66615. * 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)
  66616. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66618. * * 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
  66619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66620. * @param name defines the name of the mesh
  66621. * @param options defines the options used to create the mesh
  66622. * @param scene defines the hosting scene
  66623. * @returns the box mesh
  66624. */
  66625. static CreateTiledBox(name: string, options: {
  66626. pattern?: number;
  66627. width?: number;
  66628. height?: number;
  66629. depth?: number;
  66630. tileSize?: number;
  66631. tileWidth?: number;
  66632. tileHeight?: number;
  66633. alignHorizontal?: number;
  66634. alignVertical?: number;
  66635. faceUV?: Vector4[];
  66636. faceColors?: Color4[];
  66637. sideOrientation?: number;
  66638. updatable?: boolean;
  66639. }, scene?: Nullable<Scene>): Mesh;
  66640. }
  66641. }
  66642. declare module BABYLON {
  66643. /**
  66644. * Class containing static functions to help procedurally build meshes
  66645. */
  66646. export class TorusKnotBuilder {
  66647. /**
  66648. * Creates a torus knot mesh
  66649. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66650. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66651. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66652. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66654. * * 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
  66655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66656. * @param name defines the name of the mesh
  66657. * @param options defines the options used to create the mesh
  66658. * @param scene defines the hosting scene
  66659. * @returns the torus knot mesh
  66660. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66661. */
  66662. static CreateTorusKnot(name: string, options: {
  66663. radius?: number;
  66664. tube?: number;
  66665. radialSegments?: number;
  66666. tubularSegments?: number;
  66667. p?: number;
  66668. q?: number;
  66669. updatable?: boolean;
  66670. sideOrientation?: number;
  66671. frontUVs?: Vector4;
  66672. backUVs?: Vector4;
  66673. }, scene: any): Mesh;
  66674. }
  66675. }
  66676. declare module BABYLON {
  66677. /**
  66678. * Polygon
  66679. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66680. */
  66681. export class Polygon {
  66682. /**
  66683. * Creates a rectangle
  66684. * @param xmin bottom X coord
  66685. * @param ymin bottom Y coord
  66686. * @param xmax top X coord
  66687. * @param ymax top Y coord
  66688. * @returns points that make the resulting rectation
  66689. */
  66690. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66691. /**
  66692. * Creates a circle
  66693. * @param radius radius of circle
  66694. * @param cx scale in x
  66695. * @param cy scale in y
  66696. * @param numberOfSides number of sides that make up the circle
  66697. * @returns points that make the resulting circle
  66698. */
  66699. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66700. /**
  66701. * Creates a polygon from input string
  66702. * @param input Input polygon data
  66703. * @returns the parsed points
  66704. */
  66705. static Parse(input: string): Vector2[];
  66706. /**
  66707. * Starts building a polygon from x and y coordinates
  66708. * @param x x coordinate
  66709. * @param y y coordinate
  66710. * @returns the started path2
  66711. */
  66712. static StartingAt(x: number, y: number): Path2;
  66713. }
  66714. /**
  66715. * Builds a polygon
  66716. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66717. */
  66718. export class PolygonMeshBuilder {
  66719. private _points;
  66720. private _outlinepoints;
  66721. private _holes;
  66722. private _name;
  66723. private _scene;
  66724. private _epoints;
  66725. private _eholes;
  66726. private _addToepoint;
  66727. /**
  66728. * Babylon reference to the earcut plugin.
  66729. */
  66730. bjsEarcut: any;
  66731. /**
  66732. * Creates a PolygonMeshBuilder
  66733. * @param name name of the builder
  66734. * @param contours Path of the polygon
  66735. * @param scene scene to add to when creating the mesh
  66736. * @param earcutInjection can be used to inject your own earcut reference
  66737. */
  66738. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66739. /**
  66740. * Adds a whole within the polygon
  66741. * @param hole Array of points defining the hole
  66742. * @returns this
  66743. */
  66744. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66745. /**
  66746. * Creates the polygon
  66747. * @param updatable If the mesh should be updatable
  66748. * @param depth The depth of the mesh created
  66749. * @returns the created mesh
  66750. */
  66751. build(updatable?: boolean, depth?: number): Mesh;
  66752. /**
  66753. * Creates the polygon
  66754. * @param depth The depth of the mesh created
  66755. * @returns the created VertexData
  66756. */
  66757. buildVertexData(depth?: number): VertexData;
  66758. /**
  66759. * Adds a side to the polygon
  66760. * @param positions points that make the polygon
  66761. * @param normals normals of the polygon
  66762. * @param uvs uvs of the polygon
  66763. * @param indices indices of the polygon
  66764. * @param bounds bounds of the polygon
  66765. * @param points points of the polygon
  66766. * @param depth depth of the polygon
  66767. * @param flip flip of the polygon
  66768. */
  66769. private addSide;
  66770. }
  66771. }
  66772. declare module BABYLON {
  66773. /**
  66774. * Class containing static functions to help procedurally build meshes
  66775. */
  66776. export class PolygonBuilder {
  66777. /**
  66778. * Creates a polygon mesh
  66779. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66780. * * 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
  66781. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66783. * * 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)
  66784. * * Remember you can only change the shape positions, not their number when updating a polygon
  66785. * @param name defines the name of the mesh
  66786. * @param options defines the options used to create the mesh
  66787. * @param scene defines the hosting scene
  66788. * @param earcutInjection can be used to inject your own earcut reference
  66789. * @returns the polygon mesh
  66790. */
  66791. static CreatePolygon(name: string, options: {
  66792. shape: Vector3[];
  66793. holes?: Vector3[][];
  66794. depth?: number;
  66795. faceUV?: Vector4[];
  66796. faceColors?: Color4[];
  66797. updatable?: boolean;
  66798. sideOrientation?: number;
  66799. frontUVs?: Vector4;
  66800. backUVs?: Vector4;
  66801. wrap?: boolean;
  66802. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66803. /**
  66804. * Creates an extruded polygon mesh, with depth in the Y direction.
  66805. * * 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)
  66806. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66807. * @param name defines the name of the mesh
  66808. * @param options defines the options used to create the mesh
  66809. * @param scene defines the hosting scene
  66810. * @param earcutInjection can be used to inject your own earcut reference
  66811. * @returns the polygon mesh
  66812. */
  66813. static ExtrudePolygon(name: string, options: {
  66814. shape: Vector3[];
  66815. holes?: Vector3[][];
  66816. depth?: number;
  66817. faceUV?: Vector4[];
  66818. faceColors?: Color4[];
  66819. updatable?: boolean;
  66820. sideOrientation?: number;
  66821. frontUVs?: Vector4;
  66822. backUVs?: Vector4;
  66823. wrap?: boolean;
  66824. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66825. }
  66826. }
  66827. declare module BABYLON {
  66828. /**
  66829. * Class containing static functions to help procedurally build meshes
  66830. */
  66831. export class LatheBuilder {
  66832. /**
  66833. * Creates lathe mesh.
  66834. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66835. * * 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
  66836. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66837. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66838. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66839. * * 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
  66840. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66841. * * 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
  66842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66843. * * 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
  66844. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66846. * @param name defines the name of the mesh
  66847. * @param options defines the options used to create the mesh
  66848. * @param scene defines the hosting scene
  66849. * @returns the lathe mesh
  66850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66851. */
  66852. static CreateLathe(name: string, options: {
  66853. shape: Vector3[];
  66854. radius?: number;
  66855. tessellation?: number;
  66856. clip?: number;
  66857. arc?: number;
  66858. closed?: boolean;
  66859. updatable?: boolean;
  66860. sideOrientation?: number;
  66861. frontUVs?: Vector4;
  66862. backUVs?: Vector4;
  66863. cap?: number;
  66864. invertUV?: boolean;
  66865. }, scene?: Nullable<Scene>): Mesh;
  66866. }
  66867. }
  66868. declare module BABYLON {
  66869. /**
  66870. * Class containing static functions to help procedurally build meshes
  66871. */
  66872. export class TiledPlaneBuilder {
  66873. /**
  66874. * Creates a tiled plane mesh
  66875. * * The parameter `pattern` will, depending on value, do nothing or
  66876. * * * flip (reflect about central vertical) alternate tiles across and up
  66877. * * * flip every tile on alternate rows
  66878. * * * rotate (180 degs) alternate tiles across and up
  66879. * * * rotate every tile on alternate rows
  66880. * * * flip and rotate alternate tiles across and up
  66881. * * * flip and rotate every tile on alternate rows
  66882. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66883. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66884. * * 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
  66885. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66886. * * 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)
  66887. * * 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)
  66888. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66889. * @param name defines the name of the mesh
  66890. * @param options defines the options used to create the mesh
  66891. * @param scene defines the hosting scene
  66892. * @returns the box mesh
  66893. */
  66894. static CreateTiledPlane(name: string, options: {
  66895. pattern?: number;
  66896. tileSize?: number;
  66897. tileWidth?: number;
  66898. tileHeight?: number;
  66899. size?: number;
  66900. width?: number;
  66901. height?: number;
  66902. alignHorizontal?: number;
  66903. alignVertical?: number;
  66904. sideOrientation?: number;
  66905. frontUVs?: Vector4;
  66906. backUVs?: Vector4;
  66907. updatable?: boolean;
  66908. }, scene?: Nullable<Scene>): Mesh;
  66909. }
  66910. }
  66911. declare module BABYLON {
  66912. /**
  66913. * Class containing static functions to help procedurally build meshes
  66914. */
  66915. export class TubeBuilder {
  66916. /**
  66917. * Creates a tube mesh.
  66918. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66919. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66920. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66921. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66922. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66923. * * 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)
  66924. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66925. * * 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
  66926. * * 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
  66927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66928. * * 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
  66929. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66931. * @param name defines the name of the mesh
  66932. * @param options defines the options used to create the mesh
  66933. * @param scene defines the hosting scene
  66934. * @returns the tube mesh
  66935. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66936. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66937. */
  66938. static CreateTube(name: string, options: {
  66939. path: Vector3[];
  66940. radius?: number;
  66941. tessellation?: number;
  66942. radiusFunction?: {
  66943. (i: number, distance: number): number;
  66944. };
  66945. cap?: number;
  66946. arc?: number;
  66947. updatable?: boolean;
  66948. sideOrientation?: number;
  66949. frontUVs?: Vector4;
  66950. backUVs?: Vector4;
  66951. instance?: Mesh;
  66952. invertUV?: boolean;
  66953. }, scene?: Nullable<Scene>): Mesh;
  66954. }
  66955. }
  66956. declare module BABYLON {
  66957. /**
  66958. * Class containing static functions to help procedurally build meshes
  66959. */
  66960. export class IcoSphereBuilder {
  66961. /**
  66962. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66963. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66964. * * 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`)
  66965. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66966. * * 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
  66967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66968. * * 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
  66969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66970. * @param name defines the name of the mesh
  66971. * @param options defines the options used to create the mesh
  66972. * @param scene defines the hosting scene
  66973. * @returns the icosahedron mesh
  66974. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66975. */
  66976. static CreateIcoSphere(name: string, options: {
  66977. radius?: number;
  66978. radiusX?: number;
  66979. radiusY?: number;
  66980. radiusZ?: number;
  66981. flat?: boolean;
  66982. subdivisions?: number;
  66983. sideOrientation?: number;
  66984. frontUVs?: Vector4;
  66985. backUVs?: Vector4;
  66986. updatable?: boolean;
  66987. }, scene?: Nullable<Scene>): Mesh;
  66988. }
  66989. }
  66990. declare module BABYLON {
  66991. /**
  66992. * Class containing static functions to help procedurally build meshes
  66993. */
  66994. export class DecalBuilder {
  66995. /**
  66996. * Creates a decal mesh.
  66997. * 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
  66998. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66999. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67000. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67001. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67002. * @param name defines the name of the mesh
  67003. * @param sourceMesh defines the mesh where the decal must be applied
  67004. * @param options defines the options used to create the mesh
  67005. * @param scene defines the hosting scene
  67006. * @returns the decal mesh
  67007. * @see https://doc.babylonjs.com/how_to/decals
  67008. */
  67009. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67010. position?: Vector3;
  67011. normal?: Vector3;
  67012. size?: Vector3;
  67013. angle?: number;
  67014. }): Mesh;
  67015. }
  67016. }
  67017. declare module BABYLON {
  67018. /**
  67019. * Class containing static functions to help procedurally build meshes
  67020. */
  67021. export class MeshBuilder {
  67022. /**
  67023. * Creates a box mesh
  67024. * * The parameter `size` sets the size (float) of each box side (default 1)
  67025. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67026. * * 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)
  67027. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67029. * * 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
  67030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67031. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67032. * @param name defines the name of the mesh
  67033. * @param options defines the options used to create the mesh
  67034. * @param scene defines the hosting scene
  67035. * @returns the box mesh
  67036. */
  67037. static CreateBox(name: string, options: {
  67038. size?: number;
  67039. width?: number;
  67040. height?: number;
  67041. depth?: number;
  67042. faceUV?: Vector4[];
  67043. faceColors?: Color4[];
  67044. sideOrientation?: number;
  67045. frontUVs?: Vector4;
  67046. backUVs?: Vector4;
  67047. wrap?: boolean;
  67048. topBaseAt?: number;
  67049. bottomBaseAt?: number;
  67050. updatable?: boolean;
  67051. }, scene?: Nullable<Scene>): Mesh;
  67052. /**
  67053. * Creates a tiled box mesh
  67054. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67056. * @param name defines the name of the mesh
  67057. * @param options defines the options used to create the mesh
  67058. * @param scene defines the hosting scene
  67059. * @returns the tiled box mesh
  67060. */
  67061. static CreateTiledBox(name: string, options: {
  67062. pattern?: number;
  67063. size?: number;
  67064. width?: number;
  67065. height?: number;
  67066. depth: number;
  67067. tileSize?: number;
  67068. tileWidth?: number;
  67069. tileHeight?: number;
  67070. faceUV?: Vector4[];
  67071. faceColors?: Color4[];
  67072. alignHorizontal?: number;
  67073. alignVertical?: number;
  67074. sideOrientation?: number;
  67075. updatable?: boolean;
  67076. }, scene?: Nullable<Scene>): Mesh;
  67077. /**
  67078. * Creates a sphere mesh
  67079. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67080. * * 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`)
  67081. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67082. * * 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
  67083. * * 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)
  67084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67085. * * 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
  67086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67087. * @param name defines the name of the mesh
  67088. * @param options defines the options used to create the mesh
  67089. * @param scene defines the hosting scene
  67090. * @returns the sphere mesh
  67091. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67092. */
  67093. static CreateSphere(name: string, options: {
  67094. segments?: number;
  67095. diameter?: number;
  67096. diameterX?: number;
  67097. diameterY?: number;
  67098. diameterZ?: number;
  67099. arc?: number;
  67100. slice?: number;
  67101. sideOrientation?: number;
  67102. frontUVs?: Vector4;
  67103. backUVs?: Vector4;
  67104. updatable?: boolean;
  67105. }, scene?: Nullable<Scene>): Mesh;
  67106. /**
  67107. * Creates a plane polygonal mesh. By default, this is a disc
  67108. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67109. * * 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
  67110. * * 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
  67111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67112. * * 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
  67113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67114. * @param name defines the name of the mesh
  67115. * @param options defines the options used to create the mesh
  67116. * @param scene defines the hosting scene
  67117. * @returns the plane polygonal mesh
  67118. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67119. */
  67120. static CreateDisc(name: string, options: {
  67121. radius?: number;
  67122. tessellation?: number;
  67123. arc?: number;
  67124. updatable?: boolean;
  67125. sideOrientation?: number;
  67126. frontUVs?: Vector4;
  67127. backUVs?: Vector4;
  67128. }, scene?: Nullable<Scene>): Mesh;
  67129. /**
  67130. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67131. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67132. * * 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`)
  67133. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67134. * * 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
  67135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67136. * * 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
  67137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67138. * @param name defines the name of the mesh
  67139. * @param options defines the options used to create the mesh
  67140. * @param scene defines the hosting scene
  67141. * @returns the icosahedron mesh
  67142. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67143. */
  67144. static CreateIcoSphere(name: string, options: {
  67145. radius?: number;
  67146. radiusX?: number;
  67147. radiusY?: number;
  67148. radiusZ?: number;
  67149. flat?: boolean;
  67150. subdivisions?: number;
  67151. sideOrientation?: number;
  67152. frontUVs?: Vector4;
  67153. backUVs?: Vector4;
  67154. updatable?: boolean;
  67155. }, scene?: Nullable<Scene>): Mesh;
  67156. /**
  67157. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67158. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67159. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67160. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67161. * * 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
  67162. * * 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
  67163. * * 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
  67164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67165. * * 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
  67166. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67167. * * 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
  67168. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67169. * * 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
  67170. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67172. * @param name defines the name of the mesh
  67173. * @param options defines the options used to create the mesh
  67174. * @param scene defines the hosting scene
  67175. * @returns the ribbon mesh
  67176. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67177. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67178. */
  67179. static CreateRibbon(name: string, options: {
  67180. pathArray: Vector3[][];
  67181. closeArray?: boolean;
  67182. closePath?: boolean;
  67183. offset?: number;
  67184. updatable?: boolean;
  67185. sideOrientation?: number;
  67186. frontUVs?: Vector4;
  67187. backUVs?: Vector4;
  67188. instance?: Mesh;
  67189. invertUV?: boolean;
  67190. uvs?: Vector2[];
  67191. colors?: Color4[];
  67192. }, scene?: Nullable<Scene>): Mesh;
  67193. /**
  67194. * Creates a cylinder or a cone mesh
  67195. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67196. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67197. * * 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.
  67198. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67199. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67200. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67201. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67202. * * 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).
  67203. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67204. * * 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).
  67205. * * 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
  67206. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67207. * * 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
  67208. * * 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.
  67209. * * If `enclose` is false, a ring surface is one element.
  67210. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67211. * * 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
  67212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67213. * * 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
  67214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67215. * @param name defines the name of the mesh
  67216. * @param options defines the options used to create the mesh
  67217. * @param scene defines the hosting scene
  67218. * @returns the cylinder mesh
  67219. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67220. */
  67221. static CreateCylinder(name: string, options: {
  67222. height?: number;
  67223. diameterTop?: number;
  67224. diameterBottom?: number;
  67225. diameter?: number;
  67226. tessellation?: number;
  67227. subdivisions?: number;
  67228. arc?: number;
  67229. faceColors?: Color4[];
  67230. faceUV?: Vector4[];
  67231. updatable?: boolean;
  67232. hasRings?: boolean;
  67233. enclose?: boolean;
  67234. cap?: number;
  67235. sideOrientation?: number;
  67236. frontUVs?: Vector4;
  67237. backUVs?: Vector4;
  67238. }, scene?: Nullable<Scene>): Mesh;
  67239. /**
  67240. * Creates a torus mesh
  67241. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67242. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67243. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67245. * * 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
  67246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67247. * @param name defines the name of the mesh
  67248. * @param options defines the options used to create the mesh
  67249. * @param scene defines the hosting scene
  67250. * @returns the torus mesh
  67251. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67252. */
  67253. static CreateTorus(name: string, options: {
  67254. diameter?: number;
  67255. thickness?: number;
  67256. tessellation?: number;
  67257. updatable?: boolean;
  67258. sideOrientation?: number;
  67259. frontUVs?: Vector4;
  67260. backUVs?: Vector4;
  67261. }, scene?: Nullable<Scene>): Mesh;
  67262. /**
  67263. * Creates a torus knot mesh
  67264. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67265. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67266. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67267. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67269. * * 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
  67270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67271. * @param name defines the name of the mesh
  67272. * @param options defines the options used to create the mesh
  67273. * @param scene defines the hosting scene
  67274. * @returns the torus knot mesh
  67275. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67276. */
  67277. static CreateTorusKnot(name: string, options: {
  67278. radius?: number;
  67279. tube?: number;
  67280. radialSegments?: number;
  67281. tubularSegments?: number;
  67282. p?: number;
  67283. q?: number;
  67284. updatable?: boolean;
  67285. sideOrientation?: number;
  67286. frontUVs?: Vector4;
  67287. backUVs?: Vector4;
  67288. }, scene?: Nullable<Scene>): Mesh;
  67289. /**
  67290. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67291. * * 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
  67292. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67293. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67294. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67295. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67296. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67297. * * 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
  67298. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67300. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67301. * @param name defines the name of the new line system
  67302. * @param options defines the options used to create the line system
  67303. * @param scene defines the hosting scene
  67304. * @returns a new line system mesh
  67305. */
  67306. static CreateLineSystem(name: string, options: {
  67307. lines: Vector3[][];
  67308. updatable?: boolean;
  67309. instance?: Nullable<LinesMesh>;
  67310. colors?: Nullable<Color4[][]>;
  67311. useVertexAlpha?: boolean;
  67312. }, scene: Nullable<Scene>): LinesMesh;
  67313. /**
  67314. * Creates a line mesh
  67315. * 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
  67316. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67317. * * The parameter `points` is an array successive Vector3
  67318. * * 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
  67319. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67320. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67321. * * When updating an instance, remember that only point positions can change, not the number of points
  67322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67324. * @param name defines the name of the new line system
  67325. * @param options defines the options used to create the line system
  67326. * @param scene defines the hosting scene
  67327. * @returns a new line mesh
  67328. */
  67329. static CreateLines(name: string, options: {
  67330. points: Vector3[];
  67331. updatable?: boolean;
  67332. instance?: Nullable<LinesMesh>;
  67333. colors?: Color4[];
  67334. useVertexAlpha?: boolean;
  67335. }, scene?: Nullable<Scene>): LinesMesh;
  67336. /**
  67337. * Creates a dashed line mesh
  67338. * * 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
  67339. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67340. * * The parameter `points` is an array successive Vector3
  67341. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67342. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67343. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67344. * * 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
  67345. * * When updating an instance, remember that only point positions can change, not the number of points
  67346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67347. * @param name defines the name of the mesh
  67348. * @param options defines the options used to create the mesh
  67349. * @param scene defines the hosting scene
  67350. * @returns the dashed line mesh
  67351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67352. */
  67353. static CreateDashedLines(name: string, options: {
  67354. points: Vector3[];
  67355. dashSize?: number;
  67356. gapSize?: number;
  67357. dashNb?: number;
  67358. updatable?: boolean;
  67359. instance?: LinesMesh;
  67360. }, scene?: Nullable<Scene>): LinesMesh;
  67361. /**
  67362. * 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.
  67363. * * 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.
  67364. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67365. * * 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.
  67366. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67367. * * 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
  67368. * * 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
  67369. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67371. * * 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
  67372. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67374. * @param name defines the name of the mesh
  67375. * @param options defines the options used to create the mesh
  67376. * @param scene defines the hosting scene
  67377. * @returns the extruded shape mesh
  67378. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67379. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67380. */
  67381. static ExtrudeShape(name: string, options: {
  67382. shape: Vector3[];
  67383. path: Vector3[];
  67384. scale?: number;
  67385. rotation?: number;
  67386. cap?: number;
  67387. updatable?: boolean;
  67388. sideOrientation?: number;
  67389. frontUVs?: Vector4;
  67390. backUVs?: Vector4;
  67391. instance?: Mesh;
  67392. invertUV?: boolean;
  67393. }, scene?: Nullable<Scene>): Mesh;
  67394. /**
  67395. * Creates an custom extruded shape mesh.
  67396. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67397. * * 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.
  67398. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67399. * * 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
  67400. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67401. * * 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
  67402. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67403. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67404. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67405. * * 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
  67406. * * 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
  67407. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67409. * * 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
  67410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67412. * @param name defines the name of the mesh
  67413. * @param options defines the options used to create the mesh
  67414. * @param scene defines the hosting scene
  67415. * @returns the custom extruded shape mesh
  67416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67417. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67418. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67419. */
  67420. static ExtrudeShapeCustom(name: string, options: {
  67421. shape: Vector3[];
  67422. path: Vector3[];
  67423. scaleFunction?: any;
  67424. rotationFunction?: any;
  67425. ribbonCloseArray?: boolean;
  67426. ribbonClosePath?: boolean;
  67427. cap?: number;
  67428. updatable?: boolean;
  67429. sideOrientation?: number;
  67430. frontUVs?: Vector4;
  67431. backUVs?: Vector4;
  67432. instance?: Mesh;
  67433. invertUV?: boolean;
  67434. }, scene?: Nullable<Scene>): Mesh;
  67435. /**
  67436. * Creates lathe mesh.
  67437. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67438. * * 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
  67439. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67440. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67441. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67442. * * 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
  67443. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67444. * * 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
  67445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67446. * * 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
  67447. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67449. * @param name defines the name of the mesh
  67450. * @param options defines the options used to create the mesh
  67451. * @param scene defines the hosting scene
  67452. * @returns the lathe mesh
  67453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67454. */
  67455. static CreateLathe(name: string, options: {
  67456. shape: Vector3[];
  67457. radius?: number;
  67458. tessellation?: number;
  67459. clip?: number;
  67460. arc?: number;
  67461. closed?: boolean;
  67462. updatable?: boolean;
  67463. sideOrientation?: number;
  67464. frontUVs?: Vector4;
  67465. backUVs?: Vector4;
  67466. cap?: number;
  67467. invertUV?: boolean;
  67468. }, scene?: Nullable<Scene>): Mesh;
  67469. /**
  67470. * Creates a tiled plane mesh
  67471. * * You can set a limited pattern arrangement with the tiles
  67472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67473. * * 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
  67474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67475. * @param name defines the name of the mesh
  67476. * @param options defines the options used to create the mesh
  67477. * @param scene defines the hosting scene
  67478. * @returns the plane mesh
  67479. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67480. */
  67481. static CreateTiledPlane(name: string, options: {
  67482. pattern?: number;
  67483. tileSize?: number;
  67484. tileWidth?: number;
  67485. tileHeight?: number;
  67486. size?: number;
  67487. width?: number;
  67488. height?: number;
  67489. alignHorizontal?: number;
  67490. alignVertical?: number;
  67491. sideOrientation?: number;
  67492. frontUVs?: Vector4;
  67493. backUVs?: Vector4;
  67494. updatable?: boolean;
  67495. }, scene?: Nullable<Scene>): Mesh;
  67496. /**
  67497. * Creates a plane mesh
  67498. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67499. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67500. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67502. * * 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
  67503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67504. * @param name defines the name of the mesh
  67505. * @param options defines the options used to create the mesh
  67506. * @param scene defines the hosting scene
  67507. * @returns the plane mesh
  67508. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67509. */
  67510. static CreatePlane(name: string, options: {
  67511. size?: number;
  67512. width?: number;
  67513. height?: number;
  67514. sideOrientation?: number;
  67515. frontUVs?: Vector4;
  67516. backUVs?: Vector4;
  67517. updatable?: boolean;
  67518. sourcePlane?: Plane;
  67519. }, scene?: Nullable<Scene>): Mesh;
  67520. /**
  67521. * Creates a ground mesh
  67522. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67523. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67525. * @param name defines the name of the mesh
  67526. * @param options defines the options used to create the mesh
  67527. * @param scene defines the hosting scene
  67528. * @returns the ground mesh
  67529. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67530. */
  67531. static CreateGround(name: string, options: {
  67532. width?: number;
  67533. height?: number;
  67534. subdivisions?: number;
  67535. subdivisionsX?: number;
  67536. subdivisionsY?: number;
  67537. updatable?: boolean;
  67538. }, scene?: Nullable<Scene>): Mesh;
  67539. /**
  67540. * Creates a tiled ground mesh
  67541. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67542. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67543. * * 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
  67544. * * 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
  67545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67546. * @param name defines the name of the mesh
  67547. * @param options defines the options used to create the mesh
  67548. * @param scene defines the hosting scene
  67549. * @returns the tiled ground mesh
  67550. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67551. */
  67552. static CreateTiledGround(name: string, options: {
  67553. xmin: number;
  67554. zmin: number;
  67555. xmax: number;
  67556. zmax: number;
  67557. subdivisions?: {
  67558. w: number;
  67559. h: number;
  67560. };
  67561. precision?: {
  67562. w: number;
  67563. h: number;
  67564. };
  67565. updatable?: boolean;
  67566. }, scene?: Nullable<Scene>): Mesh;
  67567. /**
  67568. * Creates a ground mesh from a height map
  67569. * * The parameter `url` sets the URL of the height map image resource.
  67570. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67571. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67572. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67573. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67574. * * 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.
  67575. * * 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).
  67576. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67578. * @param name defines the name of the mesh
  67579. * @param url defines the url to the height map
  67580. * @param options defines the options used to create the mesh
  67581. * @param scene defines the hosting scene
  67582. * @returns the ground mesh
  67583. * @see https://doc.babylonjs.com/babylon101/height_map
  67584. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67585. */
  67586. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67587. width?: number;
  67588. height?: number;
  67589. subdivisions?: number;
  67590. minHeight?: number;
  67591. maxHeight?: number;
  67592. colorFilter?: Color3;
  67593. alphaFilter?: number;
  67594. updatable?: boolean;
  67595. onReady?: (mesh: GroundMesh) => void;
  67596. }, scene?: Nullable<Scene>): GroundMesh;
  67597. /**
  67598. * Creates a polygon mesh
  67599. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67600. * * 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
  67601. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67603. * * 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)
  67604. * * Remember you can only change the shape positions, not their number when updating a polygon
  67605. * @param name defines the name of the mesh
  67606. * @param options defines the options used to create the mesh
  67607. * @param scene defines the hosting scene
  67608. * @param earcutInjection can be used to inject your own earcut reference
  67609. * @returns the polygon mesh
  67610. */
  67611. static CreatePolygon(name: string, options: {
  67612. shape: Vector3[];
  67613. holes?: Vector3[][];
  67614. depth?: number;
  67615. faceUV?: Vector4[];
  67616. faceColors?: Color4[];
  67617. updatable?: boolean;
  67618. sideOrientation?: number;
  67619. frontUVs?: Vector4;
  67620. backUVs?: Vector4;
  67621. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67622. /**
  67623. * Creates an extruded polygon mesh, with depth in the Y direction.
  67624. * * 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)
  67625. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67626. * @param name defines the name of the mesh
  67627. * @param options defines the options used to create the mesh
  67628. * @param scene defines the hosting scene
  67629. * @param earcutInjection can be used to inject your own earcut reference
  67630. * @returns the polygon mesh
  67631. */
  67632. static ExtrudePolygon(name: string, options: {
  67633. shape: Vector3[];
  67634. holes?: Vector3[][];
  67635. depth?: number;
  67636. faceUV?: Vector4[];
  67637. faceColors?: Color4[];
  67638. updatable?: boolean;
  67639. sideOrientation?: number;
  67640. frontUVs?: Vector4;
  67641. backUVs?: Vector4;
  67642. wrap?: boolean;
  67643. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67644. /**
  67645. * Creates a tube mesh.
  67646. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67647. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67648. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67649. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67650. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67651. * * 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)
  67652. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67653. * * 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
  67654. * * 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
  67655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67656. * * 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
  67657. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67659. * @param name defines the name of the mesh
  67660. * @param options defines the options used to create the mesh
  67661. * @param scene defines the hosting scene
  67662. * @returns the tube mesh
  67663. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67664. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67665. */
  67666. static CreateTube(name: string, options: {
  67667. path: Vector3[];
  67668. radius?: number;
  67669. tessellation?: number;
  67670. radiusFunction?: {
  67671. (i: number, distance: number): number;
  67672. };
  67673. cap?: number;
  67674. arc?: number;
  67675. updatable?: boolean;
  67676. sideOrientation?: number;
  67677. frontUVs?: Vector4;
  67678. backUVs?: Vector4;
  67679. instance?: Mesh;
  67680. invertUV?: boolean;
  67681. }, scene?: Nullable<Scene>): Mesh;
  67682. /**
  67683. * Creates a polyhedron mesh
  67684. * * 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
  67685. * * The parameter `size` (positive float, default 1) sets the polygon size
  67686. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67687. * * 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`
  67688. * * 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
  67689. * * 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)`)
  67690. * * 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
  67691. * * 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
  67692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67693. * * 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
  67694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67695. * @param name defines the name of the mesh
  67696. * @param options defines the options used to create the mesh
  67697. * @param scene defines the hosting scene
  67698. * @returns the polyhedron mesh
  67699. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67700. */
  67701. static CreatePolyhedron(name: string, options: {
  67702. type?: number;
  67703. size?: number;
  67704. sizeX?: number;
  67705. sizeY?: number;
  67706. sizeZ?: number;
  67707. custom?: any;
  67708. faceUV?: Vector4[];
  67709. faceColors?: Color4[];
  67710. flat?: boolean;
  67711. updatable?: boolean;
  67712. sideOrientation?: number;
  67713. frontUVs?: Vector4;
  67714. backUVs?: Vector4;
  67715. }, scene?: Nullable<Scene>): Mesh;
  67716. /**
  67717. * Creates a decal mesh.
  67718. * 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
  67719. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67720. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67721. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67722. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67723. * @param name defines the name of the mesh
  67724. * @param sourceMesh defines the mesh where the decal must be applied
  67725. * @param options defines the options used to create the mesh
  67726. * @param scene defines the hosting scene
  67727. * @returns the decal mesh
  67728. * @see https://doc.babylonjs.com/how_to/decals
  67729. */
  67730. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67731. position?: Vector3;
  67732. normal?: Vector3;
  67733. size?: Vector3;
  67734. angle?: number;
  67735. }): Mesh;
  67736. /**
  67737. * Creates a Capsule Mesh
  67738. * @param name defines the name of the mesh.
  67739. * @param options the constructors options used to shape the mesh.
  67740. * @param scene defines the scene the mesh is scoped to.
  67741. * @returns the capsule mesh
  67742. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67743. */
  67744. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67745. }
  67746. }
  67747. declare module BABYLON {
  67748. /**
  67749. * A simplifier interface for future simplification implementations
  67750. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67751. */
  67752. export interface ISimplifier {
  67753. /**
  67754. * Simplification of a given mesh according to the given settings.
  67755. * Since this requires computation, it is assumed that the function runs async.
  67756. * @param settings The settings of the simplification, including quality and distance
  67757. * @param successCallback A callback that will be called after the mesh was simplified.
  67758. * @param errorCallback in case of an error, this callback will be called. optional.
  67759. */
  67760. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67761. }
  67762. /**
  67763. * Expected simplification settings.
  67764. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67765. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67766. */
  67767. export interface ISimplificationSettings {
  67768. /**
  67769. * Gets or sets the expected quality
  67770. */
  67771. quality: number;
  67772. /**
  67773. * Gets or sets the distance when this optimized version should be used
  67774. */
  67775. distance: number;
  67776. /**
  67777. * Gets an already optimized mesh
  67778. */
  67779. optimizeMesh?: boolean;
  67780. }
  67781. /**
  67782. * Class used to specify simplification options
  67783. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67784. */
  67785. export class SimplificationSettings implements ISimplificationSettings {
  67786. /** expected quality */
  67787. quality: number;
  67788. /** distance when this optimized version should be used */
  67789. distance: number;
  67790. /** already optimized mesh */
  67791. optimizeMesh?: boolean | undefined;
  67792. /**
  67793. * Creates a SimplificationSettings
  67794. * @param quality expected quality
  67795. * @param distance distance when this optimized version should be used
  67796. * @param optimizeMesh already optimized mesh
  67797. */
  67798. constructor(
  67799. /** expected quality */
  67800. quality: number,
  67801. /** distance when this optimized version should be used */
  67802. distance: number,
  67803. /** already optimized mesh */
  67804. optimizeMesh?: boolean | undefined);
  67805. }
  67806. /**
  67807. * Interface used to define a simplification task
  67808. */
  67809. export interface ISimplificationTask {
  67810. /**
  67811. * Array of settings
  67812. */
  67813. settings: Array<ISimplificationSettings>;
  67814. /**
  67815. * Simplification type
  67816. */
  67817. simplificationType: SimplificationType;
  67818. /**
  67819. * Mesh to simplify
  67820. */
  67821. mesh: Mesh;
  67822. /**
  67823. * Callback called on success
  67824. */
  67825. successCallback?: () => void;
  67826. /**
  67827. * Defines if parallel processing can be used
  67828. */
  67829. parallelProcessing: boolean;
  67830. }
  67831. /**
  67832. * Queue used to order the simplification tasks
  67833. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67834. */
  67835. export class SimplificationQueue {
  67836. private _simplificationArray;
  67837. /**
  67838. * Gets a boolean indicating that the process is still running
  67839. */
  67840. running: boolean;
  67841. /**
  67842. * Creates a new queue
  67843. */
  67844. constructor();
  67845. /**
  67846. * Adds a new simplification task
  67847. * @param task defines a task to add
  67848. */
  67849. addTask(task: ISimplificationTask): void;
  67850. /**
  67851. * Execute next task
  67852. */
  67853. executeNext(): void;
  67854. /**
  67855. * Execute a simplification task
  67856. * @param task defines the task to run
  67857. */
  67858. runSimplification(task: ISimplificationTask): void;
  67859. private getSimplifier;
  67860. }
  67861. /**
  67862. * The implemented types of simplification
  67863. * At the moment only Quadratic Error Decimation is implemented
  67864. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67865. */
  67866. export enum SimplificationType {
  67867. /** Quadratic error decimation */
  67868. QUADRATIC = 0
  67869. }
  67870. /**
  67871. * An implementation of the Quadratic Error simplification algorithm.
  67872. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67873. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67874. * @author RaananW
  67875. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67876. */
  67877. export class QuadraticErrorSimplification implements ISimplifier {
  67878. private _mesh;
  67879. private triangles;
  67880. private vertices;
  67881. private references;
  67882. private _reconstructedMesh;
  67883. /** Gets or sets the number pf sync interations */
  67884. syncIterations: number;
  67885. /** Gets or sets the aggressiveness of the simplifier */
  67886. aggressiveness: number;
  67887. /** Gets or sets the number of allowed iterations for decimation */
  67888. decimationIterations: number;
  67889. /** Gets or sets the espilon to use for bounding box computation */
  67890. boundingBoxEpsilon: number;
  67891. /**
  67892. * Creates a new QuadraticErrorSimplification
  67893. * @param _mesh defines the target mesh
  67894. */
  67895. constructor(_mesh: Mesh);
  67896. /**
  67897. * Simplification of a given mesh according to the given settings.
  67898. * Since this requires computation, it is assumed that the function runs async.
  67899. * @param settings The settings of the simplification, including quality and distance
  67900. * @param successCallback A callback that will be called after the mesh was simplified.
  67901. */
  67902. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67903. private runDecimation;
  67904. private initWithMesh;
  67905. private init;
  67906. private reconstructMesh;
  67907. private initDecimatedMesh;
  67908. private isFlipped;
  67909. private updateTriangles;
  67910. private identifyBorder;
  67911. private updateMesh;
  67912. private vertexError;
  67913. private calculateError;
  67914. }
  67915. }
  67916. declare module BABYLON {
  67917. interface Scene {
  67918. /** @hidden (Backing field) */
  67919. _simplificationQueue: SimplificationQueue;
  67920. /**
  67921. * Gets or sets the simplification queue attached to the scene
  67922. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67923. */
  67924. simplificationQueue: SimplificationQueue;
  67925. }
  67926. interface Mesh {
  67927. /**
  67928. * Simplify the mesh according to the given array of settings.
  67929. * Function will return immediately and will simplify async
  67930. * @param settings a collection of simplification settings
  67931. * @param parallelProcessing should all levels calculate parallel or one after the other
  67932. * @param simplificationType the type of simplification to run
  67933. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67934. * @returns the current mesh
  67935. */
  67936. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67937. }
  67938. /**
  67939. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67940. * created in a scene
  67941. */
  67942. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67943. /**
  67944. * The component name helpfull to identify the component in the list of scene components.
  67945. */
  67946. readonly name: string;
  67947. /**
  67948. * The scene the component belongs to.
  67949. */
  67950. scene: Scene;
  67951. /**
  67952. * Creates a new instance of the component for the given scene
  67953. * @param scene Defines the scene to register the component in
  67954. */
  67955. constructor(scene: Scene);
  67956. /**
  67957. * Registers the component in a given scene
  67958. */
  67959. register(): void;
  67960. /**
  67961. * Rebuilds the elements related to this component in case of
  67962. * context lost for instance.
  67963. */
  67964. rebuild(): void;
  67965. /**
  67966. * Disposes the component and the associated ressources
  67967. */
  67968. dispose(): void;
  67969. private _beforeCameraUpdate;
  67970. }
  67971. }
  67972. declare module BABYLON {
  67973. interface Mesh {
  67974. /**
  67975. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67976. */
  67977. thinInstanceEnablePicking: boolean;
  67978. /**
  67979. * Creates a new thin instance
  67980. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67981. * @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
  67982. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67983. */
  67984. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67985. /**
  67986. * Adds the transformation (matrix) of the current mesh as a thin instance
  67987. * @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
  67988. * @returns the thin instance index number
  67989. */
  67990. thinInstanceAddSelf(refresh: boolean): number;
  67991. /**
  67992. * Registers a custom attribute to be used with thin instances
  67993. * @param kind name of the attribute
  67994. * @param stride size in floats of the attribute
  67995. */
  67996. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67997. /**
  67998. * Sets the matrix of a thin instance
  67999. * @param index index of the thin instance
  68000. * @param matrix matrix to set
  68001. * @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
  68002. */
  68003. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68004. /**
  68005. * Sets the value of a custom attribute for a thin instance
  68006. * @param kind name of the attribute
  68007. * @param index index of the thin instance
  68008. * @param value value to set
  68009. * @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
  68010. */
  68011. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68012. /**
  68013. * 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.
  68014. */
  68015. thinInstanceCount: number;
  68016. /**
  68017. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68018. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68019. * @param buffer buffer to set
  68020. * @param stride size in floats of each value of the buffer
  68021. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68022. */
  68023. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68024. /**
  68025. * Gets the list of world matrices
  68026. * @return an array containing all the world matrices from the thin instances
  68027. */
  68028. thinInstanceGetWorldMatrices(): Matrix[];
  68029. /**
  68030. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68031. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68032. */
  68033. thinInstanceBufferUpdated(kind: string): void;
  68034. /**
  68035. * Applies a partial update to a buffer directly on the GPU
  68036. * 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
  68037. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68038. * @param data the data to set in the GPU buffer
  68039. * @param offset the offset in the GPU buffer where to update the data
  68040. */
  68041. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  68042. /**
  68043. * Refreshes the bounding info, taking into account all the thin instances defined
  68044. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68045. */
  68046. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68047. /** @hidden */
  68048. _thinInstanceInitializeUserStorage(): void;
  68049. /** @hidden */
  68050. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68051. /** @hidden */
  68052. _userThinInstanceBuffersStorage: {
  68053. data: {
  68054. [key: string]: Float32Array;
  68055. };
  68056. sizes: {
  68057. [key: string]: number;
  68058. };
  68059. vertexBuffers: {
  68060. [key: string]: Nullable<VertexBuffer>;
  68061. };
  68062. strides: {
  68063. [key: string]: number;
  68064. };
  68065. };
  68066. }
  68067. }
  68068. declare module BABYLON {
  68069. /**
  68070. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68071. */
  68072. export interface INavigationEnginePlugin {
  68073. /**
  68074. * plugin name
  68075. */
  68076. name: string;
  68077. /**
  68078. * Creates a navigation mesh
  68079. * @param meshes array of all the geometry used to compute the navigatio mesh
  68080. * @param parameters bunch of parameters used to filter geometry
  68081. */
  68082. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68083. /**
  68084. * Create a navigation mesh debug mesh
  68085. * @param scene is where the mesh will be added
  68086. * @returns debug display mesh
  68087. */
  68088. createDebugNavMesh(scene: Scene): Mesh;
  68089. /**
  68090. * Get a navigation mesh constrained position, closest to the parameter position
  68091. * @param position world position
  68092. * @returns the closest point to position constrained by the navigation mesh
  68093. */
  68094. getClosestPoint(position: Vector3): Vector3;
  68095. /**
  68096. * Get a navigation mesh constrained position, closest to the parameter position
  68097. * @param position world position
  68098. * @param result output the closest point to position constrained by the navigation mesh
  68099. */
  68100. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68101. /**
  68102. * Get a navigation mesh constrained position, within a particular radius
  68103. * @param position world position
  68104. * @param maxRadius the maximum distance to the constrained world position
  68105. * @returns the closest point to position constrained by the navigation mesh
  68106. */
  68107. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68108. /**
  68109. * Get a navigation mesh constrained position, within a particular radius
  68110. * @param position world position
  68111. * @param maxRadius the maximum distance to the constrained world position
  68112. * @param result output the closest point to position constrained by the navigation mesh
  68113. */
  68114. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68115. /**
  68116. * Compute the final position from a segment made of destination-position
  68117. * @param position world position
  68118. * @param destination world position
  68119. * @returns the resulting point along the navmesh
  68120. */
  68121. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68122. /**
  68123. * Compute the final position from a segment made of destination-position
  68124. * @param position world position
  68125. * @param destination world position
  68126. * @param result output the resulting point along the navmesh
  68127. */
  68128. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68129. /**
  68130. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68131. * @param start world position
  68132. * @param end world position
  68133. * @returns array containing world position composing the path
  68134. */
  68135. computePath(start: Vector3, end: Vector3): Vector3[];
  68136. /**
  68137. * If this plugin is supported
  68138. * @returns true if plugin is supported
  68139. */
  68140. isSupported(): boolean;
  68141. /**
  68142. * Create a new Crowd so you can add agents
  68143. * @param maxAgents the maximum agent count in the crowd
  68144. * @param maxAgentRadius the maximum radius an agent can have
  68145. * @param scene to attach the crowd to
  68146. * @returns the crowd you can add agents to
  68147. */
  68148. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68149. /**
  68150. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68151. * The queries will try to find a solution within those bounds
  68152. * default is (1,1,1)
  68153. * @param extent x,y,z value that define the extent around the queries point of reference
  68154. */
  68155. setDefaultQueryExtent(extent: Vector3): void;
  68156. /**
  68157. * Get the Bounding box extent specified by setDefaultQueryExtent
  68158. * @returns the box extent values
  68159. */
  68160. getDefaultQueryExtent(): Vector3;
  68161. /**
  68162. * build the navmesh from a previously saved state using getNavmeshData
  68163. * @param data the Uint8Array returned by getNavmeshData
  68164. */
  68165. buildFromNavmeshData(data: Uint8Array): void;
  68166. /**
  68167. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68168. * @returns data the Uint8Array that can be saved and reused
  68169. */
  68170. getNavmeshData(): Uint8Array;
  68171. /**
  68172. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68173. * @param result output the box extent values
  68174. */
  68175. getDefaultQueryExtentToRef(result: Vector3): void;
  68176. /**
  68177. * Release all resources
  68178. */
  68179. dispose(): void;
  68180. }
  68181. /**
  68182. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68183. */
  68184. export interface ICrowd {
  68185. /**
  68186. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68187. * You can attach anything to that node. The node position is updated in the scene update tick.
  68188. * @param pos world position that will be constrained by the navigation mesh
  68189. * @param parameters agent parameters
  68190. * @param transform hooked to the agent that will be update by the scene
  68191. * @returns agent index
  68192. */
  68193. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68194. /**
  68195. * Returns the agent position in world space
  68196. * @param index agent index returned by addAgent
  68197. * @returns world space position
  68198. */
  68199. getAgentPosition(index: number): Vector3;
  68200. /**
  68201. * Gets the agent position result in world space
  68202. * @param index agent index returned by addAgent
  68203. * @param result output world space position
  68204. */
  68205. getAgentPositionToRef(index: number, result: Vector3): void;
  68206. /**
  68207. * Gets the agent velocity in world space
  68208. * @param index agent index returned by addAgent
  68209. * @returns world space velocity
  68210. */
  68211. getAgentVelocity(index: number): Vector3;
  68212. /**
  68213. * Gets the agent velocity result in world space
  68214. * @param index agent index returned by addAgent
  68215. * @param result output world space velocity
  68216. */
  68217. getAgentVelocityToRef(index: number, result: Vector3): void;
  68218. /**
  68219. * Gets the agent next target point on the path
  68220. * @param index agent index returned by addAgent
  68221. * @returns world space position
  68222. */
  68223. getAgentNextTargetPath(index: number): Vector3;
  68224. /**
  68225. * Gets the agent state
  68226. * @param index agent index returned by addAgent
  68227. * @returns agent state
  68228. */
  68229. getAgentState(index: number): number;
  68230. /**
  68231. * returns true if the agent in over an off mesh link connection
  68232. * @param index agent index returned by addAgent
  68233. * @returns true if over an off mesh link connection
  68234. */
  68235. overOffmeshConnection(index: number): boolean;
  68236. /**
  68237. * Gets the agent next target point on the path
  68238. * @param index agent index returned by addAgent
  68239. * @param result output world space position
  68240. */
  68241. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68242. /**
  68243. * remove a particular agent previously created
  68244. * @param index agent index returned by addAgent
  68245. */
  68246. removeAgent(index: number): void;
  68247. /**
  68248. * get the list of all agents attached to this crowd
  68249. * @returns list of agent indices
  68250. */
  68251. getAgents(): number[];
  68252. /**
  68253. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68254. * @param deltaTime in seconds
  68255. */
  68256. update(deltaTime: number): void;
  68257. /**
  68258. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68259. * @param index agent index returned by addAgent
  68260. * @param destination targeted world position
  68261. */
  68262. agentGoto(index: number, destination: Vector3): void;
  68263. /**
  68264. * Teleport the agent to a new position
  68265. * @param index agent index returned by addAgent
  68266. * @param destination targeted world position
  68267. */
  68268. agentTeleport(index: number, destination: Vector3): void;
  68269. /**
  68270. * Update agent parameters
  68271. * @param index agent index returned by addAgent
  68272. * @param parameters agent parameters
  68273. */
  68274. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68275. /**
  68276. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68277. * The queries will try to find a solution within those bounds
  68278. * default is (1,1,1)
  68279. * @param extent x,y,z value that define the extent around the queries point of reference
  68280. */
  68281. setDefaultQueryExtent(extent: Vector3): void;
  68282. /**
  68283. * Get the Bounding box extent specified by setDefaultQueryExtent
  68284. * @returns the box extent values
  68285. */
  68286. getDefaultQueryExtent(): Vector3;
  68287. /**
  68288. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68289. * @param result output the box extent values
  68290. */
  68291. getDefaultQueryExtentToRef(result: Vector3): void;
  68292. /**
  68293. * Release all resources
  68294. */
  68295. dispose(): void;
  68296. }
  68297. /**
  68298. * Configures an agent
  68299. */
  68300. export interface IAgentParameters {
  68301. /**
  68302. * Agent radius. [Limit: >= 0]
  68303. */
  68304. radius: number;
  68305. /**
  68306. * Agent height. [Limit: > 0]
  68307. */
  68308. height: number;
  68309. /**
  68310. * Maximum allowed acceleration. [Limit: >= 0]
  68311. */
  68312. maxAcceleration: number;
  68313. /**
  68314. * Maximum allowed speed. [Limit: >= 0]
  68315. */
  68316. maxSpeed: number;
  68317. /**
  68318. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68319. */
  68320. collisionQueryRange: number;
  68321. /**
  68322. * The path visibility optimization range. [Limit: > 0]
  68323. */
  68324. pathOptimizationRange: number;
  68325. /**
  68326. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68327. */
  68328. separationWeight: number;
  68329. }
  68330. /**
  68331. * Configures the navigation mesh creation
  68332. */
  68333. export interface INavMeshParameters {
  68334. /**
  68335. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68336. */
  68337. cs: number;
  68338. /**
  68339. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68340. */
  68341. ch: number;
  68342. /**
  68343. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68344. */
  68345. walkableSlopeAngle: number;
  68346. /**
  68347. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68348. * be considered walkable. [Limit: >= 3] [Units: vx]
  68349. */
  68350. walkableHeight: number;
  68351. /**
  68352. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68353. */
  68354. walkableClimb: number;
  68355. /**
  68356. * The distance to erode/shrink the walkable area of the heightfield away from
  68357. * obstructions. [Limit: >=0] [Units: vx]
  68358. */
  68359. walkableRadius: number;
  68360. /**
  68361. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68362. */
  68363. maxEdgeLen: number;
  68364. /**
  68365. * The maximum distance a simplfied contour's border edges should deviate
  68366. * the original raw contour. [Limit: >=0] [Units: vx]
  68367. */
  68368. maxSimplificationError: number;
  68369. /**
  68370. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68371. */
  68372. minRegionArea: number;
  68373. /**
  68374. * Any regions with a span count smaller than this value will, if possible,
  68375. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68376. */
  68377. mergeRegionArea: number;
  68378. /**
  68379. * The maximum number of vertices allowed for polygons generated during the
  68380. * contour to polygon conversion process. [Limit: >= 3]
  68381. */
  68382. maxVertsPerPoly: number;
  68383. /**
  68384. * Sets the sampling distance to use when generating the detail mesh.
  68385. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68386. */
  68387. detailSampleDist: number;
  68388. /**
  68389. * The maximum distance the detail mesh surface should deviate from heightfield
  68390. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68391. */
  68392. detailSampleMaxError: number;
  68393. }
  68394. }
  68395. declare module BABYLON {
  68396. /**
  68397. * RecastJS navigation plugin
  68398. */
  68399. export class RecastJSPlugin implements INavigationEnginePlugin {
  68400. /**
  68401. * Reference to the Recast library
  68402. */
  68403. bjsRECAST: any;
  68404. /**
  68405. * plugin name
  68406. */
  68407. name: string;
  68408. /**
  68409. * the first navmesh created. We might extend this to support multiple navmeshes
  68410. */
  68411. navMesh: any;
  68412. /**
  68413. * Initializes the recastJS plugin
  68414. * @param recastInjection can be used to inject your own recast reference
  68415. */
  68416. constructor(recastInjection?: any);
  68417. /**
  68418. * Creates a navigation mesh
  68419. * @param meshes array of all the geometry used to compute the navigatio mesh
  68420. * @param parameters bunch of parameters used to filter geometry
  68421. */
  68422. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68423. /**
  68424. * Create a navigation mesh debug mesh
  68425. * @param scene is where the mesh will be added
  68426. * @returns debug display mesh
  68427. */
  68428. createDebugNavMesh(scene: Scene): Mesh;
  68429. /**
  68430. * Get a navigation mesh constrained position, closest to the parameter position
  68431. * @param position world position
  68432. * @returns the closest point to position constrained by the navigation mesh
  68433. */
  68434. getClosestPoint(position: Vector3): Vector3;
  68435. /**
  68436. * Get a navigation mesh constrained position, closest to the parameter position
  68437. * @param position world position
  68438. * @param result output the closest point to position constrained by the navigation mesh
  68439. */
  68440. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68441. /**
  68442. * Get a navigation mesh constrained position, within a particular radius
  68443. * @param position world position
  68444. * @param maxRadius the maximum distance to the constrained world position
  68445. * @returns the closest point to position constrained by the navigation mesh
  68446. */
  68447. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68448. /**
  68449. * Get a navigation mesh constrained position, within a particular radius
  68450. * @param position world position
  68451. * @param maxRadius the maximum distance to the constrained world position
  68452. * @param result output the closest point to position constrained by the navigation mesh
  68453. */
  68454. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68455. /**
  68456. * Compute the final position from a segment made of destination-position
  68457. * @param position world position
  68458. * @param destination world position
  68459. * @returns the resulting point along the navmesh
  68460. */
  68461. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68462. /**
  68463. * Compute the final position from a segment made of destination-position
  68464. * @param position world position
  68465. * @param destination world position
  68466. * @param result output the resulting point along the navmesh
  68467. */
  68468. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68469. /**
  68470. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68471. * @param start world position
  68472. * @param end world position
  68473. * @returns array containing world position composing the path
  68474. */
  68475. computePath(start: Vector3, end: Vector3): Vector3[];
  68476. /**
  68477. * Create a new Crowd so you can add agents
  68478. * @param maxAgents the maximum agent count in the crowd
  68479. * @param maxAgentRadius the maximum radius an agent can have
  68480. * @param scene to attach the crowd to
  68481. * @returns the crowd you can add agents to
  68482. */
  68483. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68484. /**
  68485. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68486. * The queries will try to find a solution within those bounds
  68487. * default is (1,1,1)
  68488. * @param extent x,y,z value that define the extent around the queries point of reference
  68489. */
  68490. setDefaultQueryExtent(extent: Vector3): void;
  68491. /**
  68492. * Get the Bounding box extent specified by setDefaultQueryExtent
  68493. * @returns the box extent values
  68494. */
  68495. getDefaultQueryExtent(): Vector3;
  68496. /**
  68497. * build the navmesh from a previously saved state using getNavmeshData
  68498. * @param data the Uint8Array returned by getNavmeshData
  68499. */
  68500. buildFromNavmeshData(data: Uint8Array): void;
  68501. /**
  68502. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68503. * @returns data the Uint8Array that can be saved and reused
  68504. */
  68505. getNavmeshData(): Uint8Array;
  68506. /**
  68507. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68508. * @param result output the box extent values
  68509. */
  68510. getDefaultQueryExtentToRef(result: Vector3): void;
  68511. /**
  68512. * Disposes
  68513. */
  68514. dispose(): void;
  68515. /**
  68516. * If this plugin is supported
  68517. * @returns true if plugin is supported
  68518. */
  68519. isSupported(): boolean;
  68520. }
  68521. /**
  68522. * Recast detour crowd implementation
  68523. */
  68524. export class RecastJSCrowd implements ICrowd {
  68525. /**
  68526. * Recast/detour plugin
  68527. */
  68528. bjsRECASTPlugin: RecastJSPlugin;
  68529. /**
  68530. * Link to the detour crowd
  68531. */
  68532. recastCrowd: any;
  68533. /**
  68534. * One transform per agent
  68535. */
  68536. transforms: TransformNode[];
  68537. /**
  68538. * All agents created
  68539. */
  68540. agents: number[];
  68541. /**
  68542. * Link to the scene is kept to unregister the crowd from the scene
  68543. */
  68544. private _scene;
  68545. /**
  68546. * Observer for crowd updates
  68547. */
  68548. private _onBeforeAnimationsObserver;
  68549. /**
  68550. * Constructor
  68551. * @param plugin recastJS plugin
  68552. * @param maxAgents the maximum agent count in the crowd
  68553. * @param maxAgentRadius the maximum radius an agent can have
  68554. * @param scene to attach the crowd to
  68555. * @returns the crowd you can add agents to
  68556. */
  68557. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68558. /**
  68559. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68560. * You can attach anything to that node. The node position is updated in the scene update tick.
  68561. * @param pos world position that will be constrained by the navigation mesh
  68562. * @param parameters agent parameters
  68563. * @param transform hooked to the agent that will be update by the scene
  68564. * @returns agent index
  68565. */
  68566. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68567. /**
  68568. * Returns the agent position in world space
  68569. * @param index agent index returned by addAgent
  68570. * @returns world space position
  68571. */
  68572. getAgentPosition(index: number): Vector3;
  68573. /**
  68574. * Returns the agent position result in world space
  68575. * @param index agent index returned by addAgent
  68576. * @param result output world space position
  68577. */
  68578. getAgentPositionToRef(index: number, result: Vector3): void;
  68579. /**
  68580. * Returns the agent velocity in world space
  68581. * @param index agent index returned by addAgent
  68582. * @returns world space velocity
  68583. */
  68584. getAgentVelocity(index: number): Vector3;
  68585. /**
  68586. * Returns the agent velocity result in world space
  68587. * @param index agent index returned by addAgent
  68588. * @param result output world space velocity
  68589. */
  68590. getAgentVelocityToRef(index: number, result: Vector3): void;
  68591. /**
  68592. * Returns the agent next target point on the path
  68593. * @param index agent index returned by addAgent
  68594. * @returns world space position
  68595. */
  68596. getAgentNextTargetPath(index: number): Vector3;
  68597. /**
  68598. * Returns the agent next target point on the path
  68599. * @param index agent index returned by addAgent
  68600. * @param result output world space position
  68601. */
  68602. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68603. /**
  68604. * Gets the agent state
  68605. * @param index agent index returned by addAgent
  68606. * @returns agent state
  68607. */
  68608. getAgentState(index: number): number;
  68609. /**
  68610. * returns true if the agent in over an off mesh link connection
  68611. * @param index agent index returned by addAgent
  68612. * @returns true if over an off mesh link connection
  68613. */
  68614. overOffmeshConnection(index: number): boolean;
  68615. /**
  68616. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68617. * @param index agent index returned by addAgent
  68618. * @param destination targeted world position
  68619. */
  68620. agentGoto(index: number, destination: Vector3): void;
  68621. /**
  68622. * Teleport the agent to a new position
  68623. * @param index agent index returned by addAgent
  68624. * @param destination targeted world position
  68625. */
  68626. agentTeleport(index: number, destination: Vector3): void;
  68627. /**
  68628. * Update agent parameters
  68629. * @param index agent index returned by addAgent
  68630. * @param parameters agent parameters
  68631. */
  68632. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68633. /**
  68634. * remove a particular agent previously created
  68635. * @param index agent index returned by addAgent
  68636. */
  68637. removeAgent(index: number): void;
  68638. /**
  68639. * get the list of all agents attached to this crowd
  68640. * @returns list of agent indices
  68641. */
  68642. getAgents(): number[];
  68643. /**
  68644. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68645. * @param deltaTime in seconds
  68646. */
  68647. update(deltaTime: number): void;
  68648. /**
  68649. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68650. * The queries will try to find a solution within those bounds
  68651. * default is (1,1,1)
  68652. * @param extent x,y,z value that define the extent around the queries point of reference
  68653. */
  68654. setDefaultQueryExtent(extent: Vector3): void;
  68655. /**
  68656. * Get the Bounding box extent specified by setDefaultQueryExtent
  68657. * @returns the box extent values
  68658. */
  68659. getDefaultQueryExtent(): Vector3;
  68660. /**
  68661. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68662. * @param result output the box extent values
  68663. */
  68664. getDefaultQueryExtentToRef(result: Vector3): void;
  68665. /**
  68666. * Release all resources
  68667. */
  68668. dispose(): void;
  68669. }
  68670. }
  68671. declare module BABYLON {
  68672. /**
  68673. * Class used to enable access to IndexedDB
  68674. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68675. */
  68676. export class Database implements IOfflineProvider {
  68677. private _callbackManifestChecked;
  68678. private _currentSceneUrl;
  68679. private _db;
  68680. private _enableSceneOffline;
  68681. private _enableTexturesOffline;
  68682. private _manifestVersionFound;
  68683. private _mustUpdateRessources;
  68684. private _hasReachedQuota;
  68685. private _isSupported;
  68686. private _idbFactory;
  68687. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68688. private static IsUASupportingBlobStorage;
  68689. /**
  68690. * Gets a boolean indicating if Database storate is enabled (off by default)
  68691. */
  68692. static IDBStorageEnabled: boolean;
  68693. /**
  68694. * Gets a boolean indicating if scene must be saved in the database
  68695. */
  68696. get enableSceneOffline(): boolean;
  68697. /**
  68698. * Gets a boolean indicating if textures must be saved in the database
  68699. */
  68700. get enableTexturesOffline(): boolean;
  68701. /**
  68702. * Creates a new Database
  68703. * @param urlToScene defines the url to load the scene
  68704. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68705. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68706. */
  68707. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68708. private static _ParseURL;
  68709. private static _ReturnFullUrlLocation;
  68710. private _checkManifestFile;
  68711. /**
  68712. * Open the database and make it available
  68713. * @param successCallback defines the callback to call on success
  68714. * @param errorCallback defines the callback to call on error
  68715. */
  68716. open(successCallback: () => void, errorCallback: () => void): void;
  68717. /**
  68718. * Loads an image from the database
  68719. * @param url defines the url to load from
  68720. * @param image defines the target DOM image
  68721. */
  68722. loadImage(url: string, image: HTMLImageElement): void;
  68723. private _loadImageFromDBAsync;
  68724. private _saveImageIntoDBAsync;
  68725. private _checkVersionFromDB;
  68726. private _loadVersionFromDBAsync;
  68727. private _saveVersionIntoDBAsync;
  68728. /**
  68729. * Loads a file from database
  68730. * @param url defines the URL to load from
  68731. * @param sceneLoaded defines a callback to call on success
  68732. * @param progressCallBack defines a callback to call when progress changed
  68733. * @param errorCallback defines a callback to call on error
  68734. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68735. */
  68736. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68737. private _loadFileAsync;
  68738. private _saveFileAsync;
  68739. /**
  68740. * Validates if xhr data is correct
  68741. * @param xhr defines the request to validate
  68742. * @param dataType defines the expected data type
  68743. * @returns true if data is correct
  68744. */
  68745. private static _ValidateXHRData;
  68746. }
  68747. }
  68748. declare module BABYLON {
  68749. /** @hidden */
  68750. export var gpuUpdateParticlesPixelShader: {
  68751. name: string;
  68752. shader: string;
  68753. };
  68754. }
  68755. declare module BABYLON {
  68756. /** @hidden */
  68757. export var gpuUpdateParticlesVertexShader: {
  68758. name: string;
  68759. shader: string;
  68760. };
  68761. }
  68762. declare module BABYLON {
  68763. /** @hidden */
  68764. export var clipPlaneFragmentDeclaration2: {
  68765. name: string;
  68766. shader: string;
  68767. };
  68768. }
  68769. declare module BABYLON {
  68770. /** @hidden */
  68771. export var gpuRenderParticlesPixelShader: {
  68772. name: string;
  68773. shader: string;
  68774. };
  68775. }
  68776. declare module BABYLON {
  68777. /** @hidden */
  68778. export var clipPlaneVertexDeclaration2: {
  68779. name: string;
  68780. shader: string;
  68781. };
  68782. }
  68783. declare module BABYLON {
  68784. /** @hidden */
  68785. export var gpuRenderParticlesVertexShader: {
  68786. name: string;
  68787. shader: string;
  68788. };
  68789. }
  68790. declare module BABYLON {
  68791. /**
  68792. * This represents a GPU particle system in Babylon
  68793. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68794. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68795. */
  68796. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68797. /**
  68798. * The layer mask we are rendering the particles through.
  68799. */
  68800. layerMask: number;
  68801. private _capacity;
  68802. private _activeCount;
  68803. private _currentActiveCount;
  68804. private _accumulatedCount;
  68805. private _renderEffect;
  68806. private _updateEffect;
  68807. private _buffer0;
  68808. private _buffer1;
  68809. private _spriteBuffer;
  68810. private _updateVAO;
  68811. private _renderVAO;
  68812. private _targetIndex;
  68813. private _sourceBuffer;
  68814. private _targetBuffer;
  68815. private _currentRenderId;
  68816. private _started;
  68817. private _stopped;
  68818. private _timeDelta;
  68819. private _randomTexture;
  68820. private _randomTexture2;
  68821. private _attributesStrideSize;
  68822. private _updateEffectOptions;
  68823. private _randomTextureSize;
  68824. private _actualFrame;
  68825. private _customEffect;
  68826. private readonly _rawTextureWidth;
  68827. /**
  68828. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68829. */
  68830. static get IsSupported(): boolean;
  68831. /**
  68832. * An event triggered when the system is disposed.
  68833. */
  68834. onDisposeObservable: Observable<IParticleSystem>;
  68835. /**
  68836. * An event triggered when the system is stopped
  68837. */
  68838. onStoppedObservable: Observable<IParticleSystem>;
  68839. /**
  68840. * Gets the maximum number of particles active at the same time.
  68841. * @returns The max number of active particles.
  68842. */
  68843. getCapacity(): number;
  68844. /**
  68845. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68846. * to override the particles.
  68847. */
  68848. forceDepthWrite: boolean;
  68849. /**
  68850. * Gets or set the number of active particles
  68851. */
  68852. get activeParticleCount(): number;
  68853. set activeParticleCount(value: number);
  68854. private _preWarmDone;
  68855. /**
  68856. * Specifies if the particles are updated in emitter local space or world space.
  68857. */
  68858. isLocal: boolean;
  68859. /** Gets or sets a matrix to use to compute projection */
  68860. defaultProjectionMatrix: Matrix;
  68861. /**
  68862. * Is this system ready to be used/rendered
  68863. * @return true if the system is ready
  68864. */
  68865. isReady(): boolean;
  68866. /**
  68867. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68868. * @returns True if it has been started, otherwise false.
  68869. */
  68870. isStarted(): boolean;
  68871. /**
  68872. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68873. * @returns True if it has been stopped, otherwise false.
  68874. */
  68875. isStopped(): boolean;
  68876. /**
  68877. * Gets a boolean indicating that the system is stopping
  68878. * @returns true if the system is currently stopping
  68879. */
  68880. isStopping(): boolean;
  68881. /**
  68882. * Gets the number of particles active at the same time.
  68883. * @returns The number of active particles.
  68884. */
  68885. getActiveCount(): number;
  68886. /**
  68887. * Starts the particle system and begins to emit
  68888. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68889. */
  68890. start(delay?: number): void;
  68891. /**
  68892. * Stops the particle system.
  68893. */
  68894. stop(): void;
  68895. /**
  68896. * Remove all active particles
  68897. */
  68898. reset(): void;
  68899. /**
  68900. * Returns the string "GPUParticleSystem"
  68901. * @returns a string containing the class name
  68902. */
  68903. getClassName(): string;
  68904. /**
  68905. * Gets the custom effect used to render the particles
  68906. * @param blendMode Blend mode for which the effect should be retrieved
  68907. * @returns The effect
  68908. */
  68909. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68910. /**
  68911. * Sets the custom effect used to render the particles
  68912. * @param effect The effect to set
  68913. * @param blendMode Blend mode for which the effect should be set
  68914. */
  68915. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68916. /** @hidden */
  68917. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68918. /**
  68919. * Observable that will be called just before the particles are drawn
  68920. */
  68921. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68922. /**
  68923. * Gets the name of the particle vertex shader
  68924. */
  68925. get vertexShaderName(): string;
  68926. private _colorGradientsTexture;
  68927. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68928. /**
  68929. * Adds a new color gradient
  68930. * @param gradient defines the gradient to use (between 0 and 1)
  68931. * @param color1 defines the color to affect to the specified gradient
  68932. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68933. * @returns the current particle system
  68934. */
  68935. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68936. private _refreshColorGradient;
  68937. /** Force the system to rebuild all gradients that need to be resync */
  68938. forceRefreshGradients(): void;
  68939. /**
  68940. * Remove a specific color gradient
  68941. * @param gradient defines the gradient to remove
  68942. * @returns the current particle system
  68943. */
  68944. removeColorGradient(gradient: number): GPUParticleSystem;
  68945. private _angularSpeedGradientsTexture;
  68946. private _sizeGradientsTexture;
  68947. private _velocityGradientsTexture;
  68948. private _limitVelocityGradientsTexture;
  68949. private _dragGradientsTexture;
  68950. private _addFactorGradient;
  68951. /**
  68952. * Adds a new size gradient
  68953. * @param gradient defines the gradient to use (between 0 and 1)
  68954. * @param factor defines the size factor to affect to the specified gradient
  68955. * @returns the current particle system
  68956. */
  68957. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68958. /**
  68959. * Remove a specific size gradient
  68960. * @param gradient defines the gradient to remove
  68961. * @returns the current particle system
  68962. */
  68963. removeSizeGradient(gradient: number): GPUParticleSystem;
  68964. private _refreshFactorGradient;
  68965. /**
  68966. * Adds a new angular speed gradient
  68967. * @param gradient defines the gradient to use (between 0 and 1)
  68968. * @param factor defines the angular speed to affect to the specified gradient
  68969. * @returns the current particle system
  68970. */
  68971. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68972. /**
  68973. * Remove a specific angular speed gradient
  68974. * @param gradient defines the gradient to remove
  68975. * @returns the current particle system
  68976. */
  68977. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68978. /**
  68979. * Adds a new velocity gradient
  68980. * @param gradient defines the gradient to use (between 0 and 1)
  68981. * @param factor defines the velocity to affect to the specified gradient
  68982. * @returns the current particle system
  68983. */
  68984. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68985. /**
  68986. * Remove a specific velocity gradient
  68987. * @param gradient defines the gradient to remove
  68988. * @returns the current particle system
  68989. */
  68990. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68991. /**
  68992. * Adds a new limit velocity gradient
  68993. * @param gradient defines the gradient to use (between 0 and 1)
  68994. * @param factor defines the limit velocity value to affect to the specified gradient
  68995. * @returns the current particle system
  68996. */
  68997. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68998. /**
  68999. * Remove a specific limit velocity gradient
  69000. * @param gradient defines the gradient to remove
  69001. * @returns the current particle system
  69002. */
  69003. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69004. /**
  69005. * Adds a new drag gradient
  69006. * @param gradient defines the gradient to use (between 0 and 1)
  69007. * @param factor defines the drag value to affect to the specified gradient
  69008. * @returns the current particle system
  69009. */
  69010. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69011. /**
  69012. * Remove a specific drag gradient
  69013. * @param gradient defines the gradient to remove
  69014. * @returns the current particle system
  69015. */
  69016. removeDragGradient(gradient: number): GPUParticleSystem;
  69017. /**
  69018. * Not supported by GPUParticleSystem
  69019. * @param gradient defines the gradient to use (between 0 and 1)
  69020. * @param factor defines the emit rate value to affect to the specified gradient
  69021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69022. * @returns the current particle system
  69023. */
  69024. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69025. /**
  69026. * Not supported by GPUParticleSystem
  69027. * @param gradient defines the gradient to remove
  69028. * @returns the current particle system
  69029. */
  69030. removeEmitRateGradient(gradient: number): IParticleSystem;
  69031. /**
  69032. * Not supported by GPUParticleSystem
  69033. * @param gradient defines the gradient to use (between 0 and 1)
  69034. * @param factor defines the start size value to affect to the specified gradient
  69035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69036. * @returns the current particle system
  69037. */
  69038. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69039. /**
  69040. * Not supported by GPUParticleSystem
  69041. * @param gradient defines the gradient to remove
  69042. * @returns the current particle system
  69043. */
  69044. removeStartSizeGradient(gradient: number): IParticleSystem;
  69045. /**
  69046. * Not supported by GPUParticleSystem
  69047. * @param gradient defines the gradient to use (between 0 and 1)
  69048. * @param min defines the color remap minimal range
  69049. * @param max defines the color remap maximal range
  69050. * @returns the current particle system
  69051. */
  69052. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69053. /**
  69054. * Not supported by GPUParticleSystem
  69055. * @param gradient defines the gradient to remove
  69056. * @returns the current particle system
  69057. */
  69058. removeColorRemapGradient(): IParticleSystem;
  69059. /**
  69060. * Not supported by GPUParticleSystem
  69061. * @param gradient defines the gradient to use (between 0 and 1)
  69062. * @param min defines the alpha remap minimal range
  69063. * @param max defines the alpha remap maximal range
  69064. * @returns the current particle system
  69065. */
  69066. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69067. /**
  69068. * Not supported by GPUParticleSystem
  69069. * @param gradient defines the gradient to remove
  69070. * @returns the current particle system
  69071. */
  69072. removeAlphaRemapGradient(): IParticleSystem;
  69073. /**
  69074. * Not supported by GPUParticleSystem
  69075. * @param gradient defines the gradient to use (between 0 and 1)
  69076. * @param color defines the color to affect to the specified gradient
  69077. * @returns the current particle system
  69078. */
  69079. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69080. /**
  69081. * Not supported by GPUParticleSystem
  69082. * @param gradient defines the gradient to remove
  69083. * @returns the current particle system
  69084. */
  69085. removeRampGradient(): IParticleSystem;
  69086. /**
  69087. * Not supported by GPUParticleSystem
  69088. * @returns the list of ramp gradients
  69089. */
  69090. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69091. /**
  69092. * Not supported by GPUParticleSystem
  69093. * Gets or sets a boolean indicating that ramp gradients must be used
  69094. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69095. */
  69096. get useRampGradients(): boolean;
  69097. set useRampGradients(value: boolean);
  69098. /**
  69099. * Not supported by GPUParticleSystem
  69100. * @param gradient defines the gradient to use (between 0 and 1)
  69101. * @param factor defines the life time factor to affect to the specified gradient
  69102. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69103. * @returns the current particle system
  69104. */
  69105. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69106. /**
  69107. * Not supported by GPUParticleSystem
  69108. * @param gradient defines the gradient to remove
  69109. * @returns the current particle system
  69110. */
  69111. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69112. /**
  69113. * Instantiates a GPU particle system.
  69114. * 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.
  69115. * @param name The name of the particle system
  69116. * @param options The options used to create the system
  69117. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  69118. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69119. * @param customEffect a custom effect used to change the way particles are rendered by default
  69120. */
  69121. constructor(name: string, options: Partial<{
  69122. capacity: number;
  69123. randomTextureSize: number;
  69124. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69125. protected _reset(): void;
  69126. private _createUpdateVAO;
  69127. private _createRenderVAO;
  69128. private _initialize;
  69129. /** @hidden */
  69130. _recreateUpdateEffect(): void;
  69131. private _getEffect;
  69132. /**
  69133. * Fill the defines array according to the current settings of the particle system
  69134. * @param defines Array to be updated
  69135. * @param blendMode blend mode to take into account when updating the array
  69136. */
  69137. fillDefines(defines: Array<string>, blendMode?: number): void;
  69138. /**
  69139. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69140. * @param uniforms Uniforms array to fill
  69141. * @param attributes Attributes array to fill
  69142. * @param samplers Samplers array to fill
  69143. */
  69144. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69145. /** @hidden */
  69146. _recreateRenderEffect(): Effect;
  69147. /**
  69148. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69149. * @param preWarm defines if we are in the pre-warmimg phase
  69150. */
  69151. animate(preWarm?: boolean): void;
  69152. private _createFactorGradientTexture;
  69153. private _createSizeGradientTexture;
  69154. private _createAngularSpeedGradientTexture;
  69155. private _createVelocityGradientTexture;
  69156. private _createLimitVelocityGradientTexture;
  69157. private _createDragGradientTexture;
  69158. private _createColorGradientTexture;
  69159. /**
  69160. * Renders the particle system in its current state
  69161. * @param preWarm defines if the system should only update the particles but not render them
  69162. * @returns the current number of particles
  69163. */
  69164. render(preWarm?: boolean): number;
  69165. /**
  69166. * Rebuilds the particle system
  69167. */
  69168. rebuild(): void;
  69169. private _releaseBuffers;
  69170. private _releaseVAOs;
  69171. /**
  69172. * Disposes the particle system and free the associated resources
  69173. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69174. */
  69175. dispose(disposeTexture?: boolean): void;
  69176. /**
  69177. * Clones the particle system.
  69178. * @param name The name of the cloned object
  69179. * @param newEmitter The new emitter to use
  69180. * @returns the cloned particle system
  69181. */
  69182. clone(name: string, newEmitter: any): GPUParticleSystem;
  69183. /**
  69184. * Serializes the particle system to a JSON object
  69185. * @param serializeTexture defines if the texture must be serialized as well
  69186. * @returns the JSON object
  69187. */
  69188. serialize(serializeTexture?: boolean): any;
  69189. /**
  69190. * Parses a JSON object to create a GPU particle system.
  69191. * @param parsedParticleSystem The JSON object to parse
  69192. * @param sceneOrEngine The scene or the engine to create the particle system in
  69193. * @param rootUrl The root url to use to load external dependencies like texture
  69194. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69195. * @returns the parsed GPU particle system
  69196. */
  69197. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69198. }
  69199. }
  69200. declare module BABYLON {
  69201. /**
  69202. * Represents a set of particle systems working together to create a specific effect
  69203. */
  69204. export class ParticleSystemSet implements IDisposable {
  69205. /**
  69206. * Gets or sets base Assets URL
  69207. */
  69208. static BaseAssetsUrl: string;
  69209. private _emitterCreationOptions;
  69210. private _emitterNode;
  69211. /**
  69212. * Gets the particle system list
  69213. */
  69214. systems: IParticleSystem[];
  69215. /**
  69216. * Gets the emitter node used with this set
  69217. */
  69218. get emitterNode(): Nullable<TransformNode>;
  69219. /**
  69220. * Creates a new emitter mesh as a sphere
  69221. * @param options defines the options used to create the sphere
  69222. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69223. * @param scene defines the hosting scene
  69224. */
  69225. setEmitterAsSphere(options: {
  69226. diameter: number;
  69227. segments: number;
  69228. color: Color3;
  69229. }, renderingGroupId: number, scene: Scene): void;
  69230. /**
  69231. * Starts all particle systems of the set
  69232. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69233. */
  69234. start(emitter?: AbstractMesh): void;
  69235. /**
  69236. * Release all associated resources
  69237. */
  69238. dispose(): void;
  69239. /**
  69240. * Serialize the set into a JSON compatible object
  69241. * @param serializeTexture defines if the texture must be serialized as well
  69242. * @returns a JSON compatible representation of the set
  69243. */
  69244. serialize(serializeTexture?: boolean): any;
  69245. /**
  69246. * Parse a new ParticleSystemSet from a serialized source
  69247. * @param data defines a JSON compatible representation of the set
  69248. * @param scene defines the hosting scene
  69249. * @param gpu defines if we want GPU particles or CPU particles
  69250. * @returns a new ParticleSystemSet
  69251. */
  69252. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69253. }
  69254. }
  69255. declare module BABYLON {
  69256. /**
  69257. * This class is made for on one-liner static method to help creating particle system set.
  69258. */
  69259. export class ParticleHelper {
  69260. /**
  69261. * Gets or sets base Assets URL
  69262. */
  69263. static BaseAssetsUrl: string;
  69264. /** Define the Url to load snippets */
  69265. static SnippetUrl: string;
  69266. /**
  69267. * Create a default particle system that you can tweak
  69268. * @param emitter defines the emitter to use
  69269. * @param capacity defines the system capacity (default is 500 particles)
  69270. * @param scene defines the hosting scene
  69271. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69272. * @returns the new Particle system
  69273. */
  69274. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69275. /**
  69276. * This is the main static method (one-liner) of this helper to create different particle systems
  69277. * @param type This string represents the type to the particle system to create
  69278. * @param scene The scene where the particle system should live
  69279. * @param gpu If the system will use gpu
  69280. * @returns the ParticleSystemSet created
  69281. */
  69282. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69283. /**
  69284. * Static function used to export a particle system to a ParticleSystemSet variable.
  69285. * Please note that the emitter shape is not exported
  69286. * @param systems defines the particle systems to export
  69287. * @returns the created particle system set
  69288. */
  69289. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69290. /**
  69291. * Creates a particle system from a snippet saved in a remote file
  69292. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69293. * @param url defines the url to load from
  69294. * @param scene defines the hosting scene
  69295. * @param gpu If the system will use gpu
  69296. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69297. * @returns a promise that will resolve to the new particle system
  69298. */
  69299. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69300. /**
  69301. * Creates a particle system from a snippet saved by the particle system editor
  69302. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69303. * @param scene defines the hosting scene
  69304. * @param gpu If the system will use gpu
  69305. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69306. * @returns a promise that will resolve to the new particle system
  69307. */
  69308. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69309. }
  69310. }
  69311. declare module BABYLON {
  69312. interface Engine {
  69313. /**
  69314. * Create an effect to use with particle systems.
  69315. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69316. * the particle system for which you want to create a custom effect in the last parameter
  69317. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69318. * @param uniformsNames defines a list of attribute names
  69319. * @param samplers defines an array of string used to represent textures
  69320. * @param defines defines the string containing the defines to use to compile the shaders
  69321. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69322. * @param onCompiled defines a function to call when the effect creation is successful
  69323. * @param onError defines a function to call when the effect creation has failed
  69324. * @param particleSystem the particle system you want to create the effect for
  69325. * @returns the new Effect
  69326. */
  69327. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69328. }
  69329. interface Mesh {
  69330. /**
  69331. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69332. * @returns an array of IParticleSystem
  69333. */
  69334. getEmittedParticleSystems(): IParticleSystem[];
  69335. /**
  69336. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69337. * @returns an array of IParticleSystem
  69338. */
  69339. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69340. }
  69341. }
  69342. declare module BABYLON {
  69343. /** Defines the 4 color options */
  69344. export enum PointColor {
  69345. /** color value */
  69346. Color = 2,
  69347. /** uv value */
  69348. UV = 1,
  69349. /** random value */
  69350. Random = 0,
  69351. /** stated value */
  69352. Stated = 3
  69353. }
  69354. /**
  69355. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69356. * 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.
  69357. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69358. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69359. *
  69360. * Full documentation here : TO BE ENTERED
  69361. */
  69362. export class PointsCloudSystem implements IDisposable {
  69363. /**
  69364. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69365. * Example : var p = SPS.particles[i];
  69366. */
  69367. particles: CloudPoint[];
  69368. /**
  69369. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69370. */
  69371. nbParticles: number;
  69372. /**
  69373. * This a counter for your own usage. It's not set by any SPS functions.
  69374. */
  69375. counter: number;
  69376. /**
  69377. * The PCS name. This name is also given to the underlying mesh.
  69378. */
  69379. name: string;
  69380. /**
  69381. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69382. */
  69383. mesh: Mesh;
  69384. /**
  69385. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69386. * Please read :
  69387. */
  69388. vars: any;
  69389. /**
  69390. * @hidden
  69391. */
  69392. _size: number;
  69393. private _scene;
  69394. private _promises;
  69395. private _positions;
  69396. private _indices;
  69397. private _normals;
  69398. private _colors;
  69399. private _uvs;
  69400. private _indices32;
  69401. private _positions32;
  69402. private _colors32;
  69403. private _uvs32;
  69404. private _updatable;
  69405. private _isVisibilityBoxLocked;
  69406. private _alwaysVisible;
  69407. private _groups;
  69408. private _groupCounter;
  69409. private _computeParticleColor;
  69410. private _computeParticleTexture;
  69411. private _computeParticleRotation;
  69412. private _computeBoundingBox;
  69413. private _isReady;
  69414. /**
  69415. * Creates a PCS (Points Cloud System) object
  69416. * @param name (String) is the PCS name, this will be the underlying mesh name
  69417. * @param pointSize (number) is the size for each point
  69418. * @param scene (Scene) is the scene in which the PCS is added
  69419. * @param options defines the options of the PCS e.g.
  69420. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69421. */
  69422. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69423. updatable?: boolean;
  69424. });
  69425. /**
  69426. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69427. * If no points were added to the PCS, the returned mesh is just a single point.
  69428. * @returns a promise for the created mesh
  69429. */
  69430. buildMeshAsync(): Promise<Mesh>;
  69431. /**
  69432. * @hidden
  69433. */
  69434. private _buildMesh;
  69435. private _addParticle;
  69436. private _randomUnitVector;
  69437. private _getColorIndicesForCoord;
  69438. private _setPointsColorOrUV;
  69439. private _colorFromTexture;
  69440. private _calculateDensity;
  69441. /**
  69442. * Adds points to the PCS in random positions within a unit sphere
  69443. * @param nb (positive integer) the number of particles to be created from this model
  69444. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69445. * @returns the number of groups in the system
  69446. */
  69447. addPoints(nb: number, pointFunction?: any): number;
  69448. /**
  69449. * Adds points to the PCS from the surface of the model shape
  69450. * @param mesh is any Mesh object that will be used as a surface model for the points
  69451. * @param nb (positive integer) the number of particles to be created from this model
  69452. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69453. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69454. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69455. * @returns the number of groups in the system
  69456. */
  69457. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69458. /**
  69459. * Adds points to the PCS inside the model shape
  69460. * @param mesh is any Mesh object that will be used as a surface model for the points
  69461. * @param nb (positive integer) the number of particles to be created from this model
  69462. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69463. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69464. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69465. * @returns the number of groups in the system
  69466. */
  69467. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69468. /**
  69469. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69470. * This method calls `updateParticle()` for each particle of the SPS.
  69471. * For an animated SPS, it is usually called within the render loop.
  69472. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69473. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69474. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69475. * @returns the PCS.
  69476. */
  69477. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69478. /**
  69479. * Disposes the PCS.
  69480. */
  69481. dispose(): void;
  69482. /**
  69483. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69484. * doc :
  69485. * @returns the PCS.
  69486. */
  69487. refreshVisibleSize(): PointsCloudSystem;
  69488. /**
  69489. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69490. * @param size the size (float) of the visibility box
  69491. * note : this doesn't lock the PCS mesh bounding box.
  69492. * doc :
  69493. */
  69494. setVisibilityBox(size: number): void;
  69495. /**
  69496. * Gets whether the PCS is always visible or not
  69497. * doc :
  69498. */
  69499. get isAlwaysVisible(): boolean;
  69500. /**
  69501. * Sets the PCS as always visible or not
  69502. * doc :
  69503. */
  69504. set isAlwaysVisible(val: boolean);
  69505. /**
  69506. * Tells to `setParticles()` to compute the particle rotations or not
  69507. * Default value : false. The PCS is faster when it's set to false
  69508. * Note : particle rotations are only applied to parent particles
  69509. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69510. */
  69511. set computeParticleRotation(val: boolean);
  69512. /**
  69513. * Tells to `setParticles()` to compute the particle colors or not.
  69514. * Default value : true. The PCS is faster when it's set to false.
  69515. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69516. */
  69517. set computeParticleColor(val: boolean);
  69518. set computeParticleTexture(val: boolean);
  69519. /**
  69520. * Gets if `setParticles()` computes the particle colors or not.
  69521. * Default value : false. The PCS is faster when it's set to false.
  69522. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69523. */
  69524. get computeParticleColor(): boolean;
  69525. /**
  69526. * Gets if `setParticles()` computes the particle textures or not.
  69527. * Default value : false. The PCS is faster when it's set to false.
  69528. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69529. */
  69530. get computeParticleTexture(): boolean;
  69531. /**
  69532. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69533. */
  69534. set computeBoundingBox(val: boolean);
  69535. /**
  69536. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69537. */
  69538. get computeBoundingBox(): boolean;
  69539. /**
  69540. * This function does nothing. It may be overwritten to set all the particle first values.
  69541. * The PCS doesn't call this function, you may have to call it by your own.
  69542. * doc :
  69543. */
  69544. initParticles(): void;
  69545. /**
  69546. * This function does nothing. It may be overwritten to recycle a particle
  69547. * The PCS doesn't call this function, you can to call it
  69548. * doc :
  69549. * @param particle The particle to recycle
  69550. * @returns the recycled particle
  69551. */
  69552. recycleParticle(particle: CloudPoint): CloudPoint;
  69553. /**
  69554. * Updates a particle : this function should be overwritten by the user.
  69555. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69556. * doc :
  69557. * @example : just set a particle position or velocity and recycle conditions
  69558. * @param particle The particle to update
  69559. * @returns the updated particle
  69560. */
  69561. updateParticle(particle: CloudPoint): CloudPoint;
  69562. /**
  69563. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69564. * This does nothing and may be overwritten by the user.
  69565. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69566. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69567. * @param update the boolean update value actually passed to setParticles()
  69568. */
  69569. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69570. /**
  69571. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69572. * This will be passed three parameters.
  69573. * This does nothing and may be overwritten by the user.
  69574. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69575. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69576. * @param update the boolean update value actually passed to setParticles()
  69577. */
  69578. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69579. }
  69580. }
  69581. declare module BABYLON {
  69582. /**
  69583. * Represents one particle of a points cloud system.
  69584. */
  69585. export class CloudPoint {
  69586. /**
  69587. * particle global index
  69588. */
  69589. idx: number;
  69590. /**
  69591. * The color of the particle
  69592. */
  69593. color: Nullable<Color4>;
  69594. /**
  69595. * The world space position of the particle.
  69596. */
  69597. position: Vector3;
  69598. /**
  69599. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69600. */
  69601. rotation: Vector3;
  69602. /**
  69603. * The world space rotation quaternion of the particle.
  69604. */
  69605. rotationQuaternion: Nullable<Quaternion>;
  69606. /**
  69607. * The uv of the particle.
  69608. */
  69609. uv: Nullable<Vector2>;
  69610. /**
  69611. * The current speed of the particle.
  69612. */
  69613. velocity: Vector3;
  69614. /**
  69615. * The pivot point in the particle local space.
  69616. */
  69617. pivot: Vector3;
  69618. /**
  69619. * Must the particle be translated from its pivot point in its local space ?
  69620. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69621. * Default : false
  69622. */
  69623. translateFromPivot: boolean;
  69624. /**
  69625. * Index of this particle in the global "positions" array (Internal use)
  69626. * @hidden
  69627. */
  69628. _pos: number;
  69629. /**
  69630. * @hidden Index of this particle in the global "indices" array (Internal use)
  69631. */
  69632. _ind: number;
  69633. /**
  69634. * Group this particle belongs to
  69635. */
  69636. _group: PointsGroup;
  69637. /**
  69638. * Group id of this particle
  69639. */
  69640. groupId: number;
  69641. /**
  69642. * Index of the particle in its group id (Internal use)
  69643. */
  69644. idxInGroup: number;
  69645. /**
  69646. * @hidden Particle BoundingInfo object (Internal use)
  69647. */
  69648. _boundingInfo: BoundingInfo;
  69649. /**
  69650. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69651. */
  69652. _pcs: PointsCloudSystem;
  69653. /**
  69654. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69655. */
  69656. _stillInvisible: boolean;
  69657. /**
  69658. * @hidden Last computed particle rotation matrix
  69659. */
  69660. _rotationMatrix: number[];
  69661. /**
  69662. * Parent particle Id, if any.
  69663. * Default null.
  69664. */
  69665. parentId: Nullable<number>;
  69666. /**
  69667. * @hidden Internal global position in the PCS.
  69668. */
  69669. _globalPosition: Vector3;
  69670. /**
  69671. * Creates a Point Cloud object.
  69672. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69673. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69674. * @param group (PointsGroup) is the group the particle belongs to
  69675. * @param groupId (integer) is the group identifier in the PCS.
  69676. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69677. * @param pcs defines the PCS it is associated to
  69678. */
  69679. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69680. /**
  69681. * get point size
  69682. */
  69683. get size(): Vector3;
  69684. /**
  69685. * Set point size
  69686. */
  69687. set size(scale: Vector3);
  69688. /**
  69689. * Legacy support, changed quaternion to rotationQuaternion
  69690. */
  69691. get quaternion(): Nullable<Quaternion>;
  69692. /**
  69693. * Legacy support, changed quaternion to rotationQuaternion
  69694. */
  69695. set quaternion(q: Nullable<Quaternion>);
  69696. /**
  69697. * Returns a boolean. True if the particle intersects a mesh, else false
  69698. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69699. * @param target is the object (point or mesh) what the intersection is computed against
  69700. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69701. * @returns true if it intersects
  69702. */
  69703. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69704. /**
  69705. * get the rotation matrix of the particle
  69706. * @hidden
  69707. */
  69708. getRotationMatrix(m: Matrix): void;
  69709. }
  69710. /**
  69711. * Represents a group of points in a points cloud system
  69712. * * PCS internal tool, don't use it manually.
  69713. */
  69714. export class PointsGroup {
  69715. /**
  69716. * The group id
  69717. * @hidden
  69718. */
  69719. groupID: number;
  69720. /**
  69721. * image data for group (internal use)
  69722. * @hidden
  69723. */
  69724. _groupImageData: Nullable<ArrayBufferView>;
  69725. /**
  69726. * Image Width (internal use)
  69727. * @hidden
  69728. */
  69729. _groupImgWidth: number;
  69730. /**
  69731. * Image Height (internal use)
  69732. * @hidden
  69733. */
  69734. _groupImgHeight: number;
  69735. /**
  69736. * Custom position function (internal use)
  69737. * @hidden
  69738. */
  69739. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69740. /**
  69741. * density per facet for surface points
  69742. * @hidden
  69743. */
  69744. _groupDensity: number[];
  69745. /**
  69746. * Only when points are colored by texture carries pointer to texture list array
  69747. * @hidden
  69748. */
  69749. _textureNb: number;
  69750. /**
  69751. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69752. * PCS internal tool, don't use it manually.
  69753. * @hidden
  69754. */
  69755. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69756. }
  69757. }
  69758. declare module BABYLON {
  69759. interface Scene {
  69760. /** @hidden (Backing field) */
  69761. _physicsEngine: Nullable<IPhysicsEngine>;
  69762. /** @hidden */
  69763. _physicsTimeAccumulator: number;
  69764. /**
  69765. * Gets the current physics engine
  69766. * @returns a IPhysicsEngine or null if none attached
  69767. */
  69768. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69769. /**
  69770. * Enables physics to the current scene
  69771. * @param gravity defines the scene's gravity for the physics engine
  69772. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69773. * @return a boolean indicating if the physics engine was initialized
  69774. */
  69775. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69776. /**
  69777. * Disables and disposes the physics engine associated with the scene
  69778. */
  69779. disablePhysicsEngine(): void;
  69780. /**
  69781. * Gets a boolean indicating if there is an active physics engine
  69782. * @returns a boolean indicating if there is an active physics engine
  69783. */
  69784. isPhysicsEnabled(): boolean;
  69785. /**
  69786. * Deletes a physics compound impostor
  69787. * @param compound defines the compound to delete
  69788. */
  69789. deleteCompoundImpostor(compound: any): void;
  69790. /**
  69791. * An event triggered when physic simulation is about to be run
  69792. */
  69793. onBeforePhysicsObservable: Observable<Scene>;
  69794. /**
  69795. * An event triggered when physic simulation has been done
  69796. */
  69797. onAfterPhysicsObservable: Observable<Scene>;
  69798. }
  69799. interface AbstractMesh {
  69800. /** @hidden */
  69801. _physicsImpostor: Nullable<PhysicsImpostor>;
  69802. /**
  69803. * Gets or sets impostor used for physic simulation
  69804. * @see https://doc.babylonjs.com/features/physics_engine
  69805. */
  69806. physicsImpostor: Nullable<PhysicsImpostor>;
  69807. /**
  69808. * Gets the current physics impostor
  69809. * @see https://doc.babylonjs.com/features/physics_engine
  69810. * @returns a physics impostor or null
  69811. */
  69812. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69813. /** Apply a physic impulse to the mesh
  69814. * @param force defines the force to apply
  69815. * @param contactPoint defines where to apply the force
  69816. * @returns the current mesh
  69817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69818. */
  69819. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69820. /**
  69821. * Creates a physic joint between two meshes
  69822. * @param otherMesh defines the other mesh to use
  69823. * @param pivot1 defines the pivot to use on this mesh
  69824. * @param pivot2 defines the pivot to use on the other mesh
  69825. * @param options defines additional options (can be plugin dependent)
  69826. * @returns the current mesh
  69827. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69828. */
  69829. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69830. /** @hidden */
  69831. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69832. }
  69833. /**
  69834. * Defines the physics engine scene component responsible to manage a physics engine
  69835. */
  69836. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69837. /**
  69838. * The component name helpful to identify the component in the list of scene components.
  69839. */
  69840. readonly name: string;
  69841. /**
  69842. * The scene the component belongs to.
  69843. */
  69844. scene: Scene;
  69845. /**
  69846. * Creates a new instance of the component for the given scene
  69847. * @param scene Defines the scene to register the component in
  69848. */
  69849. constructor(scene: Scene);
  69850. /**
  69851. * Registers the component in a given scene
  69852. */
  69853. register(): void;
  69854. /**
  69855. * Rebuilds the elements related to this component in case of
  69856. * context lost for instance.
  69857. */
  69858. rebuild(): void;
  69859. /**
  69860. * Disposes the component and the associated ressources
  69861. */
  69862. dispose(): void;
  69863. }
  69864. }
  69865. declare module BABYLON {
  69866. /**
  69867. * A helper for physics simulations
  69868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69869. */
  69870. export class PhysicsHelper {
  69871. private _scene;
  69872. private _physicsEngine;
  69873. /**
  69874. * Initializes the Physics helper
  69875. * @param scene Babylon.js scene
  69876. */
  69877. constructor(scene: Scene);
  69878. /**
  69879. * Applies a radial explosion impulse
  69880. * @param origin the origin of the explosion
  69881. * @param radiusOrEventOptions the radius or the options of radial explosion
  69882. * @param strength the explosion strength
  69883. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69884. * @returns A physics radial explosion event, or null
  69885. */
  69886. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69887. /**
  69888. * Applies a radial explosion force
  69889. * @param origin the origin of the explosion
  69890. * @param radiusOrEventOptions the radius or the options of radial explosion
  69891. * @param strength the explosion strength
  69892. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69893. * @returns A physics radial explosion event, or null
  69894. */
  69895. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69896. /**
  69897. * Creates a gravitational field
  69898. * @param origin the origin of the explosion
  69899. * @param radiusOrEventOptions the radius or the options of radial explosion
  69900. * @param strength the explosion strength
  69901. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69902. * @returns A physics gravitational field event, or null
  69903. */
  69904. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69905. /**
  69906. * Creates a physics updraft event
  69907. * @param origin the origin of the updraft
  69908. * @param radiusOrEventOptions the radius or the options of the updraft
  69909. * @param strength the strength of the updraft
  69910. * @param height the height of the updraft
  69911. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69912. * @returns A physics updraft event, or null
  69913. */
  69914. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69915. /**
  69916. * Creates a physics vortex event
  69917. * @param origin the of the vortex
  69918. * @param radiusOrEventOptions the radius or the options of the vortex
  69919. * @param strength the strength of the vortex
  69920. * @param height the height of the vortex
  69921. * @returns a Physics vortex event, or null
  69922. * A physics vortex event or null
  69923. */
  69924. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69925. }
  69926. /**
  69927. * Represents a physics radial explosion event
  69928. */
  69929. class PhysicsRadialExplosionEvent {
  69930. private _scene;
  69931. private _options;
  69932. private _sphere;
  69933. private _dataFetched;
  69934. /**
  69935. * Initializes a radial explosioin event
  69936. * @param _scene BabylonJS scene
  69937. * @param _options The options for the vortex event
  69938. */
  69939. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69940. /**
  69941. * Returns the data related to the radial explosion event (sphere).
  69942. * @returns The radial explosion event data
  69943. */
  69944. getData(): PhysicsRadialExplosionEventData;
  69945. /**
  69946. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69947. * @param impostor A physics imposter
  69948. * @param origin the origin of the explosion
  69949. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69950. */
  69951. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69952. /**
  69953. * Triggers affecterd impostors callbacks
  69954. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69955. */
  69956. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69957. /**
  69958. * Disposes the sphere.
  69959. * @param force Specifies if the sphere should be disposed by force
  69960. */
  69961. dispose(force?: boolean): void;
  69962. /*** Helpers ***/
  69963. private _prepareSphere;
  69964. private _intersectsWithSphere;
  69965. }
  69966. /**
  69967. * Represents a gravitational field event
  69968. */
  69969. class PhysicsGravitationalFieldEvent {
  69970. private _physicsHelper;
  69971. private _scene;
  69972. private _origin;
  69973. private _options;
  69974. private _tickCallback;
  69975. private _sphere;
  69976. private _dataFetched;
  69977. /**
  69978. * Initializes the physics gravitational field event
  69979. * @param _physicsHelper A physics helper
  69980. * @param _scene BabylonJS scene
  69981. * @param _origin The origin position of the gravitational field event
  69982. * @param _options The options for the vortex event
  69983. */
  69984. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69985. /**
  69986. * Returns the data related to the gravitational field event (sphere).
  69987. * @returns A gravitational field event
  69988. */
  69989. getData(): PhysicsGravitationalFieldEventData;
  69990. /**
  69991. * Enables the gravitational field.
  69992. */
  69993. enable(): void;
  69994. /**
  69995. * Disables the gravitational field.
  69996. */
  69997. disable(): void;
  69998. /**
  69999. * Disposes the sphere.
  70000. * @param force The force to dispose from the gravitational field event
  70001. */
  70002. dispose(force?: boolean): void;
  70003. private _tick;
  70004. }
  70005. /**
  70006. * Represents a physics updraft event
  70007. */
  70008. class PhysicsUpdraftEvent {
  70009. private _scene;
  70010. private _origin;
  70011. private _options;
  70012. private _physicsEngine;
  70013. private _originTop;
  70014. private _originDirection;
  70015. private _tickCallback;
  70016. private _cylinder;
  70017. private _cylinderPosition;
  70018. private _dataFetched;
  70019. /**
  70020. * Initializes the physics updraft event
  70021. * @param _scene BabylonJS scene
  70022. * @param _origin The origin position of the updraft
  70023. * @param _options The options for the updraft event
  70024. */
  70025. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70026. /**
  70027. * Returns the data related to the updraft event (cylinder).
  70028. * @returns A physics updraft event
  70029. */
  70030. getData(): PhysicsUpdraftEventData;
  70031. /**
  70032. * Enables the updraft.
  70033. */
  70034. enable(): void;
  70035. /**
  70036. * Disables the updraft.
  70037. */
  70038. disable(): void;
  70039. /**
  70040. * Disposes the cylinder.
  70041. * @param force Specifies if the updraft should be disposed by force
  70042. */
  70043. dispose(force?: boolean): void;
  70044. private getImpostorHitData;
  70045. private _tick;
  70046. /*** Helpers ***/
  70047. private _prepareCylinder;
  70048. private _intersectsWithCylinder;
  70049. }
  70050. /**
  70051. * Represents a physics vortex event
  70052. */
  70053. class PhysicsVortexEvent {
  70054. private _scene;
  70055. private _origin;
  70056. private _options;
  70057. private _physicsEngine;
  70058. private _originTop;
  70059. private _tickCallback;
  70060. private _cylinder;
  70061. private _cylinderPosition;
  70062. private _dataFetched;
  70063. /**
  70064. * Initializes the physics vortex event
  70065. * @param _scene The BabylonJS scene
  70066. * @param _origin The origin position of the vortex
  70067. * @param _options The options for the vortex event
  70068. */
  70069. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70070. /**
  70071. * Returns the data related to the vortex event (cylinder).
  70072. * @returns The physics vortex event data
  70073. */
  70074. getData(): PhysicsVortexEventData;
  70075. /**
  70076. * Enables the vortex.
  70077. */
  70078. enable(): void;
  70079. /**
  70080. * Disables the cortex.
  70081. */
  70082. disable(): void;
  70083. /**
  70084. * Disposes the sphere.
  70085. * @param force
  70086. */
  70087. dispose(force?: boolean): void;
  70088. private getImpostorHitData;
  70089. private _tick;
  70090. /*** Helpers ***/
  70091. private _prepareCylinder;
  70092. private _intersectsWithCylinder;
  70093. }
  70094. /**
  70095. * Options fot the radial explosion event
  70096. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70097. */
  70098. export class PhysicsRadialExplosionEventOptions {
  70099. /**
  70100. * The radius of the sphere for the radial explosion.
  70101. */
  70102. radius: number;
  70103. /**
  70104. * The strenth of the explosion.
  70105. */
  70106. strength: number;
  70107. /**
  70108. * The strenght of the force in correspondence to the distance of the affected object
  70109. */
  70110. falloff: PhysicsRadialImpulseFalloff;
  70111. /**
  70112. * Sphere options for the radial explosion.
  70113. */
  70114. sphere: {
  70115. segments: number;
  70116. diameter: number;
  70117. };
  70118. /**
  70119. * Sphere options for the radial explosion.
  70120. */
  70121. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70122. }
  70123. /**
  70124. * Options fot the updraft event
  70125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70126. */
  70127. export class PhysicsUpdraftEventOptions {
  70128. /**
  70129. * The radius of the cylinder for the vortex
  70130. */
  70131. radius: number;
  70132. /**
  70133. * The strenth of the updraft.
  70134. */
  70135. strength: number;
  70136. /**
  70137. * The height of the cylinder for the updraft.
  70138. */
  70139. height: number;
  70140. /**
  70141. * The mode for the the updraft.
  70142. */
  70143. updraftMode: PhysicsUpdraftMode;
  70144. }
  70145. /**
  70146. * Options fot the vortex event
  70147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70148. */
  70149. export class PhysicsVortexEventOptions {
  70150. /**
  70151. * The radius of the cylinder for the vortex
  70152. */
  70153. radius: number;
  70154. /**
  70155. * The strenth of the vortex.
  70156. */
  70157. strength: number;
  70158. /**
  70159. * The height of the cylinder for the vortex.
  70160. */
  70161. height: number;
  70162. /**
  70163. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70164. */
  70165. centripetalForceThreshold: number;
  70166. /**
  70167. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70168. */
  70169. centripetalForceMultiplier: number;
  70170. /**
  70171. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70172. */
  70173. centrifugalForceMultiplier: number;
  70174. /**
  70175. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70176. */
  70177. updraftForceMultiplier: number;
  70178. }
  70179. /**
  70180. * The strenght of the force in correspondence to the distance of the affected object
  70181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70182. */
  70183. export enum PhysicsRadialImpulseFalloff {
  70184. /** Defines that impulse is constant in strength across it's whole radius */
  70185. Constant = 0,
  70186. /** Defines that impulse gets weaker if it's further from the origin */
  70187. Linear = 1
  70188. }
  70189. /**
  70190. * The strength of the force in correspondence to the distance of the affected object
  70191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70192. */
  70193. export enum PhysicsUpdraftMode {
  70194. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70195. Center = 0,
  70196. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70197. Perpendicular = 1
  70198. }
  70199. /**
  70200. * Interface for a physics hit data
  70201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70202. */
  70203. export interface PhysicsHitData {
  70204. /**
  70205. * The force applied at the contact point
  70206. */
  70207. force: Vector3;
  70208. /**
  70209. * The contact point
  70210. */
  70211. contactPoint: Vector3;
  70212. /**
  70213. * The distance from the origin to the contact point
  70214. */
  70215. distanceFromOrigin: number;
  70216. }
  70217. /**
  70218. * Interface for radial explosion event data
  70219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70220. */
  70221. export interface PhysicsRadialExplosionEventData {
  70222. /**
  70223. * A sphere used for the radial explosion event
  70224. */
  70225. sphere: Mesh;
  70226. }
  70227. /**
  70228. * Interface for gravitational field event data
  70229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70230. */
  70231. export interface PhysicsGravitationalFieldEventData {
  70232. /**
  70233. * A sphere mesh used for the gravitational field event
  70234. */
  70235. sphere: Mesh;
  70236. }
  70237. /**
  70238. * Interface for updraft event data
  70239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70240. */
  70241. export interface PhysicsUpdraftEventData {
  70242. /**
  70243. * A cylinder used for the updraft event
  70244. */
  70245. cylinder: Mesh;
  70246. }
  70247. /**
  70248. * Interface for vortex event data
  70249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70250. */
  70251. export interface PhysicsVortexEventData {
  70252. /**
  70253. * A cylinder used for the vortex event
  70254. */
  70255. cylinder: Mesh;
  70256. }
  70257. /**
  70258. * Interface for an affected physics impostor
  70259. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70260. */
  70261. export interface PhysicsAffectedImpostorWithData {
  70262. /**
  70263. * The impostor affected by the effect
  70264. */
  70265. impostor: PhysicsImpostor;
  70266. /**
  70267. * The data about the hit/horce from the explosion
  70268. */
  70269. hitData: PhysicsHitData;
  70270. }
  70271. }
  70272. declare module BABYLON {
  70273. /** @hidden */
  70274. export var blackAndWhitePixelShader: {
  70275. name: string;
  70276. shader: string;
  70277. };
  70278. }
  70279. declare module BABYLON {
  70280. /**
  70281. * Post process used to render in black and white
  70282. */
  70283. export class BlackAndWhitePostProcess extends PostProcess {
  70284. /**
  70285. * Linear about to convert he result to black and white (default: 1)
  70286. */
  70287. degree: number;
  70288. /**
  70289. * Gets a string identifying the name of the class
  70290. * @returns "BlackAndWhitePostProcess" string
  70291. */
  70292. getClassName(): string;
  70293. /**
  70294. * Creates a black and white post process
  70295. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70296. * @param name The name of the effect.
  70297. * @param options The required width/height ratio to downsize to before computing the render pass.
  70298. * @param camera The camera to apply the render pass to.
  70299. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70300. * @param engine The engine which the post process will be applied. (default: current engine)
  70301. * @param reusable If the post process can be reused on the same frame. (default: false)
  70302. */
  70303. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70304. /** @hidden */
  70305. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70306. }
  70307. }
  70308. declare module BABYLON {
  70309. /**
  70310. * This represents a set of one or more post processes in Babylon.
  70311. * A post process can be used to apply a shader to a texture after it is rendered.
  70312. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70313. */
  70314. export class PostProcessRenderEffect {
  70315. private _postProcesses;
  70316. private _getPostProcesses;
  70317. private _singleInstance;
  70318. private _cameras;
  70319. private _indicesForCamera;
  70320. /**
  70321. * Name of the effect
  70322. * @hidden
  70323. */
  70324. _name: string;
  70325. /**
  70326. * Instantiates a post process render effect.
  70327. * A post process can be used to apply a shader to a texture after it is rendered.
  70328. * @param engine The engine the effect is tied to
  70329. * @param name The name of the effect
  70330. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70331. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70332. */
  70333. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70334. /**
  70335. * Checks if all the post processes in the effect are supported.
  70336. */
  70337. get isSupported(): boolean;
  70338. /**
  70339. * Updates the current state of the effect
  70340. * @hidden
  70341. */
  70342. _update(): void;
  70343. /**
  70344. * Attaches the effect on cameras
  70345. * @param cameras The camera to attach to.
  70346. * @hidden
  70347. */
  70348. _attachCameras(cameras: Camera): void;
  70349. /**
  70350. * Attaches the effect on cameras
  70351. * @param cameras The camera to attach to.
  70352. * @hidden
  70353. */
  70354. _attachCameras(cameras: Camera[]): void;
  70355. /**
  70356. * Detaches the effect on cameras
  70357. * @param cameras The camera to detatch from.
  70358. * @hidden
  70359. */
  70360. _detachCameras(cameras: Camera): void;
  70361. /**
  70362. * Detatches the effect on cameras
  70363. * @param cameras The camera to detatch from.
  70364. * @hidden
  70365. */
  70366. _detachCameras(cameras: Camera[]): void;
  70367. /**
  70368. * Enables the effect on given cameras
  70369. * @param cameras The camera to enable.
  70370. * @hidden
  70371. */
  70372. _enable(cameras: Camera): void;
  70373. /**
  70374. * Enables the effect on given cameras
  70375. * @param cameras The camera to enable.
  70376. * @hidden
  70377. */
  70378. _enable(cameras: Nullable<Camera[]>): void;
  70379. /**
  70380. * Disables the effect on the given cameras
  70381. * @param cameras The camera to disable.
  70382. * @hidden
  70383. */
  70384. _disable(cameras: Camera): void;
  70385. /**
  70386. * Disables the effect on the given cameras
  70387. * @param cameras The camera to disable.
  70388. * @hidden
  70389. */
  70390. _disable(cameras: Nullable<Camera[]>): void;
  70391. /**
  70392. * Gets a list of the post processes contained in the effect.
  70393. * @param camera The camera to get the post processes on.
  70394. * @returns The list of the post processes in the effect.
  70395. */
  70396. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70397. }
  70398. }
  70399. declare module BABYLON {
  70400. /** @hidden */
  70401. export var extractHighlightsPixelShader: {
  70402. name: string;
  70403. shader: string;
  70404. };
  70405. }
  70406. declare module BABYLON {
  70407. /**
  70408. * 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.
  70409. */
  70410. export class ExtractHighlightsPostProcess extends PostProcess {
  70411. /**
  70412. * The luminance threshold, pixels below this value will be set to black.
  70413. */
  70414. threshold: number;
  70415. /** @hidden */
  70416. _exposure: number;
  70417. /**
  70418. * Post process which has the input texture to be used when performing highlight extraction
  70419. * @hidden
  70420. */
  70421. _inputPostProcess: Nullable<PostProcess>;
  70422. /**
  70423. * Gets a string identifying the name of the class
  70424. * @returns "ExtractHighlightsPostProcess" string
  70425. */
  70426. getClassName(): string;
  70427. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70428. }
  70429. }
  70430. declare module BABYLON {
  70431. /** @hidden */
  70432. export var bloomMergePixelShader: {
  70433. name: string;
  70434. shader: string;
  70435. };
  70436. }
  70437. declare module BABYLON {
  70438. /**
  70439. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70440. */
  70441. export class BloomMergePostProcess extends PostProcess {
  70442. /** Weight of the bloom to be added to the original input. */
  70443. weight: number;
  70444. /**
  70445. * Gets a string identifying the name of the class
  70446. * @returns "BloomMergePostProcess" string
  70447. */
  70448. getClassName(): string;
  70449. /**
  70450. * Creates a new instance of @see BloomMergePostProcess
  70451. * @param name The name of the effect.
  70452. * @param originalFromInput Post process which's input will be used for the merge.
  70453. * @param blurred Blurred highlights post process which's output will be used.
  70454. * @param weight Weight of the bloom to be added to the original input.
  70455. * @param options The required width/height ratio to downsize to before computing the render pass.
  70456. * @param camera The camera to apply the render pass to.
  70457. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70458. * @param engine The engine which the post process will be applied. (default: current engine)
  70459. * @param reusable If the post process can be reused on the same frame. (default: false)
  70460. * @param textureType Type of textures used when performing the post process. (default: 0)
  70461. * @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)
  70462. */
  70463. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70464. /** Weight of the bloom to be added to the original input. */
  70465. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70466. }
  70467. }
  70468. declare module BABYLON {
  70469. /**
  70470. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70471. */
  70472. export class BloomEffect extends PostProcessRenderEffect {
  70473. private bloomScale;
  70474. /**
  70475. * @hidden Internal
  70476. */
  70477. _effects: Array<PostProcess>;
  70478. /**
  70479. * @hidden Internal
  70480. */
  70481. _downscale: ExtractHighlightsPostProcess;
  70482. private _blurX;
  70483. private _blurY;
  70484. private _merge;
  70485. /**
  70486. * The luminance threshold to find bright areas of the image to bloom.
  70487. */
  70488. get threshold(): number;
  70489. set threshold(value: number);
  70490. /**
  70491. * The strength of the bloom.
  70492. */
  70493. get weight(): number;
  70494. set weight(value: number);
  70495. /**
  70496. * Specifies the size of the bloom blur kernel, relative to the final output size
  70497. */
  70498. get kernel(): number;
  70499. set kernel(value: number);
  70500. /**
  70501. * Creates a new instance of @see BloomEffect
  70502. * @param scene The scene the effect belongs to.
  70503. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70504. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70505. * @param bloomWeight The the strength of bloom.
  70506. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70507. * @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)
  70508. */
  70509. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70510. /**
  70511. * Disposes each of the internal effects for a given camera.
  70512. * @param camera The camera to dispose the effect on.
  70513. */
  70514. disposeEffects(camera: Camera): void;
  70515. /**
  70516. * @hidden Internal
  70517. */
  70518. _updateEffects(): void;
  70519. /**
  70520. * Internal
  70521. * @returns if all the contained post processes are ready.
  70522. * @hidden
  70523. */
  70524. _isReady(): boolean;
  70525. }
  70526. }
  70527. declare module BABYLON {
  70528. /** @hidden */
  70529. export var chromaticAberrationPixelShader: {
  70530. name: string;
  70531. shader: string;
  70532. };
  70533. }
  70534. declare module BABYLON {
  70535. /**
  70536. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70537. */
  70538. export class ChromaticAberrationPostProcess extends PostProcess {
  70539. /**
  70540. * The amount of seperation of rgb channels (default: 30)
  70541. */
  70542. aberrationAmount: number;
  70543. /**
  70544. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70545. */
  70546. radialIntensity: number;
  70547. /**
  70548. * 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))
  70549. */
  70550. direction: Vector2;
  70551. /**
  70552. * 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))
  70553. */
  70554. centerPosition: Vector2;
  70555. /** The width of the screen to apply the effect on */
  70556. screenWidth: number;
  70557. /** The height of the screen to apply the effect on */
  70558. screenHeight: number;
  70559. /**
  70560. * Gets a string identifying the name of the class
  70561. * @returns "ChromaticAberrationPostProcess" string
  70562. */
  70563. getClassName(): string;
  70564. /**
  70565. * Creates a new instance ChromaticAberrationPostProcess
  70566. * @param name The name of the effect.
  70567. * @param screenWidth The width of the screen to apply the effect on.
  70568. * @param screenHeight The height of the screen to apply the effect on.
  70569. * @param options The required width/height ratio to downsize to before computing the render pass.
  70570. * @param camera The camera to apply the render pass to.
  70571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70572. * @param engine The engine which the post process will be applied. (default: current engine)
  70573. * @param reusable If the post process can be reused on the same frame. (default: false)
  70574. * @param textureType Type of textures used when performing the post process. (default: 0)
  70575. * @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)
  70576. */
  70577. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70578. /** @hidden */
  70579. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70580. }
  70581. }
  70582. declare module BABYLON {
  70583. /** @hidden */
  70584. export var circleOfConfusionPixelShader: {
  70585. name: string;
  70586. shader: string;
  70587. };
  70588. }
  70589. declare module BABYLON {
  70590. /**
  70591. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70592. */
  70593. export class CircleOfConfusionPostProcess extends PostProcess {
  70594. /**
  70595. * 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.
  70596. */
  70597. lensSize: number;
  70598. /**
  70599. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70600. */
  70601. fStop: number;
  70602. /**
  70603. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70604. */
  70605. focusDistance: number;
  70606. /**
  70607. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70608. */
  70609. focalLength: number;
  70610. /**
  70611. * Gets a string identifying the name of the class
  70612. * @returns "CircleOfConfusionPostProcess" string
  70613. */
  70614. getClassName(): string;
  70615. private _depthTexture;
  70616. /**
  70617. * Creates a new instance CircleOfConfusionPostProcess
  70618. * @param name The name of the effect.
  70619. * @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.
  70620. * @param options The required width/height ratio to downsize to before computing the render pass.
  70621. * @param camera The camera to apply the render pass to.
  70622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70623. * @param engine The engine which the post process will be applied. (default: current engine)
  70624. * @param reusable If the post process can be reused on the same frame. (default: false)
  70625. * @param textureType Type of textures used when performing the post process. (default: 0)
  70626. * @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)
  70627. */
  70628. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70629. /**
  70630. * 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.
  70631. */
  70632. set depthTexture(value: RenderTargetTexture);
  70633. }
  70634. }
  70635. declare module BABYLON {
  70636. /** @hidden */
  70637. export var colorCorrectionPixelShader: {
  70638. name: string;
  70639. shader: string;
  70640. };
  70641. }
  70642. declare module BABYLON {
  70643. /**
  70644. *
  70645. * This post-process allows the modification of rendered colors by using
  70646. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70647. *
  70648. * The object needs to be provided an url to a texture containing the color
  70649. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70650. * Use an image editing software to tweak the LUT to match your needs.
  70651. *
  70652. * For an example of a color LUT, see here:
  70653. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70654. * For explanations on color grading, see here:
  70655. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70656. *
  70657. */
  70658. export class ColorCorrectionPostProcess extends PostProcess {
  70659. private _colorTableTexture;
  70660. /**
  70661. * Gets the color table url used to create the LUT texture
  70662. */
  70663. colorTableUrl: string;
  70664. /**
  70665. * Gets a string identifying the name of the class
  70666. * @returns "ColorCorrectionPostProcess" string
  70667. */
  70668. getClassName(): string;
  70669. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70670. /** @hidden */
  70671. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70672. }
  70673. }
  70674. declare module BABYLON {
  70675. /** @hidden */
  70676. export var convolutionPixelShader: {
  70677. name: string;
  70678. shader: string;
  70679. };
  70680. }
  70681. declare module BABYLON {
  70682. /**
  70683. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70684. * input texture to perform effects such as edge detection or sharpening
  70685. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70686. */
  70687. export class ConvolutionPostProcess extends PostProcess {
  70688. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70689. kernel: number[];
  70690. /**
  70691. * Gets a string identifying the name of the class
  70692. * @returns "ConvolutionPostProcess" string
  70693. */
  70694. getClassName(): string;
  70695. /**
  70696. * Creates a new instance ConvolutionPostProcess
  70697. * @param name The name of the effect.
  70698. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70699. * @param options The required width/height ratio to downsize to before computing the render pass.
  70700. * @param camera The camera to apply the render pass to.
  70701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70702. * @param engine The engine which the post process will be applied. (default: current engine)
  70703. * @param reusable If the post process can be reused on the same frame. (default: false)
  70704. * @param textureType Type of textures used when performing the post process. (default: 0)
  70705. */
  70706. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70707. /** @hidden */
  70708. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70709. /**
  70710. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70711. */
  70712. static EdgeDetect0Kernel: number[];
  70713. /**
  70714. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70715. */
  70716. static EdgeDetect1Kernel: number[];
  70717. /**
  70718. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70719. */
  70720. static EdgeDetect2Kernel: number[];
  70721. /**
  70722. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70723. */
  70724. static SharpenKernel: number[];
  70725. /**
  70726. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70727. */
  70728. static EmbossKernel: number[];
  70729. /**
  70730. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70731. */
  70732. static GaussianKernel: number[];
  70733. }
  70734. }
  70735. declare module BABYLON {
  70736. /**
  70737. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70738. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70739. * based on samples that have a large difference in distance than the center pixel.
  70740. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70741. */
  70742. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70743. /**
  70744. * The direction the blur should be applied
  70745. */
  70746. direction: Vector2;
  70747. /**
  70748. * Gets a string identifying the name of the class
  70749. * @returns "DepthOfFieldBlurPostProcess" string
  70750. */
  70751. getClassName(): string;
  70752. /**
  70753. * Creates a new instance CircleOfConfusionPostProcess
  70754. * @param name The name of the effect.
  70755. * @param scene The scene the effect belongs to.
  70756. * @param direction The direction the blur should be applied.
  70757. * @param kernel The size of the kernel used to blur.
  70758. * @param options The required width/height ratio to downsize to before computing the render pass.
  70759. * @param camera The camera to apply the render pass to.
  70760. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70761. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70762. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70763. * @param engine The engine which the post process will be applied. (default: current engine)
  70764. * @param reusable If the post process can be reused on the same frame. (default: false)
  70765. * @param textureType Type of textures used when performing the post process. (default: 0)
  70766. * @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)
  70767. */
  70768. 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);
  70769. }
  70770. }
  70771. declare module BABYLON {
  70772. /** @hidden */
  70773. export var depthOfFieldMergePixelShader: {
  70774. name: string;
  70775. shader: string;
  70776. };
  70777. }
  70778. declare module BABYLON {
  70779. /**
  70780. * Options to be set when merging outputs from the default pipeline.
  70781. */
  70782. export class DepthOfFieldMergePostProcessOptions {
  70783. /**
  70784. * The original image to merge on top of
  70785. */
  70786. originalFromInput: PostProcess;
  70787. /**
  70788. * Parameters to perform the merge of the depth of field effect
  70789. */
  70790. depthOfField?: {
  70791. circleOfConfusion: PostProcess;
  70792. blurSteps: Array<PostProcess>;
  70793. };
  70794. /**
  70795. * Parameters to perform the merge of bloom effect
  70796. */
  70797. bloom?: {
  70798. blurred: PostProcess;
  70799. weight: number;
  70800. };
  70801. }
  70802. /**
  70803. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70804. */
  70805. export class DepthOfFieldMergePostProcess extends PostProcess {
  70806. private blurSteps;
  70807. /**
  70808. * Gets a string identifying the name of the class
  70809. * @returns "DepthOfFieldMergePostProcess" string
  70810. */
  70811. getClassName(): string;
  70812. /**
  70813. * Creates a new instance of DepthOfFieldMergePostProcess
  70814. * @param name The name of the effect.
  70815. * @param originalFromInput Post process which's input will be used for the merge.
  70816. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70817. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70818. * @param options The required width/height ratio to downsize to before computing the render pass.
  70819. * @param camera The camera to apply the render pass to.
  70820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70821. * @param engine The engine which the post process will be applied. (default: current engine)
  70822. * @param reusable If the post process can be reused on the same frame. (default: false)
  70823. * @param textureType Type of textures used when performing the post process. (default: 0)
  70824. * @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)
  70825. */
  70826. 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);
  70827. /**
  70828. * Updates the effect with the current post process compile time values and recompiles the shader.
  70829. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70830. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70831. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70832. * @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
  70833. * @param onCompiled Called when the shader has been compiled.
  70834. * @param onError Called if there is an error when compiling a shader.
  70835. */
  70836. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70837. }
  70838. }
  70839. declare module BABYLON {
  70840. /**
  70841. * Specifies the level of max blur that should be applied when using the depth of field effect
  70842. */
  70843. export enum DepthOfFieldEffectBlurLevel {
  70844. /**
  70845. * Subtle blur
  70846. */
  70847. Low = 0,
  70848. /**
  70849. * Medium blur
  70850. */
  70851. Medium = 1,
  70852. /**
  70853. * Large blur
  70854. */
  70855. High = 2
  70856. }
  70857. /**
  70858. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70859. */
  70860. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70861. private _circleOfConfusion;
  70862. /**
  70863. * @hidden Internal, blurs from high to low
  70864. */
  70865. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70866. private _depthOfFieldBlurY;
  70867. private _dofMerge;
  70868. /**
  70869. * @hidden Internal post processes in depth of field effect
  70870. */
  70871. _effects: Array<PostProcess>;
  70872. /**
  70873. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70874. */
  70875. set focalLength(value: number);
  70876. get focalLength(): number;
  70877. /**
  70878. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70879. */
  70880. set fStop(value: number);
  70881. get fStop(): number;
  70882. /**
  70883. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70884. */
  70885. set focusDistance(value: number);
  70886. get focusDistance(): number;
  70887. /**
  70888. * 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.
  70889. */
  70890. set lensSize(value: number);
  70891. get lensSize(): number;
  70892. /**
  70893. * Creates a new instance DepthOfFieldEffect
  70894. * @param scene The scene the effect belongs to.
  70895. * @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.
  70896. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70897. * @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)
  70898. */
  70899. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70900. /**
  70901. * Get the current class name of the current effet
  70902. * @returns "DepthOfFieldEffect"
  70903. */
  70904. getClassName(): string;
  70905. /**
  70906. * 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.
  70907. */
  70908. set depthTexture(value: RenderTargetTexture);
  70909. /**
  70910. * Disposes each of the internal effects for a given camera.
  70911. * @param camera The camera to dispose the effect on.
  70912. */
  70913. disposeEffects(camera: Camera): void;
  70914. /**
  70915. * @hidden Internal
  70916. */
  70917. _updateEffects(): void;
  70918. /**
  70919. * Internal
  70920. * @returns if all the contained post processes are ready.
  70921. * @hidden
  70922. */
  70923. _isReady(): boolean;
  70924. }
  70925. }
  70926. declare module BABYLON {
  70927. /** @hidden */
  70928. export var displayPassPixelShader: {
  70929. name: string;
  70930. shader: string;
  70931. };
  70932. }
  70933. declare module BABYLON {
  70934. /**
  70935. * DisplayPassPostProcess which produces an output the same as it's input
  70936. */
  70937. export class DisplayPassPostProcess extends PostProcess {
  70938. /**
  70939. * Gets a string identifying the name of the class
  70940. * @returns "DisplayPassPostProcess" string
  70941. */
  70942. getClassName(): string;
  70943. /**
  70944. * Creates the DisplayPassPostProcess
  70945. * @param name The name of the effect.
  70946. * @param options The required width/height ratio to downsize to before computing the render pass.
  70947. * @param camera The camera to apply the render pass to.
  70948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70949. * @param engine The engine which the post process will be applied. (default: current engine)
  70950. * @param reusable If the post process can be reused on the same frame. (default: false)
  70951. */
  70952. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70953. /** @hidden */
  70954. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70955. }
  70956. }
  70957. declare module BABYLON {
  70958. /** @hidden */
  70959. export var filterPixelShader: {
  70960. name: string;
  70961. shader: string;
  70962. };
  70963. }
  70964. declare module BABYLON {
  70965. /**
  70966. * Applies a kernel filter to the image
  70967. */
  70968. export class FilterPostProcess extends PostProcess {
  70969. /** The matrix to be applied to the image */
  70970. kernelMatrix: Matrix;
  70971. /**
  70972. * Gets a string identifying the name of the class
  70973. * @returns "FilterPostProcess" string
  70974. */
  70975. getClassName(): string;
  70976. /**
  70977. *
  70978. * @param name The name of the effect.
  70979. * @param kernelMatrix The matrix to be applied to the image
  70980. * @param options The required width/height ratio to downsize to before computing the render pass.
  70981. * @param camera The camera to apply the render pass to.
  70982. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70983. * @param engine The engine which the post process will be applied. (default: current engine)
  70984. * @param reusable If the post process can be reused on the same frame. (default: false)
  70985. */
  70986. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70987. /** @hidden */
  70988. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70989. }
  70990. }
  70991. declare module BABYLON {
  70992. /** @hidden */
  70993. export var fxaaPixelShader: {
  70994. name: string;
  70995. shader: string;
  70996. };
  70997. }
  70998. declare module BABYLON {
  70999. /** @hidden */
  71000. export var fxaaVertexShader: {
  71001. name: string;
  71002. shader: string;
  71003. };
  71004. }
  71005. declare module BABYLON {
  71006. /**
  71007. * Fxaa post process
  71008. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71009. */
  71010. export class FxaaPostProcess extends PostProcess {
  71011. /**
  71012. * Gets a string identifying the name of the class
  71013. * @returns "FxaaPostProcess" string
  71014. */
  71015. getClassName(): string;
  71016. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71017. private _getDefines;
  71018. /** @hidden */
  71019. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  71020. }
  71021. }
  71022. declare module BABYLON {
  71023. /** @hidden */
  71024. export var grainPixelShader: {
  71025. name: string;
  71026. shader: string;
  71027. };
  71028. }
  71029. declare module BABYLON {
  71030. /**
  71031. * The GrainPostProcess adds noise to the image at mid luminance levels
  71032. */
  71033. export class GrainPostProcess extends PostProcess {
  71034. /**
  71035. * The intensity of the grain added (default: 30)
  71036. */
  71037. intensity: number;
  71038. /**
  71039. * If the grain should be randomized on every frame
  71040. */
  71041. animated: boolean;
  71042. /**
  71043. * Gets a string identifying the name of the class
  71044. * @returns "GrainPostProcess" string
  71045. */
  71046. getClassName(): string;
  71047. /**
  71048. * Creates a new instance of @see GrainPostProcess
  71049. * @param name The name of the effect.
  71050. * @param options The required width/height ratio to downsize to before computing the render pass.
  71051. * @param camera The camera to apply the render pass to.
  71052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71053. * @param engine The engine which the post process will be applied. (default: current engine)
  71054. * @param reusable If the post process can be reused on the same frame. (default: false)
  71055. * @param textureType Type of textures used when performing the post process. (default: 0)
  71056. * @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)
  71057. */
  71058. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71059. /** @hidden */
  71060. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  71061. }
  71062. }
  71063. declare module BABYLON {
  71064. /** @hidden */
  71065. export var highlightsPixelShader: {
  71066. name: string;
  71067. shader: string;
  71068. };
  71069. }
  71070. declare module BABYLON {
  71071. /**
  71072. * Extracts highlights from the image
  71073. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71074. */
  71075. export class HighlightsPostProcess extends PostProcess {
  71076. /**
  71077. * Gets a string identifying the name of the class
  71078. * @returns "HighlightsPostProcess" string
  71079. */
  71080. getClassName(): string;
  71081. /**
  71082. * Extracts highlights from the image
  71083. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71084. * @param name The name of the effect.
  71085. * @param options The required width/height ratio to downsize to before computing the render pass.
  71086. * @param camera The camera to apply the render pass to.
  71087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71088. * @param engine The engine which the post process will be applied. (default: current engine)
  71089. * @param reusable If the post process can be reused on the same frame. (default: false)
  71090. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71091. */
  71092. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71093. }
  71094. }
  71095. declare module BABYLON {
  71096. /**
  71097. * Contains all parameters needed for the prepass to perform
  71098. * motion blur
  71099. */
  71100. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  71101. /**
  71102. * Is motion blur enabled
  71103. */
  71104. enabled: boolean;
  71105. /**
  71106. * Name of the configuration
  71107. */
  71108. name: string;
  71109. /**
  71110. * Textures that should be present in the MRT for this effect to work
  71111. */
  71112. readonly texturesRequired: number[];
  71113. }
  71114. }
  71115. declare module BABYLON {
  71116. interface Scene {
  71117. /** @hidden (Backing field) */
  71118. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71119. /**
  71120. * Gets or Sets the current geometry buffer associated to the scene.
  71121. */
  71122. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71123. /**
  71124. * Enables a GeometryBufferRender and associates it with the scene
  71125. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71126. * @returns the GeometryBufferRenderer
  71127. */
  71128. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71129. /**
  71130. * Disables the GeometryBufferRender associated with the scene
  71131. */
  71132. disableGeometryBufferRenderer(): void;
  71133. }
  71134. /**
  71135. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71136. * in several rendering techniques.
  71137. */
  71138. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71139. /**
  71140. * The component name helpful to identify the component in the list of scene components.
  71141. */
  71142. readonly name: string;
  71143. /**
  71144. * The scene the component belongs to.
  71145. */
  71146. scene: Scene;
  71147. /**
  71148. * Creates a new instance of the component for the given scene
  71149. * @param scene Defines the scene to register the component in
  71150. */
  71151. constructor(scene: Scene);
  71152. /**
  71153. * Registers the component in a given scene
  71154. */
  71155. register(): void;
  71156. /**
  71157. * Rebuilds the elements related to this component in case of
  71158. * context lost for instance.
  71159. */
  71160. rebuild(): void;
  71161. /**
  71162. * Disposes the component and the associated ressources
  71163. */
  71164. dispose(): void;
  71165. private _gatherRenderTargets;
  71166. }
  71167. }
  71168. declare module BABYLON {
  71169. /** @hidden */
  71170. export var motionBlurPixelShader: {
  71171. name: string;
  71172. shader: string;
  71173. };
  71174. }
  71175. declare module BABYLON {
  71176. /**
  71177. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71178. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71179. * As an example, all you have to do is to create the post-process:
  71180. * var mb = new BABYLON.MotionBlurPostProcess(
  71181. * 'mb', // The name of the effect.
  71182. * scene, // The scene containing the objects to blur according to their velocity.
  71183. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71184. * camera // The camera to apply the render pass to.
  71185. * );
  71186. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71187. */
  71188. export class MotionBlurPostProcess extends PostProcess {
  71189. /**
  71190. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71191. */
  71192. motionStrength: number;
  71193. /**
  71194. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71195. */
  71196. get motionBlurSamples(): number;
  71197. /**
  71198. * Sets the number of iterations to be used for motion blur quality
  71199. */
  71200. set motionBlurSamples(samples: number);
  71201. private _motionBlurSamples;
  71202. private _forceGeometryBuffer;
  71203. private _geometryBufferRenderer;
  71204. private _prePassRenderer;
  71205. /**
  71206. * Gets a string identifying the name of the class
  71207. * @returns "MotionBlurPostProcess" string
  71208. */
  71209. getClassName(): string;
  71210. /**
  71211. * Creates a new instance MotionBlurPostProcess
  71212. * @param name The name of the effect.
  71213. * @param scene The scene containing the objects to blur according to their velocity.
  71214. * @param options The required width/height ratio to downsize to before computing the render pass.
  71215. * @param camera The camera to apply the render pass to.
  71216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71217. * @param engine The engine which the post process will be applied. (default: current engine)
  71218. * @param reusable If the post process can be reused on the same frame. (default: false)
  71219. * @param textureType Type of textures used when performing the post process. (default: 0)
  71220. * @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)
  71221. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71222. */
  71223. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71224. /**
  71225. * Excludes the given skinned mesh from computing bones velocities.
  71226. * 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.
  71227. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71228. */
  71229. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71230. /**
  71231. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71232. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71233. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71234. */
  71235. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71236. /**
  71237. * Disposes the post process.
  71238. * @param camera The camera to dispose the post process on.
  71239. */
  71240. dispose(camera?: Camera): void;
  71241. /** @hidden */
  71242. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  71243. }
  71244. }
  71245. declare module BABYLON {
  71246. /** @hidden */
  71247. export var refractionPixelShader: {
  71248. name: string;
  71249. shader: string;
  71250. };
  71251. }
  71252. declare module BABYLON {
  71253. /**
  71254. * Post process which applies a refractin texture
  71255. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71256. */
  71257. export class RefractionPostProcess extends PostProcess {
  71258. private _refTexture;
  71259. private _ownRefractionTexture;
  71260. /** the base color of the refraction (used to taint the rendering) */
  71261. color: Color3;
  71262. /** simulated refraction depth */
  71263. depth: number;
  71264. /** the coefficient of the base color (0 to remove base color tainting) */
  71265. colorLevel: number;
  71266. /** Gets the url used to load the refraction texture */
  71267. refractionTextureUrl: string;
  71268. /**
  71269. * Gets or sets the refraction texture
  71270. * Please note that you are responsible for disposing the texture if you set it manually
  71271. */
  71272. get refractionTexture(): Texture;
  71273. set refractionTexture(value: Texture);
  71274. /**
  71275. * Gets a string identifying the name of the class
  71276. * @returns "RefractionPostProcess" string
  71277. */
  71278. getClassName(): string;
  71279. /**
  71280. * Initializes the RefractionPostProcess
  71281. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71282. * @param name The name of the effect.
  71283. * @param refractionTextureUrl Url of the refraction texture to use
  71284. * @param color the base color of the refraction (used to taint the rendering)
  71285. * @param depth simulated refraction depth
  71286. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71287. * @param camera The camera to apply the render pass to.
  71288. * @param options The required width/height ratio to downsize to before computing the render pass.
  71289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71290. * @param engine The engine which the post process will be applied. (default: current engine)
  71291. * @param reusable If the post process can be reused on the same frame. (default: false)
  71292. */
  71293. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71294. /**
  71295. * Disposes of the post process
  71296. * @param camera Camera to dispose post process on
  71297. */
  71298. dispose(camera: Camera): void;
  71299. /** @hidden */
  71300. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71301. }
  71302. }
  71303. declare module BABYLON {
  71304. /** @hidden */
  71305. export var sharpenPixelShader: {
  71306. name: string;
  71307. shader: string;
  71308. };
  71309. }
  71310. declare module BABYLON {
  71311. /**
  71312. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71313. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71314. */
  71315. export class SharpenPostProcess extends PostProcess {
  71316. /**
  71317. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71318. */
  71319. colorAmount: number;
  71320. /**
  71321. * How much sharpness should be applied (default: 0.3)
  71322. */
  71323. edgeAmount: number;
  71324. /**
  71325. * Gets a string identifying the name of the class
  71326. * @returns "SharpenPostProcess" string
  71327. */
  71328. getClassName(): string;
  71329. /**
  71330. * Creates a new instance ConvolutionPostProcess
  71331. * @param name The name of the effect.
  71332. * @param options The required width/height ratio to downsize to before computing the render pass.
  71333. * @param camera The camera to apply the render pass to.
  71334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71335. * @param engine The engine which the post process will be applied. (default: current engine)
  71336. * @param reusable If the post process can be reused on the same frame. (default: false)
  71337. * @param textureType Type of textures used when performing the post process. (default: 0)
  71338. * @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)
  71339. */
  71340. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71341. /** @hidden */
  71342. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71343. }
  71344. }
  71345. declare module BABYLON {
  71346. /**
  71347. * PostProcessRenderPipeline
  71348. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71349. */
  71350. export class PostProcessRenderPipeline {
  71351. private engine;
  71352. private _renderEffects;
  71353. private _renderEffectsForIsolatedPass;
  71354. /**
  71355. * List of inspectable custom properties (used by the Inspector)
  71356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71357. */
  71358. inspectableCustomProperties: IInspectable[];
  71359. /**
  71360. * @hidden
  71361. */
  71362. protected _cameras: Camera[];
  71363. /** @hidden */
  71364. _name: string;
  71365. /**
  71366. * Gets pipeline name
  71367. */
  71368. get name(): string;
  71369. /** Gets the list of attached cameras */
  71370. get cameras(): Camera[];
  71371. /**
  71372. * Initializes a PostProcessRenderPipeline
  71373. * @param engine engine to add the pipeline to
  71374. * @param name name of the pipeline
  71375. */
  71376. constructor(engine: Engine, name: string);
  71377. /**
  71378. * Gets the class name
  71379. * @returns "PostProcessRenderPipeline"
  71380. */
  71381. getClassName(): string;
  71382. /**
  71383. * If all the render effects in the pipeline are supported
  71384. */
  71385. get isSupported(): boolean;
  71386. /**
  71387. * Adds an effect to the pipeline
  71388. * @param renderEffect the effect to add
  71389. */
  71390. addEffect(renderEffect: PostProcessRenderEffect): void;
  71391. /** @hidden */
  71392. _rebuild(): void;
  71393. /** @hidden */
  71394. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71395. /** @hidden */
  71396. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71397. /** @hidden */
  71398. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71399. /** @hidden */
  71400. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71401. /** @hidden */
  71402. _attachCameras(cameras: Camera, unique: boolean): void;
  71403. /** @hidden */
  71404. _attachCameras(cameras: Camera[], unique: boolean): void;
  71405. /** @hidden */
  71406. _detachCameras(cameras: Camera): void;
  71407. /** @hidden */
  71408. _detachCameras(cameras: Nullable<Camera[]>): void;
  71409. /** @hidden */
  71410. _update(): void;
  71411. /** @hidden */
  71412. _reset(): void;
  71413. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71414. /**
  71415. * Sets the required values to the prepass renderer.
  71416. * @param prePassRenderer defines the prepass renderer to setup.
  71417. * @returns true if the pre pass is needed.
  71418. */
  71419. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71420. /**
  71421. * Disposes of the pipeline
  71422. */
  71423. dispose(): void;
  71424. }
  71425. }
  71426. declare module BABYLON {
  71427. /**
  71428. * PostProcessRenderPipelineManager class
  71429. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71430. */
  71431. export class PostProcessRenderPipelineManager {
  71432. private _renderPipelines;
  71433. /**
  71434. * Initializes a PostProcessRenderPipelineManager
  71435. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71436. */
  71437. constructor();
  71438. /**
  71439. * Gets the list of supported render pipelines
  71440. */
  71441. get supportedPipelines(): PostProcessRenderPipeline[];
  71442. /**
  71443. * Adds a pipeline to the manager
  71444. * @param renderPipeline The pipeline to add
  71445. */
  71446. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71447. /**
  71448. * Attaches a camera to the pipeline
  71449. * @param renderPipelineName The name of the pipeline to attach to
  71450. * @param cameras the camera to attach
  71451. * @param unique if the camera can be attached multiple times to the pipeline
  71452. */
  71453. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71454. /**
  71455. * Detaches a camera from the pipeline
  71456. * @param renderPipelineName The name of the pipeline to detach from
  71457. * @param cameras the camera to detach
  71458. */
  71459. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71460. /**
  71461. * Enables an effect by name on a pipeline
  71462. * @param renderPipelineName the name of the pipeline to enable the effect in
  71463. * @param renderEffectName the name of the effect to enable
  71464. * @param cameras the cameras that the effect should be enabled on
  71465. */
  71466. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71467. /**
  71468. * Disables an effect by name on a pipeline
  71469. * @param renderPipelineName the name of the pipeline to disable the effect in
  71470. * @param renderEffectName the name of the effect to disable
  71471. * @param cameras the cameras that the effect should be disabled on
  71472. */
  71473. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71474. /**
  71475. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71476. */
  71477. update(): void;
  71478. /** @hidden */
  71479. _rebuild(): void;
  71480. /**
  71481. * Disposes of the manager and pipelines
  71482. */
  71483. dispose(): void;
  71484. }
  71485. }
  71486. declare module BABYLON {
  71487. interface Scene {
  71488. /** @hidden (Backing field) */
  71489. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71490. /**
  71491. * Gets the postprocess render pipeline manager
  71492. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71493. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71494. */
  71495. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71496. }
  71497. /**
  71498. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71499. */
  71500. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71501. /**
  71502. * The component name helpfull to identify the component in the list of scene components.
  71503. */
  71504. readonly name: string;
  71505. /**
  71506. * The scene the component belongs to.
  71507. */
  71508. scene: Scene;
  71509. /**
  71510. * Creates a new instance of the component for the given scene
  71511. * @param scene Defines the scene to register the component in
  71512. */
  71513. constructor(scene: Scene);
  71514. /**
  71515. * Registers the component in a given scene
  71516. */
  71517. register(): void;
  71518. /**
  71519. * Rebuilds the elements related to this component in case of
  71520. * context lost for instance.
  71521. */
  71522. rebuild(): void;
  71523. /**
  71524. * Disposes the component and the associated ressources
  71525. */
  71526. dispose(): void;
  71527. private _gatherRenderTargets;
  71528. }
  71529. }
  71530. declare module BABYLON {
  71531. /**
  71532. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71533. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71534. */
  71535. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71536. private _scene;
  71537. private _camerasToBeAttached;
  71538. /**
  71539. * ID of the sharpen post process,
  71540. */
  71541. private readonly SharpenPostProcessId;
  71542. /**
  71543. * @ignore
  71544. * ID of the image processing post process;
  71545. */
  71546. readonly ImageProcessingPostProcessId: string;
  71547. /**
  71548. * @ignore
  71549. * ID of the Fast Approximate Anti-Aliasing post process;
  71550. */
  71551. readonly FxaaPostProcessId: string;
  71552. /**
  71553. * ID of the chromatic aberration post process,
  71554. */
  71555. private readonly ChromaticAberrationPostProcessId;
  71556. /**
  71557. * ID of the grain post process
  71558. */
  71559. private readonly GrainPostProcessId;
  71560. /**
  71561. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71562. */
  71563. sharpen: SharpenPostProcess;
  71564. private _sharpenEffect;
  71565. private bloom;
  71566. /**
  71567. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71568. */
  71569. depthOfField: DepthOfFieldEffect;
  71570. /**
  71571. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71572. */
  71573. fxaa: FxaaPostProcess;
  71574. /**
  71575. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71576. */
  71577. imageProcessing: ImageProcessingPostProcess;
  71578. /**
  71579. * Chromatic aberration post process which will shift rgb colors in the image
  71580. */
  71581. chromaticAberration: ChromaticAberrationPostProcess;
  71582. private _chromaticAberrationEffect;
  71583. /**
  71584. * Grain post process which add noise to the image
  71585. */
  71586. grain: GrainPostProcess;
  71587. private _grainEffect;
  71588. /**
  71589. * Glow post process which adds a glow to emissive areas of the image
  71590. */
  71591. private _glowLayer;
  71592. /**
  71593. * Animations which can be used to tweak settings over a period of time
  71594. */
  71595. animations: Animation[];
  71596. private _imageProcessingConfigurationObserver;
  71597. private _sharpenEnabled;
  71598. private _bloomEnabled;
  71599. private _depthOfFieldEnabled;
  71600. private _depthOfFieldBlurLevel;
  71601. private _fxaaEnabled;
  71602. private _imageProcessingEnabled;
  71603. private _defaultPipelineTextureType;
  71604. private _bloomScale;
  71605. private _chromaticAberrationEnabled;
  71606. private _grainEnabled;
  71607. private _buildAllowed;
  71608. /**
  71609. * This is triggered each time the pipeline has been built.
  71610. */
  71611. onBuildObservable: Observable<DefaultRenderingPipeline>;
  71612. /**
  71613. * Gets active scene
  71614. */
  71615. get scene(): Scene;
  71616. /**
  71617. * Enable or disable the sharpen process from the pipeline
  71618. */
  71619. set sharpenEnabled(enabled: boolean);
  71620. get sharpenEnabled(): boolean;
  71621. private _resizeObserver;
  71622. private _hardwareScaleLevel;
  71623. private _bloomKernel;
  71624. /**
  71625. * Specifies the size of the bloom blur kernel, relative to the final output size
  71626. */
  71627. get bloomKernel(): number;
  71628. set bloomKernel(value: number);
  71629. /**
  71630. * Specifies the weight of the bloom in the final rendering
  71631. */
  71632. private _bloomWeight;
  71633. /**
  71634. * Specifies the luma threshold for the area that will be blurred by the bloom
  71635. */
  71636. private _bloomThreshold;
  71637. private _hdr;
  71638. /**
  71639. * The strength of the bloom.
  71640. */
  71641. set bloomWeight(value: number);
  71642. get bloomWeight(): number;
  71643. /**
  71644. * The strength of the bloom.
  71645. */
  71646. set bloomThreshold(value: number);
  71647. get bloomThreshold(): number;
  71648. /**
  71649. * The scale of the bloom, lower value will provide better performance.
  71650. */
  71651. set bloomScale(value: number);
  71652. get bloomScale(): number;
  71653. /**
  71654. * Enable or disable the bloom from the pipeline
  71655. */
  71656. set bloomEnabled(enabled: boolean);
  71657. get bloomEnabled(): boolean;
  71658. private _rebuildBloom;
  71659. /**
  71660. * If the depth of field is enabled.
  71661. */
  71662. get depthOfFieldEnabled(): boolean;
  71663. set depthOfFieldEnabled(enabled: boolean);
  71664. /**
  71665. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71666. */
  71667. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71668. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71669. /**
  71670. * If the anti aliasing is enabled.
  71671. */
  71672. set fxaaEnabled(enabled: boolean);
  71673. get fxaaEnabled(): boolean;
  71674. private _samples;
  71675. /**
  71676. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71677. */
  71678. set samples(sampleCount: number);
  71679. get samples(): number;
  71680. /**
  71681. * If image processing is enabled.
  71682. */
  71683. set imageProcessingEnabled(enabled: boolean);
  71684. get imageProcessingEnabled(): boolean;
  71685. /**
  71686. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71687. */
  71688. set glowLayerEnabled(enabled: boolean);
  71689. get glowLayerEnabled(): boolean;
  71690. /**
  71691. * Gets the glow layer (or null if not defined)
  71692. */
  71693. get glowLayer(): Nullable<GlowLayer>;
  71694. /**
  71695. * Enable or disable the chromaticAberration process from the pipeline
  71696. */
  71697. set chromaticAberrationEnabled(enabled: boolean);
  71698. get chromaticAberrationEnabled(): boolean;
  71699. /**
  71700. * Enable or disable the grain process from the pipeline
  71701. */
  71702. set grainEnabled(enabled: boolean);
  71703. get grainEnabled(): boolean;
  71704. /**
  71705. * @constructor
  71706. * @param name - The rendering pipeline name (default: "")
  71707. * @param hdr - If high dynamic range textures should be used (default: true)
  71708. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71709. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71710. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71711. */
  71712. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71713. /**
  71714. * Get the class name
  71715. * @returns "DefaultRenderingPipeline"
  71716. */
  71717. getClassName(): string;
  71718. /**
  71719. * Force the compilation of the entire pipeline.
  71720. */
  71721. prepare(): void;
  71722. private _hasCleared;
  71723. private _prevPostProcess;
  71724. private _prevPrevPostProcess;
  71725. private _setAutoClearAndTextureSharing;
  71726. private _depthOfFieldSceneObserver;
  71727. private _buildPipeline;
  71728. private _disposePostProcesses;
  71729. /**
  71730. * Adds a camera to the pipeline
  71731. * @param camera the camera to be added
  71732. */
  71733. addCamera(camera: Camera): void;
  71734. /**
  71735. * Removes a camera from the pipeline
  71736. * @param camera the camera to remove
  71737. */
  71738. removeCamera(camera: Camera): void;
  71739. /**
  71740. * Dispose of the pipeline and stop all post processes
  71741. */
  71742. dispose(): void;
  71743. /**
  71744. * Serialize the rendering pipeline (Used when exporting)
  71745. * @returns the serialized object
  71746. */
  71747. serialize(): any;
  71748. /**
  71749. * Parse the serialized pipeline
  71750. * @param source Source pipeline.
  71751. * @param scene The scene to load the pipeline to.
  71752. * @param rootUrl The URL of the serialized pipeline.
  71753. * @returns An instantiated pipeline from the serialized object.
  71754. */
  71755. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71756. }
  71757. }
  71758. declare module BABYLON {
  71759. /** @hidden */
  71760. export var lensHighlightsPixelShader: {
  71761. name: string;
  71762. shader: string;
  71763. };
  71764. }
  71765. declare module BABYLON {
  71766. /** @hidden */
  71767. export var depthOfFieldPixelShader: {
  71768. name: string;
  71769. shader: string;
  71770. };
  71771. }
  71772. declare module BABYLON {
  71773. /**
  71774. * BABYLON.JS Chromatic Aberration GLSL Shader
  71775. * Author: Olivier Guyot
  71776. * Separates very slightly R, G and B colors on the edges of the screen
  71777. * Inspired by Francois Tarlier & Martins Upitis
  71778. */
  71779. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71780. /**
  71781. * @ignore
  71782. * The chromatic aberration PostProcess id in the pipeline
  71783. */
  71784. LensChromaticAberrationEffect: string;
  71785. /**
  71786. * @ignore
  71787. * The highlights enhancing PostProcess id in the pipeline
  71788. */
  71789. HighlightsEnhancingEffect: string;
  71790. /**
  71791. * @ignore
  71792. * The depth-of-field PostProcess id in the pipeline
  71793. */
  71794. LensDepthOfFieldEffect: string;
  71795. private _scene;
  71796. private _depthTexture;
  71797. private _grainTexture;
  71798. private _chromaticAberrationPostProcess;
  71799. private _highlightsPostProcess;
  71800. private _depthOfFieldPostProcess;
  71801. private _edgeBlur;
  71802. private _grainAmount;
  71803. private _chromaticAberration;
  71804. private _distortion;
  71805. private _highlightsGain;
  71806. private _highlightsThreshold;
  71807. private _dofDistance;
  71808. private _dofAperture;
  71809. private _dofDarken;
  71810. private _dofPentagon;
  71811. private _blurNoise;
  71812. /**
  71813. * @constructor
  71814. *
  71815. * Effect parameters are as follow:
  71816. * {
  71817. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71818. * edge_blur: number; // from 0 to x (1 for realism)
  71819. * distortion: number; // from 0 to x (1 for realism)
  71820. * grain_amount: number; // from 0 to 1
  71821. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71822. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71823. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71824. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71825. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71826. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71827. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71828. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71829. * }
  71830. * Note: if an effect parameter is unset, effect is disabled
  71831. *
  71832. * @param name The rendering pipeline name
  71833. * @param parameters - An object containing all parameters (see above)
  71834. * @param scene The scene linked to this pipeline
  71835. * @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)
  71836. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71837. */
  71838. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71839. /**
  71840. * Get the class name
  71841. * @returns "LensRenderingPipeline"
  71842. */
  71843. getClassName(): string;
  71844. /**
  71845. * Gets associated scene
  71846. */
  71847. get scene(): Scene;
  71848. /**
  71849. * Gets or sets the edge blur
  71850. */
  71851. get edgeBlur(): number;
  71852. set edgeBlur(value: number);
  71853. /**
  71854. * Gets or sets the grain amount
  71855. */
  71856. get grainAmount(): number;
  71857. set grainAmount(value: number);
  71858. /**
  71859. * Gets or sets the chromatic aberration amount
  71860. */
  71861. get chromaticAberration(): number;
  71862. set chromaticAberration(value: number);
  71863. /**
  71864. * Gets or sets the depth of field aperture
  71865. */
  71866. get dofAperture(): number;
  71867. set dofAperture(value: number);
  71868. /**
  71869. * Gets or sets the edge distortion
  71870. */
  71871. get edgeDistortion(): number;
  71872. set edgeDistortion(value: number);
  71873. /**
  71874. * Gets or sets the depth of field distortion
  71875. */
  71876. get dofDistortion(): number;
  71877. set dofDistortion(value: number);
  71878. /**
  71879. * Gets or sets the darken out of focus amount
  71880. */
  71881. get darkenOutOfFocus(): number;
  71882. set darkenOutOfFocus(value: number);
  71883. /**
  71884. * Gets or sets a boolean indicating if blur noise is enabled
  71885. */
  71886. get blurNoise(): boolean;
  71887. set blurNoise(value: boolean);
  71888. /**
  71889. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71890. */
  71891. get pentagonBokeh(): boolean;
  71892. set pentagonBokeh(value: boolean);
  71893. /**
  71894. * Gets or sets the highlight grain amount
  71895. */
  71896. get highlightsGain(): number;
  71897. set highlightsGain(value: number);
  71898. /**
  71899. * Gets or sets the highlight threshold
  71900. */
  71901. get highlightsThreshold(): number;
  71902. set highlightsThreshold(value: number);
  71903. /**
  71904. * Sets the amount of blur at the edges
  71905. * @param amount blur amount
  71906. */
  71907. setEdgeBlur(amount: number): void;
  71908. /**
  71909. * Sets edge blur to 0
  71910. */
  71911. disableEdgeBlur(): void;
  71912. /**
  71913. * Sets the amout of grain
  71914. * @param amount Amount of grain
  71915. */
  71916. setGrainAmount(amount: number): void;
  71917. /**
  71918. * Set grain amount to 0
  71919. */
  71920. disableGrain(): void;
  71921. /**
  71922. * Sets the chromatic aberration amount
  71923. * @param amount amount of chromatic aberration
  71924. */
  71925. setChromaticAberration(amount: number): void;
  71926. /**
  71927. * Sets chromatic aberration amount to 0
  71928. */
  71929. disableChromaticAberration(): void;
  71930. /**
  71931. * Sets the EdgeDistortion amount
  71932. * @param amount amount of EdgeDistortion
  71933. */
  71934. setEdgeDistortion(amount: number): void;
  71935. /**
  71936. * Sets edge distortion to 0
  71937. */
  71938. disableEdgeDistortion(): void;
  71939. /**
  71940. * Sets the FocusDistance amount
  71941. * @param amount amount of FocusDistance
  71942. */
  71943. setFocusDistance(amount: number): void;
  71944. /**
  71945. * Disables depth of field
  71946. */
  71947. disableDepthOfField(): void;
  71948. /**
  71949. * Sets the Aperture amount
  71950. * @param amount amount of Aperture
  71951. */
  71952. setAperture(amount: number): void;
  71953. /**
  71954. * Sets the DarkenOutOfFocus amount
  71955. * @param amount amount of DarkenOutOfFocus
  71956. */
  71957. setDarkenOutOfFocus(amount: number): void;
  71958. private _pentagonBokehIsEnabled;
  71959. /**
  71960. * Creates a pentagon bokeh effect
  71961. */
  71962. enablePentagonBokeh(): void;
  71963. /**
  71964. * Disables the pentagon bokeh effect
  71965. */
  71966. disablePentagonBokeh(): void;
  71967. /**
  71968. * Enables noise blur
  71969. */
  71970. enableNoiseBlur(): void;
  71971. /**
  71972. * Disables noise blur
  71973. */
  71974. disableNoiseBlur(): void;
  71975. /**
  71976. * Sets the HighlightsGain amount
  71977. * @param amount amount of HighlightsGain
  71978. */
  71979. setHighlightsGain(amount: number): void;
  71980. /**
  71981. * Sets the HighlightsThreshold amount
  71982. * @param amount amount of HighlightsThreshold
  71983. */
  71984. setHighlightsThreshold(amount: number): void;
  71985. /**
  71986. * Disables highlights
  71987. */
  71988. disableHighlights(): void;
  71989. /**
  71990. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71991. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71992. */
  71993. dispose(disableDepthRender?: boolean): void;
  71994. private _createChromaticAberrationPostProcess;
  71995. private _createHighlightsPostProcess;
  71996. private _createDepthOfFieldPostProcess;
  71997. private _createGrainTexture;
  71998. }
  71999. }
  72000. declare module BABYLON {
  72001. /**
  72002. * Contains all parameters needed for the prepass to perform
  72003. * screen space subsurface scattering
  72004. */
  72005. export class SSAO2Configuration implements PrePassEffectConfiguration {
  72006. /**
  72007. * Is subsurface enabled
  72008. */
  72009. enabled: boolean;
  72010. /**
  72011. * Name of the configuration
  72012. */
  72013. name: string;
  72014. /**
  72015. * Textures that should be present in the MRT for this effect to work
  72016. */
  72017. readonly texturesRequired: number[];
  72018. }
  72019. }
  72020. declare module BABYLON {
  72021. /** @hidden */
  72022. export var ssao2PixelShader: {
  72023. name: string;
  72024. shader: string;
  72025. };
  72026. }
  72027. declare module BABYLON {
  72028. /** @hidden */
  72029. export var ssaoCombinePixelShader: {
  72030. name: string;
  72031. shader: string;
  72032. };
  72033. }
  72034. declare module BABYLON {
  72035. /**
  72036. * Render pipeline to produce ssao effect
  72037. */
  72038. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  72039. /**
  72040. * @ignore
  72041. * The PassPostProcess id in the pipeline that contains the original scene color
  72042. */
  72043. SSAOOriginalSceneColorEffect: string;
  72044. /**
  72045. * @ignore
  72046. * The SSAO PostProcess id in the pipeline
  72047. */
  72048. SSAORenderEffect: string;
  72049. /**
  72050. * @ignore
  72051. * The horizontal blur PostProcess id in the pipeline
  72052. */
  72053. SSAOBlurHRenderEffect: string;
  72054. /**
  72055. * @ignore
  72056. * The vertical blur PostProcess id in the pipeline
  72057. */
  72058. SSAOBlurVRenderEffect: string;
  72059. /**
  72060. * @ignore
  72061. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72062. */
  72063. SSAOCombineRenderEffect: string;
  72064. /**
  72065. * The output strength of the SSAO post-process. Default value is 1.0.
  72066. */
  72067. totalStrength: number;
  72068. /**
  72069. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72070. */
  72071. maxZ: number;
  72072. /**
  72073. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72074. */
  72075. minZAspect: number;
  72076. private _samples;
  72077. /**
  72078. * Number of samples used for the SSAO calculations. Default value is 8
  72079. */
  72080. set samples(n: number);
  72081. get samples(): number;
  72082. private _textureSamples;
  72083. /**
  72084. * Number of samples to use for antialiasing
  72085. */
  72086. set textureSamples(n: number);
  72087. get textureSamples(): number;
  72088. /**
  72089. * Force rendering the geometry through geometry buffer
  72090. */
  72091. private _forceGeometryBuffer;
  72092. /**
  72093. * Ratio object used for SSAO ratio and blur ratio
  72094. */
  72095. private _ratio;
  72096. /**
  72097. * Dynamically generated sphere sampler.
  72098. */
  72099. private _sampleSphere;
  72100. /**
  72101. * Blur filter offsets
  72102. */
  72103. private _samplerOffsets;
  72104. private _expensiveBlur;
  72105. /**
  72106. * If bilateral blur should be used
  72107. */
  72108. set expensiveBlur(b: boolean);
  72109. get expensiveBlur(): boolean;
  72110. /**
  72111. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72112. */
  72113. radius: number;
  72114. /**
  72115. * The base color of the SSAO post-process
  72116. * The final result is "base + ssao" between [0, 1]
  72117. */
  72118. base: number;
  72119. /**
  72120. * Support test.
  72121. */
  72122. static get IsSupported(): boolean;
  72123. private _scene;
  72124. private _randomTexture;
  72125. private _originalColorPostProcess;
  72126. private _ssaoPostProcess;
  72127. private _blurHPostProcess;
  72128. private _blurVPostProcess;
  72129. private _ssaoCombinePostProcess;
  72130. private _prePassRenderer;
  72131. /**
  72132. * Gets active scene
  72133. */
  72134. get scene(): Scene;
  72135. /**
  72136. * @constructor
  72137. * @param name The rendering pipeline name
  72138. * @param scene The scene linked to this pipeline
  72139. * @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 }
  72140. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72141. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  72142. */
  72143. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  72144. /**
  72145. * Get the class name
  72146. * @returns "SSAO2RenderingPipeline"
  72147. */
  72148. getClassName(): string;
  72149. /**
  72150. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72151. */
  72152. dispose(disableGeometryBufferRenderer?: boolean): void;
  72153. private _createBlurPostProcess;
  72154. /** @hidden */
  72155. _rebuild(): void;
  72156. private _bits;
  72157. private _radicalInverse_VdC;
  72158. private _hammersley;
  72159. private _hemisphereSample_uniform;
  72160. private _generateHemisphere;
  72161. private _getDefinesForSSAO;
  72162. private _createSSAOPostProcess;
  72163. private _createSSAOCombinePostProcess;
  72164. private _createRandomTexture;
  72165. /**
  72166. * Serialize the rendering pipeline (Used when exporting)
  72167. * @returns the serialized object
  72168. */
  72169. serialize(): any;
  72170. /**
  72171. * Parse the serialized pipeline
  72172. * @param source Source pipeline.
  72173. * @param scene The scene to load the pipeline to.
  72174. * @param rootUrl The URL of the serialized pipeline.
  72175. * @returns An instantiated pipeline from the serialized object.
  72176. */
  72177. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72178. }
  72179. }
  72180. declare module BABYLON {
  72181. /** @hidden */
  72182. export var ssaoPixelShader: {
  72183. name: string;
  72184. shader: string;
  72185. };
  72186. }
  72187. declare module BABYLON {
  72188. /**
  72189. * Render pipeline to produce ssao effect
  72190. */
  72191. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72192. /**
  72193. * @ignore
  72194. * The PassPostProcess id in the pipeline that contains the original scene color
  72195. */
  72196. SSAOOriginalSceneColorEffect: string;
  72197. /**
  72198. * @ignore
  72199. * The SSAO PostProcess id in the pipeline
  72200. */
  72201. SSAORenderEffect: string;
  72202. /**
  72203. * @ignore
  72204. * The horizontal blur PostProcess id in the pipeline
  72205. */
  72206. SSAOBlurHRenderEffect: string;
  72207. /**
  72208. * @ignore
  72209. * The vertical blur PostProcess id in the pipeline
  72210. */
  72211. SSAOBlurVRenderEffect: string;
  72212. /**
  72213. * @ignore
  72214. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72215. */
  72216. SSAOCombineRenderEffect: string;
  72217. /**
  72218. * The output strength of the SSAO post-process. Default value is 1.0.
  72219. */
  72220. totalStrength: number;
  72221. /**
  72222. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72223. */
  72224. radius: number;
  72225. /**
  72226. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72227. * Must not be equal to fallOff and superior to fallOff.
  72228. * Default value is 0.0075
  72229. */
  72230. area: number;
  72231. /**
  72232. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72233. * Must not be equal to area and inferior to area.
  72234. * Default value is 0.000001
  72235. */
  72236. fallOff: number;
  72237. /**
  72238. * The base color of the SSAO post-process
  72239. * The final result is "base + ssao" between [0, 1]
  72240. */
  72241. base: number;
  72242. private _scene;
  72243. private _depthTexture;
  72244. private _randomTexture;
  72245. private _originalColorPostProcess;
  72246. private _ssaoPostProcess;
  72247. private _blurHPostProcess;
  72248. private _blurVPostProcess;
  72249. private _ssaoCombinePostProcess;
  72250. private _firstUpdate;
  72251. /**
  72252. * Gets active scene
  72253. */
  72254. get scene(): Scene;
  72255. /**
  72256. * @constructor
  72257. * @param name - The rendering pipeline name
  72258. * @param scene - The scene linked to this pipeline
  72259. * @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 }
  72260. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72261. */
  72262. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72263. /**
  72264. * Get the class name
  72265. * @returns "SSAORenderingPipeline"
  72266. */
  72267. getClassName(): string;
  72268. /**
  72269. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72270. */
  72271. dispose(disableDepthRender?: boolean): void;
  72272. private _createBlurPostProcess;
  72273. /** @hidden */
  72274. _rebuild(): void;
  72275. private _createSSAOPostProcess;
  72276. private _createSSAOCombinePostProcess;
  72277. private _createRandomTexture;
  72278. }
  72279. }
  72280. declare module BABYLON {
  72281. /**
  72282. * Contains all parameters needed for the prepass to perform
  72283. * screen space reflections
  72284. */
  72285. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72286. /**
  72287. * Is ssr enabled
  72288. */
  72289. enabled: boolean;
  72290. /**
  72291. * Name of the configuration
  72292. */
  72293. name: string;
  72294. /**
  72295. * Textures that should be present in the MRT for this effect to work
  72296. */
  72297. readonly texturesRequired: number[];
  72298. }
  72299. }
  72300. declare module BABYLON {
  72301. /** @hidden */
  72302. export var screenSpaceReflectionPixelShader: {
  72303. name: string;
  72304. shader: string;
  72305. };
  72306. }
  72307. declare module BABYLON {
  72308. /**
  72309. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72310. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72311. */
  72312. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72313. /**
  72314. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72315. */
  72316. threshold: number;
  72317. /**
  72318. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72319. */
  72320. strength: number;
  72321. /**
  72322. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72323. */
  72324. reflectionSpecularFalloffExponent: number;
  72325. /**
  72326. * 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]
  72327. */
  72328. step: number;
  72329. /**
  72330. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72331. */
  72332. roughnessFactor: number;
  72333. private _forceGeometryBuffer;
  72334. private _geometryBufferRenderer;
  72335. private _prePassRenderer;
  72336. private _enableSmoothReflections;
  72337. private _reflectionSamples;
  72338. private _smoothSteps;
  72339. /**
  72340. * Gets a string identifying the name of the class
  72341. * @returns "ScreenSpaceReflectionPostProcess" string
  72342. */
  72343. getClassName(): string;
  72344. /**
  72345. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72346. * @param name The name of the effect.
  72347. * @param scene The scene containing the objects to calculate reflections.
  72348. * @param options The required width/height ratio to downsize to before computing the render pass.
  72349. * @param camera The camera to apply the render pass to.
  72350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72351. * @param engine The engine which the post process will be applied. (default: current engine)
  72352. * @param reusable If the post process can be reused on the same frame. (default: false)
  72353. * @param textureType Type of textures used when performing the post process. (default: 0)
  72354. * @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)
  72355. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72356. */
  72357. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72358. /**
  72359. * Gets wether or not smoothing reflections is enabled.
  72360. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72361. */
  72362. get enableSmoothReflections(): boolean;
  72363. /**
  72364. * Sets wether or not smoothing reflections is enabled.
  72365. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72366. */
  72367. set enableSmoothReflections(enabled: boolean);
  72368. /**
  72369. * Gets the number of samples taken while computing reflections. More samples count is high,
  72370. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72371. */
  72372. get reflectionSamples(): number;
  72373. /**
  72374. * Sets the number of samples taken while computing reflections. More samples count is high,
  72375. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72376. */
  72377. set reflectionSamples(samples: number);
  72378. /**
  72379. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72380. * more the post-process will require GPU power and can generate a drop in FPS.
  72381. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72382. */
  72383. get smoothSteps(): number;
  72384. set smoothSteps(steps: number);
  72385. private _updateEffectDefines;
  72386. /** @hidden */
  72387. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72388. }
  72389. }
  72390. declare module BABYLON {
  72391. /** @hidden */
  72392. export var standardPixelShader: {
  72393. name: string;
  72394. shader: string;
  72395. };
  72396. }
  72397. declare module BABYLON {
  72398. /**
  72399. * Standard rendering pipeline
  72400. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72401. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72402. */
  72403. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72404. /**
  72405. * Public members
  72406. */
  72407. /**
  72408. * Post-process which contains the original scene color before the pipeline applies all the effects
  72409. */
  72410. originalPostProcess: Nullable<PostProcess>;
  72411. /**
  72412. * Post-process used to down scale an image x4
  72413. */
  72414. downSampleX4PostProcess: Nullable<PostProcess>;
  72415. /**
  72416. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72417. */
  72418. brightPassPostProcess: Nullable<PostProcess>;
  72419. /**
  72420. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72421. */
  72422. blurHPostProcesses: PostProcess[];
  72423. /**
  72424. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72425. */
  72426. blurVPostProcesses: PostProcess[];
  72427. /**
  72428. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72429. */
  72430. textureAdderPostProcess: Nullable<PostProcess>;
  72431. /**
  72432. * Post-process used to create volumetric lighting effect
  72433. */
  72434. volumetricLightPostProcess: Nullable<PostProcess>;
  72435. /**
  72436. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72437. */
  72438. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72439. /**
  72440. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72441. */
  72442. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72443. /**
  72444. * Post-process used to merge the volumetric light effect and the real scene color
  72445. */
  72446. volumetricLightMergePostProces: Nullable<PostProcess>;
  72447. /**
  72448. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72449. */
  72450. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72451. /**
  72452. * Base post-process used to calculate the average luminance of the final image for HDR
  72453. */
  72454. luminancePostProcess: Nullable<PostProcess>;
  72455. /**
  72456. * Post-processes used to create down sample post-processes in order to get
  72457. * the average luminance of the final image for HDR
  72458. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72459. */
  72460. luminanceDownSamplePostProcesses: PostProcess[];
  72461. /**
  72462. * Post-process used to create a HDR effect (light adaptation)
  72463. */
  72464. hdrPostProcess: Nullable<PostProcess>;
  72465. /**
  72466. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72467. */
  72468. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72469. /**
  72470. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72471. */
  72472. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72473. /**
  72474. * Post-process used to merge the final HDR post-process and the real scene color
  72475. */
  72476. hdrFinalPostProcess: Nullable<PostProcess>;
  72477. /**
  72478. * Post-process used to create a lens flare effect
  72479. */
  72480. lensFlarePostProcess: Nullable<PostProcess>;
  72481. /**
  72482. * Post-process that merges the result of the lens flare post-process and the real scene color
  72483. */
  72484. lensFlareComposePostProcess: Nullable<PostProcess>;
  72485. /**
  72486. * Post-process used to create a motion blur effect
  72487. */
  72488. motionBlurPostProcess: Nullable<PostProcess>;
  72489. /**
  72490. * Post-process used to create a depth of field effect
  72491. */
  72492. depthOfFieldPostProcess: Nullable<PostProcess>;
  72493. /**
  72494. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72495. */
  72496. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72497. /**
  72498. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72499. */
  72500. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72501. /**
  72502. * Represents the brightness threshold in order to configure the illuminated surfaces
  72503. */
  72504. brightThreshold: number;
  72505. /**
  72506. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72507. */
  72508. blurWidth: number;
  72509. /**
  72510. * Sets if the blur for highlighted surfaces must be only horizontal
  72511. */
  72512. horizontalBlur: boolean;
  72513. /**
  72514. * Gets the overall exposure used by the pipeline
  72515. */
  72516. get exposure(): number;
  72517. /**
  72518. * Sets the overall exposure used by the pipeline
  72519. */
  72520. set exposure(value: number);
  72521. /**
  72522. * Texture used typically to simulate "dirty" on camera lens
  72523. */
  72524. lensTexture: Nullable<Texture>;
  72525. /**
  72526. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72527. */
  72528. volumetricLightCoefficient: number;
  72529. /**
  72530. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72531. */
  72532. volumetricLightPower: number;
  72533. /**
  72534. * Used the set the blur intensity to smooth the volumetric lights
  72535. */
  72536. volumetricLightBlurScale: number;
  72537. /**
  72538. * Light (spot or directional) used to generate the volumetric lights rays
  72539. * The source light must have a shadow generate so the pipeline can get its
  72540. * depth map
  72541. */
  72542. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72543. /**
  72544. * For eye adaptation, represents the minimum luminance the eye can see
  72545. */
  72546. hdrMinimumLuminance: number;
  72547. /**
  72548. * For eye adaptation, represents the decrease luminance speed
  72549. */
  72550. hdrDecreaseRate: number;
  72551. /**
  72552. * For eye adaptation, represents the increase luminance speed
  72553. */
  72554. hdrIncreaseRate: number;
  72555. /**
  72556. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72557. */
  72558. get hdrAutoExposure(): boolean;
  72559. /**
  72560. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72561. */
  72562. set hdrAutoExposure(value: boolean);
  72563. /**
  72564. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72565. */
  72566. lensColorTexture: Nullable<Texture>;
  72567. /**
  72568. * The overall strengh for the lens flare effect
  72569. */
  72570. lensFlareStrength: number;
  72571. /**
  72572. * Dispersion coefficient for lens flare ghosts
  72573. */
  72574. lensFlareGhostDispersal: number;
  72575. /**
  72576. * Main lens flare halo width
  72577. */
  72578. lensFlareHaloWidth: number;
  72579. /**
  72580. * Based on the lens distortion effect, defines how much the lens flare result
  72581. * is distorted
  72582. */
  72583. lensFlareDistortionStrength: number;
  72584. /**
  72585. * Configures the blur intensity used for for lens flare (halo)
  72586. */
  72587. lensFlareBlurWidth: number;
  72588. /**
  72589. * Lens star texture must be used to simulate rays on the flares and is available
  72590. * in the documentation
  72591. */
  72592. lensStarTexture: Nullable<Texture>;
  72593. /**
  72594. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72595. * flare effect by taking account of the dirt texture
  72596. */
  72597. lensFlareDirtTexture: Nullable<Texture>;
  72598. /**
  72599. * Represents the focal length for the depth of field effect
  72600. */
  72601. depthOfFieldDistance: number;
  72602. /**
  72603. * Represents the blur intensity for the blurred part of the depth of field effect
  72604. */
  72605. depthOfFieldBlurWidth: number;
  72606. /**
  72607. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72608. */
  72609. get motionStrength(): number;
  72610. /**
  72611. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72612. */
  72613. set motionStrength(strength: number);
  72614. /**
  72615. * Gets wether or not the motion blur post-process is object based or screen based.
  72616. */
  72617. get objectBasedMotionBlur(): boolean;
  72618. /**
  72619. * Sets wether or not the motion blur post-process should be object based or screen based
  72620. */
  72621. set objectBasedMotionBlur(value: boolean);
  72622. /**
  72623. * List of animations for the pipeline (IAnimatable implementation)
  72624. */
  72625. animations: Animation[];
  72626. /**
  72627. * Private members
  72628. */
  72629. private _scene;
  72630. private _currentDepthOfFieldSource;
  72631. private _basePostProcess;
  72632. private _fixedExposure;
  72633. private _currentExposure;
  72634. private _hdrAutoExposure;
  72635. private _hdrCurrentLuminance;
  72636. private _motionStrength;
  72637. private _isObjectBasedMotionBlur;
  72638. private _floatTextureType;
  72639. private _camerasToBeAttached;
  72640. private _ratio;
  72641. private _bloomEnabled;
  72642. private _depthOfFieldEnabled;
  72643. private _vlsEnabled;
  72644. private _lensFlareEnabled;
  72645. private _hdrEnabled;
  72646. private _motionBlurEnabled;
  72647. private _fxaaEnabled;
  72648. private _screenSpaceReflectionsEnabled;
  72649. private _motionBlurSamples;
  72650. private _volumetricLightStepsCount;
  72651. private _samples;
  72652. /**
  72653. * @ignore
  72654. * Specifies if the bloom pipeline is enabled
  72655. */
  72656. get BloomEnabled(): boolean;
  72657. set BloomEnabled(enabled: boolean);
  72658. /**
  72659. * @ignore
  72660. * Specifies if the depth of field pipeline is enabed
  72661. */
  72662. get DepthOfFieldEnabled(): boolean;
  72663. set DepthOfFieldEnabled(enabled: boolean);
  72664. /**
  72665. * @ignore
  72666. * Specifies if the lens flare pipeline is enabed
  72667. */
  72668. get LensFlareEnabled(): boolean;
  72669. set LensFlareEnabled(enabled: boolean);
  72670. /**
  72671. * @ignore
  72672. * Specifies if the HDR pipeline is enabled
  72673. */
  72674. get HDREnabled(): boolean;
  72675. set HDREnabled(enabled: boolean);
  72676. /**
  72677. * @ignore
  72678. * Specifies if the volumetric lights scattering effect is enabled
  72679. */
  72680. get VLSEnabled(): boolean;
  72681. set VLSEnabled(enabled: boolean);
  72682. /**
  72683. * @ignore
  72684. * Specifies if the motion blur effect is enabled
  72685. */
  72686. get MotionBlurEnabled(): boolean;
  72687. set MotionBlurEnabled(enabled: boolean);
  72688. /**
  72689. * Specifies if anti-aliasing is enabled
  72690. */
  72691. get fxaaEnabled(): boolean;
  72692. set fxaaEnabled(enabled: boolean);
  72693. /**
  72694. * Specifies if screen space reflections are enabled.
  72695. */
  72696. get screenSpaceReflectionsEnabled(): boolean;
  72697. set screenSpaceReflectionsEnabled(enabled: boolean);
  72698. /**
  72699. * Specifies the number of steps used to calculate the volumetric lights
  72700. * Typically in interval [50, 200]
  72701. */
  72702. get volumetricLightStepsCount(): number;
  72703. set volumetricLightStepsCount(count: number);
  72704. /**
  72705. * Specifies the number of samples used for the motion blur effect
  72706. * Typically in interval [16, 64]
  72707. */
  72708. get motionBlurSamples(): number;
  72709. set motionBlurSamples(samples: number);
  72710. /**
  72711. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72712. */
  72713. get samples(): number;
  72714. set samples(sampleCount: number);
  72715. /**
  72716. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72717. * @constructor
  72718. * @param name The rendering pipeline name
  72719. * @param scene The scene linked to this pipeline
  72720. * @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)
  72721. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72722. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72723. */
  72724. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72725. private _buildPipeline;
  72726. private _createDownSampleX4PostProcess;
  72727. private _createBrightPassPostProcess;
  72728. private _createBlurPostProcesses;
  72729. private _createTextureAdderPostProcess;
  72730. private _createVolumetricLightPostProcess;
  72731. private _createLuminancePostProcesses;
  72732. private _createHdrPostProcess;
  72733. private _createLensFlarePostProcess;
  72734. private _createDepthOfFieldPostProcess;
  72735. private _createMotionBlurPostProcess;
  72736. private _getDepthTexture;
  72737. private _disposePostProcesses;
  72738. /**
  72739. * Dispose of the pipeline and stop all post processes
  72740. */
  72741. dispose(): void;
  72742. /**
  72743. * Serialize the rendering pipeline (Used when exporting)
  72744. * @returns the serialized object
  72745. */
  72746. serialize(): any;
  72747. /**
  72748. * Parse the serialized pipeline
  72749. * @param source Source pipeline.
  72750. * @param scene The scene to load the pipeline to.
  72751. * @param rootUrl The URL of the serialized pipeline.
  72752. * @returns An instantiated pipeline from the serialized object.
  72753. */
  72754. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72755. /**
  72756. * Luminance steps
  72757. */
  72758. static LuminanceSteps: number;
  72759. }
  72760. }
  72761. declare module BABYLON {
  72762. /** @hidden */
  72763. export var stereoscopicInterlacePixelShader: {
  72764. name: string;
  72765. shader: string;
  72766. };
  72767. }
  72768. declare module BABYLON {
  72769. /**
  72770. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72771. */
  72772. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72773. private _stepSize;
  72774. private _passedProcess;
  72775. /**
  72776. * Gets a string identifying the name of the class
  72777. * @returns "StereoscopicInterlacePostProcessI" string
  72778. */
  72779. getClassName(): string;
  72780. /**
  72781. * Initializes a StereoscopicInterlacePostProcessI
  72782. * @param name The name of the effect.
  72783. * @param rigCameras The rig cameras to be appled to the post process
  72784. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72785. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72787. * @param engine The engine which the post process will be applied. (default: current engine)
  72788. * @param reusable If the post process can be reused on the same frame. (default: false)
  72789. */
  72790. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72791. }
  72792. /**
  72793. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72794. */
  72795. export class StereoscopicInterlacePostProcess extends PostProcess {
  72796. private _stepSize;
  72797. private _passedProcess;
  72798. /**
  72799. * Gets a string identifying the name of the class
  72800. * @returns "StereoscopicInterlacePostProcess" string
  72801. */
  72802. getClassName(): string;
  72803. /**
  72804. * Initializes a StereoscopicInterlacePostProcess
  72805. * @param name The name of the effect.
  72806. * @param rigCameras The rig cameras to be appled to the post process
  72807. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72809. * @param engine The engine which the post process will be applied. (default: current engine)
  72810. * @param reusable If the post process can be reused on the same frame. (default: false)
  72811. */
  72812. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72813. }
  72814. }
  72815. declare module BABYLON {
  72816. /** @hidden */
  72817. export var tonemapPixelShader: {
  72818. name: string;
  72819. shader: string;
  72820. };
  72821. }
  72822. declare module BABYLON {
  72823. /** Defines operator used for tonemapping */
  72824. export enum TonemappingOperator {
  72825. /** Hable */
  72826. Hable = 0,
  72827. /** Reinhard */
  72828. Reinhard = 1,
  72829. /** HejiDawson */
  72830. HejiDawson = 2,
  72831. /** Photographic */
  72832. Photographic = 3
  72833. }
  72834. /**
  72835. * Defines a post process to apply tone mapping
  72836. */
  72837. export class TonemapPostProcess extends PostProcess {
  72838. private _operator;
  72839. /** Defines the required exposure adjustement */
  72840. exposureAdjustment: number;
  72841. /**
  72842. * Gets a string identifying the name of the class
  72843. * @returns "TonemapPostProcess" string
  72844. */
  72845. getClassName(): string;
  72846. /**
  72847. * Creates a new TonemapPostProcess
  72848. * @param name defines the name of the postprocess
  72849. * @param _operator defines the operator to use
  72850. * @param exposureAdjustment defines the required exposure adjustement
  72851. * @param camera defines the camera to use (can be null)
  72852. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72853. * @param engine defines the hosting engine (can be ignore if camera is set)
  72854. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72855. */
  72856. constructor(name: string, _operator: TonemappingOperator,
  72857. /** Defines the required exposure adjustement */
  72858. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72859. }
  72860. }
  72861. declare module BABYLON {
  72862. /** @hidden */
  72863. export var volumetricLightScatteringPixelShader: {
  72864. name: string;
  72865. shader: string;
  72866. };
  72867. }
  72868. declare module BABYLON {
  72869. /** @hidden */
  72870. export var volumetricLightScatteringPassVertexShader: {
  72871. name: string;
  72872. shader: string;
  72873. };
  72874. }
  72875. declare module BABYLON {
  72876. /** @hidden */
  72877. export var volumetricLightScatteringPassPixelShader: {
  72878. name: string;
  72879. shader: string;
  72880. };
  72881. }
  72882. declare module BABYLON {
  72883. /**
  72884. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72885. */
  72886. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72887. private _volumetricLightScatteringPass;
  72888. private _volumetricLightScatteringRTT;
  72889. private _viewPort;
  72890. private _screenCoordinates;
  72891. private _cachedDefines;
  72892. /**
  72893. * If not undefined, the mesh position is computed from the attached node position
  72894. */
  72895. attachedNode: {
  72896. position: Vector3;
  72897. };
  72898. /**
  72899. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72900. */
  72901. customMeshPosition: Vector3;
  72902. /**
  72903. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72904. */
  72905. useCustomMeshPosition: boolean;
  72906. /**
  72907. * If the post-process should inverse the light scattering direction
  72908. */
  72909. invert: boolean;
  72910. /**
  72911. * The internal mesh used by the post-process
  72912. */
  72913. mesh: Mesh;
  72914. /**
  72915. * @hidden
  72916. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72917. */
  72918. get useDiffuseColor(): boolean;
  72919. set useDiffuseColor(useDiffuseColor: boolean);
  72920. /**
  72921. * Array containing the excluded meshes not rendered in the internal pass
  72922. */
  72923. excludedMeshes: AbstractMesh[];
  72924. /**
  72925. * Controls the overall intensity of the post-process
  72926. */
  72927. exposure: number;
  72928. /**
  72929. * Dissipates each sample's contribution in range [0, 1]
  72930. */
  72931. decay: number;
  72932. /**
  72933. * Controls the overall intensity of each sample
  72934. */
  72935. weight: number;
  72936. /**
  72937. * Controls the density of each sample
  72938. */
  72939. density: number;
  72940. /**
  72941. * @constructor
  72942. * @param name The post-process name
  72943. * @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)
  72944. * @param camera The camera that the post-process will be attached to
  72945. * @param mesh The mesh used to create the light scattering
  72946. * @param samples The post-process quality, default 100
  72947. * @param samplingModeThe post-process filtering mode
  72948. * @param engine The babylon engine
  72949. * @param reusable If the post-process is reusable
  72950. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72951. */
  72952. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72953. /**
  72954. * Returns the string "VolumetricLightScatteringPostProcess"
  72955. * @returns "VolumetricLightScatteringPostProcess"
  72956. */
  72957. getClassName(): string;
  72958. private _isReady;
  72959. /**
  72960. * Sets the new light position for light scattering effect
  72961. * @param position The new custom light position
  72962. */
  72963. setCustomMeshPosition(position: Vector3): void;
  72964. /**
  72965. * Returns the light position for light scattering effect
  72966. * @return Vector3 The custom light position
  72967. */
  72968. getCustomMeshPosition(): Vector3;
  72969. /**
  72970. * Disposes the internal assets and detaches the post-process from the camera
  72971. */
  72972. dispose(camera: Camera): void;
  72973. /**
  72974. * Returns the render target texture used by the post-process
  72975. * @return the render target texture used by the post-process
  72976. */
  72977. getPass(): RenderTargetTexture;
  72978. private _meshExcluded;
  72979. private _createPass;
  72980. private _updateMeshScreenCoordinates;
  72981. /**
  72982. * Creates a default mesh for the Volumeric Light Scattering post-process
  72983. * @param name The mesh name
  72984. * @param scene The scene where to create the mesh
  72985. * @return the default mesh
  72986. */
  72987. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72988. }
  72989. }
  72990. declare module BABYLON {
  72991. /** @hidden */
  72992. export var screenSpaceCurvaturePixelShader: {
  72993. name: string;
  72994. shader: string;
  72995. };
  72996. }
  72997. declare module BABYLON {
  72998. /**
  72999. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  73000. */
  73001. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  73002. /**
  73003. * Defines how much ridge the curvature effect displays.
  73004. */
  73005. ridge: number;
  73006. /**
  73007. * Defines how much valley the curvature effect displays.
  73008. */
  73009. valley: number;
  73010. private _geometryBufferRenderer;
  73011. /**
  73012. * Gets a string identifying the name of the class
  73013. * @returns "ScreenSpaceCurvaturePostProcess" string
  73014. */
  73015. getClassName(): string;
  73016. /**
  73017. * Creates a new instance ScreenSpaceCurvaturePostProcess
  73018. * @param name The name of the effect.
  73019. * @param scene The scene containing the objects to blur according to their velocity.
  73020. * @param options The required width/height ratio to downsize to before computing the render pass.
  73021. * @param camera The camera to apply the render pass to.
  73022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73023. * @param engine The engine which the post process will be applied. (default: current engine)
  73024. * @param reusable If the post process can be reused on the same frame. (default: false)
  73025. * @param textureType Type of textures used when performing the post process. (default: 0)
  73026. * @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)
  73027. */
  73028. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73029. /**
  73030. * Support test.
  73031. */
  73032. static get IsSupported(): boolean;
  73033. /** @hidden */
  73034. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  73035. }
  73036. }
  73037. declare module BABYLON {
  73038. interface Scene {
  73039. /** @hidden (Backing field) */
  73040. _boundingBoxRenderer: BoundingBoxRenderer;
  73041. /** @hidden (Backing field) */
  73042. _forceShowBoundingBoxes: boolean;
  73043. /**
  73044. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73045. */
  73046. forceShowBoundingBoxes: boolean;
  73047. /**
  73048. * Gets the bounding box renderer associated with the scene
  73049. * @returns a BoundingBoxRenderer
  73050. */
  73051. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73052. }
  73053. interface AbstractMesh {
  73054. /** @hidden (Backing field) */
  73055. _showBoundingBox: boolean;
  73056. /**
  73057. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73058. */
  73059. showBoundingBox: boolean;
  73060. }
  73061. /**
  73062. * Component responsible of rendering the bounding box of the meshes in a scene.
  73063. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73064. */
  73065. export class BoundingBoxRenderer implements ISceneComponent {
  73066. /**
  73067. * The component name helpfull to identify the component in the list of scene components.
  73068. */
  73069. readonly name: string;
  73070. /**
  73071. * The scene the component belongs to.
  73072. */
  73073. scene: Scene;
  73074. /**
  73075. * Color of the bounding box lines placed in front of an object
  73076. */
  73077. frontColor: Color3;
  73078. /**
  73079. * Color of the bounding box lines placed behind an object
  73080. */
  73081. backColor: Color3;
  73082. /**
  73083. * Defines if the renderer should show the back lines or not
  73084. */
  73085. showBackLines: boolean;
  73086. /**
  73087. * Observable raised before rendering a bounding box
  73088. */
  73089. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73090. /**
  73091. * Observable raised after rendering a bounding box
  73092. */
  73093. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73094. /**
  73095. * Observable raised after resources are created
  73096. */
  73097. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  73098. /**
  73099. * When false, no bounding boxes will be rendered
  73100. */
  73101. enabled: boolean;
  73102. /**
  73103. * @hidden
  73104. */
  73105. renderList: SmartArray<BoundingBox>;
  73106. private _colorShader;
  73107. private _vertexBuffers;
  73108. private _indexBuffer;
  73109. private _fillIndexBuffer;
  73110. private _fillIndexData;
  73111. /**
  73112. * Instantiates a new bounding box renderer in a scene.
  73113. * @param scene the scene the renderer renders in
  73114. */
  73115. constructor(scene: Scene);
  73116. /**
  73117. * Registers the component in a given scene
  73118. */
  73119. register(): void;
  73120. private _evaluateSubMesh;
  73121. private _preActiveMesh;
  73122. private _prepareResources;
  73123. private _createIndexBuffer;
  73124. /**
  73125. * Rebuilds the elements related to this component in case of
  73126. * context lost for instance.
  73127. */
  73128. rebuild(): void;
  73129. /**
  73130. * @hidden
  73131. */
  73132. reset(): void;
  73133. /**
  73134. * Render the bounding boxes of a specific rendering group
  73135. * @param renderingGroupId defines the rendering group to render
  73136. */
  73137. render(renderingGroupId: number): void;
  73138. /**
  73139. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73140. * @param mesh Define the mesh to render the occlusion bounding box for
  73141. */
  73142. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73143. /**
  73144. * Dispose and release the resources attached to this renderer.
  73145. */
  73146. dispose(): void;
  73147. }
  73148. }
  73149. declare module BABYLON {
  73150. interface Scene {
  73151. /** @hidden (Backing field) */
  73152. _depthRenderer: {
  73153. [id: string]: DepthRenderer;
  73154. };
  73155. /**
  73156. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73157. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73158. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73159. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  73160. * @returns the created depth renderer
  73161. */
  73162. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  73163. /**
  73164. * Disables a depth renderer for a given camera
  73165. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73166. */
  73167. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73168. }
  73169. /**
  73170. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73171. * in several rendering techniques.
  73172. */
  73173. export class DepthRendererSceneComponent implements ISceneComponent {
  73174. /**
  73175. * The component name helpfull to identify the component in the list of scene components.
  73176. */
  73177. readonly name: string;
  73178. /**
  73179. * The scene the component belongs to.
  73180. */
  73181. scene: Scene;
  73182. /**
  73183. * Creates a new instance of the component for the given scene
  73184. * @param scene Defines the scene to register the component in
  73185. */
  73186. constructor(scene: Scene);
  73187. /**
  73188. * Registers the component in a given scene
  73189. */
  73190. register(): void;
  73191. /**
  73192. * Rebuilds the elements related to this component in case of
  73193. * context lost for instance.
  73194. */
  73195. rebuild(): void;
  73196. /**
  73197. * Disposes the component and the associated ressources
  73198. */
  73199. dispose(): void;
  73200. private _gatherRenderTargets;
  73201. private _gatherActiveCameraRenderTargets;
  73202. }
  73203. }
  73204. declare module BABYLON {
  73205. interface AbstractScene {
  73206. /** @hidden (Backing field) */
  73207. _prePassRenderer: Nullable<PrePassRenderer>;
  73208. /**
  73209. * Gets or Sets the current prepass renderer associated to the scene.
  73210. */
  73211. prePassRenderer: Nullable<PrePassRenderer>;
  73212. /**
  73213. * Enables the prepass and associates it with the scene
  73214. * @returns the PrePassRenderer
  73215. */
  73216. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  73217. /**
  73218. * Disables the prepass associated with the scene
  73219. */
  73220. disablePrePassRenderer(): void;
  73221. }
  73222. /**
  73223. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73224. * in several rendering techniques.
  73225. */
  73226. export class PrePassRendererSceneComponent implements ISceneComponent {
  73227. /**
  73228. * The component name helpful to identify the component in the list of scene components.
  73229. */
  73230. readonly name: string;
  73231. /**
  73232. * The scene the component belongs to.
  73233. */
  73234. scene: Scene;
  73235. /**
  73236. * Creates a new instance of the component for the given scene
  73237. * @param scene Defines the scene to register the component in
  73238. */
  73239. constructor(scene: Scene);
  73240. /**
  73241. * Registers the component in a given scene
  73242. */
  73243. register(): void;
  73244. private _beforeCameraDraw;
  73245. private _afterCameraDraw;
  73246. private _beforeClearStage;
  73247. /**
  73248. * Rebuilds the elements related to this component in case of
  73249. * context lost for instance.
  73250. */
  73251. rebuild(): void;
  73252. /**
  73253. * Disposes the component and the associated ressources
  73254. */
  73255. dispose(): void;
  73256. }
  73257. }
  73258. declare module BABYLON {
  73259. /** @hidden */
  73260. export var fibonacci: {
  73261. name: string;
  73262. shader: string;
  73263. };
  73264. }
  73265. declare module BABYLON {
  73266. /** @hidden */
  73267. export var diffusionProfile: {
  73268. name: string;
  73269. shader: string;
  73270. };
  73271. }
  73272. declare module BABYLON {
  73273. /** @hidden */
  73274. export var subSurfaceScatteringPixelShader: {
  73275. name: string;
  73276. shader: string;
  73277. };
  73278. }
  73279. declare module BABYLON {
  73280. /**
  73281. * Sub surface scattering post process
  73282. */
  73283. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73284. /**
  73285. * Gets a string identifying the name of the class
  73286. * @returns "SubSurfaceScatteringPostProcess" string
  73287. */
  73288. getClassName(): string;
  73289. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73290. }
  73291. }
  73292. declare module BABYLON {
  73293. /**
  73294. * Contains all parameters needed for the prepass to perform
  73295. * screen space subsurface scattering
  73296. */
  73297. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73298. /** @hidden */
  73299. static _SceneComponentInitialization: (scene: Scene) => void;
  73300. private _ssDiffusionS;
  73301. private _ssFilterRadii;
  73302. private _ssDiffusionD;
  73303. /**
  73304. * Post process to attach for screen space subsurface scattering
  73305. */
  73306. postProcess: SubSurfaceScatteringPostProcess;
  73307. /**
  73308. * Diffusion profile color for subsurface scattering
  73309. */
  73310. get ssDiffusionS(): number[];
  73311. /**
  73312. * Diffusion profile max color channel value for subsurface scattering
  73313. */
  73314. get ssDiffusionD(): number[];
  73315. /**
  73316. * Diffusion profile filter radius for subsurface scattering
  73317. */
  73318. get ssFilterRadii(): number[];
  73319. /**
  73320. * Is subsurface enabled
  73321. */
  73322. enabled: boolean;
  73323. /**
  73324. * Name of the configuration
  73325. */
  73326. name: string;
  73327. /**
  73328. * Diffusion profile colors for subsurface scattering
  73329. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73330. * See ...
  73331. * Note that you can only store up to 5 of them
  73332. */
  73333. ssDiffusionProfileColors: Color3[];
  73334. /**
  73335. * Defines the ratio real world => scene units.
  73336. * Used for subsurface scattering
  73337. */
  73338. metersPerUnit: number;
  73339. /**
  73340. * Textures that should be present in the MRT for this effect to work
  73341. */
  73342. readonly texturesRequired: number[];
  73343. private _scene;
  73344. /**
  73345. * Builds a subsurface configuration object
  73346. * @param scene The scene
  73347. */
  73348. constructor(scene: Scene);
  73349. /**
  73350. * Adds a new diffusion profile.
  73351. * Useful for more realistic subsurface scattering on diverse materials.
  73352. * @param color The color of the diffusion profile. Should be the average color of the material.
  73353. * @return The index of the diffusion profile for the material subsurface configuration
  73354. */
  73355. addDiffusionProfile(color: Color3): number;
  73356. /**
  73357. * Creates the sss post process
  73358. * @return The created post process
  73359. */
  73360. createPostProcess(): SubSurfaceScatteringPostProcess;
  73361. /**
  73362. * Deletes all diffusion profiles.
  73363. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73364. */
  73365. clearAllDiffusionProfiles(): void;
  73366. /**
  73367. * Disposes this object
  73368. */
  73369. dispose(): void;
  73370. /**
  73371. * @hidden
  73372. * https://zero-radiance.github.io/post/sampling-diffusion/
  73373. *
  73374. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73375. * ------------------------------------------------------------------------------------
  73376. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73377. * PDF[r, phi, s] = r * R[r, phi, s]
  73378. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73379. * ------------------------------------------------------------------------------------
  73380. * We importance sample the color channel with the widest scattering distance.
  73381. */
  73382. getDiffusionProfileParameters(color: Color3): number;
  73383. /**
  73384. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73385. * 'u' is the random number (the value of the CDF): [0, 1).
  73386. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73387. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73388. */
  73389. private _sampleBurleyDiffusionProfile;
  73390. }
  73391. }
  73392. declare module BABYLON {
  73393. interface AbstractScene {
  73394. /** @hidden (Backing field) */
  73395. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73396. /**
  73397. * Gets or Sets the current prepass renderer associated to the scene.
  73398. */
  73399. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73400. /**
  73401. * Enables the subsurface effect for prepass
  73402. * @returns the SubSurfaceConfiguration
  73403. */
  73404. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73405. /**
  73406. * Disables the subsurface effect for prepass
  73407. */
  73408. disableSubSurfaceForPrePass(): void;
  73409. }
  73410. /**
  73411. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73412. * in several rendering techniques.
  73413. */
  73414. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73415. /**
  73416. * The component name helpful to identify the component in the list of scene components.
  73417. */
  73418. readonly name: string;
  73419. /**
  73420. * The scene the component belongs to.
  73421. */
  73422. scene: Scene;
  73423. /**
  73424. * Creates a new instance of the component for the given scene
  73425. * @param scene Defines the scene to register the component in
  73426. */
  73427. constructor(scene: Scene);
  73428. /**
  73429. * Registers the component in a given scene
  73430. */
  73431. register(): void;
  73432. /**
  73433. * Serializes the component data to the specified json object
  73434. * @param serializationObject The object to serialize to
  73435. */
  73436. serialize(serializationObject: any): void;
  73437. /**
  73438. * Adds all the elements from the container to the scene
  73439. * @param container the container holding the elements
  73440. */
  73441. addFromContainer(container: AbstractScene): void;
  73442. /**
  73443. * Removes all the elements in the container from the scene
  73444. * @param container contains the elements to remove
  73445. * @param dispose if the removed element should be disposed (default: false)
  73446. */
  73447. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73448. /**
  73449. * Rebuilds the elements related to this component in case of
  73450. * context lost for instance.
  73451. */
  73452. rebuild(): void;
  73453. /**
  73454. * Disposes the component and the associated ressources
  73455. */
  73456. dispose(): void;
  73457. }
  73458. }
  73459. declare module BABYLON {
  73460. /** @hidden */
  73461. export var outlinePixelShader: {
  73462. name: string;
  73463. shader: string;
  73464. };
  73465. }
  73466. declare module BABYLON {
  73467. /** @hidden */
  73468. export var outlineVertexShader: {
  73469. name: string;
  73470. shader: string;
  73471. };
  73472. }
  73473. declare module BABYLON {
  73474. interface Scene {
  73475. /** @hidden */
  73476. _outlineRenderer: OutlineRenderer;
  73477. /**
  73478. * Gets the outline renderer associated with the scene
  73479. * @returns a OutlineRenderer
  73480. */
  73481. getOutlineRenderer(): OutlineRenderer;
  73482. }
  73483. interface AbstractMesh {
  73484. /** @hidden (Backing field) */
  73485. _renderOutline: boolean;
  73486. /**
  73487. * Gets or sets a boolean indicating if the outline must be rendered as well
  73488. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73489. */
  73490. renderOutline: boolean;
  73491. /** @hidden (Backing field) */
  73492. _renderOverlay: boolean;
  73493. /**
  73494. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73495. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73496. */
  73497. renderOverlay: boolean;
  73498. }
  73499. /**
  73500. * This class is responsible to draw bothe outline/overlay of meshes.
  73501. * It should not be used directly but through the available method on mesh.
  73502. */
  73503. export class OutlineRenderer implements ISceneComponent {
  73504. /**
  73505. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73506. */
  73507. private static _StencilReference;
  73508. /**
  73509. * The name of the component. Each component must have a unique name.
  73510. */
  73511. name: string;
  73512. /**
  73513. * The scene the component belongs to.
  73514. */
  73515. scene: Scene;
  73516. /**
  73517. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73518. */
  73519. zOffset: number;
  73520. private _engine;
  73521. private _effect;
  73522. private _cachedDefines;
  73523. private _savedDepthWrite;
  73524. /**
  73525. * Instantiates a new outline renderer. (There could be only one per scene).
  73526. * @param scene Defines the scene it belongs to
  73527. */
  73528. constructor(scene: Scene);
  73529. /**
  73530. * Register the component to one instance of a scene.
  73531. */
  73532. register(): void;
  73533. /**
  73534. * Rebuilds the elements related to this component in case of
  73535. * context lost for instance.
  73536. */
  73537. rebuild(): void;
  73538. /**
  73539. * Disposes the component and the associated ressources.
  73540. */
  73541. dispose(): void;
  73542. /**
  73543. * Renders the outline in the canvas.
  73544. * @param subMesh Defines the sumesh to render
  73545. * @param batch Defines the batch of meshes in case of instances
  73546. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73547. */
  73548. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73549. /**
  73550. * Returns whether or not the outline renderer is ready for a given submesh.
  73551. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73552. * @param subMesh Defines the submesh to check readyness for
  73553. * @param useInstances Defines wheter wee are trying to render instances or not
  73554. * @returns true if ready otherwise false
  73555. */
  73556. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73557. private _beforeRenderingMesh;
  73558. private _afterRenderingMesh;
  73559. }
  73560. }
  73561. declare module BABYLON {
  73562. /**
  73563. * Defines the basic options interface of a Sprite Frame Source Size.
  73564. */
  73565. export interface ISpriteJSONSpriteSourceSize {
  73566. /**
  73567. * number of the original width of the Frame
  73568. */
  73569. w: number;
  73570. /**
  73571. * number of the original height of the Frame
  73572. */
  73573. h: number;
  73574. }
  73575. /**
  73576. * Defines the basic options interface of a Sprite Frame Data.
  73577. */
  73578. export interface ISpriteJSONSpriteFrameData {
  73579. /**
  73580. * number of the x offset of the Frame
  73581. */
  73582. x: number;
  73583. /**
  73584. * number of the y offset of the Frame
  73585. */
  73586. y: number;
  73587. /**
  73588. * number of the width of the Frame
  73589. */
  73590. w: number;
  73591. /**
  73592. * number of the height of the Frame
  73593. */
  73594. h: number;
  73595. }
  73596. /**
  73597. * Defines the basic options interface of a JSON Sprite.
  73598. */
  73599. export interface ISpriteJSONSprite {
  73600. /**
  73601. * string name of the Frame
  73602. */
  73603. filename: string;
  73604. /**
  73605. * ISpriteJSONSpriteFrame basic object of the frame data
  73606. */
  73607. frame: ISpriteJSONSpriteFrameData;
  73608. /**
  73609. * boolean to flag is the frame was rotated.
  73610. */
  73611. rotated: boolean;
  73612. /**
  73613. * boolean to flag is the frame was trimmed.
  73614. */
  73615. trimmed: boolean;
  73616. /**
  73617. * ISpriteJSONSpriteFrame basic object of the source data
  73618. */
  73619. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73620. /**
  73621. * ISpriteJSONSpriteFrame basic object of the source data
  73622. */
  73623. sourceSize: ISpriteJSONSpriteSourceSize;
  73624. }
  73625. /**
  73626. * Defines the basic options interface of a JSON atlas.
  73627. */
  73628. export interface ISpriteJSONAtlas {
  73629. /**
  73630. * Array of objects that contain the frame data.
  73631. */
  73632. frames: Array<ISpriteJSONSprite>;
  73633. /**
  73634. * object basic object containing the sprite meta data.
  73635. */
  73636. meta?: object;
  73637. }
  73638. }
  73639. declare module BABYLON {
  73640. /** @hidden */
  73641. export var spriteMapPixelShader: {
  73642. name: string;
  73643. shader: string;
  73644. };
  73645. }
  73646. declare module BABYLON {
  73647. /** @hidden */
  73648. export var spriteMapVertexShader: {
  73649. name: string;
  73650. shader: string;
  73651. };
  73652. }
  73653. declare module BABYLON {
  73654. /**
  73655. * Defines the basic options interface of a SpriteMap
  73656. */
  73657. export interface ISpriteMapOptions {
  73658. /**
  73659. * Vector2 of the number of cells in the grid.
  73660. */
  73661. stageSize?: Vector2;
  73662. /**
  73663. * Vector2 of the size of the output plane in World Units.
  73664. */
  73665. outputSize?: Vector2;
  73666. /**
  73667. * Vector3 of the position of the output plane in World Units.
  73668. */
  73669. outputPosition?: Vector3;
  73670. /**
  73671. * Vector3 of the rotation of the output plane.
  73672. */
  73673. outputRotation?: Vector3;
  73674. /**
  73675. * number of layers that the system will reserve in resources.
  73676. */
  73677. layerCount?: number;
  73678. /**
  73679. * number of max animation frames a single cell will reserve in resources.
  73680. */
  73681. maxAnimationFrames?: number;
  73682. /**
  73683. * number cell index of the base tile when the system compiles.
  73684. */
  73685. baseTile?: number;
  73686. /**
  73687. * boolean flip the sprite after its been repositioned by the framing data.
  73688. */
  73689. flipU?: boolean;
  73690. /**
  73691. * Vector3 scalar of the global RGB values of the SpriteMap.
  73692. */
  73693. colorMultiply?: Vector3;
  73694. }
  73695. /**
  73696. * Defines the IDisposable interface in order to be cleanable from resources.
  73697. */
  73698. export interface ISpriteMap extends IDisposable {
  73699. /**
  73700. * String name of the SpriteMap.
  73701. */
  73702. name: string;
  73703. /**
  73704. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73705. */
  73706. atlasJSON: ISpriteJSONAtlas;
  73707. /**
  73708. * Texture of the SpriteMap.
  73709. */
  73710. spriteSheet: Texture;
  73711. /**
  73712. * The parameters to initialize the SpriteMap with.
  73713. */
  73714. options: ISpriteMapOptions;
  73715. }
  73716. /**
  73717. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73718. */
  73719. export class SpriteMap implements ISpriteMap {
  73720. /** The Name of the spriteMap */
  73721. name: string;
  73722. /** The JSON file with the frame and meta data */
  73723. atlasJSON: ISpriteJSONAtlas;
  73724. /** The systems Sprite Sheet Texture */
  73725. spriteSheet: Texture;
  73726. /** Arguments passed with the Constructor */
  73727. options: ISpriteMapOptions;
  73728. /** Public Sprite Storage array, parsed from atlasJSON */
  73729. sprites: Array<ISpriteJSONSprite>;
  73730. /** Returns the Number of Sprites in the System */
  73731. get spriteCount(): number;
  73732. /** Returns the Position of Output Plane*/
  73733. get position(): Vector3;
  73734. /** Returns the Position of Output Plane*/
  73735. set position(v: Vector3);
  73736. /** Returns the Rotation of Output Plane*/
  73737. get rotation(): Vector3;
  73738. /** Returns the Rotation of Output Plane*/
  73739. set rotation(v: Vector3);
  73740. /** Sets the AnimationMap*/
  73741. get animationMap(): RawTexture;
  73742. /** Sets the AnimationMap*/
  73743. set animationMap(v: RawTexture);
  73744. /** Scene that the SpriteMap was created in */
  73745. private _scene;
  73746. /** Texture Buffer of Float32 that holds tile frame data*/
  73747. private _frameMap;
  73748. /** Texture Buffers of Float32 that holds tileMap data*/
  73749. private _tileMaps;
  73750. /** Texture Buffer of Float32 that holds Animation Data*/
  73751. private _animationMap;
  73752. /** Custom ShaderMaterial Central to the System*/
  73753. private _material;
  73754. /** Custom ShaderMaterial Central to the System*/
  73755. private _output;
  73756. /** Systems Time Ticker*/
  73757. private _time;
  73758. /**
  73759. * Creates a new SpriteMap
  73760. * @param name defines the SpriteMaps Name
  73761. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73762. * @param spriteSheet is the Texture that the Sprites are on.
  73763. * @param options a basic deployment configuration
  73764. * @param scene The Scene that the map is deployed on
  73765. */
  73766. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73767. /**
  73768. * Returns tileID location
  73769. * @returns Vector2 the cell position ID
  73770. */
  73771. getTileID(): Vector2;
  73772. /**
  73773. * Gets the UV location of the mouse over the SpriteMap.
  73774. * @returns Vector2 the UV position of the mouse interaction
  73775. */
  73776. getMousePosition(): Vector2;
  73777. /**
  73778. * Creates the "frame" texture Buffer
  73779. * -------------------------------------
  73780. * Structure of frames
  73781. * "filename": "Falling-Water-2.png",
  73782. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73783. * "rotated": true,
  73784. * "trimmed": true,
  73785. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73786. * "sourceSize": {"w":32,"h":32}
  73787. * @returns RawTexture of the frameMap
  73788. */
  73789. private _createFrameBuffer;
  73790. /**
  73791. * Creates the tileMap texture Buffer
  73792. * @param buffer normally and array of numbers, or a false to generate from scratch
  73793. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73794. * @returns RawTexture of the tileMap
  73795. */
  73796. private _createTileBuffer;
  73797. /**
  73798. * Modifies the data of the tileMaps
  73799. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73800. * @param pos is the iVector2 Coordinates of the Tile
  73801. * @param tile The SpriteIndex of the new Tile
  73802. */
  73803. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73804. /**
  73805. * Creates the animationMap texture Buffer
  73806. * @param buffer normally and array of numbers, or a false to generate from scratch
  73807. * @returns RawTexture of the animationMap
  73808. */
  73809. private _createTileAnimationBuffer;
  73810. /**
  73811. * Modifies the data of the animationMap
  73812. * @param cellID is the Index of the Sprite
  73813. * @param _frame is the target Animation frame
  73814. * @param toCell is the Target Index of the next frame of the animation
  73815. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73816. * @param speed is a global scalar of the time variable on the map.
  73817. */
  73818. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73819. /**
  73820. * Exports the .tilemaps file
  73821. */
  73822. saveTileMaps(): void;
  73823. /**
  73824. * Imports the .tilemaps file
  73825. * @param url of the .tilemaps file
  73826. */
  73827. loadTileMaps(url: string): void;
  73828. /**
  73829. * Release associated resources
  73830. */
  73831. dispose(): void;
  73832. }
  73833. }
  73834. declare module BABYLON {
  73835. /**
  73836. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73837. * @see https://doc.babylonjs.com/babylon101/sprites
  73838. */
  73839. export class SpritePackedManager extends SpriteManager {
  73840. /** defines the packed manager's name */
  73841. name: string;
  73842. /**
  73843. * Creates a new sprite manager from a packed sprite sheet
  73844. * @param name defines the manager's name
  73845. * @param imgUrl defines the sprite sheet url
  73846. * @param capacity defines the maximum allowed number of sprites
  73847. * @param scene defines the hosting scene
  73848. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73849. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73850. * @param samplingMode defines the smapling mode to use with spritesheet
  73851. * @param fromPacked set to true; do not alter
  73852. */
  73853. constructor(
  73854. /** defines the packed manager's name */
  73855. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73856. }
  73857. }
  73858. declare module BABYLON {
  73859. /**
  73860. * Defines the list of states available for a task inside a AssetsManager
  73861. */
  73862. export enum AssetTaskState {
  73863. /**
  73864. * Initialization
  73865. */
  73866. INIT = 0,
  73867. /**
  73868. * Running
  73869. */
  73870. RUNNING = 1,
  73871. /**
  73872. * Done
  73873. */
  73874. DONE = 2,
  73875. /**
  73876. * Error
  73877. */
  73878. ERROR = 3
  73879. }
  73880. /**
  73881. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73882. */
  73883. export abstract class AbstractAssetTask {
  73884. /**
  73885. * Task name
  73886. */ name: string;
  73887. /**
  73888. * Callback called when the task is successful
  73889. */
  73890. onSuccess: (task: any) => void;
  73891. /**
  73892. * Callback called when the task is not successful
  73893. */
  73894. onError: (task: any, message?: string, exception?: any) => void;
  73895. /**
  73896. * Creates a new AssetsManager
  73897. * @param name defines the name of the task
  73898. */
  73899. constructor(
  73900. /**
  73901. * Task name
  73902. */ name: string);
  73903. private _isCompleted;
  73904. private _taskState;
  73905. private _errorObject;
  73906. /**
  73907. * Get if the task is completed
  73908. */
  73909. get isCompleted(): boolean;
  73910. /**
  73911. * Gets the current state of the task
  73912. */
  73913. get taskState(): AssetTaskState;
  73914. /**
  73915. * Gets the current error object (if task is in error)
  73916. */
  73917. get errorObject(): {
  73918. message?: string;
  73919. exception?: any;
  73920. };
  73921. /**
  73922. * Internal only
  73923. * @hidden
  73924. */
  73925. _setErrorObject(message?: string, exception?: any): void;
  73926. /**
  73927. * Execute the current task
  73928. * @param scene defines the scene where you want your assets to be loaded
  73929. * @param onSuccess is a callback called when the task is successfully executed
  73930. * @param onError is a callback called if an error occurs
  73931. */
  73932. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73933. /**
  73934. * Execute the current task
  73935. * @param scene defines the scene where you want your assets to be loaded
  73936. * @param onSuccess is a callback called when the task is successfully executed
  73937. * @param onError is a callback called if an error occurs
  73938. */
  73939. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73940. /**
  73941. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73942. * This can be used with failed tasks that have the reason for failure fixed.
  73943. */
  73944. reset(): void;
  73945. private onErrorCallback;
  73946. private onDoneCallback;
  73947. }
  73948. /**
  73949. * Define the interface used by progress events raised during assets loading
  73950. */
  73951. export interface IAssetsProgressEvent {
  73952. /**
  73953. * Defines the number of remaining tasks to process
  73954. */
  73955. remainingCount: number;
  73956. /**
  73957. * Defines the total number of tasks
  73958. */
  73959. totalCount: number;
  73960. /**
  73961. * Defines the task that was just processed
  73962. */
  73963. task: AbstractAssetTask;
  73964. }
  73965. /**
  73966. * Class used to share progress information about assets loading
  73967. */
  73968. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73969. /**
  73970. * Defines the number of remaining tasks to process
  73971. */
  73972. remainingCount: number;
  73973. /**
  73974. * Defines the total number of tasks
  73975. */
  73976. totalCount: number;
  73977. /**
  73978. * Defines the task that was just processed
  73979. */
  73980. task: AbstractAssetTask;
  73981. /**
  73982. * Creates a AssetsProgressEvent
  73983. * @param remainingCount defines the number of remaining tasks to process
  73984. * @param totalCount defines the total number of tasks
  73985. * @param task defines the task that was just processed
  73986. */
  73987. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73988. }
  73989. /**
  73990. * Define a task used by AssetsManager to load assets into a container
  73991. */
  73992. export class ContainerAssetTask extends AbstractAssetTask {
  73993. /**
  73994. * Defines the name of the task
  73995. */
  73996. name: string;
  73997. /**
  73998. * Defines the list of mesh's names you want to load
  73999. */
  74000. meshesNames: any;
  74001. /**
  74002. * Defines the root url to use as a base to load your meshes and associated resources
  74003. */
  74004. rootUrl: string;
  74005. /**
  74006. * Defines the filename or File of the scene to load from
  74007. */
  74008. sceneFilename: string | File;
  74009. /**
  74010. * Get the loaded asset container
  74011. */
  74012. loadedContainer: AssetContainer;
  74013. /**
  74014. * Gets the list of loaded meshes
  74015. */
  74016. loadedMeshes: Array<AbstractMesh>;
  74017. /**
  74018. * Gets the list of loaded particle systems
  74019. */
  74020. loadedParticleSystems: Array<IParticleSystem>;
  74021. /**
  74022. * Gets the list of loaded skeletons
  74023. */
  74024. loadedSkeletons: Array<Skeleton>;
  74025. /**
  74026. * Gets the list of loaded animation groups
  74027. */
  74028. loadedAnimationGroups: Array<AnimationGroup>;
  74029. /**
  74030. * Callback called when the task is successful
  74031. */
  74032. onSuccess: (task: ContainerAssetTask) => void;
  74033. /**
  74034. * Callback called when the task is successful
  74035. */
  74036. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  74037. /**
  74038. * Creates a new ContainerAssetTask
  74039. * @param name defines the name of the task
  74040. * @param meshesNames defines the list of mesh's names you want to load
  74041. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74042. * @param sceneFilename defines the filename or File of the scene to load from
  74043. */
  74044. constructor(
  74045. /**
  74046. * Defines the name of the task
  74047. */
  74048. name: string,
  74049. /**
  74050. * Defines the list of mesh's names you want to load
  74051. */
  74052. meshesNames: any,
  74053. /**
  74054. * Defines the root url to use as a base to load your meshes and associated resources
  74055. */
  74056. rootUrl: string,
  74057. /**
  74058. * Defines the filename or File of the scene to load from
  74059. */
  74060. sceneFilename: string | File);
  74061. /**
  74062. * Execute the current task
  74063. * @param scene defines the scene where you want your assets to be loaded
  74064. * @param onSuccess is a callback called when the task is successfully executed
  74065. * @param onError is a callback called if an error occurs
  74066. */
  74067. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74068. }
  74069. /**
  74070. * Define a task used by AssetsManager to load meshes
  74071. */
  74072. export class MeshAssetTask extends AbstractAssetTask {
  74073. /**
  74074. * Defines the name of the task
  74075. */
  74076. name: string;
  74077. /**
  74078. * Defines the list of mesh's names you want to load
  74079. */
  74080. meshesNames: any;
  74081. /**
  74082. * Defines the root url to use as a base to load your meshes and associated resources
  74083. */
  74084. rootUrl: string;
  74085. /**
  74086. * Defines the filename or File of the scene to load from
  74087. */
  74088. sceneFilename: string | File;
  74089. /**
  74090. * Gets the list of loaded meshes
  74091. */
  74092. loadedMeshes: Array<AbstractMesh>;
  74093. /**
  74094. * Gets the list of loaded particle systems
  74095. */
  74096. loadedParticleSystems: Array<IParticleSystem>;
  74097. /**
  74098. * Gets the list of loaded skeletons
  74099. */
  74100. loadedSkeletons: Array<Skeleton>;
  74101. /**
  74102. * Gets the list of loaded animation groups
  74103. */
  74104. loadedAnimationGroups: Array<AnimationGroup>;
  74105. /**
  74106. * Callback called when the task is successful
  74107. */
  74108. onSuccess: (task: MeshAssetTask) => void;
  74109. /**
  74110. * Callback called when the task is successful
  74111. */
  74112. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74113. /**
  74114. * Creates a new MeshAssetTask
  74115. * @param name defines the name of the task
  74116. * @param meshesNames defines the list of mesh's names you want to load
  74117. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74118. * @param sceneFilename defines the filename or File of the scene to load from
  74119. */
  74120. constructor(
  74121. /**
  74122. * Defines the name of the task
  74123. */
  74124. name: string,
  74125. /**
  74126. * Defines the list of mesh's names you want to load
  74127. */
  74128. meshesNames: any,
  74129. /**
  74130. * Defines the root url to use as a base to load your meshes and associated resources
  74131. */
  74132. rootUrl: string,
  74133. /**
  74134. * Defines the filename or File of the scene to load from
  74135. */
  74136. sceneFilename: string | File);
  74137. /**
  74138. * Execute the current task
  74139. * @param scene defines the scene where you want your assets to be loaded
  74140. * @param onSuccess is a callback called when the task is successfully executed
  74141. * @param onError is a callback called if an error occurs
  74142. */
  74143. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74144. }
  74145. /**
  74146. * Define a task used by AssetsManager to load text content
  74147. */
  74148. export class TextFileAssetTask extends AbstractAssetTask {
  74149. /**
  74150. * Defines the name of the task
  74151. */
  74152. name: string;
  74153. /**
  74154. * Defines the location of the file to load
  74155. */
  74156. url: string;
  74157. /**
  74158. * Gets the loaded text string
  74159. */
  74160. text: string;
  74161. /**
  74162. * Callback called when the task is successful
  74163. */
  74164. onSuccess: (task: TextFileAssetTask) => void;
  74165. /**
  74166. * Callback called when the task is successful
  74167. */
  74168. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74169. /**
  74170. * Creates a new TextFileAssetTask object
  74171. * @param name defines the name of the task
  74172. * @param url defines the location of the file to load
  74173. */
  74174. constructor(
  74175. /**
  74176. * Defines the name of the task
  74177. */
  74178. name: string,
  74179. /**
  74180. * Defines the location of the file to load
  74181. */
  74182. url: string);
  74183. /**
  74184. * Execute the current task
  74185. * @param scene defines the scene where you want your assets to be loaded
  74186. * @param onSuccess is a callback called when the task is successfully executed
  74187. * @param onError is a callback called if an error occurs
  74188. */
  74189. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74190. }
  74191. /**
  74192. * Define a task used by AssetsManager to load binary data
  74193. */
  74194. export class BinaryFileAssetTask extends AbstractAssetTask {
  74195. /**
  74196. * Defines the name of the task
  74197. */
  74198. name: string;
  74199. /**
  74200. * Defines the location of the file to load
  74201. */
  74202. url: string;
  74203. /**
  74204. * Gets the lodaded data (as an array buffer)
  74205. */
  74206. data: ArrayBuffer;
  74207. /**
  74208. * Callback called when the task is successful
  74209. */
  74210. onSuccess: (task: BinaryFileAssetTask) => void;
  74211. /**
  74212. * Callback called when the task is successful
  74213. */
  74214. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74215. /**
  74216. * Creates a new BinaryFileAssetTask object
  74217. * @param name defines the name of the new task
  74218. * @param url defines the location of the file to load
  74219. */
  74220. constructor(
  74221. /**
  74222. * Defines the name of the task
  74223. */
  74224. name: string,
  74225. /**
  74226. * Defines the location of the file to load
  74227. */
  74228. url: string);
  74229. /**
  74230. * Execute the current task
  74231. * @param scene defines the scene where you want your assets to be loaded
  74232. * @param onSuccess is a callback called when the task is successfully executed
  74233. * @param onError is a callback called if an error occurs
  74234. */
  74235. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74236. }
  74237. /**
  74238. * Define a task used by AssetsManager to load images
  74239. */
  74240. export class ImageAssetTask extends AbstractAssetTask {
  74241. /**
  74242. * Defines the name of the task
  74243. */
  74244. name: string;
  74245. /**
  74246. * Defines the location of the image to load
  74247. */
  74248. url: string;
  74249. /**
  74250. * Gets the loaded images
  74251. */
  74252. image: HTMLImageElement;
  74253. /**
  74254. * Callback called when the task is successful
  74255. */
  74256. onSuccess: (task: ImageAssetTask) => void;
  74257. /**
  74258. * Callback called when the task is successful
  74259. */
  74260. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74261. /**
  74262. * Creates a new ImageAssetTask
  74263. * @param name defines the name of the task
  74264. * @param url defines the location of the image to load
  74265. */
  74266. constructor(
  74267. /**
  74268. * Defines the name of the task
  74269. */
  74270. name: string,
  74271. /**
  74272. * Defines the location of the image to load
  74273. */
  74274. url: string);
  74275. /**
  74276. * Execute the current task
  74277. * @param scene defines the scene where you want your assets to be loaded
  74278. * @param onSuccess is a callback called when the task is successfully executed
  74279. * @param onError is a callback called if an error occurs
  74280. */
  74281. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74282. }
  74283. /**
  74284. * Defines the interface used by texture loading tasks
  74285. */
  74286. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74287. /**
  74288. * Gets the loaded texture
  74289. */
  74290. texture: TEX;
  74291. }
  74292. /**
  74293. * Define a task used by AssetsManager to load 2D textures
  74294. */
  74295. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74296. /**
  74297. * Defines the name of the task
  74298. */
  74299. name: string;
  74300. /**
  74301. * Defines the location of the file to load
  74302. */
  74303. url: string;
  74304. /**
  74305. * Defines if mipmap should not be generated (default is false)
  74306. */
  74307. noMipmap?: boolean | undefined;
  74308. /**
  74309. * Defines if texture must be inverted on Y axis (default is true)
  74310. */
  74311. invertY: boolean;
  74312. /**
  74313. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74314. */
  74315. samplingMode: number;
  74316. /**
  74317. * Gets the loaded texture
  74318. */
  74319. texture: Texture;
  74320. /**
  74321. * Callback called when the task is successful
  74322. */
  74323. onSuccess: (task: TextureAssetTask) => void;
  74324. /**
  74325. * Callback called when the task is successful
  74326. */
  74327. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74328. /**
  74329. * Creates a new TextureAssetTask object
  74330. * @param name defines the name of the task
  74331. * @param url defines the location of the file to load
  74332. * @param noMipmap defines if mipmap should not be generated (default is false)
  74333. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74334. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74335. */
  74336. constructor(
  74337. /**
  74338. * Defines the name of the task
  74339. */
  74340. name: string,
  74341. /**
  74342. * Defines the location of the file to load
  74343. */
  74344. url: string,
  74345. /**
  74346. * Defines if mipmap should not be generated (default is false)
  74347. */
  74348. noMipmap?: boolean | undefined,
  74349. /**
  74350. * Defines if texture must be inverted on Y axis (default is true)
  74351. */
  74352. invertY?: boolean,
  74353. /**
  74354. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74355. */
  74356. samplingMode?: number);
  74357. /**
  74358. * Execute the current task
  74359. * @param scene defines the scene where you want your assets to be loaded
  74360. * @param onSuccess is a callback called when the task is successfully executed
  74361. * @param onError is a callback called if an error occurs
  74362. */
  74363. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74364. }
  74365. /**
  74366. * Define a task used by AssetsManager to load cube textures
  74367. */
  74368. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74369. /**
  74370. * Defines the name of the task
  74371. */
  74372. name: string;
  74373. /**
  74374. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74375. */
  74376. url: string;
  74377. /**
  74378. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74379. */
  74380. extensions?: string[] | undefined;
  74381. /**
  74382. * Defines if mipmaps should not be generated (default is false)
  74383. */
  74384. noMipmap?: boolean | undefined;
  74385. /**
  74386. * Defines the explicit list of files (undefined by default)
  74387. */
  74388. files?: string[] | undefined;
  74389. /**
  74390. * Gets the loaded texture
  74391. */
  74392. texture: CubeTexture;
  74393. /**
  74394. * Callback called when the task is successful
  74395. */
  74396. onSuccess: (task: CubeTextureAssetTask) => void;
  74397. /**
  74398. * Callback called when the task is successful
  74399. */
  74400. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74401. /**
  74402. * Creates a new CubeTextureAssetTask
  74403. * @param name defines the name of the task
  74404. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74405. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74406. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74407. * @param files defines the explicit list of files (undefined by default)
  74408. */
  74409. constructor(
  74410. /**
  74411. * Defines the name of the task
  74412. */
  74413. name: string,
  74414. /**
  74415. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74416. */
  74417. url: string,
  74418. /**
  74419. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74420. */
  74421. extensions?: string[] | undefined,
  74422. /**
  74423. * Defines if mipmaps should not be generated (default is false)
  74424. */
  74425. noMipmap?: boolean | undefined,
  74426. /**
  74427. * Defines the explicit list of files (undefined by default)
  74428. */
  74429. files?: string[] | undefined);
  74430. /**
  74431. * Execute the current task
  74432. * @param scene defines the scene where you want your assets to be loaded
  74433. * @param onSuccess is a callback called when the task is successfully executed
  74434. * @param onError is a callback called if an error occurs
  74435. */
  74436. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74437. }
  74438. /**
  74439. * Define a task used by AssetsManager to load HDR cube textures
  74440. */
  74441. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74442. /**
  74443. * Defines the name of the task
  74444. */
  74445. name: string;
  74446. /**
  74447. * Defines the location of the file to load
  74448. */
  74449. url: string;
  74450. /**
  74451. * Defines the desired size (the more it increases the longer the generation will be)
  74452. */
  74453. size: number;
  74454. /**
  74455. * Defines if mipmaps should not be generated (default is false)
  74456. */
  74457. noMipmap: boolean;
  74458. /**
  74459. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74460. */
  74461. generateHarmonics: boolean;
  74462. /**
  74463. * 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)
  74464. */
  74465. gammaSpace: boolean;
  74466. /**
  74467. * Internal Use Only
  74468. */
  74469. reserved: boolean;
  74470. /**
  74471. * Gets the loaded texture
  74472. */
  74473. texture: HDRCubeTexture;
  74474. /**
  74475. * Callback called when the task is successful
  74476. */
  74477. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74478. /**
  74479. * Callback called when the task is successful
  74480. */
  74481. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74482. /**
  74483. * Creates a new HDRCubeTextureAssetTask object
  74484. * @param name defines the name of the task
  74485. * @param url defines the location of the file to load
  74486. * @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.
  74487. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74488. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74489. * @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)
  74490. * @param reserved Internal use only
  74491. */
  74492. constructor(
  74493. /**
  74494. * Defines the name of the task
  74495. */
  74496. name: string,
  74497. /**
  74498. * Defines the location of the file to load
  74499. */
  74500. url: string,
  74501. /**
  74502. * Defines the desired size (the more it increases the longer the generation will be)
  74503. */
  74504. size: number,
  74505. /**
  74506. * Defines if mipmaps should not be generated (default is false)
  74507. */
  74508. noMipmap?: boolean,
  74509. /**
  74510. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74511. */
  74512. generateHarmonics?: boolean,
  74513. /**
  74514. * 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)
  74515. */
  74516. gammaSpace?: boolean,
  74517. /**
  74518. * Internal Use Only
  74519. */
  74520. reserved?: boolean);
  74521. /**
  74522. * Execute the current task
  74523. * @param scene defines the scene where you want your assets to be loaded
  74524. * @param onSuccess is a callback called when the task is successfully executed
  74525. * @param onError is a callback called if an error occurs
  74526. */
  74527. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74528. }
  74529. /**
  74530. * Define a task used by AssetsManager to load Equirectangular cube textures
  74531. */
  74532. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74533. /**
  74534. * Defines the name of the task
  74535. */
  74536. name: string;
  74537. /**
  74538. * Defines the location of the file to load
  74539. */
  74540. url: string;
  74541. /**
  74542. * Defines the desired size (the more it increases the longer the generation will be)
  74543. */
  74544. size: number;
  74545. /**
  74546. * Defines if mipmaps should not be generated (default is false)
  74547. */
  74548. noMipmap: boolean;
  74549. /**
  74550. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74551. * but the standard material would require them in Gamma space) (default is true)
  74552. */
  74553. gammaSpace: boolean;
  74554. /**
  74555. * Gets the loaded texture
  74556. */
  74557. texture: EquiRectangularCubeTexture;
  74558. /**
  74559. * Callback called when the task is successful
  74560. */
  74561. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74562. /**
  74563. * Callback called when the task is successful
  74564. */
  74565. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74566. /**
  74567. * Creates a new EquiRectangularCubeTextureAssetTask object
  74568. * @param name defines the name of the task
  74569. * @param url defines the location of the file to load
  74570. * @param size defines the desired size (the more it increases the longer the generation will be)
  74571. * If the size is omitted this implies you are using a preprocessed cubemap.
  74572. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74573. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74574. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74575. * (default is true)
  74576. */
  74577. constructor(
  74578. /**
  74579. * Defines the name of the task
  74580. */
  74581. name: string,
  74582. /**
  74583. * Defines the location of the file to load
  74584. */
  74585. url: string,
  74586. /**
  74587. * Defines the desired size (the more it increases the longer the generation will be)
  74588. */
  74589. size: number,
  74590. /**
  74591. * Defines if mipmaps should not be generated (default is false)
  74592. */
  74593. noMipmap?: boolean,
  74594. /**
  74595. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74596. * but the standard material would require them in Gamma space) (default is true)
  74597. */
  74598. gammaSpace?: boolean);
  74599. /**
  74600. * Execute the current task
  74601. * @param scene defines the scene where you want your assets to be loaded
  74602. * @param onSuccess is a callback called when the task is successfully executed
  74603. * @param onError is a callback called if an error occurs
  74604. */
  74605. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74606. }
  74607. /**
  74608. * This class can be used to easily import assets into a scene
  74609. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74610. */
  74611. export class AssetsManager {
  74612. private _scene;
  74613. private _isLoading;
  74614. protected _tasks: AbstractAssetTask[];
  74615. protected _waitingTasksCount: number;
  74616. protected _totalTasksCount: number;
  74617. /**
  74618. * Callback called when all tasks are processed
  74619. */
  74620. onFinish: (tasks: AbstractAssetTask[]) => void;
  74621. /**
  74622. * Callback called when a task is successful
  74623. */
  74624. onTaskSuccess: (task: AbstractAssetTask) => void;
  74625. /**
  74626. * Callback called when a task had an error
  74627. */
  74628. onTaskError: (task: AbstractAssetTask) => void;
  74629. /**
  74630. * Callback called when a task is done (whatever the result is)
  74631. */
  74632. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74633. /**
  74634. * Observable called when all tasks are processed
  74635. */
  74636. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74637. /**
  74638. * Observable called when a task had an error
  74639. */
  74640. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74641. /**
  74642. * Observable called when all tasks were executed
  74643. */
  74644. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74645. /**
  74646. * Observable called when a task is done (whatever the result is)
  74647. */
  74648. onProgressObservable: Observable<IAssetsProgressEvent>;
  74649. /**
  74650. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74651. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74652. */
  74653. useDefaultLoadingScreen: boolean;
  74654. /**
  74655. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74656. * when all assets have been downloaded.
  74657. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74658. */
  74659. autoHideLoadingUI: boolean;
  74660. /**
  74661. * Creates a new AssetsManager
  74662. * @param scene defines the scene to work on
  74663. */
  74664. constructor(scene: Scene);
  74665. /**
  74666. * Add a ContainerAssetTask to the list of active tasks
  74667. * @param taskName defines the name of the new task
  74668. * @param meshesNames defines the name of meshes to load
  74669. * @param rootUrl defines the root url to use to locate files
  74670. * @param sceneFilename defines the filename of the scene file
  74671. * @returns a new ContainerAssetTask object
  74672. */
  74673. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74674. /**
  74675. * Add a MeshAssetTask to the list of active tasks
  74676. * @param taskName defines the name of the new task
  74677. * @param meshesNames defines the name of meshes to load
  74678. * @param rootUrl defines the root url to use to locate files
  74679. * @param sceneFilename defines the filename of the scene file
  74680. * @returns a new MeshAssetTask object
  74681. */
  74682. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74683. /**
  74684. * Add a TextFileAssetTask to the list of active tasks
  74685. * @param taskName defines the name of the new task
  74686. * @param url defines the url of the file to load
  74687. * @returns a new TextFileAssetTask object
  74688. */
  74689. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74690. /**
  74691. * Add a BinaryFileAssetTask to the list of active tasks
  74692. * @param taskName defines the name of the new task
  74693. * @param url defines the url of the file to load
  74694. * @returns a new BinaryFileAssetTask object
  74695. */
  74696. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74697. /**
  74698. * Add a ImageAssetTask to the list of active tasks
  74699. * @param taskName defines the name of the new task
  74700. * @param url defines the url of the file to load
  74701. * @returns a new ImageAssetTask object
  74702. */
  74703. addImageTask(taskName: string, url: string): ImageAssetTask;
  74704. /**
  74705. * Add a TextureAssetTask to the list of active tasks
  74706. * @param taskName defines the name of the new task
  74707. * @param url defines the url of the file to load
  74708. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74709. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74710. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74711. * @returns a new TextureAssetTask object
  74712. */
  74713. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74714. /**
  74715. * Add a CubeTextureAssetTask to the list of active tasks
  74716. * @param taskName defines the name of the new task
  74717. * @param url defines the url of the file to load
  74718. * @param extensions defines the extension to use to load the cube map (can be null)
  74719. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74720. * @param files defines the list of files to load (can be null)
  74721. * @returns a new CubeTextureAssetTask object
  74722. */
  74723. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74724. /**
  74725. *
  74726. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74727. * @param taskName defines the name of the new task
  74728. * @param url defines the url of the file to load
  74729. * @param size defines the size you want for the cubemap (can be null)
  74730. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74731. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74732. * @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)
  74733. * @param reserved Internal use only
  74734. * @returns a new HDRCubeTextureAssetTask object
  74735. */
  74736. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74737. /**
  74738. *
  74739. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74740. * @param taskName defines the name of the new task
  74741. * @param url defines the url of the file to load
  74742. * @param size defines the size you want for the cubemap (can be null)
  74743. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74744. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74745. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74746. * @returns a new EquiRectangularCubeTextureAssetTask object
  74747. */
  74748. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74749. /**
  74750. * Remove a task from the assets manager.
  74751. * @param task the task to remove
  74752. */
  74753. removeTask(task: AbstractAssetTask): void;
  74754. private _decreaseWaitingTasksCount;
  74755. private _runTask;
  74756. /**
  74757. * Reset the AssetsManager and remove all tasks
  74758. * @return the current instance of the AssetsManager
  74759. */
  74760. reset(): AssetsManager;
  74761. /**
  74762. * Start the loading process
  74763. * @return the current instance of the AssetsManager
  74764. */
  74765. load(): AssetsManager;
  74766. /**
  74767. * Start the loading process as an async operation
  74768. * @return a promise returning the list of failed tasks
  74769. */
  74770. loadAsync(): Promise<void>;
  74771. }
  74772. }
  74773. declare module BABYLON {
  74774. /**
  74775. * Wrapper class for promise with external resolve and reject.
  74776. */
  74777. export class Deferred<T> {
  74778. /**
  74779. * The promise associated with this deferred object.
  74780. */
  74781. readonly promise: Promise<T>;
  74782. private _resolve;
  74783. private _reject;
  74784. /**
  74785. * The resolve method of the promise associated with this deferred object.
  74786. */
  74787. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74788. /**
  74789. * The reject method of the promise associated with this deferred object.
  74790. */
  74791. get reject(): (reason?: any) => void;
  74792. /**
  74793. * Constructor for this deferred object.
  74794. */
  74795. constructor();
  74796. }
  74797. }
  74798. declare module BABYLON {
  74799. /**
  74800. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74801. */
  74802. export class MeshExploder {
  74803. private _centerMesh;
  74804. private _meshes;
  74805. private _meshesOrigins;
  74806. private _toCenterVectors;
  74807. private _scaledDirection;
  74808. private _newPosition;
  74809. private _centerPosition;
  74810. /**
  74811. * Explodes meshes from a center mesh.
  74812. * @param meshes The meshes to explode.
  74813. * @param centerMesh The mesh to be center of explosion.
  74814. */
  74815. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74816. private _setCenterMesh;
  74817. /**
  74818. * Get class name
  74819. * @returns "MeshExploder"
  74820. */
  74821. getClassName(): string;
  74822. /**
  74823. * "Exploded meshes"
  74824. * @returns Array of meshes with the centerMesh at index 0.
  74825. */
  74826. getMeshes(): Array<Mesh>;
  74827. /**
  74828. * Explodes meshes giving a specific direction
  74829. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74830. */
  74831. explode(direction?: number): void;
  74832. }
  74833. }
  74834. declare module BABYLON {
  74835. /**
  74836. * Class used to help managing file picking and drag'n'drop
  74837. */
  74838. export class FilesInput {
  74839. /**
  74840. * List of files ready to be loaded
  74841. */
  74842. static get FilesToLoad(): {
  74843. [key: string]: File;
  74844. };
  74845. /**
  74846. * Callback called when a file is processed
  74847. */
  74848. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74849. private _engine;
  74850. private _currentScene;
  74851. private _sceneLoadedCallback;
  74852. private _progressCallback;
  74853. private _additionalRenderLoopLogicCallback;
  74854. private _textureLoadingCallback;
  74855. private _startingProcessingFilesCallback;
  74856. private _onReloadCallback;
  74857. private _errorCallback;
  74858. private _elementToMonitor;
  74859. private _sceneFileToLoad;
  74860. private _filesToLoad;
  74861. /**
  74862. * Creates a new FilesInput
  74863. * @param engine defines the rendering engine
  74864. * @param scene defines the hosting scene
  74865. * @param sceneLoadedCallback callback called when scene is loaded
  74866. * @param progressCallback callback called to track progress
  74867. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74868. * @param textureLoadingCallback callback called when a texture is loading
  74869. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74870. * @param onReloadCallback callback called when a reload is requested
  74871. * @param errorCallback callback call if an error occurs
  74872. */
  74873. 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>);
  74874. private _dragEnterHandler;
  74875. private _dragOverHandler;
  74876. private _dropHandler;
  74877. /**
  74878. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74879. * @param elementToMonitor defines the DOM element to track
  74880. */
  74881. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74882. /** Gets the current list of files to load */
  74883. get filesToLoad(): File[];
  74884. /**
  74885. * Release all associated resources
  74886. */
  74887. dispose(): void;
  74888. private renderFunction;
  74889. private drag;
  74890. private drop;
  74891. private _traverseFolder;
  74892. private _processFiles;
  74893. /**
  74894. * Load files from a drop event
  74895. * @param event defines the drop event to use as source
  74896. */
  74897. loadFiles(event: any): void;
  74898. private _processReload;
  74899. /**
  74900. * Reload the current scene from the loaded files
  74901. */
  74902. reload(): void;
  74903. }
  74904. }
  74905. declare module BABYLON {
  74906. /**
  74907. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74908. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74909. */
  74910. export class SceneOptimization {
  74911. /**
  74912. * Defines the priority of this optimization (0 by default which means first in the list)
  74913. */
  74914. priority: number;
  74915. /**
  74916. * Gets a string describing the action executed by the current optimization
  74917. * @returns description string
  74918. */
  74919. getDescription(): string;
  74920. /**
  74921. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74922. * @param scene defines the current scene where to apply this optimization
  74923. * @param optimizer defines the current optimizer
  74924. * @returns true if everything that can be done was applied
  74925. */
  74926. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74927. /**
  74928. * Creates the SceneOptimization object
  74929. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74930. * @param desc defines the description associated with the optimization
  74931. */
  74932. constructor(
  74933. /**
  74934. * Defines the priority of this optimization (0 by default which means first in the list)
  74935. */
  74936. priority?: number);
  74937. }
  74938. /**
  74939. * Defines an optimization used to reduce the size of render target textures
  74940. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74941. */
  74942. export class TextureOptimization extends SceneOptimization {
  74943. /**
  74944. * Defines the priority of this optimization (0 by default which means first in the list)
  74945. */
  74946. priority: number;
  74947. /**
  74948. * 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
  74949. */
  74950. maximumSize: number;
  74951. /**
  74952. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74953. */
  74954. step: number;
  74955. /**
  74956. * Gets a string describing the action executed by the current optimization
  74957. * @returns description string
  74958. */
  74959. getDescription(): string;
  74960. /**
  74961. * Creates the TextureOptimization object
  74962. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74963. * @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
  74964. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74965. */
  74966. constructor(
  74967. /**
  74968. * Defines the priority of this optimization (0 by default which means first in the list)
  74969. */
  74970. priority?: number,
  74971. /**
  74972. * 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
  74973. */
  74974. maximumSize?: number,
  74975. /**
  74976. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74977. */
  74978. step?: number);
  74979. /**
  74980. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74981. * @param scene defines the current scene where to apply this optimization
  74982. * @param optimizer defines the current optimizer
  74983. * @returns true if everything that can be done was applied
  74984. */
  74985. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74986. }
  74987. /**
  74988. * Defines an optimization used to increase or decrease the rendering resolution
  74989. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74990. */
  74991. export class HardwareScalingOptimization extends SceneOptimization {
  74992. /**
  74993. * Defines the priority of this optimization (0 by default which means first in the list)
  74994. */
  74995. priority: number;
  74996. /**
  74997. * Defines the maximum scale to use (2 by default)
  74998. */
  74999. maximumScale: number;
  75000. /**
  75001. * Defines the step to use between two passes (0.5 by default)
  75002. */
  75003. step: number;
  75004. private _currentScale;
  75005. private _directionOffset;
  75006. /**
  75007. * Gets a string describing the action executed by the current optimization
  75008. * @return description string
  75009. */
  75010. getDescription(): string;
  75011. /**
  75012. * Creates the HardwareScalingOptimization object
  75013. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75014. * @param maximumScale defines the maximum scale to use (2 by default)
  75015. * @param step defines the step to use between two passes (0.5 by default)
  75016. */
  75017. constructor(
  75018. /**
  75019. * Defines the priority of this optimization (0 by default which means first in the list)
  75020. */
  75021. priority?: number,
  75022. /**
  75023. * Defines the maximum scale to use (2 by default)
  75024. */
  75025. maximumScale?: number,
  75026. /**
  75027. * Defines the step to use between two passes (0.5 by default)
  75028. */
  75029. step?: number);
  75030. /**
  75031. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75032. * @param scene defines the current scene where to apply this optimization
  75033. * @param optimizer defines the current optimizer
  75034. * @returns true if everything that can be done was applied
  75035. */
  75036. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75037. }
  75038. /**
  75039. * Defines an optimization used to remove shadows
  75040. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75041. */
  75042. export class ShadowsOptimization extends SceneOptimization {
  75043. /**
  75044. * Gets a string describing the action executed by the current optimization
  75045. * @return description string
  75046. */
  75047. getDescription(): string;
  75048. /**
  75049. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75050. * @param scene defines the current scene where to apply this optimization
  75051. * @param optimizer defines the current optimizer
  75052. * @returns true if everything that can be done was applied
  75053. */
  75054. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75055. }
  75056. /**
  75057. * Defines an optimization used to turn post-processes off
  75058. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75059. */
  75060. export class PostProcessesOptimization extends SceneOptimization {
  75061. /**
  75062. * Gets a string describing the action executed by the current optimization
  75063. * @return description string
  75064. */
  75065. getDescription(): string;
  75066. /**
  75067. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75068. * @param scene defines the current scene where to apply this optimization
  75069. * @param optimizer defines the current optimizer
  75070. * @returns true if everything that can be done was applied
  75071. */
  75072. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75073. }
  75074. /**
  75075. * Defines an optimization used to turn lens flares off
  75076. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75077. */
  75078. export class LensFlaresOptimization extends SceneOptimization {
  75079. /**
  75080. * Gets a string describing the action executed by the current optimization
  75081. * @return description string
  75082. */
  75083. getDescription(): string;
  75084. /**
  75085. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75086. * @param scene defines the current scene where to apply this optimization
  75087. * @param optimizer defines the current optimizer
  75088. * @returns true if everything that can be done was applied
  75089. */
  75090. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75091. }
  75092. /**
  75093. * Defines an optimization based on user defined callback.
  75094. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75095. */
  75096. export class CustomOptimization extends SceneOptimization {
  75097. /**
  75098. * Callback called to apply the custom optimization.
  75099. */
  75100. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75101. /**
  75102. * Callback called to get custom description
  75103. */
  75104. onGetDescription: () => string;
  75105. /**
  75106. * Gets a string describing the action executed by the current optimization
  75107. * @returns description string
  75108. */
  75109. getDescription(): string;
  75110. /**
  75111. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75112. * @param scene defines the current scene where to apply this optimization
  75113. * @param optimizer defines the current optimizer
  75114. * @returns true if everything that can be done was applied
  75115. */
  75116. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75117. }
  75118. /**
  75119. * Defines an optimization used to turn particles off
  75120. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75121. */
  75122. export class ParticlesOptimization extends SceneOptimization {
  75123. /**
  75124. * Gets a string describing the action executed by the current optimization
  75125. * @return description string
  75126. */
  75127. getDescription(): string;
  75128. /**
  75129. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75130. * @param scene defines the current scene where to apply this optimization
  75131. * @param optimizer defines the current optimizer
  75132. * @returns true if everything that can be done was applied
  75133. */
  75134. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75135. }
  75136. /**
  75137. * Defines an optimization used to turn render targets off
  75138. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75139. */
  75140. export class RenderTargetsOptimization extends SceneOptimization {
  75141. /**
  75142. * Gets a string describing the action executed by the current optimization
  75143. * @return description string
  75144. */
  75145. getDescription(): string;
  75146. /**
  75147. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75148. * @param scene defines the current scene where to apply this optimization
  75149. * @param optimizer defines the current optimizer
  75150. * @returns true if everything that can be done was applied
  75151. */
  75152. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75153. }
  75154. /**
  75155. * Defines an optimization used to merge meshes with compatible materials
  75156. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75157. */
  75158. export class MergeMeshesOptimization extends SceneOptimization {
  75159. private static _UpdateSelectionTree;
  75160. /**
  75161. * Gets or sets a boolean which defines if optimization octree has to be updated
  75162. */
  75163. static get UpdateSelectionTree(): boolean;
  75164. /**
  75165. * Gets or sets a boolean which defines if optimization octree has to be updated
  75166. */
  75167. static set UpdateSelectionTree(value: boolean);
  75168. /**
  75169. * Gets a string describing the action executed by the current optimization
  75170. * @return description string
  75171. */
  75172. getDescription(): string;
  75173. private _canBeMerged;
  75174. /**
  75175. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75176. * @param scene defines the current scene where to apply this optimization
  75177. * @param optimizer defines the current optimizer
  75178. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75179. * @returns true if everything that can be done was applied
  75180. */
  75181. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75182. }
  75183. /**
  75184. * Defines a list of options used by SceneOptimizer
  75185. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75186. */
  75187. export class SceneOptimizerOptions {
  75188. /**
  75189. * Defines the target frame rate to reach (60 by default)
  75190. */
  75191. targetFrameRate: number;
  75192. /**
  75193. * Defines the interval between two checkes (2000ms by default)
  75194. */
  75195. trackerDuration: number;
  75196. /**
  75197. * Gets the list of optimizations to apply
  75198. */
  75199. optimizations: SceneOptimization[];
  75200. /**
  75201. * Creates a new list of options used by SceneOptimizer
  75202. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75203. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75204. */
  75205. constructor(
  75206. /**
  75207. * Defines the target frame rate to reach (60 by default)
  75208. */
  75209. targetFrameRate?: number,
  75210. /**
  75211. * Defines the interval between two checkes (2000ms by default)
  75212. */
  75213. trackerDuration?: number);
  75214. /**
  75215. * Add a new optimization
  75216. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75217. * @returns the current SceneOptimizerOptions
  75218. */
  75219. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75220. /**
  75221. * Add a new custom optimization
  75222. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75223. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75224. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75225. * @returns the current SceneOptimizerOptions
  75226. */
  75227. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75228. /**
  75229. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75230. * @param targetFrameRate defines the target frame rate (60 by default)
  75231. * @returns a SceneOptimizerOptions object
  75232. */
  75233. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75234. /**
  75235. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75236. * @param targetFrameRate defines the target frame rate (60 by default)
  75237. * @returns a SceneOptimizerOptions object
  75238. */
  75239. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75240. /**
  75241. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75242. * @param targetFrameRate defines the target frame rate (60 by default)
  75243. * @returns a SceneOptimizerOptions object
  75244. */
  75245. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75246. }
  75247. /**
  75248. * Class used to run optimizations in order to reach a target frame rate
  75249. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75250. */
  75251. export class SceneOptimizer implements IDisposable {
  75252. private _isRunning;
  75253. private _options;
  75254. private _scene;
  75255. private _currentPriorityLevel;
  75256. private _targetFrameRate;
  75257. private _trackerDuration;
  75258. private _currentFrameRate;
  75259. private _sceneDisposeObserver;
  75260. private _improvementMode;
  75261. /**
  75262. * Defines an observable called when the optimizer reaches the target frame rate
  75263. */
  75264. onSuccessObservable: Observable<SceneOptimizer>;
  75265. /**
  75266. * Defines an observable called when the optimizer enables an optimization
  75267. */
  75268. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75269. /**
  75270. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75271. */
  75272. onFailureObservable: Observable<SceneOptimizer>;
  75273. /**
  75274. * Gets a boolean indicating if the optimizer is in improvement mode
  75275. */
  75276. get isInImprovementMode(): boolean;
  75277. /**
  75278. * Gets the current priority level (0 at start)
  75279. */
  75280. get currentPriorityLevel(): number;
  75281. /**
  75282. * Gets the current frame rate checked by the SceneOptimizer
  75283. */
  75284. get currentFrameRate(): number;
  75285. /**
  75286. * Gets or sets the current target frame rate (60 by default)
  75287. */
  75288. get targetFrameRate(): number;
  75289. /**
  75290. * Gets or sets the current target frame rate (60 by default)
  75291. */
  75292. set targetFrameRate(value: number);
  75293. /**
  75294. * Gets or sets the current interval between two checks (every 2000ms by default)
  75295. */
  75296. get trackerDuration(): number;
  75297. /**
  75298. * Gets or sets the current interval between two checks (every 2000ms by default)
  75299. */
  75300. set trackerDuration(value: number);
  75301. /**
  75302. * Gets the list of active optimizations
  75303. */
  75304. get optimizations(): SceneOptimization[];
  75305. /**
  75306. * Creates a new SceneOptimizer
  75307. * @param scene defines the scene to work on
  75308. * @param options defines the options to use with the SceneOptimizer
  75309. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75310. * @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)
  75311. */
  75312. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75313. /**
  75314. * Stops the current optimizer
  75315. */
  75316. stop(): void;
  75317. /**
  75318. * Reset the optimizer to initial step (current priority level = 0)
  75319. */
  75320. reset(): void;
  75321. /**
  75322. * Start the optimizer. By default it will try to reach a specific framerate
  75323. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75324. */
  75325. start(): void;
  75326. private _checkCurrentState;
  75327. /**
  75328. * Release all resources
  75329. */
  75330. dispose(): void;
  75331. /**
  75332. * Helper function to create a SceneOptimizer with one single line of code
  75333. * @param scene defines the scene to work on
  75334. * @param options defines the options to use with the SceneOptimizer
  75335. * @param onSuccess defines a callback to call on success
  75336. * @param onFailure defines a callback to call on failure
  75337. * @returns the new SceneOptimizer object
  75338. */
  75339. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75340. }
  75341. }
  75342. declare module BABYLON {
  75343. /**
  75344. * Class used to serialize a scene into a string
  75345. */
  75346. export class SceneSerializer {
  75347. /**
  75348. * Clear cache used by a previous serialization
  75349. */
  75350. static ClearCache(): void;
  75351. /**
  75352. * Serialize a scene into a JSON compatible object
  75353. * @param scene defines the scene to serialize
  75354. * @returns a JSON compatible object
  75355. */
  75356. static Serialize(scene: Scene): any;
  75357. /**
  75358. * Serialize a mesh into a JSON compatible object
  75359. * @param toSerialize defines the mesh to serialize
  75360. * @param withParents defines if parents must be serialized as well
  75361. * @param withChildren defines if children must be serialized as well
  75362. * @returns a JSON compatible object
  75363. */
  75364. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75365. }
  75366. }
  75367. declare module BABYLON {
  75368. /**
  75369. * Class used to host texture specific utilities
  75370. */
  75371. export class TextureTools {
  75372. /**
  75373. * Uses the GPU to create a copy texture rescaled at a given size
  75374. * @param texture Texture to copy from
  75375. * @param width defines the desired width
  75376. * @param height defines the desired height
  75377. * @param useBilinearMode defines if bilinear mode has to be used
  75378. * @return the generated texture
  75379. */
  75380. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75381. }
  75382. }
  75383. declare module BABYLON {
  75384. /**
  75385. * This represents the different options available for the video capture.
  75386. */
  75387. export interface VideoRecorderOptions {
  75388. /** Defines the mime type of the video. */
  75389. mimeType: string;
  75390. /** Defines the FPS the video should be recorded at. */
  75391. fps: number;
  75392. /** Defines the chunk size for the recording data. */
  75393. recordChunckSize: number;
  75394. /** The audio tracks to attach to the recording. */
  75395. audioTracks?: MediaStreamTrack[];
  75396. }
  75397. /**
  75398. * This can help with recording videos from BabylonJS.
  75399. * This is based on the available WebRTC functionalities of the browser.
  75400. *
  75401. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75402. */
  75403. export class VideoRecorder {
  75404. private static readonly _defaultOptions;
  75405. /**
  75406. * Returns whether or not the VideoRecorder is available in your browser.
  75407. * @param engine Defines the Babylon Engine.
  75408. * @returns true if supported otherwise false.
  75409. */
  75410. static IsSupported(engine: Engine): boolean;
  75411. private readonly _options;
  75412. private _canvas;
  75413. private _mediaRecorder;
  75414. private _recordedChunks;
  75415. private _fileName;
  75416. private _resolve;
  75417. private _reject;
  75418. /**
  75419. * True when a recording is already in progress.
  75420. */
  75421. get isRecording(): boolean;
  75422. /**
  75423. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75424. * @param engine Defines the BabylonJS Engine you wish to record.
  75425. * @param options Defines options that can be used to customize the capture.
  75426. */
  75427. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75428. /**
  75429. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75430. */
  75431. stopRecording(): void;
  75432. /**
  75433. * Starts recording the canvas for a max duration specified in parameters.
  75434. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75435. * If null no automatic download will start and you can rely on the promise to get the data back.
  75436. * @param maxDuration Defines the maximum recording time in seconds.
  75437. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75438. * @return A promise callback at the end of the recording with the video data in Blob.
  75439. */
  75440. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75441. /**
  75442. * Releases internal resources used during the recording.
  75443. */
  75444. dispose(): void;
  75445. private _handleDataAvailable;
  75446. private _handleError;
  75447. private _handleStop;
  75448. }
  75449. }
  75450. declare module BABYLON {
  75451. /**
  75452. * Class containing a set of static utilities functions for screenshots
  75453. */
  75454. export class ScreenshotTools {
  75455. /**
  75456. * Captures a screenshot of the current rendering
  75457. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75458. * @param engine defines the rendering engine
  75459. * @param camera defines the source camera
  75460. * @param size This parameter can be set to a single number or to an object with the
  75461. * following (optional) properties: precision, width, height. If a single number is passed,
  75462. * it will be used for both width and height. If an object is passed, the screenshot size
  75463. * will be derived from the parameters. The precision property is a multiplier allowing
  75464. * rendering at a higher or lower resolution
  75465. * @param successCallback defines the callback receives a single parameter which contains the
  75466. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75467. * src parameter of an <img> to display it
  75468. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75469. * Check your browser for supported MIME types
  75470. */
  75471. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75472. /**
  75473. * Captures a screenshot of the current rendering
  75474. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75475. * @param engine defines the rendering engine
  75476. * @param camera defines the source camera
  75477. * @param size This parameter can be set to a single number or to an object with the
  75478. * following (optional) properties: precision, width, height. If a single number is passed,
  75479. * it will be used for both width and height. If an object is passed, the screenshot size
  75480. * will be derived from the parameters. The precision property is a multiplier allowing
  75481. * rendering at a higher or lower resolution
  75482. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75483. * Check your browser for supported MIME types
  75484. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75485. * to the src parameter of an <img> to display it
  75486. */
  75487. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75488. /**
  75489. * Generates an image screenshot from the specified camera.
  75490. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75491. * @param engine The engine to use for rendering
  75492. * @param camera The camera to use for rendering
  75493. * @param size This parameter can be set to a single number or to an object with the
  75494. * following (optional) properties: precision, width, height. If a single number is passed,
  75495. * it will be used for both width and height. If an object is passed, the screenshot size
  75496. * will be derived from the parameters. The precision property is a multiplier allowing
  75497. * rendering at a higher or lower resolution
  75498. * @param successCallback The callback receives a single parameter which contains the
  75499. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75500. * src parameter of an <img> to display it
  75501. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75502. * Check your browser for supported MIME types
  75503. * @param samples Texture samples (default: 1)
  75504. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75505. * @param fileName A name for for the downloaded file.
  75506. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75507. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75508. */
  75509. 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;
  75510. /**
  75511. * Generates an image screenshot from the specified camera.
  75512. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75513. * @param engine The engine to use for rendering
  75514. * @param camera The camera to use for rendering
  75515. * @param size This parameter can be set to a single number or to an object with the
  75516. * following (optional) properties: precision, width, height. If a single number is passed,
  75517. * it will be used for both width and height. If an object is passed, the screenshot size
  75518. * will be derived from the parameters. The precision property is a multiplier allowing
  75519. * rendering at a higher or lower resolution
  75520. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75521. * Check your browser for supported MIME types
  75522. * @param samples Texture samples (default: 1)
  75523. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75524. * @param fileName A name for for the downloaded file.
  75525. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75526. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75527. * to the src parameter of an <img> to display it
  75528. */
  75529. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75530. /**
  75531. * Gets height and width for screenshot size
  75532. * @private
  75533. */
  75534. private static _getScreenshotSize;
  75535. }
  75536. }
  75537. declare module BABYLON {
  75538. /**
  75539. * Interface for a data buffer
  75540. */
  75541. export interface IDataBuffer {
  75542. /**
  75543. * Reads bytes from the data buffer.
  75544. * @param byteOffset The byte offset to read
  75545. * @param byteLength The byte length to read
  75546. * @returns A promise that resolves when the bytes are read
  75547. */
  75548. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75549. /**
  75550. * The byte length of the buffer.
  75551. */
  75552. readonly byteLength: number;
  75553. }
  75554. /**
  75555. * Utility class for reading from a data buffer
  75556. */
  75557. export class DataReader {
  75558. /**
  75559. * The data buffer associated with this data reader.
  75560. */
  75561. readonly buffer: IDataBuffer;
  75562. /**
  75563. * The current byte offset from the beginning of the data buffer.
  75564. */
  75565. byteOffset: number;
  75566. private _dataView;
  75567. private _dataByteOffset;
  75568. /**
  75569. * Constructor
  75570. * @param buffer The buffer to read
  75571. */
  75572. constructor(buffer: IDataBuffer);
  75573. /**
  75574. * Loads the given byte length.
  75575. * @param byteLength The byte length to load
  75576. * @returns A promise that resolves when the load is complete
  75577. */
  75578. loadAsync(byteLength: number): Promise<void>;
  75579. /**
  75580. * Read a unsigned 32-bit integer from the currently loaded data range.
  75581. * @returns The 32-bit integer read
  75582. */
  75583. readUint32(): number;
  75584. /**
  75585. * Read a byte array from the currently loaded data range.
  75586. * @param byteLength The byte length to read
  75587. * @returns The byte array read
  75588. */
  75589. readUint8Array(byteLength: number): Uint8Array;
  75590. /**
  75591. * Read a string from the currently loaded data range.
  75592. * @param byteLength The byte length to read
  75593. * @returns The string read
  75594. */
  75595. readString(byteLength: number): string;
  75596. /**
  75597. * Skips the given byte length the currently loaded data range.
  75598. * @param byteLength The byte length to skip
  75599. */
  75600. skipBytes(byteLength: number): void;
  75601. }
  75602. }
  75603. declare module BABYLON {
  75604. /**
  75605. * Class for storing data to local storage if available or in-memory storage otherwise
  75606. */
  75607. export class DataStorage {
  75608. private static _Storage;
  75609. private static _GetStorage;
  75610. /**
  75611. * Reads a string from the data storage
  75612. * @param key The key to read
  75613. * @param defaultValue The value if the key doesn't exist
  75614. * @returns The string value
  75615. */
  75616. static ReadString(key: string, defaultValue: string): string;
  75617. /**
  75618. * Writes a string to the data storage
  75619. * @param key The key to write
  75620. * @param value The value to write
  75621. */
  75622. static WriteString(key: string, value: string): void;
  75623. /**
  75624. * Reads a boolean from the data storage
  75625. * @param key The key to read
  75626. * @param defaultValue The value if the key doesn't exist
  75627. * @returns The boolean value
  75628. */
  75629. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75630. /**
  75631. * Writes a boolean to the data storage
  75632. * @param key The key to write
  75633. * @param value The value to write
  75634. */
  75635. static WriteBoolean(key: string, value: boolean): void;
  75636. /**
  75637. * Reads a number from the data storage
  75638. * @param key The key to read
  75639. * @param defaultValue The value if the key doesn't exist
  75640. * @returns The number value
  75641. */
  75642. static ReadNumber(key: string, defaultValue: number): number;
  75643. /**
  75644. * Writes a number to the data storage
  75645. * @param key The key to write
  75646. * @param value The value to write
  75647. */
  75648. static WriteNumber(key: string, value: number): void;
  75649. }
  75650. }
  75651. declare module BABYLON {
  75652. /**
  75653. * Class used to record delta files between 2 scene states
  75654. */
  75655. export class SceneRecorder {
  75656. private _trackedScene;
  75657. private _savedJSON;
  75658. /**
  75659. * Track a given scene. This means the current scene state will be considered the original state
  75660. * @param scene defines the scene to track
  75661. */
  75662. track(scene: Scene): void;
  75663. /**
  75664. * Get the delta between current state and original state
  75665. * @returns a string containing the delta
  75666. */
  75667. getDelta(): any;
  75668. private _compareArray;
  75669. private _compareObjects;
  75670. private _compareCollections;
  75671. private static GetShadowGeneratorById;
  75672. /**
  75673. * Apply a given delta to a given scene
  75674. * @param deltaJSON defines the JSON containing the delta
  75675. * @param scene defines the scene to apply the delta to
  75676. */
  75677. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75678. private static _ApplyPropertiesToEntity;
  75679. private static _ApplyDeltaForEntity;
  75680. }
  75681. }
  75682. declare module BABYLON {
  75683. /**
  75684. * A 3D trajectory consisting of an order list of vectors describing a
  75685. * path of motion through 3D space.
  75686. */
  75687. export class Trajectory {
  75688. private _points;
  75689. private readonly _segmentLength;
  75690. /**
  75691. * Serialize to JSON.
  75692. * @returns serialized JSON string
  75693. */
  75694. serialize(): string;
  75695. /**
  75696. * Deserialize from JSON.
  75697. * @param json serialized JSON string
  75698. * @returns deserialized Trajectory
  75699. */
  75700. static Deserialize(json: string): Trajectory;
  75701. /**
  75702. * Create a new empty Trajectory.
  75703. * @param segmentLength radius of discretization for Trajectory points
  75704. */
  75705. constructor(segmentLength?: number);
  75706. /**
  75707. * Get the length of the Trajectory.
  75708. * @returns length of the Trajectory
  75709. */
  75710. getLength(): number;
  75711. /**
  75712. * Append a new point to the Trajectory.
  75713. * NOTE: This implementation has many allocations.
  75714. * @param point point to append to the Trajectory
  75715. */
  75716. add(point: DeepImmutable<Vector3>): void;
  75717. /**
  75718. * Create a new Trajectory with a segment length chosen to make it
  75719. * probable that the new Trajectory will have a specified number of
  75720. * segments. This operation is imprecise.
  75721. * @param targetResolution number of segments desired
  75722. * @returns new Trajectory with approximately the requested number of segments
  75723. */
  75724. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75725. /**
  75726. * Convert Trajectory segments into tokenized representation. This
  75727. * representation is an array of numbers where each nth number is the
  75728. * index of the token which is most similar to the nth segment of the
  75729. * Trajectory.
  75730. * @param tokens list of vectors which serve as discrete tokens
  75731. * @returns list of indices of most similar token per segment
  75732. */
  75733. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75734. private static _forwardDir;
  75735. private static _inverseFromVec;
  75736. private static _upDir;
  75737. private static _fromToVec;
  75738. private static _lookMatrix;
  75739. /**
  75740. * Transform the rotation (i.e., direction) of a segment to isolate
  75741. * the relative transformation represented by the segment. This operation
  75742. * may or may not succeed due to singularities in the equations that define
  75743. * motion relativity in this context.
  75744. * @param priorVec the origin of the prior segment
  75745. * @param fromVec the origin of the current segment
  75746. * @param toVec the destination of the current segment
  75747. * @param result reference to output variable
  75748. * @returns whether or not transformation was successful
  75749. */
  75750. private static _transformSegmentDirToRef;
  75751. private static _bestMatch;
  75752. private static _score;
  75753. private static _bestScore;
  75754. /**
  75755. * Determine which token vector is most similar to the
  75756. * segment vector.
  75757. * @param segment segment vector
  75758. * @param tokens token vector list
  75759. * @returns index of the most similar token to the segment
  75760. */
  75761. private static _tokenizeSegment;
  75762. }
  75763. /**
  75764. * Class representing a set of known, named trajectories to which Trajectories can be
  75765. * added and using which Trajectories can be recognized.
  75766. */
  75767. export class TrajectoryClassifier {
  75768. private _maximumAllowableMatchCost;
  75769. private _vector3Alphabet;
  75770. private _levenshteinAlphabet;
  75771. private _nameToDescribedTrajectory;
  75772. /**
  75773. * Serialize to JSON.
  75774. * @returns JSON serialization
  75775. */
  75776. serialize(): string;
  75777. /**
  75778. * Deserialize from JSON.
  75779. * @param json JSON serialization
  75780. * @returns deserialized TrajectorySet
  75781. */
  75782. static Deserialize(json: string): TrajectoryClassifier;
  75783. /**
  75784. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75785. * VERY naive, need to be generating these things from known
  75786. * sets. Better version later, probably eliminating this one.
  75787. * @returns auto-generated TrajectorySet
  75788. */
  75789. static Generate(): TrajectoryClassifier;
  75790. private constructor();
  75791. /**
  75792. * Add a new Trajectory to the set with a given name.
  75793. * @param trajectory new Trajectory to be added
  75794. * @param classification name to which to add the Trajectory
  75795. */
  75796. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75797. /**
  75798. * Remove a known named trajectory and all Trajectories associated with it.
  75799. * @param classification name to remove
  75800. * @returns whether anything was removed
  75801. */
  75802. deleteClassification(classification: string): boolean;
  75803. /**
  75804. * Attempt to recognize a Trajectory from among all the classifications
  75805. * already known to the classifier.
  75806. * @param trajectory Trajectory to be recognized
  75807. * @returns classification of Trajectory if recognized, null otherwise
  75808. */
  75809. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75810. }
  75811. }
  75812. declare module BABYLON {
  75813. /**
  75814. * An interface for all Hit test features
  75815. */
  75816. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75817. /**
  75818. * Triggered when new babylon (transformed) hit test results are available
  75819. */
  75820. onHitTestResultObservable: Observable<T[]>;
  75821. }
  75822. /**
  75823. * Options used for hit testing
  75824. */
  75825. export interface IWebXRLegacyHitTestOptions {
  75826. /**
  75827. * Only test when user interacted with the scene. Default - hit test every frame
  75828. */
  75829. testOnPointerDownOnly?: boolean;
  75830. /**
  75831. * The node to use to transform the local results to world coordinates
  75832. */
  75833. worldParentNode?: TransformNode;
  75834. }
  75835. /**
  75836. * Interface defining the babylon result of raycasting/hit-test
  75837. */
  75838. export interface IWebXRLegacyHitResult {
  75839. /**
  75840. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75841. */
  75842. transformationMatrix: Matrix;
  75843. /**
  75844. * The native hit test result
  75845. */
  75846. xrHitResult: XRHitResult | XRHitTestResult;
  75847. }
  75848. /**
  75849. * The currently-working hit-test module.
  75850. * Hit test (or Ray-casting) is used to interact with the real world.
  75851. * For further information read here - https://github.com/immersive-web/hit-test
  75852. */
  75853. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75854. /**
  75855. * options to use when constructing this feature
  75856. */
  75857. readonly options: IWebXRLegacyHitTestOptions;
  75858. private _direction;
  75859. private _mat;
  75860. private _onSelectEnabled;
  75861. private _origin;
  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. * Populated with the last native XR Hit Results
  75874. */
  75875. lastNativeXRHitResults: XRHitResult[];
  75876. /**
  75877. * Triggered when new babylon (transformed) hit test results are available
  75878. */
  75879. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75880. /**
  75881. * Creates a new instance of the (legacy version) hit test feature
  75882. * @param _xrSessionManager an instance of WebXRSessionManager
  75883. * @param options options to use when constructing this feature
  75884. */
  75885. constructor(_xrSessionManager: WebXRSessionManager,
  75886. /**
  75887. * options to use when constructing this feature
  75888. */
  75889. options?: IWebXRLegacyHitTestOptions);
  75890. /**
  75891. * execute a hit test with an XR Ray
  75892. *
  75893. * @param xrSession a native xrSession that will execute this hit test
  75894. * @param xrRay the ray (position and direction) to use for ray-casting
  75895. * @param referenceSpace native XR reference space to use for the hit-test
  75896. * @param filter filter function that will filter the results
  75897. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75898. */
  75899. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75900. /**
  75901. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75902. * @param event the (select) event to use to select with
  75903. * @param referenceSpace the reference space to use for this hit test
  75904. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75905. */
  75906. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75907. /**
  75908. * attach this feature
  75909. * Will usually be called by the features manager
  75910. *
  75911. * @returns true if successful.
  75912. */
  75913. attach(): boolean;
  75914. /**
  75915. * detach this feature.
  75916. * Will usually be called by the features manager
  75917. *
  75918. * @returns true if successful.
  75919. */
  75920. detach(): boolean;
  75921. /**
  75922. * Dispose this feature and all of the resources attached
  75923. */
  75924. dispose(): void;
  75925. protected _onXRFrame(frame: XRFrame): void;
  75926. private _onHitTestResults;
  75927. private _onSelect;
  75928. }
  75929. }
  75930. declare module BABYLON {
  75931. /**
  75932. * Options used for hit testing (version 2)
  75933. */
  75934. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75935. /**
  75936. * Do not create a permanent hit test. Will usually be used when only
  75937. * transient inputs are needed.
  75938. */
  75939. disablePermanentHitTest?: boolean;
  75940. /**
  75941. * Enable transient (for example touch-based) hit test inspections
  75942. */
  75943. enableTransientHitTest?: boolean;
  75944. /**
  75945. * Offset ray for the permanent hit test
  75946. */
  75947. offsetRay?: Vector3;
  75948. /**
  75949. * Offset ray for the transient hit test
  75950. */
  75951. transientOffsetRay?: Vector3;
  75952. /**
  75953. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75954. */
  75955. useReferenceSpace?: boolean;
  75956. /**
  75957. * Override the default entity type(s) of the hit-test result
  75958. */
  75959. entityTypes?: XRHitTestTrackableType[];
  75960. }
  75961. /**
  75962. * Interface defining the babylon result of hit-test
  75963. */
  75964. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75965. /**
  75966. * The input source that generated this hit test (if transient)
  75967. */
  75968. inputSource?: XRInputSource;
  75969. /**
  75970. * Is this a transient hit test
  75971. */
  75972. isTransient?: boolean;
  75973. /**
  75974. * Position of the hit test result
  75975. */
  75976. position: Vector3;
  75977. /**
  75978. * Rotation of the hit test result
  75979. */
  75980. rotationQuaternion: Quaternion;
  75981. /**
  75982. * The native hit test result
  75983. */
  75984. xrHitResult: XRHitTestResult;
  75985. }
  75986. /**
  75987. * The currently-working hit-test module.
  75988. * Hit test (or Ray-casting) is used to interact with the real world.
  75989. * For further information read here - https://github.com/immersive-web/hit-test
  75990. *
  75991. * Tested on chrome (mobile) 80.
  75992. */
  75993. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75994. /**
  75995. * options to use when constructing this feature
  75996. */
  75997. readonly options: IWebXRHitTestOptions;
  75998. private _tmpMat;
  75999. private _tmpPos;
  76000. private _tmpQuat;
  76001. private _transientXrHitTestSource;
  76002. private _xrHitTestSource;
  76003. private initHitTestSource;
  76004. /**
  76005. * The module's name
  76006. */
  76007. static readonly Name: string;
  76008. /**
  76009. * The (Babylon) version of this module.
  76010. * This is an integer representing the implementation version.
  76011. * This number does not correspond to the WebXR specs version
  76012. */
  76013. static readonly Version: number;
  76014. /**
  76015. * When set to true, each hit test will have its own position/rotation objects
  76016. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76017. * the developers will clone them or copy them as they see fit.
  76018. */
  76019. autoCloneTransformation: boolean;
  76020. /**
  76021. * Triggered when new babylon (transformed) hit test results are available
  76022. * Note - this will be called when results come back from the device. It can be an empty array!!
  76023. */
  76024. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76025. /**
  76026. * Use this to temporarily pause hit test checks.
  76027. */
  76028. paused: boolean;
  76029. /**
  76030. * Creates a new instance of the hit test feature
  76031. * @param _xrSessionManager an instance of WebXRSessionManager
  76032. * @param options options to use when constructing this feature
  76033. */
  76034. constructor(_xrSessionManager: WebXRSessionManager,
  76035. /**
  76036. * options to use when constructing this feature
  76037. */
  76038. options?: IWebXRHitTestOptions);
  76039. /**
  76040. * attach this feature
  76041. * Will usually be called by the features manager
  76042. *
  76043. * @returns true if successful.
  76044. */
  76045. attach(): boolean;
  76046. /**
  76047. * detach this feature.
  76048. * Will usually be called by the features manager
  76049. *
  76050. * @returns true if successful.
  76051. */
  76052. detach(): boolean;
  76053. /**
  76054. * Dispose this feature and all of the resources attached
  76055. */
  76056. dispose(): void;
  76057. protected _onXRFrame(frame: XRFrame): void;
  76058. private _processWebXRHitTestResult;
  76059. }
  76060. }
  76061. declare module BABYLON {
  76062. /**
  76063. * Configuration options of the anchor system
  76064. */
  76065. export interface IWebXRAnchorSystemOptions {
  76066. /**
  76067. * a node that will be used to convert local to world coordinates
  76068. */
  76069. worldParentNode?: TransformNode;
  76070. /**
  76071. * If set to true a reference of the created anchors will be kept until the next session starts
  76072. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76073. */
  76074. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76075. }
  76076. /**
  76077. * A babylon container for an XR Anchor
  76078. */
  76079. export interface IWebXRAnchor {
  76080. /**
  76081. * A babylon-assigned ID for this anchor
  76082. */
  76083. id: number;
  76084. /**
  76085. * Transformation matrix to apply to an object attached to this anchor
  76086. */
  76087. transformationMatrix: Matrix;
  76088. /**
  76089. * The native anchor object
  76090. */
  76091. xrAnchor: XRAnchor;
  76092. /**
  76093. * if defined, this object will be constantly updated by the anchor's position and rotation
  76094. */
  76095. attachedNode?: TransformNode;
  76096. }
  76097. /**
  76098. * An implementation of the anchor system for WebXR.
  76099. * For further information see https://github.com/immersive-web/anchors/
  76100. */
  76101. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76102. private _options;
  76103. private _lastFrameDetected;
  76104. private _trackedAnchors;
  76105. private _referenceSpaceForFrameAnchors;
  76106. private _futureAnchors;
  76107. /**
  76108. * The module's name
  76109. */
  76110. static readonly Name: string;
  76111. /**
  76112. * The (Babylon) version of this module.
  76113. * This is an integer representing the implementation version.
  76114. * This number does not correspond to the WebXR specs version
  76115. */
  76116. static readonly Version: number;
  76117. /**
  76118. * Observers registered here will be executed when a new anchor was added to the session
  76119. */
  76120. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76121. /**
  76122. * Observers registered here will be executed when an anchor was removed from the session
  76123. */
  76124. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76125. /**
  76126. * Observers registered here will be executed when an existing anchor updates
  76127. * This can execute N times every frame
  76128. */
  76129. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76130. /**
  76131. * Set the reference space to use for anchor creation, when not using a hit test.
  76132. * Will default to the session's reference space if not defined
  76133. */
  76134. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76135. /**
  76136. * constructs a new anchor system
  76137. * @param _xrSessionManager an instance of WebXRSessionManager
  76138. * @param _options configuration object for this feature
  76139. */
  76140. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76141. private _tmpVector;
  76142. private _tmpQuaternion;
  76143. private _populateTmpTransformation;
  76144. /**
  76145. * Create a new anchor point using a hit test result at a specific point in the scene
  76146. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76147. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76148. *
  76149. * @param hitTestResult The hit test result to use for this anchor creation
  76150. * @param position an optional position offset for this anchor
  76151. * @param rotationQuaternion an optional rotation offset for this anchor
  76152. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76153. */
  76154. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  76155. /**
  76156. * Add a new anchor at a specific position and rotation
  76157. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76158. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76159. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76160. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76161. *
  76162. * @param position the position in which to add an anchor
  76163. * @param rotationQuaternion an optional rotation for the anchor transformation
  76164. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76165. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76166. */
  76167. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  76168. /**
  76169. * detach this feature.
  76170. * Will usually be called by the features manager
  76171. *
  76172. * @returns true if successful.
  76173. */
  76174. detach(): boolean;
  76175. /**
  76176. * Dispose this feature and all of the resources attached
  76177. */
  76178. dispose(): void;
  76179. protected _onXRFrame(frame: XRFrame): void;
  76180. /**
  76181. * avoiding using Array.find for global support.
  76182. * @param xrAnchor the plane to find in the array
  76183. */
  76184. private _findIndexInAnchorArray;
  76185. private _updateAnchorWithXRFrame;
  76186. private _createAnchorAtTransformation;
  76187. }
  76188. }
  76189. declare module BABYLON {
  76190. /**
  76191. * Options used in the plane detector module
  76192. */
  76193. export interface IWebXRPlaneDetectorOptions {
  76194. /**
  76195. * The node to use to transform the local results to world coordinates
  76196. */
  76197. worldParentNode?: TransformNode;
  76198. /**
  76199. * If set to true a reference of the created planes will be kept until the next session starts
  76200. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76201. */
  76202. doNotRemovePlanesOnSessionEnded?: boolean;
  76203. }
  76204. /**
  76205. * A babylon interface for a WebXR plane.
  76206. * A Plane is actually a polygon, built from N points in space
  76207. *
  76208. * Supported in chrome 79, not supported in canary 81 ATM
  76209. */
  76210. export interface IWebXRPlane {
  76211. /**
  76212. * a babylon-assigned ID for this polygon
  76213. */
  76214. id: number;
  76215. /**
  76216. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76217. */
  76218. polygonDefinition: Array<Vector3>;
  76219. /**
  76220. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76221. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76222. */
  76223. transformationMatrix: Matrix;
  76224. /**
  76225. * the native xr-plane object
  76226. */
  76227. xrPlane: XRPlane;
  76228. }
  76229. /**
  76230. * The plane detector is used to detect planes in the real world when in AR
  76231. * For more information see https://github.com/immersive-web/real-world-geometry/
  76232. */
  76233. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76234. private _options;
  76235. private _detectedPlanes;
  76236. private _enabled;
  76237. private _lastFrameDetected;
  76238. /**
  76239. * The module's name
  76240. */
  76241. static readonly Name: string;
  76242. /**
  76243. * The (Babylon) version of this module.
  76244. * This is an integer representing the implementation version.
  76245. * This number does not correspond to the WebXR specs version
  76246. */
  76247. static readonly Version: number;
  76248. /**
  76249. * Observers registered here will be executed when a new plane was added to the session
  76250. */
  76251. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76252. /**
  76253. * Observers registered here will be executed when a plane is no longer detected in the session
  76254. */
  76255. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76256. /**
  76257. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76258. * This can execute N times every frame
  76259. */
  76260. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76261. /**
  76262. * construct a new Plane Detector
  76263. * @param _xrSessionManager an instance of xr Session manager
  76264. * @param _options configuration to use when constructing this feature
  76265. */
  76266. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76267. /**
  76268. * detach this feature.
  76269. * Will usually be called by the features manager
  76270. *
  76271. * @returns true if successful.
  76272. */
  76273. detach(): boolean;
  76274. /**
  76275. * Dispose this feature and all of the resources attached
  76276. */
  76277. dispose(): void;
  76278. /**
  76279. * Check if the needed objects are defined.
  76280. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76281. */
  76282. isCompatible(): boolean;
  76283. protected _onXRFrame(frame: XRFrame): void;
  76284. private _init;
  76285. private _updatePlaneWithXRPlane;
  76286. /**
  76287. * avoiding using Array.find for global support.
  76288. * @param xrPlane the plane to find in the array
  76289. */
  76290. private findIndexInPlaneArray;
  76291. }
  76292. }
  76293. declare module BABYLON {
  76294. /**
  76295. * Options interface for the background remover plugin
  76296. */
  76297. export interface IWebXRBackgroundRemoverOptions {
  76298. /**
  76299. * Further background meshes to disable when entering AR
  76300. */
  76301. backgroundMeshes?: AbstractMesh[];
  76302. /**
  76303. * flags to configure the removal of the environment helper.
  76304. * If not set, the entire background will be removed. If set, flags should be set as well.
  76305. */
  76306. environmentHelperRemovalFlags?: {
  76307. /**
  76308. * Should the skybox be removed (default false)
  76309. */
  76310. skyBox?: boolean;
  76311. /**
  76312. * Should the ground be removed (default false)
  76313. */
  76314. ground?: boolean;
  76315. };
  76316. /**
  76317. * don't disable the environment helper
  76318. */
  76319. ignoreEnvironmentHelper?: boolean;
  76320. }
  76321. /**
  76322. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76323. */
  76324. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76325. /**
  76326. * read-only options to be used in this module
  76327. */
  76328. readonly options: IWebXRBackgroundRemoverOptions;
  76329. /**
  76330. * The module's name
  76331. */
  76332. static readonly Name: string;
  76333. /**
  76334. * The (Babylon) version of this module.
  76335. * This is an integer representing the implementation version.
  76336. * This number does not correspond to the WebXR specs version
  76337. */
  76338. static readonly Version: number;
  76339. /**
  76340. * registered observers will be triggered when the background state changes
  76341. */
  76342. onBackgroundStateChangedObservable: Observable<boolean>;
  76343. /**
  76344. * constructs a new background remover module
  76345. * @param _xrSessionManager the session manager for this module
  76346. * @param options read-only options to be used in this module
  76347. */
  76348. constructor(_xrSessionManager: WebXRSessionManager,
  76349. /**
  76350. * read-only options to be used in this module
  76351. */
  76352. options?: IWebXRBackgroundRemoverOptions);
  76353. /**
  76354. * attach this feature
  76355. * Will usually be called by the features manager
  76356. *
  76357. * @returns true if successful.
  76358. */
  76359. attach(): boolean;
  76360. /**
  76361. * detach this feature.
  76362. * Will usually be called by the features manager
  76363. *
  76364. * @returns true if successful.
  76365. */
  76366. detach(): boolean;
  76367. /**
  76368. * Dispose this feature and all of the resources attached
  76369. */
  76370. dispose(): void;
  76371. protected _onXRFrame(_xrFrame: XRFrame): void;
  76372. private _setBackgroundState;
  76373. }
  76374. }
  76375. declare module BABYLON {
  76376. /**
  76377. * Options for the controller physics feature
  76378. */
  76379. export class IWebXRControllerPhysicsOptions {
  76380. /**
  76381. * Should the headset get its own impostor
  76382. */
  76383. enableHeadsetImpostor?: boolean;
  76384. /**
  76385. * Optional parameters for the headset impostor
  76386. */
  76387. headsetImpostorParams?: {
  76388. /**
  76389. * The type of impostor to create. Default is sphere
  76390. */
  76391. impostorType: number;
  76392. /**
  76393. * the size of the impostor. Defaults to 10cm
  76394. */
  76395. impostorSize?: number | {
  76396. width: number;
  76397. height: number;
  76398. depth: number;
  76399. };
  76400. /**
  76401. * Friction definitions
  76402. */
  76403. friction?: number;
  76404. /**
  76405. * Restitution
  76406. */
  76407. restitution?: number;
  76408. };
  76409. /**
  76410. * The physics properties of the future impostors
  76411. */
  76412. physicsProperties?: {
  76413. /**
  76414. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76415. * Note that this requires a physics engine that supports mesh impostors!
  76416. */
  76417. useControllerMesh?: boolean;
  76418. /**
  76419. * The type of impostor to create. Default is sphere
  76420. */
  76421. impostorType?: number;
  76422. /**
  76423. * the size of the impostor. Defaults to 10cm
  76424. */
  76425. impostorSize?: number | {
  76426. width: number;
  76427. height: number;
  76428. depth: number;
  76429. };
  76430. /**
  76431. * Friction definitions
  76432. */
  76433. friction?: number;
  76434. /**
  76435. * Restitution
  76436. */
  76437. restitution?: number;
  76438. };
  76439. /**
  76440. * the xr input to use with this pointer selection
  76441. */
  76442. xrInput: WebXRInput;
  76443. }
  76444. /**
  76445. * Add physics impostor to your webxr controllers,
  76446. * including naive calculation of their linear and angular velocity
  76447. */
  76448. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76449. private readonly _options;
  76450. private _attachController;
  76451. private _controllers;
  76452. private _debugMode;
  76453. private _delta;
  76454. private _headsetImpostor?;
  76455. private _headsetMesh?;
  76456. private _lastTimestamp;
  76457. private _tmpQuaternion;
  76458. private _tmpVector;
  76459. /**
  76460. * The module's name
  76461. */
  76462. static readonly Name: string;
  76463. /**
  76464. * The (Babylon) version of this module.
  76465. * This is an integer representing the implementation version.
  76466. * This number does not correspond to the webxr specs version
  76467. */
  76468. static readonly Version: number;
  76469. /**
  76470. * Construct a new Controller Physics Feature
  76471. * @param _xrSessionManager the corresponding xr session manager
  76472. * @param _options options to create this feature with
  76473. */
  76474. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76475. /**
  76476. * @hidden
  76477. * enable debugging - will show console outputs and the impostor mesh
  76478. */
  76479. _enablePhysicsDebug(): void;
  76480. /**
  76481. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76482. * @param xrController the controller to add
  76483. */
  76484. addController(xrController: WebXRInputSource): void;
  76485. /**
  76486. * attach this feature
  76487. * Will usually be called by the features manager
  76488. *
  76489. * @returns true if successful.
  76490. */
  76491. attach(): boolean;
  76492. /**
  76493. * detach this feature.
  76494. * Will usually be called by the features manager
  76495. *
  76496. * @returns true if successful.
  76497. */
  76498. detach(): boolean;
  76499. /**
  76500. * Get the headset impostor, if enabled
  76501. * @returns the impostor
  76502. */
  76503. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76504. /**
  76505. * Get the physics impostor of a specific controller.
  76506. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76507. * @param controller the controller or the controller id of which to get the impostor
  76508. * @returns the impostor or null
  76509. */
  76510. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76511. /**
  76512. * Update the physics properties provided in the constructor
  76513. * @param newProperties the new properties object
  76514. */
  76515. setPhysicsProperties(newProperties: {
  76516. impostorType?: number;
  76517. impostorSize?: number | {
  76518. width: number;
  76519. height: number;
  76520. depth: number;
  76521. };
  76522. friction?: number;
  76523. restitution?: number;
  76524. }): void;
  76525. protected _onXRFrame(_xrFrame: any): void;
  76526. private _detachController;
  76527. }
  76528. }
  76529. declare module BABYLON {
  76530. /**
  76531. * A babylon interface for a "WebXR" feature point.
  76532. * Represents the position and confidence value of a given feature point.
  76533. */
  76534. export interface IWebXRFeaturePoint {
  76535. /**
  76536. * Represents the position of the feature point in world space.
  76537. */
  76538. position: Vector3;
  76539. /**
  76540. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76541. */
  76542. confidenceValue: number;
  76543. }
  76544. /**
  76545. * The feature point system is used to detect feature points from real world geometry.
  76546. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76547. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76548. */
  76549. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76550. private _enabled;
  76551. private _featurePointCloud;
  76552. /**
  76553. * The module's name
  76554. */
  76555. static readonly Name: string;
  76556. /**
  76557. * The (Babylon) version of this module.
  76558. * This is an integer representing the implementation version.
  76559. * This number does not correspond to the WebXR specs version
  76560. */
  76561. static readonly Version: number;
  76562. /**
  76563. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76564. * Will notify the observers about which feature points have been added.
  76565. */
  76566. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76567. /**
  76568. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76569. * Will notify the observers about which feature points have been updated.
  76570. */
  76571. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76572. /**
  76573. * The current feature point cloud maintained across frames.
  76574. */
  76575. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76576. /**
  76577. * construct the feature point system
  76578. * @param _xrSessionManager an instance of xr Session manager
  76579. */
  76580. constructor(_xrSessionManager: WebXRSessionManager);
  76581. /**
  76582. * Detach this feature.
  76583. * Will usually be called by the features manager
  76584. *
  76585. * @returns true if successful.
  76586. */
  76587. detach(): boolean;
  76588. /**
  76589. * Dispose this feature and all of the resources attached
  76590. */
  76591. dispose(): void;
  76592. /**
  76593. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76594. */
  76595. protected _onXRFrame(frame: XRFrame): void;
  76596. /**
  76597. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76598. */
  76599. private _init;
  76600. }
  76601. }
  76602. declare module BABYLON {
  76603. /**
  76604. * Configuration interface for the hand tracking feature
  76605. */
  76606. export interface IWebXRHandTrackingOptions {
  76607. /**
  76608. * The xrInput that will be used as source for new hands
  76609. */
  76610. xrInput: WebXRInput;
  76611. /**
  76612. * Configuration object for the joint meshes
  76613. */
  76614. jointMeshes?: {
  76615. /**
  76616. * Should the meshes created be invisible (defaults to false)
  76617. */
  76618. invisible?: boolean;
  76619. /**
  76620. * A source mesh to be used to create instances. Defaults to a sphere.
  76621. * This mesh will be the source for all other (25) meshes.
  76622. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76623. */
  76624. sourceMesh?: Mesh;
  76625. /**
  76626. * This function will be called after a mesh was created for a specific joint.
  76627. * Using this function you can either manipulate the instance or return a new mesh.
  76628. * When returning a new mesh the instance created before will be disposed
  76629. */
  76630. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76631. /**
  76632. * Should the source mesh stay visible. Defaults to false
  76633. */
  76634. keepOriginalVisible?: boolean;
  76635. /**
  76636. * Scale factor for all instances (defaults to 2)
  76637. */
  76638. scaleFactor?: number;
  76639. /**
  76640. * Should each instance have its own physics impostor
  76641. */
  76642. enablePhysics?: boolean;
  76643. /**
  76644. * If enabled, override default physics properties
  76645. */
  76646. physicsProps?: {
  76647. friction?: number;
  76648. restitution?: number;
  76649. impostorType?: number;
  76650. };
  76651. /**
  76652. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76653. */
  76654. handMesh?: AbstractMesh;
  76655. };
  76656. }
  76657. /**
  76658. * Parts of the hands divided to writs and finger names
  76659. */
  76660. export const enum HandPart {
  76661. /**
  76662. * HandPart - Wrist
  76663. */
  76664. WRIST = "wrist",
  76665. /**
  76666. * HandPart - The THumb
  76667. */
  76668. THUMB = "thumb",
  76669. /**
  76670. * HandPart - Index finger
  76671. */
  76672. INDEX = "index",
  76673. /**
  76674. * HandPart - Middle finger
  76675. */
  76676. MIDDLE = "middle",
  76677. /**
  76678. * HandPart - Ring finger
  76679. */
  76680. RING = "ring",
  76681. /**
  76682. * HandPart - Little finger
  76683. */
  76684. LITTLE = "little"
  76685. }
  76686. /**
  76687. * Representing a single hand (with its corresponding native XRHand object)
  76688. */
  76689. export class WebXRHand implements IDisposable {
  76690. /** the controller to which the hand correlates */
  76691. readonly xrController: WebXRInputSource;
  76692. /** the meshes to be used to track the hand joints */
  76693. readonly trackedMeshes: AbstractMesh[];
  76694. /**
  76695. * Hand-parts definition (key is HandPart)
  76696. */
  76697. handPartsDefinition: {
  76698. [key: string]: number[];
  76699. };
  76700. /**
  76701. * Populate the HandPartsDefinition object.
  76702. * This is called as a side effect since certain browsers don't have XRHand defined.
  76703. */
  76704. private generateHandPartsDefinition;
  76705. /**
  76706. * Construct a new hand object
  76707. * @param xrController the controller to which the hand correlates
  76708. * @param trackedMeshes the meshes to be used to track the hand joints
  76709. */
  76710. constructor(
  76711. /** the controller to which the hand correlates */
  76712. xrController: WebXRInputSource,
  76713. /** the meshes to be used to track the hand joints */
  76714. trackedMeshes: AbstractMesh[]);
  76715. /**
  76716. * Update this hand from the latest xr frame
  76717. * @param xrFrame xrFrame to update from
  76718. * @param referenceSpace The current viewer reference space
  76719. * @param scaleFactor optional scale factor for the meshes
  76720. */
  76721. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76722. /**
  76723. * Get meshes of part of the hand
  76724. * @param part the part of hand to get
  76725. * @returns An array of meshes that correlate to the hand part requested
  76726. */
  76727. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76728. /**
  76729. * Dispose this Hand object
  76730. */
  76731. dispose(): void;
  76732. }
  76733. /**
  76734. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76735. */
  76736. export class WebXRHandTracking extends WebXRAbstractFeature {
  76737. /**
  76738. * options to use when constructing this feature
  76739. */
  76740. readonly options: IWebXRHandTrackingOptions;
  76741. private static _idCounter;
  76742. /**
  76743. * The module's name
  76744. */
  76745. static readonly Name: string;
  76746. /**
  76747. * The (Babylon) version of this module.
  76748. * This is an integer representing the implementation version.
  76749. * This number does not correspond to the WebXR specs version
  76750. */
  76751. static readonly Version: number;
  76752. /**
  76753. * This observable will notify registered observers when a new hand object was added and initialized
  76754. */
  76755. onHandAddedObservable: Observable<WebXRHand>;
  76756. /**
  76757. * This observable will notify its observers right before the hand object is disposed
  76758. */
  76759. onHandRemovedObservable: Observable<WebXRHand>;
  76760. private _hands;
  76761. /**
  76762. * Creates a new instance of the hit test feature
  76763. * @param _xrSessionManager an instance of WebXRSessionManager
  76764. * @param options options to use when constructing this feature
  76765. */
  76766. constructor(_xrSessionManager: WebXRSessionManager,
  76767. /**
  76768. * options to use when constructing this feature
  76769. */
  76770. options: IWebXRHandTrackingOptions);
  76771. /**
  76772. * Check if the needed objects are defined.
  76773. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76774. */
  76775. isCompatible(): boolean;
  76776. /**
  76777. * attach this feature
  76778. * Will usually be called by the features manager
  76779. *
  76780. * @returns true if successful.
  76781. */
  76782. attach(): boolean;
  76783. /**
  76784. * detach this feature.
  76785. * Will usually be called by the features manager
  76786. *
  76787. * @returns true if successful.
  76788. */
  76789. detach(): boolean;
  76790. /**
  76791. * Dispose this feature and all of the resources attached
  76792. */
  76793. dispose(): void;
  76794. /**
  76795. * Get the hand object according to the controller id
  76796. * @param controllerId the controller id to which we want to get the hand
  76797. * @returns null if not found or the WebXRHand object if found
  76798. */
  76799. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76800. /**
  76801. * Get a hand object according to the requested handedness
  76802. * @param handedness the handedness to request
  76803. * @returns null if not found or the WebXRHand object if found
  76804. */
  76805. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76806. protected _onXRFrame(_xrFrame: XRFrame): void;
  76807. private _attachHand;
  76808. private _detachHand;
  76809. }
  76810. }
  76811. declare module BABYLON {
  76812. /**
  76813. * The motion controller class for all microsoft mixed reality controllers
  76814. */
  76815. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76816. protected readonly _mapping: {
  76817. defaultButton: {
  76818. valueNodeName: string;
  76819. unpressedNodeName: string;
  76820. pressedNodeName: string;
  76821. };
  76822. defaultAxis: {
  76823. valueNodeName: string;
  76824. minNodeName: string;
  76825. maxNodeName: string;
  76826. };
  76827. buttons: {
  76828. "xr-standard-trigger": {
  76829. rootNodeName: string;
  76830. componentProperty: string;
  76831. states: string[];
  76832. };
  76833. "xr-standard-squeeze": {
  76834. rootNodeName: string;
  76835. componentProperty: string;
  76836. states: string[];
  76837. };
  76838. "xr-standard-touchpad": {
  76839. rootNodeName: string;
  76840. labelAnchorNodeName: string;
  76841. touchPointNodeName: string;
  76842. };
  76843. "xr-standard-thumbstick": {
  76844. rootNodeName: string;
  76845. componentProperty: string;
  76846. states: string[];
  76847. };
  76848. };
  76849. axes: {
  76850. "xr-standard-touchpad": {
  76851. "x-axis": {
  76852. rootNodeName: string;
  76853. };
  76854. "y-axis": {
  76855. rootNodeName: string;
  76856. };
  76857. };
  76858. "xr-standard-thumbstick": {
  76859. "x-axis": {
  76860. rootNodeName: string;
  76861. };
  76862. "y-axis": {
  76863. rootNodeName: string;
  76864. };
  76865. };
  76866. };
  76867. };
  76868. /**
  76869. * The base url used to load the left and right controller models
  76870. */
  76871. static MODEL_BASE_URL: string;
  76872. /**
  76873. * The name of the left controller model file
  76874. */
  76875. static MODEL_LEFT_FILENAME: string;
  76876. /**
  76877. * The name of the right controller model file
  76878. */
  76879. static MODEL_RIGHT_FILENAME: string;
  76880. profileId: string;
  76881. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76882. protected _getFilenameAndPath(): {
  76883. filename: string;
  76884. path: string;
  76885. };
  76886. protected _getModelLoadingConstraints(): boolean;
  76887. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76888. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76889. protected _updateModel(): void;
  76890. }
  76891. }
  76892. declare module BABYLON {
  76893. /**
  76894. * The motion controller class for oculus touch (quest, rift).
  76895. * This class supports legacy mapping as well the standard xr mapping
  76896. */
  76897. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76898. private _forceLegacyControllers;
  76899. private _modelRootNode;
  76900. /**
  76901. * The base url used to load the left and right controller models
  76902. */
  76903. static MODEL_BASE_URL: string;
  76904. /**
  76905. * The name of the left controller model file
  76906. */
  76907. static MODEL_LEFT_FILENAME: string;
  76908. /**
  76909. * The name of the right controller model file
  76910. */
  76911. static MODEL_RIGHT_FILENAME: string;
  76912. /**
  76913. * Base Url for the Quest controller model.
  76914. */
  76915. static QUEST_MODEL_BASE_URL: string;
  76916. profileId: string;
  76917. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76918. protected _getFilenameAndPath(): {
  76919. filename: string;
  76920. path: string;
  76921. };
  76922. protected _getModelLoadingConstraints(): boolean;
  76923. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76924. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76925. protected _updateModel(): void;
  76926. /**
  76927. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76928. * between the touch and touch 2.
  76929. */
  76930. private _isQuest;
  76931. }
  76932. }
  76933. declare module BABYLON {
  76934. /**
  76935. * The motion controller class for the standard HTC-Vive controllers
  76936. */
  76937. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76938. private _modelRootNode;
  76939. /**
  76940. * The base url used to load the left and right controller models
  76941. */
  76942. static MODEL_BASE_URL: string;
  76943. /**
  76944. * File name for the controller model.
  76945. */
  76946. static MODEL_FILENAME: string;
  76947. profileId: string;
  76948. /**
  76949. * Create a new Vive motion controller object
  76950. * @param scene the scene to use to create this controller
  76951. * @param gamepadObject the corresponding gamepad object
  76952. * @param handedness the handedness of the controller
  76953. */
  76954. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76955. protected _getFilenameAndPath(): {
  76956. filename: string;
  76957. path: string;
  76958. };
  76959. protected _getModelLoadingConstraints(): boolean;
  76960. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76961. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76962. protected _updateModel(): void;
  76963. }
  76964. }
  76965. declare module BABYLON {
  76966. /**
  76967. * A cursor which tracks a point on a path
  76968. */
  76969. export class PathCursor {
  76970. private path;
  76971. /**
  76972. * Stores path cursor callbacks for when an onchange event is triggered
  76973. */
  76974. private _onchange;
  76975. /**
  76976. * The value of the path cursor
  76977. */
  76978. value: number;
  76979. /**
  76980. * The animation array of the path cursor
  76981. */
  76982. animations: Animation[];
  76983. /**
  76984. * Initializes the path cursor
  76985. * @param path The path to track
  76986. */
  76987. constructor(path: Path2);
  76988. /**
  76989. * Gets the cursor point on the path
  76990. * @returns A point on the path cursor at the cursor location
  76991. */
  76992. getPoint(): Vector3;
  76993. /**
  76994. * Moves the cursor ahead by the step amount
  76995. * @param step The amount to move the cursor forward
  76996. * @returns This path cursor
  76997. */
  76998. moveAhead(step?: number): PathCursor;
  76999. /**
  77000. * Moves the cursor behind by the step amount
  77001. * @param step The amount to move the cursor back
  77002. * @returns This path cursor
  77003. */
  77004. moveBack(step?: number): PathCursor;
  77005. /**
  77006. * Moves the cursor by the step amount
  77007. * If the step amount is greater than one, an exception is thrown
  77008. * @param step The amount to move the cursor
  77009. * @returns This path cursor
  77010. */
  77011. move(step: number): PathCursor;
  77012. /**
  77013. * Ensures that the value is limited between zero and one
  77014. * @returns This path cursor
  77015. */
  77016. private ensureLimits;
  77017. /**
  77018. * Runs onchange callbacks on change (used by the animation engine)
  77019. * @returns This path cursor
  77020. */
  77021. private raiseOnChange;
  77022. /**
  77023. * Executes a function on change
  77024. * @param f A path cursor onchange callback
  77025. * @returns This path cursor
  77026. */
  77027. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77028. }
  77029. }
  77030. declare module BABYLON {
  77031. /** @hidden */
  77032. export var blurPixelShader: {
  77033. name: string;
  77034. shader: string;
  77035. };
  77036. }
  77037. declare module BABYLON {
  77038. /** @hidden */
  77039. export var pointCloudVertexDeclaration: {
  77040. name: string;
  77041. shader: string;
  77042. };
  77043. }
  77044. // Mixins
  77045. interface Window {
  77046. mozIndexedDB: IDBFactory;
  77047. webkitIndexedDB: IDBFactory;
  77048. msIndexedDB: IDBFactory;
  77049. webkitURL: typeof URL;
  77050. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  77051. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  77052. WebGLRenderingContext: WebGLRenderingContext;
  77053. MSGesture: MSGesture;
  77054. CANNON: any;
  77055. AudioContext: AudioContext;
  77056. webkitAudioContext: AudioContext;
  77057. PointerEvent: any;
  77058. Math: Math;
  77059. Uint8Array: Uint8ArrayConstructor;
  77060. Float32Array: Float32ArrayConstructor;
  77061. mozURL: typeof URL;
  77062. msURL: typeof URL;
  77063. VRFrameData: any; // WebVR, from specs 1.1
  77064. DracoDecoderModule: any;
  77065. setImmediate(handler: (...args: any[]) => void): number;
  77066. }
  77067. interface HTMLCanvasElement {
  77068. requestPointerLock(): void;
  77069. msRequestPointerLock?(): void;
  77070. mozRequestPointerLock?(): void;
  77071. webkitRequestPointerLock?(): void;
  77072. /** Track wether a record is in progress */
  77073. isRecording: boolean;
  77074. /** Capture Stream method defined by some browsers */
  77075. captureStream(fps?: number): MediaStream;
  77076. }
  77077. interface CanvasRenderingContext2D {
  77078. msImageSmoothingEnabled: boolean;
  77079. }
  77080. interface MouseEvent {
  77081. mozMovementX: number;
  77082. mozMovementY: number;
  77083. webkitMovementX: number;
  77084. webkitMovementY: number;
  77085. msMovementX: number;
  77086. msMovementY: number;
  77087. }
  77088. interface Navigator {
  77089. mozGetVRDevices: (any: any) => any;
  77090. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77091. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77092. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77093. webkitGetGamepads(): Gamepad[];
  77094. msGetGamepads(): Gamepad[];
  77095. webkitGamepads(): Gamepad[];
  77096. }
  77097. interface HTMLVideoElement {
  77098. mozSrcObject: any;
  77099. }
  77100. interface Math {
  77101. fround(x: number): number;
  77102. imul(a: number, b: number): number;
  77103. }
  77104. interface WebGLRenderingContext {
  77105. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  77106. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  77107. vertexAttribDivisor(index: number, divisor: number): void;
  77108. createVertexArray(): any;
  77109. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  77110. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  77111. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  77112. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  77113. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  77114. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  77115. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  77116. // Queries
  77117. createQuery(): WebGLQuery;
  77118. deleteQuery(query: WebGLQuery): void;
  77119. beginQuery(target: number, query: WebGLQuery): void;
  77120. endQuery(target: number): void;
  77121. getQueryParameter(query: WebGLQuery, pname: number): any;
  77122. getQuery(target: number, pname: number): any;
  77123. MAX_SAMPLES: number;
  77124. RGBA8: number;
  77125. READ_FRAMEBUFFER: number;
  77126. DRAW_FRAMEBUFFER: number;
  77127. UNIFORM_BUFFER: number;
  77128. HALF_FLOAT_OES: number;
  77129. RGBA16F: number;
  77130. RGBA32F: number;
  77131. R32F: number;
  77132. RG32F: number;
  77133. RGB32F: number;
  77134. R16F: number;
  77135. RG16F: number;
  77136. RGB16F: number;
  77137. RED: number;
  77138. RG: number;
  77139. R8: number;
  77140. RG8: number;
  77141. UNSIGNED_INT_24_8: number;
  77142. DEPTH24_STENCIL8: number;
  77143. MIN: number;
  77144. MAX: number;
  77145. /* Multiple Render Targets */
  77146. drawBuffers(buffers: number[]): void;
  77147. readBuffer(src: number): void;
  77148. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  77149. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  77150. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  77151. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  77152. // Occlusion Query
  77153. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  77154. ANY_SAMPLES_PASSED: number;
  77155. QUERY_RESULT_AVAILABLE: number;
  77156. QUERY_RESULT: number;
  77157. }
  77158. interface WebGLProgram {
  77159. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  77160. }
  77161. interface EXT_disjoint_timer_query {
  77162. QUERY_COUNTER_BITS_EXT: number;
  77163. TIME_ELAPSED_EXT: number;
  77164. TIMESTAMP_EXT: number;
  77165. GPU_DISJOINT_EXT: number;
  77166. QUERY_RESULT_EXT: number;
  77167. QUERY_RESULT_AVAILABLE_EXT: number;
  77168. queryCounterEXT(query: WebGLQuery, target: number): void;
  77169. createQueryEXT(): WebGLQuery;
  77170. beginQueryEXT(target: number, query: WebGLQuery): void;
  77171. endQueryEXT(target: number): void;
  77172. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  77173. deleteQueryEXT(query: WebGLQuery): void;
  77174. }
  77175. interface WebGLUniformLocation {
  77176. _currentState: any;
  77177. }
  77178. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  77179. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  77180. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  77181. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77182. interface WebGLRenderingContext {
  77183. readonly RASTERIZER_DISCARD: number;
  77184. readonly DEPTH_COMPONENT24: number;
  77185. readonly TEXTURE_3D: number;
  77186. readonly TEXTURE_2D_ARRAY: number;
  77187. readonly TEXTURE_COMPARE_FUNC: number;
  77188. readonly TEXTURE_COMPARE_MODE: number;
  77189. readonly COMPARE_REF_TO_TEXTURE: number;
  77190. readonly TEXTURE_WRAP_R: number;
  77191. readonly HALF_FLOAT: number;
  77192. readonly RGB8: number;
  77193. readonly RED_INTEGER: number;
  77194. readonly RG_INTEGER: number;
  77195. readonly RGB_INTEGER: number;
  77196. readonly RGBA_INTEGER: number;
  77197. readonly R8_SNORM: number;
  77198. readonly RG8_SNORM: number;
  77199. readonly RGB8_SNORM: number;
  77200. readonly RGBA8_SNORM: number;
  77201. readonly R8I: number;
  77202. readonly RG8I: number;
  77203. readonly RGB8I: number;
  77204. readonly RGBA8I: number;
  77205. readonly R8UI: number;
  77206. readonly RG8UI: number;
  77207. readonly RGB8UI: number;
  77208. readonly RGBA8UI: number;
  77209. readonly R16I: number;
  77210. readonly RG16I: number;
  77211. readonly RGB16I: number;
  77212. readonly RGBA16I: number;
  77213. readonly R16UI: number;
  77214. readonly RG16UI: number;
  77215. readonly RGB16UI: number;
  77216. readonly RGBA16UI: number;
  77217. readonly R32I: number;
  77218. readonly RG32I: number;
  77219. readonly RGB32I: number;
  77220. readonly RGBA32I: number;
  77221. readonly R32UI: number;
  77222. readonly RG32UI: number;
  77223. readonly RGB32UI: number;
  77224. readonly RGBA32UI: number;
  77225. readonly RGB10_A2UI: number;
  77226. readonly R11F_G11F_B10F: number;
  77227. readonly RGB9_E5: number;
  77228. readonly RGB10_A2: number;
  77229. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  77230. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  77231. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  77232. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77233. readonly DEPTH_COMPONENT32F: number;
  77234. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  77235. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  77236. 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;
  77237. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  77238. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  77239. readonly TRANSFORM_FEEDBACK: number;
  77240. readonly INTERLEAVED_ATTRIBS: number;
  77241. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  77242. createTransformFeedback(): WebGLTransformFeedback;
  77243. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  77244. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  77245. beginTransformFeedback(primitiveMode: number): void;
  77246. endTransformFeedback(): void;
  77247. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  77248. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77249. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77250. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77251. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77252. }
  77253. interface ImageBitmap {
  77254. readonly width: number;
  77255. readonly height: number;
  77256. close(): void;
  77257. }
  77258. interface WebGLQuery extends WebGLObject {
  77259. }
  77260. declare var WebGLQuery: {
  77261. prototype: WebGLQuery;
  77262. new(): WebGLQuery;
  77263. };
  77264. interface WebGLSampler extends WebGLObject {
  77265. }
  77266. declare var WebGLSampler: {
  77267. prototype: WebGLSampler;
  77268. new(): WebGLSampler;
  77269. };
  77270. interface WebGLSync extends WebGLObject {
  77271. }
  77272. declare var WebGLSync: {
  77273. prototype: WebGLSync;
  77274. new(): WebGLSync;
  77275. };
  77276. interface WebGLTransformFeedback extends WebGLObject {
  77277. }
  77278. declare var WebGLTransformFeedback: {
  77279. prototype: WebGLTransformFeedback;
  77280. new(): WebGLTransformFeedback;
  77281. };
  77282. interface WebGLVertexArrayObject extends WebGLObject {
  77283. }
  77284. declare var WebGLVertexArrayObject: {
  77285. prototype: WebGLVertexArrayObject;
  77286. new(): WebGLVertexArrayObject;
  77287. };
  77288. // Type definitions for WebVR API
  77289. // Project: https://w3c.github.io/webvr/
  77290. // Definitions by: six a <https://github.com/lostfictions>
  77291. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77292. interface VRDisplay extends EventTarget {
  77293. /**
  77294. * Dictionary of capabilities describing the VRDisplay.
  77295. */
  77296. readonly capabilities: VRDisplayCapabilities;
  77297. /**
  77298. * z-depth defining the far plane of the eye view frustum
  77299. * enables mapping of values in the render target depth
  77300. * attachment to scene coordinates. Initially set to 10000.0.
  77301. */
  77302. depthFar: number;
  77303. /**
  77304. * z-depth defining the near plane of the eye view frustum
  77305. * enables mapping of values in the render target depth
  77306. * attachment to scene coordinates. Initially set to 0.01.
  77307. */
  77308. depthNear: number;
  77309. /**
  77310. * An identifier for this distinct VRDisplay. Used as an
  77311. * association point in the Gamepad API.
  77312. */
  77313. readonly displayId: number;
  77314. /**
  77315. * A display name, a user-readable name identifying it.
  77316. */
  77317. readonly displayName: string;
  77318. readonly isConnected: boolean;
  77319. readonly isPresenting: boolean;
  77320. /**
  77321. * If this VRDisplay supports room-scale experiences, the optional
  77322. * stage attribute contains details on the room-scale parameters.
  77323. */
  77324. readonly stageParameters: VRStageParameters | null;
  77325. /**
  77326. * Passing the value returned by `requestAnimationFrame` to
  77327. * `cancelAnimationFrame` will unregister the callback.
  77328. * @param handle Define the hanle of the request to cancel
  77329. */
  77330. cancelAnimationFrame(handle: number): void;
  77331. /**
  77332. * Stops presenting to the VRDisplay.
  77333. * @returns a promise to know when it stopped
  77334. */
  77335. exitPresent(): Promise<void>;
  77336. /**
  77337. * Return the current VREyeParameters for the given eye.
  77338. * @param whichEye Define the eye we want the parameter for
  77339. * @returns the eye parameters
  77340. */
  77341. getEyeParameters(whichEye: string): VREyeParameters;
  77342. /**
  77343. * Populates the passed VRFrameData with the information required to render
  77344. * the current frame.
  77345. * @param frameData Define the data structure to populate
  77346. * @returns true if ok otherwise false
  77347. */
  77348. getFrameData(frameData: VRFrameData): boolean;
  77349. /**
  77350. * Get the layers currently being presented.
  77351. * @returns the list of VR layers
  77352. */
  77353. getLayers(): VRLayer[];
  77354. /**
  77355. * Return a VRPose containing the future predicted pose of the VRDisplay
  77356. * when the current frame will be presented. The value returned will not
  77357. * change until JavaScript has returned control to the browser.
  77358. *
  77359. * The VRPose will contain the position, orientation, velocity,
  77360. * and acceleration of each of these properties.
  77361. * @returns the pose object
  77362. */
  77363. getPose(): VRPose;
  77364. /**
  77365. * Return the current instantaneous pose of the VRDisplay, with no
  77366. * prediction applied.
  77367. * @returns the current instantaneous pose
  77368. */
  77369. getImmediatePose(): VRPose;
  77370. /**
  77371. * The callback passed to `requestAnimationFrame` will be called
  77372. * any time a new frame should be rendered. When the VRDisplay is
  77373. * presenting the callback will be called at the native refresh
  77374. * rate of the HMD. When not presenting this function acts
  77375. * identically to how window.requestAnimationFrame acts. Content should
  77376. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77377. * asynchronously from other displays and at differing refresh rates.
  77378. * @param callback Define the eaction to run next frame
  77379. * @returns the request handle it
  77380. */
  77381. requestAnimationFrame(callback: FrameRequestCallback): number;
  77382. /**
  77383. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77384. * Repeat calls while already presenting will update the VRLayers being displayed.
  77385. * @param layers Define the list of layer to present
  77386. * @returns a promise to know when the request has been fulfilled
  77387. */
  77388. requestPresent(layers: VRLayer[]): Promise<void>;
  77389. /**
  77390. * Reset the pose for this display, treating its current position and
  77391. * orientation as the "origin/zero" values. VRPose.position,
  77392. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77393. * updated when calling resetPose(). This should be called in only
  77394. * sitting-space experiences.
  77395. */
  77396. resetPose(): void;
  77397. /**
  77398. * The VRLayer provided to the VRDisplay will be captured and presented
  77399. * in the HMD. Calling this function has the same effect on the source
  77400. * canvas as any other operation that uses its source image, and canvases
  77401. * created without preserveDrawingBuffer set to true will be cleared.
  77402. * @param pose Define the pose to submit
  77403. */
  77404. submitFrame(pose?: VRPose): void;
  77405. }
  77406. declare var VRDisplay: {
  77407. prototype: VRDisplay;
  77408. new(): VRDisplay;
  77409. };
  77410. interface VRLayer {
  77411. leftBounds?: number[] | Float32Array | null;
  77412. rightBounds?: number[] | Float32Array | null;
  77413. source?: HTMLCanvasElement | null;
  77414. }
  77415. interface VRDisplayCapabilities {
  77416. readonly canPresent: boolean;
  77417. readonly hasExternalDisplay: boolean;
  77418. readonly hasOrientation: boolean;
  77419. readonly hasPosition: boolean;
  77420. readonly maxLayers: number;
  77421. }
  77422. interface VREyeParameters {
  77423. /** @deprecated */
  77424. readonly fieldOfView: VRFieldOfView;
  77425. readonly offset: Float32Array;
  77426. readonly renderHeight: number;
  77427. readonly renderWidth: number;
  77428. }
  77429. interface VRFieldOfView {
  77430. readonly downDegrees: number;
  77431. readonly leftDegrees: number;
  77432. readonly rightDegrees: number;
  77433. readonly upDegrees: number;
  77434. }
  77435. interface VRFrameData {
  77436. readonly leftProjectionMatrix: Float32Array;
  77437. readonly leftViewMatrix: Float32Array;
  77438. readonly pose: VRPose;
  77439. readonly rightProjectionMatrix: Float32Array;
  77440. readonly rightViewMatrix: Float32Array;
  77441. readonly timestamp: number;
  77442. }
  77443. interface VRPose {
  77444. readonly angularAcceleration: Float32Array | null;
  77445. readonly angularVelocity: Float32Array | null;
  77446. readonly linearAcceleration: Float32Array | null;
  77447. readonly linearVelocity: Float32Array | null;
  77448. readonly orientation: Float32Array | null;
  77449. readonly position: Float32Array | null;
  77450. readonly timestamp: number;
  77451. }
  77452. interface VRStageParameters {
  77453. sittingToStandingTransform?: Float32Array;
  77454. sizeX?: number;
  77455. sizeY?: number;
  77456. }
  77457. interface Navigator {
  77458. getVRDisplays(): Promise<VRDisplay[]>;
  77459. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77460. }
  77461. interface Window {
  77462. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77463. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77464. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77465. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77466. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77467. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77468. }
  77469. interface Gamepad {
  77470. readonly displayId: number;
  77471. }
  77472. /**
  77473. * Available session modes
  77474. */
  77475. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77476. /**
  77477. * Reference space types
  77478. */
  77479. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77480. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77481. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77482. /**
  77483. * Handedness types
  77484. */
  77485. type XRHandedness = "none" | "left" | "right";
  77486. /**
  77487. * InputSource target ray modes
  77488. */
  77489. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77490. /**
  77491. * Eye types
  77492. */
  77493. type XREye = "none" | "left" | "right";
  77494. /**
  77495. * Type of XR events available
  77496. */
  77497. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77498. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77499. type XRPlaneSet = Set<XRPlane>;
  77500. type XRAnchorSet = Set<XRAnchor>;
  77501. type XREventHandler = (callback: any) => void;
  77502. interface XRLayer extends EventTarget {}
  77503. interface XRSessionInit {
  77504. optionalFeatures?: string[];
  77505. requiredFeatures?: string[];
  77506. }
  77507. interface XRSessionEvent extends Event {
  77508. readonly session: XRSession;
  77509. }
  77510. interface XRSystem {
  77511. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77512. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77513. }
  77514. interface XRViewport {
  77515. readonly x: number;
  77516. readonly y: number;
  77517. readonly width: number;
  77518. readonly height: number;
  77519. }
  77520. interface XRWebGLLayerInit {
  77521. antialias?: boolean;
  77522. depth?: boolean;
  77523. stencil?: boolean;
  77524. alpha?: boolean;
  77525. multiview?: boolean;
  77526. framebufferScaleFactor?: number;
  77527. }
  77528. declare class XRWebGLLayer {
  77529. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77530. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77531. readonly antialias: boolean;
  77532. readonly framebuffer: WebGLFramebuffer;
  77533. readonly framebufferWidth: number;
  77534. readonly framebufferHeight: number;
  77535. readonly ignoreDepthValues: boolean;
  77536. getViewport: (view: XRView) => XRViewport;
  77537. }
  77538. // tslint:disable-next-line no-empty-interface
  77539. interface XRSpace extends EventTarget {}
  77540. interface XRRenderState {
  77541. readonly baseLayer?: XRWebGLLayer;
  77542. readonly depthFar: number;
  77543. readonly depthNear: number;
  77544. readonly inlineVerticalFieldOfView?: number;
  77545. }
  77546. interface XRRenderStateInit extends XRRenderState {
  77547. baseLayer: XRWebGLLayer;
  77548. depthFar: number;
  77549. depthNear: number;
  77550. inlineVerticalFieldOfView?: number;
  77551. layers?: XRLayer[];
  77552. }
  77553. interface XRReferenceSpace extends XRSpace {
  77554. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77555. onreset: XREventHandler;
  77556. }
  77557. interface XRBoundedReferenceSpace extends XRSpace {
  77558. readonly boundsGeometry: DOMPointReadOnly[];
  77559. }
  77560. interface XRInputSource {
  77561. readonly handedness: XRHandedness;
  77562. readonly targetRayMode: XRTargetRayMode;
  77563. readonly targetRaySpace: XRSpace;
  77564. readonly gripSpace?: XRSpace;
  77565. readonly gamepad?: Gamepad;
  77566. readonly profiles: Array<string>;
  77567. readonly hand?: XRHand;
  77568. }
  77569. interface XRPose {
  77570. readonly transform: XRRigidTransform;
  77571. readonly emulatedPosition: boolean;
  77572. }
  77573. interface XRFrame {
  77574. readonly session: XRSession;
  77575. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77576. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77577. // AR
  77578. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77579. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77580. // Anchors
  77581. trackedAnchors?: XRAnchorSet;
  77582. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77583. // Planes
  77584. worldInformation?: {
  77585. detectedPlanes?: XRPlaneSet;
  77586. };
  77587. // Hand tracking
  77588. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77589. }
  77590. interface XRInputSourceEvent extends Event {
  77591. readonly frame: XRFrame;
  77592. readonly inputSource: XRInputSource;
  77593. }
  77594. type XRInputSourceArray = XRInputSource[];
  77595. interface XRSession {
  77596. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77597. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77598. /**
  77599. * Returns a list of this session's XRInputSources, each representing an input device
  77600. * used to control the camera and/or scene.
  77601. */
  77602. readonly inputSources: Array<XRInputSource>;
  77603. /**
  77604. * object which contains options affecting how the imagery is rendered.
  77605. * This includes things such as the near and far clipping planes
  77606. */
  77607. readonly renderState: XRRenderState;
  77608. readonly visibilityState: XRVisibilityState;
  77609. /**
  77610. * Removes a callback from the animation frame painting callback from
  77611. * XRSession's set of animation frame rendering callbacks, given the
  77612. * identifying handle returned by a previous call to requestAnimationFrame().
  77613. */
  77614. cancelAnimationFrame: (handle: number) => void;
  77615. /**
  77616. * Ends the WebXR session. Returns a promise which resolves when the
  77617. * session has been shut down.
  77618. */
  77619. end(): Promise<void>;
  77620. /**
  77621. * Schedules the specified method to be called the next time the user agent
  77622. * is working on rendering an animation frame for the WebXR device. Returns an
  77623. * integer value which can be used to identify the request for the purposes of
  77624. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77625. * to the Window.requestAnimationFrame() method.
  77626. */
  77627. requestAnimationFrame: XRFrameRequestCallback;
  77628. /**
  77629. * Requests that a new XRReferenceSpace of the specified type be created.
  77630. * Returns a promise which resolves with the XRReferenceSpace or
  77631. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77632. * the requested space type isn't supported by the device.
  77633. */
  77634. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77635. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77636. onend: XREventHandler;
  77637. oninputsourceschange: XREventHandler;
  77638. onselect: XREventHandler;
  77639. onselectstart: XREventHandler;
  77640. onselectend: XREventHandler;
  77641. onsqueeze: XREventHandler;
  77642. onsqueezestart: XREventHandler;
  77643. onsqueezeend: XREventHandler;
  77644. onvisibilitychange: XREventHandler;
  77645. // hit test
  77646. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77647. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77648. // legacy AR hit test
  77649. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77650. // legacy plane detection
  77651. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77652. }
  77653. interface XRViewerPose extends XRPose {
  77654. readonly views: Array<XRView>;
  77655. }
  77656. declare class XRRigidTransform {
  77657. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77658. position: DOMPointReadOnly;
  77659. orientation: DOMPointReadOnly;
  77660. matrix: Float32Array;
  77661. inverse: XRRigidTransform;
  77662. }
  77663. interface XRView {
  77664. readonly eye: XREye;
  77665. readonly projectionMatrix: Float32Array;
  77666. readonly transform: XRRigidTransform;
  77667. readonly recommendedViewportScale?: number;
  77668. requestViewportScale(scale: number): void;
  77669. }
  77670. interface XRInputSourceChangeEvent extends Event {
  77671. session: XRSession;
  77672. removed: Array<XRInputSource>;
  77673. added: Array<XRInputSource>;
  77674. }
  77675. // Experimental/Draft features
  77676. declare class XRRay {
  77677. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77678. origin: DOMPointReadOnly;
  77679. direction: DOMPointReadOnly;
  77680. matrix: Float32Array;
  77681. }
  77682. declare enum XRHitTestTrackableType {
  77683. "point",
  77684. "plane",
  77685. "mesh",
  77686. }
  77687. interface XRHitResult {
  77688. hitMatrix: Float32Array;
  77689. }
  77690. interface XRTransientInputHitTestResult {
  77691. readonly inputSource: XRInputSource;
  77692. readonly results: Array<XRHitTestResult>;
  77693. }
  77694. interface XRHitTestResult {
  77695. getPose(baseSpace: XRSpace): XRPose | undefined;
  77696. // When anchor system is enabled
  77697. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77698. }
  77699. interface XRHitTestSource {
  77700. cancel(): void;
  77701. }
  77702. interface XRTransientInputHitTestSource {
  77703. cancel(): void;
  77704. }
  77705. interface XRHitTestOptionsInit {
  77706. space: XRSpace;
  77707. entityTypes?: Array<XRHitTestTrackableType>;
  77708. offsetRay?: XRRay;
  77709. }
  77710. interface XRTransientInputHitTestOptionsInit {
  77711. profile: string;
  77712. entityTypes?: Array<XRHitTestTrackableType>;
  77713. offsetRay?: XRRay;
  77714. }
  77715. interface XRAnchor {
  77716. anchorSpace: XRSpace;
  77717. delete(): void;
  77718. }
  77719. interface XRPlane {
  77720. orientation: "Horizontal" | "Vertical";
  77721. planeSpace: XRSpace;
  77722. polygon: Array<DOMPointReadOnly>;
  77723. lastChangedTime: number;
  77724. }
  77725. interface XRJointSpace extends XRSpace {}
  77726. interface XRJointPose extends XRPose {
  77727. radius: number | undefined;
  77728. }
  77729. interface XRHand extends Iterable<XRJointSpace> {
  77730. readonly length: number;
  77731. [index: number]: XRJointSpace;
  77732. readonly WRIST: number;
  77733. readonly THUMB_METACARPAL: number;
  77734. readonly THUMB_PHALANX_PROXIMAL: number;
  77735. readonly THUMB_PHALANX_DISTAL: number;
  77736. readonly THUMB_PHALANX_TIP: number;
  77737. readonly INDEX_METACARPAL: number;
  77738. readonly INDEX_PHALANX_PROXIMAL: number;
  77739. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77740. readonly INDEX_PHALANX_DISTAL: number;
  77741. readonly INDEX_PHALANX_TIP: number;
  77742. readonly MIDDLE_METACARPAL: number;
  77743. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77744. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77745. readonly MIDDLE_PHALANX_DISTAL: number;
  77746. readonly MIDDLE_PHALANX_TIP: number;
  77747. readonly RING_METACARPAL: number;
  77748. readonly RING_PHALANX_PROXIMAL: number;
  77749. readonly RING_PHALANX_INTERMEDIATE: number;
  77750. readonly RING_PHALANX_DISTAL: number;
  77751. readonly RING_PHALANX_TIP: number;
  77752. readonly LITTLE_METACARPAL: number;
  77753. readonly LITTLE_PHALANX_PROXIMAL: number;
  77754. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77755. readonly LITTLE_PHALANX_DISTAL: number;
  77756. readonly LITTLE_PHALANX_TIP: number;
  77757. }
  77758. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77759. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77760. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77761. interface XRSession {
  77762. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77763. }
  77764. interface XRFrame {
  77765. featurePointCloud? : Array<number>;
  77766. }
  77767. /**
  77768. * @ignore
  77769. */
  77770. declare module BABYLON.GLTF2.Exporter {
  77771. }
  77772. /**
  77773. * @ignore
  77774. */
  77775. declare module BABYLON.GLTF1 {
  77776. }
  77777. declare module BABYLON.GUI {
  77778. /**
  77779. * Class used to specific a value and its associated unit
  77780. */
  77781. export class ValueAndUnit {
  77782. /** defines the unit to store */
  77783. unit: number;
  77784. /** defines a boolean indicating if the value can be negative */
  77785. negativeValueAllowed: boolean;
  77786. private _value;
  77787. private _originalUnit;
  77788. /**
  77789. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77790. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77791. */
  77792. ignoreAdaptiveScaling: boolean;
  77793. /**
  77794. * Creates a new ValueAndUnit
  77795. * @param value defines the value to store
  77796. * @param unit defines the unit to store
  77797. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77798. */
  77799. constructor(value: number,
  77800. /** defines the unit to store */
  77801. unit?: number,
  77802. /** defines a boolean indicating if the value can be negative */
  77803. negativeValueAllowed?: boolean);
  77804. /** Gets a boolean indicating if the value is a percentage */
  77805. get isPercentage(): boolean;
  77806. /** Gets a boolean indicating if the value is store as pixel */
  77807. get isPixel(): boolean;
  77808. /** Gets direct internal value */
  77809. get internalValue(): number;
  77810. /**
  77811. * Gets value as pixel
  77812. * @param host defines the root host
  77813. * @param refValue defines the reference value for percentages
  77814. * @returns the value as pixel
  77815. */
  77816. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77817. /**
  77818. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77819. * @param value defines the value to store
  77820. * @param unit defines the unit to store
  77821. * @returns the current ValueAndUnit
  77822. */
  77823. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77824. /**
  77825. * Gets the value accordingly to its unit
  77826. * @param host defines the root host
  77827. * @returns the value
  77828. */
  77829. getValue(host: AdvancedDynamicTexture): number;
  77830. /**
  77831. * Gets a string representation of the value
  77832. * @param host defines the root host
  77833. * @param decimals defines an optional number of decimals to display
  77834. * @returns a string
  77835. */
  77836. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77837. /**
  77838. * Store a value parsed from a string
  77839. * @param source defines the source string
  77840. * @returns true if the value was successfully parsed
  77841. */
  77842. fromString(source: string | number): boolean;
  77843. private static _Regex;
  77844. private static _UNITMODE_PERCENTAGE;
  77845. private static _UNITMODE_PIXEL;
  77846. /** UNITMODE_PERCENTAGE */
  77847. static get UNITMODE_PERCENTAGE(): number;
  77848. /** UNITMODE_PIXEL */
  77849. static get UNITMODE_PIXEL(): number;
  77850. }
  77851. }
  77852. declare module BABYLON.GUI {
  77853. /**
  77854. * Define a style used by control to automatically setup properties based on a template.
  77855. * Only support font related properties so far
  77856. */
  77857. export class Style implements BABYLON.IDisposable {
  77858. private _fontFamily;
  77859. private _fontStyle;
  77860. private _fontWeight;
  77861. /** @hidden */
  77862. _host: AdvancedDynamicTexture;
  77863. /** @hidden */
  77864. _fontSize: ValueAndUnit;
  77865. /**
  77866. * BABYLON.Observable raised when the style values are changed
  77867. */
  77868. onChangedObservable: BABYLON.Observable<Style>;
  77869. /**
  77870. * Creates a new style object
  77871. * @param host defines the AdvancedDynamicTexture which hosts this style
  77872. */
  77873. constructor(host: AdvancedDynamicTexture);
  77874. /**
  77875. * Gets or sets the font size
  77876. */
  77877. get fontSize(): string | number;
  77878. set fontSize(value: string | number);
  77879. /**
  77880. * Gets or sets the font family
  77881. */
  77882. get fontFamily(): string;
  77883. set fontFamily(value: string);
  77884. /**
  77885. * Gets or sets the font style
  77886. */
  77887. get fontStyle(): string;
  77888. set fontStyle(value: string);
  77889. /** Gets or sets font weight */
  77890. get fontWeight(): string;
  77891. set fontWeight(value: string);
  77892. /** Dispose all associated resources */
  77893. dispose(): void;
  77894. }
  77895. }
  77896. declare module BABYLON.GUI {
  77897. /**
  77898. * Class used to transport BABYLON.Vector2 information for pointer events
  77899. */
  77900. export class Vector2WithInfo extends BABYLON.Vector2 {
  77901. /** defines the current mouse button index */
  77902. buttonIndex: number;
  77903. /**
  77904. * Creates a new Vector2WithInfo
  77905. * @param source defines the vector2 data to transport
  77906. * @param buttonIndex defines the current mouse button index
  77907. */
  77908. constructor(source: BABYLON.Vector2,
  77909. /** defines the current mouse button index */
  77910. buttonIndex?: number);
  77911. }
  77912. /** Class used to provide 2D matrix features */
  77913. export class Matrix2D {
  77914. /** Gets the internal array of 6 floats used to store matrix data */
  77915. m: Float32Array;
  77916. /**
  77917. * Creates a new matrix
  77918. * @param m00 defines value for (0, 0)
  77919. * @param m01 defines value for (0, 1)
  77920. * @param m10 defines value for (1, 0)
  77921. * @param m11 defines value for (1, 1)
  77922. * @param m20 defines value for (2, 0)
  77923. * @param m21 defines value for (2, 1)
  77924. */
  77925. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77926. /**
  77927. * Fills the matrix from direct values
  77928. * @param m00 defines value for (0, 0)
  77929. * @param m01 defines value for (0, 1)
  77930. * @param m10 defines value for (1, 0)
  77931. * @param m11 defines value for (1, 1)
  77932. * @param m20 defines value for (2, 0)
  77933. * @param m21 defines value for (2, 1)
  77934. * @returns the current modified matrix
  77935. */
  77936. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77937. /**
  77938. * Gets matrix determinant
  77939. * @returns the determinant
  77940. */
  77941. determinant(): number;
  77942. /**
  77943. * Inverses the matrix and stores it in a target matrix
  77944. * @param result defines the target matrix
  77945. * @returns the current matrix
  77946. */
  77947. invertToRef(result: Matrix2D): Matrix2D;
  77948. /**
  77949. * Multiplies the current matrix with another one
  77950. * @param other defines the second operand
  77951. * @param result defines the target matrix
  77952. * @returns the current matrix
  77953. */
  77954. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77955. /**
  77956. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77957. * @param x defines the x coordinate to transform
  77958. * @param y defines the x coordinate to transform
  77959. * @param result defines the target vector2
  77960. * @returns the current matrix
  77961. */
  77962. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77963. /**
  77964. * Creates an identity matrix
  77965. * @returns a new matrix
  77966. */
  77967. static Identity(): Matrix2D;
  77968. /**
  77969. * Creates a translation matrix and stores it in a target matrix
  77970. * @param x defines the x coordinate of the translation
  77971. * @param y defines the y coordinate of the translation
  77972. * @param result defines the target matrix
  77973. */
  77974. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77975. /**
  77976. * Creates a scaling matrix and stores it in a target matrix
  77977. * @param x defines the x coordinate of the scaling
  77978. * @param y defines the y coordinate of the scaling
  77979. * @param result defines the target matrix
  77980. */
  77981. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77982. /**
  77983. * Creates a rotation matrix and stores it in a target matrix
  77984. * @param angle defines the rotation angle
  77985. * @param result defines the target matrix
  77986. */
  77987. static RotationToRef(angle: number, result: Matrix2D): void;
  77988. private static _TempPreTranslationMatrix;
  77989. private static _TempPostTranslationMatrix;
  77990. private static _TempRotationMatrix;
  77991. private static _TempScalingMatrix;
  77992. private static _TempCompose0;
  77993. private static _TempCompose1;
  77994. private static _TempCompose2;
  77995. /**
  77996. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77997. * @param tx defines the x coordinate of the translation
  77998. * @param ty defines the y coordinate of the translation
  77999. * @param angle defines the rotation angle
  78000. * @param scaleX defines the x coordinate of the scaling
  78001. * @param scaleY defines the y coordinate of the scaling
  78002. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  78003. * @param result defines the target matrix
  78004. */
  78005. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  78006. }
  78007. }
  78008. declare module BABYLON.GUI {
  78009. /**
  78010. * Class used to store 2D control sizes
  78011. */
  78012. export class Measure {
  78013. /** defines left coordinate */
  78014. left: number;
  78015. /** defines top coordinate */
  78016. top: number;
  78017. /** defines width dimension */
  78018. width: number;
  78019. /** defines height dimension */
  78020. height: number;
  78021. /**
  78022. * Creates a new measure
  78023. * @param left defines left coordinate
  78024. * @param top defines top coordinate
  78025. * @param width defines width dimension
  78026. * @param height defines height dimension
  78027. */
  78028. constructor(
  78029. /** defines left coordinate */
  78030. left: number,
  78031. /** defines top coordinate */
  78032. top: number,
  78033. /** defines width dimension */
  78034. width: number,
  78035. /** defines height dimension */
  78036. height: number);
  78037. /**
  78038. * Copy from another measure
  78039. * @param other defines the other measure to copy from
  78040. */
  78041. copyFrom(other: Measure): void;
  78042. /**
  78043. * Copy from a group of 4 floats
  78044. * @param left defines left coordinate
  78045. * @param top defines top coordinate
  78046. * @param width defines width dimension
  78047. * @param height defines height dimension
  78048. */
  78049. copyFromFloats(left: number, top: number, width: number, height: number): void;
  78050. /**
  78051. * Computes the axis aligned bounding box measure for two given measures
  78052. * @param a Input measure
  78053. * @param b Input measure
  78054. * @param result the resulting bounding measure
  78055. */
  78056. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  78057. /**
  78058. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78059. * @param transform the matrix to transform the measure before computing the AABB
  78060. * @param addX number to add to left
  78061. * @param addY number to add to top
  78062. * @param addWidth number to add to width
  78063. * @param addHeight number to add to height
  78064. * @param result the resulting AABB
  78065. */
  78066. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  78067. /**
  78068. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78069. * @param transform the matrix to transform the measure before computing the AABB
  78070. * @param result the resulting AABB
  78071. */
  78072. transformToRef(transform: Matrix2D, result: Measure): void;
  78073. /**
  78074. * Check equality between this measure and another one
  78075. * @param other defines the other measures
  78076. * @returns true if both measures are equals
  78077. */
  78078. isEqualsTo(other: Measure): boolean;
  78079. /**
  78080. * Creates an empty measure
  78081. * @returns a new measure
  78082. */
  78083. static Empty(): Measure;
  78084. }
  78085. }
  78086. declare module BABYLON.GUI {
  78087. /**
  78088. * Interface used to define a control that can receive focus
  78089. */
  78090. export interface IFocusableControl {
  78091. /**
  78092. * Function called when the control receives the focus
  78093. */
  78094. onFocus(): void;
  78095. /**
  78096. * Function called when the control loses the focus
  78097. */
  78098. onBlur(): void;
  78099. /**
  78100. * Function called to let the control handle keyboard events
  78101. * @param evt defines the current keyboard event
  78102. */
  78103. processKeyboard(evt: KeyboardEvent): void;
  78104. /**
  78105. * Function called to get the list of controls that should not steal the focus from this control
  78106. * @returns an array of controls
  78107. */
  78108. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78109. }
  78110. /**
  78111. * Class used to create texture to support 2D GUI elements
  78112. * @see https://doc.babylonjs.com/how_to/gui
  78113. */
  78114. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  78115. private _isDirty;
  78116. private _renderObserver;
  78117. private _resizeObserver;
  78118. private _preKeyboardObserver;
  78119. private _pointerMoveObserver;
  78120. private _pointerObserver;
  78121. private _canvasPointerOutObserver;
  78122. private _canvasBlurObserver;
  78123. private _background;
  78124. /** @hidden */
  78125. _rootContainer: Container;
  78126. /** @hidden */
  78127. _lastPickedControl: Control;
  78128. /** @hidden */
  78129. _lastControlOver: {
  78130. [pointerId: number]: Control;
  78131. };
  78132. /** @hidden */
  78133. _lastControlDown: {
  78134. [pointerId: number]: Control;
  78135. };
  78136. /** @hidden */
  78137. _capturingControl: {
  78138. [pointerId: number]: Control;
  78139. };
  78140. /** @hidden */
  78141. _shouldBlockPointer: boolean;
  78142. /** @hidden */
  78143. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  78144. /** @hidden */
  78145. _linkedControls: Control[];
  78146. private _isFullscreen;
  78147. private _fullscreenViewport;
  78148. private _idealWidth;
  78149. private _idealHeight;
  78150. private _useSmallestIdeal;
  78151. private _renderAtIdealSize;
  78152. private _focusedControl;
  78153. private _blockNextFocusCheck;
  78154. private _renderScale;
  78155. private _rootElement;
  78156. private _cursorChanged;
  78157. private _defaultMousePointerId;
  78158. /** @hidden */
  78159. _numLayoutCalls: number;
  78160. /** Gets the number of layout calls made the last time the ADT has been rendered */
  78161. get numLayoutCalls(): number;
  78162. /** @hidden */
  78163. _numRenderCalls: number;
  78164. /** Gets the number of render calls made the last time the ADT has been rendered */
  78165. get numRenderCalls(): number;
  78166. /**
  78167. * Define type to string to ensure compatibility across browsers
  78168. * Safari doesn't support DataTransfer constructor
  78169. */
  78170. private _clipboardData;
  78171. /**
  78172. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  78173. */
  78174. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  78175. /**
  78176. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  78177. */
  78178. onControlPickedObservable: BABYLON.Observable<Control>;
  78179. /**
  78180. * BABYLON.Observable event triggered before layout is evaluated
  78181. */
  78182. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78183. /**
  78184. * BABYLON.Observable event triggered after the layout was evaluated
  78185. */
  78186. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78187. /**
  78188. * BABYLON.Observable event triggered before the texture is rendered
  78189. */
  78190. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78191. /**
  78192. * BABYLON.Observable event triggered after the texture was rendered
  78193. */
  78194. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78195. /**
  78196. * Gets or sets a boolean defining if alpha is stored as premultiplied
  78197. */
  78198. premulAlpha: boolean;
  78199. /**
  78200. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  78201. * Useful when you want more antialiasing
  78202. */
  78203. get renderScale(): number;
  78204. set renderScale(value: number);
  78205. /** Gets or sets the background color */
  78206. get background(): string;
  78207. set background(value: string);
  78208. /**
  78209. * Gets or sets the ideal width used to design controls.
  78210. * The GUI will then rescale everything accordingly
  78211. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78212. */
  78213. get idealWidth(): number;
  78214. set idealWidth(value: number);
  78215. /**
  78216. * Gets or sets the ideal height used to design controls.
  78217. * The GUI will then rescale everything accordingly
  78218. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78219. */
  78220. get idealHeight(): number;
  78221. set idealHeight(value: number);
  78222. /**
  78223. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  78224. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78225. */
  78226. get useSmallestIdeal(): boolean;
  78227. set useSmallestIdeal(value: boolean);
  78228. /**
  78229. * Gets or sets a boolean indicating if adaptive scaling must be used
  78230. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78231. */
  78232. get renderAtIdealSize(): boolean;
  78233. set renderAtIdealSize(value: boolean);
  78234. /**
  78235. * Gets the ratio used when in "ideal mode"
  78236. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78237. * */
  78238. get idealRatio(): number;
  78239. /**
  78240. * Gets the underlying layer used to render the texture when in fullscreen mode
  78241. */
  78242. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  78243. /**
  78244. * Gets the root container control
  78245. */
  78246. get rootContainer(): Container;
  78247. /**
  78248. * Returns an array containing the root container.
  78249. * This is mostly used to let the Inspector introspects the ADT
  78250. * @returns an array containing the rootContainer
  78251. */
  78252. getChildren(): Array<Container>;
  78253. /**
  78254. * Will return all controls that are inside this texture
  78255. * @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
  78256. * @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
  78257. * @return all child controls
  78258. */
  78259. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78260. /**
  78261. * Gets or sets the current focused control
  78262. */
  78263. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78264. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78265. /**
  78266. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78267. */
  78268. get isForeground(): boolean;
  78269. set isForeground(value: boolean);
  78270. /**
  78271. * Gets or set information about clipboardData
  78272. */
  78273. get clipboardData(): string;
  78274. set clipboardData(value: string);
  78275. /**
  78276. * Creates a new AdvancedDynamicTexture
  78277. * @param name defines the name of the texture
  78278. * @param width defines the width of the texture
  78279. * @param height defines the height of the texture
  78280. * @param scene defines the hosting scene
  78281. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78282. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78283. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78284. */
  78285. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78286. /**
  78287. * Get the current class name of the texture useful for serialization or dynamic coding.
  78288. * @returns "AdvancedDynamicTexture"
  78289. */
  78290. getClassName(): string;
  78291. /**
  78292. * Function used to execute a function on all controls
  78293. * @param func defines the function to execute
  78294. * @param container defines the container where controls belong. If null the root container will be used
  78295. */
  78296. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78297. private _useInvalidateRectOptimization;
  78298. /**
  78299. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78300. */
  78301. get useInvalidateRectOptimization(): boolean;
  78302. set useInvalidateRectOptimization(value: boolean);
  78303. private _invalidatedRectangle;
  78304. /**
  78305. * Invalidates a rectangle area on the gui texture
  78306. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78307. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78308. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78309. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78310. */
  78311. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78312. /**
  78313. * Marks the texture as dirty forcing a complete update
  78314. */
  78315. markAsDirty(): void;
  78316. /**
  78317. * Helper function used to create a new style
  78318. * @returns a new style
  78319. * @see https://doc.babylonjs.com/how_to/gui#styles
  78320. */
  78321. createStyle(): Style;
  78322. /**
  78323. * Adds a new control to the root container
  78324. * @param control defines the control to add
  78325. * @returns the current texture
  78326. */
  78327. addControl(control: Control): AdvancedDynamicTexture;
  78328. /**
  78329. * Removes a control from the root container
  78330. * @param control defines the control to remove
  78331. * @returns the current texture
  78332. */
  78333. removeControl(control: Control): AdvancedDynamicTexture;
  78334. /**
  78335. * Release all resources
  78336. */
  78337. dispose(): void;
  78338. private _onResize;
  78339. /** @hidden */
  78340. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78341. /**
  78342. * Get screen coordinates for a vector3
  78343. * @param position defines the position to project
  78344. * @param worldMatrix defines the world matrix to use
  78345. * @returns the projected position
  78346. */
  78347. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78348. /**
  78349. * Get screen coordinates for a vector3
  78350. * @param position defines the position to project
  78351. * @param worldMatrix defines the world matrix to use
  78352. * @returns the projected position with Z
  78353. */
  78354. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  78355. private _checkUpdate;
  78356. private _clearMeasure;
  78357. private _render;
  78358. /** @hidden */
  78359. _changeCursor(cursor: string): void;
  78360. /** @hidden */
  78361. _registerLastControlDown(control: Control, pointerId: number): void;
  78362. private _doPicking;
  78363. /** @hidden */
  78364. _cleanControlAfterRemovalFromList(list: {
  78365. [pointerId: number]: Control;
  78366. }, control: Control): void;
  78367. /** @hidden */
  78368. _cleanControlAfterRemoval(control: Control): void;
  78369. /** Attach to all scene events required to support pointer events */
  78370. attach(): void;
  78371. /** @hidden */
  78372. private onClipboardCopy;
  78373. /** @hidden */
  78374. private onClipboardCut;
  78375. /** @hidden */
  78376. private onClipboardPaste;
  78377. /**
  78378. * Register the clipboard Events onto the canvas
  78379. */
  78380. registerClipboardEvents(): void;
  78381. /**
  78382. * Unregister the clipboard Events from the canvas
  78383. */
  78384. unRegisterClipboardEvents(): void;
  78385. /**
  78386. * Connect the texture to a hosting mesh to enable interactions
  78387. * @param mesh defines the mesh to attach to
  78388. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78389. */
  78390. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78391. /**
  78392. * Move the focus to a specific control
  78393. * @param control defines the control which will receive the focus
  78394. */
  78395. moveFocusToControl(control: IFocusableControl): void;
  78396. private _manageFocus;
  78397. private _attachToOnPointerOut;
  78398. private _attachToOnBlur;
  78399. /**
  78400. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78401. * @param mesh defines the mesh which will receive the texture
  78402. * @param width defines the texture width (1024 by default)
  78403. * @param height defines the texture height (1024 by default)
  78404. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78405. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78406. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78407. * @returns a new AdvancedDynamicTexture
  78408. */
  78409. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78410. /**
  78411. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78412. * In this mode the texture will rely on a layer for its rendering.
  78413. * This allows it to be treated like any other layer.
  78414. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78415. * LayerMask is set through advancedTexture.layer.layerMask
  78416. * @param name defines name for the texture
  78417. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78418. * @param scene defines the hsoting scene
  78419. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78420. * @returns a new AdvancedDynamicTexture
  78421. */
  78422. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78423. }
  78424. }
  78425. declare module BABYLON.GUI {
  78426. /**
  78427. * Root class used for all 2D controls
  78428. * @see https://doc.babylonjs.com/how_to/gui#controls
  78429. */
  78430. export class Control {
  78431. /** defines the name of the control */
  78432. name?: string | undefined;
  78433. /**
  78434. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78435. */
  78436. static AllowAlphaInheritance: boolean;
  78437. private _alpha;
  78438. private _alphaSet;
  78439. private _zIndex;
  78440. /** @hidden */
  78441. _host: AdvancedDynamicTexture;
  78442. /** Gets or sets the control parent */
  78443. parent: BABYLON.Nullable<Container>;
  78444. /** @hidden */
  78445. _currentMeasure: Measure;
  78446. private _fontFamily;
  78447. private _fontStyle;
  78448. private _fontWeight;
  78449. private _fontSize;
  78450. private _font;
  78451. /** @hidden */
  78452. _width: ValueAndUnit;
  78453. /** @hidden */
  78454. _height: ValueAndUnit;
  78455. /** @hidden */
  78456. protected _fontOffset: {
  78457. ascent: number;
  78458. height: number;
  78459. descent: number;
  78460. };
  78461. private _color;
  78462. private _style;
  78463. private _styleObserver;
  78464. /** @hidden */
  78465. protected _horizontalAlignment: number;
  78466. /** @hidden */
  78467. protected _verticalAlignment: number;
  78468. /** @hidden */
  78469. protected _isDirty: boolean;
  78470. /** @hidden */
  78471. protected _wasDirty: boolean;
  78472. /** @hidden */
  78473. _tempParentMeasure: Measure;
  78474. /** @hidden */
  78475. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78476. /** @hidden */
  78477. protected _cachedParentMeasure: Measure;
  78478. private _paddingLeft;
  78479. private _paddingRight;
  78480. private _paddingTop;
  78481. private _paddingBottom;
  78482. /** @hidden */
  78483. _left: ValueAndUnit;
  78484. /** @hidden */
  78485. _top: ValueAndUnit;
  78486. private _scaleX;
  78487. private _scaleY;
  78488. private _rotation;
  78489. private _transformCenterX;
  78490. private _transformCenterY;
  78491. /** @hidden */
  78492. _transformMatrix: Matrix2D;
  78493. /** @hidden */
  78494. protected _invertTransformMatrix: Matrix2D;
  78495. /** @hidden */
  78496. protected _transformedPosition: BABYLON.Vector2;
  78497. private _isMatrixDirty;
  78498. private _cachedOffsetX;
  78499. private _cachedOffsetY;
  78500. private _isVisible;
  78501. private _isHighlighted;
  78502. /** @hidden */
  78503. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78504. private _fontSet;
  78505. private _dummyVector2;
  78506. private _downCount;
  78507. private _enterCount;
  78508. private _doNotRender;
  78509. private _downPointerIds;
  78510. protected _isEnabled: boolean;
  78511. protected _disabledColor: string;
  78512. protected _disabledColorItem: string;
  78513. /** @hidden */
  78514. protected _rebuildLayout: boolean;
  78515. /** @hidden */
  78516. _customData: any;
  78517. /** @hidden */
  78518. _isClipped: boolean;
  78519. /** @hidden */
  78520. _automaticSize: boolean;
  78521. /** @hidden */
  78522. _tag: any;
  78523. /**
  78524. * 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
  78525. */
  78526. uniqueId: number;
  78527. /**
  78528. * Gets or sets an object used to store user defined information for the node
  78529. */
  78530. metadata: any;
  78531. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78532. isHitTestVisible: boolean;
  78533. /** Gets or sets a boolean indicating if the control can block pointer events */
  78534. isPointerBlocker: boolean;
  78535. /** Gets or sets a boolean indicating if the control can be focusable */
  78536. isFocusInvisible: boolean;
  78537. /**
  78538. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78539. * 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
  78540. */
  78541. clipChildren: boolean;
  78542. /**
  78543. * Gets or sets a boolean indicating that control content must be clipped
  78544. * 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
  78545. */
  78546. clipContent: boolean;
  78547. /**
  78548. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78549. */
  78550. useBitmapCache: boolean;
  78551. private _cacheData;
  78552. private _shadowOffsetX;
  78553. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78554. get shadowOffsetX(): number;
  78555. set shadowOffsetX(value: number);
  78556. private _shadowOffsetY;
  78557. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78558. get shadowOffsetY(): number;
  78559. set shadowOffsetY(value: number);
  78560. private _shadowBlur;
  78561. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78562. get shadowBlur(): number;
  78563. set shadowBlur(value: number);
  78564. private _shadowColor;
  78565. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78566. get shadowColor(): string;
  78567. set shadowColor(value: string);
  78568. /** Gets or sets the cursor to use when the control is hovered */
  78569. hoverCursor: string;
  78570. /** @hidden */
  78571. protected _linkOffsetX: ValueAndUnit;
  78572. /** @hidden */
  78573. protected _linkOffsetY: ValueAndUnit;
  78574. /** Gets the control type name */
  78575. get typeName(): string;
  78576. /**
  78577. * Get the current class name of the control.
  78578. * @returns current class name
  78579. */
  78580. getClassName(): string;
  78581. /**
  78582. * An event triggered when pointer wheel is scrolled
  78583. */
  78584. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78585. /**
  78586. * An event triggered when the pointer move over the control.
  78587. */
  78588. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78589. /**
  78590. * An event triggered when the pointer move out of the control.
  78591. */
  78592. onPointerOutObservable: BABYLON.Observable<Control>;
  78593. /**
  78594. * An event triggered when the pointer taps the control
  78595. */
  78596. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78597. /**
  78598. * An event triggered when pointer up
  78599. */
  78600. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78601. /**
  78602. * An event triggered when a control is clicked on
  78603. */
  78604. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78605. /**
  78606. * An event triggered when pointer enters the control
  78607. */
  78608. onPointerEnterObservable: BABYLON.Observable<Control>;
  78609. /**
  78610. * An event triggered when the control is marked as dirty
  78611. */
  78612. onDirtyObservable: BABYLON.Observable<Control>;
  78613. /**
  78614. * An event triggered before drawing the control
  78615. */
  78616. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78617. /**
  78618. * An event triggered after the control was drawn
  78619. */
  78620. onAfterDrawObservable: BABYLON.Observable<Control>;
  78621. /**
  78622. * An event triggered when the control has been disposed
  78623. */
  78624. onDisposeObservable: BABYLON.Observable<Control>;
  78625. /**
  78626. * Get the hosting AdvancedDynamicTexture
  78627. */
  78628. get host(): AdvancedDynamicTexture;
  78629. /** Gets or set information about font offsets (used to render and align text) */
  78630. get fontOffset(): {
  78631. ascent: number;
  78632. height: number;
  78633. descent: number;
  78634. };
  78635. set fontOffset(offset: {
  78636. ascent: number;
  78637. height: number;
  78638. descent: number;
  78639. });
  78640. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78641. get alpha(): number;
  78642. set alpha(value: number);
  78643. /**
  78644. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78645. */
  78646. get isHighlighted(): boolean;
  78647. set isHighlighted(value: boolean);
  78648. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78649. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78650. */
  78651. get scaleX(): number;
  78652. set scaleX(value: number);
  78653. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78654. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78655. */
  78656. get scaleY(): number;
  78657. set scaleY(value: number);
  78658. /** Gets or sets the rotation angle (0 by default)
  78659. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78660. */
  78661. get rotation(): number;
  78662. set rotation(value: number);
  78663. /** Gets or sets the transformation center on Y axis (0 by default)
  78664. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78665. */
  78666. get transformCenterY(): number;
  78667. set transformCenterY(value: number);
  78668. /** Gets or sets the transformation center on X axis (0 by default)
  78669. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78670. */
  78671. get transformCenterX(): number;
  78672. set transformCenterX(value: number);
  78673. /**
  78674. * Gets or sets the horizontal alignment
  78675. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78676. */
  78677. get horizontalAlignment(): number;
  78678. set horizontalAlignment(value: number);
  78679. /**
  78680. * Gets or sets the vertical alignment
  78681. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78682. */
  78683. get verticalAlignment(): number;
  78684. set verticalAlignment(value: number);
  78685. /**
  78686. * Gets or sets a fixed ratio for this control.
  78687. * When different from 0, the ratio is used to compute the "second" dimension.
  78688. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78689. * second dimension is computed as first dimension * fixedRatio
  78690. */
  78691. fixedRatio: number;
  78692. private _fixedRatioMasterIsWidth;
  78693. /**
  78694. * Gets or sets control width
  78695. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78696. */
  78697. get width(): string | number;
  78698. set width(value: string | number);
  78699. /**
  78700. * Gets or sets the control width in pixel
  78701. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78702. */
  78703. get widthInPixels(): number;
  78704. set widthInPixels(value: number);
  78705. /**
  78706. * Gets or sets control height
  78707. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78708. */
  78709. get height(): string | number;
  78710. set height(value: string | number);
  78711. /**
  78712. * Gets or sets control height in pixel
  78713. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78714. */
  78715. get heightInPixels(): number;
  78716. set heightInPixels(value: number);
  78717. /** Gets or set font family */
  78718. get fontFamily(): string;
  78719. set fontFamily(value: string);
  78720. /** Gets or sets font style */
  78721. get fontStyle(): string;
  78722. set fontStyle(value: string);
  78723. /** Gets or sets font weight */
  78724. get fontWeight(): string;
  78725. set fontWeight(value: string);
  78726. /**
  78727. * Gets or sets style
  78728. * @see https://doc.babylonjs.com/how_to/gui#styles
  78729. */
  78730. get style(): BABYLON.Nullable<Style>;
  78731. set style(value: BABYLON.Nullable<Style>);
  78732. /** @hidden */
  78733. get _isFontSizeInPercentage(): boolean;
  78734. /** Gets or sets font size in pixels */
  78735. get fontSizeInPixels(): number;
  78736. set fontSizeInPixels(value: number);
  78737. /** Gets or sets font size */
  78738. get fontSize(): string | number;
  78739. set fontSize(value: string | number);
  78740. /** Gets or sets foreground color */
  78741. get color(): string;
  78742. set color(value: string);
  78743. /** Gets or sets z index which is used to reorder controls on the z axis */
  78744. get zIndex(): number;
  78745. set zIndex(value: number);
  78746. /** Gets or sets a boolean indicating if the control can be rendered */
  78747. get notRenderable(): boolean;
  78748. set notRenderable(value: boolean);
  78749. /** Gets or sets a boolean indicating if the control is visible */
  78750. get isVisible(): boolean;
  78751. set isVisible(value: boolean);
  78752. /** Gets a boolean indicating that the control needs to update its rendering */
  78753. get isDirty(): boolean;
  78754. /**
  78755. * Gets the current linked mesh (or null if none)
  78756. */
  78757. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78758. /**
  78759. * Gets or sets a value indicating the padding to use on the left of the control
  78760. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78761. */
  78762. get paddingLeft(): string | number;
  78763. set paddingLeft(value: string | number);
  78764. /**
  78765. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78766. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78767. */
  78768. get paddingLeftInPixels(): number;
  78769. set paddingLeftInPixels(value: number);
  78770. /**
  78771. * Gets or sets a value indicating the padding to use on the right of the control
  78772. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78773. */
  78774. get paddingRight(): string | number;
  78775. set paddingRight(value: string | number);
  78776. /**
  78777. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78778. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78779. */
  78780. get paddingRightInPixels(): number;
  78781. set paddingRightInPixels(value: number);
  78782. /**
  78783. * Gets or sets a value indicating the padding to use on the top of the control
  78784. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78785. */
  78786. get paddingTop(): string | number;
  78787. set paddingTop(value: string | number);
  78788. /**
  78789. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78790. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78791. */
  78792. get paddingTopInPixels(): number;
  78793. set paddingTopInPixels(value: number);
  78794. /**
  78795. * Gets or sets a value indicating the padding to use on the bottom of the control
  78796. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78797. */
  78798. get paddingBottom(): string | number;
  78799. set paddingBottom(value: string | number);
  78800. /**
  78801. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78802. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78803. */
  78804. get paddingBottomInPixels(): number;
  78805. set paddingBottomInPixels(value: number);
  78806. /**
  78807. * Gets or sets a value indicating the left coordinate of the control
  78808. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78809. */
  78810. get left(): string | number;
  78811. set left(value: string | number);
  78812. /**
  78813. * Gets or sets a value indicating the left coordinate in pixels of the control
  78814. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78815. */
  78816. get leftInPixels(): number;
  78817. set leftInPixels(value: number);
  78818. /**
  78819. * Gets or sets a value indicating the top coordinate of the control
  78820. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78821. */
  78822. get top(): string | number;
  78823. set top(value: string | number);
  78824. /**
  78825. * Gets or sets a value indicating the top coordinate in pixels of the control
  78826. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78827. */
  78828. get topInPixels(): number;
  78829. set topInPixels(value: number);
  78830. /**
  78831. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78832. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78833. */
  78834. get linkOffsetX(): string | number;
  78835. set linkOffsetX(value: string | number);
  78836. /**
  78837. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78838. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78839. */
  78840. get linkOffsetXInPixels(): number;
  78841. set linkOffsetXInPixels(value: number);
  78842. /**
  78843. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78844. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78845. */
  78846. get linkOffsetY(): string | number;
  78847. set linkOffsetY(value: string | number);
  78848. /**
  78849. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78850. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78851. */
  78852. get linkOffsetYInPixels(): number;
  78853. set linkOffsetYInPixels(value: number);
  78854. /** Gets the center coordinate on X axis */
  78855. get centerX(): number;
  78856. /** Gets the center coordinate on Y axis */
  78857. get centerY(): number;
  78858. /** Gets or sets if control is Enabled*/
  78859. get isEnabled(): boolean;
  78860. set isEnabled(value: boolean);
  78861. /** Gets or sets background color of control if it's disabled*/
  78862. get disabledColor(): string;
  78863. set disabledColor(value: string);
  78864. /** Gets or sets front color of control if it's disabled*/
  78865. get disabledColorItem(): string;
  78866. set disabledColorItem(value: string);
  78867. /**
  78868. * Creates a new control
  78869. * @param name defines the name of the control
  78870. */
  78871. constructor(
  78872. /** defines the name of the control */
  78873. name?: string | undefined);
  78874. /** @hidden */
  78875. protected _getTypeName(): string;
  78876. /**
  78877. * Gets the first ascendant in the hierarchy of the given type
  78878. * @param className defines the required type
  78879. * @returns the ascendant or null if not found
  78880. */
  78881. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78882. /** @hidden */
  78883. _resetFontCache(): void;
  78884. /**
  78885. * Determines if a container is an ascendant of the current control
  78886. * @param container defines the container to look for
  78887. * @returns true if the container is one of the ascendant of the control
  78888. */
  78889. isAscendant(container: Control): boolean;
  78890. /**
  78891. * Gets coordinates in local control space
  78892. * @param globalCoordinates defines the coordinates to transform
  78893. * @returns the new coordinates in local space
  78894. */
  78895. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78896. /**
  78897. * Gets coordinates in local control space
  78898. * @param globalCoordinates defines the coordinates to transform
  78899. * @param result defines the target vector2 where to store the result
  78900. * @returns the current control
  78901. */
  78902. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78903. /**
  78904. * Gets coordinates in parent local control space
  78905. * @param globalCoordinates defines the coordinates to transform
  78906. * @returns the new coordinates in parent local space
  78907. */
  78908. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78909. /**
  78910. * Move the current control to a vector3 position projected onto the screen.
  78911. * @param position defines the target position
  78912. * @param scene defines the hosting scene
  78913. */
  78914. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78915. /**
  78916. * Will store all controls that have this control as ascendant in a given array
  78917. * @param results defines the array where to store the descendants
  78918. * @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
  78919. * @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
  78920. */
  78921. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78922. /**
  78923. * Will return all controls that have this control as ascendant
  78924. * @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
  78925. * @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
  78926. * @return all child controls
  78927. */
  78928. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78929. /**
  78930. * Link current control with a target mesh
  78931. * @param mesh defines the mesh to link with
  78932. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78933. */
  78934. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  78935. /** @hidden */
  78936. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78937. /** @hidden */
  78938. _offsetLeft(offset: number): void;
  78939. /** @hidden */
  78940. _offsetTop(offset: number): void;
  78941. /** @hidden */
  78942. _markMatrixAsDirty(): void;
  78943. /** @hidden */
  78944. _flagDescendantsAsMatrixDirty(): void;
  78945. /** @hidden */
  78946. _intersectsRect(rect: Measure): boolean;
  78947. /** @hidden */
  78948. protected invalidateRect(): void;
  78949. /** @hidden */
  78950. _markAsDirty(force?: boolean): void;
  78951. /** @hidden */
  78952. _markAllAsDirty(): void;
  78953. /** @hidden */
  78954. _link(host: AdvancedDynamicTexture): void;
  78955. /** @hidden */
  78956. protected _transform(context?: CanvasRenderingContext2D): void;
  78957. /** @hidden */
  78958. _renderHighlight(context: CanvasRenderingContext2D): void;
  78959. /** @hidden */
  78960. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78961. /** @hidden */
  78962. protected _applyStates(context: CanvasRenderingContext2D): void;
  78963. /** @hidden */
  78964. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78965. /** @hidden */
  78966. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78967. protected _evaluateClippingState(parentMeasure: Measure): void;
  78968. /** @hidden */
  78969. _measure(): void;
  78970. /** @hidden */
  78971. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78972. /** @hidden */
  78973. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78974. /** @hidden */
  78975. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78976. /** @hidden */
  78977. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78978. private static _ClipMeasure;
  78979. private _tmpMeasureA;
  78980. private _clip;
  78981. /** @hidden */
  78982. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78983. /** @hidden */
  78984. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78985. /**
  78986. * Tests if a given coordinates belong to the current control
  78987. * @param x defines x coordinate to test
  78988. * @param y defines y coordinate to test
  78989. * @returns true if the coordinates are inside the control
  78990. */
  78991. contains(x: number, y: number): boolean;
  78992. /** @hidden */
  78993. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78994. /** @hidden */
  78995. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  78996. /** @hidden */
  78997. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78998. /** @hidden */
  78999. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  79000. /** @hidden */
  79001. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79002. /** @hidden */
  79003. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  79004. /** @hidden */
  79005. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79006. /** @hidden */
  79007. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  79008. /** @hidden */
  79009. _onCanvasBlur(): void;
  79010. /** @hidden */
  79011. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79012. private _prepareFont;
  79013. /** Releases associated resources */
  79014. dispose(): void;
  79015. private static _HORIZONTAL_ALIGNMENT_LEFT;
  79016. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  79017. private static _HORIZONTAL_ALIGNMENT_CENTER;
  79018. private static _VERTICAL_ALIGNMENT_TOP;
  79019. private static _VERTICAL_ALIGNMENT_BOTTOM;
  79020. private static _VERTICAL_ALIGNMENT_CENTER;
  79021. /** HORIZONTAL_ALIGNMENT_LEFT */
  79022. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  79023. /** HORIZONTAL_ALIGNMENT_RIGHT */
  79024. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  79025. /** HORIZONTAL_ALIGNMENT_CENTER */
  79026. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  79027. /** VERTICAL_ALIGNMENT_TOP */
  79028. static get VERTICAL_ALIGNMENT_TOP(): number;
  79029. /** VERTICAL_ALIGNMENT_BOTTOM */
  79030. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  79031. /** VERTICAL_ALIGNMENT_CENTER */
  79032. static get VERTICAL_ALIGNMENT_CENTER(): number;
  79033. private static _FontHeightSizes;
  79034. /** @hidden */
  79035. static _GetFontOffset(font: string): {
  79036. ascent: number;
  79037. height: number;
  79038. descent: number;
  79039. };
  79040. /**
  79041. * Creates a stack panel that can be used to render headers
  79042. * @param control defines the control to associate with the header
  79043. * @param text defines the text of the header
  79044. * @param size defines the size of the header
  79045. * @param options defines options used to configure the header
  79046. * @returns a new StackPanel
  79047. * @ignore
  79048. * @hidden
  79049. */
  79050. static AddHeader: (control: Control, text: string, size: string | number, options: {
  79051. isHorizontal: boolean;
  79052. controlFirst: boolean;
  79053. }) => any;
  79054. /** @hidden */
  79055. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  79056. }
  79057. }
  79058. declare module BABYLON.GUI {
  79059. /**
  79060. * Root class for 2D containers
  79061. * @see https://doc.babylonjs.com/how_to/gui#containers
  79062. */
  79063. export class Container extends Control {
  79064. name?: string | undefined;
  79065. /** @hidden */
  79066. _children: Control[];
  79067. /** @hidden */
  79068. protected _measureForChildren: Measure;
  79069. /** @hidden */
  79070. protected _background: string;
  79071. /** @hidden */
  79072. protected _adaptWidthToChildren: boolean;
  79073. /** @hidden */
  79074. protected _adaptHeightToChildren: boolean;
  79075. /**
  79076. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  79077. */
  79078. logLayoutCycleErrors: boolean;
  79079. /**
  79080. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  79081. */
  79082. maxLayoutCycle: number;
  79083. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  79084. get adaptHeightToChildren(): boolean;
  79085. set adaptHeightToChildren(value: boolean);
  79086. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  79087. get adaptWidthToChildren(): boolean;
  79088. set adaptWidthToChildren(value: boolean);
  79089. /** Gets or sets background color */
  79090. get background(): string;
  79091. set background(value: string);
  79092. /** Gets the list of children */
  79093. get children(): Control[];
  79094. /**
  79095. * Creates a new Container
  79096. * @param name defines the name of the container
  79097. */
  79098. constructor(name?: string | undefined);
  79099. protected _getTypeName(): string;
  79100. _flagDescendantsAsMatrixDirty(): void;
  79101. /**
  79102. * Gets a child using its name
  79103. * @param name defines the child name to look for
  79104. * @returns the child control if found
  79105. */
  79106. getChildByName(name: string): BABYLON.Nullable<Control>;
  79107. /**
  79108. * Gets a child using its type and its name
  79109. * @param name defines the child name to look for
  79110. * @param type defines the child type to look for
  79111. * @returns the child control if found
  79112. */
  79113. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  79114. /**
  79115. * Search for a specific control in children
  79116. * @param control defines the control to look for
  79117. * @returns true if the control is in child list
  79118. */
  79119. containsControl(control: Control): boolean;
  79120. /**
  79121. * Adds a new control to the current container
  79122. * @param control defines the control to add
  79123. * @returns the current container
  79124. */
  79125. addControl(control: BABYLON.Nullable<Control>): Container;
  79126. /**
  79127. * Removes all controls from the current container
  79128. * @returns the current container
  79129. */
  79130. clearControls(): Container;
  79131. /**
  79132. * Removes a control from the current container
  79133. * @param control defines the control to remove
  79134. * @returns the current container
  79135. */
  79136. removeControl(control: Control): Container;
  79137. /** @hidden */
  79138. _reOrderControl(control: Control): void;
  79139. /** @hidden */
  79140. _offsetLeft(offset: number): void;
  79141. /** @hidden */
  79142. _offsetTop(offset: number): void;
  79143. /** @hidden */
  79144. _markAllAsDirty(): void;
  79145. /** @hidden */
  79146. protected _localDraw(context: CanvasRenderingContext2D): void;
  79147. /** @hidden */
  79148. _link(host: AdvancedDynamicTexture): void;
  79149. /** @hidden */
  79150. protected _beforeLayout(): void;
  79151. /** @hidden */
  79152. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79153. /** @hidden */
  79154. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79155. protected _postMeasure(): void;
  79156. /** @hidden */
  79157. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79158. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79159. /** @hidden */
  79160. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79161. /** @hidden */
  79162. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79163. /** Releases associated resources */
  79164. dispose(): void;
  79165. }
  79166. }
  79167. declare module BABYLON.GUI {
  79168. /** Class used to create rectangle container */
  79169. export class Rectangle extends Container {
  79170. name?: string | undefined;
  79171. private _thickness;
  79172. private _cornerRadius;
  79173. /** Gets or sets border thickness */
  79174. get thickness(): number;
  79175. set thickness(value: number);
  79176. /** Gets or sets the corner radius angle */
  79177. get cornerRadius(): number;
  79178. set cornerRadius(value: number);
  79179. /**
  79180. * Creates a new Rectangle
  79181. * @param name defines the control name
  79182. */
  79183. constructor(name?: string | undefined);
  79184. protected _getTypeName(): string;
  79185. protected _localDraw(context: CanvasRenderingContext2D): void;
  79186. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79187. private _drawRoundedRect;
  79188. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79189. }
  79190. }
  79191. declare module BABYLON.GUI {
  79192. /**
  79193. * Enum that determines the text-wrapping mode to use.
  79194. */
  79195. export enum TextWrapping {
  79196. /**
  79197. * Clip the text when it's larger than Control.width; this is the default mode.
  79198. */
  79199. Clip = 0,
  79200. /**
  79201. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  79202. */
  79203. WordWrap = 1,
  79204. /**
  79205. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  79206. */
  79207. Ellipsis = 2
  79208. }
  79209. /**
  79210. * Class used to create text block control
  79211. */
  79212. export class TextBlock extends Control {
  79213. /**
  79214. * Defines the name of the control
  79215. */
  79216. name?: string | undefined;
  79217. private _text;
  79218. private _textWrapping;
  79219. private _textHorizontalAlignment;
  79220. private _textVerticalAlignment;
  79221. private _lines;
  79222. private _resizeToFit;
  79223. private _lineSpacing;
  79224. private _outlineWidth;
  79225. private _outlineColor;
  79226. private _underline;
  79227. private _lineThrough;
  79228. /**
  79229. * An event triggered after the text is changed
  79230. */
  79231. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  79232. /**
  79233. * An event triggered after the text was broken up into lines
  79234. */
  79235. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  79236. /**
  79237. * Function used to split a string into words. By default, a string is split at each space character found
  79238. */
  79239. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  79240. /**
  79241. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  79242. */
  79243. get lines(): any[];
  79244. /**
  79245. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79246. */
  79247. get resizeToFit(): boolean;
  79248. /**
  79249. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79250. */
  79251. set resizeToFit(value: boolean);
  79252. /**
  79253. * Gets or sets a boolean indicating if text must be wrapped
  79254. */
  79255. get textWrapping(): TextWrapping | boolean;
  79256. /**
  79257. * Gets or sets a boolean indicating if text must be wrapped
  79258. */
  79259. set textWrapping(value: TextWrapping | boolean);
  79260. /**
  79261. * Gets or sets text to display
  79262. */
  79263. get text(): string;
  79264. /**
  79265. * Gets or sets text to display
  79266. */
  79267. set text(value: string);
  79268. /**
  79269. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79270. */
  79271. get textHorizontalAlignment(): number;
  79272. /**
  79273. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79274. */
  79275. set textHorizontalAlignment(value: number);
  79276. /**
  79277. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79278. */
  79279. get textVerticalAlignment(): number;
  79280. /**
  79281. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79282. */
  79283. set textVerticalAlignment(value: number);
  79284. /**
  79285. * Gets or sets line spacing value
  79286. */
  79287. set lineSpacing(value: string | number);
  79288. /**
  79289. * Gets or sets line spacing value
  79290. */
  79291. get lineSpacing(): string | number;
  79292. /**
  79293. * Gets or sets outlineWidth of the text to display
  79294. */
  79295. get outlineWidth(): number;
  79296. /**
  79297. * Gets or sets outlineWidth of the text to display
  79298. */
  79299. set outlineWidth(value: number);
  79300. /**
  79301. * Gets or sets a boolean indicating that text must have underline
  79302. */
  79303. get underline(): boolean;
  79304. /**
  79305. * Gets or sets a boolean indicating that text must have underline
  79306. */
  79307. set underline(value: boolean);
  79308. /**
  79309. * Gets or sets an boolean indicating that text must be crossed out
  79310. */
  79311. get lineThrough(): boolean;
  79312. /**
  79313. * Gets or sets an boolean indicating that text must be crossed out
  79314. */
  79315. set lineThrough(value: boolean);
  79316. /**
  79317. * Gets or sets outlineColor of the text to display
  79318. */
  79319. get outlineColor(): string;
  79320. /**
  79321. * Gets or sets outlineColor of the text to display
  79322. */
  79323. set outlineColor(value: string);
  79324. /**
  79325. * Creates a new TextBlock object
  79326. * @param name defines the name of the control
  79327. * @param text defines the text to display (emptry string by default)
  79328. */
  79329. constructor(
  79330. /**
  79331. * Defines the name of the control
  79332. */
  79333. name?: string | undefined, text?: string);
  79334. protected _getTypeName(): string;
  79335. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79336. private _drawText;
  79337. /** @hidden */
  79338. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79339. protected _applyStates(context: CanvasRenderingContext2D): void;
  79340. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79341. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79342. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79343. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79344. protected _renderLines(context: CanvasRenderingContext2D): void;
  79345. /**
  79346. * Given a width constraint applied on the text block, find the expected height
  79347. * @returns expected height
  79348. */
  79349. computeExpectedHeight(): number;
  79350. dispose(): void;
  79351. }
  79352. }
  79353. declare module BABYLON.GUI {
  79354. /**
  79355. * Class used to create 2D images
  79356. */
  79357. export class Image extends Control {
  79358. name?: string | undefined;
  79359. private _workingCanvas;
  79360. private _domImage;
  79361. private _imageWidth;
  79362. private _imageHeight;
  79363. private _loaded;
  79364. private _stretch;
  79365. private _source;
  79366. private _autoScale;
  79367. private _sourceLeft;
  79368. private _sourceTop;
  79369. private _sourceWidth;
  79370. private _sourceHeight;
  79371. private _svgAttributesComputationCompleted;
  79372. private _isSVG;
  79373. private _cellWidth;
  79374. private _cellHeight;
  79375. private _cellId;
  79376. private _populateNinePatchSlicesFromImage;
  79377. private _sliceLeft;
  79378. private _sliceRight;
  79379. private _sliceTop;
  79380. private _sliceBottom;
  79381. private _detectPointerOnOpaqueOnly;
  79382. private _imageDataCache;
  79383. /**
  79384. * BABYLON.Observable notified when the content is loaded
  79385. */
  79386. onImageLoadedObservable: BABYLON.Observable<Image>;
  79387. /**
  79388. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79389. */
  79390. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79391. /**
  79392. * Gets a boolean indicating that the content is loaded
  79393. */
  79394. get isLoaded(): boolean;
  79395. /**
  79396. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79397. */
  79398. get populateNinePatchSlicesFromImage(): boolean;
  79399. set populateNinePatchSlicesFromImage(value: boolean);
  79400. /**
  79401. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79402. * Beware using this as this will comsume more memory as the image has to be stored twice
  79403. */
  79404. get detectPointerOnOpaqueOnly(): boolean;
  79405. set detectPointerOnOpaqueOnly(value: boolean);
  79406. /**
  79407. * Gets or sets the left value for slicing (9-patch)
  79408. */
  79409. get sliceLeft(): number;
  79410. set sliceLeft(value: number);
  79411. /**
  79412. * Gets or sets the right value for slicing (9-patch)
  79413. */
  79414. get sliceRight(): number;
  79415. set sliceRight(value: number);
  79416. /**
  79417. * Gets or sets the top value for slicing (9-patch)
  79418. */
  79419. get sliceTop(): number;
  79420. set sliceTop(value: number);
  79421. /**
  79422. * Gets or sets the bottom value for slicing (9-patch)
  79423. */
  79424. get sliceBottom(): number;
  79425. set sliceBottom(value: number);
  79426. /**
  79427. * Gets or sets the left coordinate in the source image
  79428. */
  79429. get sourceLeft(): number;
  79430. set sourceLeft(value: number);
  79431. /**
  79432. * Gets or sets the top coordinate in the source image
  79433. */
  79434. get sourceTop(): number;
  79435. set sourceTop(value: number);
  79436. /**
  79437. * Gets or sets the width to capture in the source image
  79438. */
  79439. get sourceWidth(): number;
  79440. set sourceWidth(value: number);
  79441. /**
  79442. * Gets or sets the height to capture in the source image
  79443. */
  79444. get sourceHeight(): number;
  79445. set sourceHeight(value: number);
  79446. /** Indicates if the format of the image is SVG */
  79447. get isSVG(): boolean;
  79448. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79449. get svgAttributesComputationCompleted(): boolean;
  79450. /**
  79451. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79452. * @see https://doc.babylonjs.com/how_to/gui#image
  79453. */
  79454. get autoScale(): boolean;
  79455. set autoScale(value: boolean);
  79456. /** Gets or sets the streching mode used by the image */
  79457. get stretch(): number;
  79458. set stretch(value: number);
  79459. /** @hidden */
  79460. _rotate90(n: number, preserveProperties?: boolean): Image;
  79461. private _handleRotationForSVGImage;
  79462. private _rotate90SourceProperties;
  79463. /**
  79464. * Gets or sets the internal DOM image used to render the control
  79465. */
  79466. set domImage(value: HTMLImageElement);
  79467. get domImage(): HTMLImageElement;
  79468. private _onImageLoaded;
  79469. private _extractNinePatchSliceDataFromImage;
  79470. /**
  79471. * Gets or sets image source url
  79472. */
  79473. set source(value: BABYLON.Nullable<string>);
  79474. /**
  79475. * Checks for svg document with icon id present
  79476. */
  79477. private _svgCheck;
  79478. /**
  79479. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79480. * given external svg file and icon id
  79481. */
  79482. private _getSVGAttribs;
  79483. /**
  79484. * Gets or sets the cell width to use when animation sheet is enabled
  79485. * @see https://doc.babylonjs.com/how_to/gui#image
  79486. */
  79487. get cellWidth(): number;
  79488. set cellWidth(value: number);
  79489. /**
  79490. * Gets or sets the cell height to use when animation sheet is enabled
  79491. * @see https://doc.babylonjs.com/how_to/gui#image
  79492. */
  79493. get cellHeight(): number;
  79494. set cellHeight(value: number);
  79495. /**
  79496. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79497. * @see https://doc.babylonjs.com/how_to/gui#image
  79498. */
  79499. get cellId(): number;
  79500. set cellId(value: number);
  79501. /**
  79502. * Creates a new Image
  79503. * @param name defines the control name
  79504. * @param url defines the image url
  79505. */
  79506. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79507. /**
  79508. * Tests if a given coordinates belong to the current control
  79509. * @param x defines x coordinate to test
  79510. * @param y defines y coordinate to test
  79511. * @returns true if the coordinates are inside the control
  79512. */
  79513. contains(x: number, y: number): boolean;
  79514. protected _getTypeName(): string;
  79515. /** Force the control to synchronize with its content */
  79516. synchronizeSizeWithContent(): void;
  79517. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79518. private _prepareWorkingCanvasForOpaqueDetection;
  79519. private _drawImage;
  79520. _draw(context: CanvasRenderingContext2D): void;
  79521. private _renderCornerPatch;
  79522. private _renderNinePatch;
  79523. dispose(): void;
  79524. /** STRETCH_NONE */
  79525. static readonly STRETCH_NONE: number;
  79526. /** STRETCH_FILL */
  79527. static readonly STRETCH_FILL: number;
  79528. /** STRETCH_UNIFORM */
  79529. static readonly STRETCH_UNIFORM: number;
  79530. /** STRETCH_EXTEND */
  79531. static readonly STRETCH_EXTEND: number;
  79532. /** NINE_PATCH */
  79533. static readonly STRETCH_NINE_PATCH: number;
  79534. }
  79535. }
  79536. declare module BABYLON.GUI {
  79537. /**
  79538. * Class used to create 2D buttons
  79539. */
  79540. export class Button extends Rectangle {
  79541. name?: string | undefined;
  79542. /**
  79543. * Function called to generate a pointer enter animation
  79544. */
  79545. pointerEnterAnimation: () => void;
  79546. /**
  79547. * Function called to generate a pointer out animation
  79548. */
  79549. pointerOutAnimation: () => void;
  79550. /**
  79551. * Function called to generate a pointer down animation
  79552. */
  79553. pointerDownAnimation: () => void;
  79554. /**
  79555. * Function called to generate a pointer up animation
  79556. */
  79557. pointerUpAnimation: () => void;
  79558. /**
  79559. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79560. */
  79561. delegatePickingToChildren: boolean;
  79562. private _image;
  79563. /**
  79564. * Returns the image part of the button (if any)
  79565. */
  79566. get image(): BABYLON.Nullable<Image>;
  79567. private _textBlock;
  79568. /**
  79569. * Returns the image part of the button (if any)
  79570. */
  79571. get textBlock(): BABYLON.Nullable<TextBlock>;
  79572. /**
  79573. * Creates a new Button
  79574. * @param name defines the name of the button
  79575. */
  79576. constructor(name?: string | undefined);
  79577. protected _getTypeName(): string;
  79578. /** @hidden */
  79579. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79580. /** @hidden */
  79581. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79582. /** @hidden */
  79583. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79584. /** @hidden */
  79585. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79586. /** @hidden */
  79587. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79588. /**
  79589. * Creates a new button made with an image and a text
  79590. * @param name defines the name of the button
  79591. * @param text defines the text of the button
  79592. * @param imageUrl defines the url of the image
  79593. * @returns a new Button
  79594. */
  79595. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79596. /**
  79597. * Creates a new button made with an image
  79598. * @param name defines the name of the button
  79599. * @param imageUrl defines the url of the image
  79600. * @returns a new Button
  79601. */
  79602. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79603. /**
  79604. * Creates a new button made with a text
  79605. * @param name defines the name of the button
  79606. * @param text defines the text of the button
  79607. * @returns a new Button
  79608. */
  79609. static CreateSimpleButton(name: string, text: string): Button;
  79610. /**
  79611. * Creates a new button made with an image and a centered text
  79612. * @param name defines the name of the button
  79613. * @param text defines the text of the button
  79614. * @param imageUrl defines the url of the image
  79615. * @returns a new Button
  79616. */
  79617. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79618. }
  79619. }
  79620. declare module BABYLON.GUI {
  79621. /**
  79622. * Class used to create a 2D stack panel container
  79623. */
  79624. export class StackPanel extends Container {
  79625. name?: string | undefined;
  79626. private _isVertical;
  79627. private _manualWidth;
  79628. private _manualHeight;
  79629. private _doNotTrackManualChanges;
  79630. /**
  79631. * Gets or sets a boolean indicating that layou warnings should be ignored
  79632. */
  79633. ignoreLayoutWarnings: boolean;
  79634. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79635. get isVertical(): boolean;
  79636. set isVertical(value: boolean);
  79637. /**
  79638. * Gets or sets panel width.
  79639. * This value should not be set when in horizontal mode as it will be computed automatically
  79640. */
  79641. set width(value: string | number);
  79642. get width(): string | number;
  79643. /**
  79644. * Gets or sets panel height.
  79645. * This value should not be set when in vertical mode as it will be computed automatically
  79646. */
  79647. set height(value: string | number);
  79648. get height(): string | number;
  79649. /**
  79650. * Creates a new StackPanel
  79651. * @param name defines control name
  79652. */
  79653. constructor(name?: string | undefined);
  79654. protected _getTypeName(): string;
  79655. /** @hidden */
  79656. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79657. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79658. protected _postMeasure(): void;
  79659. }
  79660. }
  79661. declare module BABYLON.GUI {
  79662. /**
  79663. * Class used to represent a 2D checkbox
  79664. */
  79665. export class Checkbox extends Control {
  79666. name?: string | undefined;
  79667. private _isChecked;
  79668. private _background;
  79669. private _checkSizeRatio;
  79670. private _thickness;
  79671. /** Gets or sets border thickness */
  79672. get thickness(): number;
  79673. set thickness(value: number);
  79674. /**
  79675. * BABYLON.Observable raised when isChecked property changes
  79676. */
  79677. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79678. /** Gets or sets a value indicating the ratio between overall size and check size */
  79679. get checkSizeRatio(): number;
  79680. set checkSizeRatio(value: number);
  79681. /** Gets or sets background color */
  79682. get background(): string;
  79683. set background(value: string);
  79684. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79685. get isChecked(): boolean;
  79686. set isChecked(value: boolean);
  79687. /**
  79688. * Creates a new CheckBox
  79689. * @param name defines the control name
  79690. */
  79691. constructor(name?: string | undefined);
  79692. protected _getTypeName(): string;
  79693. /** @hidden */
  79694. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79695. /** @hidden */
  79696. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79697. /**
  79698. * Utility function to easily create a checkbox with a header
  79699. * @param title defines the label to use for the header
  79700. * @param onValueChanged defines the callback to call when value changes
  79701. * @returns a StackPanel containing the checkbox and a textBlock
  79702. */
  79703. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79704. }
  79705. }
  79706. declare module BABYLON.GUI {
  79707. /**
  79708. * Class used to store key control properties
  79709. */
  79710. export class KeyPropertySet {
  79711. /** Width */
  79712. width?: string;
  79713. /** Height */
  79714. height?: string;
  79715. /** Left padding */
  79716. paddingLeft?: string;
  79717. /** Right padding */
  79718. paddingRight?: string;
  79719. /** Top padding */
  79720. paddingTop?: string;
  79721. /** Bottom padding */
  79722. paddingBottom?: string;
  79723. /** Foreground color */
  79724. color?: string;
  79725. /** Background color */
  79726. background?: string;
  79727. }
  79728. /**
  79729. * Class used to create virtual keyboard
  79730. */
  79731. export class VirtualKeyboard extends StackPanel {
  79732. /** BABYLON.Observable raised when a key is pressed */
  79733. onKeyPressObservable: BABYLON.Observable<string>;
  79734. /** Gets or sets default key button width */
  79735. defaultButtonWidth: string;
  79736. /** Gets or sets default key button height */
  79737. defaultButtonHeight: string;
  79738. /** Gets or sets default key button left padding */
  79739. defaultButtonPaddingLeft: string;
  79740. /** Gets or sets default key button right padding */
  79741. defaultButtonPaddingRight: string;
  79742. /** Gets or sets default key button top padding */
  79743. defaultButtonPaddingTop: string;
  79744. /** Gets or sets default key button bottom padding */
  79745. defaultButtonPaddingBottom: string;
  79746. /** Gets or sets default key button foreground color */
  79747. defaultButtonColor: string;
  79748. /** Gets or sets default key button background color */
  79749. defaultButtonBackground: string;
  79750. /** Gets or sets shift button foreground color */
  79751. shiftButtonColor: string;
  79752. /** Gets or sets shift button thickness*/
  79753. selectedShiftThickness: number;
  79754. /** Gets shift key state */
  79755. shiftState: number;
  79756. protected _getTypeName(): string;
  79757. private _createKey;
  79758. /**
  79759. * Adds a new row of keys
  79760. * @param keys defines the list of keys to add
  79761. * @param propertySets defines the associated property sets
  79762. */
  79763. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79764. /**
  79765. * Set the shift key to a specific state
  79766. * @param shiftState defines the new shift state
  79767. */
  79768. applyShiftState(shiftState: number): void;
  79769. private _currentlyConnectedInputText;
  79770. private _connectedInputTexts;
  79771. private _onKeyPressObserver;
  79772. /** Gets the input text control currently attached to the keyboard */
  79773. get connectedInputText(): BABYLON.Nullable<InputText>;
  79774. /**
  79775. * Connects the keyboard with an input text control
  79776. *
  79777. * @param input defines the target control
  79778. */
  79779. connect(input: InputText): void;
  79780. /**
  79781. * Disconnects the keyboard from connected InputText controls
  79782. *
  79783. * @param input optionally defines a target control, otherwise all are disconnected
  79784. */
  79785. disconnect(input?: InputText): void;
  79786. private _removeConnectedInputObservables;
  79787. /**
  79788. * Release all resources
  79789. */
  79790. dispose(): void;
  79791. /**
  79792. * Creates a new keyboard using a default layout
  79793. *
  79794. * @param name defines control name
  79795. * @returns a new VirtualKeyboard
  79796. */
  79797. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79798. }
  79799. }
  79800. declare module BABYLON.GUI {
  79801. /**
  79802. * Class used to create input text control
  79803. */
  79804. export class InputText extends Control implements IFocusableControl {
  79805. name?: string | undefined;
  79806. private _text;
  79807. private _placeholderText;
  79808. private _background;
  79809. private _focusedBackground;
  79810. private _focusedColor;
  79811. private _placeholderColor;
  79812. private _thickness;
  79813. private _margin;
  79814. private _autoStretchWidth;
  79815. private _maxWidth;
  79816. private _isFocused;
  79817. private _blinkTimeout;
  79818. private _blinkIsEven;
  79819. private _cursorOffset;
  79820. private _scrollLeft;
  79821. private _textWidth;
  79822. private _clickedCoordinate;
  79823. private _deadKey;
  79824. private _addKey;
  79825. private _currentKey;
  79826. private _isTextHighlightOn;
  79827. private _textHighlightColor;
  79828. private _highligherOpacity;
  79829. private _highlightedText;
  79830. private _startHighlightIndex;
  79831. private _endHighlightIndex;
  79832. private _cursorIndex;
  79833. private _onFocusSelectAll;
  79834. private _isPointerDown;
  79835. private _onClipboardObserver;
  79836. private _onPointerDblTapObserver;
  79837. /** @hidden */
  79838. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79839. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79840. promptMessage: string;
  79841. /** Force disable prompt on mobile device */
  79842. disableMobilePrompt: boolean;
  79843. /** BABYLON.Observable raised when the text changes */
  79844. onTextChangedObservable: BABYLON.Observable<InputText>;
  79845. /** BABYLON.Observable raised just before an entered character is to be added */
  79846. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79847. /** BABYLON.Observable raised when the control gets the focus */
  79848. onFocusObservable: BABYLON.Observable<InputText>;
  79849. /** BABYLON.Observable raised when the control loses the focus */
  79850. onBlurObservable: BABYLON.Observable<InputText>;
  79851. /**Observable raised when the text is highlighted */
  79852. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79853. /**Observable raised when copy event is triggered */
  79854. onTextCopyObservable: BABYLON.Observable<InputText>;
  79855. /** BABYLON.Observable raised when cut event is triggered */
  79856. onTextCutObservable: BABYLON.Observable<InputText>;
  79857. /** BABYLON.Observable raised when paste event is triggered */
  79858. onTextPasteObservable: BABYLON.Observable<InputText>;
  79859. /** BABYLON.Observable raised when a key event was processed */
  79860. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79861. /** Gets or sets the maximum width allowed by the control */
  79862. get maxWidth(): string | number;
  79863. /** Gets the maximum width allowed by the control in pixels */
  79864. get maxWidthInPixels(): number;
  79865. set maxWidth(value: string | number);
  79866. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79867. get highligherOpacity(): number;
  79868. set highligherOpacity(value: number);
  79869. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79870. get onFocusSelectAll(): boolean;
  79871. set onFocusSelectAll(value: boolean);
  79872. /** Gets or sets the text hightlight color */
  79873. get textHighlightColor(): string;
  79874. set textHighlightColor(value: string);
  79875. /** Gets or sets control margin */
  79876. get margin(): string;
  79877. /** Gets control margin in pixels */
  79878. get marginInPixels(): number;
  79879. set margin(value: string);
  79880. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79881. get autoStretchWidth(): boolean;
  79882. set autoStretchWidth(value: boolean);
  79883. /** Gets or sets border thickness */
  79884. get thickness(): number;
  79885. set thickness(value: number);
  79886. /** Gets or sets the background color when focused */
  79887. get focusedBackground(): string;
  79888. set focusedBackground(value: string);
  79889. /** Gets or sets the background color when focused */
  79890. get focusedColor(): string;
  79891. set focusedColor(value: string);
  79892. /** Gets or sets the background color */
  79893. get background(): string;
  79894. set background(value: string);
  79895. /** Gets or sets the placeholder color */
  79896. get placeholderColor(): string;
  79897. set placeholderColor(value: string);
  79898. /** Gets or sets the text displayed when the control is empty */
  79899. get placeholderText(): string;
  79900. set placeholderText(value: string);
  79901. /** Gets or sets the dead key flag */
  79902. get deadKey(): boolean;
  79903. set deadKey(flag: boolean);
  79904. /** Gets or sets the highlight text */
  79905. get highlightedText(): string;
  79906. set highlightedText(text: string);
  79907. /** Gets or sets if the current key should be added */
  79908. get addKey(): boolean;
  79909. set addKey(flag: boolean);
  79910. /** Gets or sets the value of the current key being entered */
  79911. get currentKey(): string;
  79912. set currentKey(key: string);
  79913. /** Gets or sets the text displayed in the control */
  79914. get text(): string;
  79915. set text(value: string);
  79916. /** Gets or sets control width */
  79917. get width(): string | number;
  79918. set width(value: string | number);
  79919. /**
  79920. * Creates a new InputText
  79921. * @param name defines the control name
  79922. * @param text defines the text of the control
  79923. */
  79924. constructor(name?: string | undefined, text?: string);
  79925. /** @hidden */
  79926. onBlur(): void;
  79927. /** @hidden */
  79928. onFocus(): void;
  79929. protected _getTypeName(): string;
  79930. /**
  79931. * Function called to get the list of controls that should not steal the focus from this control
  79932. * @returns an array of controls
  79933. */
  79934. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79935. /** @hidden */
  79936. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79937. /** @hidden */
  79938. private _updateValueFromCursorIndex;
  79939. /** @hidden */
  79940. private _processDblClick;
  79941. /** @hidden */
  79942. private _selectAllText;
  79943. /**
  79944. * Handles the keyboard event
  79945. * @param evt Defines the KeyboardEvent
  79946. */
  79947. processKeyboard(evt: KeyboardEvent): void;
  79948. /** @hidden */
  79949. private _onCopyText;
  79950. /** @hidden */
  79951. private _onCutText;
  79952. /** @hidden */
  79953. private _onPasteText;
  79954. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79955. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79956. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79957. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79958. protected _beforeRenderText(text: string): string;
  79959. dispose(): void;
  79960. }
  79961. }
  79962. declare module BABYLON.GUI {
  79963. /**
  79964. * Class used to create a 2D grid container
  79965. */
  79966. export class Grid extends Container {
  79967. name?: string | undefined;
  79968. private _rowDefinitions;
  79969. private _columnDefinitions;
  79970. private _cells;
  79971. private _childControls;
  79972. /**
  79973. * Gets the number of columns
  79974. */
  79975. get columnCount(): number;
  79976. /**
  79977. * Gets the number of rows
  79978. */
  79979. get rowCount(): number;
  79980. /** Gets the list of children */
  79981. get children(): Control[];
  79982. /** Gets the list of cells (e.g. the containers) */
  79983. get cells(): {
  79984. [key: string]: Container;
  79985. };
  79986. /**
  79987. * Gets the definition of a specific row
  79988. * @param index defines the index of the row
  79989. * @returns the row definition
  79990. */
  79991. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79992. /**
  79993. * Gets the definition of a specific column
  79994. * @param index defines the index of the column
  79995. * @returns the column definition
  79996. */
  79997. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79998. /**
  79999. * Adds a new row to the grid
  80000. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80001. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  80002. * @returns the current grid
  80003. */
  80004. addRowDefinition(height: number, isPixel?: boolean): Grid;
  80005. /**
  80006. * Adds a new column to the grid
  80007. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80008. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80009. * @returns the current grid
  80010. */
  80011. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  80012. /**
  80013. * Update a row definition
  80014. * @param index defines the index of the row to update
  80015. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80016. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  80017. * @returns the current grid
  80018. */
  80019. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  80020. /**
  80021. * Update a column definition
  80022. * @param index defines the index of the column to update
  80023. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80024. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80025. * @returns the current grid
  80026. */
  80027. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  80028. /**
  80029. * Gets the list of children stored in a specific cell
  80030. * @param row defines the row to check
  80031. * @param column defines the column to check
  80032. * @returns the list of controls
  80033. */
  80034. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  80035. /**
  80036. * Gets a string representing the child cell info (row x column)
  80037. * @param child defines the control to get info from
  80038. * @returns a string containing the child cell info (row x column)
  80039. */
  80040. getChildCellInfo(child: Control): string;
  80041. private _removeCell;
  80042. private _offsetCell;
  80043. /**
  80044. * Remove a column definition at specified index
  80045. * @param index defines the index of the column to remove
  80046. * @returns the current grid
  80047. */
  80048. removeColumnDefinition(index: number): Grid;
  80049. /**
  80050. * Remove a row definition at specified index
  80051. * @param index defines the index of the row to remove
  80052. * @returns the current grid
  80053. */
  80054. removeRowDefinition(index: number): Grid;
  80055. /**
  80056. * Adds a new control to the current grid
  80057. * @param control defines the control to add
  80058. * @param row defines the row where to add the control (0 by default)
  80059. * @param column defines the column where to add the control (0 by default)
  80060. * @returns the current grid
  80061. */
  80062. addControl(control: Control, row?: number, column?: number): Grid;
  80063. /**
  80064. * Removes a control from the current container
  80065. * @param control defines the control to remove
  80066. * @returns the current container
  80067. */
  80068. removeControl(control: Control): Container;
  80069. /**
  80070. * Creates a new Grid
  80071. * @param name defines control name
  80072. */
  80073. constructor(name?: string | undefined);
  80074. protected _getTypeName(): string;
  80075. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  80076. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80077. _flagDescendantsAsMatrixDirty(): void;
  80078. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80079. /** Releases associated resources */
  80080. dispose(): void;
  80081. }
  80082. }
  80083. declare module BABYLON.GUI {
  80084. /** Class used to create color pickers */
  80085. export class ColorPicker extends Control {
  80086. name?: string | undefined;
  80087. private static _Epsilon;
  80088. private _colorWheelCanvas;
  80089. private _value;
  80090. private _tmpColor;
  80091. private _pointerStartedOnSquare;
  80092. private _pointerStartedOnWheel;
  80093. private _squareLeft;
  80094. private _squareTop;
  80095. private _squareSize;
  80096. private _h;
  80097. private _s;
  80098. private _v;
  80099. private _lastPointerDownID;
  80100. /**
  80101. * BABYLON.Observable raised when the value changes
  80102. */
  80103. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  80104. /** Gets or sets the color of the color picker */
  80105. get value(): BABYLON.Color3;
  80106. set value(value: BABYLON.Color3);
  80107. /**
  80108. * Gets or sets control width
  80109. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80110. */
  80111. get width(): string | number;
  80112. set width(value: string | number);
  80113. /**
  80114. * Gets or sets control height
  80115. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80116. */
  80117. get height(): string | number;
  80118. /** Gets or sets control height */
  80119. set height(value: string | number);
  80120. /** Gets or sets control size */
  80121. get size(): string | number;
  80122. set size(value: string | number);
  80123. /**
  80124. * Creates a new ColorPicker
  80125. * @param name defines the control name
  80126. */
  80127. constructor(name?: string | undefined);
  80128. protected _getTypeName(): string;
  80129. /** @hidden */
  80130. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80131. private _updateSquareProps;
  80132. private _drawGradientSquare;
  80133. private _drawCircle;
  80134. private _createColorWheelCanvas;
  80135. /** @hidden */
  80136. _draw(context: CanvasRenderingContext2D): void;
  80137. private _pointerIsDown;
  80138. private _updateValueFromPointer;
  80139. private _isPointOnSquare;
  80140. private _isPointOnWheel;
  80141. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80142. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80143. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  80144. _onCanvasBlur(): void;
  80145. /**
  80146. * This function expands the color picker by creating a color picker dialog with manual
  80147. * color value input and the ability to save colors into an array to be used later in
  80148. * subsequent launches of the dialogue.
  80149. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  80150. * @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.
  80151. * @returns picked color as a hex string and the saved colors array as hex strings.
  80152. */
  80153. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  80154. pickerWidth?: string;
  80155. pickerHeight?: string;
  80156. headerHeight?: string;
  80157. lastColor?: string;
  80158. swatchLimit?: number;
  80159. numSwatchesPerLine?: number;
  80160. savedColors?: Array<string>;
  80161. }): Promise<{
  80162. savedColors?: string[];
  80163. pickedColor: string;
  80164. }>;
  80165. }
  80166. }
  80167. declare module BABYLON.GUI {
  80168. /** Class used to create 2D ellipse containers */
  80169. export class Ellipse extends Container {
  80170. name?: string | undefined;
  80171. private _thickness;
  80172. /** Gets or sets border thickness */
  80173. get thickness(): number;
  80174. set thickness(value: number);
  80175. /**
  80176. * Creates a new Ellipse
  80177. * @param name defines the control name
  80178. */
  80179. constructor(name?: string | undefined);
  80180. protected _getTypeName(): string;
  80181. protected _localDraw(context: CanvasRenderingContext2D): void;
  80182. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80183. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  80184. }
  80185. }
  80186. declare module BABYLON.GUI {
  80187. /**
  80188. * Class used to create a password control
  80189. */
  80190. export class InputPassword extends InputText {
  80191. protected _beforeRenderText(text: string): string;
  80192. }
  80193. }
  80194. declare module BABYLON.GUI {
  80195. /** Class used to render 2D lines */
  80196. export class Line extends Control {
  80197. name?: string | undefined;
  80198. private _lineWidth;
  80199. private _x1;
  80200. private _y1;
  80201. private _x2;
  80202. private _y2;
  80203. private _dash;
  80204. private _connectedControl;
  80205. private _connectedControlDirtyObserver;
  80206. /** Gets or sets the dash pattern */
  80207. get dash(): Array<number>;
  80208. set dash(value: Array<number>);
  80209. /** Gets or sets the control connected with the line end */
  80210. get connectedControl(): Control;
  80211. set connectedControl(value: Control);
  80212. /** Gets or sets start coordinates on X axis */
  80213. get x1(): string | number;
  80214. set x1(value: string | number);
  80215. /** Gets or sets start coordinates on Y axis */
  80216. get y1(): string | number;
  80217. set y1(value: string | number);
  80218. /** Gets or sets end coordinates on X axis */
  80219. get x2(): string | number;
  80220. set x2(value: string | number);
  80221. /** Gets or sets end coordinates on Y axis */
  80222. get y2(): string | number;
  80223. set y2(value: string | number);
  80224. /** Gets or sets line width */
  80225. get lineWidth(): number;
  80226. set lineWidth(value: number);
  80227. /** Gets or sets horizontal alignment */
  80228. set horizontalAlignment(value: number);
  80229. /** Gets or sets vertical alignment */
  80230. set verticalAlignment(value: number);
  80231. private get _effectiveX2();
  80232. private get _effectiveY2();
  80233. /**
  80234. * Creates a new Line
  80235. * @param name defines the control name
  80236. */
  80237. constructor(name?: string | undefined);
  80238. protected _getTypeName(): string;
  80239. _draw(context: CanvasRenderingContext2D): void;
  80240. _measure(): void;
  80241. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80242. /**
  80243. * Move one end of the line given 3D cartesian coordinates.
  80244. * @param position Targeted world position
  80245. * @param scene BABYLON.Scene
  80246. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80247. */
  80248. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  80249. /**
  80250. * Move one end of the line to a position in screen absolute space.
  80251. * @param projectedPosition Position in screen absolute space (X, Y)
  80252. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80253. */
  80254. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  80255. }
  80256. }
  80257. declare module BABYLON.GUI {
  80258. /**
  80259. * Class used to store a point for a MultiLine object.
  80260. * The point can be pure 2D coordinates, a mesh or a control
  80261. */
  80262. export class MultiLinePoint {
  80263. private _multiLine;
  80264. private _x;
  80265. private _y;
  80266. private _control;
  80267. private _mesh;
  80268. private _controlObserver;
  80269. private _meshObserver;
  80270. /** @hidden */
  80271. _point: BABYLON.Vector3;
  80272. /**
  80273. * Creates a new MultiLinePoint
  80274. * @param multiLine defines the source MultiLine object
  80275. */
  80276. constructor(multiLine: MultiLine);
  80277. /** Gets or sets x coordinate */
  80278. get x(): string | number;
  80279. set x(value: string | number);
  80280. /** Gets or sets y coordinate */
  80281. get y(): string | number;
  80282. set y(value: string | number);
  80283. /** Gets or sets the control associated with this point */
  80284. get control(): BABYLON.Nullable<Control>;
  80285. set control(value: BABYLON.Nullable<Control>);
  80286. /** Gets or sets the mesh associated with this point */
  80287. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80288. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80289. /** Resets links */
  80290. resetLinks(): void;
  80291. /**
  80292. * Gets a translation vector with Z component
  80293. * @returns the translation vector
  80294. */
  80295. translate(): BABYLON.Vector3;
  80296. private _translatePoint;
  80297. /** Release associated resources */
  80298. dispose(): void;
  80299. }
  80300. }
  80301. declare module BABYLON.GUI {
  80302. /**
  80303. * Class used to create multi line control
  80304. */
  80305. export class MultiLine extends Control {
  80306. name?: string | undefined;
  80307. private _lineWidth;
  80308. private _dash;
  80309. private _points;
  80310. private _minX;
  80311. private _minY;
  80312. private _maxX;
  80313. private _maxY;
  80314. /**
  80315. * Creates a new MultiLine
  80316. * @param name defines the control name
  80317. */
  80318. constructor(name?: string | undefined);
  80319. /** Gets or sets dash pattern */
  80320. get dash(): Array<number>;
  80321. set dash(value: Array<number>);
  80322. /**
  80323. * Gets point stored at specified index
  80324. * @param index defines the index to look for
  80325. * @returns the requested point if found
  80326. */
  80327. getAt(index: number): MultiLinePoint;
  80328. /** Function called when a point is updated */
  80329. onPointUpdate: () => void;
  80330. /**
  80331. * Adds new points to the point collection
  80332. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80333. * @returns the list of created MultiLinePoint
  80334. */
  80335. add(...items: (AbstractMesh | Control | {
  80336. x: string | number;
  80337. y: string | number;
  80338. })[]): MultiLinePoint[];
  80339. /**
  80340. * Adds a new point to the point collection
  80341. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80342. * @returns the created MultiLinePoint
  80343. */
  80344. push(item?: (AbstractMesh | Control | {
  80345. x: string | number;
  80346. y: string | number;
  80347. })): MultiLinePoint;
  80348. /**
  80349. * Remove a specific value or point from the active point collection
  80350. * @param value defines the value or point to remove
  80351. */
  80352. remove(value: number | MultiLinePoint): void;
  80353. /**
  80354. * Resets this object to initial state (no point)
  80355. */
  80356. reset(): void;
  80357. /**
  80358. * Resets all links
  80359. */
  80360. resetLinks(): void;
  80361. /** Gets or sets line width */
  80362. get lineWidth(): number;
  80363. set lineWidth(value: number);
  80364. set horizontalAlignment(value: number);
  80365. set verticalAlignment(value: number);
  80366. protected _getTypeName(): string;
  80367. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80368. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80369. _measure(): void;
  80370. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80371. dispose(): void;
  80372. }
  80373. }
  80374. declare module BABYLON.GUI {
  80375. /**
  80376. * Class used to create radio button controls
  80377. */
  80378. export class RadioButton extends Control {
  80379. name?: string | undefined;
  80380. private _isChecked;
  80381. private _background;
  80382. private _checkSizeRatio;
  80383. private _thickness;
  80384. /** Gets or sets border thickness */
  80385. get thickness(): number;
  80386. set thickness(value: number);
  80387. /** Gets or sets group name */
  80388. group: string;
  80389. /** BABYLON.Observable raised when isChecked is changed */
  80390. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80391. /** Gets or sets a value indicating the ratio between overall size and check size */
  80392. get checkSizeRatio(): number;
  80393. set checkSizeRatio(value: number);
  80394. /** Gets or sets background color */
  80395. get background(): string;
  80396. set background(value: string);
  80397. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80398. get isChecked(): boolean;
  80399. set isChecked(value: boolean);
  80400. /**
  80401. * Creates a new RadioButton
  80402. * @param name defines the control name
  80403. */
  80404. constructor(name?: string | undefined);
  80405. protected _getTypeName(): string;
  80406. _draw(context: CanvasRenderingContext2D): void;
  80407. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80408. /**
  80409. * Utility function to easily create a radio button with a header
  80410. * @param title defines the label to use for the header
  80411. * @param group defines the group to use for the radio button
  80412. * @param isChecked defines the initial state of the radio button
  80413. * @param onValueChanged defines the callback to call when value changes
  80414. * @returns a StackPanel containing the radio button and a textBlock
  80415. */
  80416. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80417. }
  80418. }
  80419. declare module BABYLON.GUI {
  80420. /**
  80421. * Class used to create slider controls
  80422. */
  80423. export class BaseSlider extends Control {
  80424. name?: string | undefined;
  80425. protected _thumbWidth: ValueAndUnit;
  80426. private _minimum;
  80427. private _maximum;
  80428. private _value;
  80429. private _isVertical;
  80430. protected _barOffset: ValueAndUnit;
  80431. private _isThumbClamped;
  80432. protected _displayThumb: boolean;
  80433. private _step;
  80434. private _lastPointerDownID;
  80435. protected _effectiveBarOffset: number;
  80436. protected _renderLeft: number;
  80437. protected _renderTop: number;
  80438. protected _renderWidth: number;
  80439. protected _renderHeight: number;
  80440. protected _backgroundBoxLength: number;
  80441. protected _backgroundBoxThickness: number;
  80442. protected _effectiveThumbThickness: number;
  80443. /** BABYLON.Observable raised when the sldier value changes */
  80444. onValueChangedObservable: BABYLON.Observable<number>;
  80445. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80446. get displayThumb(): boolean;
  80447. set displayThumb(value: boolean);
  80448. /** Gets or sets a step to apply to values (0 by default) */
  80449. get step(): number;
  80450. set step(value: number);
  80451. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80452. get barOffset(): string | number;
  80453. /** Gets main bar offset in pixels*/
  80454. get barOffsetInPixels(): number;
  80455. set barOffset(value: string | number);
  80456. /** Gets or sets thumb width */
  80457. get thumbWidth(): string | number;
  80458. /** Gets thumb width in pixels */
  80459. get thumbWidthInPixels(): number;
  80460. set thumbWidth(value: string | number);
  80461. /** Gets or sets minimum value */
  80462. get minimum(): number;
  80463. set minimum(value: number);
  80464. /** Gets or sets maximum value */
  80465. get maximum(): number;
  80466. set maximum(value: number);
  80467. /** Gets or sets current value */
  80468. get value(): number;
  80469. set value(value: number);
  80470. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80471. get isVertical(): boolean;
  80472. set isVertical(value: boolean);
  80473. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80474. get isThumbClamped(): boolean;
  80475. set isThumbClamped(value: boolean);
  80476. /**
  80477. * Creates a new BaseSlider
  80478. * @param name defines the control name
  80479. */
  80480. constructor(name?: string | undefined);
  80481. protected _getTypeName(): string;
  80482. protected _getThumbPosition(): number;
  80483. protected _getThumbThickness(type: string): number;
  80484. protected _prepareRenderingData(type: string): void;
  80485. private _pointerIsDown;
  80486. /** @hidden */
  80487. protected _updateValueFromPointer(x: number, y: number): void;
  80488. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80489. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80490. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80491. _onCanvasBlur(): void;
  80492. }
  80493. }
  80494. declare module BABYLON.GUI {
  80495. /**
  80496. * Class used to create slider controls
  80497. */
  80498. export class Slider extends BaseSlider {
  80499. name?: string | undefined;
  80500. private _background;
  80501. private _borderColor;
  80502. private _thumbColor;
  80503. private _isThumbCircle;
  80504. protected _displayValueBar: boolean;
  80505. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80506. get displayValueBar(): boolean;
  80507. set displayValueBar(value: boolean);
  80508. /** Gets or sets border color */
  80509. get borderColor(): string;
  80510. set borderColor(value: string);
  80511. /** Gets or sets background color */
  80512. get background(): string;
  80513. set background(value: string);
  80514. /** Gets or sets thumb's color */
  80515. get thumbColor(): string;
  80516. set thumbColor(value: string);
  80517. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80518. get isThumbCircle(): boolean;
  80519. set isThumbCircle(value: boolean);
  80520. /**
  80521. * Creates a new Slider
  80522. * @param name defines the control name
  80523. */
  80524. constructor(name?: string | undefined);
  80525. protected _getTypeName(): string;
  80526. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80527. }
  80528. }
  80529. declare module BABYLON.GUI {
  80530. /** Class used to create a RadioGroup
  80531. * which contains groups of radio buttons
  80532. */
  80533. export class SelectorGroup {
  80534. /** name of SelectorGroup */
  80535. name: string;
  80536. private _groupPanel;
  80537. private _selectors;
  80538. private _groupHeader;
  80539. /**
  80540. * Creates a new SelectorGroup
  80541. * @param name of group, used as a group heading
  80542. */
  80543. constructor(
  80544. /** name of SelectorGroup */
  80545. name: string);
  80546. /** Gets the groupPanel of the SelectorGroup */
  80547. get groupPanel(): StackPanel;
  80548. /** Gets the selectors array */
  80549. get selectors(): StackPanel[];
  80550. /** Gets and sets the group header */
  80551. get header(): string;
  80552. set header(label: string);
  80553. /** @hidden */
  80554. private _addGroupHeader;
  80555. /** @hidden*/
  80556. _getSelector(selectorNb: number): StackPanel | undefined;
  80557. /** Removes the selector at the given position
  80558. * @param selectorNb the position of the selector within the group
  80559. */
  80560. removeSelector(selectorNb: number): void;
  80561. }
  80562. /** Class used to create a CheckboxGroup
  80563. * which contains groups of checkbox buttons
  80564. */
  80565. export class CheckboxGroup extends SelectorGroup {
  80566. /** Adds a checkbox as a control
  80567. * @param text is the label for the selector
  80568. * @param func is the function called when the Selector is checked
  80569. * @param checked is true when Selector is checked
  80570. */
  80571. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80572. /** @hidden */
  80573. _setSelectorLabel(selectorNb: number, label: string): void;
  80574. /** @hidden */
  80575. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80576. /** @hidden */
  80577. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80578. /** @hidden */
  80579. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80580. }
  80581. /** Class used to create a RadioGroup
  80582. * which contains groups of radio buttons
  80583. */
  80584. export class RadioGroup extends SelectorGroup {
  80585. private _selectNb;
  80586. /** Adds a radio button as a control
  80587. * @param label is the label for the selector
  80588. * @param func is the function called when the Selector is checked
  80589. * @param checked is true when Selector is checked
  80590. */
  80591. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80592. /** @hidden */
  80593. _setSelectorLabel(selectorNb: number, label: string): void;
  80594. /** @hidden */
  80595. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80596. /** @hidden */
  80597. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80598. /** @hidden */
  80599. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80600. }
  80601. /** Class used to create a SliderGroup
  80602. * which contains groups of slider buttons
  80603. */
  80604. export class SliderGroup extends SelectorGroup {
  80605. /**
  80606. * Adds a slider to the SelectorGroup
  80607. * @param label is the label for the SliderBar
  80608. * @param func is the function called when the Slider moves
  80609. * @param unit is a string describing the units used, eg degrees or metres
  80610. * @param min is the minimum value for the Slider
  80611. * @param max is the maximum value for the Slider
  80612. * @param value is the start value for the Slider between min and max
  80613. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80614. */
  80615. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80616. /** @hidden */
  80617. _setSelectorLabel(selectorNb: number, label: string): void;
  80618. /** @hidden */
  80619. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80620. /** @hidden */
  80621. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80622. /** @hidden */
  80623. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80624. }
  80625. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80626. * @see https://doc.babylonjs.com/how_to/selector
  80627. */
  80628. export class SelectionPanel extends Rectangle {
  80629. /** name of SelectionPanel */
  80630. name: string;
  80631. /** an array of SelectionGroups */
  80632. groups: SelectorGroup[];
  80633. private _panel;
  80634. private _buttonColor;
  80635. private _buttonBackground;
  80636. private _headerColor;
  80637. private _barColor;
  80638. private _barHeight;
  80639. private _spacerHeight;
  80640. private _labelColor;
  80641. private _groups;
  80642. private _bars;
  80643. /**
  80644. * Creates a new SelectionPanel
  80645. * @param name of SelectionPanel
  80646. * @param groups is an array of SelectionGroups
  80647. */
  80648. constructor(
  80649. /** name of SelectionPanel */
  80650. name: string,
  80651. /** an array of SelectionGroups */
  80652. groups?: SelectorGroup[]);
  80653. protected _getTypeName(): string;
  80654. /** Gets the (stack) panel of the SelectionPanel */
  80655. get panel(): StackPanel;
  80656. /** Gets or sets the headerColor */
  80657. get headerColor(): string;
  80658. set headerColor(color: string);
  80659. private _setHeaderColor;
  80660. /** Gets or sets the button color */
  80661. get buttonColor(): string;
  80662. set buttonColor(color: string);
  80663. private _setbuttonColor;
  80664. /** Gets or sets the label color */
  80665. get labelColor(): string;
  80666. set labelColor(color: string);
  80667. private _setLabelColor;
  80668. /** Gets or sets the button background */
  80669. get buttonBackground(): string;
  80670. set buttonBackground(color: string);
  80671. private _setButtonBackground;
  80672. /** Gets or sets the color of separator bar */
  80673. get barColor(): string;
  80674. set barColor(color: string);
  80675. private _setBarColor;
  80676. /** Gets or sets the height of separator bar */
  80677. get barHeight(): string;
  80678. set barHeight(value: string);
  80679. private _setBarHeight;
  80680. /** Gets or sets the height of spacers*/
  80681. get spacerHeight(): string;
  80682. set spacerHeight(value: string);
  80683. private _setSpacerHeight;
  80684. /** Adds a bar between groups */
  80685. private _addSpacer;
  80686. /** Add a group to the selection panel
  80687. * @param group is the selector group to add
  80688. */
  80689. addGroup(group: SelectorGroup): void;
  80690. /** Remove the group from the given position
  80691. * @param groupNb is the position of the group in the list
  80692. */
  80693. removeGroup(groupNb: number): void;
  80694. /** Change a group header label
  80695. * @param label is the new group header label
  80696. * @param groupNb is the number of the group to relabel
  80697. * */
  80698. setHeaderName(label: string, groupNb: number): void;
  80699. /** Change selector label to the one given
  80700. * @param label is the new selector label
  80701. * @param groupNb is the number of the groupcontaining the selector
  80702. * @param selectorNb is the number of the selector within a group to relabel
  80703. * */
  80704. relabel(label: string, groupNb: number, selectorNb: number): void;
  80705. /** For a given group position remove the selector at the given position
  80706. * @param groupNb is the number of the group to remove the selector from
  80707. * @param selectorNb is the number of the selector within the group
  80708. */
  80709. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80710. /** For a given group position of correct type add a checkbox button
  80711. * @param groupNb is the number of the group to remove the selector from
  80712. * @param label is the label for the selector
  80713. * @param func is the function called when the Selector is checked
  80714. * @param checked is true when Selector is checked
  80715. */
  80716. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80717. /** For a given group position of correct type add a radio button
  80718. * @param groupNb is the number of the group to remove the selector from
  80719. * @param label is the label for the selector
  80720. * @param func is the function called when the Selector is checked
  80721. * @param checked is true when Selector is checked
  80722. */
  80723. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80724. /**
  80725. * For a given slider group add a slider
  80726. * @param groupNb is the number of the group to add the slider to
  80727. * @param label is the label for the Slider
  80728. * @param func is the function called when the Slider moves
  80729. * @param unit is a string describing the units used, eg degrees or metres
  80730. * @param min is the minimum value for the Slider
  80731. * @param max is the maximum value for the Slider
  80732. * @param value is the start value for the Slider between min and max
  80733. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80734. */
  80735. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80736. }
  80737. }
  80738. declare module BABYLON.GUI {
  80739. /**
  80740. * Class used to hold a the container for ScrollViewer
  80741. * @hidden
  80742. */
  80743. export class _ScrollViewerWindow extends Container {
  80744. parentClientWidth: number;
  80745. parentClientHeight: number;
  80746. private _freezeControls;
  80747. private _parentMeasure;
  80748. private _oldLeft;
  80749. private _oldTop;
  80750. get freezeControls(): boolean;
  80751. set freezeControls(value: boolean);
  80752. private _bucketWidth;
  80753. private _bucketHeight;
  80754. private _buckets;
  80755. private _bucketLen;
  80756. get bucketWidth(): number;
  80757. get bucketHeight(): number;
  80758. setBucketSizes(width: number, height: number): void;
  80759. private _useBuckets;
  80760. private _makeBuckets;
  80761. private _dispatchInBuckets;
  80762. private _updateMeasures;
  80763. private _updateChildrenMeasures;
  80764. private _restoreMeasures;
  80765. /**
  80766. * Creates a new ScrollViewerWindow
  80767. * @param name of ScrollViewerWindow
  80768. */
  80769. constructor(name?: string);
  80770. protected _getTypeName(): string;
  80771. /** @hidden */
  80772. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80773. /** @hidden */
  80774. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80775. private _scrollChildren;
  80776. private _scrollChildrenWithBuckets;
  80777. /** @hidden */
  80778. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80779. protected _postMeasure(): void;
  80780. }
  80781. }
  80782. declare module BABYLON.GUI {
  80783. /**
  80784. * Class used to create slider controls
  80785. */
  80786. export class ScrollBar extends BaseSlider {
  80787. name?: string | undefined;
  80788. private _background;
  80789. private _borderColor;
  80790. private _tempMeasure;
  80791. /** Gets or sets border color */
  80792. get borderColor(): string;
  80793. set borderColor(value: string);
  80794. /** Gets or sets background color */
  80795. get background(): string;
  80796. set background(value: string);
  80797. /**
  80798. * Creates a new Slider
  80799. * @param name defines the control name
  80800. */
  80801. constructor(name?: string | undefined);
  80802. protected _getTypeName(): string;
  80803. protected _getThumbThickness(): number;
  80804. _draw(context: CanvasRenderingContext2D): void;
  80805. private _first;
  80806. private _originX;
  80807. private _originY;
  80808. /** @hidden */
  80809. protected _updateValueFromPointer(x: number, y: number): void;
  80810. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80811. }
  80812. }
  80813. declare module BABYLON.GUI {
  80814. /**
  80815. * Class used to create slider controls
  80816. */
  80817. export class ImageScrollBar extends BaseSlider {
  80818. name?: string | undefined;
  80819. private _backgroundBaseImage;
  80820. private _backgroundImage;
  80821. private _thumbImage;
  80822. private _thumbBaseImage;
  80823. private _thumbLength;
  80824. private _thumbHeight;
  80825. private _barImageHeight;
  80826. private _tempMeasure;
  80827. /** Number of 90° rotation to apply on the images when in vertical mode */
  80828. num90RotationInVerticalMode: number;
  80829. /**
  80830. * Gets or sets the image used to render the background for horizontal bar
  80831. */
  80832. get backgroundImage(): Image;
  80833. set backgroundImage(value: Image);
  80834. /**
  80835. * Gets or sets the image used to render the thumb
  80836. */
  80837. get thumbImage(): Image;
  80838. set thumbImage(value: Image);
  80839. /**
  80840. * Gets or sets the length of the thumb
  80841. */
  80842. get thumbLength(): number;
  80843. set thumbLength(value: number);
  80844. /**
  80845. * Gets or sets the height of the thumb
  80846. */
  80847. get thumbHeight(): number;
  80848. set thumbHeight(value: number);
  80849. /**
  80850. * Gets or sets the height of the bar image
  80851. */
  80852. get barImageHeight(): number;
  80853. set barImageHeight(value: number);
  80854. /**
  80855. * Creates a new ImageScrollBar
  80856. * @param name defines the control name
  80857. */
  80858. constructor(name?: string | undefined);
  80859. protected _getTypeName(): string;
  80860. protected _getThumbThickness(): number;
  80861. _draw(context: CanvasRenderingContext2D): void;
  80862. private _first;
  80863. private _originX;
  80864. private _originY;
  80865. /** @hidden */
  80866. protected _updateValueFromPointer(x: number, y: number): void;
  80867. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80868. }
  80869. }
  80870. declare module BABYLON.GUI {
  80871. /**
  80872. * Class used to hold a viewer window and sliders in a grid
  80873. */
  80874. export class ScrollViewer extends Rectangle {
  80875. private _grid;
  80876. private _horizontalBarSpace;
  80877. private _verticalBarSpace;
  80878. private _dragSpace;
  80879. private _horizontalBar;
  80880. private _verticalBar;
  80881. private _barColor;
  80882. private _barBackground;
  80883. private _barImage;
  80884. private _horizontalBarImage;
  80885. private _verticalBarImage;
  80886. private _barBackgroundImage;
  80887. private _horizontalBarBackgroundImage;
  80888. private _verticalBarBackgroundImage;
  80889. private _barSize;
  80890. private _window;
  80891. private _pointerIsOver;
  80892. private _wheelPrecision;
  80893. private _onWheelObserver;
  80894. private _clientWidth;
  80895. private _clientHeight;
  80896. private _useImageBar;
  80897. private _thumbLength;
  80898. private _thumbHeight;
  80899. private _barImageHeight;
  80900. private _horizontalBarImageHeight;
  80901. private _verticalBarImageHeight;
  80902. private _oldWindowContentsWidth;
  80903. private _oldWindowContentsHeight;
  80904. /**
  80905. * Gets the horizontal scrollbar
  80906. */
  80907. get horizontalBar(): ScrollBar | ImageScrollBar;
  80908. /**
  80909. * Gets the vertical scrollbar
  80910. */
  80911. get verticalBar(): ScrollBar | ImageScrollBar;
  80912. /**
  80913. * Adds a new control to the current container
  80914. * @param control defines the control to add
  80915. * @returns the current container
  80916. */
  80917. addControl(control: BABYLON.Nullable<Control>): Container;
  80918. /**
  80919. * Removes a control from the current container
  80920. * @param control defines the control to remove
  80921. * @returns the current container
  80922. */
  80923. removeControl(control: Control): Container;
  80924. /** Gets the list of children */
  80925. get children(): Control[];
  80926. _flagDescendantsAsMatrixDirty(): void;
  80927. /**
  80928. * Freezes or unfreezes the controls in the window.
  80929. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80930. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80931. */
  80932. get freezeControls(): boolean;
  80933. set freezeControls(value: boolean);
  80934. /** Gets the bucket width */
  80935. get bucketWidth(): number;
  80936. /** Gets the bucket height */
  80937. get bucketHeight(): number;
  80938. /**
  80939. * Sets the bucket sizes.
  80940. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80941. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80942. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80943. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80944. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80945. * used), that's why it is not enabled by default.
  80946. * @param width width of the bucket
  80947. * @param height height of the bucket
  80948. */
  80949. setBucketSizes(width: number, height: number): void;
  80950. private _forceHorizontalBar;
  80951. private _forceVerticalBar;
  80952. /**
  80953. * Forces the horizontal scroll bar to be displayed
  80954. */
  80955. get forceHorizontalBar(): boolean;
  80956. set forceHorizontalBar(value: boolean);
  80957. /**
  80958. * Forces the vertical scroll bar to be displayed
  80959. */
  80960. get forceVerticalBar(): boolean;
  80961. set forceVerticalBar(value: boolean);
  80962. /**
  80963. * Creates a new ScrollViewer
  80964. * @param name of ScrollViewer
  80965. */
  80966. constructor(name?: string, isImageBased?: boolean);
  80967. /** Reset the scroll viewer window to initial size */
  80968. resetWindow(): void;
  80969. protected _getTypeName(): string;
  80970. private _buildClientSizes;
  80971. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80972. protected _postMeasure(): void;
  80973. /**
  80974. * Gets or sets the mouse wheel precision
  80975. * from 0 to 1 with a default value of 0.05
  80976. * */
  80977. get wheelPrecision(): number;
  80978. set wheelPrecision(value: number);
  80979. /** Gets or sets the scroll bar container background color */
  80980. get scrollBackground(): string;
  80981. set scrollBackground(color: string);
  80982. /** Gets or sets the bar color */
  80983. get barColor(): string;
  80984. set barColor(color: string);
  80985. /** Gets or sets the bar image */
  80986. get thumbImage(): Image;
  80987. set thumbImage(value: Image);
  80988. /** Gets or sets the horizontal bar image */
  80989. get horizontalThumbImage(): Image;
  80990. set horizontalThumbImage(value: Image);
  80991. /** Gets or sets the vertical bar image */
  80992. get verticalThumbImage(): Image;
  80993. set verticalThumbImage(value: Image);
  80994. /** Gets or sets the size of the bar */
  80995. get barSize(): number;
  80996. set barSize(value: number);
  80997. /** Gets or sets the length of the thumb */
  80998. get thumbLength(): number;
  80999. set thumbLength(value: number);
  81000. /** Gets or sets the height of the thumb */
  81001. get thumbHeight(): number;
  81002. set thumbHeight(value: number);
  81003. /** Gets or sets the height of the bar image */
  81004. get barImageHeight(): number;
  81005. set barImageHeight(value: number);
  81006. /** Gets or sets the height of the horizontal bar image */
  81007. get horizontalBarImageHeight(): number;
  81008. set horizontalBarImageHeight(value: number);
  81009. /** Gets or sets the height of the vertical bar image */
  81010. get verticalBarImageHeight(): number;
  81011. set verticalBarImageHeight(value: number);
  81012. /** Gets or sets the bar background */
  81013. get barBackground(): string;
  81014. set barBackground(color: string);
  81015. /** Gets or sets the bar background image */
  81016. get barImage(): Image;
  81017. set barImage(value: Image);
  81018. /** Gets or sets the horizontal bar background image */
  81019. get horizontalBarImage(): Image;
  81020. set horizontalBarImage(value: Image);
  81021. /** Gets or sets the vertical bar background image */
  81022. get verticalBarImage(): Image;
  81023. set verticalBarImage(value: Image);
  81024. private _setWindowPosition;
  81025. /** @hidden */
  81026. private _updateScroller;
  81027. _link(host: AdvancedDynamicTexture): void;
  81028. /** @hidden */
  81029. private _addBar;
  81030. /** @hidden */
  81031. private _attachWheel;
  81032. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  81033. /** Releases associated resources */
  81034. dispose(): void;
  81035. }
  81036. }
  81037. declare module BABYLON.GUI {
  81038. /** Class used to render a grid */
  81039. export class DisplayGrid extends Control {
  81040. name?: string | undefined;
  81041. private _cellWidth;
  81042. private _cellHeight;
  81043. private _minorLineTickness;
  81044. private _minorLineColor;
  81045. private _majorLineTickness;
  81046. private _majorLineColor;
  81047. private _majorLineFrequency;
  81048. private _background;
  81049. private _displayMajorLines;
  81050. private _displayMinorLines;
  81051. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  81052. get displayMinorLines(): boolean;
  81053. set displayMinorLines(value: boolean);
  81054. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  81055. get displayMajorLines(): boolean;
  81056. set displayMajorLines(value: boolean);
  81057. /** Gets or sets background color (Black by default) */
  81058. get background(): string;
  81059. set background(value: string);
  81060. /** Gets or sets the width of each cell (20 by default) */
  81061. get cellWidth(): number;
  81062. set cellWidth(value: number);
  81063. /** Gets or sets the height of each cell (20 by default) */
  81064. get cellHeight(): number;
  81065. set cellHeight(value: number);
  81066. /** Gets or sets the tickness of minor lines (1 by default) */
  81067. get minorLineTickness(): number;
  81068. set minorLineTickness(value: number);
  81069. /** Gets or sets the color of minor lines (DarkGray by default) */
  81070. get minorLineColor(): string;
  81071. set minorLineColor(value: string);
  81072. /** Gets or sets the tickness of major lines (2 by default) */
  81073. get majorLineTickness(): number;
  81074. set majorLineTickness(value: number);
  81075. /** Gets or sets the color of major lines (White by default) */
  81076. get majorLineColor(): string;
  81077. set majorLineColor(value: string);
  81078. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  81079. get majorLineFrequency(): number;
  81080. set majorLineFrequency(value: number);
  81081. /**
  81082. * Creates a new GridDisplayRectangle
  81083. * @param name defines the control name
  81084. */
  81085. constructor(name?: string | undefined);
  81086. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81087. protected _getTypeName(): string;
  81088. }
  81089. }
  81090. declare module BABYLON.GUI {
  81091. /**
  81092. * Class used to create slider controls based on images
  81093. */
  81094. export class ImageBasedSlider extends BaseSlider {
  81095. name?: string | undefined;
  81096. private _backgroundImage;
  81097. private _thumbImage;
  81098. private _valueBarImage;
  81099. private _tempMeasure;
  81100. get displayThumb(): boolean;
  81101. set displayThumb(value: boolean);
  81102. /**
  81103. * Gets or sets the image used to render the background
  81104. */
  81105. get backgroundImage(): Image;
  81106. set backgroundImage(value: Image);
  81107. /**
  81108. * Gets or sets the image used to render the value bar
  81109. */
  81110. get valueBarImage(): Image;
  81111. set valueBarImage(value: Image);
  81112. /**
  81113. * Gets or sets the image used to render the thumb
  81114. */
  81115. get thumbImage(): Image;
  81116. set thumbImage(value: Image);
  81117. /**
  81118. * Creates a new ImageBasedSlider
  81119. * @param name defines the control name
  81120. */
  81121. constructor(name?: string | undefined);
  81122. protected _getTypeName(): string;
  81123. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81124. }
  81125. }
  81126. declare module BABYLON.GUI {
  81127. /**
  81128. * Forcing an export so that this code will execute
  81129. * @hidden
  81130. */
  81131. const name = "Statics";
  81132. }
  81133. declare module BABYLON.GUI {
  81134. /**
  81135. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  81136. */
  81137. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  81138. /**
  81139. * Define the instrumented AdvancedDynamicTexture.
  81140. */
  81141. texture: AdvancedDynamicTexture;
  81142. private _captureRenderTime;
  81143. private _renderTime;
  81144. private _captureLayoutTime;
  81145. private _layoutTime;
  81146. private _onBeginRenderObserver;
  81147. private _onEndRenderObserver;
  81148. private _onBeginLayoutObserver;
  81149. private _onEndLayoutObserver;
  81150. /**
  81151. * Gets the perf counter used to capture render time
  81152. */
  81153. get renderTimeCounter(): BABYLON.PerfCounter;
  81154. /**
  81155. * Gets the perf counter used to capture layout time
  81156. */
  81157. get layoutTimeCounter(): BABYLON.PerfCounter;
  81158. /**
  81159. * Enable or disable the render time capture
  81160. */
  81161. get captureRenderTime(): boolean;
  81162. set captureRenderTime(value: boolean);
  81163. /**
  81164. * Enable or disable the layout time capture
  81165. */
  81166. get captureLayoutTime(): boolean;
  81167. set captureLayoutTime(value: boolean);
  81168. /**
  81169. * Instantiates a new advanced dynamic texture instrumentation.
  81170. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  81171. * @param texture Defines the AdvancedDynamicTexture to instrument
  81172. */
  81173. constructor(
  81174. /**
  81175. * Define the instrumented AdvancedDynamicTexture.
  81176. */
  81177. texture: AdvancedDynamicTexture);
  81178. /**
  81179. * Dispose and release associated resources.
  81180. */
  81181. dispose(): void;
  81182. }
  81183. }
  81184. declare module BABYLON.GUI {
  81185. /**
  81186. * Class used to load GUI via XML.
  81187. */
  81188. export class XmlLoader {
  81189. private _nodes;
  81190. private _nodeTypes;
  81191. private _isLoaded;
  81192. private _objectAttributes;
  81193. private _parentClass;
  81194. /**
  81195. * Create a new xml loader
  81196. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  81197. */
  81198. constructor(parentClass?: null);
  81199. private _getChainElement;
  81200. private _getClassAttribute;
  81201. private _createGuiElement;
  81202. private _parseGrid;
  81203. private _parseElement;
  81204. private _prepareSourceElement;
  81205. private _parseElementsFromSource;
  81206. private _parseXml;
  81207. /**
  81208. * Gets if the loading has finished.
  81209. * @returns whether the loading has finished or not
  81210. */
  81211. isLoaded(): boolean;
  81212. /**
  81213. * Gets a loaded node / control by id.
  81214. * @param id the Controls id set in the xml
  81215. * @returns element of type Control
  81216. */
  81217. getNodeById(id: string): any;
  81218. /**
  81219. * Gets all loaded nodes / controls
  81220. * @returns Array of controls
  81221. */
  81222. getNodes(): any;
  81223. /**
  81224. * Initiates the xml layout loading
  81225. * @param xmlFile defines the xml layout to load
  81226. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  81227. * @param callback defines the callback called on layout load.
  81228. */
  81229. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  81230. }
  81231. }
  81232. declare module BABYLON.GUI {
  81233. /**
  81234. * Class used to create containers for controls
  81235. */
  81236. export class Container3D extends Control3D {
  81237. private _blockLayout;
  81238. /**
  81239. * Gets the list of child controls
  81240. */
  81241. protected _children: Control3D[];
  81242. /**
  81243. * Gets the list of child controls
  81244. */
  81245. get children(): Array<Control3D>;
  81246. /**
  81247. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  81248. * This is helpful to optimize layout operation when adding multiple children in a row
  81249. */
  81250. get blockLayout(): boolean;
  81251. set blockLayout(value: boolean);
  81252. /**
  81253. * Creates a new container
  81254. * @param name defines the container name
  81255. */
  81256. constructor(name?: string);
  81257. /**
  81258. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81259. * @returns the current container
  81260. */
  81261. updateLayout(): Container3D;
  81262. /**
  81263. * Gets a boolean indicating if the given control is in the children of this control
  81264. * @param control defines the control to check
  81265. * @returns true if the control is in the child list
  81266. */
  81267. containsControl(control: Control3D): boolean;
  81268. /**
  81269. * Adds a control to the children of this control
  81270. * @param control defines the control to add
  81271. * @returns the current container
  81272. */
  81273. addControl(control: Control3D): Container3D;
  81274. /**
  81275. * This function will be called everytime a new control is added
  81276. */
  81277. protected _arrangeChildren(): void;
  81278. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81279. /**
  81280. * Removes a control from the children of this control
  81281. * @param control defines the control to remove
  81282. * @returns the current container
  81283. */
  81284. removeControl(control: Control3D): Container3D;
  81285. protected _getTypeName(): string;
  81286. /**
  81287. * Releases all associated resources
  81288. */
  81289. dispose(): void;
  81290. /** Control rotation will remain unchanged */
  81291. static readonly UNSET_ORIENTATION: number;
  81292. /** Control will rotate to make it look at sphere central axis */
  81293. static readonly FACEORIGIN_ORIENTATION: number;
  81294. /** Control will rotate to make it look back at sphere central axis */
  81295. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81296. /** Control will rotate to look at z axis (0, 0, 1) */
  81297. static readonly FACEFORWARD_ORIENTATION: number;
  81298. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81299. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81300. }
  81301. }
  81302. declare module BABYLON.GUI {
  81303. /**
  81304. * Class used to manage 3D user interface
  81305. * @see https://doc.babylonjs.com/how_to/gui3d
  81306. */
  81307. export class GUI3DManager implements BABYLON.IDisposable {
  81308. private _scene;
  81309. private _sceneDisposeObserver;
  81310. private _utilityLayer;
  81311. private _rootContainer;
  81312. private _pointerObserver;
  81313. private _pointerOutObserver;
  81314. /** @hidden */
  81315. _lastPickedControl: Control3D;
  81316. /** @hidden */
  81317. _lastControlOver: {
  81318. [pointerId: number]: Control3D;
  81319. };
  81320. /** @hidden */
  81321. _lastControlDown: {
  81322. [pointerId: number]: Control3D;
  81323. };
  81324. /**
  81325. * BABYLON.Observable raised when the point picked by the pointer events changed
  81326. */
  81327. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81328. /** @hidden */
  81329. _sharedMaterials: {
  81330. [key: string]: BABYLON.Material;
  81331. };
  81332. /** Gets the hosting scene */
  81333. get scene(): BABYLON.Scene;
  81334. /** Gets associated utility layer */
  81335. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81336. /**
  81337. * Creates a new GUI3DManager
  81338. * @param scene
  81339. */
  81340. constructor(scene?: BABYLON.Scene);
  81341. private _handlePointerOut;
  81342. private _doPicking;
  81343. /**
  81344. * Gets the root container
  81345. */
  81346. get rootContainer(): Container3D;
  81347. /**
  81348. * Gets a boolean indicating if the given control is in the root child list
  81349. * @param control defines the control to check
  81350. * @returns true if the control is in the root child list
  81351. */
  81352. containsControl(control: Control3D): boolean;
  81353. /**
  81354. * Adds a control to the root child list
  81355. * @param control defines the control to add
  81356. * @returns the current manager
  81357. */
  81358. addControl(control: Control3D): GUI3DManager;
  81359. /**
  81360. * Removes a control from the root child list
  81361. * @param control defines the control to remove
  81362. * @returns the current container
  81363. */
  81364. removeControl(control: Control3D): GUI3DManager;
  81365. /**
  81366. * Releases all associated resources
  81367. */
  81368. dispose(): void;
  81369. }
  81370. }
  81371. declare module BABYLON.GUI {
  81372. /**
  81373. * Class used to transport BABYLON.Vector3 information for pointer events
  81374. */
  81375. export class Vector3WithInfo extends BABYLON.Vector3 {
  81376. /** defines the current mouse button index */
  81377. buttonIndex: number;
  81378. /**
  81379. * Creates a new Vector3WithInfo
  81380. * @param source defines the vector3 data to transport
  81381. * @param buttonIndex defines the current mouse button index
  81382. */
  81383. constructor(source: BABYLON.Vector3,
  81384. /** defines the current mouse button index */
  81385. buttonIndex?: number);
  81386. }
  81387. }
  81388. declare module BABYLON.GUI {
  81389. /**
  81390. * Class used as base class for controls
  81391. */
  81392. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81393. /** Defines the control name */
  81394. name?: string | undefined;
  81395. /** @hidden */
  81396. _host: GUI3DManager;
  81397. private _node;
  81398. private _downCount;
  81399. private _enterCount;
  81400. private _downPointerIds;
  81401. private _isVisible;
  81402. /** Gets or sets the control position in world space */
  81403. get position(): BABYLON.Vector3;
  81404. set position(value: BABYLON.Vector3);
  81405. /** Gets or sets the control scaling in world space */
  81406. get scaling(): BABYLON.Vector3;
  81407. set scaling(value: BABYLON.Vector3);
  81408. /** Callback used to start pointer enter animation */
  81409. pointerEnterAnimation: () => void;
  81410. /** Callback used to start pointer out animation */
  81411. pointerOutAnimation: () => void;
  81412. /** Callback used to start pointer down animation */
  81413. pointerDownAnimation: () => void;
  81414. /** Callback used to start pointer up animation */
  81415. pointerUpAnimation: () => void;
  81416. /**
  81417. * An event triggered when the pointer move over the control
  81418. */
  81419. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81420. /**
  81421. * An event triggered when the pointer move out of the control
  81422. */
  81423. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81424. /**
  81425. * An event triggered when the pointer taps the control
  81426. */
  81427. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81428. /**
  81429. * An event triggered when pointer is up
  81430. */
  81431. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81432. /**
  81433. * An event triggered when a control is clicked on (with a mouse)
  81434. */
  81435. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81436. /**
  81437. * An event triggered when pointer enters the control
  81438. */
  81439. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81440. /**
  81441. * Gets or sets the parent container
  81442. */
  81443. parent: BABYLON.Nullable<Container3D>;
  81444. private _behaviors;
  81445. /**
  81446. * Gets the list of attached behaviors
  81447. * @see https://doc.babylonjs.com/features/behaviour
  81448. */
  81449. get behaviors(): BABYLON.Behavior<Control3D>[];
  81450. /**
  81451. * Attach a behavior to the control
  81452. * @see https://doc.babylonjs.com/features/behaviour
  81453. * @param behavior defines the behavior to attach
  81454. * @returns the current control
  81455. */
  81456. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81457. /**
  81458. * Remove an attached behavior
  81459. * @see https://doc.babylonjs.com/features/behaviour
  81460. * @param behavior defines the behavior to attach
  81461. * @returns the current control
  81462. */
  81463. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81464. /**
  81465. * Gets an attached behavior by name
  81466. * @param name defines the name of the behavior to look for
  81467. * @see https://doc.babylonjs.com/features/behaviour
  81468. * @returns null if behavior was not found else the requested behavior
  81469. */
  81470. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81471. /** Gets or sets a boolean indicating if the control is visible */
  81472. get isVisible(): boolean;
  81473. set isVisible(value: boolean);
  81474. /**
  81475. * Creates a new control
  81476. * @param name defines the control name
  81477. */
  81478. constructor(
  81479. /** Defines the control name */
  81480. name?: string | undefined);
  81481. /**
  81482. * Gets a string representing the class name
  81483. */
  81484. get typeName(): string;
  81485. /**
  81486. * Get the current class name of the control.
  81487. * @returns current class name
  81488. */
  81489. getClassName(): string;
  81490. protected _getTypeName(): string;
  81491. /**
  81492. * Gets the transform node used by this control
  81493. */
  81494. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81495. /**
  81496. * Gets the mesh used to render this control
  81497. */
  81498. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81499. /**
  81500. * Link the control as child of the given node
  81501. * @param node defines the node to link to. Use null to unlink the control
  81502. * @returns the current control
  81503. */
  81504. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81505. /** @hidden **/
  81506. _prepareNode(scene: BABYLON.Scene): void;
  81507. /**
  81508. * Node creation.
  81509. * Can be overriden by children
  81510. * @param scene defines the scene where the node must be attached
  81511. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81512. */
  81513. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81514. /**
  81515. * Affect a material to the given mesh
  81516. * @param mesh defines the mesh which will represent the control
  81517. */
  81518. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81519. /** @hidden */
  81520. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81521. /** @hidden */
  81522. _onPointerEnter(target: Control3D): boolean;
  81523. /** @hidden */
  81524. _onPointerOut(target: Control3D): void;
  81525. /** @hidden */
  81526. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81527. /** @hidden */
  81528. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81529. /** @hidden */
  81530. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81531. /** @hidden */
  81532. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81533. /** @hidden */
  81534. _disposeNode(): void;
  81535. /**
  81536. * Releases all associated resources
  81537. */
  81538. dispose(): void;
  81539. }
  81540. }
  81541. declare module BABYLON.GUI {
  81542. /**
  81543. * Class used as a root to all buttons
  81544. */
  81545. export class AbstractButton3D extends Control3D {
  81546. /**
  81547. * Creates a new button
  81548. * @param name defines the control name
  81549. */
  81550. constructor(name?: string);
  81551. protected _getTypeName(): string;
  81552. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81553. }
  81554. }
  81555. declare module BABYLON.GUI {
  81556. /**
  81557. * Class used to create a button in 3D
  81558. */
  81559. export class Button3D extends AbstractButton3D {
  81560. /** @hidden */
  81561. protected _currentMaterial: BABYLON.Material;
  81562. private _facadeTexture;
  81563. private _content;
  81564. private _contentResolution;
  81565. private _contentScaleRatio;
  81566. /**
  81567. * Gets or sets the texture resolution used to render content (512 by default)
  81568. */
  81569. get contentResolution(): BABYLON.int;
  81570. set contentResolution(value: BABYLON.int);
  81571. /**
  81572. * Gets or sets the texture scale ratio used to render content (2 by default)
  81573. */
  81574. get contentScaleRatio(): number;
  81575. set contentScaleRatio(value: number);
  81576. protected _disposeFacadeTexture(): void;
  81577. protected _resetContent(): void;
  81578. /**
  81579. * Creates a new button
  81580. * @param name defines the control name
  81581. */
  81582. constructor(name?: string);
  81583. /**
  81584. * Gets or sets the GUI 2D content used to display the button's facade
  81585. */
  81586. get content(): Control;
  81587. set content(value: Control);
  81588. /**
  81589. * Apply the facade texture (created from the content property).
  81590. * This function can be overloaded by child classes
  81591. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81592. */
  81593. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81594. protected _getTypeName(): string;
  81595. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81596. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81597. /**
  81598. * Releases all associated resources
  81599. */
  81600. dispose(): void;
  81601. }
  81602. }
  81603. declare module BABYLON.GUI {
  81604. /**
  81605. * Abstract class used to create a container panel deployed on the surface of a volume
  81606. */
  81607. export abstract class VolumeBasedPanel extends Container3D {
  81608. private _columns;
  81609. private _rows;
  81610. private _rowThenColum;
  81611. private _orientation;
  81612. protected _cellWidth: number;
  81613. protected _cellHeight: number;
  81614. /**
  81615. * Gets or sets the distance between elements
  81616. */
  81617. margin: number;
  81618. /**
  81619. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81620. * | Value | Type | Description |
  81621. * | ----- | ----------------------------------- | ----------- |
  81622. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81623. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81624. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81625. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81626. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81627. */
  81628. get orientation(): number;
  81629. set orientation(value: number);
  81630. /**
  81631. * Gets or sets the number of columns requested (10 by default).
  81632. * The panel will automatically compute the number of rows based on number of child controls.
  81633. */
  81634. get columns(): BABYLON.int;
  81635. set columns(value: BABYLON.int);
  81636. /**
  81637. * Gets or sets a the number of rows requested.
  81638. * The panel will automatically compute the number of columns based on number of child controls.
  81639. */
  81640. get rows(): BABYLON.int;
  81641. set rows(value: BABYLON.int);
  81642. /**
  81643. * Creates new VolumeBasedPanel
  81644. */
  81645. constructor();
  81646. protected _arrangeChildren(): void;
  81647. /** Child classes must implement this function to provide correct control positioning */
  81648. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81649. /** Child classes can implement this function to provide additional processing */
  81650. protected _finalProcessing(): void;
  81651. }
  81652. }
  81653. declare module BABYLON.GUI {
  81654. /**
  81655. * Class used to create a container panel deployed on the surface of a cylinder
  81656. */
  81657. export class CylinderPanel extends VolumeBasedPanel {
  81658. private _radius;
  81659. /**
  81660. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81661. */
  81662. get radius(): BABYLON.float;
  81663. set radius(value: BABYLON.float);
  81664. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81665. private _cylindricalMapping;
  81666. }
  81667. }
  81668. declare module BABYLON.GUI {
  81669. /** @hidden */
  81670. export var fluentVertexShader: {
  81671. name: string;
  81672. shader: string;
  81673. };
  81674. }
  81675. declare module BABYLON.GUI {
  81676. /** @hidden */
  81677. export var fluentPixelShader: {
  81678. name: string;
  81679. shader: string;
  81680. };
  81681. }
  81682. declare module BABYLON.GUI {
  81683. /** @hidden */
  81684. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81685. INNERGLOW: boolean;
  81686. BORDER: boolean;
  81687. HOVERLIGHT: boolean;
  81688. TEXTURE: boolean;
  81689. constructor();
  81690. }
  81691. /**
  81692. * Class used to render controls with fluent desgin
  81693. */
  81694. export class FluentMaterial extends BABYLON.PushMaterial {
  81695. /**
  81696. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81697. */
  81698. innerGlowColorIntensity: number;
  81699. /**
  81700. * Gets or sets the inner glow color (white by default)
  81701. */
  81702. innerGlowColor: BABYLON.Color3;
  81703. /**
  81704. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81705. */
  81706. albedoColor: BABYLON.Color3;
  81707. /**
  81708. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81709. */
  81710. renderBorders: boolean;
  81711. /**
  81712. * Gets or sets border width (default is 0.5)
  81713. */
  81714. borderWidth: number;
  81715. /**
  81716. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81717. */
  81718. edgeSmoothingValue: number;
  81719. /**
  81720. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81721. */
  81722. borderMinValue: number;
  81723. /**
  81724. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81725. */
  81726. renderHoverLight: boolean;
  81727. /**
  81728. * Gets or sets the radius used to render the hover light (default is 1.0)
  81729. */
  81730. hoverRadius: number;
  81731. /**
  81732. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81733. */
  81734. hoverColor: BABYLON.Color4;
  81735. /**
  81736. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81737. */
  81738. hoverPosition: BABYLON.Vector3;
  81739. private _albedoTexture;
  81740. /** Gets or sets the texture to use for albedo color */
  81741. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81742. /**
  81743. * Creates a new Fluent material
  81744. * @param name defines the name of the material
  81745. * @param scene defines the hosting scene
  81746. */
  81747. constructor(name: string, scene: BABYLON.Scene);
  81748. needAlphaBlending(): boolean;
  81749. needAlphaTesting(): boolean;
  81750. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81751. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81752. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81753. getActiveTextures(): BABYLON.BaseTexture[];
  81754. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81755. dispose(forceDisposeEffect?: boolean): void;
  81756. clone(name: string): FluentMaterial;
  81757. serialize(): any;
  81758. getClassName(): string;
  81759. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81760. }
  81761. }
  81762. declare module BABYLON.GUI {
  81763. /**
  81764. * Class used to create a holographic button in 3D
  81765. */
  81766. export class HolographicButton extends Button3D {
  81767. private _backPlate;
  81768. private _textPlate;
  81769. private _frontPlate;
  81770. private _text;
  81771. private _imageUrl;
  81772. private _shareMaterials;
  81773. private _frontMaterial;
  81774. private _backMaterial;
  81775. private _plateMaterial;
  81776. private _pickedPointObserver;
  81777. private _tooltipFade;
  81778. private _tooltipTextBlock;
  81779. private _tooltipTexture;
  81780. private _tooltipMesh;
  81781. private _tooltipHoverObserver;
  81782. private _tooltipOutObserver;
  81783. private _disposeTooltip;
  81784. /**
  81785. * Rendering ground id of all the mesh in the button
  81786. */
  81787. set renderingGroupId(id: number);
  81788. get renderingGroupId(): number;
  81789. /**
  81790. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81791. */
  81792. set tooltipText(text: BABYLON.Nullable<string>);
  81793. get tooltipText(): BABYLON.Nullable<string>;
  81794. /**
  81795. * Gets or sets text for the button
  81796. */
  81797. get text(): string;
  81798. set text(value: string);
  81799. /**
  81800. * Gets or sets the image url for the button
  81801. */
  81802. get imageUrl(): string;
  81803. set imageUrl(value: string);
  81804. /**
  81805. * Gets the back material used by this button
  81806. */
  81807. get backMaterial(): FluentMaterial;
  81808. /**
  81809. * Gets the front material used by this button
  81810. */
  81811. get frontMaterial(): FluentMaterial;
  81812. /**
  81813. * Gets the plate material used by this button
  81814. */
  81815. get plateMaterial(): BABYLON.StandardMaterial;
  81816. /**
  81817. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81818. */
  81819. get shareMaterials(): boolean;
  81820. /**
  81821. * Creates a new button
  81822. * @param name defines the control name
  81823. */
  81824. constructor(name?: string, shareMaterials?: boolean);
  81825. protected _getTypeName(): string;
  81826. private _rebuildContent;
  81827. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81828. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81829. private _createBackMaterial;
  81830. private _createFrontMaterial;
  81831. private _createPlateMaterial;
  81832. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81833. /**
  81834. * Releases all associated resources
  81835. */
  81836. dispose(): void;
  81837. }
  81838. }
  81839. declare module BABYLON.GUI {
  81840. /**
  81841. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81842. */
  81843. export class MeshButton3D extends Button3D {
  81844. /** @hidden */
  81845. protected _currentMesh: BABYLON.Mesh;
  81846. /**
  81847. * Creates a new 3D button based on a mesh
  81848. * @param mesh mesh to become a 3D button
  81849. * @param name defines the control name
  81850. */
  81851. constructor(mesh: BABYLON.Mesh, name?: string);
  81852. protected _getTypeName(): string;
  81853. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81854. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81855. }
  81856. }
  81857. declare module BABYLON.GUI {
  81858. /**
  81859. * Class used to create a container panel deployed on the surface of a plane
  81860. */
  81861. export class PlanePanel extends VolumeBasedPanel {
  81862. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81863. }
  81864. }
  81865. declare module BABYLON.GUI {
  81866. /**
  81867. * Class used to create a container panel where items get randomized planar mapping
  81868. */
  81869. export class ScatterPanel extends VolumeBasedPanel {
  81870. private _iteration;
  81871. /**
  81872. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81873. */
  81874. get iteration(): BABYLON.float;
  81875. set iteration(value: BABYLON.float);
  81876. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81877. private _scatterMapping;
  81878. protected _finalProcessing(): void;
  81879. }
  81880. }
  81881. declare module BABYLON.GUI {
  81882. /**
  81883. * Class used to create a container panel deployed on the surface of a sphere
  81884. */
  81885. export class SpherePanel extends VolumeBasedPanel {
  81886. private _radius;
  81887. /**
  81888. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81889. */
  81890. get radius(): BABYLON.float;
  81891. set radius(value: BABYLON.float);
  81892. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81893. private _sphericalMapping;
  81894. }
  81895. }
  81896. declare module BABYLON.GUI {
  81897. /**
  81898. * Class used to create a stack panel in 3D on XY plane
  81899. */
  81900. export class StackPanel3D extends Container3D {
  81901. private _isVertical;
  81902. /**
  81903. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81904. */
  81905. get isVertical(): boolean;
  81906. set isVertical(value: boolean);
  81907. /**
  81908. * Gets or sets the distance between elements
  81909. */
  81910. margin: number;
  81911. /**
  81912. * Creates new StackPanel
  81913. * @param isVertical
  81914. */
  81915. constructor(isVertical?: boolean);
  81916. protected _arrangeChildren(): void;
  81917. }
  81918. }
  81919. declare module BABYLON {
  81920. /**
  81921. * Configuration for glTF validation
  81922. */
  81923. export interface IGLTFValidationConfiguration {
  81924. /**
  81925. * The url of the glTF validator.
  81926. */
  81927. url: string;
  81928. }
  81929. /**
  81930. * glTF validation
  81931. */
  81932. export class GLTFValidation {
  81933. /**
  81934. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81935. */
  81936. static Configuration: IGLTFValidationConfiguration;
  81937. private static _LoadScriptPromise;
  81938. /**
  81939. * Validate a glTF asset using the glTF-Validator.
  81940. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81941. * @param rootUrl The root url for the glTF
  81942. * @param fileName The file name for the glTF
  81943. * @param getExternalResource The callback to get external resources for the glTF validator
  81944. * @returns A promise that resolves with the glTF validation results once complete
  81945. */
  81946. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81947. }
  81948. }
  81949. declare module BABYLON {
  81950. /**
  81951. * Mode that determines the coordinate system to use.
  81952. */
  81953. export enum GLTFLoaderCoordinateSystemMode {
  81954. /**
  81955. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81956. */
  81957. AUTO = 0,
  81958. /**
  81959. * Sets the useRightHandedSystem flag on the scene.
  81960. */
  81961. FORCE_RIGHT_HANDED = 1
  81962. }
  81963. /**
  81964. * Mode that determines what animations will start.
  81965. */
  81966. export enum GLTFLoaderAnimationStartMode {
  81967. /**
  81968. * No animation will start.
  81969. */
  81970. NONE = 0,
  81971. /**
  81972. * The first animation will start.
  81973. */
  81974. FIRST = 1,
  81975. /**
  81976. * All animations will start.
  81977. */
  81978. ALL = 2
  81979. }
  81980. /**
  81981. * Interface that contains the data for the glTF asset.
  81982. */
  81983. export interface IGLTFLoaderData {
  81984. /**
  81985. * The object that represents the glTF JSON.
  81986. */
  81987. json: Object;
  81988. /**
  81989. * The BIN chunk of a binary glTF.
  81990. */
  81991. bin: Nullable<IDataBuffer>;
  81992. }
  81993. /**
  81994. * Interface for extending the loader.
  81995. */
  81996. export interface IGLTFLoaderExtension {
  81997. /**
  81998. * The name of this extension.
  81999. */
  82000. readonly name: string;
  82001. /**
  82002. * Defines whether this extension is enabled.
  82003. */
  82004. enabled: boolean;
  82005. /**
  82006. * Defines the order of this extension.
  82007. * The loader sorts the extensions using these values when loading.
  82008. */
  82009. order?: number;
  82010. }
  82011. /**
  82012. * Loader state.
  82013. */
  82014. export enum GLTFLoaderState {
  82015. /**
  82016. * The asset is loading.
  82017. */
  82018. LOADING = 0,
  82019. /**
  82020. * The asset is ready for rendering.
  82021. */
  82022. READY = 1,
  82023. /**
  82024. * The asset is completely loaded.
  82025. */
  82026. COMPLETE = 2
  82027. }
  82028. /** @hidden */
  82029. export interface IImportMeshAsyncOutput {
  82030. meshes: AbstractMesh[];
  82031. geometries: Geometry[];
  82032. particleSystems: IParticleSystem[];
  82033. skeletons: Skeleton[];
  82034. animationGroups: AnimationGroup[];
  82035. lights: Light[];
  82036. transformNodes: TransformNode[];
  82037. }
  82038. /** @hidden */
  82039. export interface IGLTFLoader extends IDisposable {
  82040. readonly state: Nullable<GLTFLoaderState>;
  82041. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  82042. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  82043. }
  82044. /**
  82045. * File loader for loading glTF files into a scene.
  82046. */
  82047. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82048. /** @hidden */
  82049. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82050. /** @hidden */
  82051. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82052. /**
  82053. * Raised when the asset has been parsed
  82054. */
  82055. onParsedObservable: Observable<IGLTFLoaderData>;
  82056. private _onParsedObserver;
  82057. /**
  82058. * Raised when the asset has been parsed
  82059. */
  82060. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  82061. /**
  82062. * 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.
  82063. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  82064. * Defaults to true.
  82065. * @hidden
  82066. */
  82067. static IncrementalLoading: boolean;
  82068. /**
  82069. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  82070. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  82071. * @hidden
  82072. */
  82073. static HomogeneousCoordinates: boolean;
  82074. /**
  82075. * The coordinate system mode. Defaults to AUTO.
  82076. */
  82077. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  82078. /**
  82079. * The animation start mode. Defaults to FIRST.
  82080. */
  82081. animationStartMode: GLTFLoaderAnimationStartMode;
  82082. /**
  82083. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  82084. */
  82085. compileMaterials: boolean;
  82086. /**
  82087. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  82088. */
  82089. useClipPlane: boolean;
  82090. /**
  82091. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  82092. */
  82093. compileShadowGenerators: boolean;
  82094. /**
  82095. * Defines if the Alpha blended materials are only applied as coverage.
  82096. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  82097. * If true, no extra effects are applied to transparent pixels.
  82098. */
  82099. transparencyAsCoverage: boolean;
  82100. /**
  82101. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  82102. * Enabling will disable offline support and glTF validator.
  82103. * Defaults to false.
  82104. */
  82105. useRangeRequests: boolean;
  82106. /**
  82107. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  82108. */
  82109. createInstances: boolean;
  82110. /**
  82111. * 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.
  82112. */
  82113. alwaysComputeBoundingBox: boolean;
  82114. /**
  82115. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  82116. */
  82117. loadAllMaterials: boolean;
  82118. /**
  82119. * Function called before loading a url referenced by the asset.
  82120. */
  82121. preprocessUrlAsync: (url: string) => Promise<string>;
  82122. /**
  82123. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82124. * 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, ...)
  82125. */
  82126. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  82127. private _onMeshLoadedObserver;
  82128. /**
  82129. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82130. * 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, ...)
  82131. */
  82132. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  82133. /**
  82134. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  82135. */
  82136. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  82137. private _onTextureLoadedObserver;
  82138. /**
  82139. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  82140. */
  82141. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  82142. /**
  82143. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  82144. */
  82145. readonly onMaterialLoadedObservable: Observable<Material>;
  82146. private _onMaterialLoadedObserver;
  82147. /**
  82148. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  82149. */
  82150. set onMaterialLoaded(callback: (material: Material) => void);
  82151. /**
  82152. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  82153. */
  82154. readonly onCameraLoadedObservable: Observable<Camera>;
  82155. private _onCameraLoadedObserver;
  82156. /**
  82157. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  82158. */
  82159. set onCameraLoaded(callback: (camera: Camera) => void);
  82160. /**
  82161. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  82162. * For assets with LODs, raised when all of the LODs are complete.
  82163. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82164. */
  82165. readonly onCompleteObservable: Observable<void>;
  82166. private _onCompleteObserver;
  82167. /**
  82168. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  82169. * For assets with LODs, raised when all of the LODs are complete.
  82170. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82171. */
  82172. set onComplete(callback: () => void);
  82173. /**
  82174. * Observable raised when an error occurs.
  82175. */
  82176. readonly onErrorObservable: Observable<any>;
  82177. private _onErrorObserver;
  82178. /**
  82179. * Callback raised when an error occurs.
  82180. */
  82181. set onError(callback: (reason: any) => void);
  82182. /**
  82183. * Observable raised after the loader is disposed.
  82184. */
  82185. readonly onDisposeObservable: Observable<void>;
  82186. private _onDisposeObserver;
  82187. /**
  82188. * Callback raised after the loader is disposed.
  82189. */
  82190. set onDispose(callback: () => void);
  82191. /**
  82192. * Observable raised after a loader extension is created.
  82193. * Set additional options for a loader extension in this event.
  82194. */
  82195. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  82196. private _onExtensionLoadedObserver;
  82197. /**
  82198. * Callback raised after a loader extension is created.
  82199. */
  82200. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  82201. /**
  82202. * Defines if the loader logging is enabled.
  82203. */
  82204. get loggingEnabled(): boolean;
  82205. set loggingEnabled(value: boolean);
  82206. /**
  82207. * Defines if the loader should capture performance counters.
  82208. */
  82209. get capturePerformanceCounters(): boolean;
  82210. set capturePerformanceCounters(value: boolean);
  82211. /**
  82212. * Defines if the loader should validate the asset.
  82213. */
  82214. validate: boolean;
  82215. /**
  82216. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  82217. */
  82218. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  82219. private _onValidatedObserver;
  82220. /**
  82221. * Callback raised after a loader extension is created.
  82222. */
  82223. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  82224. private _loader;
  82225. private _progressCallback?;
  82226. private _requests;
  82227. private static magicBase64Encoded;
  82228. /**
  82229. * Name of the loader ("gltf")
  82230. */
  82231. name: string;
  82232. /** @hidden */
  82233. extensions: ISceneLoaderPluginExtensions;
  82234. /**
  82235. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  82236. */
  82237. dispose(): void;
  82238. /** @hidden */
  82239. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82240. /** @hidden */
  82241. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82242. /** @hidden */
  82243. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82244. meshes: AbstractMesh[];
  82245. particleSystems: IParticleSystem[];
  82246. skeletons: Skeleton[];
  82247. animationGroups: AnimationGroup[];
  82248. }>;
  82249. /** @hidden */
  82250. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82251. /** @hidden */
  82252. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82253. /** @hidden */
  82254. canDirectLoad(data: string): boolean;
  82255. /** @hidden */
  82256. directLoad(scene: Scene, data: string): Promise<any>;
  82257. /**
  82258. * The callback that allows custom handling of the root url based on the response url.
  82259. * @param rootUrl the original root url
  82260. * @param responseURL the response url if available
  82261. * @returns the new root url
  82262. */
  82263. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82264. /** @hidden */
  82265. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82266. /**
  82267. * The loader state or null if the loader is not active.
  82268. */
  82269. get loaderState(): Nullable<GLTFLoaderState>;
  82270. /**
  82271. * Returns a promise that resolves when the asset is completely loaded.
  82272. * @returns a promise that resolves when the asset is completely loaded.
  82273. */
  82274. whenCompleteAsync(): Promise<void>;
  82275. /** @hidden */
  82276. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82277. /** @hidden */
  82278. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82279. private _onProgress;
  82280. private _validate;
  82281. private _getLoader;
  82282. private _parseJson;
  82283. private _unpackBinaryAsync;
  82284. private _unpackBinaryV1Async;
  82285. private _unpackBinaryV2Async;
  82286. private static _parseVersion;
  82287. private static _compareVersion;
  82288. private static readonly _logSpaces;
  82289. private _logIndentLevel;
  82290. private _loggingEnabled;
  82291. /** @hidden */
  82292. _log: (message: string) => void;
  82293. /** @hidden */
  82294. _logOpen(message: string): void;
  82295. /** @hidden */
  82296. _logClose(): void;
  82297. private _logEnabled;
  82298. private _logDisabled;
  82299. private _capturePerformanceCounters;
  82300. /** @hidden */
  82301. _startPerformanceCounter: (counterName: string) => void;
  82302. /** @hidden */
  82303. _endPerformanceCounter: (counterName: string) => void;
  82304. private _startPerformanceCounterEnabled;
  82305. private _startPerformanceCounterDisabled;
  82306. private _endPerformanceCounterEnabled;
  82307. private _endPerformanceCounterDisabled;
  82308. }
  82309. }
  82310. declare module BABYLON.GLTF1 {
  82311. /**
  82312. * Enums
  82313. * @hidden
  82314. */
  82315. export enum EComponentType {
  82316. BYTE = 5120,
  82317. UNSIGNED_BYTE = 5121,
  82318. SHORT = 5122,
  82319. UNSIGNED_SHORT = 5123,
  82320. FLOAT = 5126
  82321. }
  82322. /** @hidden */
  82323. export enum EShaderType {
  82324. FRAGMENT = 35632,
  82325. VERTEX = 35633
  82326. }
  82327. /** @hidden */
  82328. export enum EParameterType {
  82329. BYTE = 5120,
  82330. UNSIGNED_BYTE = 5121,
  82331. SHORT = 5122,
  82332. UNSIGNED_SHORT = 5123,
  82333. INT = 5124,
  82334. UNSIGNED_INT = 5125,
  82335. FLOAT = 5126,
  82336. FLOAT_VEC2 = 35664,
  82337. FLOAT_VEC3 = 35665,
  82338. FLOAT_VEC4 = 35666,
  82339. INT_VEC2 = 35667,
  82340. INT_VEC3 = 35668,
  82341. INT_VEC4 = 35669,
  82342. BOOL = 35670,
  82343. BOOL_VEC2 = 35671,
  82344. BOOL_VEC3 = 35672,
  82345. BOOL_VEC4 = 35673,
  82346. FLOAT_MAT2 = 35674,
  82347. FLOAT_MAT3 = 35675,
  82348. FLOAT_MAT4 = 35676,
  82349. SAMPLER_2D = 35678
  82350. }
  82351. /** @hidden */
  82352. export enum ETextureWrapMode {
  82353. CLAMP_TO_EDGE = 33071,
  82354. MIRRORED_REPEAT = 33648,
  82355. REPEAT = 10497
  82356. }
  82357. /** @hidden */
  82358. export enum ETextureFilterType {
  82359. NEAREST = 9728,
  82360. LINEAR = 9728,
  82361. NEAREST_MIPMAP_NEAREST = 9984,
  82362. LINEAR_MIPMAP_NEAREST = 9985,
  82363. NEAREST_MIPMAP_LINEAR = 9986,
  82364. LINEAR_MIPMAP_LINEAR = 9987
  82365. }
  82366. /** @hidden */
  82367. export enum ETextureFormat {
  82368. ALPHA = 6406,
  82369. RGB = 6407,
  82370. RGBA = 6408,
  82371. LUMINANCE = 6409,
  82372. LUMINANCE_ALPHA = 6410
  82373. }
  82374. /** @hidden */
  82375. export enum ECullingType {
  82376. FRONT = 1028,
  82377. BACK = 1029,
  82378. FRONT_AND_BACK = 1032
  82379. }
  82380. /** @hidden */
  82381. export enum EBlendingFunction {
  82382. ZERO = 0,
  82383. ONE = 1,
  82384. SRC_COLOR = 768,
  82385. ONE_MINUS_SRC_COLOR = 769,
  82386. DST_COLOR = 774,
  82387. ONE_MINUS_DST_COLOR = 775,
  82388. SRC_ALPHA = 770,
  82389. ONE_MINUS_SRC_ALPHA = 771,
  82390. DST_ALPHA = 772,
  82391. ONE_MINUS_DST_ALPHA = 773,
  82392. CONSTANT_COLOR = 32769,
  82393. ONE_MINUS_CONSTANT_COLOR = 32770,
  82394. CONSTANT_ALPHA = 32771,
  82395. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82396. SRC_ALPHA_SATURATE = 776
  82397. }
  82398. /** @hidden */
  82399. export interface IGLTFProperty {
  82400. extensions?: {
  82401. [key: string]: any;
  82402. };
  82403. extras?: Object;
  82404. }
  82405. /** @hidden */
  82406. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82407. name?: string;
  82408. }
  82409. /** @hidden */
  82410. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82411. bufferView: string;
  82412. byteOffset: number;
  82413. byteStride: number;
  82414. count: number;
  82415. type: string;
  82416. componentType: EComponentType;
  82417. max?: number[];
  82418. min?: number[];
  82419. name?: string;
  82420. }
  82421. /** @hidden */
  82422. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82423. buffer: string;
  82424. byteOffset: number;
  82425. byteLength: number;
  82426. byteStride: number;
  82427. target?: number;
  82428. }
  82429. /** @hidden */
  82430. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82431. uri: string;
  82432. byteLength?: number;
  82433. type?: string;
  82434. }
  82435. /** @hidden */
  82436. export interface IGLTFShader extends IGLTFChildRootProperty {
  82437. uri: string;
  82438. type: EShaderType;
  82439. }
  82440. /** @hidden */
  82441. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82442. attributes: string[];
  82443. fragmentShader: string;
  82444. vertexShader: string;
  82445. }
  82446. /** @hidden */
  82447. export interface IGLTFTechniqueParameter {
  82448. type: number;
  82449. count?: number;
  82450. semantic?: string;
  82451. node?: string;
  82452. value?: number | boolean | string | Array<any>;
  82453. source?: string;
  82454. babylonValue?: any;
  82455. }
  82456. /** @hidden */
  82457. export interface IGLTFTechniqueCommonProfile {
  82458. lightingModel: string;
  82459. texcoordBindings: Object;
  82460. parameters?: Array<any>;
  82461. }
  82462. /** @hidden */
  82463. export interface IGLTFTechniqueStatesFunctions {
  82464. blendColor?: number[];
  82465. blendEquationSeparate?: number[];
  82466. blendFuncSeparate?: number[];
  82467. colorMask: boolean[];
  82468. cullFace: number[];
  82469. }
  82470. /** @hidden */
  82471. export interface IGLTFTechniqueStates {
  82472. enable: number[];
  82473. functions: IGLTFTechniqueStatesFunctions;
  82474. }
  82475. /** @hidden */
  82476. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82477. parameters: {
  82478. [key: string]: IGLTFTechniqueParameter;
  82479. };
  82480. program: string;
  82481. attributes: {
  82482. [key: string]: string;
  82483. };
  82484. uniforms: {
  82485. [key: string]: string;
  82486. };
  82487. states: IGLTFTechniqueStates;
  82488. }
  82489. /** @hidden */
  82490. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82491. technique?: string;
  82492. values: string[];
  82493. }
  82494. /** @hidden */
  82495. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82496. attributes: {
  82497. [key: string]: string;
  82498. };
  82499. indices: string;
  82500. material: string;
  82501. mode?: number;
  82502. }
  82503. /** @hidden */
  82504. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82505. primitives: IGLTFMeshPrimitive[];
  82506. }
  82507. /** @hidden */
  82508. export interface IGLTFImage extends IGLTFChildRootProperty {
  82509. uri: string;
  82510. }
  82511. /** @hidden */
  82512. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82513. magFilter?: number;
  82514. minFilter?: number;
  82515. wrapS?: number;
  82516. wrapT?: number;
  82517. }
  82518. /** @hidden */
  82519. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82520. sampler: string;
  82521. source: string;
  82522. format?: ETextureFormat;
  82523. internalFormat?: ETextureFormat;
  82524. target?: number;
  82525. type?: number;
  82526. babylonTexture?: Texture;
  82527. }
  82528. /** @hidden */
  82529. export interface IGLTFAmbienLight {
  82530. color?: number[];
  82531. }
  82532. /** @hidden */
  82533. export interface IGLTFDirectionalLight {
  82534. color?: number[];
  82535. }
  82536. /** @hidden */
  82537. export interface IGLTFPointLight {
  82538. color?: number[];
  82539. constantAttenuation?: number;
  82540. linearAttenuation?: number;
  82541. quadraticAttenuation?: number;
  82542. }
  82543. /** @hidden */
  82544. export interface IGLTFSpotLight {
  82545. color?: number[];
  82546. constantAttenuation?: number;
  82547. fallOfAngle?: number;
  82548. fallOffExponent?: number;
  82549. linearAttenuation?: number;
  82550. quadraticAttenuation?: number;
  82551. }
  82552. /** @hidden */
  82553. export interface IGLTFLight extends IGLTFChildRootProperty {
  82554. type: string;
  82555. }
  82556. /** @hidden */
  82557. export interface IGLTFCameraOrthographic {
  82558. xmag: number;
  82559. ymag: number;
  82560. zfar: number;
  82561. znear: number;
  82562. }
  82563. /** @hidden */
  82564. export interface IGLTFCameraPerspective {
  82565. aspectRatio: number;
  82566. yfov: number;
  82567. zfar: number;
  82568. znear: number;
  82569. }
  82570. /** @hidden */
  82571. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82572. type: string;
  82573. }
  82574. /** @hidden */
  82575. export interface IGLTFAnimationChannelTarget {
  82576. id: string;
  82577. path: string;
  82578. }
  82579. /** @hidden */
  82580. export interface IGLTFAnimationChannel {
  82581. sampler: string;
  82582. target: IGLTFAnimationChannelTarget;
  82583. }
  82584. /** @hidden */
  82585. export interface IGLTFAnimationSampler {
  82586. input: string;
  82587. output: string;
  82588. interpolation?: string;
  82589. }
  82590. /** @hidden */
  82591. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82592. channels?: IGLTFAnimationChannel[];
  82593. parameters?: {
  82594. [key: string]: string;
  82595. };
  82596. samplers?: {
  82597. [key: string]: IGLTFAnimationSampler;
  82598. };
  82599. }
  82600. /** @hidden */
  82601. export interface IGLTFNodeInstanceSkin {
  82602. skeletons: string[];
  82603. skin: string;
  82604. meshes: string[];
  82605. }
  82606. /** @hidden */
  82607. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82608. bindShapeMatrix: number[];
  82609. inverseBindMatrices: string;
  82610. jointNames: string[];
  82611. babylonSkeleton?: Skeleton;
  82612. }
  82613. /** @hidden */
  82614. export interface IGLTFNode extends IGLTFChildRootProperty {
  82615. camera?: string;
  82616. children: string[];
  82617. skin?: string;
  82618. jointName?: string;
  82619. light?: string;
  82620. matrix: number[];
  82621. mesh?: string;
  82622. meshes?: string[];
  82623. rotation?: number[];
  82624. scale?: number[];
  82625. translation?: number[];
  82626. babylonNode?: Node;
  82627. }
  82628. /** @hidden */
  82629. export interface IGLTFScene extends IGLTFChildRootProperty {
  82630. nodes: string[];
  82631. }
  82632. /** @hidden */
  82633. export interface IGLTFRuntime {
  82634. extensions: {
  82635. [key: string]: any;
  82636. };
  82637. accessors: {
  82638. [key: string]: IGLTFAccessor;
  82639. };
  82640. buffers: {
  82641. [key: string]: IGLTFBuffer;
  82642. };
  82643. bufferViews: {
  82644. [key: string]: IGLTFBufferView;
  82645. };
  82646. meshes: {
  82647. [key: string]: IGLTFMesh;
  82648. };
  82649. lights: {
  82650. [key: string]: IGLTFLight;
  82651. };
  82652. cameras: {
  82653. [key: string]: IGLTFCamera;
  82654. };
  82655. nodes: {
  82656. [key: string]: IGLTFNode;
  82657. };
  82658. images: {
  82659. [key: string]: IGLTFImage;
  82660. };
  82661. textures: {
  82662. [key: string]: IGLTFTexture;
  82663. };
  82664. shaders: {
  82665. [key: string]: IGLTFShader;
  82666. };
  82667. programs: {
  82668. [key: string]: IGLTFProgram;
  82669. };
  82670. samplers: {
  82671. [key: string]: IGLTFSampler;
  82672. };
  82673. techniques: {
  82674. [key: string]: IGLTFTechnique;
  82675. };
  82676. materials: {
  82677. [key: string]: IGLTFMaterial;
  82678. };
  82679. animations: {
  82680. [key: string]: IGLTFAnimation;
  82681. };
  82682. skins: {
  82683. [key: string]: IGLTFSkins;
  82684. };
  82685. currentScene?: Object;
  82686. scenes: {
  82687. [key: string]: IGLTFScene;
  82688. };
  82689. extensionsUsed: string[];
  82690. extensionsRequired?: string[];
  82691. buffersCount: number;
  82692. shaderscount: number;
  82693. scene: Scene;
  82694. rootUrl: string;
  82695. loadedBufferCount: number;
  82696. loadedBufferViews: {
  82697. [name: string]: ArrayBufferView;
  82698. };
  82699. loadedShaderCount: number;
  82700. importOnlyMeshes: boolean;
  82701. importMeshesNames?: string[];
  82702. dummyNodes: Node[];
  82703. forAssetContainer: boolean;
  82704. }
  82705. /** @hidden */
  82706. export interface INodeToRoot {
  82707. bone: Bone;
  82708. node: IGLTFNode;
  82709. id: string;
  82710. }
  82711. /** @hidden */
  82712. export interface IJointNode {
  82713. node: IGLTFNode;
  82714. id: string;
  82715. }
  82716. }
  82717. declare module BABYLON.GLTF1 {
  82718. /**
  82719. * Utils functions for GLTF
  82720. * @hidden
  82721. */
  82722. export class GLTFUtils {
  82723. /**
  82724. * Sets the given "parameter" matrix
  82725. * @param scene: the Scene object
  82726. * @param source: the source node where to pick the matrix
  82727. * @param parameter: the GLTF technique parameter
  82728. * @param uniformName: the name of the shader's uniform
  82729. * @param shaderMaterial: the shader material
  82730. */
  82731. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82732. /**
  82733. * Sets the given "parameter" matrix
  82734. * @param shaderMaterial: the shader material
  82735. * @param uniform: the name of the shader's uniform
  82736. * @param value: the value of the uniform
  82737. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82738. */
  82739. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82740. /**
  82741. * Returns the wrap mode of the texture
  82742. * @param mode: the mode value
  82743. */
  82744. static GetWrapMode(mode: number): number;
  82745. /**
  82746. * Returns the byte stride giving an accessor
  82747. * @param accessor: the GLTF accessor objet
  82748. */
  82749. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82750. /**
  82751. * Returns the texture filter mode giving a mode value
  82752. * @param mode: the filter mode value
  82753. */
  82754. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82755. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82756. /**
  82757. * Returns a buffer from its accessor
  82758. * @param gltfRuntime: the GLTF runtime
  82759. * @param accessor: the GLTF accessor
  82760. */
  82761. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82762. /**
  82763. * Decodes a buffer view into a string
  82764. * @param view: the buffer view
  82765. */
  82766. static DecodeBufferToText(view: ArrayBufferView): string;
  82767. /**
  82768. * Returns the default material of gltf. Related to
  82769. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82770. * @param scene: the Babylon.js scene
  82771. */
  82772. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82773. private static _DefaultMaterial;
  82774. }
  82775. }
  82776. declare module BABYLON.GLTF1 {
  82777. /**
  82778. * Implementation of the base glTF spec
  82779. * @hidden
  82780. */
  82781. export class GLTFLoaderBase {
  82782. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82783. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82784. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82785. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82786. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82787. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82788. }
  82789. /**
  82790. * glTF V1 Loader
  82791. * @hidden
  82792. */
  82793. export class GLTFLoader implements IGLTFLoader {
  82794. static Extensions: {
  82795. [name: string]: GLTFLoaderExtension;
  82796. };
  82797. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82798. state: Nullable<GLTFLoaderState>;
  82799. dispose(): void;
  82800. private _importMeshAsync;
  82801. /**
  82802. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82803. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82804. * @param scene the scene the meshes should be added to
  82805. * @param forAssetContainer defines if the entities must be stored in the scene
  82806. * @param data gltf data containing information of the meshes in a loaded file
  82807. * @param rootUrl root url to load from
  82808. * @param onProgress event that fires when loading progress has occured
  82809. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82810. */
  82811. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  82812. private _loadAsync;
  82813. /**
  82814. * Imports all objects from a loaded gltf file and adds them to the scene
  82815. * @param scene the scene the objects should be added to
  82816. * @param data gltf data containing information of the meshes in a loaded file
  82817. * @param rootUrl root url to load from
  82818. * @param onProgress event that fires when loading progress has occured
  82819. * @returns a promise which completes when objects have been loaded to the scene
  82820. */
  82821. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82822. private _loadShadersAsync;
  82823. private _loadBuffersAsync;
  82824. private _createNodes;
  82825. }
  82826. /** @hidden */
  82827. export abstract class GLTFLoaderExtension {
  82828. private _name;
  82829. constructor(name: string);
  82830. get name(): string;
  82831. /**
  82832. * Defines an override for loading the runtime
  82833. * Return true to stop further extensions from loading the runtime
  82834. */
  82835. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82836. /**
  82837. * Defines an onverride for creating gltf runtime
  82838. * Return true to stop further extensions from creating the runtime
  82839. */
  82840. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82841. /**
  82842. * Defines an override for loading buffers
  82843. * Return true to stop further extensions from loading this buffer
  82844. */
  82845. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82846. /**
  82847. * Defines an override for loading texture buffers
  82848. * Return true to stop further extensions from loading this texture data
  82849. */
  82850. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82851. /**
  82852. * Defines an override for creating textures
  82853. * Return true to stop further extensions from loading this texture
  82854. */
  82855. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82856. /**
  82857. * Defines an override for loading shader strings
  82858. * Return true to stop further extensions from loading this shader data
  82859. */
  82860. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82861. /**
  82862. * Defines an override for loading materials
  82863. * Return true to stop further extensions from loading this material
  82864. */
  82865. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82866. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82867. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82868. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82869. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82870. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82871. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82872. private static LoadTextureBufferAsync;
  82873. private static CreateTextureAsync;
  82874. private static ApplyExtensions;
  82875. }
  82876. }
  82877. declare module BABYLON.GLTF1 {
  82878. /** @hidden */
  82879. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82880. private _bin;
  82881. constructor();
  82882. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82883. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82884. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82885. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82886. }
  82887. }
  82888. declare module BABYLON.GLTF1 {
  82889. /** @hidden */
  82890. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82891. constructor();
  82892. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82893. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82894. private _loadTexture;
  82895. }
  82896. }
  82897. declare module BABYLON.GLTF2.Loader {
  82898. /**
  82899. * Loader interface with an index field.
  82900. */
  82901. export interface IArrayItem {
  82902. /**
  82903. * The index of this item in the array.
  82904. */
  82905. index: number;
  82906. }
  82907. /**
  82908. * Loader interface with additional members.
  82909. */
  82910. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82911. /** @hidden */
  82912. _data?: Promise<ArrayBufferView>;
  82913. /** @hidden */
  82914. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82915. }
  82916. /**
  82917. * Loader interface with additional members.
  82918. */
  82919. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82920. }
  82921. /** @hidden */
  82922. export interface _IAnimationSamplerData {
  82923. input: Float32Array;
  82924. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82925. output: Float32Array;
  82926. }
  82927. /**
  82928. * Loader interface with additional members.
  82929. */
  82930. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82931. /** @hidden */
  82932. _data?: Promise<_IAnimationSamplerData>;
  82933. }
  82934. /**
  82935. * Loader interface with additional members.
  82936. */
  82937. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82938. channels: IAnimationChannel[];
  82939. samplers: IAnimationSampler[];
  82940. /** @hidden */
  82941. _babylonAnimationGroup?: AnimationGroup;
  82942. }
  82943. /**
  82944. * Loader interface with additional members.
  82945. */
  82946. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82947. /** @hidden */
  82948. _data?: Promise<ArrayBufferView>;
  82949. }
  82950. /**
  82951. * Loader interface with additional members.
  82952. */
  82953. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82954. /** @hidden */
  82955. _data?: Promise<ArrayBufferView>;
  82956. /** @hidden */
  82957. _babylonBuffer?: Promise<Buffer>;
  82958. }
  82959. /**
  82960. * Loader interface with additional members.
  82961. */
  82962. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82963. }
  82964. /**
  82965. * Loader interface with additional members.
  82966. */
  82967. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82968. /** @hidden */
  82969. _data?: Promise<ArrayBufferView>;
  82970. }
  82971. /**
  82972. * Loader interface with additional members.
  82973. */
  82974. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82975. }
  82976. /**
  82977. * Loader interface with additional members.
  82978. */
  82979. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82980. }
  82981. /**
  82982. * Loader interface with additional members.
  82983. */
  82984. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82985. baseColorTexture?: ITextureInfo;
  82986. metallicRoughnessTexture?: ITextureInfo;
  82987. }
  82988. /**
  82989. * Loader interface with additional members.
  82990. */
  82991. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82992. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82993. normalTexture?: IMaterialNormalTextureInfo;
  82994. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82995. emissiveTexture?: ITextureInfo;
  82996. /** @hidden */
  82997. _data?: {
  82998. [babylonDrawMode: number]: {
  82999. babylonMaterial: Material;
  83000. babylonMeshes: AbstractMesh[];
  83001. promise: Promise<void>;
  83002. };
  83003. };
  83004. }
  83005. /**
  83006. * Loader interface with additional members.
  83007. */
  83008. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  83009. primitives: IMeshPrimitive[];
  83010. }
  83011. /**
  83012. * Loader interface with additional members.
  83013. */
  83014. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  83015. /** @hidden */
  83016. _instanceData?: {
  83017. babylonSourceMesh: Mesh;
  83018. promise: Promise<any>;
  83019. };
  83020. }
  83021. /**
  83022. * Loader interface with additional members.
  83023. */
  83024. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  83025. /**
  83026. * The parent glTF node.
  83027. */
  83028. parent?: INode;
  83029. /** @hidden */
  83030. _babylonTransformNode?: TransformNode;
  83031. /** @hidden */
  83032. _primitiveBabylonMeshes?: AbstractMesh[];
  83033. /** @hidden */
  83034. _babylonBones?: Bone[];
  83035. /** @hidden */
  83036. _numMorphTargets?: number;
  83037. }
  83038. /** @hidden */
  83039. export interface _ISamplerData {
  83040. noMipMaps: boolean;
  83041. samplingMode: number;
  83042. wrapU: number;
  83043. wrapV: number;
  83044. }
  83045. /**
  83046. * Loader interface with additional members.
  83047. */
  83048. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  83049. /** @hidden */
  83050. _data?: _ISamplerData;
  83051. }
  83052. /**
  83053. * Loader interface with additional members.
  83054. */
  83055. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  83056. }
  83057. /**
  83058. * Loader interface with additional members.
  83059. */
  83060. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  83061. /** @hidden */
  83062. _data?: {
  83063. babylonSkeleton: Skeleton;
  83064. promise: Promise<void>;
  83065. };
  83066. }
  83067. /**
  83068. * Loader interface with additional members.
  83069. */
  83070. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  83071. /** @hidden */
  83072. _textureInfo: ITextureInfo;
  83073. }
  83074. /**
  83075. * Loader interface with additional members.
  83076. */
  83077. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  83078. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  83079. nonColorData?: boolean;
  83080. }
  83081. /**
  83082. * Loader interface with additional members.
  83083. */
  83084. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  83085. accessors?: IAccessor[];
  83086. animations?: IAnimation[];
  83087. buffers?: IBuffer[];
  83088. bufferViews?: IBufferView[];
  83089. cameras?: ICamera[];
  83090. images?: IImage[];
  83091. materials?: IMaterial[];
  83092. meshes?: IMesh[];
  83093. nodes?: INode[];
  83094. samplers?: ISampler[];
  83095. scenes?: IScene[];
  83096. skins?: ISkin[];
  83097. textures?: ITexture[];
  83098. }
  83099. }
  83100. declare module BABYLON.GLTF2 {
  83101. /**
  83102. * Interface for a glTF loader extension.
  83103. */
  83104. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  83105. /**
  83106. * Called after the loader state changes to LOADING.
  83107. */
  83108. onLoading?(): void;
  83109. /**
  83110. * Called after the loader state changes to READY.
  83111. */
  83112. onReady?(): void;
  83113. /**
  83114. * Define this method to modify the default behavior when loading scenes.
  83115. * @param context The context when loading the asset
  83116. * @param scene The glTF scene property
  83117. * @returns A promise that resolves when the load is complete or null if not handled
  83118. */
  83119. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  83120. /**
  83121. * Define this method to modify the default behavior when loading nodes.
  83122. * @param context The context when loading the asset
  83123. * @param node The glTF node property
  83124. * @param assign A function called synchronously after parsing the glTF properties
  83125. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  83126. */
  83127. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83128. /**
  83129. * Define this method to modify the default behavior when loading cameras.
  83130. * @param context The context when loading the asset
  83131. * @param camera The glTF camera property
  83132. * @param assign A function called synchronously after parsing the glTF properties
  83133. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  83134. */
  83135. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83136. /**
  83137. * @hidden
  83138. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  83139. * @param context The context when loading the asset
  83140. * @param primitive The glTF mesh primitive property
  83141. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  83142. */
  83143. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83144. /**
  83145. * @hidden
  83146. * Define this method to modify the default behavior when loading data for mesh primitives.
  83147. * @param context The context when loading the asset
  83148. * @param name The mesh name when loading the asset
  83149. * @param node The glTF node when loading the asset
  83150. * @param mesh The glTF mesh when loading the asset
  83151. * @param primitive The glTF mesh primitive property
  83152. * @param assign A function called synchronously after parsing the glTF properties
  83153. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83154. */
  83155. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83156. /**
  83157. * @hidden
  83158. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  83159. * @param context The context when loading the asset
  83160. * @param material The glTF material property
  83161. * @param assign A function called synchronously after parsing the glTF properties
  83162. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  83163. */
  83164. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83165. /**
  83166. * Define this method to modify the default behavior when creating materials.
  83167. * @param context The context when loading the asset
  83168. * @param material The glTF material property
  83169. * @param babylonDrawMode The draw mode for the Babylon material
  83170. * @returns The Babylon material or null if not handled
  83171. */
  83172. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83173. /**
  83174. * Define this method to modify the default behavior when loading material properties.
  83175. * @param context The context when loading the asset
  83176. * @param material The glTF material property
  83177. * @param babylonMaterial The Babylon material
  83178. * @returns A promise that resolves when the load is complete or null if not handled
  83179. */
  83180. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83181. /**
  83182. * Define this method to modify the default behavior when loading texture infos.
  83183. * @param context The context when loading the asset
  83184. * @param textureInfo The glTF texture info property
  83185. * @param assign A function called synchronously after parsing the glTF properties
  83186. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83187. */
  83188. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83189. /**
  83190. * @hidden
  83191. * Define this method to modify the default behavior when loading textures.
  83192. * @param context The context when loading the asset
  83193. * @param texture The glTF texture property
  83194. * @param assign A function called synchronously after parsing the glTF properties
  83195. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83196. */
  83197. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83198. /**
  83199. * Define this method to modify the default behavior when loading animations.
  83200. * @param context The context when loading the asset
  83201. * @param animation The glTF animation property
  83202. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  83203. */
  83204. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83205. /**
  83206. * @hidden
  83207. * Define this method to modify the default behavior when loading skins.
  83208. * @param context The context when loading the asset
  83209. * @param node The glTF node property
  83210. * @param skin The glTF skin property
  83211. * @returns A promise that resolves when the load is complete or null if not handled
  83212. */
  83213. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  83214. /**
  83215. * @hidden
  83216. * Define this method to modify the default behavior when loading uris.
  83217. * @param context The context when loading the asset
  83218. * @param property The glTF property associated with the uri
  83219. * @param uri The uri to load
  83220. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83221. */
  83222. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83223. /**
  83224. * Define this method to modify the default behavior when loading buffer views.
  83225. * @param context The context when loading the asset
  83226. * @param bufferView The glTF buffer view property
  83227. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83228. */
  83229. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  83230. /**
  83231. * Define this method to modify the default behavior when loading buffers.
  83232. * @param context The context when loading the asset
  83233. * @param buffer The glTF buffer property
  83234. * @param byteOffset The byte offset to load
  83235. * @param byteLength The byte length to load
  83236. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83237. */
  83238. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83239. }
  83240. }
  83241. declare module BABYLON.GLTF2 {
  83242. /**
  83243. * Helper class for working with arrays when loading the glTF asset
  83244. */
  83245. export class ArrayItem {
  83246. /**
  83247. * Gets an item from the given array.
  83248. * @param context The context when loading the asset
  83249. * @param array The array to get the item from
  83250. * @param index The index to the array
  83251. * @returns The array item
  83252. */
  83253. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  83254. /**
  83255. * Assign an `index` field to each item of the given array.
  83256. * @param array The array of items
  83257. */
  83258. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83259. }
  83260. /**
  83261. * The glTF 2.0 loader
  83262. */
  83263. export class GLTFLoader implements IGLTFLoader {
  83264. /** @hidden */
  83265. _completePromises: Promise<any>[];
  83266. /** @hidden */
  83267. _forAssetContainer: boolean;
  83268. /** Storage */
  83269. _babylonLights: Light[];
  83270. /** @hidden */
  83271. _disableInstancedMesh: number;
  83272. private _disposed;
  83273. private _parent;
  83274. private _state;
  83275. private _extensions;
  83276. private _rootUrl;
  83277. private _fileName;
  83278. private _uniqueRootUrl;
  83279. private _gltf;
  83280. private _bin;
  83281. private _babylonScene;
  83282. private _rootBabylonMesh;
  83283. private _defaultBabylonMaterialData;
  83284. private static _RegisteredExtensions;
  83285. /**
  83286. * The default glTF sampler.
  83287. */
  83288. static readonly DefaultSampler: ISampler;
  83289. /**
  83290. * Registers a loader extension.
  83291. * @param name The name of the loader extension.
  83292. * @param factory The factory function that creates the loader extension.
  83293. */
  83294. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83295. /**
  83296. * Unregisters a loader extension.
  83297. * @param name The name of the loader extension.
  83298. * @returns A boolean indicating whether the extension has been unregistered
  83299. */
  83300. static UnregisterExtension(name: string): boolean;
  83301. /**
  83302. * The loader state.
  83303. */
  83304. get state(): Nullable<GLTFLoaderState>;
  83305. /**
  83306. * The object that represents the glTF JSON.
  83307. */
  83308. get gltf(): IGLTF;
  83309. /**
  83310. * The BIN chunk of a binary glTF.
  83311. */
  83312. get bin(): Nullable<IDataBuffer>;
  83313. /**
  83314. * The parent file loader.
  83315. */
  83316. get parent(): GLTFFileLoader;
  83317. /**
  83318. * The Babylon scene when loading the asset.
  83319. */
  83320. get babylonScene(): Scene;
  83321. /**
  83322. * The root Babylon mesh when loading the asset.
  83323. */
  83324. get rootBabylonMesh(): Mesh;
  83325. /** @hidden */
  83326. constructor(parent: GLTFFileLoader);
  83327. /** @hidden */
  83328. dispose(): void;
  83329. /** @hidden */
  83330. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  83331. /** @hidden */
  83332. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83333. private _loadAsync;
  83334. private _loadData;
  83335. private _setupData;
  83336. private _loadExtensions;
  83337. private _checkExtensions;
  83338. private _setState;
  83339. private _createRootNode;
  83340. /**
  83341. * Loads a glTF scene.
  83342. * @param context The context when loading the asset
  83343. * @param scene The glTF scene property
  83344. * @returns A promise that resolves when the load is complete
  83345. */
  83346. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83347. private _forEachPrimitive;
  83348. private _getGeometries;
  83349. private _getMeshes;
  83350. private _getTransformNodes;
  83351. private _getSkeletons;
  83352. private _getAnimationGroups;
  83353. private _startAnimations;
  83354. /**
  83355. * Loads a glTF node.
  83356. * @param context The context when loading the asset
  83357. * @param node The glTF node property
  83358. * @param assign A function called synchronously after parsing the glTF properties
  83359. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83360. */
  83361. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83362. private _loadMeshAsync;
  83363. /**
  83364. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83365. * @param context The context when loading the asset
  83366. * @param name The mesh name when loading the asset
  83367. * @param node The glTF node when loading the asset
  83368. * @param mesh The glTF mesh when loading the asset
  83369. * @param primitive The glTF mesh primitive property
  83370. * @param assign A function called synchronously after parsing the glTF properties
  83371. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83372. */
  83373. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83374. private _loadVertexDataAsync;
  83375. private _createMorphTargets;
  83376. private _loadMorphTargetsAsync;
  83377. private _loadMorphTargetVertexDataAsync;
  83378. private static _LoadTransform;
  83379. private _loadSkinAsync;
  83380. private _loadBones;
  83381. private _loadBone;
  83382. private _loadSkinInverseBindMatricesDataAsync;
  83383. private _updateBoneMatrices;
  83384. private _getNodeMatrix;
  83385. /**
  83386. * Loads a glTF camera.
  83387. * @param context The context when loading the asset
  83388. * @param camera The glTF camera property
  83389. * @param assign A function called synchronously after parsing the glTF properties
  83390. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83391. */
  83392. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83393. private _loadAnimationsAsync;
  83394. /**
  83395. * Loads a glTF animation.
  83396. * @param context The context when loading the asset
  83397. * @param animation The glTF animation property
  83398. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83399. */
  83400. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83401. /**
  83402. * @hidden Loads a glTF animation channel.
  83403. * @param context The context when loading the asset
  83404. * @param animationContext The context of the animation when loading the asset
  83405. * @param animation The glTF animation property
  83406. * @param channel The glTF animation channel property
  83407. * @param babylonAnimationGroup The babylon animation group property
  83408. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83409. * @returns A void promise when the channel load is complete
  83410. */
  83411. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83412. private _loadAnimationSamplerAsync;
  83413. private _loadBufferAsync;
  83414. /**
  83415. * Loads a glTF buffer view.
  83416. * @param context The context when loading the asset
  83417. * @param bufferView The glTF buffer view property
  83418. * @returns A promise that resolves with the loaded data when the load is complete
  83419. */
  83420. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83421. private _loadAccessorAsync;
  83422. /** @hidden */
  83423. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83424. private _loadIndicesAccessorAsync;
  83425. private _loadVertexBufferViewAsync;
  83426. private _loadVertexAccessorAsync;
  83427. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83428. /** @hidden */
  83429. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83430. private _createDefaultMaterial;
  83431. /**
  83432. * Creates a Babylon material from a glTF material.
  83433. * @param context The context when loading the asset
  83434. * @param material The glTF material property
  83435. * @param babylonDrawMode The draw mode for the Babylon material
  83436. * @returns The Babylon material
  83437. */
  83438. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83439. /**
  83440. * Loads properties from a glTF material into a Babylon material.
  83441. * @param context The context when loading the asset
  83442. * @param material The glTF material property
  83443. * @param babylonMaterial The Babylon material
  83444. * @returns A promise that resolves when the load is complete
  83445. */
  83446. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83447. /**
  83448. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83449. * @param context The context when loading the asset
  83450. * @param material The glTF material property
  83451. * @param babylonMaterial The Babylon material
  83452. * @returns A promise that resolves when the load is complete
  83453. */
  83454. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83455. /**
  83456. * Loads the alpha properties from a glTF material into a Babylon material.
  83457. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83458. * @param context The context when loading the asset
  83459. * @param material The glTF material property
  83460. * @param babylonMaterial The Babylon material
  83461. */
  83462. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83463. /**
  83464. * Loads a glTF texture info.
  83465. * @param context The context when loading the asset
  83466. * @param textureInfo The glTF texture info property
  83467. * @param assign A function called synchronously after parsing the glTF properties
  83468. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83469. */
  83470. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83471. /** @hidden */
  83472. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83473. /** @hidden */
  83474. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83475. private _loadSampler;
  83476. /**
  83477. * Loads a glTF image.
  83478. * @param context The context when loading the asset
  83479. * @param image The glTF image property
  83480. * @returns A promise that resolves with the loaded data when the load is complete
  83481. */
  83482. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83483. /**
  83484. * Loads a glTF uri.
  83485. * @param context The context when loading the asset
  83486. * @param property The glTF property associated with the uri
  83487. * @param uri The base64 or relative uri
  83488. * @returns A promise that resolves with the loaded data when the load is complete
  83489. */
  83490. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83491. /**
  83492. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83493. * @param babylonObject the Babylon object with metadata
  83494. * @param pointer the JSON pointer
  83495. */
  83496. static AddPointerMetadata(babylonObject: {
  83497. metadata: any;
  83498. }, pointer: string): void;
  83499. private static _GetTextureWrapMode;
  83500. private static _GetTextureSamplingMode;
  83501. private static _GetTypedArrayConstructor;
  83502. private static _GetTypedArray;
  83503. private static _GetNumComponents;
  83504. private static _ValidateUri;
  83505. /** @hidden */
  83506. static _GetDrawMode(context: string, mode: number | undefined): number;
  83507. private _compileMaterialsAsync;
  83508. private _compileShadowGeneratorsAsync;
  83509. private _forEachExtensions;
  83510. private _applyExtensions;
  83511. private _extensionsOnLoading;
  83512. private _extensionsOnReady;
  83513. private _extensionsLoadSceneAsync;
  83514. private _extensionsLoadNodeAsync;
  83515. private _extensionsLoadCameraAsync;
  83516. private _extensionsLoadVertexDataAsync;
  83517. private _extensionsLoadMeshPrimitiveAsync;
  83518. private _extensionsLoadMaterialAsync;
  83519. private _extensionsCreateMaterial;
  83520. private _extensionsLoadMaterialPropertiesAsync;
  83521. private _extensionsLoadTextureInfoAsync;
  83522. private _extensionsLoadTextureAsync;
  83523. private _extensionsLoadAnimationAsync;
  83524. private _extensionsLoadSkinAsync;
  83525. private _extensionsLoadUriAsync;
  83526. private _extensionsLoadBufferViewAsync;
  83527. private _extensionsLoadBufferAsync;
  83528. /**
  83529. * Helper method called by a loader extension to load an glTF extension.
  83530. * @param context The context when loading the asset
  83531. * @param property The glTF property to load the extension from
  83532. * @param extensionName The name of the extension to load
  83533. * @param actionAsync The action to run
  83534. * @returns The promise returned by actionAsync or null if the extension does not exist
  83535. */
  83536. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83537. /**
  83538. * Helper method called by a loader extension to load a glTF extra.
  83539. * @param context The context when loading the asset
  83540. * @param property The glTF property to load the extra from
  83541. * @param extensionName The name of the extension to load
  83542. * @param actionAsync The action to run
  83543. * @returns The promise returned by actionAsync or null if the extra does not exist
  83544. */
  83545. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83546. /**
  83547. * Checks for presence of an extension.
  83548. * @param name The name of the extension to check
  83549. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83550. */
  83551. isExtensionUsed(name: string): boolean;
  83552. /**
  83553. * Increments the indentation level and logs a message.
  83554. * @param message The message to log
  83555. */
  83556. logOpen(message: string): void;
  83557. /**
  83558. * Decrements the indentation level.
  83559. */
  83560. logClose(): void;
  83561. /**
  83562. * Logs a message
  83563. * @param message The message to log
  83564. */
  83565. log(message: string): void;
  83566. /**
  83567. * Starts a performance counter.
  83568. * @param counterName The name of the performance counter
  83569. */
  83570. startPerformanceCounter(counterName: string): void;
  83571. /**
  83572. * Ends a performance counter.
  83573. * @param counterName The name of the performance counter
  83574. */
  83575. endPerformanceCounter(counterName: string): void;
  83576. }
  83577. }
  83578. declare module BABYLON.GLTF2.Loader.Extensions {
  83579. /** @hidden */
  83580. interface IEXTLightsImageBased_LightImageBased {
  83581. _babylonTexture?: BaseTexture;
  83582. _loaded?: Promise<void>;
  83583. }
  83584. /**
  83585. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83586. */
  83587. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83588. /**
  83589. * The name of this extension.
  83590. */
  83591. readonly name: string;
  83592. /**
  83593. * Defines whether this extension is enabled.
  83594. */
  83595. enabled: boolean;
  83596. private _loader;
  83597. private _lights?;
  83598. /** @hidden */
  83599. constructor(loader: GLTFLoader);
  83600. /** @hidden */
  83601. dispose(): void;
  83602. /** @hidden */
  83603. onLoading(): void;
  83604. /** @hidden */
  83605. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83606. private _loadLightAsync;
  83607. }
  83608. }
  83609. declare module BABYLON.GLTF2.Loader.Extensions {
  83610. /**
  83611. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83612. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83613. * !!! Experimental Extension Subject to Changes !!!
  83614. */
  83615. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83616. /**
  83617. * The name of this extension.
  83618. */
  83619. readonly name: string;
  83620. /**
  83621. * Defines whether this extension is enabled.
  83622. */
  83623. enabled: boolean;
  83624. private _loader;
  83625. /** @hidden */
  83626. constructor(loader: GLTFLoader);
  83627. /** @hidden */
  83628. dispose(): void;
  83629. /** @hidden */
  83630. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83631. }
  83632. }
  83633. declare module BABYLON.GLTF2.Loader.Extensions {
  83634. /**
  83635. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83636. */
  83637. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83638. /** The name of this extension. */
  83639. readonly name: string;
  83640. /** Defines whether this extension is enabled. */
  83641. enabled: boolean;
  83642. private _loader;
  83643. /** @hidden */
  83644. constructor(loader: GLTFLoader);
  83645. /** @hidden */
  83646. dispose(): void;
  83647. /** @hidden */
  83648. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83649. }
  83650. }
  83651. declare module BABYLON.GLTF2.Loader.Extensions {
  83652. /**
  83653. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83654. */
  83655. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83656. /**
  83657. * The name of this extension.
  83658. */
  83659. readonly name: string;
  83660. /**
  83661. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83662. */
  83663. dracoCompression?: DracoCompression;
  83664. /**
  83665. * Defines whether this extension is enabled.
  83666. */
  83667. enabled: boolean;
  83668. private _loader;
  83669. /** @hidden */
  83670. constructor(loader: GLTFLoader);
  83671. /** @hidden */
  83672. dispose(): void;
  83673. /** @hidden */
  83674. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83675. }
  83676. }
  83677. declare module BABYLON.GLTF2.Loader.Extensions {
  83678. /**
  83679. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83680. */
  83681. export class KHR_lights implements IGLTFLoaderExtension {
  83682. /**
  83683. * The name of this extension.
  83684. */
  83685. readonly name: string;
  83686. /**
  83687. * Defines whether this extension is enabled.
  83688. */
  83689. enabled: boolean;
  83690. private _loader;
  83691. private _lights?;
  83692. /** @hidden */
  83693. constructor(loader: GLTFLoader);
  83694. /** @hidden */
  83695. dispose(): void;
  83696. /** @hidden */
  83697. onLoading(): void;
  83698. /** @hidden */
  83699. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83700. }
  83701. }
  83702. declare module BABYLON.GLTF2.Loader.Extensions {
  83703. /**
  83704. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83705. */
  83706. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83707. /**
  83708. * The name of this extension.
  83709. */
  83710. readonly name: string;
  83711. /**
  83712. * Defines whether this extension is enabled.
  83713. */
  83714. enabled: boolean;
  83715. /**
  83716. * Defines a number that determines the order the extensions are applied.
  83717. */
  83718. order: number;
  83719. private _loader;
  83720. /** @hidden */
  83721. constructor(loader: GLTFLoader);
  83722. /** @hidden */
  83723. dispose(): void;
  83724. /** @hidden */
  83725. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83726. private _loadSpecularGlossinessPropertiesAsync;
  83727. }
  83728. }
  83729. declare module BABYLON.GLTF2.Loader.Extensions {
  83730. /**
  83731. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83732. */
  83733. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83734. /**
  83735. * The name of this extension.
  83736. */
  83737. readonly name: string;
  83738. /**
  83739. * Defines whether this extension is enabled.
  83740. */
  83741. enabled: boolean;
  83742. /**
  83743. * Defines a number that determines the order the extensions are applied.
  83744. */
  83745. order: number;
  83746. private _loader;
  83747. /** @hidden */
  83748. constructor(loader: GLTFLoader);
  83749. /** @hidden */
  83750. dispose(): void;
  83751. /** @hidden */
  83752. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83753. private _loadUnlitPropertiesAsync;
  83754. }
  83755. }
  83756. declare module BABYLON.GLTF2.Loader.Extensions {
  83757. /**
  83758. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  83759. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83760. */
  83761. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83762. /**
  83763. * The name of this extension.
  83764. */
  83765. readonly name: string;
  83766. /**
  83767. * Defines whether this extension is enabled.
  83768. */
  83769. enabled: boolean;
  83770. /**
  83771. * Defines a number that determines the order the extensions are applied.
  83772. */
  83773. order: number;
  83774. private _loader;
  83775. /** @hidden */
  83776. constructor(loader: GLTFLoader);
  83777. /** @hidden */
  83778. dispose(): void;
  83779. /** @hidden */
  83780. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83781. private _loadClearCoatPropertiesAsync;
  83782. }
  83783. }
  83784. declare module BABYLON.GLTF2.Loader.Extensions {
  83785. /**
  83786. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83787. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83788. * !!! Experimental Extension Subject to Changes !!!
  83789. */
  83790. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83791. /**
  83792. * The name of this extension.
  83793. */
  83794. readonly name: string;
  83795. /**
  83796. * Defines whether this extension is enabled.
  83797. */
  83798. enabled: boolean;
  83799. /**
  83800. * Defines a number that determines the order the extensions are applied.
  83801. */
  83802. order: number;
  83803. private _loader;
  83804. /** @hidden */
  83805. constructor(loader: GLTFLoader);
  83806. /** @hidden */
  83807. dispose(): void;
  83808. /** @hidden */
  83809. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83810. private _loadSheenPropertiesAsync;
  83811. }
  83812. }
  83813. declare module BABYLON.GLTF2.Loader.Extensions {
  83814. /**
  83815. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83816. * !!! Experimental Extension Subject to Changes !!!
  83817. */
  83818. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83819. /**
  83820. * The name of this extension.
  83821. */
  83822. readonly name: string;
  83823. /**
  83824. * Defines whether this extension is enabled.
  83825. */
  83826. enabled: boolean;
  83827. /**
  83828. * Defines a number that determines the order the extensions are applied.
  83829. */
  83830. order: number;
  83831. private _loader;
  83832. /** @hidden */
  83833. constructor(loader: GLTFLoader);
  83834. /** @hidden */
  83835. dispose(): void;
  83836. /** @hidden */
  83837. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83838. private _loadSpecularPropertiesAsync;
  83839. }
  83840. }
  83841. declare module BABYLON.GLTF2.Loader.Extensions {
  83842. /**
  83843. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83844. * !!! Experimental Extension Subject to Changes !!!
  83845. */
  83846. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83847. /**
  83848. * Default ior Value from the spec.
  83849. */
  83850. private static readonly _DEFAULT_IOR;
  83851. /**
  83852. * The name of this extension.
  83853. */
  83854. readonly name: string;
  83855. /**
  83856. * Defines whether this extension is enabled.
  83857. */
  83858. enabled: boolean;
  83859. /**
  83860. * Defines a number that determines the order the extensions are applied.
  83861. */
  83862. order: number;
  83863. private _loader;
  83864. /** @hidden */
  83865. constructor(loader: GLTFLoader);
  83866. /** @hidden */
  83867. dispose(): void;
  83868. /** @hidden */
  83869. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83870. private _loadIorPropertiesAsync;
  83871. }
  83872. }
  83873. declare module BABYLON.GLTF2.Loader.Extensions {
  83874. /**
  83875. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83876. * !!! Experimental Extension Subject to Changes !!!
  83877. */
  83878. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83879. /**
  83880. * The name of this extension.
  83881. */
  83882. readonly name: string;
  83883. /**
  83884. * Defines whether this extension is enabled.
  83885. */
  83886. enabled: boolean;
  83887. private _loader;
  83888. private _variants?;
  83889. /** @hidden */
  83890. constructor(loader: GLTFLoader);
  83891. /** @hidden */
  83892. dispose(): void;
  83893. /**
  83894. * Gets the list of available variant names for this asset.
  83895. * @param rootMesh The glTF root mesh
  83896. * @returns the list of all the variant names for this model
  83897. */
  83898. static GetAvailableVariants(rootMesh: Mesh): string[];
  83899. /**
  83900. * Gets the list of available variant names for this asset.
  83901. * @param rootMesh The glTF root mesh
  83902. * @returns the list of all the variant names for this model
  83903. */
  83904. getAvailableVariants(rootMesh: Mesh): string[];
  83905. /**
  83906. * Select a variant given a variant name or a list of variant names.
  83907. * @param rootMesh The glTF root mesh
  83908. * @param variantName The variant name(s) to select.
  83909. */
  83910. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83911. /**
  83912. * Select a variant given a variant name or a list of variant names.
  83913. * @param rootMesh The glTF root mesh
  83914. * @param variantName The variant name(s) to select.
  83915. */
  83916. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83917. /**
  83918. * Reset back to the original before selecting a variant.
  83919. * @param rootMesh The glTF root mesh
  83920. */
  83921. static Reset(rootMesh: Mesh): void;
  83922. /**
  83923. * Reset back to the original before selecting a variant.
  83924. * @param rootMesh The glTF root mesh
  83925. */
  83926. reset(rootMesh: Mesh): void;
  83927. /**
  83928. * Gets the last selected variant name(s) or null if original.
  83929. * @param rootMesh The glTF root mesh
  83930. * @returns The selected variant name(s).
  83931. */
  83932. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83933. /**
  83934. * Gets the last selected variant name(s) or null if original.
  83935. * @param rootMesh The glTF root mesh
  83936. * @returns The selected variant name(s).
  83937. */
  83938. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83939. private static _GetExtensionMetadata;
  83940. /** @hidden */
  83941. onLoading(): void;
  83942. /** @hidden */
  83943. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83944. }
  83945. }
  83946. declare module BABYLON.GLTF2.Loader.Extensions {
  83947. /**
  83948. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83949. * !!! Experimental Extension Subject to Changes !!!
  83950. */
  83951. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83952. /**
  83953. * The name of this extension.
  83954. */
  83955. readonly name: string;
  83956. /**
  83957. * Defines whether this extension is enabled.
  83958. */
  83959. enabled: boolean;
  83960. /**
  83961. * Defines a number that determines the order the extensions are applied.
  83962. */
  83963. order: number;
  83964. private _loader;
  83965. /** @hidden */
  83966. constructor(loader: GLTFLoader);
  83967. /** @hidden */
  83968. dispose(): void;
  83969. /** @hidden */
  83970. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83971. private _loadTransparentPropertiesAsync;
  83972. }
  83973. }
  83974. declare module BABYLON.GLTF2.Loader.Extensions {
  83975. /**
  83976. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83977. */
  83978. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83979. /**
  83980. * The name of this extension.
  83981. */
  83982. readonly name: string;
  83983. /**
  83984. * Defines whether this extension is enabled.
  83985. */
  83986. enabled: boolean;
  83987. /** @hidden */
  83988. constructor(loader: GLTFLoader);
  83989. /** @hidden */
  83990. dispose(): void;
  83991. }
  83992. }
  83993. declare module BABYLON.GLTF2.Loader.Extensions {
  83994. /**
  83995. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83996. * !!! Experimental Extension Subject to Changes !!!
  83997. */
  83998. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83999. /** The name of this extension. */
  84000. readonly name: string;
  84001. /** Defines whether this extension is enabled. */
  84002. enabled: boolean;
  84003. private _loader;
  84004. /** @hidden */
  84005. constructor(loader: GLTFLoader);
  84006. /** @hidden */
  84007. dispose(): void;
  84008. /** @hidden */
  84009. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84010. }
  84011. }
  84012. declare module BABYLON.GLTF2.Loader.Extensions {
  84013. /**
  84014. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  84015. */
  84016. export class KHR_texture_transform implements IGLTFLoaderExtension {
  84017. /**
  84018. * The name of this extension.
  84019. */
  84020. readonly name: string;
  84021. /**
  84022. * Defines whether this extension is enabled.
  84023. */
  84024. enabled: boolean;
  84025. private _loader;
  84026. /** @hidden */
  84027. constructor(loader: GLTFLoader);
  84028. /** @hidden */
  84029. dispose(): void;
  84030. /** @hidden */
  84031. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84032. }
  84033. }
  84034. declare module BABYLON.GLTF2.Loader.Extensions {
  84035. /**
  84036. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  84037. * !!! Experimental Extension Subject to Changes !!!
  84038. */
  84039. export class KHR_xmp implements IGLTFLoaderExtension {
  84040. /**
  84041. * The name of this extension.
  84042. */
  84043. readonly name: string;
  84044. /**
  84045. * Defines whether this extension is enabled.
  84046. */
  84047. enabled: boolean;
  84048. /**
  84049. * Defines a number that determines the order the extensions are applied.
  84050. */
  84051. order: number;
  84052. private _loader;
  84053. /** @hidden */
  84054. constructor(loader: GLTFLoader);
  84055. /** @hidden */
  84056. dispose(): void;
  84057. /**
  84058. * Called after the loader state changes to LOADING.
  84059. */
  84060. onLoading(): void;
  84061. }
  84062. }
  84063. declare module BABYLON.GLTF2.Loader.Extensions {
  84064. /**
  84065. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  84066. */
  84067. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  84068. /**
  84069. * The name of this extension.
  84070. */
  84071. readonly name: string;
  84072. /**
  84073. * Defines whether this extension is enabled.
  84074. */
  84075. enabled: boolean;
  84076. private _loader;
  84077. private _clips;
  84078. private _emitters;
  84079. /** @hidden */
  84080. constructor(loader: GLTFLoader);
  84081. /** @hidden */
  84082. dispose(): void;
  84083. /** @hidden */
  84084. onLoading(): void;
  84085. /** @hidden */
  84086. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84087. /** @hidden */
  84088. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84089. /** @hidden */
  84090. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  84091. private _loadClipAsync;
  84092. private _loadEmitterAsync;
  84093. private _getEventAction;
  84094. private _loadAnimationEventAsync;
  84095. }
  84096. }
  84097. declare module BABYLON.GLTF2.Loader.Extensions {
  84098. /**
  84099. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  84100. */
  84101. export class MSFT_lod implements IGLTFLoaderExtension {
  84102. /**
  84103. * The name of this extension.
  84104. */
  84105. readonly name: string;
  84106. /**
  84107. * Defines whether this extension is enabled.
  84108. */
  84109. enabled: boolean;
  84110. /**
  84111. * Defines a number that determines the order the extensions are applied.
  84112. */
  84113. order: number;
  84114. /**
  84115. * Maximum number of LODs to load, starting from the lowest LOD.
  84116. */
  84117. maxLODsToLoad: number;
  84118. /**
  84119. * Observable raised when all node LODs of one level are loaded.
  84120. * The event data is the index of the loaded LOD starting from zero.
  84121. * Dispose the loader to cancel the loading of the next level of LODs.
  84122. */
  84123. onNodeLODsLoadedObservable: Observable<number>;
  84124. /**
  84125. * Observable raised when all material LODs of one level are loaded.
  84126. * The event data is the index of the loaded LOD starting from zero.
  84127. * Dispose the loader to cancel the loading of the next level of LODs.
  84128. */
  84129. onMaterialLODsLoadedObservable: Observable<number>;
  84130. private _loader;
  84131. private _bufferLODs;
  84132. private _nodeIndexLOD;
  84133. private _nodeSignalLODs;
  84134. private _nodePromiseLODs;
  84135. private _nodeBufferLODs;
  84136. private _materialIndexLOD;
  84137. private _materialSignalLODs;
  84138. private _materialPromiseLODs;
  84139. private _materialBufferLODs;
  84140. /** @hidden */
  84141. constructor(loader: GLTFLoader);
  84142. /** @hidden */
  84143. dispose(): void;
  84144. /** @hidden */
  84145. onReady(): void;
  84146. /** @hidden */
  84147. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84148. /** @hidden */
  84149. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84150. /** @hidden */
  84151. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  84152. /** @hidden */
  84153. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  84154. /** @hidden */
  84155. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  84156. private _loadBufferLOD;
  84157. /**
  84158. * Gets an array of LOD properties from lowest to highest.
  84159. */
  84160. private _getLODs;
  84161. private _disposeTransformNode;
  84162. private _disposeMaterials;
  84163. }
  84164. }
  84165. declare module BABYLON.GLTF2.Loader.Extensions {
  84166. /** @hidden */
  84167. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  84168. readonly name: string;
  84169. enabled: boolean;
  84170. private _loader;
  84171. constructor(loader: GLTFLoader);
  84172. dispose(): void;
  84173. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84174. }
  84175. }
  84176. declare module BABYLON.GLTF2.Loader.Extensions {
  84177. /** @hidden */
  84178. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  84179. readonly name: string;
  84180. enabled: boolean;
  84181. private _loader;
  84182. constructor(loader: GLTFLoader);
  84183. dispose(): void;
  84184. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84185. }
  84186. }
  84187. declare module BABYLON.GLTF2.Loader.Extensions {
  84188. /**
  84189. * Store glTF extras (if present) in BJS objects' metadata
  84190. */
  84191. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  84192. /**
  84193. * The name of this extension.
  84194. */
  84195. readonly name: string;
  84196. /**
  84197. * Defines whether this extension is enabled.
  84198. */
  84199. enabled: boolean;
  84200. private _loader;
  84201. private _assignExtras;
  84202. /** @hidden */
  84203. constructor(loader: GLTFLoader);
  84204. /** @hidden */
  84205. dispose(): void;
  84206. /** @hidden */
  84207. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84208. /** @hidden */
  84209. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  84210. /** @hidden */
  84211. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  84212. }
  84213. }
  84214. declare module BABYLON {
  84215. /**
  84216. * Class reading and parsing the MTL file bundled with the obj file.
  84217. */
  84218. export class MTLFileLoader {
  84219. /**
  84220. * Invert Y-Axis of referenced textures on load
  84221. */
  84222. static INVERT_TEXTURE_Y: boolean;
  84223. /**
  84224. * All material loaded from the mtl will be set here
  84225. */
  84226. materials: StandardMaterial[];
  84227. /**
  84228. * This function will read the mtl file and create each material described inside
  84229. * This function could be improve by adding :
  84230. * -some component missing (Ni, Tf...)
  84231. * -including the specific options available
  84232. *
  84233. * @param scene defines the scene the material will be created in
  84234. * @param data defines the mtl data to parse
  84235. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  84236. * @param forAssetContainer defines if the material should be registered in the scene
  84237. */
  84238. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  84239. /**
  84240. * Gets the texture for the material.
  84241. *
  84242. * If the material is imported from input file,
  84243. * We sanitize the url to ensure it takes the textre from aside the material.
  84244. *
  84245. * @param rootUrl The root url to load from
  84246. * @param value The value stored in the mtl
  84247. * @return The Texture
  84248. */
  84249. private static _getTexture;
  84250. }
  84251. }
  84252. declare module BABYLON {
  84253. /**
  84254. * Options for loading OBJ/MTL files
  84255. */
  84256. type MeshLoadOptions = {
  84257. /**
  84258. * Defines if UVs are optimized by default during load.
  84259. */
  84260. OptimizeWithUV: boolean;
  84261. /**
  84262. * Defines custom scaling of UV coordinates of loaded meshes.
  84263. */
  84264. UVScaling: Vector2;
  84265. /**
  84266. * Invert model on y-axis (does a model scaling inversion)
  84267. */
  84268. InvertY: boolean;
  84269. /**
  84270. * Invert Y-Axis of referenced textures on load
  84271. */
  84272. InvertTextureY: boolean;
  84273. /**
  84274. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84275. */
  84276. ImportVertexColors: boolean;
  84277. /**
  84278. * Compute the normals for the model, even if normals are present in the file.
  84279. */
  84280. ComputeNormals: boolean;
  84281. /**
  84282. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84283. */
  84284. SkipMaterials: boolean;
  84285. /**
  84286. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84287. */
  84288. MaterialLoadingFailsSilently: boolean;
  84289. };
  84290. /**
  84291. * OBJ file type loader.
  84292. * This is a babylon scene loader plugin.
  84293. */
  84294. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84295. /**
  84296. * Defines if UVs are optimized by default during load.
  84297. */
  84298. static OPTIMIZE_WITH_UV: boolean;
  84299. /**
  84300. * Invert model on y-axis (does a model scaling inversion)
  84301. */
  84302. static INVERT_Y: boolean;
  84303. /**
  84304. * Invert Y-Axis of referenced textures on load
  84305. */
  84306. static get INVERT_TEXTURE_Y(): boolean;
  84307. static set INVERT_TEXTURE_Y(value: boolean);
  84308. /**
  84309. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84310. */
  84311. static IMPORT_VERTEX_COLORS: boolean;
  84312. /**
  84313. * Compute the normals for the model, even if normals are present in the file.
  84314. */
  84315. static COMPUTE_NORMALS: boolean;
  84316. /**
  84317. * Defines custom scaling of UV coordinates of loaded meshes.
  84318. */
  84319. static UV_SCALING: Vector2;
  84320. /**
  84321. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84322. */
  84323. static SKIP_MATERIALS: boolean;
  84324. /**
  84325. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84326. *
  84327. * Defaults to true for backwards compatibility.
  84328. */
  84329. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84330. /**
  84331. * Defines the name of the plugin.
  84332. */
  84333. name: string;
  84334. /**
  84335. * Defines the extension the plugin is able to load.
  84336. */
  84337. extensions: string;
  84338. /** @hidden */
  84339. obj: RegExp;
  84340. /** @hidden */
  84341. group: RegExp;
  84342. /** @hidden */
  84343. mtllib: RegExp;
  84344. /** @hidden */
  84345. usemtl: RegExp;
  84346. /** @hidden */
  84347. smooth: RegExp;
  84348. /** @hidden */
  84349. vertexPattern: RegExp;
  84350. /** @hidden */
  84351. normalPattern: RegExp;
  84352. /** @hidden */
  84353. uvPattern: RegExp;
  84354. /** @hidden */
  84355. facePattern1: RegExp;
  84356. /** @hidden */
  84357. facePattern2: RegExp;
  84358. /** @hidden */
  84359. facePattern3: RegExp;
  84360. /** @hidden */
  84361. facePattern4: RegExp;
  84362. /** @hidden */
  84363. facePattern5: RegExp;
  84364. private _forAssetContainer;
  84365. private _meshLoadOptions;
  84366. /**
  84367. * Creates loader for .OBJ files
  84368. *
  84369. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84370. */
  84371. constructor(meshLoadOptions?: MeshLoadOptions);
  84372. private static get currentMeshLoadOptions();
  84373. /**
  84374. * Calls synchronously the MTL file attached to this obj.
  84375. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84376. * Without this function materials are not displayed in the first frame (but displayed after).
  84377. * In consequence it is impossible to get material information in your HTML file
  84378. *
  84379. * @param url The URL of the MTL file
  84380. * @param rootUrl
  84381. * @param onSuccess Callback function to be called when the MTL file is loaded
  84382. * @private
  84383. */
  84384. private _loadMTL;
  84385. /**
  84386. * Instantiates a OBJ file loader plugin.
  84387. * @returns the created plugin
  84388. */
  84389. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84390. /**
  84391. * If the data string can be loaded directly.
  84392. *
  84393. * @param data string containing the file data
  84394. * @returns if the data can be loaded directly
  84395. */
  84396. canDirectLoad(data: string): boolean;
  84397. /**
  84398. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84399. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84400. * @param scene the scene the meshes should be added to
  84401. * @param data the OBJ data to load
  84402. * @param rootUrl root url to load from
  84403. * @param onProgress event that fires when loading progress has occured
  84404. * @param fileName Defines the name of the file to load
  84405. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84406. */
  84407. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  84408. meshes: AbstractMesh[];
  84409. particleSystems: IParticleSystem[];
  84410. skeletons: Skeleton[];
  84411. animationGroups: AnimationGroup[];
  84412. }>;
  84413. /**
  84414. * Imports all objects from the loaded OBJ data and adds them to the scene
  84415. * @param scene the scene the objects should be added to
  84416. * @param data the OBJ data to load
  84417. * @param rootUrl root url to load from
  84418. * @param onProgress event that fires when loading progress has occured
  84419. * @param fileName Defines the name of the file to load
  84420. * @returns a promise which completes when objects have been loaded to the scene
  84421. */
  84422. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84423. /**
  84424. * Load into an asset container.
  84425. * @param scene The scene to load into
  84426. * @param data The data to import
  84427. * @param rootUrl The root url for scene and resources
  84428. * @param onProgress The callback when the load progresses
  84429. * @param fileName Defines the name of the file to load
  84430. * @returns The loaded asset container
  84431. */
  84432. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84433. /**
  84434. * Read the OBJ file and create an Array of meshes.
  84435. * Each mesh contains all information given by the OBJ and the MTL file.
  84436. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84437. *
  84438. * @param meshesNames
  84439. * @param scene Scene The scene where are displayed the data
  84440. * @param data String The content of the obj file
  84441. * @param rootUrl String The path to the folder
  84442. * @returns Array<AbstractMesh>
  84443. * @private
  84444. */
  84445. private _parseSolid;
  84446. }
  84447. }
  84448. declare module BABYLON {
  84449. /**
  84450. * STL file type loader.
  84451. * This is a babylon scene loader plugin.
  84452. */
  84453. export class STLFileLoader implements ISceneLoaderPlugin {
  84454. /** @hidden */
  84455. solidPattern: RegExp;
  84456. /** @hidden */
  84457. facetsPattern: RegExp;
  84458. /** @hidden */
  84459. normalPattern: RegExp;
  84460. /** @hidden */
  84461. vertexPattern: RegExp;
  84462. /**
  84463. * Defines the name of the plugin.
  84464. */
  84465. name: string;
  84466. /**
  84467. * Defines the extensions the stl loader is able to load.
  84468. * force data to come in as an ArrayBuffer
  84469. * we'll convert to string if it looks like it's an ASCII .stl
  84470. */
  84471. extensions: ISceneLoaderPluginExtensions;
  84472. /**
  84473. * Import meshes into a scene.
  84474. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84475. * @param scene The scene to import into
  84476. * @param data The data to import
  84477. * @param rootUrl The root url for scene and resources
  84478. * @param meshes The meshes array to import into
  84479. * @param particleSystems The particle systems array to import into
  84480. * @param skeletons The skeletons array to import into
  84481. * @param onError The callback when import fails
  84482. * @returns True if successful or false otherwise
  84483. */
  84484. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84485. /**
  84486. * Load into a scene.
  84487. * @param scene The scene to load into
  84488. * @param data The data to import
  84489. * @param rootUrl The root url for scene and resources
  84490. * @param onError The callback when import fails
  84491. * @returns true if successful or false otherwise
  84492. */
  84493. load(scene: Scene, data: any, rootUrl: string): boolean;
  84494. /**
  84495. * Load into an asset container.
  84496. * @param scene The scene to load into
  84497. * @param data The data to import
  84498. * @param rootUrl The root url for scene and resources
  84499. * @param onError The callback when import fails
  84500. * @returns The loaded asset container
  84501. */
  84502. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84503. private _isBinary;
  84504. private _parseBinary;
  84505. private _parseASCII;
  84506. }
  84507. }
  84508. declare module BABYLON {
  84509. /**
  84510. * Class for generating OBJ data from a Babylon scene.
  84511. */
  84512. export class OBJExport {
  84513. /**
  84514. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84515. * @param mesh defines the list of meshes to serialize
  84516. * @param materials defines if materials should be exported
  84517. * @param matlibname defines the name of the associated mtl file
  84518. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84519. * @returns the OBJ content
  84520. */
  84521. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84522. /**
  84523. * Exports the material(s) of a mesh in .MTL file format (text)
  84524. * @param mesh defines the mesh to extract the material from
  84525. * @returns the mtl content
  84526. */
  84527. static MTL(mesh: Mesh): string;
  84528. }
  84529. }
  84530. declare module BABYLON {
  84531. /** @hidden */
  84532. export var __IGLTFExporterExtension: number;
  84533. /**
  84534. * Interface for extending the exporter
  84535. * @hidden
  84536. */
  84537. export interface IGLTFExporterExtension {
  84538. /**
  84539. * The name of this extension
  84540. */
  84541. readonly name: string;
  84542. /**
  84543. * Defines whether this extension is enabled
  84544. */
  84545. enabled: boolean;
  84546. /**
  84547. * Defines whether this extension is required
  84548. */
  84549. required: boolean;
  84550. }
  84551. }
  84552. declare module BABYLON.GLTF2.Exporter {
  84553. /** @hidden */
  84554. export var __IGLTFExporterExtensionV2: number;
  84555. /**
  84556. * Interface for a glTF exporter extension
  84557. * @hidden
  84558. */
  84559. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84560. /**
  84561. * Define this method to modify the default behavior before exporting a texture
  84562. * @param context The context when loading the asset
  84563. * @param babylonTexture The Babylon.js texture
  84564. * @param mimeType The mime-type of the generated image
  84565. * @returns A promise that resolves with the exported texture
  84566. */
  84567. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84568. /**
  84569. * Define this method to get notified when a texture info is created
  84570. * @param context The context when loading the asset
  84571. * @param textureInfo The glTF texture info
  84572. * @param babylonTexture The Babylon.js texture
  84573. */
  84574. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84575. /**
  84576. * Define this method to modify the default behavior when exporting texture info
  84577. * @param context The context when loading the asset
  84578. * @param meshPrimitive glTF mesh primitive
  84579. * @param babylonSubMesh Babylon submesh
  84580. * @param binaryWriter glTF serializer binary writer instance
  84581. * @returns nullable IMeshPrimitive promise
  84582. */
  84583. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84584. /**
  84585. * Define this method to modify the default behavior when exporting a node
  84586. * @param context The context when exporting the node
  84587. * @param node glTF node
  84588. * @param babylonNode BabylonJS node
  84589. * @returns nullable INode promise
  84590. */
  84591. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84592. [key: number]: number;
  84593. }): Promise<Nullable<INode>>;
  84594. /**
  84595. * Define this method to modify the default behavior when exporting a material
  84596. * @param material glTF material
  84597. * @param babylonMaterial BabylonJS material
  84598. * @returns nullable IMaterial promise
  84599. */
  84600. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84601. /**
  84602. * Define this method to return additional textures to export from a material
  84603. * @param material glTF material
  84604. * @param babylonMaterial BabylonJS material
  84605. * @returns List of textures
  84606. */
  84607. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84608. /** Gets a boolean indicating that this extension was used */
  84609. wasUsed: boolean;
  84610. /** Gets a boolean indicating that this extension is required for the file to work */
  84611. required: boolean;
  84612. /**
  84613. * Called after the exporter state changes to EXPORTING
  84614. */
  84615. onExporting?(): void;
  84616. }
  84617. }
  84618. declare module BABYLON.GLTF2.Exporter {
  84619. /**
  84620. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84621. * @hidden
  84622. */
  84623. export class _GLTFMaterialExporter {
  84624. /**
  84625. * Represents the dielectric specular values for R, G and B
  84626. */
  84627. private static readonly _DielectricSpecular;
  84628. /**
  84629. * Allows the maximum specular power to be defined for material calculations
  84630. */
  84631. private static readonly _MaxSpecularPower;
  84632. /**
  84633. * Mapping to store textures
  84634. */
  84635. private _textureMap;
  84636. /**
  84637. * Numeric tolerance value
  84638. */
  84639. private static readonly _Epsilon;
  84640. /**
  84641. * Reference to the glTF Exporter
  84642. */
  84643. private _exporter;
  84644. constructor(exporter: _Exporter);
  84645. /**
  84646. * Specifies if two colors are approximately equal in value
  84647. * @param color1 first color to compare to
  84648. * @param color2 second color to compare to
  84649. * @param epsilon threshold value
  84650. */
  84651. private static FuzzyEquals;
  84652. /**
  84653. * Gets the materials from a Babylon scene and converts them to glTF materials
  84654. * @param scene babylonjs scene
  84655. * @param mimeType texture mime type
  84656. * @param images array of images
  84657. * @param textures array of textures
  84658. * @param materials array of materials
  84659. * @param imageData mapping of texture names to base64 textures
  84660. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84661. */
  84662. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84663. /**
  84664. * Makes a copy of the glTF material without the texture parameters
  84665. * @param originalMaterial original glTF material
  84666. * @returns glTF material without texture parameters
  84667. */
  84668. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84669. /**
  84670. * Specifies if the material has any texture parameters present
  84671. * @param material glTF Material
  84672. * @returns boolean specifying if texture parameters are present
  84673. */
  84674. _hasTexturesPresent(material: IMaterial): boolean;
  84675. /**
  84676. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84677. * @param babylonStandardMaterial
  84678. * @returns glTF Metallic Roughness Material representation
  84679. */
  84680. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84681. /**
  84682. * Computes the metallic factor
  84683. * @param diffuse diffused value
  84684. * @param specular specular value
  84685. * @param oneMinusSpecularStrength one minus the specular strength
  84686. * @returns metallic value
  84687. */
  84688. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84689. /**
  84690. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84691. * @param glTFMaterial glTF material
  84692. * @param babylonMaterial Babylon material
  84693. */
  84694. private static _SetAlphaMode;
  84695. /**
  84696. * Converts a Babylon Standard Material to a glTF Material
  84697. * @param babylonStandardMaterial BJS Standard Material
  84698. * @param mimeType mime type to use for the textures
  84699. * @param images array of glTF image interfaces
  84700. * @param textures array of glTF texture interfaces
  84701. * @param materials array of glTF material interfaces
  84702. * @param imageData map of image file name to data
  84703. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84704. */
  84705. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84706. private _finishMaterial;
  84707. /**
  84708. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84709. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84710. * @param mimeType mime type to use for the textures
  84711. * @param images array of glTF image interfaces
  84712. * @param textures array of glTF texture interfaces
  84713. * @param materials array of glTF material interfaces
  84714. * @param imageData map of image file name to data
  84715. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84716. */
  84717. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84718. /**
  84719. * Converts an image typed array buffer to a base64 image
  84720. * @param buffer typed array buffer
  84721. * @param width width of the image
  84722. * @param height height of the image
  84723. * @param mimeType mimetype of the image
  84724. * @returns base64 image string
  84725. */
  84726. private _createBase64FromCanvasAsync;
  84727. /**
  84728. * Generates a white texture based on the specified width and height
  84729. * @param width width of the texture in pixels
  84730. * @param height height of the texture in pixels
  84731. * @param scene babylonjs scene
  84732. * @returns white texture
  84733. */
  84734. private _createWhiteTexture;
  84735. /**
  84736. * 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
  84737. * @param texture1 first texture to resize
  84738. * @param texture2 second texture to resize
  84739. * @param scene babylonjs scene
  84740. * @returns resized textures or null
  84741. */
  84742. private _resizeTexturesToSameDimensions;
  84743. /**
  84744. * Converts an array of pixels to a Float32Array
  84745. * Throws an error if the pixel format is not supported
  84746. * @param pixels - array buffer containing pixel values
  84747. * @returns Float32 of pixels
  84748. */
  84749. private _convertPixelArrayToFloat32;
  84750. /**
  84751. * Convert Specular Glossiness Textures to Metallic Roughness
  84752. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84753. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84754. * @param diffuseTexture texture used to store diffuse information
  84755. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84756. * @param factors specular glossiness material factors
  84757. * @param mimeType the mime type to use for the texture
  84758. * @returns pbr metallic roughness interface or null
  84759. */
  84760. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84761. /**
  84762. * Converts specular glossiness material properties to metallic roughness
  84763. * @param specularGlossiness interface with specular glossiness material properties
  84764. * @returns interface with metallic roughness material properties
  84765. */
  84766. private _convertSpecularGlossinessToMetallicRoughness;
  84767. /**
  84768. * Calculates the surface reflectance, independent of lighting conditions
  84769. * @param color Color source to calculate brightness from
  84770. * @returns number representing the perceived brightness, or zero if color is undefined
  84771. */
  84772. private _getPerceivedBrightness;
  84773. /**
  84774. * Returns the maximum color component value
  84775. * @param color
  84776. * @returns maximum color component value, or zero if color is null or undefined
  84777. */
  84778. private _getMaxComponent;
  84779. /**
  84780. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84781. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84782. * @param mimeType mime type to use for the textures
  84783. * @param images array of glTF image interfaces
  84784. * @param textures array of glTF texture interfaces
  84785. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84786. * @param imageData map of image file name to data
  84787. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84788. * @returns glTF PBR Metallic Roughness factors
  84789. */
  84790. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84791. private _getGLTFTextureSampler;
  84792. private _getGLTFTextureWrapMode;
  84793. private _getGLTFTextureWrapModesSampler;
  84794. /**
  84795. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84796. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84797. * @param mimeType mime type to use for the textures
  84798. * @param images array of glTF image interfaces
  84799. * @param textures array of glTF texture interfaces
  84800. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84801. * @param imageData map of image file name to data
  84802. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84803. * @returns glTF PBR Metallic Roughness factors
  84804. */
  84805. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84806. /**
  84807. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84808. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84809. * @param mimeType mime type to use for the textures
  84810. * @param images array of glTF image interfaces
  84811. * @param textures array of glTF texture interfaces
  84812. * @param materials array of glTF material interfaces
  84813. * @param imageData map of image file name to data
  84814. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84815. */
  84816. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84817. private setMetallicRoughnessPbrMaterial;
  84818. private getPixelsFromTexture;
  84819. /**
  84820. * Extracts a texture from a Babylon texture into file data and glTF data
  84821. * @param babylonTexture Babylon texture to extract
  84822. * @param mimeType Mime Type of the babylonTexture
  84823. * @return glTF texture info, or null if the texture format is not supported
  84824. */
  84825. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84826. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84827. /**
  84828. * Builds a texture from base64 string
  84829. * @param base64Texture base64 texture string
  84830. * @param baseTextureName Name to use for the texture
  84831. * @param mimeType image mime type for the texture
  84832. * @param images array of images
  84833. * @param textures array of textures
  84834. * @param imageData map of image data
  84835. * @returns glTF texture info, or null if the texture format is not supported
  84836. */
  84837. private _getTextureInfoFromBase64;
  84838. }
  84839. }
  84840. declare module BABYLON {
  84841. /**
  84842. * Class for holding and downloading glTF file data
  84843. */
  84844. export class GLTFData {
  84845. /**
  84846. * Object which contains the file name as the key and its data as the value
  84847. */
  84848. glTFFiles: {
  84849. [fileName: string]: string | Blob;
  84850. };
  84851. /**
  84852. * Initializes the glTF file object
  84853. */
  84854. constructor();
  84855. /**
  84856. * Downloads the glTF data as files based on their names and data
  84857. */
  84858. downloadFiles(): void;
  84859. }
  84860. }
  84861. declare module BABYLON {
  84862. /**
  84863. * Holds a collection of exporter options and parameters
  84864. */
  84865. export interface IExportOptions {
  84866. /**
  84867. * Function which indicates whether a babylon node should be exported or not
  84868. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84869. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84870. */
  84871. shouldExportNode?(node: Node): boolean;
  84872. /**
  84873. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84874. * @param metadata source metadata to read from
  84875. * @returns the data to store to glTF node extras
  84876. */
  84877. metadataSelector?(metadata: any): any;
  84878. /**
  84879. * The sample rate to bake animation curves
  84880. */
  84881. animationSampleRate?: number;
  84882. /**
  84883. * Begin serialization without waiting for the scene to be ready
  84884. */
  84885. exportWithoutWaitingForScene?: boolean;
  84886. /**
  84887. * Indicates if coordinate system swapping root nodes should be included in export
  84888. */
  84889. includeCoordinateSystemConversionNodes?: boolean;
  84890. }
  84891. /**
  84892. * Class for generating glTF data from a Babylon scene.
  84893. */
  84894. export class GLTF2Export {
  84895. /**
  84896. * Exports the geometry of the scene to .gltf file format asynchronously
  84897. * @param scene Babylon scene with scene hierarchy information
  84898. * @param filePrefix File prefix to use when generating the glTF file
  84899. * @param options Exporter options
  84900. * @returns Returns an object with a .gltf file and associates texture names
  84901. * as keys and their data and paths as values
  84902. */
  84903. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84904. private static _PreExportAsync;
  84905. private static _PostExportAsync;
  84906. /**
  84907. * Exports the geometry of the scene to .glb file format asychronously
  84908. * @param scene Babylon scene with scene hierarchy information
  84909. * @param filePrefix File prefix to use when generating glb file
  84910. * @param options Exporter options
  84911. * @returns Returns an object with a .glb filename as key and data as value
  84912. */
  84913. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84914. }
  84915. }
  84916. declare module BABYLON.GLTF2.Exporter {
  84917. /**
  84918. * @hidden
  84919. */
  84920. export class _GLTFUtilities {
  84921. /**
  84922. * Creates a buffer view based on the supplied arguments
  84923. * @param bufferIndex index value of the specified buffer
  84924. * @param byteOffset byte offset value
  84925. * @param byteLength byte length of the bufferView
  84926. * @param byteStride byte distance between conequential elements
  84927. * @param name name of the buffer view
  84928. * @returns bufferView for glTF
  84929. */
  84930. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84931. /**
  84932. * Creates an accessor based on the supplied arguments
  84933. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84934. * @param name The name of the accessor
  84935. * @param type The type of the accessor
  84936. * @param componentType The datatype of components in the attribute
  84937. * @param count The number of attributes referenced by this accessor
  84938. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84939. * @param min Minimum value of each component in this attribute
  84940. * @param max Maximum value of each component in this attribute
  84941. * @returns accessor for glTF
  84942. */
  84943. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84944. /**
  84945. * Calculates the minimum and maximum values of an array of position floats
  84946. * @param positions Positions array of a mesh
  84947. * @param vertexStart Starting vertex offset to calculate min and max values
  84948. * @param vertexCount Number of vertices to check for min and max values
  84949. * @returns min number array and max number array
  84950. */
  84951. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84952. min: number[];
  84953. max: number[];
  84954. };
  84955. /**
  84956. * Converts a new right-handed Vector3
  84957. * @param vector vector3 array
  84958. * @returns right-handed Vector3
  84959. */
  84960. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84961. /**
  84962. * Converts a Vector3 to right-handed
  84963. * @param vector Vector3 to convert to right-handed
  84964. */
  84965. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84966. /**
  84967. * Converts a three element number array to right-handed
  84968. * @param vector number array to convert to right-handed
  84969. */
  84970. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84971. /**
  84972. * Converts a new right-handed Vector3
  84973. * @param vector vector3 array
  84974. * @returns right-handed Vector3
  84975. */
  84976. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84977. /**
  84978. * Converts a Vector3 to right-handed
  84979. * @param vector Vector3 to convert to right-handed
  84980. */
  84981. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84982. /**
  84983. * Converts a three element number array to right-handed
  84984. * @param vector number array to convert to right-handed
  84985. */
  84986. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84987. /**
  84988. * Converts a Vector4 to right-handed
  84989. * @param vector Vector4 to convert to right-handed
  84990. */
  84991. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84992. /**
  84993. * Converts a Vector4 to right-handed
  84994. * @param vector Vector4 to convert to right-handed
  84995. */
  84996. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84997. /**
  84998. * Converts a Quaternion to right-handed
  84999. * @param quaternion Source quaternion to convert to right-handed
  85000. */
  85001. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  85002. /**
  85003. * Converts a Quaternion to right-handed
  85004. * @param quaternion Source quaternion to convert to right-handed
  85005. */
  85006. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  85007. static _NormalizeTangentFromRef(tangent: Vector4): void;
  85008. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  85009. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  85010. }
  85011. }
  85012. declare module BABYLON.GLTF2.Exporter {
  85013. /**
  85014. * Converts Babylon Scene into glTF 2.0.
  85015. * @hidden
  85016. */
  85017. export class _Exporter {
  85018. /**
  85019. * Stores the glTF to export
  85020. */
  85021. _glTF: IGLTF;
  85022. /**
  85023. * Stores all generated buffer views, which represents views into the main glTF buffer data
  85024. */
  85025. _bufferViews: IBufferView[];
  85026. /**
  85027. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  85028. */
  85029. _accessors: IAccessor[];
  85030. /**
  85031. * Stores all the generated nodes, which contains transform and/or mesh information per node
  85032. */
  85033. _nodes: INode[];
  85034. /**
  85035. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  85036. */
  85037. private _scenes;
  85038. /**
  85039. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  85040. */
  85041. private _meshes;
  85042. /**
  85043. * Stores all the generated material information, which represents the appearance of each primitive
  85044. */
  85045. _materials: IMaterial[];
  85046. _materialMap: {
  85047. [materialID: number]: number;
  85048. };
  85049. /**
  85050. * Stores all the generated texture information, which is referenced by glTF materials
  85051. */
  85052. _textures: ITexture[];
  85053. /**
  85054. * Stores all the generated image information, which is referenced by glTF textures
  85055. */
  85056. _images: IImage[];
  85057. /**
  85058. * Stores all the texture samplers
  85059. */
  85060. _samplers: ISampler[];
  85061. /**
  85062. * Stores all the generated glTF skins
  85063. */
  85064. _skins: ISkin[];
  85065. /**
  85066. * Stores all the generated animation samplers, which is referenced by glTF animations
  85067. */
  85068. /**
  85069. * Stores the animations for glTF models
  85070. */
  85071. private _animations;
  85072. /**
  85073. * Stores the total amount of bytes stored in the glTF buffer
  85074. */
  85075. private _totalByteLength;
  85076. /**
  85077. * Stores a reference to the Babylon scene containing the source geometry and material information
  85078. */
  85079. _babylonScene: Scene;
  85080. /**
  85081. * Stores a map of the image data, where the key is the file name and the value
  85082. * is the image data
  85083. */
  85084. _imageData: {
  85085. [fileName: string]: {
  85086. data: Uint8Array;
  85087. mimeType: ImageMimeType;
  85088. };
  85089. };
  85090. protected _orderedImageData: Array<{
  85091. data: Uint8Array;
  85092. mimeType: ImageMimeType;
  85093. }>;
  85094. /**
  85095. * Stores a map of the unique id of a node to its index in the node array
  85096. */
  85097. _nodeMap: {
  85098. [key: number]: number;
  85099. };
  85100. /**
  85101. * Specifies if the source Babylon scene was left handed, and needed conversion.
  85102. */
  85103. _convertToRightHandedSystem: boolean;
  85104. /**
  85105. * Specifies if a Babylon node should be converted to right-handed on export
  85106. */
  85107. _convertToRightHandedSystemMap: {
  85108. [nodeId: number]: boolean;
  85109. };
  85110. _includeCoordinateSystemConversionNodes: boolean;
  85111. /**
  85112. * Baked animation sample rate
  85113. */
  85114. private _animationSampleRate;
  85115. private _options;
  85116. private _localEngine;
  85117. _glTFMaterialExporter: _GLTFMaterialExporter;
  85118. private _extensions;
  85119. private static _ExtensionNames;
  85120. private static _ExtensionFactories;
  85121. private _applyExtension;
  85122. private _applyExtensions;
  85123. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  85124. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  85125. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85126. [key: number]: number;
  85127. }): Promise<Nullable<INode>>;
  85128. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  85129. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  85130. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  85131. private _forEachExtensions;
  85132. private _extensionsOnExporting;
  85133. /**
  85134. * Load glTF serializer extensions
  85135. */
  85136. private _loadExtensions;
  85137. /**
  85138. * Creates a glTF Exporter instance, which can accept optional exporter options
  85139. * @param babylonScene Babylon scene object
  85140. * @param options Options to modify the behavior of the exporter
  85141. */
  85142. constructor(babylonScene: Scene, options?: IExportOptions);
  85143. dispose(): void;
  85144. /**
  85145. * Registers a glTF exporter extension
  85146. * @param name Name of the extension to export
  85147. * @param factory The factory function that creates the exporter extension
  85148. */
  85149. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  85150. /**
  85151. * Un-registers an exporter extension
  85152. * @param name The name fo the exporter extension
  85153. * @returns A boolean indicating whether the extension has been un-registered
  85154. */
  85155. static UnregisterExtension(name: string): boolean;
  85156. /**
  85157. * Lazy load a local engine
  85158. */
  85159. _getLocalEngine(): Engine;
  85160. private reorderIndicesBasedOnPrimitiveMode;
  85161. /**
  85162. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  85163. * clock-wise during export to glTF
  85164. * @param submesh BabylonJS submesh
  85165. * @param primitiveMode Primitive mode of the mesh
  85166. * @param sideOrientation the winding order of the submesh
  85167. * @param vertexBufferKind The type of vertex attribute
  85168. * @param meshAttributeArray The vertex attribute data
  85169. * @param byteOffset The offset to the binary data
  85170. * @param binaryWriter The binary data for the glTF file
  85171. * @param convertToRightHandedSystem Converts the values to right-handed
  85172. */
  85173. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  85174. /**
  85175. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  85176. * clock-wise during export to glTF
  85177. * @param submesh BabylonJS submesh
  85178. * @param primitiveMode Primitive mode of the mesh
  85179. * @param sideOrientation the winding order of the submesh
  85180. * @param vertexBufferKind The type of vertex attribute
  85181. * @param meshAttributeArray The vertex attribute data
  85182. * @param byteOffset The offset to the binary data
  85183. * @param binaryWriter The binary data for the glTF file
  85184. * @param convertToRightHandedSystem Converts the values to right-handed
  85185. */
  85186. private reorderTriangleFillMode;
  85187. /**
  85188. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  85189. * clock-wise during export to glTF
  85190. * @param submesh BabylonJS submesh
  85191. * @param primitiveMode Primitive mode of the mesh
  85192. * @param sideOrientation the winding order of the submesh
  85193. * @param vertexBufferKind The type of vertex attribute
  85194. * @param meshAttributeArray The vertex attribute data
  85195. * @param byteOffset The offset to the binary data
  85196. * @param binaryWriter The binary data for the glTF file
  85197. * @param convertToRightHandedSystem Converts the values to right-handed
  85198. */
  85199. private reorderTriangleStripDrawMode;
  85200. /**
  85201. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  85202. * clock-wise during export to glTF
  85203. * @param submesh BabylonJS submesh
  85204. * @param primitiveMode Primitive mode of the mesh
  85205. * @param sideOrientation the winding order of the submesh
  85206. * @param vertexBufferKind The type of vertex attribute
  85207. * @param meshAttributeArray The vertex attribute data
  85208. * @param byteOffset The offset to the binary data
  85209. * @param binaryWriter The binary data for the glTF file
  85210. * @param convertToRightHandedSystem Converts the values to right-handed
  85211. */
  85212. private reorderTriangleFanMode;
  85213. /**
  85214. * Writes the vertex attribute data to binary
  85215. * @param vertices The vertices to write to the binary writer
  85216. * @param byteOffset The offset into the binary writer to overwrite binary data
  85217. * @param vertexAttributeKind The vertex attribute type
  85218. * @param meshAttributeArray The vertex attribute data
  85219. * @param binaryWriter The writer containing the binary data
  85220. * @param convertToRightHandedSystem Converts the values to right-handed
  85221. */
  85222. private writeVertexAttributeData;
  85223. /**
  85224. * Writes mesh attribute data to a data buffer
  85225. * Returns the bytelength of the data
  85226. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85227. * @param meshAttributeArray Array containing the attribute data
  85228. * @param byteStride Specifies the space between data
  85229. * @param binaryWriter The buffer to write the binary data to
  85230. * @param convertToRightHandedSystem Converts the values to right-handed
  85231. */
  85232. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  85233. /**
  85234. * Writes mesh attribute data to a data buffer
  85235. * Returns the bytelength of the data
  85236. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85237. * @param meshAttributeArray Array containing the attribute data
  85238. * @param byteStride Specifies the space between data
  85239. * @param binaryWriter The buffer to write the binary data to
  85240. * @param convertToRightHandedSystem Converts the values to right-handed
  85241. */
  85242. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  85243. /**
  85244. * Generates glTF json data
  85245. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  85246. * @param glTFPrefix Text to use when prefixing a glTF file
  85247. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  85248. * @returns json data as string
  85249. */
  85250. private generateJSON;
  85251. /**
  85252. * Generates data for .gltf and .bin files based on the glTF prefix string
  85253. * @param glTFPrefix Text to use when prefixing a glTF file
  85254. * @param dispose Dispose the exporter
  85255. * @returns GLTFData with glTF file data
  85256. */
  85257. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85258. /**
  85259. * Creates a binary buffer for glTF
  85260. * @returns array buffer for binary data
  85261. */
  85262. private _generateBinaryAsync;
  85263. /**
  85264. * Pads the number to a multiple of 4
  85265. * @param num number to pad
  85266. * @returns padded number
  85267. */
  85268. private _getPadding;
  85269. /**
  85270. * @hidden
  85271. */
  85272. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85273. /**
  85274. * Sets the TRS for each node
  85275. * @param node glTF Node for storing the transformation data
  85276. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85277. * @param convertToRightHandedSystem Converts the values to right-handed
  85278. */
  85279. private setNodeTransformation;
  85280. private getVertexBufferFromMesh;
  85281. /**
  85282. * Creates a bufferview based on the vertices type for the Babylon mesh
  85283. * @param kind Indicates the type of vertices data
  85284. * @param componentType Indicates the numerical type used to store the data
  85285. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85286. * @param binaryWriter The buffer to write the bufferview data to
  85287. * @param convertToRightHandedSystem Converts the values to right-handed
  85288. */
  85289. private createBufferViewKind;
  85290. /**
  85291. * Creates a bufferview based on the vertices type for the Babylon mesh
  85292. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85293. * @param babylonMorphTarget the morph target to be exported
  85294. * @param binaryWriter The buffer to write the bufferview data to
  85295. * @param convertToRightHandedSystem Converts the values to right-handed
  85296. */
  85297. private setMorphTargetAttributes;
  85298. /**
  85299. * The primitive mode of the Babylon mesh
  85300. * @param babylonMesh The BabylonJS mesh
  85301. */
  85302. private getMeshPrimitiveMode;
  85303. /**
  85304. * Sets the primitive mode of the glTF mesh primitive
  85305. * @param meshPrimitive glTF mesh primitive
  85306. * @param primitiveMode The primitive mode
  85307. */
  85308. private setPrimitiveMode;
  85309. /**
  85310. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85311. * @param meshPrimitive glTF mesh primitive
  85312. * @param attributeKind vertex attribute
  85313. * @returns boolean specifying if uv coordinates are present
  85314. */
  85315. private setAttributeKind;
  85316. /**
  85317. * Sets data for the primitive attributes of each submesh
  85318. * @param mesh glTF Mesh object to store the primitive attribute information
  85319. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85320. * @param binaryWriter Buffer to write the attribute data to
  85321. * @param convertToRightHandedSystem Converts the values to right-handed
  85322. */
  85323. private setPrimitiveAttributesAsync;
  85324. /**
  85325. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85326. * @param node The node to check
  85327. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85328. */
  85329. private isBabylonCoordinateSystemConvertingNode;
  85330. /**
  85331. * Creates a glTF scene based on the array of meshes
  85332. * Returns the the total byte offset
  85333. * @param babylonScene Babylon scene to get the mesh data from
  85334. * @param binaryWriter Buffer to write binary data to
  85335. */
  85336. private createSceneAsync;
  85337. /**
  85338. * Creates a mapping of Node unique id to node index and handles animations
  85339. * @param babylonScene Babylon Scene
  85340. * @param nodes Babylon transform nodes
  85341. * @param binaryWriter Buffer to write binary data to
  85342. * @returns Node mapping of unique id to index
  85343. */
  85344. private createNodeMapAndAnimationsAsync;
  85345. /**
  85346. * Creates a glTF node from a Babylon mesh
  85347. * @param babylonMesh Source Babylon mesh
  85348. * @param binaryWriter Buffer for storing geometry data
  85349. * @param convertToRightHandedSystem Converts the values to right-handed
  85350. * @param nodeMap Node mapping of unique id to glTF node index
  85351. * @returns glTF node
  85352. */
  85353. private createNodeAsync;
  85354. /**
  85355. * Creates a glTF skin from a Babylon skeleton
  85356. * @param babylonScene Babylon Scene
  85357. * @param nodes Babylon transform nodes
  85358. * @param binaryWriter Buffer to write binary data to
  85359. * @returns Node mapping of unique id to index
  85360. */
  85361. private createSkinsAsync;
  85362. }
  85363. /**
  85364. * @hidden
  85365. *
  85366. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85367. */
  85368. export class _BinaryWriter {
  85369. /**
  85370. * Array buffer which stores all binary data
  85371. */
  85372. private _arrayBuffer;
  85373. /**
  85374. * View of the array buffer
  85375. */
  85376. private _dataView;
  85377. /**
  85378. * byte offset of data in array buffer
  85379. */
  85380. private _byteOffset;
  85381. /**
  85382. * Initialize binary writer with an initial byte length
  85383. * @param byteLength Initial byte length of the array buffer
  85384. */
  85385. constructor(byteLength: number);
  85386. /**
  85387. * Resize the array buffer to the specified byte length
  85388. * @param byteLength
  85389. */
  85390. private resizeBuffer;
  85391. /**
  85392. * Get an array buffer with the length of the byte offset
  85393. * @returns ArrayBuffer resized to the byte offset
  85394. */
  85395. getArrayBuffer(): ArrayBuffer;
  85396. /**
  85397. * Get the byte offset of the array buffer
  85398. * @returns byte offset
  85399. */
  85400. getByteOffset(): number;
  85401. /**
  85402. * Stores an UInt8 in the array buffer
  85403. * @param entry
  85404. * @param byteOffset If defined, specifies where to set the value as an offset.
  85405. */
  85406. setUInt8(entry: number, byteOffset?: number): void;
  85407. /**
  85408. * Stores an UInt16 in the array buffer
  85409. * @param entry
  85410. * @param byteOffset If defined, specifies where to set the value as an offset.
  85411. */
  85412. setUInt16(entry: number, byteOffset?: number): void;
  85413. /**
  85414. * Gets an UInt32 in the array buffer
  85415. * @param entry
  85416. * @param byteOffset If defined, specifies where to set the value as an offset.
  85417. */
  85418. getUInt32(byteOffset: number): number;
  85419. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85420. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85421. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85422. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85423. /**
  85424. * Stores a Float32 in the array buffer
  85425. * @param entry
  85426. */
  85427. setFloat32(entry: number, byteOffset?: number): void;
  85428. /**
  85429. * Stores an UInt32 in the array buffer
  85430. * @param entry
  85431. * @param byteOffset If defined, specifies where to set the value as an offset.
  85432. */
  85433. setUInt32(entry: number, byteOffset?: number): void;
  85434. }
  85435. }
  85436. declare module BABYLON.GLTF2.Exporter {
  85437. /**
  85438. * @hidden
  85439. * Interface to store animation data.
  85440. */
  85441. export interface _IAnimationData {
  85442. /**
  85443. * Keyframe data.
  85444. */
  85445. inputs: number[];
  85446. /**
  85447. * Value data.
  85448. */
  85449. outputs: number[][];
  85450. /**
  85451. * Animation interpolation data.
  85452. */
  85453. samplerInterpolation: AnimationSamplerInterpolation;
  85454. /**
  85455. * Minimum keyframe value.
  85456. */
  85457. inputsMin: number;
  85458. /**
  85459. * Maximum keyframe value.
  85460. */
  85461. inputsMax: number;
  85462. }
  85463. /**
  85464. * @hidden
  85465. */
  85466. export interface _IAnimationInfo {
  85467. /**
  85468. * The target channel for the animation
  85469. */
  85470. animationChannelTargetPath: AnimationChannelTargetPath;
  85471. /**
  85472. * The glTF accessor type for the data.
  85473. */
  85474. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85475. /**
  85476. * Specifies if quaternions should be used.
  85477. */
  85478. useQuaternion: boolean;
  85479. }
  85480. /**
  85481. * @hidden
  85482. * Utility class for generating glTF animation data from BabylonJS.
  85483. */
  85484. export class _GLTFAnimation {
  85485. /**
  85486. * @ignore
  85487. *
  85488. * Creates glTF channel animation from BabylonJS animation.
  85489. * @param babylonTransformNode - BabylonJS mesh.
  85490. * @param animation - animation.
  85491. * @param animationChannelTargetPath - The target animation channel.
  85492. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85493. * @param useQuaternion - Specifies if quaternions are used.
  85494. * @returns nullable IAnimationData
  85495. */
  85496. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85497. private static _DeduceAnimationInfo;
  85498. /**
  85499. * @ignore
  85500. * Create node animations from the transform node animations
  85501. * @param babylonNode
  85502. * @param runtimeGLTFAnimation
  85503. * @param idleGLTFAnimations
  85504. * @param nodeMap
  85505. * @param nodes
  85506. * @param binaryWriter
  85507. * @param bufferViews
  85508. * @param accessors
  85509. * @param convertToRightHandedSystem
  85510. * @param animationSampleRate
  85511. */
  85512. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85513. [key: number]: number;
  85514. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85515. /**
  85516. * @ignore
  85517. * Create individual morph animations from the mesh's morph target animation tracks
  85518. * @param babylonNode
  85519. * @param runtimeGLTFAnimation
  85520. * @param idleGLTFAnimations
  85521. * @param nodeMap
  85522. * @param nodes
  85523. * @param binaryWriter
  85524. * @param bufferViews
  85525. * @param accessors
  85526. * @param convertToRightHandedSystem
  85527. * @param animationSampleRate
  85528. */
  85529. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85530. [key: number]: number;
  85531. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85532. /**
  85533. * @ignore
  85534. * Create node and morph animations from the animation groups
  85535. * @param babylonScene
  85536. * @param glTFAnimations
  85537. * @param nodeMap
  85538. * @param nodes
  85539. * @param binaryWriter
  85540. * @param bufferViews
  85541. * @param accessors
  85542. * @param convertToRightHandedSystemMap
  85543. * @param animationSampleRate
  85544. */
  85545. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85546. [key: number]: number;
  85547. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85548. [nodeId: number]: boolean;
  85549. }, animationSampleRate: number): void;
  85550. private static AddAnimation;
  85551. /**
  85552. * Create a baked animation
  85553. * @param babylonTransformNode BabylonJS mesh
  85554. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85555. * @param animationChannelTargetPath animation target channel
  85556. * @param minFrame minimum animation frame
  85557. * @param maxFrame maximum animation frame
  85558. * @param fps frames per second of the animation
  85559. * @param inputs input key frames of the animation
  85560. * @param outputs output key frame data of the animation
  85561. * @param convertToRightHandedSystem converts the values to right-handed
  85562. * @param useQuaternion specifies if quaternions should be used
  85563. */
  85564. private static _CreateBakedAnimation;
  85565. private static _ConvertFactorToVector3OrQuaternion;
  85566. private static _SetInterpolatedValue;
  85567. /**
  85568. * Creates linear animation from the animation key frames
  85569. * @param babylonTransformNode BabylonJS mesh
  85570. * @param animation BabylonJS animation
  85571. * @param animationChannelTargetPath The target animation channel
  85572. * @param frameDelta The difference between the last and first frame of the animation
  85573. * @param inputs Array to store the key frame times
  85574. * @param outputs Array to store the key frame data
  85575. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85576. * @param useQuaternion Specifies if quaternions are used in the animation
  85577. */
  85578. private static _CreateLinearOrStepAnimation;
  85579. /**
  85580. * Creates cubic spline animation from the animation key frames
  85581. * @param babylonTransformNode BabylonJS mesh
  85582. * @param animation BabylonJS animation
  85583. * @param animationChannelTargetPath The target animation channel
  85584. * @param frameDelta The difference between the last and first frame of the animation
  85585. * @param inputs Array to store the key frame times
  85586. * @param outputs Array to store the key frame data
  85587. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85588. * @param useQuaternion Specifies if quaternions are used in the animation
  85589. */
  85590. private static _CreateCubicSplineAnimation;
  85591. private static _GetBasePositionRotationOrScale;
  85592. /**
  85593. * Adds a key frame value
  85594. * @param keyFrame
  85595. * @param animation
  85596. * @param outputs
  85597. * @param animationChannelTargetPath
  85598. * @param basePositionRotationOrScale
  85599. * @param convertToRightHandedSystem
  85600. * @param useQuaternion
  85601. */
  85602. private static _AddKeyframeValue;
  85603. /**
  85604. * Determine the interpolation based on the key frames
  85605. * @param keyFrames
  85606. * @param animationChannelTargetPath
  85607. * @param useQuaternion
  85608. */
  85609. private static _DeduceInterpolation;
  85610. /**
  85611. * Adds an input tangent or output tangent to the output data
  85612. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85613. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85614. * @param outputs The animation data by keyframe
  85615. * @param animationChannelTargetPath The target animation channel
  85616. * @param interpolation The interpolation type
  85617. * @param keyFrame The key frame with the animation data
  85618. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85619. * @param useQuaternion Specifies if quaternions are used
  85620. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85621. */
  85622. private static AddSplineTangent;
  85623. /**
  85624. * Get the minimum and maximum key frames' frame values
  85625. * @param keyFrames animation key frames
  85626. * @returns the minimum and maximum key frame value
  85627. */
  85628. private static calculateMinMaxKeyFrames;
  85629. }
  85630. }
  85631. declare module BABYLON.GLTF2.Exporter {
  85632. /** @hidden */
  85633. export var textureTransformPixelShader: {
  85634. name: string;
  85635. shader: string;
  85636. };
  85637. }
  85638. declare module BABYLON.GLTF2.Exporter.Extensions {
  85639. /**
  85640. * @hidden
  85641. */
  85642. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85643. private _recordedTextures;
  85644. /** Name of this extension */
  85645. readonly name: string;
  85646. /** Defines whether this extension is enabled */
  85647. enabled: boolean;
  85648. /** Defines whether this extension is required */
  85649. required: boolean;
  85650. /** Reference to the glTF exporter */
  85651. private _wasUsed;
  85652. constructor(exporter: _Exporter);
  85653. dispose(): void;
  85654. /** @hidden */
  85655. get wasUsed(): boolean;
  85656. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85657. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85658. /**
  85659. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85660. * @param babylonTexture
  85661. * @param offset
  85662. * @param rotation
  85663. * @param scale
  85664. * @param scene
  85665. */
  85666. private _textureTransformTextureAsync;
  85667. }
  85668. }
  85669. declare module BABYLON.GLTF2.Exporter.Extensions {
  85670. /**
  85671. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85672. */
  85673. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85674. /** The name of this extension. */
  85675. readonly name: string;
  85676. /** Defines whether this extension is enabled. */
  85677. enabled: boolean;
  85678. /** Defines whether this extension is required */
  85679. required: boolean;
  85680. /** Reference to the glTF exporter */
  85681. private _exporter;
  85682. private _lights;
  85683. /** @hidden */
  85684. constructor(exporter: _Exporter);
  85685. /** @hidden */
  85686. dispose(): void;
  85687. /** @hidden */
  85688. get wasUsed(): boolean;
  85689. /** @hidden */
  85690. onExporting(): void;
  85691. /**
  85692. * Define this method to modify the default behavior when exporting a node
  85693. * @param context The context when exporting the node
  85694. * @param node glTF node
  85695. * @param babylonNode BabylonJS node
  85696. * @param nodeMap Node mapping of unique id to glTF node index
  85697. * @returns nullable INode promise
  85698. */
  85699. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85700. [key: number]: number;
  85701. }): Promise<Nullable<INode>>;
  85702. }
  85703. }
  85704. declare module BABYLON.GLTF2.Exporter.Extensions {
  85705. /**
  85706. * @hidden
  85707. */
  85708. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85709. /** Name of this extension */
  85710. readonly name: string;
  85711. /** Defines whether this extension is enabled */
  85712. enabled: boolean;
  85713. /** Defines whether this extension is required */
  85714. required: boolean;
  85715. /** Reference to the glTF exporter */
  85716. private _textureInfos;
  85717. private _exportedTextures;
  85718. private _wasUsed;
  85719. constructor(exporter: _Exporter);
  85720. dispose(): void;
  85721. /** @hidden */
  85722. get wasUsed(): boolean;
  85723. private _getTextureIndex;
  85724. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85725. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85726. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85727. }
  85728. }
  85729. declare module BABYLON.GLTF2.Exporter.Extensions {
  85730. /**
  85731. * @hidden
  85732. */
  85733. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85734. /** Name of this extension */
  85735. readonly name: string;
  85736. /** Defines whether this extension is enabled */
  85737. enabled: boolean;
  85738. /** Defines whether this extension is required */
  85739. required: boolean;
  85740. private _wasUsed;
  85741. constructor(exporter: _Exporter);
  85742. /** @hidden */
  85743. get wasUsed(): boolean;
  85744. dispose(): void;
  85745. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85746. }
  85747. }
  85748. declare module BABYLON {
  85749. /**
  85750. * Class for generating STL data from a Babylon scene.
  85751. */
  85752. export class STLExport {
  85753. /**
  85754. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85755. * @param meshes list defines the mesh to serialize
  85756. * @param download triggers the automatic download of the file.
  85757. * @param fileName changes the downloads fileName.
  85758. * @param binary changes the STL to a binary type.
  85759. * @param isLittleEndian toggle for binary type exporter.
  85760. * @returns the STL as UTF8 string
  85761. */
  85762. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85763. }
  85764. }
  85765. declare module "babylonjs-gltf2interface" {
  85766. export = BABYLON.GLTF2;
  85767. }
  85768. /**
  85769. * Module for glTF 2.0 Interface
  85770. */
  85771. declare module BABYLON.GLTF2 {
  85772. /**
  85773. * The datatype of the components in the attribute
  85774. */
  85775. const enum AccessorComponentType {
  85776. /**
  85777. * Byte
  85778. */
  85779. BYTE = 5120,
  85780. /**
  85781. * Unsigned Byte
  85782. */
  85783. UNSIGNED_BYTE = 5121,
  85784. /**
  85785. * Short
  85786. */
  85787. SHORT = 5122,
  85788. /**
  85789. * Unsigned Short
  85790. */
  85791. UNSIGNED_SHORT = 5123,
  85792. /**
  85793. * Unsigned Int
  85794. */
  85795. UNSIGNED_INT = 5125,
  85796. /**
  85797. * Float
  85798. */
  85799. FLOAT = 5126,
  85800. }
  85801. /**
  85802. * Specifies if the attirbute is a scalar, vector, or matrix
  85803. */
  85804. const enum AccessorType {
  85805. /**
  85806. * Scalar
  85807. */
  85808. SCALAR = "SCALAR",
  85809. /**
  85810. * Vector2
  85811. */
  85812. VEC2 = "VEC2",
  85813. /**
  85814. * Vector3
  85815. */
  85816. VEC3 = "VEC3",
  85817. /**
  85818. * Vector4
  85819. */
  85820. VEC4 = "VEC4",
  85821. /**
  85822. * Matrix2x2
  85823. */
  85824. MAT2 = "MAT2",
  85825. /**
  85826. * Matrix3x3
  85827. */
  85828. MAT3 = "MAT3",
  85829. /**
  85830. * Matrix4x4
  85831. */
  85832. MAT4 = "MAT4",
  85833. }
  85834. /**
  85835. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85836. */
  85837. const enum AnimationChannelTargetPath {
  85838. /**
  85839. * Translation
  85840. */
  85841. TRANSLATION = "translation",
  85842. /**
  85843. * Rotation
  85844. */
  85845. ROTATION = "rotation",
  85846. /**
  85847. * Scale
  85848. */
  85849. SCALE = "scale",
  85850. /**
  85851. * Weights
  85852. */
  85853. WEIGHTS = "weights",
  85854. }
  85855. /**
  85856. * Interpolation algorithm
  85857. */
  85858. const enum AnimationSamplerInterpolation {
  85859. /**
  85860. * The animated values are linearly interpolated between keyframes
  85861. */
  85862. LINEAR = "LINEAR",
  85863. /**
  85864. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85865. */
  85866. STEP = "STEP",
  85867. /**
  85868. * The animation's interpolation is computed using a cubic spline with specified tangents
  85869. */
  85870. CUBICSPLINE = "CUBICSPLINE",
  85871. }
  85872. /**
  85873. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85874. */
  85875. const enum CameraType {
  85876. /**
  85877. * A perspective camera containing properties to create a perspective projection matrix
  85878. */
  85879. PERSPECTIVE = "perspective",
  85880. /**
  85881. * An orthographic camera containing properties to create an orthographic projection matrix
  85882. */
  85883. ORTHOGRAPHIC = "orthographic",
  85884. }
  85885. /**
  85886. * The mime-type of the image
  85887. */
  85888. const enum ImageMimeType {
  85889. /**
  85890. * JPEG Mime-type
  85891. */
  85892. JPEG = "image/jpeg",
  85893. /**
  85894. * PNG Mime-type
  85895. */
  85896. PNG = "image/png",
  85897. }
  85898. /**
  85899. * The alpha rendering mode of the material
  85900. */
  85901. const enum MaterialAlphaMode {
  85902. /**
  85903. * The alpha value is ignored and the rendered output is fully opaque
  85904. */
  85905. OPAQUE = "OPAQUE",
  85906. /**
  85907. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85908. */
  85909. MASK = "MASK",
  85910. /**
  85911. * 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)
  85912. */
  85913. BLEND = "BLEND",
  85914. }
  85915. /**
  85916. * The type of the primitives to render
  85917. */
  85918. const enum MeshPrimitiveMode {
  85919. /**
  85920. * Points
  85921. */
  85922. POINTS = 0,
  85923. /**
  85924. * Lines
  85925. */
  85926. LINES = 1,
  85927. /**
  85928. * Line Loop
  85929. */
  85930. LINE_LOOP = 2,
  85931. /**
  85932. * Line Strip
  85933. */
  85934. LINE_STRIP = 3,
  85935. /**
  85936. * Triangles
  85937. */
  85938. TRIANGLES = 4,
  85939. /**
  85940. * Triangle Strip
  85941. */
  85942. TRIANGLE_STRIP = 5,
  85943. /**
  85944. * Triangle Fan
  85945. */
  85946. TRIANGLE_FAN = 6,
  85947. }
  85948. /**
  85949. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85950. */
  85951. const enum TextureMagFilter {
  85952. /**
  85953. * Nearest
  85954. */
  85955. NEAREST = 9728,
  85956. /**
  85957. * Linear
  85958. */
  85959. LINEAR = 9729,
  85960. }
  85961. /**
  85962. * Minification filter. All valid values correspond to WebGL enums
  85963. */
  85964. const enum TextureMinFilter {
  85965. /**
  85966. * Nearest
  85967. */
  85968. NEAREST = 9728,
  85969. /**
  85970. * Linear
  85971. */
  85972. LINEAR = 9729,
  85973. /**
  85974. * Nearest Mip-Map Nearest
  85975. */
  85976. NEAREST_MIPMAP_NEAREST = 9984,
  85977. /**
  85978. * Linear Mipmap Nearest
  85979. */
  85980. LINEAR_MIPMAP_NEAREST = 9985,
  85981. /**
  85982. * Nearest Mipmap Linear
  85983. */
  85984. NEAREST_MIPMAP_LINEAR = 9986,
  85985. /**
  85986. * Linear Mipmap Linear
  85987. */
  85988. LINEAR_MIPMAP_LINEAR = 9987,
  85989. }
  85990. /**
  85991. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85992. */
  85993. const enum TextureWrapMode {
  85994. /**
  85995. * Clamp to Edge
  85996. */
  85997. CLAMP_TO_EDGE = 33071,
  85998. /**
  85999. * Mirrored Repeat
  86000. */
  86001. MIRRORED_REPEAT = 33648,
  86002. /**
  86003. * Repeat
  86004. */
  86005. REPEAT = 10497,
  86006. }
  86007. /**
  86008. * glTF Property
  86009. */
  86010. interface IProperty {
  86011. /**
  86012. * Dictionary object with extension-specific objects
  86013. */
  86014. extensions?: {
  86015. [key: string]: any;
  86016. };
  86017. /**
  86018. * Application-Specific data
  86019. */
  86020. extras?: any;
  86021. }
  86022. /**
  86023. * glTF Child of Root Property
  86024. */
  86025. interface IChildRootProperty extends IProperty {
  86026. /**
  86027. * The user-defined name of this object
  86028. */
  86029. name?: string;
  86030. }
  86031. /**
  86032. * Indices of those attributes that deviate from their initialization value
  86033. */
  86034. interface IAccessorSparseIndices extends IProperty {
  86035. /**
  86036. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86037. */
  86038. bufferView: number;
  86039. /**
  86040. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86041. */
  86042. byteOffset?: number;
  86043. /**
  86044. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  86045. */
  86046. componentType: AccessorComponentType;
  86047. }
  86048. /**
  86049. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  86050. */
  86051. interface IAccessorSparseValues extends IProperty {
  86052. /**
  86053. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86054. */
  86055. bufferView: number;
  86056. /**
  86057. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86058. */
  86059. byteOffset?: number;
  86060. }
  86061. /**
  86062. * Sparse storage of attributes that deviate from their initialization value
  86063. */
  86064. interface IAccessorSparse extends IProperty {
  86065. /**
  86066. * The number of attributes encoded in this sparse accessor
  86067. */
  86068. count: number;
  86069. /**
  86070. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  86071. */
  86072. indices: IAccessorSparseIndices;
  86073. /**
  86074. * 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
  86075. */
  86076. values: IAccessorSparseValues;
  86077. }
  86078. /**
  86079. * 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
  86080. */
  86081. interface IAccessor extends IChildRootProperty {
  86082. /**
  86083. * The index of the bufferview
  86084. */
  86085. bufferView?: number;
  86086. /**
  86087. * The offset relative to the start of the bufferView in bytes
  86088. */
  86089. byteOffset?: number;
  86090. /**
  86091. * The datatype of components in the attribute
  86092. */
  86093. componentType: AccessorComponentType;
  86094. /**
  86095. * Specifies whether integer data values should be normalized
  86096. */
  86097. normalized?: boolean;
  86098. /**
  86099. * The number of attributes referenced by this accessor
  86100. */
  86101. count: number;
  86102. /**
  86103. * Specifies if the attribute is a scalar, vector, or matrix
  86104. */
  86105. type: AccessorType;
  86106. /**
  86107. * Maximum value of each component in this attribute
  86108. */
  86109. max?: number[];
  86110. /**
  86111. * Minimum value of each component in this attribute
  86112. */
  86113. min?: number[];
  86114. /**
  86115. * Sparse storage of attributes that deviate from their initialization value
  86116. */
  86117. sparse?: IAccessorSparse;
  86118. }
  86119. /**
  86120. * Targets an animation's sampler at a node's property
  86121. */
  86122. interface IAnimationChannel extends IProperty {
  86123. /**
  86124. * The index of a sampler in this animation used to compute the value for the target
  86125. */
  86126. sampler: number;
  86127. /**
  86128. * The index of the node and TRS property to target
  86129. */
  86130. target: IAnimationChannelTarget;
  86131. }
  86132. /**
  86133. * The index of the node and TRS property that an animation channel targets
  86134. */
  86135. interface IAnimationChannelTarget extends IProperty {
  86136. /**
  86137. * The index of the node to target
  86138. */
  86139. node: number;
  86140. /**
  86141. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86142. */
  86143. path: AnimationChannelTargetPath;
  86144. }
  86145. /**
  86146. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86147. */
  86148. interface IAnimationSampler extends IProperty {
  86149. /**
  86150. * The index of an accessor containing keyframe input values, e.g., time
  86151. */
  86152. input: number;
  86153. /**
  86154. * Interpolation algorithm
  86155. */
  86156. interpolation?: AnimationSamplerInterpolation;
  86157. /**
  86158. * The index of an accessor, containing keyframe output values
  86159. */
  86160. output: number;
  86161. }
  86162. /**
  86163. * A keyframe animation
  86164. */
  86165. interface IAnimation extends IChildRootProperty {
  86166. /**
  86167. * An array of channels, each of which targets an animation's sampler at a node's property
  86168. */
  86169. channels: IAnimationChannel[];
  86170. /**
  86171. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86172. */
  86173. samplers: IAnimationSampler[];
  86174. }
  86175. /**
  86176. * Metadata about the glTF asset
  86177. */
  86178. interface IAsset extends IChildRootProperty {
  86179. /**
  86180. * A copyright message suitable for display to credit the content creator
  86181. */
  86182. copyright?: string;
  86183. /**
  86184. * Tool that generated this glTF model. Useful for debugging
  86185. */
  86186. generator?: string;
  86187. /**
  86188. * The glTF version that this asset targets
  86189. */
  86190. version: string;
  86191. /**
  86192. * The minimum glTF version that this asset targets
  86193. */
  86194. minVersion?: string;
  86195. }
  86196. /**
  86197. * A buffer points to binary geometry, animation, or skins
  86198. */
  86199. interface IBuffer extends IChildRootProperty {
  86200. /**
  86201. * 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
  86202. */
  86203. uri?: string;
  86204. /**
  86205. * The length of the buffer in bytes
  86206. */
  86207. byteLength: number;
  86208. }
  86209. /**
  86210. * A view into a buffer generally representing a subset of the buffer
  86211. */
  86212. interface IBufferView extends IChildRootProperty {
  86213. /**
  86214. * The index of the buffer
  86215. */
  86216. buffer: number;
  86217. /**
  86218. * The offset into the buffer in bytes
  86219. */
  86220. byteOffset?: number;
  86221. /**
  86222. * The lenth of the bufferView in bytes
  86223. */
  86224. byteLength: number;
  86225. /**
  86226. * The stride, in bytes
  86227. */
  86228. byteStride?: number;
  86229. }
  86230. /**
  86231. * An orthographic camera containing properties to create an orthographic projection matrix
  86232. */
  86233. interface ICameraOrthographic extends IProperty {
  86234. /**
  86235. * The floating-point horizontal magnification of the view. Must not be zero
  86236. */
  86237. xmag: number;
  86238. /**
  86239. * The floating-point vertical magnification of the view. Must not be zero
  86240. */
  86241. ymag: number;
  86242. /**
  86243. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  86244. */
  86245. zfar: number;
  86246. /**
  86247. * The floating-point distance to the near clipping plane
  86248. */
  86249. znear: number;
  86250. }
  86251. /**
  86252. * A perspective camera containing properties to create a perspective projection matrix
  86253. */
  86254. interface ICameraPerspective extends IProperty {
  86255. /**
  86256. * The floating-point aspect ratio of the field of view
  86257. */
  86258. aspectRatio?: number;
  86259. /**
  86260. * The floating-point vertical field of view in radians
  86261. */
  86262. yfov: number;
  86263. /**
  86264. * The floating-point distance to the far clipping plane
  86265. */
  86266. zfar?: number;
  86267. /**
  86268. * The floating-point distance to the near clipping plane
  86269. */
  86270. znear: number;
  86271. }
  86272. /**
  86273. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86274. */
  86275. interface ICamera extends IChildRootProperty {
  86276. /**
  86277. * An orthographic camera containing properties to create an orthographic projection matrix
  86278. */
  86279. orthographic?: ICameraOrthographic;
  86280. /**
  86281. * A perspective camera containing properties to create a perspective projection matrix
  86282. */
  86283. perspective?: ICameraPerspective;
  86284. /**
  86285. * Specifies if the camera uses a perspective or orthographic projection
  86286. */
  86287. type: CameraType;
  86288. }
  86289. /**
  86290. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86291. */
  86292. interface IImage extends IChildRootProperty {
  86293. /**
  86294. * 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
  86295. */
  86296. uri?: string;
  86297. /**
  86298. * The image's MIME type
  86299. */
  86300. mimeType?: ImageMimeType;
  86301. /**
  86302. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86303. */
  86304. bufferView?: number;
  86305. }
  86306. /**
  86307. * Material Normal Texture Info
  86308. */
  86309. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86310. /**
  86311. * The scalar multiplier applied to each normal vector of the normal texture
  86312. */
  86313. scale?: number;
  86314. }
  86315. /**
  86316. * Material Occlusion Texture Info
  86317. */
  86318. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86319. /**
  86320. * A scalar multiplier controlling the amount of occlusion applied
  86321. */
  86322. strength?: number;
  86323. }
  86324. /**
  86325. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86326. */
  86327. interface IMaterialPbrMetallicRoughness {
  86328. /**
  86329. * The material's base color factor
  86330. */
  86331. baseColorFactor?: number[];
  86332. /**
  86333. * The base color texture
  86334. */
  86335. baseColorTexture?: ITextureInfo;
  86336. /**
  86337. * The metalness of the material
  86338. */
  86339. metallicFactor?: number;
  86340. /**
  86341. * The roughness of the material
  86342. */
  86343. roughnessFactor?: number;
  86344. /**
  86345. * The metallic-roughness texture
  86346. */
  86347. metallicRoughnessTexture?: ITextureInfo;
  86348. }
  86349. /**
  86350. * The material appearance of a primitive
  86351. */
  86352. interface IMaterial extends IChildRootProperty {
  86353. /**
  86354. * 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
  86355. */
  86356. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86357. /**
  86358. * The normal map texture
  86359. */
  86360. normalTexture?: IMaterialNormalTextureInfo;
  86361. /**
  86362. * The occlusion map texture
  86363. */
  86364. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86365. /**
  86366. * The emissive map texture
  86367. */
  86368. emissiveTexture?: ITextureInfo;
  86369. /**
  86370. * 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
  86371. */
  86372. emissiveFactor?: number[];
  86373. /**
  86374. * The alpha rendering mode of the material
  86375. */
  86376. alphaMode?: MaterialAlphaMode;
  86377. /**
  86378. * The alpha cutoff value of the material
  86379. */
  86380. alphaCutoff?: number;
  86381. /**
  86382. * Specifies whether the material is double sided
  86383. */
  86384. doubleSided?: boolean;
  86385. }
  86386. /**
  86387. * Geometry to be rendered with the given material
  86388. */
  86389. interface IMeshPrimitive extends IProperty {
  86390. /**
  86391. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86392. */
  86393. attributes: {
  86394. [name: string]: number;
  86395. };
  86396. /**
  86397. * The index of the accessor that contains the indices
  86398. */
  86399. indices?: number;
  86400. /**
  86401. * The index of the material to apply to this primitive when rendering
  86402. */
  86403. material?: number;
  86404. /**
  86405. * The type of primitives to render. All valid values correspond to WebGL enums
  86406. */
  86407. mode?: MeshPrimitiveMode;
  86408. /**
  86409. * 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
  86410. */
  86411. targets?: {
  86412. [name: string]: number;
  86413. }[];
  86414. }
  86415. /**
  86416. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86417. */
  86418. interface IMesh extends IChildRootProperty {
  86419. /**
  86420. * An array of primitives, each defining geometry to be rendered with a material
  86421. */
  86422. primitives: IMeshPrimitive[];
  86423. /**
  86424. * Array of weights to be applied to the Morph Targets
  86425. */
  86426. weights?: number[];
  86427. }
  86428. /**
  86429. * A node in the node hierarchy
  86430. */
  86431. interface INode extends IChildRootProperty {
  86432. /**
  86433. * The index of the camera referenced by this node
  86434. */
  86435. camera?: number;
  86436. /**
  86437. * The indices of this node's children
  86438. */
  86439. children?: number[];
  86440. /**
  86441. * The index of the skin referenced by this node
  86442. */
  86443. skin?: number;
  86444. /**
  86445. * A floating-point 4x4 transformation matrix stored in column-major order
  86446. */
  86447. matrix?: number[];
  86448. /**
  86449. * The index of the mesh in this node
  86450. */
  86451. mesh?: number;
  86452. /**
  86453. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86454. */
  86455. rotation?: number[];
  86456. /**
  86457. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86458. */
  86459. scale?: number[];
  86460. /**
  86461. * The node's translation along the x, y, and z axes
  86462. */
  86463. translation?: number[];
  86464. /**
  86465. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86466. */
  86467. weights?: number[];
  86468. }
  86469. /**
  86470. * Texture sampler properties for filtering and wrapping modes
  86471. */
  86472. interface ISampler extends IChildRootProperty {
  86473. /**
  86474. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86475. */
  86476. magFilter?: TextureMagFilter;
  86477. /**
  86478. * Minification filter. All valid values correspond to WebGL enums
  86479. */
  86480. minFilter?: TextureMinFilter;
  86481. /**
  86482. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86483. */
  86484. wrapS?: TextureWrapMode;
  86485. /**
  86486. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86487. */
  86488. wrapT?: TextureWrapMode;
  86489. }
  86490. /**
  86491. * The root nodes of a scene
  86492. */
  86493. interface IScene extends IChildRootProperty {
  86494. /**
  86495. * The indices of each root node
  86496. */
  86497. nodes: number[];
  86498. }
  86499. /**
  86500. * Joints and matrices defining a skin
  86501. */
  86502. interface ISkin extends IChildRootProperty {
  86503. /**
  86504. * 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
  86505. */
  86506. inverseBindMatrices?: number;
  86507. /**
  86508. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86509. */
  86510. skeleton?: number;
  86511. /**
  86512. * 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)
  86513. */
  86514. joints: number[];
  86515. }
  86516. /**
  86517. * A texture and its sampler
  86518. */
  86519. interface ITexture extends IChildRootProperty {
  86520. /**
  86521. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86522. */
  86523. sampler?: number;
  86524. /**
  86525. * The index of the image used by this texture
  86526. */
  86527. source: number;
  86528. }
  86529. /**
  86530. * Reference to a texture
  86531. */
  86532. interface ITextureInfo extends IProperty {
  86533. /**
  86534. * The index of the texture
  86535. */
  86536. index: number;
  86537. /**
  86538. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86539. */
  86540. texCoord?: number;
  86541. }
  86542. /**
  86543. * The root object for a glTF asset
  86544. */
  86545. interface IGLTF extends IProperty {
  86546. /**
  86547. * An array of accessors. An accessor is a typed view into a bufferView
  86548. */
  86549. accessors?: IAccessor[];
  86550. /**
  86551. * An array of keyframe animations
  86552. */
  86553. animations?: IAnimation[];
  86554. /**
  86555. * Metadata about the glTF asset
  86556. */
  86557. asset: IAsset;
  86558. /**
  86559. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86560. */
  86561. buffers?: IBuffer[];
  86562. /**
  86563. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86564. */
  86565. bufferViews?: IBufferView[];
  86566. /**
  86567. * An array of cameras
  86568. */
  86569. cameras?: ICamera[];
  86570. /**
  86571. * Names of glTF extensions used somewhere in this asset
  86572. */
  86573. extensionsUsed?: string[];
  86574. /**
  86575. * Names of glTF extensions required to properly load this asset
  86576. */
  86577. extensionsRequired?: string[];
  86578. /**
  86579. * An array of images. An image defines data used to create a texture
  86580. */
  86581. images?: IImage[];
  86582. /**
  86583. * An array of materials. A material defines the appearance of a primitive
  86584. */
  86585. materials?: IMaterial[];
  86586. /**
  86587. * An array of meshes. A mesh is a set of primitives to be rendered
  86588. */
  86589. meshes?: IMesh[];
  86590. /**
  86591. * An array of nodes
  86592. */
  86593. nodes?: INode[];
  86594. /**
  86595. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86596. */
  86597. samplers?: ISampler[];
  86598. /**
  86599. * The index of the default scene
  86600. */
  86601. scene?: number;
  86602. /**
  86603. * An array of scenes
  86604. */
  86605. scenes?: IScene[];
  86606. /**
  86607. * An array of skins. A skin is defined by joints and matrices
  86608. */
  86609. skins?: ISkin[];
  86610. /**
  86611. * An array of textures
  86612. */
  86613. textures?: ITexture[];
  86614. }
  86615. /**
  86616. * The glTF validation results
  86617. * @ignore
  86618. */
  86619. interface IGLTFValidationResults {
  86620. info: {
  86621. generator: string;
  86622. hasAnimations: boolean;
  86623. hasDefaultScene: boolean;
  86624. hasMaterials: boolean;
  86625. hasMorphTargets: boolean;
  86626. hasSkins: boolean;
  86627. hasTextures: boolean;
  86628. maxAttributesUsed: number;
  86629. primitivesCount: number
  86630. };
  86631. issues: {
  86632. messages: Array<string>;
  86633. numErrors: number;
  86634. numHints: number;
  86635. numInfos: number;
  86636. numWarnings: number;
  86637. truncated: boolean
  86638. };
  86639. mimeType: string;
  86640. uri: string;
  86641. validatedAt: string;
  86642. validatorVersion: string;
  86643. }
  86644. /**
  86645. * The glTF validation options
  86646. */
  86647. interface IGLTFValidationOptions {
  86648. /** Uri to use */
  86649. uri?: string;
  86650. /** Function used to load external resources */
  86651. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86652. /** Boolean indicating that we need to validate accessor data */
  86653. validateAccessorData?: boolean;
  86654. /** max number of issues allowed */
  86655. maxIssues?: number;
  86656. /** Ignored issues */
  86657. ignoredIssues?: Array<string>;
  86658. /** Value to override severy settings */
  86659. severityOverrides?: Object;
  86660. }
  86661. /**
  86662. * The glTF validator object
  86663. * @ignore
  86664. */
  86665. interface IGLTFValidator {
  86666. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86667. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86668. }
  86669. /**
  86670. * Interfaces from the EXT_lights_image_based extension
  86671. */
  86672. /** @hidden */
  86673. interface IEXTLightsImageBased_LightReferenceImageBased {
  86674. light: number;
  86675. }
  86676. /** @hidden */
  86677. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86678. intensity: number;
  86679. rotation: number[];
  86680. specularImageSize: number;
  86681. specularImages: number[][];
  86682. irradianceCoefficients: number[][];
  86683. }
  86684. /** @hidden */
  86685. interface IEXTLightsImageBased {
  86686. lights: IEXTLightsImageBased_LightImageBased[];
  86687. }
  86688. /**
  86689. * Interfaces from the EXT_mesh_gpu_instancing extension
  86690. * !!! Experimental Extension Subject to Changes !!!
  86691. */
  86692. /** @hidden */
  86693. interface IEXTMeshGpuInstancing {
  86694. mesh?: number;
  86695. attributes: { [name: string]: number };
  86696. }
  86697. /**
  86698. * Interfaces from the KHR_draco_mesh_compression extension
  86699. */
  86700. /** @hidden */
  86701. interface IKHRDracoMeshCompression {
  86702. bufferView: number;
  86703. attributes: { [name: string]: number };
  86704. }
  86705. /**
  86706. * Interfaces from the KHR_lights_punctual extension
  86707. */
  86708. /** @hidden */
  86709. const enum IKHRLightsPunctual_LightType {
  86710. DIRECTIONAL = "directional",
  86711. POINT = "point",
  86712. SPOT = "spot"
  86713. }
  86714. /** @hidden */
  86715. interface IKHRLightsPunctual_LightReference {
  86716. light: number;
  86717. }
  86718. /** @hidden */
  86719. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86720. type: IKHRLightsPunctual_LightType;
  86721. color?: number[];
  86722. intensity?: number;
  86723. range?: number;
  86724. spot?: {
  86725. innerConeAngle?: number;
  86726. outerConeAngle?: number;
  86727. };
  86728. }
  86729. /** @hidden */
  86730. interface IKHRLightsPunctual {
  86731. lights: IKHRLightsPunctual_Light[];
  86732. }
  86733. /**
  86734. * Interfaces from the KHR_materials_clearcoat extension
  86735. * !!! Experimental Extension Subject to Changes !!!
  86736. */
  86737. /** @hidden */
  86738. interface IKHRMaterialsClearcoat {
  86739. clearcoatFactor: number;
  86740. clearcoatTexture: ITextureInfo;
  86741. clearcoatRoughnessFactor: number;
  86742. clearcoatRoughnessTexture: ITextureInfo;
  86743. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86744. }
  86745. /**
  86746. * Interfaces from the KHR_materials_ior extension
  86747. * !!! Experimental Extension Subject to Changes !!!
  86748. */
  86749. /** @hidden */
  86750. interface IKHRMaterialsIor {
  86751. ior: number;
  86752. }
  86753. /**
  86754. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86755. */
  86756. /** @hidden */
  86757. interface IKHRMaterialsPbrSpecularGlossiness {
  86758. diffuseFactor: number[];
  86759. diffuseTexture: ITextureInfo;
  86760. specularFactor: number[];
  86761. glossinessFactor: number;
  86762. specularGlossinessTexture: ITextureInfo;
  86763. }
  86764. /**
  86765. * Interfaces from the KHR_materials_sheen extension
  86766. * !!! Experimental Extension Subject to Changes !!!
  86767. */
  86768. /** @hidden */
  86769. interface IKHRMaterialsSheen {
  86770. sheenColorFactor?: number[];
  86771. sheenColorTexture?: ITextureInfo;
  86772. sheenRoughnessFactor?: number;
  86773. sheenRoughnessTexture?: ITextureInfo;
  86774. }
  86775. /**
  86776. * Interfaces from the KHR_materials_specular extension
  86777. * !!! Experimental Extension Subject to Changes !!!
  86778. */
  86779. /** @hidden */
  86780. interface IKHRMaterialsSpecular {
  86781. specularFactor: number;
  86782. specularColorFactor: number[];
  86783. specularTexture: ITextureInfo;
  86784. }
  86785. /**
  86786. * Interfaces from the KHR_materials_transmission extension
  86787. * !!! Experimental Extension Subject to Changes !!!
  86788. */
  86789. /** @hidden */
  86790. interface IKHRMaterialsTransmission {
  86791. transmissionFactor?: number;
  86792. transmissionTexture?: ITextureInfo;
  86793. }
  86794. /**
  86795. * Interfaces from the KHR_materials_variants extension
  86796. * !!! Experimental Extension Subject to Changes !!!
  86797. */
  86798. /** @hidden */
  86799. interface IKHRMaterialVariants_Mapping extends IProperty {
  86800. mappings: Array<{
  86801. variants: number[];
  86802. material: number;
  86803. }>;
  86804. }
  86805. /** @hidden */
  86806. interface IKHRMaterialVariants_Variant extends IProperty {
  86807. name: string;
  86808. }
  86809. /** @hidden */
  86810. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86811. variants: Array<IKHRMaterialVariants_Variant>;
  86812. }
  86813. /**
  86814. * Interfaces from the KHR_texture_basisu extension
  86815. * !!! Experimental Extension Subject to Changes !!!
  86816. */
  86817. /** @hidden */
  86818. interface IKHRTextureBasisU {
  86819. source: number;
  86820. }
  86821. /**
  86822. * Interfaces from the EXT_texture_webp extension
  86823. */
  86824. /** @hidden */
  86825. interface IEXTTextureWebP {
  86826. source: number;
  86827. }
  86828. /**
  86829. * Interfaces from the KHR_texture_transform extension
  86830. */
  86831. /** @hidden */
  86832. interface IKHRTextureTransform {
  86833. offset?: number[];
  86834. rotation?: number;
  86835. scale?: number[];
  86836. texCoord?: number;
  86837. }
  86838. /**
  86839. * Interfaces from the KHR_xmp extension
  86840. * !!! Experimental Extension Subject to Changes !!!
  86841. */
  86842. /** @hidden */
  86843. interface IKHRXmp_Data {
  86844. [key: string]: unknown;
  86845. }
  86846. /** @hidden */
  86847. interface IKHRXmp_Gltf {
  86848. packets: IKHRXmp_Data[];
  86849. }
  86850. /** @hidden */
  86851. interface IKHRXmp_Node {
  86852. packet: number;
  86853. }
  86854. /**
  86855. * Interfaces from the MSFT_audio_emitter extension
  86856. */
  86857. /** @hidden */
  86858. interface IMSFTAudioEmitter_ClipReference {
  86859. clip: number;
  86860. weight?: number;
  86861. }
  86862. /** @hidden */
  86863. interface IMSFTAudioEmitter_EmittersReference {
  86864. emitters: number[];
  86865. }
  86866. /** @hidden */
  86867. const enum IMSFTAudioEmitter_DistanceModel {
  86868. linear = "linear",
  86869. inverse = "inverse",
  86870. exponential = "exponential",
  86871. }
  86872. /** @hidden */
  86873. interface IMSFTAudioEmitter_Emitter {
  86874. name?: string;
  86875. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86876. refDistance?: number;
  86877. maxDistance?: number;
  86878. rolloffFactor?: number;
  86879. innerAngle?: number;
  86880. outerAngle?: number;
  86881. loop?: boolean;
  86882. volume?: number;
  86883. clips: IMSFTAudioEmitter_ClipReference[];
  86884. }
  86885. /** @hidden */
  86886. const enum IMSFTAudioEmitter_AudioMimeType {
  86887. WAV = "audio/wav",
  86888. }
  86889. /** @hidden */
  86890. interface IMSFTAudioEmitter_Clip extends IProperty {
  86891. uri?: string;
  86892. bufferView?: number;
  86893. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86894. }
  86895. /** @hidden */
  86896. const enum IMSFTAudioEmitter_AnimationEventAction {
  86897. play = "play",
  86898. pause = "pause",
  86899. stop = "stop",
  86900. }
  86901. /** @hidden */
  86902. interface IMSFTAudioEmitter_AnimationEvent {
  86903. action: IMSFTAudioEmitter_AnimationEventAction;
  86904. emitter: number;
  86905. time: number;
  86906. startOffset?: number;
  86907. }
  86908. /**
  86909. * Interfaces from the MSFT_lod extension
  86910. */
  86911. /** @hidden */
  86912. interface IMSFTLOD {
  86913. ids: number[];
  86914. }
  86915. }
  86916. declare module BABYLON {
  86917. /** @hidden */
  86918. export var cellPixelShader: {
  86919. name: string;
  86920. shader: string;
  86921. };
  86922. }
  86923. declare module BABYLON {
  86924. /** @hidden */
  86925. export var cellVertexShader: {
  86926. name: string;
  86927. shader: string;
  86928. };
  86929. }
  86930. declare module BABYLON {
  86931. export class CellMaterial extends BABYLON.PushMaterial {
  86932. private _diffuseTexture;
  86933. diffuseTexture: BABYLON.BaseTexture;
  86934. diffuseColor: BABYLON.Color3;
  86935. _computeHighLevel: boolean;
  86936. computeHighLevel: boolean;
  86937. private _disableLighting;
  86938. disableLighting: boolean;
  86939. private _maxSimultaneousLights;
  86940. maxSimultaneousLights: number;
  86941. constructor(name: string, scene: BABYLON.Scene);
  86942. needAlphaBlending(): boolean;
  86943. needAlphaTesting(): boolean;
  86944. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86945. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86946. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86947. getAnimatables(): BABYLON.IAnimatable[];
  86948. getActiveTextures(): BABYLON.BaseTexture[];
  86949. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86950. dispose(forceDisposeEffect?: boolean): void;
  86951. getClassName(): string;
  86952. clone(name: string): CellMaterial;
  86953. serialize(): any;
  86954. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86955. }
  86956. }
  86957. declare module BABYLON {
  86958. export class CustomShaderStructure {
  86959. FragmentStore: string;
  86960. VertexStore: string;
  86961. constructor();
  86962. }
  86963. export class ShaderSpecialParts {
  86964. constructor();
  86965. Fragment_Begin: string;
  86966. Fragment_Definitions: string;
  86967. Fragment_MainBegin: string;
  86968. Fragment_Custom_Diffuse: string;
  86969. Fragment_Before_Lights: string;
  86970. Fragment_Before_Fog: string;
  86971. Fragment_Custom_Alpha: string;
  86972. Fragment_Before_FragColor: string;
  86973. Vertex_Begin: string;
  86974. Vertex_Definitions: string;
  86975. Vertex_MainBegin: string;
  86976. Vertex_Before_PositionUpdated: string;
  86977. Vertex_Before_NormalUpdated: string;
  86978. Vertex_After_WorldPosComputed: string;
  86979. Vertex_MainEnd: string;
  86980. }
  86981. export class CustomMaterial extends BABYLON.StandardMaterial {
  86982. static ShaderIndexer: number;
  86983. CustomParts: ShaderSpecialParts;
  86984. _isCreatedShader: boolean;
  86985. _createdShaderName: string;
  86986. _customUniform: string[];
  86987. _newUniforms: string[];
  86988. _newUniformInstances: {
  86989. [name: string]: any;
  86990. };
  86991. _newSamplerInstances: {
  86992. [name: string]: BABYLON.Texture;
  86993. };
  86994. _customAttributes: string[];
  86995. FragmentShader: string;
  86996. VertexShader: string;
  86997. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86998. ReviewUniform(name: string, arr: string[]): string[];
  86999. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87000. constructor(name: string, scene: BABYLON.Scene);
  87001. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  87002. AddAttribute(name: string): CustomMaterial;
  87003. Fragment_Begin(shaderPart: string): CustomMaterial;
  87004. Fragment_Definitions(shaderPart: string): CustomMaterial;
  87005. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  87006. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  87007. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  87008. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  87009. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  87010. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  87011. Vertex_Begin(shaderPart: string): CustomMaterial;
  87012. Vertex_Definitions(shaderPart: string): CustomMaterial;
  87013. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  87014. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  87015. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  87016. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  87017. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  87018. }
  87019. }
  87020. declare module BABYLON {
  87021. export class ShaderAlebdoParts {
  87022. constructor();
  87023. Fragment_Begin: string;
  87024. Fragment_Definitions: string;
  87025. Fragment_MainBegin: string;
  87026. Fragment_Custom_Albedo: string;
  87027. Fragment_Before_Lights: string;
  87028. Fragment_Custom_MetallicRoughness: string;
  87029. Fragment_Custom_MicroSurface: string;
  87030. Fragment_Before_Fog: string;
  87031. Fragment_Custom_Alpha: string;
  87032. Fragment_Before_FragColor: string;
  87033. Vertex_Begin: string;
  87034. Vertex_Definitions: string;
  87035. Vertex_MainBegin: string;
  87036. Vertex_Before_PositionUpdated: string;
  87037. Vertex_Before_NormalUpdated: string;
  87038. Vertex_After_WorldPosComputed: string;
  87039. Vertex_MainEnd: string;
  87040. }
  87041. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  87042. static ShaderIndexer: number;
  87043. CustomParts: ShaderAlebdoParts;
  87044. _isCreatedShader: boolean;
  87045. _createdShaderName: string;
  87046. _customUniform: string[];
  87047. _newUniforms: string[];
  87048. _newUniformInstances: {
  87049. [name: string]: any;
  87050. };
  87051. _newSamplerInstances: {
  87052. [name: string]: BABYLON.Texture;
  87053. };
  87054. _customAttributes: string[];
  87055. FragmentShader: string;
  87056. VertexShader: string;
  87057. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87058. ReviewUniform(name: string, arr: string[]): string[];
  87059. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87060. constructor(name: string, scene: BABYLON.Scene);
  87061. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  87062. AddAttribute(name: string): PBRCustomMaterial;
  87063. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  87064. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  87065. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  87066. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  87067. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  87068. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  87069. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  87070. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  87071. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  87072. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  87073. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  87074. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  87075. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  87076. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  87077. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  87078. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  87079. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  87080. }
  87081. }
  87082. declare module BABYLON {
  87083. /** @hidden */
  87084. export var firePixelShader: {
  87085. name: string;
  87086. shader: string;
  87087. };
  87088. }
  87089. declare module BABYLON {
  87090. /** @hidden */
  87091. export var fireVertexShader: {
  87092. name: string;
  87093. shader: string;
  87094. };
  87095. }
  87096. declare module BABYLON {
  87097. export class FireMaterial extends BABYLON.PushMaterial {
  87098. private _diffuseTexture;
  87099. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87100. private _distortionTexture;
  87101. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87102. private _opacityTexture;
  87103. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87104. diffuseColor: BABYLON.Color3;
  87105. speed: number;
  87106. private _scaledDiffuse;
  87107. private _lastTime;
  87108. constructor(name: string, scene: BABYLON.Scene);
  87109. needAlphaBlending(): boolean;
  87110. needAlphaTesting(): boolean;
  87111. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87112. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87113. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87114. getAnimatables(): BABYLON.IAnimatable[];
  87115. getActiveTextures(): BABYLON.BaseTexture[];
  87116. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87117. getClassName(): string;
  87118. dispose(forceDisposeEffect?: boolean): void;
  87119. clone(name: string): FireMaterial;
  87120. serialize(): any;
  87121. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  87122. }
  87123. }
  87124. declare module BABYLON {
  87125. /** @hidden */
  87126. export var furPixelShader: {
  87127. name: string;
  87128. shader: string;
  87129. };
  87130. }
  87131. declare module BABYLON {
  87132. /** @hidden */
  87133. export var furVertexShader: {
  87134. name: string;
  87135. shader: string;
  87136. };
  87137. }
  87138. declare module BABYLON {
  87139. export class FurMaterial extends BABYLON.PushMaterial {
  87140. private _diffuseTexture;
  87141. diffuseTexture: BABYLON.BaseTexture;
  87142. private _heightTexture;
  87143. heightTexture: BABYLON.BaseTexture;
  87144. diffuseColor: BABYLON.Color3;
  87145. furLength: number;
  87146. furAngle: number;
  87147. furColor: BABYLON.Color3;
  87148. furOffset: number;
  87149. furSpacing: number;
  87150. furGravity: BABYLON.Vector3;
  87151. furSpeed: number;
  87152. furDensity: number;
  87153. furOcclusion: number;
  87154. furTexture: BABYLON.DynamicTexture;
  87155. private _disableLighting;
  87156. disableLighting: boolean;
  87157. private _maxSimultaneousLights;
  87158. maxSimultaneousLights: number;
  87159. highLevelFur: boolean;
  87160. _meshes: BABYLON.AbstractMesh[];
  87161. private _furTime;
  87162. constructor(name: string, scene: BABYLON.Scene);
  87163. get furTime(): number;
  87164. set furTime(furTime: number);
  87165. needAlphaBlending(): boolean;
  87166. needAlphaTesting(): boolean;
  87167. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87168. updateFur(): void;
  87169. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87170. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87171. getAnimatables(): BABYLON.IAnimatable[];
  87172. getActiveTextures(): BABYLON.BaseTexture[];
  87173. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87174. dispose(forceDisposeEffect?: boolean): void;
  87175. clone(name: string): FurMaterial;
  87176. serialize(): any;
  87177. getClassName(): string;
  87178. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  87179. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  87180. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  87181. }
  87182. }
  87183. declare module BABYLON {
  87184. /** @hidden */
  87185. export var gradientPixelShader: {
  87186. name: string;
  87187. shader: string;
  87188. };
  87189. }
  87190. declare module BABYLON {
  87191. /** @hidden */
  87192. export var gradientVertexShader: {
  87193. name: string;
  87194. shader: string;
  87195. };
  87196. }
  87197. declare module BABYLON {
  87198. export class GradientMaterial extends BABYLON.PushMaterial {
  87199. private _maxSimultaneousLights;
  87200. maxSimultaneousLights: number;
  87201. topColor: BABYLON.Color3;
  87202. topColorAlpha: number;
  87203. bottomColor: BABYLON.Color3;
  87204. bottomColorAlpha: number;
  87205. offset: number;
  87206. scale: number;
  87207. smoothness: number;
  87208. private _disableLighting;
  87209. disableLighting: boolean;
  87210. constructor(name: string, scene: BABYLON.Scene);
  87211. needAlphaBlending(): boolean;
  87212. needAlphaTesting(): boolean;
  87213. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87214. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87215. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87216. getAnimatables(): BABYLON.IAnimatable[];
  87217. dispose(forceDisposeEffect?: boolean): void;
  87218. clone(name: string): GradientMaterial;
  87219. serialize(): any;
  87220. getClassName(): string;
  87221. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  87222. }
  87223. }
  87224. declare module BABYLON {
  87225. /** @hidden */
  87226. export var gridPixelShader: {
  87227. name: string;
  87228. shader: string;
  87229. };
  87230. }
  87231. declare module BABYLON {
  87232. /** @hidden */
  87233. export var gridVertexShader: {
  87234. name: string;
  87235. shader: string;
  87236. };
  87237. }
  87238. declare module BABYLON {
  87239. /**
  87240. * The grid materials allows you to wrap any shape with a grid.
  87241. * Colors are customizable.
  87242. */
  87243. export class GridMaterial extends BABYLON.PushMaterial {
  87244. /**
  87245. * Main color of the grid (e.g. between lines)
  87246. */
  87247. mainColor: BABYLON.Color3;
  87248. /**
  87249. * Color of the grid lines.
  87250. */
  87251. lineColor: BABYLON.Color3;
  87252. /**
  87253. * The scale of the grid compared to unit.
  87254. */
  87255. gridRatio: number;
  87256. /**
  87257. * Allows setting an offset for the grid lines.
  87258. */
  87259. gridOffset: BABYLON.Vector3;
  87260. /**
  87261. * The frequency of thicker lines.
  87262. */
  87263. majorUnitFrequency: number;
  87264. /**
  87265. * The visibility of minor units in the grid.
  87266. */
  87267. minorUnitVisibility: number;
  87268. /**
  87269. * The grid opacity outside of the lines.
  87270. */
  87271. opacity: number;
  87272. /**
  87273. * Determine RBG output is premultiplied by alpha value.
  87274. */
  87275. preMultiplyAlpha: boolean;
  87276. private _opacityTexture;
  87277. opacityTexture: BABYLON.BaseTexture;
  87278. private _gridControl;
  87279. /**
  87280. * constructor
  87281. * @param name The name given to the material in order to identify it afterwards.
  87282. * @param scene The scene the material is used in.
  87283. */
  87284. constructor(name: string, scene: BABYLON.Scene);
  87285. /**
  87286. * Returns wehter or not the grid requires alpha blending.
  87287. */
  87288. needAlphaBlending(): boolean;
  87289. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87290. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87291. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87292. /**
  87293. * Dispose the material and its associated resources.
  87294. * @param forceDisposeEffect will also dispose the used effect when true
  87295. */
  87296. dispose(forceDisposeEffect?: boolean): void;
  87297. clone(name: string): GridMaterial;
  87298. serialize(): any;
  87299. getClassName(): string;
  87300. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87301. }
  87302. }
  87303. declare module BABYLON {
  87304. /** @hidden */
  87305. export var lavaPixelShader: {
  87306. name: string;
  87307. shader: string;
  87308. };
  87309. }
  87310. declare module BABYLON {
  87311. /** @hidden */
  87312. export var lavaVertexShader: {
  87313. name: string;
  87314. shader: string;
  87315. };
  87316. }
  87317. declare module BABYLON {
  87318. export class LavaMaterial extends BABYLON.PushMaterial {
  87319. private _diffuseTexture;
  87320. diffuseTexture: BABYLON.BaseTexture;
  87321. noiseTexture: BABYLON.BaseTexture;
  87322. fogColor: BABYLON.Color3;
  87323. speed: number;
  87324. movingSpeed: number;
  87325. lowFrequencySpeed: number;
  87326. fogDensity: number;
  87327. private _lastTime;
  87328. diffuseColor: BABYLON.Color3;
  87329. private _disableLighting;
  87330. disableLighting: boolean;
  87331. private _unlit;
  87332. unlit: boolean;
  87333. private _maxSimultaneousLights;
  87334. maxSimultaneousLights: number;
  87335. private _scaledDiffuse;
  87336. constructor(name: string, scene: BABYLON.Scene);
  87337. needAlphaBlending(): boolean;
  87338. needAlphaTesting(): boolean;
  87339. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87340. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87341. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87342. getAnimatables(): BABYLON.IAnimatable[];
  87343. getActiveTextures(): BABYLON.BaseTexture[];
  87344. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87345. dispose(forceDisposeEffect?: boolean): void;
  87346. clone(name: string): LavaMaterial;
  87347. serialize(): any;
  87348. getClassName(): string;
  87349. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87350. }
  87351. }
  87352. declare module BABYLON {
  87353. /** @hidden */
  87354. export var mixPixelShader: {
  87355. name: string;
  87356. shader: string;
  87357. };
  87358. }
  87359. declare module BABYLON {
  87360. /** @hidden */
  87361. export var mixVertexShader: {
  87362. name: string;
  87363. shader: string;
  87364. };
  87365. }
  87366. declare module BABYLON {
  87367. export class MixMaterial extends BABYLON.PushMaterial {
  87368. /**
  87369. * Mix textures
  87370. */
  87371. private _mixTexture1;
  87372. mixTexture1: BABYLON.BaseTexture;
  87373. private _mixTexture2;
  87374. mixTexture2: BABYLON.BaseTexture;
  87375. /**
  87376. * Diffuse textures
  87377. */
  87378. private _diffuseTexture1;
  87379. diffuseTexture1: BABYLON.Texture;
  87380. private _diffuseTexture2;
  87381. diffuseTexture2: BABYLON.Texture;
  87382. private _diffuseTexture3;
  87383. diffuseTexture3: BABYLON.Texture;
  87384. private _diffuseTexture4;
  87385. diffuseTexture4: BABYLON.Texture;
  87386. private _diffuseTexture5;
  87387. diffuseTexture5: BABYLON.Texture;
  87388. private _diffuseTexture6;
  87389. diffuseTexture6: BABYLON.Texture;
  87390. private _diffuseTexture7;
  87391. diffuseTexture7: BABYLON.Texture;
  87392. private _diffuseTexture8;
  87393. diffuseTexture8: BABYLON.Texture;
  87394. /**
  87395. * Uniforms
  87396. */
  87397. diffuseColor: BABYLON.Color3;
  87398. specularColor: BABYLON.Color3;
  87399. specularPower: number;
  87400. private _disableLighting;
  87401. disableLighting: boolean;
  87402. private _maxSimultaneousLights;
  87403. maxSimultaneousLights: number;
  87404. constructor(name: string, scene: BABYLON.Scene);
  87405. needAlphaBlending(): boolean;
  87406. needAlphaTesting(): boolean;
  87407. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87408. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87409. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87410. getAnimatables(): BABYLON.IAnimatable[];
  87411. getActiveTextures(): BABYLON.BaseTexture[];
  87412. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87413. dispose(forceDisposeEffect?: boolean): void;
  87414. clone(name: string): MixMaterial;
  87415. serialize(): any;
  87416. getClassName(): string;
  87417. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87418. }
  87419. }
  87420. declare module BABYLON {
  87421. /** @hidden */
  87422. export var normalPixelShader: {
  87423. name: string;
  87424. shader: string;
  87425. };
  87426. }
  87427. declare module BABYLON {
  87428. /** @hidden */
  87429. export var normalVertexShader: {
  87430. name: string;
  87431. shader: string;
  87432. };
  87433. }
  87434. declare module BABYLON {
  87435. export class NormalMaterial extends BABYLON.PushMaterial {
  87436. private _diffuseTexture;
  87437. diffuseTexture: BABYLON.BaseTexture;
  87438. diffuseColor: BABYLON.Color3;
  87439. private _disableLighting;
  87440. disableLighting: boolean;
  87441. private _maxSimultaneousLights;
  87442. maxSimultaneousLights: number;
  87443. constructor(name: string, scene: BABYLON.Scene);
  87444. needAlphaBlending(): boolean;
  87445. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87446. needAlphaTesting(): boolean;
  87447. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87448. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87449. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87450. getAnimatables(): BABYLON.IAnimatable[];
  87451. getActiveTextures(): BABYLON.BaseTexture[];
  87452. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87453. dispose(forceDisposeEffect?: boolean): void;
  87454. clone(name: string): NormalMaterial;
  87455. serialize(): any;
  87456. getClassName(): string;
  87457. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87458. }
  87459. }
  87460. declare module BABYLON {
  87461. /** @hidden */
  87462. export var shadowOnlyPixelShader: {
  87463. name: string;
  87464. shader: string;
  87465. };
  87466. }
  87467. declare module BABYLON {
  87468. /** @hidden */
  87469. export var shadowOnlyVertexShader: {
  87470. name: string;
  87471. shader: string;
  87472. };
  87473. }
  87474. declare module BABYLON {
  87475. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87476. private _activeLight;
  87477. private _needAlphaBlending;
  87478. constructor(name: string, scene: BABYLON.Scene);
  87479. shadowColor: BABYLON.Color3;
  87480. needAlphaBlending(): boolean;
  87481. needAlphaTesting(): boolean;
  87482. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87483. get activeLight(): BABYLON.IShadowLight;
  87484. set activeLight(light: BABYLON.IShadowLight);
  87485. private _getFirstShadowLightForMesh;
  87486. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87487. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87488. clone(name: string): ShadowOnlyMaterial;
  87489. serialize(): any;
  87490. getClassName(): string;
  87491. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87492. }
  87493. }
  87494. declare module BABYLON {
  87495. /** @hidden */
  87496. export var simplePixelShader: {
  87497. name: string;
  87498. shader: string;
  87499. };
  87500. }
  87501. declare module BABYLON {
  87502. /** @hidden */
  87503. export var simpleVertexShader: {
  87504. name: string;
  87505. shader: string;
  87506. };
  87507. }
  87508. declare module BABYLON {
  87509. export class SimpleMaterial extends BABYLON.PushMaterial {
  87510. private _diffuseTexture;
  87511. diffuseTexture: BABYLON.BaseTexture;
  87512. diffuseColor: BABYLON.Color3;
  87513. private _disableLighting;
  87514. disableLighting: boolean;
  87515. private _maxSimultaneousLights;
  87516. maxSimultaneousLights: number;
  87517. constructor(name: string, scene: BABYLON.Scene);
  87518. needAlphaBlending(): boolean;
  87519. needAlphaTesting(): boolean;
  87520. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87521. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87522. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87523. getAnimatables(): BABYLON.IAnimatable[];
  87524. getActiveTextures(): BABYLON.BaseTexture[];
  87525. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87526. dispose(forceDisposeEffect?: boolean): void;
  87527. clone(name: string): SimpleMaterial;
  87528. serialize(): any;
  87529. getClassName(): string;
  87530. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87531. }
  87532. }
  87533. declare module BABYLON {
  87534. /** @hidden */
  87535. export var skyPixelShader: {
  87536. name: string;
  87537. shader: string;
  87538. };
  87539. }
  87540. declare module BABYLON {
  87541. /** @hidden */
  87542. export var skyVertexShader: {
  87543. name: string;
  87544. shader: string;
  87545. };
  87546. }
  87547. declare module BABYLON {
  87548. /**
  87549. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87550. * @see https://doc.babylonjs.com/extensions/sky
  87551. */
  87552. export class SkyMaterial extends BABYLON.PushMaterial {
  87553. /**
  87554. * Defines the overall luminance of sky in interval ]0, 1[.
  87555. */
  87556. luminance: number;
  87557. /**
  87558. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87559. */
  87560. turbidity: number;
  87561. /**
  87562. * Defines the sky appearance (light intensity).
  87563. */
  87564. rayleigh: number;
  87565. /**
  87566. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87567. */
  87568. mieCoefficient: number;
  87569. /**
  87570. * Defines the amount of haze particles following the Mie scattering theory.
  87571. */
  87572. mieDirectionalG: number;
  87573. /**
  87574. * Defines the distance of the sun according to the active scene camera.
  87575. */
  87576. distance: number;
  87577. /**
  87578. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87579. * "inclined".
  87580. */
  87581. inclination: number;
  87582. /**
  87583. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87584. * an object direction and a reference direction.
  87585. */
  87586. azimuth: number;
  87587. /**
  87588. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87589. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87590. */
  87591. sunPosition: BABYLON.Vector3;
  87592. /**
  87593. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87594. * .sunPosition property.
  87595. */
  87596. useSunPosition: boolean;
  87597. /**
  87598. * Defines an offset vector used to get a horizon offset.
  87599. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87600. */
  87601. cameraOffset: BABYLON.Vector3;
  87602. private _cameraPosition;
  87603. /**
  87604. * Instantiates a new sky material.
  87605. * This material allows to create dynamic and texture free
  87606. * effects for skyboxes by taking care of the atmosphere state.
  87607. * @see https://doc.babylonjs.com/extensions/sky
  87608. * @param name Define the name of the material in the scene
  87609. * @param scene Define the scene the material belong to
  87610. */
  87611. constructor(name: string, scene: BABYLON.Scene);
  87612. /**
  87613. * Specifies if the material will require alpha blending
  87614. * @returns a boolean specifying if alpha blending is needed
  87615. */
  87616. needAlphaBlending(): boolean;
  87617. /**
  87618. * Specifies if this material should be rendered in alpha test mode
  87619. * @returns false as the sky material doesn't need alpha testing.
  87620. */
  87621. needAlphaTesting(): boolean;
  87622. /**
  87623. * Get the texture used for alpha test purpose.
  87624. * @returns null as the sky material has no texture.
  87625. */
  87626. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87627. /**
  87628. * Get if the submesh is ready to be used and all its information available.
  87629. * Child classes can use it to update shaders
  87630. * @param mesh defines the mesh to check
  87631. * @param subMesh defines which submesh to check
  87632. * @param useInstances specifies that instances should be used
  87633. * @returns a boolean indicating that the submesh is ready or not
  87634. */
  87635. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87636. /**
  87637. * Binds the submesh to this material by preparing the effect and shader to draw
  87638. * @param world defines the world transformation matrix
  87639. * @param mesh defines the mesh containing the submesh
  87640. * @param subMesh defines the submesh to bind the material to
  87641. */
  87642. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87643. /**
  87644. * Get the list of animatables in the material.
  87645. * @returns the list of animatables object used in the material
  87646. */
  87647. getAnimatables(): BABYLON.IAnimatable[];
  87648. /**
  87649. * Disposes the material
  87650. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87651. */
  87652. dispose(forceDisposeEffect?: boolean): void;
  87653. /**
  87654. * Makes a duplicate of the material, and gives it a new name
  87655. * @param name defines the new name for the duplicated material
  87656. * @returns the cloned material
  87657. */
  87658. clone(name: string): SkyMaterial;
  87659. /**
  87660. * Serializes this material in a JSON representation
  87661. * @returns the serialized material object
  87662. */
  87663. serialize(): any;
  87664. /**
  87665. * Gets the current class name of the material e.g. "SkyMaterial"
  87666. * Mainly use in serialization.
  87667. * @returns the class name
  87668. */
  87669. getClassName(): string;
  87670. /**
  87671. * Creates a sky material from parsed material data
  87672. * @param source defines the JSON representation of the material
  87673. * @param scene defines the hosting scene
  87674. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87675. * @returns a new sky material
  87676. */
  87677. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87678. }
  87679. }
  87680. declare module BABYLON {
  87681. /** @hidden */
  87682. export var terrainPixelShader: {
  87683. name: string;
  87684. shader: string;
  87685. };
  87686. }
  87687. declare module BABYLON {
  87688. /** @hidden */
  87689. export var terrainVertexShader: {
  87690. name: string;
  87691. shader: string;
  87692. };
  87693. }
  87694. declare module BABYLON {
  87695. export class TerrainMaterial extends BABYLON.PushMaterial {
  87696. private _mixTexture;
  87697. mixTexture: BABYLON.BaseTexture;
  87698. private _diffuseTexture1;
  87699. diffuseTexture1: BABYLON.Texture;
  87700. private _diffuseTexture2;
  87701. diffuseTexture2: BABYLON.Texture;
  87702. private _diffuseTexture3;
  87703. diffuseTexture3: BABYLON.Texture;
  87704. private _bumpTexture1;
  87705. bumpTexture1: BABYLON.Texture;
  87706. private _bumpTexture2;
  87707. bumpTexture2: BABYLON.Texture;
  87708. private _bumpTexture3;
  87709. bumpTexture3: BABYLON.Texture;
  87710. diffuseColor: BABYLON.Color3;
  87711. specularColor: BABYLON.Color3;
  87712. specularPower: number;
  87713. private _disableLighting;
  87714. disableLighting: boolean;
  87715. private _maxSimultaneousLights;
  87716. maxSimultaneousLights: number;
  87717. constructor(name: string, scene: BABYLON.Scene);
  87718. needAlphaBlending(): boolean;
  87719. needAlphaTesting(): boolean;
  87720. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87721. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87722. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87723. getAnimatables(): BABYLON.IAnimatable[];
  87724. getActiveTextures(): BABYLON.BaseTexture[];
  87725. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87726. dispose(forceDisposeEffect?: boolean): void;
  87727. clone(name: string): TerrainMaterial;
  87728. serialize(): any;
  87729. getClassName(): string;
  87730. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87731. }
  87732. }
  87733. declare module BABYLON {
  87734. /** @hidden */
  87735. export var triplanarPixelShader: {
  87736. name: string;
  87737. shader: string;
  87738. };
  87739. }
  87740. declare module BABYLON {
  87741. /** @hidden */
  87742. export var triplanarVertexShader: {
  87743. name: string;
  87744. shader: string;
  87745. };
  87746. }
  87747. declare module BABYLON {
  87748. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87749. mixTexture: BABYLON.BaseTexture;
  87750. private _diffuseTextureX;
  87751. diffuseTextureX: BABYLON.BaseTexture;
  87752. private _diffuseTextureY;
  87753. diffuseTextureY: BABYLON.BaseTexture;
  87754. private _diffuseTextureZ;
  87755. diffuseTextureZ: BABYLON.BaseTexture;
  87756. private _normalTextureX;
  87757. normalTextureX: BABYLON.BaseTexture;
  87758. private _normalTextureY;
  87759. normalTextureY: BABYLON.BaseTexture;
  87760. private _normalTextureZ;
  87761. normalTextureZ: BABYLON.BaseTexture;
  87762. tileSize: number;
  87763. diffuseColor: BABYLON.Color3;
  87764. specularColor: BABYLON.Color3;
  87765. specularPower: number;
  87766. private _disableLighting;
  87767. disableLighting: boolean;
  87768. private _maxSimultaneousLights;
  87769. maxSimultaneousLights: number;
  87770. constructor(name: string, scene: BABYLON.Scene);
  87771. needAlphaBlending(): boolean;
  87772. needAlphaTesting(): boolean;
  87773. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87774. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87775. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87776. getAnimatables(): BABYLON.IAnimatable[];
  87777. getActiveTextures(): BABYLON.BaseTexture[];
  87778. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87779. dispose(forceDisposeEffect?: boolean): void;
  87780. clone(name: string): TriPlanarMaterial;
  87781. serialize(): any;
  87782. getClassName(): string;
  87783. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87784. }
  87785. }
  87786. declare module BABYLON {
  87787. /** @hidden */
  87788. export var waterPixelShader: {
  87789. name: string;
  87790. shader: string;
  87791. };
  87792. }
  87793. declare module BABYLON {
  87794. /** @hidden */
  87795. export var waterVertexShader: {
  87796. name: string;
  87797. shader: string;
  87798. };
  87799. }
  87800. declare module BABYLON {
  87801. export class WaterMaterial extends BABYLON.PushMaterial {
  87802. renderTargetSize: BABYLON.Vector2;
  87803. private _bumpTexture;
  87804. bumpTexture: BABYLON.BaseTexture;
  87805. diffuseColor: BABYLON.Color3;
  87806. specularColor: BABYLON.Color3;
  87807. specularPower: number;
  87808. private _disableLighting;
  87809. disableLighting: boolean;
  87810. private _maxSimultaneousLights;
  87811. maxSimultaneousLights: number;
  87812. /**
  87813. * Defines the wind force.
  87814. */
  87815. windForce: number;
  87816. /**
  87817. * Defines the direction of the wind in the plane (X, Z).
  87818. */
  87819. windDirection: BABYLON.Vector2;
  87820. /**
  87821. * Defines the height of the waves.
  87822. */
  87823. waveHeight: number;
  87824. /**
  87825. * Defines the bump height related to the bump map.
  87826. */
  87827. bumpHeight: number;
  87828. /**
  87829. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87830. */
  87831. private _bumpSuperimpose;
  87832. bumpSuperimpose: boolean;
  87833. /**
  87834. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87835. */
  87836. private _fresnelSeparate;
  87837. fresnelSeparate: boolean;
  87838. /**
  87839. * Defines wether or not bump Wwves modify the reflection.
  87840. */
  87841. private _bumpAffectsReflection;
  87842. bumpAffectsReflection: boolean;
  87843. /**
  87844. * Defines the water color blended with the refraction (near).
  87845. */
  87846. waterColor: BABYLON.Color3;
  87847. /**
  87848. * Defines the blend factor related to the water color.
  87849. */
  87850. colorBlendFactor: number;
  87851. /**
  87852. * Defines the water color blended with the reflection (far).
  87853. */
  87854. waterColor2: BABYLON.Color3;
  87855. /**
  87856. * Defines the blend factor related to the water color (reflection, far).
  87857. */
  87858. colorBlendFactor2: number;
  87859. /**
  87860. * Defines the maximum length of a wave.
  87861. */
  87862. waveLength: number;
  87863. /**
  87864. * Defines the waves speed.
  87865. */
  87866. waveSpeed: number;
  87867. /**
  87868. * 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.
  87869. */
  87870. waveCount: number;
  87871. /**
  87872. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87873. * will avoid calculating useless pixels in the pixel shader of the water material.
  87874. */
  87875. disableClipPlane: boolean;
  87876. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87877. private _mesh;
  87878. private _refractionRTT;
  87879. private _reflectionRTT;
  87880. private _reflectionTransform;
  87881. private _lastTime;
  87882. private _lastDeltaTime;
  87883. private _useLogarithmicDepth;
  87884. private _waitingRenderList;
  87885. private _imageProcessingConfiguration;
  87886. private _imageProcessingObserver;
  87887. /**
  87888. * Gets a boolean indicating that current material needs to register RTT
  87889. */
  87890. get hasRenderTargetTextures(): boolean;
  87891. /**
  87892. * Constructor
  87893. */
  87894. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87895. get useLogarithmicDepth(): boolean;
  87896. set useLogarithmicDepth(value: boolean);
  87897. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87898. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87899. addToRenderList(node: any): void;
  87900. enableRenderTargets(enable: boolean): void;
  87901. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87902. get renderTargetsEnabled(): boolean;
  87903. needAlphaBlending(): boolean;
  87904. needAlphaTesting(): boolean;
  87905. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87906. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87907. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87908. private _createRenderTargets;
  87909. getAnimatables(): BABYLON.IAnimatable[];
  87910. getActiveTextures(): BABYLON.BaseTexture[];
  87911. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87912. dispose(forceDisposeEffect?: boolean): void;
  87913. clone(name: string): WaterMaterial;
  87914. serialize(): any;
  87915. getClassName(): string;
  87916. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87917. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87918. }
  87919. }
  87920. declare module BABYLON {
  87921. /** @hidden */
  87922. export var asciiartPixelShader: {
  87923. name: string;
  87924. shader: string;
  87925. };
  87926. }
  87927. declare module BABYLON {
  87928. /**
  87929. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87930. *
  87931. * It basically takes care rendering the font front the given font size to a texture.
  87932. * This is used later on in the postprocess.
  87933. */
  87934. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87935. private _font;
  87936. private _text;
  87937. private _charSize;
  87938. /**
  87939. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87940. */
  87941. get charSize(): number;
  87942. /**
  87943. * Create a new instance of the Ascii Art FontTexture class
  87944. * @param name the name of the texture
  87945. * @param font the font to use, use the W3C CSS notation
  87946. * @param text the caracter set to use in the rendering.
  87947. * @param scene the scene that owns the texture
  87948. */
  87949. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87950. /**
  87951. * Gets the max char width of a font.
  87952. * @param font the font to use, use the W3C CSS notation
  87953. * @return the max char width
  87954. */
  87955. private getFontWidth;
  87956. /**
  87957. * Gets the max char height of a font.
  87958. * @param font the font to use, use the W3C CSS notation
  87959. * @return the max char height
  87960. */
  87961. private getFontHeight;
  87962. /**
  87963. * Clones the current AsciiArtTexture.
  87964. * @return the clone of the texture.
  87965. */
  87966. clone(): AsciiArtFontTexture;
  87967. /**
  87968. * Parses a json object representing the texture and returns an instance of it.
  87969. * @param source the source JSON representation
  87970. * @param scene the scene to create the texture for
  87971. * @return the parsed texture
  87972. */
  87973. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87974. }
  87975. /**
  87976. * Option available in the Ascii Art Post Process.
  87977. */
  87978. export interface IAsciiArtPostProcessOptions {
  87979. /**
  87980. * The font to use following the w3c font definition.
  87981. */
  87982. font?: string;
  87983. /**
  87984. * The character set to use in the postprocess.
  87985. */
  87986. characterSet?: string;
  87987. /**
  87988. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87989. * This number is defined between 0 and 1;
  87990. */
  87991. mixToTile?: number;
  87992. /**
  87993. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87994. * This number is defined between 0 and 1;
  87995. */
  87996. mixToNormal?: number;
  87997. }
  87998. /**
  87999. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  88000. *
  88001. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88002. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  88003. */
  88004. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  88005. /**
  88006. * The font texture used to render the char in the post process.
  88007. */
  88008. private _asciiArtFontTexture;
  88009. /**
  88010. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88011. * This number is defined between 0 and 1;
  88012. */
  88013. mixToTile: number;
  88014. /**
  88015. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88016. * This number is defined between 0 and 1;
  88017. */
  88018. mixToNormal: number;
  88019. /**
  88020. * Instantiates a new Ascii Art Post Process.
  88021. * @param name the name to give to the postprocess
  88022. * @camera the camera to apply the post process to.
  88023. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  88024. */
  88025. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  88026. }
  88027. }
  88028. declare module BABYLON {
  88029. /** @hidden */
  88030. export var digitalrainPixelShader: {
  88031. name: string;
  88032. shader: string;
  88033. };
  88034. }
  88035. declare module BABYLON {
  88036. /**
  88037. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  88038. *
  88039. * It basically takes care rendering the font front the given font size to a texture.
  88040. * This is used later on in the postprocess.
  88041. */
  88042. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  88043. private _font;
  88044. private _text;
  88045. private _charSize;
  88046. /**
  88047. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88048. */
  88049. get charSize(): number;
  88050. /**
  88051. * Create a new instance of the Digital Rain FontTexture class
  88052. * @param name the name of the texture
  88053. * @param font the font to use, use the W3C CSS notation
  88054. * @param text the caracter set to use in the rendering.
  88055. * @param scene the scene that owns the texture
  88056. */
  88057. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88058. /**
  88059. * Gets the max char width of a font.
  88060. * @param font the font to use, use the W3C CSS notation
  88061. * @return the max char width
  88062. */
  88063. private getFontWidth;
  88064. /**
  88065. * Gets the max char height of a font.
  88066. * @param font the font to use, use the W3C CSS notation
  88067. * @return the max char height
  88068. */
  88069. private getFontHeight;
  88070. /**
  88071. * Clones the current DigitalRainFontTexture.
  88072. * @return the clone of the texture.
  88073. */
  88074. clone(): DigitalRainFontTexture;
  88075. /**
  88076. * Parses a json object representing the texture and returns an instance of it.
  88077. * @param source the source JSON representation
  88078. * @param scene the scene to create the texture for
  88079. * @return the parsed texture
  88080. */
  88081. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  88082. }
  88083. /**
  88084. * Option available in the Digital Rain Post Process.
  88085. */
  88086. export interface IDigitalRainPostProcessOptions {
  88087. /**
  88088. * The font to use following the w3c font definition.
  88089. */
  88090. font?: string;
  88091. /**
  88092. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88093. * This number is defined between 0 and 1;
  88094. */
  88095. mixToTile?: number;
  88096. /**
  88097. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88098. * This number is defined between 0 and 1;
  88099. */
  88100. mixToNormal?: number;
  88101. }
  88102. /**
  88103. * DigitalRainPostProcess helps rendering everithing in digital rain.
  88104. *
  88105. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88106. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  88107. */
  88108. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  88109. /**
  88110. * The font texture used to render the char in the post process.
  88111. */
  88112. private _digitalRainFontTexture;
  88113. /**
  88114. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88115. * This number is defined between 0 and 1;
  88116. */
  88117. mixToTile: number;
  88118. /**
  88119. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88120. * This number is defined between 0 and 1;
  88121. */
  88122. mixToNormal: number;
  88123. /**
  88124. * Instantiates a new Digital Rain Post Process.
  88125. * @param name the name to give to the postprocess
  88126. * @camera the camera to apply the post process to.
  88127. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  88128. */
  88129. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  88130. }
  88131. }
  88132. declare module BABYLON {
  88133. /** @hidden */
  88134. export var brickProceduralTexturePixelShader: {
  88135. name: string;
  88136. shader: string;
  88137. };
  88138. }
  88139. declare module BABYLON {
  88140. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  88141. private _numberOfBricksHeight;
  88142. private _numberOfBricksWidth;
  88143. private _jointColor;
  88144. private _brickColor;
  88145. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88146. updateShaderUniforms(): void;
  88147. get numberOfBricksHeight(): number;
  88148. set numberOfBricksHeight(value: number);
  88149. get numberOfBricksWidth(): number;
  88150. set numberOfBricksWidth(value: number);
  88151. get jointColor(): BABYLON.Color3;
  88152. set jointColor(value: BABYLON.Color3);
  88153. get brickColor(): BABYLON.Color3;
  88154. set brickColor(value: BABYLON.Color3);
  88155. /**
  88156. * Serializes this brick procedural texture
  88157. * @returns a serialized brick procedural texture object
  88158. */
  88159. serialize(): any;
  88160. /**
  88161. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  88162. * @param parsedTexture defines parsed texture data
  88163. * @param scene defines the current scene
  88164. * @param rootUrl defines the root URL containing brick procedural texture information
  88165. * @returns a parsed Brick Procedural BABYLON.Texture
  88166. */
  88167. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  88168. }
  88169. }
  88170. declare module BABYLON {
  88171. /** @hidden */
  88172. export var cloudProceduralTexturePixelShader: {
  88173. name: string;
  88174. shader: string;
  88175. };
  88176. }
  88177. declare module BABYLON {
  88178. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  88179. private _skyColor;
  88180. private _cloudColor;
  88181. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88182. updateShaderUniforms(): void;
  88183. get skyColor(): BABYLON.Color4;
  88184. set skyColor(value: BABYLON.Color4);
  88185. get cloudColor(): BABYLON.Color4;
  88186. set cloudColor(value: BABYLON.Color4);
  88187. /**
  88188. * Serializes this cloud procedural texture
  88189. * @returns a serialized cloud procedural texture object
  88190. */
  88191. serialize(): any;
  88192. /**
  88193. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  88194. * @param parsedTexture defines parsed texture data
  88195. * @param scene defines the current scene
  88196. * @param rootUrl defines the root URL containing cloud procedural texture information
  88197. * @returns a parsed Cloud Procedural BABYLON.Texture
  88198. */
  88199. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  88200. }
  88201. }
  88202. declare module BABYLON {
  88203. /** @hidden */
  88204. export var fireProceduralTexturePixelShader: {
  88205. name: string;
  88206. shader: string;
  88207. };
  88208. }
  88209. declare module BABYLON {
  88210. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  88211. private _time;
  88212. private _speed;
  88213. private _autoGenerateTime;
  88214. private _fireColors;
  88215. private _alphaThreshold;
  88216. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88217. updateShaderUniforms(): void;
  88218. render(useCameraPostProcess?: boolean): void;
  88219. static get PurpleFireColors(): BABYLON.Color3[];
  88220. static get GreenFireColors(): BABYLON.Color3[];
  88221. static get RedFireColors(): BABYLON.Color3[];
  88222. static get BlueFireColors(): BABYLON.Color3[];
  88223. get autoGenerateTime(): boolean;
  88224. set autoGenerateTime(value: boolean);
  88225. get fireColors(): BABYLON.Color3[];
  88226. set fireColors(value: BABYLON.Color3[]);
  88227. get time(): number;
  88228. set time(value: number);
  88229. get speed(): BABYLON.Vector2;
  88230. set speed(value: BABYLON.Vector2);
  88231. get alphaThreshold(): number;
  88232. set alphaThreshold(value: number);
  88233. /**
  88234. * Serializes this fire procedural texture
  88235. * @returns a serialized fire procedural texture object
  88236. */
  88237. serialize(): any;
  88238. /**
  88239. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  88240. * @param parsedTexture defines parsed texture data
  88241. * @param scene defines the current scene
  88242. * @param rootUrl defines the root URL containing fire procedural texture information
  88243. * @returns a parsed Fire Procedural BABYLON.Texture
  88244. */
  88245. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  88246. }
  88247. }
  88248. declare module BABYLON {
  88249. /** @hidden */
  88250. export var grassProceduralTexturePixelShader: {
  88251. name: string;
  88252. shader: string;
  88253. };
  88254. }
  88255. declare module BABYLON {
  88256. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88257. private _grassColors;
  88258. private _groundColor;
  88259. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88260. updateShaderUniforms(): void;
  88261. get grassColors(): BABYLON.Color3[];
  88262. set grassColors(value: BABYLON.Color3[]);
  88263. get groundColor(): BABYLON.Color3;
  88264. set groundColor(value: BABYLON.Color3);
  88265. /**
  88266. * Serializes this grass procedural texture
  88267. * @returns a serialized grass procedural texture object
  88268. */
  88269. serialize(): any;
  88270. /**
  88271. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88272. * @param parsedTexture defines parsed texture data
  88273. * @param scene defines the current scene
  88274. * @param rootUrl defines the root URL containing grass procedural texture information
  88275. * @returns a parsed Grass Procedural BABYLON.Texture
  88276. */
  88277. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88278. }
  88279. }
  88280. declare module BABYLON {
  88281. /** @hidden */
  88282. export var marbleProceduralTexturePixelShader: {
  88283. name: string;
  88284. shader: string;
  88285. };
  88286. }
  88287. declare module BABYLON {
  88288. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88289. private _numberOfTilesHeight;
  88290. private _numberOfTilesWidth;
  88291. private _amplitude;
  88292. private _jointColor;
  88293. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88294. updateShaderUniforms(): void;
  88295. get numberOfTilesHeight(): number;
  88296. set numberOfTilesHeight(value: number);
  88297. get amplitude(): number;
  88298. set amplitude(value: number);
  88299. get numberOfTilesWidth(): number;
  88300. set numberOfTilesWidth(value: number);
  88301. get jointColor(): BABYLON.Color3;
  88302. set jointColor(value: BABYLON.Color3);
  88303. /**
  88304. * Serializes this marble procedural texture
  88305. * @returns a serialized marble procedural texture object
  88306. */
  88307. serialize(): any;
  88308. /**
  88309. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88310. * @param parsedTexture defines parsed texture data
  88311. * @param scene defines the current scene
  88312. * @param rootUrl defines the root URL containing marble procedural texture information
  88313. * @returns a parsed Marble Procedural BABYLON.Texture
  88314. */
  88315. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88316. }
  88317. }
  88318. declare module BABYLON {
  88319. /** @hidden */
  88320. export var normalMapProceduralTexturePixelShader: {
  88321. name: string;
  88322. shader: string;
  88323. };
  88324. }
  88325. declare module BABYLON {
  88326. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88327. private _baseTexture;
  88328. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88329. updateShaderUniforms(): void;
  88330. render(useCameraPostProcess?: boolean): void;
  88331. resize(size: any, generateMipMaps: any): void;
  88332. get baseTexture(): BABYLON.Texture;
  88333. set baseTexture(texture: BABYLON.Texture);
  88334. /**
  88335. * Serializes this normal map procedural texture
  88336. * @returns a serialized normal map procedural texture object
  88337. */
  88338. serialize(): any;
  88339. /**
  88340. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88341. * @param parsedTexture defines parsed texture data
  88342. * @param scene defines the current scene
  88343. * @param rootUrl defines the root URL containing normal map procedural texture information
  88344. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88345. */
  88346. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88347. }
  88348. }
  88349. declare module BABYLON {
  88350. /** @hidden */
  88351. export var perlinNoiseProceduralTexturePixelShader: {
  88352. name: string;
  88353. shader: string;
  88354. };
  88355. }
  88356. declare module BABYLON {
  88357. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88358. time: number;
  88359. timeScale: number;
  88360. translationSpeed: number;
  88361. private _currentTranslation;
  88362. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88363. updateShaderUniforms(): void;
  88364. render(useCameraPostProcess?: boolean): void;
  88365. resize(size: any, generateMipMaps: any): void;
  88366. /**
  88367. * Serializes this perlin noise procedural texture
  88368. * @returns a serialized perlin noise procedural texture object
  88369. */
  88370. serialize(): any;
  88371. /**
  88372. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88373. * @param parsedTexture defines parsed texture data
  88374. * @param scene defines the current scene
  88375. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88376. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88377. */
  88378. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88379. }
  88380. }
  88381. declare module BABYLON {
  88382. /** @hidden */
  88383. export var roadProceduralTexturePixelShader: {
  88384. name: string;
  88385. shader: string;
  88386. };
  88387. }
  88388. declare module BABYLON {
  88389. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88390. private _roadColor;
  88391. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88392. updateShaderUniforms(): void;
  88393. get roadColor(): BABYLON.Color3;
  88394. set roadColor(value: BABYLON.Color3);
  88395. /**
  88396. * Serializes this road procedural texture
  88397. * @returns a serialized road procedural texture object
  88398. */
  88399. serialize(): any;
  88400. /**
  88401. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88402. * @param parsedTexture defines parsed texture data
  88403. * @param scene defines the current scene
  88404. * @param rootUrl defines the root URL containing road procedural texture information
  88405. * @returns a parsed Road Procedural BABYLON.Texture
  88406. */
  88407. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88408. }
  88409. }
  88410. declare module BABYLON {
  88411. /** @hidden */
  88412. export var starfieldProceduralTexturePixelShader: {
  88413. name: string;
  88414. shader: string;
  88415. };
  88416. }
  88417. declare module BABYLON {
  88418. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88419. private _time;
  88420. private _alpha;
  88421. private _beta;
  88422. private _zoom;
  88423. private _formuparam;
  88424. private _stepsize;
  88425. private _tile;
  88426. private _brightness;
  88427. private _darkmatter;
  88428. private _distfading;
  88429. private _saturation;
  88430. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88431. updateShaderUniforms(): void;
  88432. get time(): number;
  88433. set time(value: number);
  88434. get alpha(): number;
  88435. set alpha(value: number);
  88436. get beta(): number;
  88437. set beta(value: number);
  88438. get formuparam(): number;
  88439. set formuparam(value: number);
  88440. get stepsize(): number;
  88441. set stepsize(value: number);
  88442. get zoom(): number;
  88443. set zoom(value: number);
  88444. get tile(): number;
  88445. set tile(value: number);
  88446. get brightness(): number;
  88447. set brightness(value: number);
  88448. get darkmatter(): number;
  88449. set darkmatter(value: number);
  88450. get distfading(): number;
  88451. set distfading(value: number);
  88452. get saturation(): number;
  88453. set saturation(value: number);
  88454. /**
  88455. * Serializes this starfield procedural texture
  88456. * @returns a serialized starfield procedural texture object
  88457. */
  88458. serialize(): any;
  88459. /**
  88460. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88461. * @param parsedTexture defines parsed texture data
  88462. * @param scene defines the current scene
  88463. * @param rootUrl defines the root URL containing startfield procedural texture information
  88464. * @returns a parsed Starfield Procedural BABYLON.Texture
  88465. */
  88466. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88467. }
  88468. }
  88469. declare module BABYLON {
  88470. /** @hidden */
  88471. export var woodProceduralTexturePixelShader: {
  88472. name: string;
  88473. shader: string;
  88474. };
  88475. }
  88476. declare module BABYLON {
  88477. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88478. private _ampScale;
  88479. private _woodColor;
  88480. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88481. updateShaderUniforms(): void;
  88482. get ampScale(): number;
  88483. set ampScale(value: number);
  88484. get woodColor(): BABYLON.Color3;
  88485. set woodColor(value: BABYLON.Color3);
  88486. /**
  88487. * Serializes this wood procedural texture
  88488. * @returns a serialized wood procedural texture object
  88489. */
  88490. serialize(): any;
  88491. /**
  88492. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88493. * @param parsedTexture defines parsed texture data
  88494. * @param scene defines the current scene
  88495. * @param rootUrl defines the root URL containing wood procedural texture information
  88496. * @returns a parsed Wood Procedural BABYLON.Texture
  88497. */
  88498. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88499. }
  88500. }